From d20cc273f670d4141ba94a860bfbafa80e223dad Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Mon, 11 Jul 2011 11:00:33 -0700 Subject: [PATCH] elog/mod_save: ensure parent logdir exists --- pym/portage/elog/mod_save.py | 9 ++++++++- pym/portage/elog/mod_save_summary.py | 9 ++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/pym/portage/elog/mod_save.py b/pym/portage/elog/mod_save.py index 40ba26765..36654b3f2 100644 --- a/pym/portage/elog/mod_save.py +++ b/pym/portage/elog/mod_save.py @@ -8,8 +8,9 @@ from portage import os from portage import _encodings from portage import _unicode_decode from portage import _unicode_encode +from portage.data import portage_gid from portage.package.ebuild.prepare_build_dirs import _ensure_log_subdirs -from portage.util import normalize_path +from portage.util import ensure_dirs, normalize_path def process(mysettings, key, logentries, fulltext): @@ -18,6 +19,12 @@ def process(mysettings, key, logentries, fulltext): else: logdir = os.path.join(os.sep, "var", "log", "portage") + if not os.path.isdir(logdir): + # Only initialize group/mode if the directory doesn't + # exist, so that we don't override permissions if they + # were previously set by the administrator. + ensure_dirs(logdir, gid=portage_gid, mode=0o2770) + cat = mysettings['CATEGORY'] pf = mysettings['PF'] diff --git a/pym/portage/elog/mod_save_summary.py b/pym/portage/elog/mod_save_summary.py index 67bd76e55..f090deaf0 100644 --- a/pym/portage/elog/mod_save_summary.py +++ b/pym/portage/elog/mod_save_summary.py @@ -8,9 +8,10 @@ from portage import os from portage import _encodings from portage import _unicode_decode from portage import _unicode_encode +from portage.data import portage_gid from portage.localization import _ from portage.package.ebuild.prepare_build_dirs import _ensure_log_subdirs -from portage.util import apply_permissions, normalize_path +from portage.util import apply_permissions, ensure_dirs, normalize_path def process(mysettings, key, logentries, fulltext): if mysettings.get("PORT_LOGDIR"): @@ -18,6 +19,12 @@ def process(mysettings, key, logentries, fulltext): else: logdir = os.path.join(os.sep, "var", "log", "portage") + if not os.path.isdir(logdir): + # Only initialize group/mode if the directory doesn't + # exist, so that we don't override permissions if they + # were previously set by the administrator. + ensure_dirs(logdir, gid=portage_gid, mode=0o2770) + elogdir = os.path.join(logdir, "elog") _ensure_log_subdirs(logdir, elogdir) -- 2.26.2