- cleaner version of the hardlink basic suid protection. actually check that the...
authorNed Ludd <solar@gentoo.org>
Tue, 22 May 2007 18:19:21 +0000 (18:19 -0000)
committerNed Ludd <solar@gentoo.org>
Tue, 22 May 2007 18:19:21 +0000 (18:19 -0000)
svn path=/main/trunk/; revision=6579

pym/portage/dbapi/vartree.py

index 986516e259ea48bd6dbfb7672347602ac24b0b0a..448df94df0b8d634f1edefecf1e4904469f5daf1 100644 (file)
@@ -1211,11 +1211,12 @@ 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 '%s'\n" % obj)
-                                               # Always blind chmod 0 before unlinking to avoid race conditions.
-                                               os.chmod(obj, 0000)
+                                               if statobj.st_mode & S_ISUID or statobj.st_mode & S_ISGID:
+                                                       # Always blind chmod 0 before unlinking to avoid race conditions.
+                                                       os.chmod(obj, 0000)
+                                                       if statobj.st_nlink > 1:
+                                                               portage.writemsg("setXid: "+str(st.st_nlink-1)+ \
+                                                                       " hardlinks to '%s'\n" % obj)
                                                os.unlink(obj)
                                        except (OSError, IOError), e:
                                                pass