diff options
Diffstat (limited to 'pym')
-rw-r--r-- | pym/elog_modules/mod_save.py | 6 | ||||
-rw-r--r-- | pym/elog_modules/mod_save_summary.py | 7 |
2 files changed, 5 insertions, 8 deletions
diff --git a/pym/elog_modules/mod_save.py b/pym/elog_modules/mod_save.py index 4e1cd2cf8..97213e040 100644 --- a/pym/elog_modules/mod_save.py +++ b/pym/elog_modules/mod_save.py @@ -1,5 +1,6 @@ import os, time from portage_data import portage_uid, portage_gid +from portage_util import ensure_dirs def process(mysettings, cpv, logentries, fulltext): cpv_path = cpv.replace("/", ":") @@ -8,10 +9,7 @@ def process(mysettings, cpv, logentries, fulltext): elogdir = os.path.join(mysettings["PORT_LOGDIR"], "elog") else: elogdir = os.path.join(os.sep, "var", "log", "portage", "elog") - if not os.path.exists(elogdir): - os.makedirs(elogdir) - os.chown(elogdir, portage_uid, portage_gid) - os.chmod(elogdir, 02770) + ensure_dirs(elogdir, uid=portage_uid, gid=portage_gid, mode=02770) elogfilename = elogdir+"/"+cpv_path+":"+time.strftime("%Y%m%d-%H%M%S", time.gmtime(time.time()))+".log" elogfile = open(elogfilename, "w") diff --git a/pym/elog_modules/mod_save_summary.py b/pym/elog_modules/mod_save_summary.py index 7cb310d95..7dbfc03cc 100644 --- a/pym/elog_modules/mod_save_summary.py +++ b/pym/elog_modules/mod_save_summary.py @@ -1,19 +1,18 @@ import os, time from portage_data import portage_uid, portage_gid +from portage_util import ensure_dirs, apply_permissions def process(mysettings, cpv, logentries, fulltext): if mysettings["PORT_LOGDIR"] != "": elogdir = os.path.join(mysettings["PORT_LOGDIR"], "elog") else: elogdir = os.path.join(os.sep, "var", "log", "portage", "elog") - if not os.path.exists(elogdir): - os.makedirs(elogdir) - os.chown(elogdir, portage_uid, portage_gid) - os.chmod(elogdir, 02770) + ensure_dirs(elogdir, uid=portage_uid, gid=portage_gid, mode=02770) # TODO: Locking elogfilename = elogdir+"/summary.log" elogfile = open(elogfilename, "a") + apply_permissions(elogfilename, mode=060, mask=0) elogfile.write(">>> Messages generated by process %d on %s for package %s:\n\n" % \ (os.getpid(), time.strftime("%Y-%m-%d %H:%M:%S", time.gmtime(time.time())), cpv)) elogfile.write(fulltext) |