protect variables specified in PROFILE_ONLY_VARIABLES from
authorZac Medico <zmedico@gentoo.org>
Fri, 2 Nov 2007 04:56:09 +0000 (04:56 -0000)
committerZac Medico <zmedico@gentoo.org>
Fri, 2 Nov 2007 04:56:09 +0000 (04:56 -0000)
being set by the user (trunk r8251:8253, r8255, and r8259)

svn path=/main/branches/2.1.2/; revision=8361

man/portage.5
pym/portage.py
pym/portage_const.py

index 725e09375e3b54c4e41c8f123fe4d7c687a3d27e..6728ebe281f2761d35993b65b4eadbef225e0b9e 100644 (file)
@@ -163,9 +163,13 @@ Architecture type (x86/ppc/hppa/etc...).
 .B USERLAND = \fI"GNU"\fR
 Support BSD/cygwin/etc...
 .TP
-.B PORTAGE_LIBC = \fI"glibc"\fR
+.B ELIBC = \fI"glibc"\fR
 Support uClibc/BSD libc/etc...
 .TP
+.B PROFILE_ONLY_VARIABLES = \fI"ARCH"\fR
+Prevent critical variables from being changed by the user in make.conf 
+or the env.
+.TP
 .BR PROFILE_ARCH
 Distinguish machines classes that have the same \fBARCH\fR.  All sparc 
 machines have ARCH=sparc but set this to either 'sparc32' or 'sparc64'.
index bddc3f2570d656109d660f053d71070a811f744a..5e3cb6bd67ef4b7a0736a4e263f3bbdd18069883 100644 (file)
@@ -1301,6 +1301,13 @@ class config:
                                                "this. Do not use them.\n", noiselevel=-1)
                                sys.exit(1)
 
+
+                       # Don't allow the user to override certain variables in make.conf
+                       profile_only_variables = self.configdict["defaults"].get(
+                               "PROFILE_ONLY_VARIABLES", "").split()
+                       for k in profile_only_variables:
+                               self.mygcfg.pop(k, None)
+                       
                        # Allow ROOT setting to come from make.conf if it's not overridden
                        # by the constructor argument (from the calling environment).  As a
                        # special exception for a very common use case, config_root == "/"
@@ -1324,7 +1331,12 @@ class config:
                        self.configlist.append(self.backupenv) # XXX Why though?
                        self.configdict["backupenv"]=self.configlist[-1]
 
-                       self.configlist.append(os.environ.copy())
+                       myenv = os.environ.copy()               
+                       # Don't allow the user to override certain variables in the env
+                       for k in profile_only_variables:
+                               myenv.pop(k, None)
+
+                       self.configlist.append(myenv)
                        self.configdict["env"]=self.configlist[-1]
                        if not local_config:
                                # Clean up pollution from portage_data so that it doesn't
index f29e7b6b798533d7ad8fa22cfb3abbd3737f1ad3..c27764e4635bbcdbbcb2d7885768e530b2ef6178 100644 (file)
@@ -51,7 +51,7 @@ REPO_NAME_LOC          = "profiles" + "/" + REPO_NAME_FILE
 INCREMENTALS = ["USE", "USE_EXPAND", "USE_EXPAND_HIDDEN", "FEATURES",
        "ACCEPT_KEYWORDS", "ACCEPT_LICENSE",
        "CONFIG_PROTECT_MASK", "CONFIG_PROTECT",
-       "PRELINK_PATH", "PRELINK_PATH_MASK"]
+       "PRELINK_PATH", "PRELINK_PATH_MASK", "PROFILE_ONLY_VARIABLES"]
 EBUILD_PHASES           = ["setup", "unpack", "compile", "test", "install",
                           "preinst", "postinst", "prerm", "postrm", "other"]