From 9cabb5e830eb206de7f45e6a7cc9ce13079b2460 Mon Sep 17 00:00:00 2001 From: Nikos Kouremenos <kourem@gmail.com> Date: Thu, 25 Aug 2005 16:50:02 +0000 Subject: [PATCH] chmod bad permisioned dirs --- src/common/logger.py | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/common/logger.py b/src/common/logger.py index b4773c3c4..b17958968 100644 --- a/src/common/logger.py +++ b/src/common/logger.py @@ -20,6 +20,8 @@ import os import sys import time +import stat + import common.gajim from common import i18n _ = i18n._ @@ -42,13 +44,21 @@ class Logger: print _('Gajim will now exit') sys.exit() elif os.path.isdir(dot_gajim): - if os.path.isfile(LOGPATH): + s = os.stat(dot_gajim) + if s.st_mode & stat.S_IROTH: # others have read permission! + os.chmod(fname, 0700) # rwx------ + + if not os.path.exists(LOGPATH): + print _('creating %s directory') % LOGPATH + os.mkdir(LOGPATH, 0700) + elif os.path.isfile(LOGPATH): print _('%s is file but it should be a directory') % LOGPATH print _('Gajim will now exit') sys.exit() - elif not os.path.exists(LOGPATH): - print _('creating %s directory') % LOGPATH - os.mkdir(LOGPATH, 0700) + elif os.path.isdir(LOGPATH): + s = os.stat(LOGPATH) + if s.st_mode & stat.S_IROTH: # others have read permission! + os.chmod(LOGPATH, 0700) # rwx------ else: # dot_gajim doesn't exist if dot_gajim: # is '' on win9x so avoid that print _('creating %s directory') % dot_gajim