pykolab/logger.py

Jeroen van Meeuwen vanmeeuwen at kolabsys.com
Fri Oct 5 15:42:05 CEST 2012


 pykolab/logger.py |   25 +++++++++++++------------
 1 file changed, 13 insertions(+), 12 deletions(-)

New commits:
commit 92dc9a8e0318839b669b8e4fbb7b2b4f6a5fddbb
Author: Jeroen van Meeuwen (Kolab Systems) <vanmeeuwen at kolabsys.com>
Date:   Fri Oct 5 14:41:21 2012 +0100

    Only attempt to change the permissions on a logfile after verifying such file actually exists. (#1072)

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:





More information about the commits mailing list