- blind chmod 0 before unlinking files to avoid anybody doing sneaky stuff via hardlinks
authorNed Ludd <solar@gentoo.org>
Mon, 21 May 2007 19:27:28 +0000 (19:27 -0000)
committerNed Ludd <solar@gentoo.org>
Mon, 21 May 2007 19:27:28 +0000 (19:27 -0000)
svn path=/main/trunk/; revision=6563

pym/portage/dbapi/vartree.py

index d438cbee029374592102f37c466450aae9755a2f..3c7e646ebaeefb9aa6620e3e2eb2206fa4d92445 100644 (file)
@@ -1211,6 +1211,10 @@ class dblink(object):
                                                writemsg_stdout("--- !md5   %s %s\n" % ("obj", obj))
                                                continue
                                        try:
+                                               if statobj.st_nlink > 1:
+                                                       portage.writemsg("There are "+str(st.st_nlink-1)+" hardlinks to " + obj)
+                                               # Always blind chmod 0 before unlinking to avoid race conditions.
+                                               os.chmod(obj, 0000)
                                                os.unlink(obj)
                                        except (OSError, IOError), e:
                                                pass