summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--pym/portage/elog/mod_save.py6
-rw-r--r--pym/portage/elog/mod_save_summary.py7
2 files changed, 5 insertions, 8 deletions
diff --git a/pym/portage/elog/mod_save.py b/pym/portage/elog/mod_save.py
index 31c410fac..35c433828 100644
--- a/pym/portage/elog/mod_save.py
+++ b/pym/portage/elog/mod_save.py
@@ -5,6 +5,7 @@
import os, time
from portage.data import portage_uid, portage_gid
+from portage.util import ensure_dirs
def process(mysettings, key, logentries, fulltext):
path = key.replace("/", ":")
@@ -13,10 +14,7 @@ def process(mysettings, key, 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+"/"+path+":"+time.strftime("%Y%m%d-%H%M%S", time.gmtime(time.time()))+".log"
elogfile = open(elogfilename, "w")
diff --git a/pym/portage/elog/mod_save_summary.py b/pym/portage/elog/mod_save_summary.py
index 25f8ae77a..ee40731df 100644
--- a/pym/portage/elog/mod_save_summary.py
+++ b/pym/portage/elog/mod_save_summary.py
@@ -5,20 +5,19 @@
import os, time
from portage.data import portage_uid, portage_gid
+from portage.util import ensure_dirs, apply_permissions
def process(mysettings, key, 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())), key))
elogfile.write(fulltext)