def main(): # check for root privilege if not (os.getuid() == 0): print('Require the permission of root!') exit(-1) um = usermgr.UserMgr() login_info = [] # test whether user info is empty if (um.get_user_number() == 0): choice = raw_input( 'No user conf file found, creat a new one?\n<Y/N>: ') if choice == 'y' or choice == 'Y': login_info = prompt_user_info() um.create_user(login_info) else: exit(-1) else: users_info = um.get_users_info() # print menu print '0. Create/Modify user info' for i in range(len(users_info)): print i + 1, users_info[i] while True: try: choice = int(raw_input('Your choice: ')) except ValueError: print 'Please input a valid number!' else: break # chioce to add/modify a user if (choice == 0): login_info = prompt_user_info() try: um.create_user(login_info) print 'Create user info Successfully!' except ConfigParser.DuplicateSectionError: um.update_user_info(login_info) print 'Update user info Successfully!' else: login_info = um.get_user_info(choice - 1) # change mac address for binding mac user macaddr = login_info[3] if macaddr != 'default': line_of_mac = macmgr.get_line_of_mac("'wan'") if macaddr not in line_of_mac: macmgr.change_mac("'wan'", macaddr) macmgr.apply_mac() # TODO: delete the following line login_info_new = login_info[0:3] oh3c = eapauth.EAPAuth(login_info_new) oh3c.serve_forever()
def main(): login_info = sys.argv[1:] # change mac address for binding mac user macaddr = login_info[3] if macaddr != "default": line_of_mac = macmgr.get_line_of_mac("'wan'") if macaddr not in line_of_mac: macmgr.change_mac("'wan'", macaddr) macmgr.apply_mac() # TODO: delete the following line login_info_new = login_info[0:3] oh3c = eapauth.EAPAuth(login_info_new) oh3c.serve_forever()
def main(): login_info = sys.argv[1:] # change mac address for binding mac user macaddr = login_info[3] if macaddr != 'default': line_of_mac = macmgr.get_line_of_mac("'wan'") if macaddr not in line_of_mac: macmgr.change_mac("'wan'", macaddr) macmgr.apply_mac() # TODO: delete the following line login_info_new = login_info[0:3] oh3c = eapauth.EAPAuth(login_info_new) oh3c.serve_forever()
def main(): # check for root privilege if not (os.getuid() == 0): print ('Require the permission of root!') exit(-1) um = usermgr.UserMgr() login_info = [] # test whether user info is empty if (um.get_user_number() == 0): choice = raw_input('No user conf file found, creat a new one?\n<Y/N>: ') if choice == 'y' or choice == 'Y': login_info = prompt_user_info() um.create_user(login_info) else: exit(-1) else: users_info = um.get_users_info() # print menu print '0. Create/Modify user info' for i in range(len(users_info)): print i+1, users_info[i] while True: try: choice = int(raw_input('Your choice: ')) except ValueError: print 'Please input a valid number!' else: break; # chioce to add/modify a user if (choice == 0): login_info = prompt_user_info() try: um.create_user(login_info) print 'Create user info Successfully!' except ConfigParser.DuplicateSectionError: um.update_user_info(login_info) print 'Update user info Successfully!' else: login_info = um.get_user_info(choice-1) # change mac address for binding mac user macaddr = login_info[3] if macaddr != 'default': line_of_mac = macmgr.get_line_of_mac("'wan'") if macaddr not in line_of_mac: macmgr.change_mac("'wan'",macaddr) macmgr.apply_mac() # TODO: delete the following line login_info_new = login_info[0:3] oh3c = eapauth.EAPAuth(login_info_new) oh3c.serve_forever()
def main(): # check for root privilege if not (os.getuid() == 0): print ('Require the permission of root !') exit() um = usermgr.UserMgr() login_info = [] # test whether user info is empty if (um.get_user_number() == 0): try: choice = raw_input('No user conf file found, creat a new one ?\n<Y/N>: ') if choice == 'y' or choice == 'Y': login_info = prompt_user_info() um.create_user(login_info) except KeyboardInterrupt: print ' Cancel by user !' exit() else: exit() else: users_info = um.get_users_info() # print menu print '\na Add/Modify user info\nd Delete a user info\n------' for i in range(len(users_info)): print i+1, users_info[i] while True: try: choice = raw_input('Your choice(Ctrl + C to cancel): ') except KeyboardInterrupt: print ' Cancel by user !' exit() # chioce to add/modify a user if (choice == 'a'): login_info = prompt_user_info() try: um.create_user(login_info) print 'Create the user successfully !' except ConfigParser.DuplicateSectionError: um.update_user_info(login_info) print 'Modify the user info successfully !' exit() # chioce to delete a user if (choice == 'd'): username = prompt_user_name() if username in um.get_users_list(): um.delete_user(username) print 'Delete user "'+username+'" successfully !' exit() else: print 'Not found user named '+username+' !' if choice != 'a' and choice != 'd': try: login_info = um.get_user_info(int(choice)-1) break except: print 'Please input a valid option !' # change mac address for binding mac user macaddr = login_info[3] if macaddr != 'default': line_of_mac = macmgr.get_line_of_mac("'wan'") if macaddr not in line_of_mac: macmgr.change_mac("'wan'",macaddr) macmgr.apply_mac() # TODO: delete the following line login_info_new = login_info[0:3] oh3c = eapauth.EAPAuth(login_info_new) oh3c.serve_forever()