diff options
author | Zac Medico <zmedico@gentoo.org> | 2011-08-12 02:47:04 -0700 |
---|---|---|
committer | Zac Medico <zmedico@gentoo.org> | 2011-08-12 02:47:04 -0700 |
commit | e3954bead8d7e37978cac4ae5a5ec7836d3dcd1c (patch) | |
tree | 948dfad6e4bfce890437dbf798b2cd5720c3a683 /pym/portage/package/ebuild/prepare_build_dirs.py | |
parent | 72137f634878c4b0ef54287dd4a33fa2240a68f7 (diff) | |
download | portage-e3954bead8d7e37978cac4ae5a5ec7836d3dcd1c.tar.gz portage-e3954bead8d7e37978cac4ae5a5ec7836d3dcd1c.tar.bz2 portage-e3954bead8d7e37978cac4ae5a5ec7836d3dcd1c.zip |
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.
Diffstat (limited to 'pym/portage/package/ebuild/prepare_build_dirs.py')
-rw-r--r-- | pym/portage/package/ebuild/prepare_build_dirs.py | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/pym/portage/package/ebuild/prepare_build_dirs.py b/pym/portage/package/ebuild/prepare_build_dirs.py index 616dc2e06..9104d0e63 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) |