summaryrefslogtreecommitdiff
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:30:02 -0500
commita81bec0c6ed16f3acd9e5a61c3646921889f0658 (patch)
tree8a2fba3cd8b4138acb2aa9718071538be5876855 /server
parent9e88e38f2fa4e6b752ac87392b8af8db03a2b82a (diff)
downloadsssd-a81bec0c6ed16f3acd9e5a61c3646921889f0658.tar.gz
sssd-a81bec0c6ed16f3acd9e5a61c3646921889f0658.tar.bz2
sssd-a81bec0c6ed16f3acd9e5a61c3646921889f0658.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)