def run(self): # read the registration request from the connected client. try: data = self.sock.recv(1024) data = data.rstrip("\n") except: msg = "[!] connection closed: " + self.sock.getpeername()[0] self.console_log(msg) self.sock.close() return try: (module, project, username, password) = data.split(":::") except: return msg = "[*] %s registration request for project '%s' from %s" % ( module, project, username) self.console_log(msg) # validate the username and password. um = user_manager() try: um.validate(username, password) except serverx, x: self.console_log("[!] registration failed: " + x.msg()) self.sock.sendall("0:::" + x.msg()) self.sock.close() return
def run(self): # read the registration request from the connected client. try: data = self.sock.recv(1024) data = data.rstrip("\n") except: msg = "[!] connection closed: " + self.sock.getpeername()[0] self.console_log(msg) self.sock.close() return try: (module, project, username, password) = data.split(":::") except: return msg = "[*] %s registration request for project '%s' from %s" % (module, project, username) self.console_log(msg) # validate the username and password. um = user_manager() try: um.validate(username, password) except serverx, x: self.console_log("[!] registration failed: " + x.msg()) self.sock.sendall("0:::" + x.msg()) self.sock.close() return
from serverx import * try: command = sys.argv[1] if (command != "list"): username = sys.argv[2] except: print "usage: users [add|delete|validate <username>] [list]" sys.exit(1) if (command == "add"): password = getpass.getpass("password> ") realname = raw_input("realname> ") um = user_manager() try: um.add(username, password, realname) except serverx, x: print x sys.exit(1) elif (command == "delete"): um = user_manager() try: um.delete(username) except serverx, x: print x sys.exit(1)
from serverx import * try: command = sys.argv[1] if command != "list": username = sys.argv[2] except: print "usage: users [add|delete|validate <username>] [list]" sys.exit(1) if command == "add": password = getpass.getpass("password> ") realname = raw_input("realname> ") um = user_manager() try: um.add(username, password, realname) except serverx, x: print x sys.exit(1) elif command == "delete": um = user_manager() try: um.delete(username) except serverx, x: print x sys.exit(1)