From 7c974b9078fa54741ef13e76bf010e0e32ee4e4e Mon Sep 17 00:00:00 2001 From: lxnay Date: Fri, 30 May 2008 11:08:48 +0000 Subject: [PATCH] Entropy/Permissions: - set proper permissions to the pid file - ignore OSError exceptions on run_sync() when trying to setup database file permissions git-svn-id: http://svn.sabayonlinux.org/projects/entropy/trunk@2046 cd1c1023-2f26-0410-ae45-c471fc1f0318 --- libraries/entropy.py | 5 ++++- libraries/entropyConstants.py | 32 ++++++++++++++++++++++++++------ 2 files changed, 30 insertions(+), 7 deletions(-) diff --git a/libraries/entropy.py b/libraries/entropy.py index ae29b0407..b017378ec 100644 --- a/libraries/entropy.py +++ b/libraries/entropy.py @@ -6231,7 +6231,10 @@ class RepoInterface: continue if os.path.isfile(dbfile) and os.access(dbfile,os.W_OK): - self.Entropy.setup_default_file_perms(dbfile) + try: + self.Entropy.setup_default_file_perms(dbfile) + except OSError: # notification applet + pass # database is going to be updated self.dbupdated = True diff --git a/libraries/entropyConstants.py b/libraries/entropyConstants.py index 677f9c670..cc1627e3f 100644 --- a/libraries/entropyConstants.py +++ b/libraries/entropyConstants.py @@ -1098,6 +1098,10 @@ def const_setupEntropyPid(): pass else: raise + try: + const_chmod_entropy_pid() + except OSError: + pass else: #if etpConst['uid'] == 0: @@ -1115,6 +1119,19 @@ def const_setupEntropyPid(): f.flush() f.close() + try: + const_chmod_entropy_pid() + except OSError: + pass + + +def const_chmod_entropy_pid(): + try: + mygid = const_get_entropy_gid() + except KeyError: + mygid = 0 + const_setup_file(etpConst['pidfile'], mygid, 0664) + def const_createWorkingDirectories(): # handle pid file @@ -1380,15 +1397,18 @@ def const_setup_perms(mydir, gid): for item in files: item = os.path.join(currentdir,item) try: - cur_gid = os.stat(item)[stat.ST_GID] - if cur_gid != gid: - os.chown(item,-1,gid) - cur_mod = const_get_chmod(item) - if cur_mod != oct(0664): - os.chmod(item,0664) + const_setup_file(item, gid, 0664) except OSError: pass +def const_setup_file(myfile, gid, chmod): + cur_gid = os.stat(myfile)[stat.ST_GID] + if cur_gid != gid: + os.chown(myfile,-1,gid) + cur_mod = const_get_chmod(myfile) + if cur_mod != oct(chmod): + os.chmod(myfile,chmod) + # you need to convert to int def const_get_chmod(item): st = os.stat(item)[stat.ST_MODE]