Created
May 29, 2018 05:49
-
-
Save davidsaccavino/874a3caa86a20503d9d6f0007b7474c6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! python 3 | |
# unix.py - authentication app | |
username = input('What\'s your username? ') | |
password = input('What\'s your password? ') | |
users = { | |
david = { | |
'power' : 'superuser', | |
'loggedin' : 0 | |
} | |
} | |
def interp(inpvars): | |
i = 0 | |
funcToCall = '' | |
for inpvar in range(inpvars.count(' ') + 1): | |
if not (' ' in inpvars): | |
if inpvars in cmdList: | |
cmdList[inpvars]() | |
i += 1 | |
def helpF(): | |
print(' '.join(cmdList)) | |
def power(user): | |
return user['power'] | |
def ls(): | |
print('placeholder\n') | |
def cd(): | |
print('placeholder\n') | |
def logout(): | |
user = currentUser | |
user['loggedin'] = 0 | |
cmdList = { | |
'power' : power, | |
'help' : helpF, | |
'cd' : cd, | |
'ls' : ls, | |
'logout' : logout} | |
if username == 'david': | |
if password == 'yo': | |
currentUser = 'david' | |
david['loggedin'] = 1 | |
print('Hello, administrator.\n') | |
print('Type \'help\' for help.\n') | |
while david['loggedin'] == 1: | |
cmd1 = input() | |
interp(cmd1) | |
else: | |
print('Fuck off, loser.\n') | |
elif username == 'camical': | |
if password == 'idon\'tcare03': | |
cmd1 = input('Type \'help\' for help.\n') | |
interp(cmd1) | |
else: | |
print('Fuck off, loser.\n') | |
else: | |
print('User doesn\'t exist.\n') | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment