sss_obfuscate revision c9f6ca2ca7399c301853ff774c20883fef2b2267
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"
8d00718b943ab8b326320feb50820f0663031817Stephen Gallagher if not options.stdin and not options.password:
8d00718b943ab8b326320feb50820f0663031817Stephen Gallagher pprompt = lambda: (getpass.getpass("Enter password: "), getpass.getpass("Re-enter password: "))
8d00718b943ab8b326320feb50820f0663031817Stephen Gallagher print('Passwords do not match. Try again')
530ba03ecabb472f17d5d1ab546aec9390492de1Jakub Hrozek # Obfuscate the password
530ba03ecabb472f17d5d1ab546aec9390492de1Jakub Hrozek obfpwd = obfobj.encrypt(password, obfobj.AES_256)
530ba03ecabb472f17d5d1ab546aec9390492de1Jakub Hrozek # Save the obfuscated password into the domain
530ba03ecabb472f17d5d1ab546aec9390492de1Jakub Hrozek print "Cannot open config file %s" % options.filename
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" % \