Merged from trunk 4876:4881
authorFabian Groffen <grobian@gentoo.org>
Mon, 30 Oct 2006 20:01:26 +0000 (20:01 -0000)
committerFabian Groffen <grobian@gentoo.org>
Mon, 30 Oct 2006 20:01:26 +0000 (20:01 -0000)
For bug #153295, do a sanity check for non-string types in
config.environ().

For getmaskingstatus messages, don't assume ARCH is a valid keyword,
since that assumption is not necessarily correct for operating systems
other than Linux.  Thanks to Diego Petteno for reporting.

Just use stat instead of lstat for config protect, so that broken
symlinks are just ignored.

svn path=/main/branches/prefix/; revision=4883

bin/dispatch-conf
pym/portage.py
pym/portage_util.py

index fe524517d47655c761532b5fb523431214fe884a..29ecb89d440fdb3db54e1fc81b886e11f59e7a6a 100755 (executable)
@@ -80,7 +80,7 @@ class dispatch:
         for path in config_paths.split ():
             path = portage.normalize_path(portage_const.EPREFIX + path)
             try:
-                mymode = os.lstat(path).st_mode
+                mymode = os.stat(path).st_mode
             except OSError:
                 continue
             basename = "*"
index 99420474bd77835544598a983fcc13f630abfc5c..4cf304ea480d8887403e1d6e3d2f62bb767063fa 100644 (file)
@@ -1912,7 +1912,12 @@ class config:
                "return our locally-maintained environment"
                mydict={}
                for x in self.keys():
-                       mydict[x]=self[x]
+                       myvalue = self[x]
+                       if not isinstance(myvalue, basestring):
+                               writemsg("!!! Non-string value in config: %s=%s\n" % \
+                                       (x, myvalue), noiselevel=-1)
+                               continue
+                       mydict[x] = myvalue
                if not mydict.has_key("HOME") and mydict.has_key("BUILD_PREFIX"):
                        writemsg("*** HOME not set. Setting to "+mydict["BUILD_PREFIX"]+"\n")
                        mydict["HOME"]=mydict["BUILD_PREFIX"][:]
@@ -3958,6 +3963,10 @@ def getmaskingstatus(mycpv, settings=None, portdb=None):
        mygroups = mygroups.split()
        pgroups = settings["ACCEPT_KEYWORDS"].split()
        myarch = settings["ARCH"]
+       if pgroups and myarch not in pgroups:
+               """For operating systems other than Linux, ARCH is not necessarily a
+               valid keyword."""
+               myarch = pgroups[0].lstrip("~")
        pkgdict = settings.pkeywordsdict
 
        cp = dep_getkey(mycpv)
index bfa0554e8841e0c36a0c5cd401da0d2b272c9e6a..086f3b741030c89e01ac1ddcb4c476272401fcde 100644 (file)
@@ -848,14 +848,9 @@ 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)
+                               self.protect.append(ppath)
                        except OSError:
                                # If it doesn't exist, there's no need to protect it.
                                pass