sss_obfuscate revision 675f529e1a0ada1b1a400a59465560ab88a6e24c
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)",
8d00718b943ab8b326320feb50820f0663031817Stephen Gallagher print >> sys.stderr, "Cannot parse options"
c9f6ca2ca7399c301853ff774c20883fef2b2267Stephen Gallagher print >> sys.stderr, "No domain specified"
675f529e1a0ada1b1a400a59465560ab88a6e24cStephen Gallagher pprompt = lambda: (getpass.getpass("Enter password: "), getpass.getpass("Re-enter password: "))
675f529e1a0ada1b1a400a59465560ab88a6e24cStephen Gallagher print('Passwords do not match. Try again')
675f529e1a0ada1b1a400a59465560ab88a6e24cStephen Gallagher print >> sys.stderr, '\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
5daa8ae758349c0077fb5f664579809aa0ab4f78Stephen Gallagher print "Cannot read internal configuration files."
5daa8ae758349c0077fb5f664579809aa0ab4f78Stephen Gallagher 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)
530ba03ecabb472f17d5d1ab546aec9390492de1Jakub Hrozek print "The domain %s does not seem to support the required options" % \
5daa8ae758349c0077fb5f664579809aa0ab4f78Stephen Gallagher # File could not be written
5daa8ae758349c0077fb5f664579809aa0ab4f78Stephen Gallagher print >> sys.stderr, "Could not write to config file. Check that " \
5daa8ae758349c0077fb5f664579809aa0ab4f78Stephen Gallagher "you have the appropriate permissions to edit " \