From b1de340b63bcf3ba20aa222b27fcbac998668adf Mon Sep 17 00:00:00 2001 From: Lukas Slebodnik Date: Wed, 27 Jan 2016 16:02:33 +0100 Subject: [PATCH 1/2] PYTHON: sss_obfuscate should work with python3 Based on patch from: Steven W. Elling Resolves: https://fedorahosted.org/sssd/ticket/2937 --- src/tools/sss_obfuscate | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/src/tools/sss_obfuscate b/src/tools/sss_obfuscate index fbea1213d8f7e99ab3b1a6d7d24accf8a6194094..68ef30e386ced95b85afbea87696e3c69bea7b51 100644 --- a/src/tools/sss_obfuscate +++ b/src/tools/sss_obfuscate @@ -1,5 +1,7 @@ #!/usr/bin/python +from __future__ import print_function + import sys from optparse import OptionParser @@ -33,11 +35,11 @@ def parse_options(): def main(): options, args = parse_options() if not options: - print >> sys.stderr, "Cannot parse options" + print("Cannot parse options", file=sys.stderr) return 1 if not options.domain: - print >> sys.stderr, "No domain specified" + print("No domain specified", file=sys.stderr) return 1 if not options.stdin: @@ -59,7 +61,8 @@ def main(): password = p1 except EOFError: - print >> sys.stderr, '\nUnexpected end-of-file. Password change aborted' + print('\nUnexpected end-of-file. Password change aborted', + file=sys.stderr) return 1 except KeyboardInterrupt: return 1 @@ -78,26 +81,26 @@ def main(): try: sssdconfig = SSSDConfig.SSSDConfig() except IOError: - print "Cannot read internal configuration files." + print("Cannot read internal configuration files.") return 1 try: sssdconfig.import_config(options.filename) except IOError: - print "Permissions error reading config file" + print("Permissions error reading config file") return 1 try: domain = sssdconfig.get_domain(options.domain) except SSSDConfig.NoDomainError: - print "No such domain %s" % options.domain + print("No such domain %s" % options.domain) return 1 try: domain.set_option('ldap_default_authtok_type', 'obfuscated_password') domain.set_option('ldap_default_authtok', obfpwd) except SSSDConfig.NoOptionError: - print "The domain %s does not seem to support the required options" % \ - options.domain + print("The domain %s does not seem to support the required options" + % options.domain) return 1 @@ -106,9 +109,8 @@ def main(): sssdconfig.write() except IOError: # File could not be written - print >> sys.stderr, "Could not write to config file. Check that " \ - "you have the appropriate permissions to edit " \ - "this file." + print("Could not write to config file. Check that you have the " + "appropriate permissions to edit this file.", file=sys.stderr) return 1 return 0 -- 2.5.0