Fix CONFIG_PROTECT so that is works with symlinked directories for bug #151502.
authorZac Medico <zmedico@gentoo.org>
Tue, 17 Oct 2006 21:10:15 +0000 (21:10 -0000)
committerZac Medico <zmedico@gentoo.org>
Tue, 17 Oct 2006 21:10:15 +0000 (21:10 -0000)
svn path=/main/trunk/; revision=4742

pym/portage_util.py

index d07fe63c9b568462f0be5c0af6a7bc33828c5e5c..0e6d5395627f6d44801bc6f61e853c92fc831335 100644 (file)
@@ -848,9 +848,14 @@ class ConfigProtect(object):
                                os.path.join(self.myroot, x.lstrip(os.path.sep)))
                        mystat = None
                        try:
+                               """Use lstat so that anything, even a broken symlink can be
+                               protected."""
                                if stat.S_ISDIR(os.lstat(ppath).st_mode):
                                        self._dirs.add(ppath)
                                self.protect.append(ppath)
+                               """Now use stat in case this is a symlink to a directory."""
+                               if stat.S_ISDIR(os.stat(ppath).st_mode):
+                                       self._dirs.add(ppath)
                        except OSError:
                                # If it doesn't exist, there's no need to protect it.
                                pass
@@ -861,9 +866,14 @@ class ConfigProtect(object):
                                os.path.join(self.myroot, x.lstrip(os.path.sep)))
                        mystat = None
                        try:
+                               """Use lstat so that anything, even a broken symlink can be
+                               protected."""
                                if stat.S_ISDIR(os.lstat(ppath).st_mode):
                                        self._dirs.add(ppath)
                                self.protectmask.append(ppath)
+                               """Now use stat in case this is a symlink to a directory."""
+                               if stat.S_ISDIR(os.stat(ppath).st_mode):
+                                       self._dirs.add(ppath)
                        except OSError:
                                # If it doesn't exist, there's no need to mask it.
                                pass