summaryrefslogtreecommitdiffstats
path: root/server
diff options
context:
space:
mode:
authorJakub Hrozek <jhrozek@redhat.com>2009-12-07 21:35:32 +0100
committerStephen Gallagher <sgallagh@redhat.com>2009-12-08 12:31:46 -0500
commitac8c76a353f29e9989e838df1967c75656b647f6 (patch)
tree50967eccc1e995cf99bce3dfb4df8354c18d311a /server
parent573190f896b4f474e604dd86b11cbfbdd987a236 (diff)
downloadsssd_unused-ac8c76a353f29e9989e838df1967c75656b647f6.tar.gz
sssd_unused-ac8c76a353f29e9989e838df1967c75656b647f6.tar.xz
sssd_unused-ac8c76a353f29e9989e838df1967c75656b647f6.zip
Fail on nonexistent input file
Diffstat (limited to 'server')
-rw-r--r--server/config/ipachangeconf.py9
-rw-r--r--server/config/upgrade_config.py6
2 files changed, 12 insertions, 3 deletions
diff --git a/server/config/ipachangeconf.py b/server/config/ipachangeconf.py
index 9635de44..f06ab4c3 100644
--- a/server/config/ipachangeconf.py
+++ b/server/config/ipachangeconf.py
@@ -25,10 +25,15 @@ import time
import shutil
import re
-def openLocked(filename, perms):
+def openLocked(filename, perms, create = True):
fd = -1
+
+ flags = os.O_RDWR
+ if create:
+ flags = flags | os.O_CREAT
+
try:
- fd = os.open(filename, os.O_RDWR | os.O_CREAT, perms)
+ fd = os.open(filename, flags, perms)
fcntl.lockf(fd, fcntl.LOCK_EX)
except OSError, (errno, strerr):
if fd != -1:
diff --git a/server/config/upgrade_config.py b/server/config/upgrade_config.py
index 09758211..d47fcd38 100644
--- a/server/config/upgrade_config.py
+++ b/server/config/upgrade_config.py
@@ -34,7 +34,7 @@ class SSSDConfigFile(SSSDChangeConf):
SSSDChangeConf.__init__(self)
self.filename = filename
- f = openLocked(self.filename, 0600)
+ f = openLocked(self.filename, 0600, False)
self.opts = self.parse(f)
f.close()
@@ -368,6 +368,10 @@ def main():
verbose(traceback.format_exc(), options.verbose)
print >>sys.stderr, "Cannot parse config file %s" % options.filename
return 1
+ except Exception, e:
+ print "ERROR: %s" % e
+ verbose(traceback.format_exc(), options.verbose)
+ return 1
# make sure we keep strict settings when creating new files
os.umask(0077)