diff options
author | Zac Medico <zmedico@gentoo.org> | 2006-03-14 08:39:46 +0000 |
---|---|---|
committer | Zac Medico <zmedico@gentoo.org> | 2006-03-14 08:39:46 +0000 |
commit | 91a7af10f09afbd9de9a597144adad6f424073f3 (patch) | |
tree | a0860420969b39a1d8678855189523a8f9d267f6 | |
parent | d0fa70a4875fcda4c4870bd0349d32746b43d6db (diff) | |
download | portage-91a7af10f09afbd9de9a597144adad6f424073f3.tar.gz portage-91a7af10f09afbd9de9a597144adad6f424073f3.tar.bz2 portage-91a7af10f09afbd9de9a597144adad6f424073f3.zip |
Use 'mode & 0777' to protect ourselves from unwanted mode bits in apply_permissions.
svn path=/main/trunk/; revision=2880
-rw-r--r-- | pym/portage_util.py | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/pym/portage_util.py b/pym/portage_util.py index 7a9cfb850..68faa7802 100644 --- a/pym/portage_util.py +++ b/pym/portage_util.py @@ -471,16 +471,19 @@ def apply_permissions(filename, uid=-1, gid=-1, mode=-1, mask=-1, (gid != -1 and gid != stat_cached.st_gid): os.chown(filename, uid, gid) + st_mode = stat_cached.st_mode & 0777 # protect from unwanted bits if mask >= 0: if mode == -1: mode = 0 # Don't add any mode bits when mode is unspecified. - if (mode & stat_cached.st_mode != mode) or \ - (mask ^ stat_cached.st_mode != stat_cached.st_mode): - new_mode = mode | stat_cached.st_mode + if (mode & st_mode != mode) or \ + (mask ^ st_mode != st_mode): + new_mode = mode | st_mode new_mode = mask ^ new_mode os.chmod(filename, new_mode) - elif mode != -1 and mode != stat_cached.st_mode: - os.chmod(filename, mode) + elif mode != -1: + mode = mode & 0777 # protect from unwanted bits + if mode != st_mode: + os.chmod(filename, mode) except OSError, oe: if oe.errno == errno.EPERM: raise OperationNotPermitted(oe) |