summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephen Gallagher <sgallagh@redhat.com>2011-02-01 16:16:18 -0500
committerStephen Gallagher <sgallagh@redhat.com>2011-02-03 12:16:13 -0500
commit5daa8ae758349c0077fb5f664579809aa0ab4f78 (patch)
treea0aa10d6c0378f26afa8a8155975398164bbd69a
parentc9f6ca2ca7399c301853ff774c20883fef2b2267 (diff)
downloadsssd-5daa8ae758349c0077fb5f664579809aa0ab4f78.tar.gz
sssd-5daa8ae758349c0077fb5f664579809aa0ab4f78.tar.bz2
sssd-5daa8ae758349c0077fb5f664579809aa0ab4f78.zip
Gracefully handle permission errors in sss_obfuscate
-rw-r--r--src/tools/sss_obfuscate18
1 files changed, 15 insertions, 3 deletions
diff --git a/src/tools/sss_obfuscate b/src/tools/sss_obfuscate
index faa2d981..4657a8fa 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__":