sss_obfuscate revision 5daa8ae758349c0077fb5f664579809aa0ab4f78
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein parser.set_description("sss_obfuscate converts a given password into \
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein human-unreadable format and places it into \
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein appropriate domain section of the SSSD config \
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein file. The password can be passed in by stdin, \
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein specified on the command-line or entered \
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein parser.add_option("-s", "--stdin", action="store_true",
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein help="The domain to use the password in (mandatory)",
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein help="Set input file to FILE (default: Use system default, usually /etc/sssd/sssd.conf)",
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein pprompt = lambda: (getpass.getpass("Enter password: "), getpass.getpass("Re-enter password: "))
28b3569d6248168e6c00caab951521cc8141a49dAutomatic Updater print('Passwords do not match. Try again')
28b3569d6248168e6c00caab951521cc8141a49dAutomatic Updater # Obfuscate the password
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein obfpwd = obfobj.encrypt(password, obfobj.AES_256)
28b3569d6248168e6c00caab951521cc8141a49dAutomatic Updater # Save the obfuscated password into the domain
28b3569d6248168e6c00caab951521cc8141a49dAutomatic Updater print "Cannot read internal configuration files."
28b3569d6248168e6c00caab951521cc8141a49dAutomatic Updater sssdconfig.import_config(options.filename)
28b3569d6248168e6c00caab951521cc8141a49dAutomatic Updater print "Permissions error reading config file"
aeb7938001b22e811a910e1b36cdf452f9193865Automatic Updater domain = sssdconfig.get_domain(options.domain)
aeb7938001b22e811a910e1b36cdf452f9193865Automatic Updater domain.set_option('ldap_default_authtok_type', 'obfuscated_password')
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein domain.set_option('ldap_default_authtok', obfpwd)
aeb7938001b22e811a910e1b36cdf452f9193865Automatic Updater print "The domain %s does not seem to support the required options" % \
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein # File could not be written
9011c72c568aedd03709f56f21d639fd55944a74Automatic Updater print >> sys.stderr, "Could not write to config file. Check that " \
aeb7938001b22e811a910e1b36cdf452f9193865Automatic Updater "you have the appropriate permissions to edit " \