Lightens passwd & adduser procedures logic

This commit is contained in:
HorlogeSkynet 2017-04-28 17:39:10 +02:00
parent 5c5e8257e7
commit 8d86909f87

@ -407,29 +407,21 @@ if __name__ == '__main__':
password_2 = input("\nRetype the password: ")
if len(password_1) == 0 or password_1 != password_2:
print(Fore.RED + "\nPasswords do not match (or are empty ?)..." + Fore.RESET)
print(Fore.RED + "\n\nPasswords do not match (or are empty ?)..." + Fore.RESET, end='')
sendData(sock, 'ABORTED', clientSendErrHandler)
else:
print('\n')
sendData(sock, 'USER_PASSWORD:' + password_1, clientSendErrHandler)
result = recvData(sock, clientRecvErrHandler)
if not result:
print(Fore.RED + "\nThe connection with the server has been closed, let\'s close the client !\n" + Fore.RESET)
quit()
else:
print(result + '\n')
except:
sendData(sock, 'ABORTED', clientSendErrHandler)
print('\n' + recvData(sock, clientRecvErrHandler) + '\n')
finally:
attributes[3] = attributes[3] | termios.ECHO
termios.tcsetattr(sys.stdin.fileno(), termios.TCSADRAIN, attributes)
print('\n\n' + recvData(sock, clientRecvErrHandler) + '\n')
elif data == 'CHANGE_PASSWD_PROCEDURE':
attributes = termios.tcgetattr(sys.stdin.fileno())
attributes[3] = attributes[3] & ~termios.ECHO
@ -441,42 +433,31 @@ if __name__ == '__main__':
sendData(sock, 'OLD_PASSWORD:' + oldPassword, clientSendErrHandler)
result = recvData(sock, clientRecvErrHandler)
if not result or result != 'OLD_PASSWORD_OK':
if not result:
print(Fore.RED + "\nThe connection with the server has been closed, let\'s close the client !\n" + Fore.RESET)
quit()
else:
print('\n' + result + '\n')
if result != 'OLD_PASSWORD_OK':
print('\n\n' + result + '\n')
else:
newPassword_1 = input("\nEnter new password: ")
newPassword_2 = input("\nRetype new password: ")
if len(newPassword_1) == 0 or newPassword_1 != newPassword_2:
print(Fore.RED + "\nPasswords do not match (or are empty ?)..." + Fore.RESET)
print(Fore.RED + "\n\nPasswords do not match (or are empty ?)..." + Fore.RESET, end='')
sendData(sock, 'ABORTED', clientSendErrHandler)
else:
print('\n')
sendData(sock, 'NEW_PASSWORD:' + newPassword_1, clientSendErrHandler)
result = recvData(sock, clientRecvErrHandler)
if not result:
print(Fore.RED + "\nThe connection with the server has been closed, let\'s close the client !\n" + Fore.RESET)
quit()
else:
print(result + '\n')
except:
sendData(sock, 'ABORTED', clientSendErrHandler)
print('\n' + recvData(sock, clientRecvErrHandler) + '\n')
finally:
attributes[3] = attributes[3] | termios.ECHO
termios.tcsetattr(sys.stdin.fileno(), termios.TCSADRAIN, attributes)
# Tricky part: in one case we don't have to receive any message from server...
if result == 'OLD_PASSWORD_OK':
print('\n\n' + recvData(sock, clientRecvErrHandler) + '\n')
elif data.startswith('VNCSERVER_RUNNING:'):
if not os.path.exists('VNC/bin/VNCClient'):
print(Fore.RED + "\nVNC module is not available on your system.\n" + Fore.RESET)