--- /dev/null
+# -*- coding: utf-8 -*-
+
+import platform
+
+class BBSFakeUserEnv(object):
+ _user = ""
+ _node = ""
+ _name = ""
+ _hideRealUname = False
+
+ def setUser(self, _user):
+ self._user = _user
+
+ def getUser(self):
+ return self._user
+
+ def getNode(self):
+ return self._node
+
+ def getName(self):
+ return self._name
+
+ def setHideRealUname(self, _hideRealUname):
+ self._hideRealUname = _hideRealUname
+
+ def getHome(self):
+ return "/usr/home/" + self.getUser()
+
+ def getUName(self):
+ if not self._hideRealUname:
+ return platform.uname()[0]+" "+platform.uname()[1]+" "+platform.uname()[2]
+ else:
+ return "Linux "+self.getNode()+" 0.13.37-42"
+
+ def __init__(self):
+ self._user = "doctor_who"
+ self._node = platform.node()
+ #self._node = platform.uname()[1]
+ self._name = "I am the Doctor!"
+
--- /dev/null
+#!/usr/bin/env python3
+# -*- coding: utf-8 -*-
+#
+# Minimal Shell
+# Use whenever a user should be able to launch a shell,
+# but not to execute commands.
+#
+# Copyright (c) 2013-2015 Malte Bublitz.
+# All rights reserved.
+#
+# Licensed under the terms of the 2-clause BSD license.
+# See LICENSE for details.
+#
+
+import platform
+import os
+import sys
+import getpass
+
+os.chdir(os.path.dirname(sys.argv[0]))
+
+import bbs_env
+import bofh
+
+def getuser():
+ return "doctorwho"
+
+def login(prompt1="login: ", prompt2="Password: "):
+ login_data = ["", ""]
+ while len(login_data[0]) < 2:
+ login_data[0] = input(prompt1)
+
+ login_data[1] = getpass.getpass(prompt2)
+
+ return login_data
+
+def main():
+ env = bbs_env.BBSFakeUserEnv()
+ commands_allowed = (
+ "",
+ "exit",
+ "logout",
+ "help",
+ "whoami",
+ "id",
+ "hostname",
+ "pwd",
+ "uname",
+ "clear",
+ "sry"
+ )
+ command = ""
+
+ # Log in
+ env._user = login()[0]
+ env.setHideRealUname(True)
+
+ print("\nWelcome on "+env.getNode()+", "+env.getUser()+"!\n")
+
+ try:
+ while command != "exit":
+ print("$ ",end="")
+ try:
+ command = input()
+
+ except KeyboardInterrupt:
+ print("")
+ continue
+
+ if command == "logout" or command == "exit":
+ command = "exit"
+
+ elif command == "help":
+ print("""Minimal Shell Help
+Commands:
+ whoami
+ id
+ hostname
+ pwd
+ uname
+ clear
+ help
+ logout/exit
+""")
+ elif command == "whoami":
+ if not env.getUser() in ["doctor", "doctorwho", "doctor_who"]:
+ print(env.getUser())
+ else:
+ #print("I am the Doctor!")
+ print(env.getName())
+ print("")
+ print("I should behave politely, so maybe excuse for")
+ print("future mistakes with \"sry\" (Yes, an easter egg!)")
+ print("")
+
+ elif command == "id":
+ print("uid=42(" + env.getUser() + ") gid=100(users) groups=42(" + env.getUser() + "),9999(telnet)")
+
+ elif command == "hostname":
+ print(env.getNode())
+
+ elif command == "pwd":
+ # print("/usr/home/"+getuser())
+ print(env.getHome())
+
+ elif command == "uname":
+ print(env.getUName())
+
+ elif command == "clear":
+ ret_code = os.system("clear")
+
+ elif command == "sry" or command == "bofh":
+ print("<BOFH> "+bofh.get_excuse())
+
+ #elif not command in commands_allowed:
+ # print("-minishell: "+command.split(" ")[0]+": Command not found.")
+ elif len(command) > 0:
+ print("-minishell: "+command.split(" ")[0]+": Command not found.")
+
+ except EOFError:
+ print("<EOF>")
+
+ print("Good bye.")
+
+if __name__ == "__main__":
+ main()
+