sss_obfuscate revision 675f529e1a0ada1b1a400a59465560ab88a6e24c
199767f8919635c4928607450d9e0abb932109ceToomas Soome parser.set_description("sss_obfuscate converts a given password into \
199767f8919635c4928607450d9e0abb932109ceToomas Soome human-unreadable format and places it into \
199767f8919635c4928607450d9e0abb932109ceToomas Soome appropriate domain section of the SSSD config \
199767f8919635c4928607450d9e0abb932109ceToomas Soome file. The password can be passed in by stdin, \
199767f8919635c4928607450d9e0abb932109ceToomas Soome specified on the command-line or entered \
199767f8919635c4928607450d9e0abb932109ceToomas Soome parser.add_option("-s", "--stdin", action="store_true",
199767f8919635c4928607450d9e0abb932109ceToomas Soome help="The domain to use the password in (mandatory)",
199767f8919635c4928607450d9e0abb932109ceToomas Soome help="Set input file to FILE (default: Use system default, usually /etc/sssd/sssd.conf)",
199767f8919635c4928607450d9e0abb932109ceToomas Soome pprompt = lambda: (getpass.getpass("Enter password: "), getpass.getpass("Re-enter password: "))
199767f8919635c4928607450d9e0abb932109ceToomas Soome print >> sys.stderr, '\nUnexpected end-of-file. Password change aborted'
199767f8919635c4928607450d9e0abb932109ceToomas Soome # Obfuscate the password
199767f8919635c4928607450d9e0abb932109ceToomas Soome obfpwd = obfobj.encrypt(password, obfobj.AES_256)
199767f8919635c4928607450d9e0abb932109ceToomas Soome # Save the obfuscated password into the domain
199767f8919635c4928607450d9e0abb932109ceToomas Soome print "Cannot read internal configuration files."
199767f8919635c4928607450d9e0abb932109ceToomas Soome print "Permissions error reading config file"
199767f8919635c4928607450d9e0abb932109ceToomas Soome domain.set_option('ldap_default_authtok_type', 'obfuscated_password')
199767f8919635c4928607450d9e0abb932109ceToomas Soome domain.set_option('ldap_default_authtok', obfpwd)
199767f8919635c4928607450d9e0abb932109ceToomas Soome print "The domain %s does not seem to support the required options" % \
199767f8919635c4928607450d9e0abb932109ceToomas Soome # File could not be written
199767f8919635c4928607450d9e0abb932109ceToomas Soome print >> sys.stderr, "Could not write to config file. Check that " \
199767f8919635c4928607450d9e0abb932109ceToomas Soome "you have the appropriate permissions to edit " \
199767f8919635c4928607450d9e0abb932109ceToomas Soome "this file."