sss_obfuscate revision 11496692da75a330de01d5f15b7183d2439efd3c
8d00718b943ab8b326320feb50820f0663031817Stephen Gallagher parser.set_description("sss_obfuscate converts a given password into \
8d00718b943ab8b326320feb50820f0663031817Stephen Gallagher human-unreadable format and places it into \
8d00718b943ab8b326320feb50820f0663031817Stephen Gallagher appropriate domain section of the SSSD config \
8d00718b943ab8b326320feb50820f0663031817Stephen Gallagher file. The password can be passed in by stdin, \
8d00718b943ab8b326320feb50820f0663031817Stephen Gallagher specified on the command-line or entered \
530ba03ecabb472f17d5d1ab546aec9390492de1Jakub Hrozek parser.add_option("-s", "--stdin", action="store_true",
c9f6ca2ca7399c301853ff774c20883fef2b2267Stephen Gallagher help="The domain to use the password in (mandatory)",
530ba03ecabb472f17d5d1ab546aec9390492de1Jakub Hrozek help="Set input file to FILE (default: Use system default, usually /etc/sssd/sssd.conf)",
11496692da75a330de01d5f15b7183d2439efd3cLukas Slebodnik print("Cannot parse options", file=sys.stderr)
11496692da75a330de01d5f15b7183d2439efd3cLukas Slebodnik print("No domain specified", file=sys.stderr)
675f529e1a0ada1b1a400a59465560ab88a6e24cStephen Gallagher pprompt = lambda: (getpass.getpass("Enter password: "), getpass.getpass("Re-enter password: "))
764bda08267d867a30ceb07d398dc30be1f4b699Stephen Gallagher #Work around bug in Python 2.6
675f529e1a0ada1b1a400a59465560ab88a6e24cStephen Gallagher print('Passwords do not match. Try again')
764bda08267d867a30ceb07d398dc30be1f4b699Stephen Gallagher #Work around bug in Python 2.6
11496692da75a330de01d5f15b7183d2439efd3cLukas Slebodnik print('\nUnexpected end-of-file. Password change aborted',
530ba03ecabb472f17d5d1ab546aec9390492de1Jakub Hrozek # Obfuscate the password
530ba03ecabb472f17d5d1ab546aec9390492de1Jakub Hrozek obfpwd = obfobj.encrypt(password, obfobj.AES_256)
530ba03ecabb472f17d5d1ab546aec9390492de1Jakub Hrozek # Save the obfuscated password into the domain
11496692da75a330de01d5f15b7183d2439efd3cLukas Slebodnik print("Cannot read internal configuration files.")
11496692da75a330de01d5f15b7183d2439efd3cLukas Slebodnik print("Permissions error reading config file")
530ba03ecabb472f17d5d1ab546aec9390492de1Jakub Hrozek domain.set_option('ldap_default_authtok_type', 'obfuscated_password')
530ba03ecabb472f17d5d1ab546aec9390492de1Jakub Hrozek domain.set_option('ldap_default_authtok', obfpwd)
11496692da75a330de01d5f15b7183d2439efd3cLukas Slebodnik print("The domain %s does not seem to support the required options"
5daa8ae758349c0077fb5f664579809aa0ab4f78Stephen Gallagher # File could not be written
11496692da75a330de01d5f15b7183d2439efd3cLukas Slebodnik print("Could not write to config file. Check that you have the "
11496692da75a330de01d5f15b7183d2439efd3cLukas Slebodnik "appropriate permissions to edit this file.", file=sys.stderr)