summaryrefslogtreecommitdiffstats
path: root/pykolab
diff options
context:
space:
mode:
authorJeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com>2012-10-05 14:41:21 +0100
committerJeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com>2012-10-05 14:41:58 +0100
commitb92d2972edcd5ec3325c91aec8a0b197e3e3403d (patch)
tree73ad3752f98a91046e3e83d938ecbbb3e84de574 /pykolab
parent44569a17eec2a0bc5d31e4016d399d7db9206229 (diff)
downloadpykolab-b92d2972edcd5ec3325c91aec8a0b197e3e3403d.tar.gz
Only attempt to change the permissions on a logfile after verifying such file actually exists. (#1072)
Diffstat (limited to 'pykolab')
-rw-r--r--pykolab/logger.py25
1 files changed, 13 insertions, 12 deletions
diff --git a/pykolab/logger.py b/pykolab/logger.py
index a0c75c9..7bd0bd4 100644
--- a/pykolab/logger.py
+++ b/pykolab/logger.py
@@ -93,18 +93,19 @@ class Logger(logging.Logger):
rgid = os.getgid()
if ruid == 0 or rgid == 0:
- try:
- os.chown(
- self.logfile,
- pwd.getpwnam('kolab')[2],
- grp.getgrnam('kolab-n')[2]
- )
- os.chmod(self.logfile, 0660)
- except:
- print >> sys.stderr, \
- _("Could not change the ownership of log file %s") % (
- self.logfile
- )
+ if os.path.isfile(self.logfile):
+ try:
+ os.chown(
+ self.logfile,
+ pwd.getpwnam('kolab')[2],
+ grp.getgrnam('kolab-n')[2]
+ )
+ os.chmod(self.logfile, 0660)
+ except:
+ print >> sys.stderr, \
+ _("Could not change the ownership of log file %s") % (
+ self.logfile
+ )
# Make sure the log file exists
try: