summaryrefslogtreecommitdiffstats
path: root/pym/portage_util.py
diff options
context:
space:
mode:
Diffstat (limited to 'pym/portage_util.py')
-rw-r--r--pym/portage_util.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/pym/portage_util.py b/pym/portage_util.py
index 4c7e3176f..1e7afe4b6 100644
--- a/pym/portage_util.py
+++ b/pym/portage_util.py
@@ -558,7 +558,10 @@ def apply_permissions(filename, uid=-1, gid=-1, mode=-1, mask=-1,
# bits, so those bits are restored if necessary.
if modified and new_mode == -1 and \
(st_mode & stat.S_ISUID or st_mode & stat.S_ISGID):
- new_mode = mode & 07777
+ if mode == -1:
+ new_mode = st_mode
+ elif mode & stat.S_ISUID or mode & stat.S_ISGID:
+ new_mode = mode & 07777
if not follow_links and stat.S_ISLNK(stat_cached.st_mode):
# Mode doesn't matter for symlinks.