summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--pym/portage.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/pym/portage.py b/pym/portage.py
index be41b4d96..759b50174 100644
--- a/pym/portage.py
+++ b/pym/portage.py
@@ -7134,6 +7134,12 @@ class dblink:
writemsg_stdout("--- !md5 %s %s\n" % ("obj", obj))
continue
try:
+ if statobj.st_mode & (stat.S_ISUID | stat.S_ISGID):
+ # Always blind chmod 0 before unlinking to avoid race conditions.
+ os.chmod(obj, 0000)
+ if statobj.st_nlink > 1:
+ writemsg("setXid: "+str(statobj.st_nlink-1)+ \
+ " hardlinks to '%s'\n" % obj)
os.unlink(obj)
except (OSError,IOError),e:
pass