From 026f55b3494e3c01203f263fd699c91219cde5d6 Mon Sep 17 00:00:00 2001 From: Stephen Gallagher Date: Tue, 1 Feb 2011 16:16:18 -0500 Subject: Gracefully handle permission errors in sss_obfuscate --- src/tools/sss_obfuscate | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/tools/sss_obfuscate b/src/tools/sss_obfuscate index faa2d981a..4657a8fa2 100644 --- a/src/tools/sss_obfuscate +++ b/src/tools/sss_obfuscate @@ -63,11 +63,15 @@ def main(): obfpwd = obfobj.encrypt(password, obfobj.AES_256) # Save the obfuscated password into the domain - sssdconfig = SSSDConfig.SSSDConfig() + try: + sssdconfig = SSSDConfig.SSSDConfig() + except IOError: + print "Cannot read internal configuration files." + return 1 try: sssdconfig.import_config(options.filename) except IOError: - print "Cannot open config file %s" % options.filename + print "Permissions error reading config file" return 1 try: @@ -86,7 +90,15 @@ def main(): sssdconfig.save_domain(domain) - sssdconfig.write() + try: + 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." + return 1 + return 0 if __name__ == "__main__": -- cgit