summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2006-03-30 09:20:34 +0000
committerZac Medico <zmedico@gentoo.org>2006-03-30 09:20:34 +0000
commitfddfcec8f370e37cd1518ad0b975a886dc5a28a2 (patch)
tree0b736076bdcf696e94ff2498c98ec979495ad0d9
parent227cef9e3cecf48af1d0e0aa517f64862db96b45 (diff)
downloadportage-fddfcec8f370e37cd1518ad0b975a886dc5a28a2.tar.gz
portage-fddfcec8f370e37cd1518ad0b975a886dc5a28a2.tar.bz2
portage-fddfcec8f370e37cd1518ad0b975a886dc5a28a2.zip
The return value from apply_permissions now indicates whether or not the permissions needed to be modified.
svn path=/main/trunk/; revision=3039
-rw-r--r--pym/portage_util.py8
1 files changed, 7 insertions, 1 deletions
diff --git a/pym/portage_util.py b/pym/portage_util.py
index 14ecaa7f8..bd8aefeff 100644
--- a/pym/portage_util.py
+++ b/pym/portage_util.py
@@ -462,7 +462,10 @@ def apply_permissions(filename, uid=-1, gid=-1, mode=-1, mask=-1,
bits. When mask=0 is specified, mode bits on the target file are allowed
to be a superset of the mode argument (via logical OR). When mask>0, the
mode bits that the target file is allowed to have are restricted via
- logical XOR."""
+ logical XOR.
+ Returns True if the permissions were modified and False otherwise."""
+
+ modified = False
if stat_cached is None:
try:
@@ -479,6 +482,7 @@ def apply_permissions(filename, uid=-1, gid=-1, mode=-1, mask=-1,
(gid != -1 and gid != stat_cached.st_gid):
try:
os.chown(filename, uid, gid)
+ modified = True
except OSError, oe:
if oe.errno == errno.EPERM:
raise OperationNotPermitted("chown('%s', %i, %i)" % (filename, uid, gid))
@@ -506,6 +510,7 @@ def apply_permissions(filename, uid=-1, gid=-1, mode=-1, mask=-1,
if new_mode != -1:
try:
os.chmod(filename, new_mode)
+ modified = True
except OSError, oe:
if oe.errno == errno.EPERM:
raise OperationNotPermitted("chmod('%s', %s)" % (filename, oct(new_mode)))
@@ -513,6 +518,7 @@ def apply_permissions(filename, uid=-1, gid=-1, mode=-1, mask=-1,
raise FileNotFound(filename)
else:
raise
+ return modified
def apply_stat_permissions(filename, newstat, **kwargs):
"""A wrapper around apply_secpass_permissions that gets