* [gentoo-commits] proj/portage:master commit in: pym/portage/package/ebuild/, pym/portage/elog/
@ 2011-07-11 21:06 Zac Medico
0 siblings, 0 replies; 3+ messages in thread
From: Zac Medico @ 2011-07-11 21:06 UTC (permalink / raw
To: gentoo-commits
commit: baecf07ec888f338b8f628d2c0358d3d70d24f8f
Author: Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Mon Jul 11 21:02:40 2011 +0000
Commit: Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Mon Jul 11 21:02:40 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=baecf07e
elog/mod_save: fix permissions for logrotate
These permissions should be compatible with our default logrotate
config as discussed in bug 374287.
---
pym/portage/elog/mod_save.py | 6 ++++--
pym/portage/elog/mod_save_summary.py | 6 ++++--
pym/portage/package/ebuild/prepare_build_dirs.py | 5 +++++
3 files changed, 13 insertions(+), 4 deletions(-)
diff --git a/pym/portage/elog/mod_save.py b/pym/portage/elog/mod_save.py
index 36654b3..9350a6e 100644
--- a/pym/portage/elog/mod_save.py
+++ b/pym/portage/elog/mod_save.py
@@ -8,7 +8,7 @@ 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.data import portage_gid, portage_uid
from portage.package.ebuild.prepare_build_dirs import _ensure_log_subdirs
from portage.util import ensure_dirs, normalize_path
@@ -23,7 +23,9 @@ def process(mysettings, key, logentries, fulltext):
# 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)
+ # NOTE: These permissions should be compatible with our
+ # default logrotate config as discussed in bug 374287.
+ ensure_dirs(logdir, uid=portage_uid, 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 f090dea..4adc6f3 100644
--- a/pym/portage/elog/mod_save_summary.py
+++ b/pym/portage/elog/mod_save_summary.py
@@ -8,7 +8,7 @@ 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.data import portage_gid, portage_uid
from portage.localization import _
from portage.package.ebuild.prepare_build_dirs import _ensure_log_subdirs
from portage.util import apply_permissions, ensure_dirs, normalize_path
@@ -23,7 +23,9 @@ def process(mysettings, key, logentries, fulltext):
# 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)
+ # NOTE: These permissions should be compatible with our
+ # default logrotate config as discussed in bug 374287.
+ ensure_dirs(logdir, uid=portage_uid, gid=portage_gid, mode=0o2770)
elogdir = os.path.join(logdir, "elog")
_ensure_log_subdirs(logdir, elogdir)
diff --git a/pym/portage/package/ebuild/prepare_build_dirs.py b/pym/portage/package/ebuild/prepare_build_dirs.py
index aaf0740..616dc2e 100644
--- a/pym/portage/package/ebuild/prepare_build_dirs.py
+++ b/pym/portage/package/ebuild/prepare_build_dirs.py
@@ -286,6 +286,11 @@ def _prepare_workdir(mysettings):
try:
modified = ensure_dirs(mysettings["PORT_LOGDIR"])
if modified:
+ # 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.
+ # NOTE: These permissions should be compatible with our
+ # default logrotate config as discussed in bug 374287.
apply_secpass_permissions(mysettings["PORT_LOGDIR"],
uid=portage_uid, gid=portage_gid, mode=0o2770)
except PortageException as e:
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [gentoo-commits] proj/portage:master commit in: pym/portage/package/ebuild/, pym/portage/elog/
@ 2011-08-12 9:47 Zac Medico
0 siblings, 0 replies; 3+ messages in thread
From: Zac Medico @ 2011-08-12 9:47 UTC (permalink / raw
To: gentoo-commits
commit: e3954bead8d7e37978cac4ae5a5ec7836d3dcd1c
Author: Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Fri Aug 12 09:47:04 2011 +0000
Commit: Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Fri Aug 12 09:47:04 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=e3954bea
Fix log uid for logrotate-3.8 compat (bug 378451)
If PORT_LOGDIR is writable by the portage group but its uid is not
portage_uid, then set the uid to portage_uid if we have privileges to
do so, and also copy the uid to the logfile. This fixes logrotate
chown failures during the compression phase, when it attempts to copy
the uid from the logfile to a temp file. With the "su portage portage"
directive and logrotate-3.8.0, logrotate's chown call during the
compression phase will only succeed if the log file's uid is
portage_uid.
---
pym/portage/elog/mod_save.py | 25 ++++++++++++++++++++-
pym/portage/elog/mod_save_summary.py | 18 ++++++++++++++-
pym/portage/package/ebuild/prepare_build_dirs.py | 17 ++++++++++++++-
3 files changed, 55 insertions(+), 5 deletions(-)
diff --git a/pym/portage/elog/mod_save.py b/pym/portage/elog/mod_save.py
index 9350a6e..091bbf8 100644
--- a/pym/portage/elog/mod_save.py
+++ b/pym/portage/elog/mod_save.py
@@ -4,13 +4,14 @@
import io
import time
+import portage
from portage import os
from portage import _encodings
from portage import _unicode_decode
from portage import _unicode_encode
from portage.data import portage_gid, portage_uid
from portage.package.ebuild.prepare_build_dirs import _ensure_log_subdirs
-from portage.util import ensure_dirs, normalize_path
+from portage.util import apply_permissions, ensure_dirs, normalize_path
def process(mysettings, key, logentries, fulltext):
@@ -25,7 +26,10 @@ def process(mysettings, key, logentries, fulltext):
# were previously set by the administrator.
# NOTE: These permissions should be compatible with our
# default logrotate config as discussed in bug 374287.
- ensure_dirs(logdir, uid=portage_uid, gid=portage_gid, mode=0o2770)
+ uid = -1
+ if portage.data.secpass >= 2:
+ uid = portage_uid
+ ensure_dirs(logdir, uid=uid, gid=portage_gid, mode=0o2770)
cat = mysettings['CATEGORY']
pf = mysettings['PF']
@@ -48,4 +52,21 @@ def process(mysettings, key, logentries, fulltext):
elogfile.write(_unicode_decode(fulltext))
elogfile.close()
+ # Copy group permission bits from parent directory.
+ elogdir_st = os.stat(log_subdir)
+ elogdir_gid = elogdir_st.st_gid
+ elogdir_grp_mode = 0o060 & elogdir_st.st_mode
+
+ # Copy the uid from the parent directory if we have privileges
+ # to do so, for compatibility with our default logrotate
+ # config (see bug 378451). With the "su portage portage"
+ # directive and logrotate-3.8.0, logrotate's chown call during
+ # the compression phase will only succeed if the log file's uid
+ # is portage_uid.
+ logfile_uid = -1
+ if portage.data.secpass >= 2:
+ logfile_uid = elogdir_st.st_uid
+ apply_permissions(elogfilename, uid=logfile_uid, gid=elogdir_gid,
+ mode=elogdir_grp_mode, mask=0)
+
return elogfilename
diff --git a/pym/portage/elog/mod_save_summary.py b/pym/portage/elog/mod_save_summary.py
index 4adc6f3..ab71724 100644
--- a/pym/portage/elog/mod_save_summary.py
+++ b/pym/portage/elog/mod_save_summary.py
@@ -4,6 +4,7 @@
import io
import time
+import portage
from portage import os
from portage import _encodings
from portage import _unicode_decode
@@ -25,7 +26,10 @@ def process(mysettings, key, logentries, fulltext):
# were previously set by the administrator.
# NOTE: These permissions should be compatible with our
# default logrotate config as discussed in bug 374287.
- ensure_dirs(logdir, uid=portage_uid, gid=portage_gid, mode=0o2770)
+ logdir_uid = -1
+ if portage.data.secpass >= 2:
+ logdir_uid = portage_uid
+ ensure_dirs(logdir, uid=logdir_uid, gid=portage_gid, mode=0o2770)
elogdir = os.path.join(logdir, "elog")
_ensure_log_subdirs(logdir, elogdir)
@@ -40,7 +44,17 @@ def process(mysettings, key, logentries, fulltext):
elogdir_st = os.stat(elogdir)
elogdir_gid = elogdir_st.st_gid
elogdir_grp_mode = 0o060 & elogdir_st.st_mode
- apply_permissions(elogfilename, gid=elogdir_gid,
+
+ # Copy the uid from the parent directory if we have privileges
+ # to do so, for compatibility with our default logrotate
+ # config (see bug 378451). With the "su portage portage"
+ # directive and logrotate-3.8.0, logrotate's chown call during
+ # the compression phase will only succeed if the log file's uid
+ # is portage_uid.
+ logfile_uid = -1
+ if portage.data.secpass >= 2:
+ logfile_uid = elogdir_st.st_uid
+ apply_permissions(elogfilename, uid=logfile_uid, gid=elogdir_gid,
mode=elogdir_grp_mode, mask=0)
time_str = time.strftime("%Y-%m-%d %H:%M:%S %Z",
diff --git a/pym/portage/package/ebuild/prepare_build_dirs.py b/pym/portage/package/ebuild/prepare_build_dirs.py
index 616dc2e..9104d0e 100644
--- a/pym/portage/package/ebuild/prepare_build_dirs.py
+++ b/pym/portage/package/ebuild/prepare_build_dirs.py
@@ -9,6 +9,7 @@ import shutil
import stat
import time
+import portage
from portage import os, _encodings, _unicode_encode, _unicode_decode
from portage.data import portage_gid, portage_uid, secpass
from portage.exception import DirectoryNotFound, FileNotFound, \
@@ -358,13 +359,27 @@ def _ensure_log_subdirs(logdir, subdir):
and subdir are assumed to be normalized absolute paths.
"""
st = os.stat(logdir)
+ uid = -1
gid = st.st_gid
grp_mode = 0o2070 & st.st_mode
+ # If logdir is writable by the portage group but its uid
+ # is not portage_uid, then set the uid to portage_uid if
+ # we have privileges to do so, for compatibility with our
+ # default logrotate config (see bug 378451). With the
+ # "su portage portage" directive and logrotate-3.8.0,
+ # logrotate's chown call during the compression phase will
+ # only succeed if the log file's uid is portage_uid.
+ if grp_mode and gid == portage_gid and \
+ portage.data.secpass >= 2:
+ uid = portage_uid
+ if st.st_uid != portage_uid:
+ ensure_dirs(logdir, uid=uid)
+
logdir_split_len = len(logdir.split(os.sep))
subdir_split = subdir.split(os.sep)[logdir_split_len:]
subdir_split.reverse()
current = logdir
while subdir_split:
current = os.path.join(current, subdir_split.pop())
- ensure_dirs(current, gid=gid, mode=grp_mode, mask=0)
+ ensure_dirs(current, uid=uid, gid=gid, mode=grp_mode, mask=0)
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [gentoo-commits] proj/portage:master commit in: pym/portage/package/ebuild/, pym/portage/elog/
@ 2011-07-11 16:55 Zac Medico
0 siblings, 0 replies; 3+ messages in thread
From: Zac Medico @ 2011-07-11 16:55 UTC (permalink / raw
To: gentoo-commits
commit: 4d689ffbe80b8d5038cc0105ace69de7b80e6cb1
Author: Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Mon Jul 11 16:55:16 2011 +0000
Commit: Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Mon Jul 11 16:55:16 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=4d689ffb
elog/mod_save: use _ensure_log_subdirs
This fixes permission issues with category subdirectories created for
FEATURES=split-elog.
---
pym/portage/elog/mod_save.py | 21 +++++++++----------
pym/portage/elog/mod_save_summary.py | 23 +++++++++++++++------
pym/portage/package/ebuild/prepare_build_dirs.py | 2 +-
3 files changed, 27 insertions(+), 19 deletions(-)
diff --git a/pym/portage/elog/mod_save.py b/pym/portage/elog/mod_save.py
index 0f09794..40ba267 100644
--- a/pym/portage/elog/mod_save.py
+++ b/pym/portage/elog/mod_save.py
@@ -8,17 +8,15 @@ from portage import os
from portage import _encodings
from portage import _unicode_decode
from portage import _unicode_encode
-from portage.data import portage_uid, portage_gid
-from portage.util import ensure_dirs
+from portage.package.ebuild.prepare_build_dirs import _ensure_log_subdirs
+from portage.util import normalize_path
def process(mysettings, key, logentries, fulltext):
- path = key.replace("/", ":")
- if mysettings["PORT_LOGDIR"] != "":
- elogdir = os.path.join(mysettings["PORT_LOGDIR"], "elog")
+ if mysettings.get("PORT_LOGDIR"):
+ logdir = normalize_path(mysettings["PORT_LOGDIR"])
else:
- elogdir = os.path.join(os.sep, "var", "log", "portage", "elog")
- ensure_dirs(elogdir, uid=portage_uid, gid=portage_gid, mode=0o2770)
+ logdir = os.path.join(os.sep, "var", "log", "portage")
cat = mysettings['CATEGORY']
pf = mysettings['PF']
@@ -28,11 +26,12 @@ def process(mysettings, key, logentries, fulltext):
encoding=_encodings['content'], errors='replace') + ".log"
if "split-elog" in mysettings.features:
- elogfilename = os.path.join(elogdir, cat, elogfilename)
+ log_subdir = os.path.join(logdir, "elog", cat)
+ elogfilename = os.path.join(log_subdir, elogfilename)
else:
- elogfilename = os.path.join(elogdir, cat + ':' + elogfilename)
- ensure_dirs(os.path.dirname(elogfilename),
- uid=portage_uid, gid=portage_gid, mode=0o2770)
+ log_subdir = os.path.join(logdir, "elog")
+ elogfilename = os.path.join(log_subdir, cat + ':' + elogfilename)
+ _ensure_log_subdirs(logdir, log_subdir)
elogfile = io.open(_unicode_encode(elogfilename,
encoding=_encodings['fs'], errors='strict'),
diff --git a/pym/portage/elog/mod_save_summary.py b/pym/portage/elog/mod_save_summary.py
index 8970f06..67bd76e 100644
--- a/pym/portage/elog/mod_save_summary.py
+++ b/pym/portage/elog/mod_save_summary.py
@@ -8,23 +8,32 @@ from portage import os
from portage import _encodings
from portage import _unicode_decode
from portage import _unicode_encode
-from portage.data import portage_uid, portage_gid
from portage.localization import _
-from portage.util import ensure_dirs, apply_permissions
+from portage.package.ebuild.prepare_build_dirs import _ensure_log_subdirs
+from portage.util import apply_permissions, normalize_path
def process(mysettings, key, logentries, fulltext):
- if mysettings["PORT_LOGDIR"] != "":
- elogdir = os.path.join(mysettings["PORT_LOGDIR"], "elog")
+ if mysettings.get("PORT_LOGDIR"):
+ logdir = normalize_path(mysettings["PORT_LOGDIR"])
else:
- elogdir = os.path.join(os.sep, "var", "log", "portage", "elog")
- ensure_dirs(elogdir, uid=portage_uid, gid=portage_gid, mode=0o2770)
+ logdir = os.path.join(os.sep, "var", "log", "portage")
+
+ elogdir = os.path.join(logdir, "elog")
+ _ensure_log_subdirs(logdir, elogdir)
# TODO: Locking
elogfilename = elogdir+"/summary.log"
elogfile = io.open(_unicode_encode(elogfilename,
encoding=_encodings['fs'], errors='strict'),
mode='a', encoding=_encodings['content'], errors='backslashreplace')
- apply_permissions(elogfilename, mode=0o60, mask=0)
+
+ # Copy group permission bits from parent directory.
+ elogdir_st = os.stat(elogdir)
+ elogdir_gid = elogdir_st.st_gid
+ elogdir_grp_mode = 0o060 & elogdir_st.st_mode
+ apply_permissions(elogfilename, gid=elogdir_gid,
+ mode=elogdir_grp_mode, mask=0)
+
time_str = time.strftime("%Y-%m-%d %H:%M:%S %Z",
time.localtime(time.time()))
# Avoid potential UnicodeDecodeError later.
diff --git a/pym/portage/package/ebuild/prepare_build_dirs.py b/pym/portage/package/ebuild/prepare_build_dirs.py
index de1dc93..aaf0740 100644
--- a/pym/portage/package/ebuild/prepare_build_dirs.py
+++ b/pym/portage/package/ebuild/prepare_build_dirs.py
@@ -1,4 +1,4 @@
-# Copyright 2010 Gentoo Foundation
+# Copyright 2010-2011 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
__all__ = ['prepare_build_dirs']
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2011-08-12 9:47 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-07-11 21:06 [gentoo-commits] proj/portage:master commit in: pym/portage/package/ebuild/, pym/portage/elog/ Zac Medico
-- strict thread matches above, loose matches on Subject: below --
2011-08-12 9:47 Zac Medico
2011-07-11 16:55 Zac Medico
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox