From: Fabian Groffen Date: Thu, 8 Jan 2009 20:06:46 +0000 (-0000) Subject: Merged from trunk -r12375:12380 X-Git-Url: http://git.tremily.us/gitweb.cgi?a=commitdiff_plain;h=375a6c613a673177d9bba09b8dfbb32f26c21875;p=portage.git Merged from trunk -r12375:12380 | 12376 | Bug #253336 - Set PORTAGE_VERBOSE=1 so that files are | | zmedico | displayed as they are merge. | | 12377 | Fix the 'Unrecognized configure options' check for | | zmedico | compatibility with output produced by Autoconf 2.63. Thanks | | | to Arfrever Frehtes Taifersar Arahesis for reporting. | | 12378 | Inside action_sync(), when running as root, detect if | | zmedico | $PORTDIR has non-root uid/gid bits and drop privileges to | | | match the existing bits if appropriate. | | 12379 | Bug #253467 - Don't allow alien $A values to leak into the | | zmedico | ebuild environment. | | 12380 | When dropping privileges inside action_sync(), set the umask | | zmedico | to preserve the group write bit if appropriate. | svn path=/main/branches/prefix/; revision=12394 --- diff --git a/bin/ebuild b/bin/ebuild index 0ef80cfda..6b24e566b 100755 --- a/bin/ebuild +++ b/bin/ebuild @@ -180,6 +180,8 @@ def discard_digests(myebuild, mysettings, mydbapi): portage.settings.validate() # generate warning messages if necessary tmpsettings = portage.config(clone=portage.settings) +tmpsettings["PORTAGE_VERBOSE"] = "1" +tmpsettings.backup_changes("PORTAGE_VERBOSE") if "test" in pargs: # This variable is a signal to config.regenerate() to # indicate that the test phase should be enabled regardless diff --git a/pym/_emerge/__init__.py b/pym/_emerge/__init__.py index 8dfc1cb07..8a9b1c848 100644 --- a/pym/_emerge/__init__.py +++ b/pym/_emerge/__init__.py @@ -8,6 +8,7 @@ from collections import deque import fcntl import formatter import logging +import pwd import select import shlex import shutil @@ -11837,9 +11838,36 @@ def action_sync(settings, trees, mtimedb, myopts, myaction): sys.exit(1) if myportdir[-1]=="/": myportdir=myportdir[:-1] - if not os.path.exists(myportdir): + try: + st = os.stat(myportdir) + except OSError: + st = None + if st is None: print ">>>",myportdir,"not found, creating it." os.makedirs(myportdir,0755) + st = os.stat(myportdir) + + spawn_kwargs = {} + spawn_kwargs["env"] = settings.environ() + if portage.data.secpass >= 2 and \ + (st.st_uid != os.getuid() and st.st_mode & 0700 or \ + st.st_gid != os.getgid() and st.st_mode & 0070): + try: + homedir = pwd.getpwuid(st.st_uid).pw_dir + except KeyError: + pass + else: + # Drop privileges when syncing, in order to match + # existing uid/gid settings. + spawn_kwargs["uid"] = st.st_uid + spawn_kwargs["gid"] = st.st_gid + spawn_kwargs["groups"] = [st.st_gid] + spawn_kwargs["env"]["HOME"] = homedir + umask = 0002 + if not st.st_mode & 0020: + umask = umask | 0020 + spawn_kwargs["umask"] = umask + syncuri = settings.get("SYNC", "").strip() if not syncuri: writemsg_level("!!! SYNC is undefined. Is /etc/make.globals missing?\n", @@ -11863,8 +11891,8 @@ def action_sync(settings, trees, mtimedb, myopts, myaction): msg = ">>> Starting git pull in %s..." % myportdir emergelog(xterm_titles, msg ) writemsg_level(msg + "\n") - exitcode = portage.spawn("cd %s ; git pull" % \ - (portage._shell_quote(myportdir),), settings, free=1) + exitcode = portage.process.spawn_bash("cd %s ; git pull" % \ + (portage._shell_quote(myportdir),), **spawn_kwargs) if exitcode != os.EX_OK: msg = "!!! git pull error in %s." % myportdir emergelog(xterm_titles, msg) @@ -12157,8 +12185,7 @@ def action_sync(settings, trees, mtimedb, myopts, myaction): elif (servertimestamp == 0) or (servertimestamp > mytimestamp): # actual sync mycommand = rsynccommand + [dosyncuri+"/", myportdir] - exitcode = portage.process.spawn(mycommand, - env=settings.environ()) + exitcode = portage.process.spawn(mycommand, **spawn_kwargs) if exitcode in [0,1,3,4,11,14,20,21]: break elif exitcode in [1,3,4,11,14,20,21]: @@ -12241,8 +12268,9 @@ def action_sync(settings, trees, mtimedb, myopts, myaction): else: #cvs update print ">>> Starting cvs update with "+syncuri+"..." - retval = portage.spawn("cd '%s'; cvs -z0 -q update -dP" % \ - myportdir, settings, free=1) + retval = portage.process.spawn_bash( + "cd %s; cvs -z0 -q update -dP" % \ + (portage._shell_quote(myportdir),), **spawn_kwargs) if retval != os.EX_OK: sys.exit(retval) dosyncuri = syncuri diff --git a/pym/portage/__init__.py b/pym/portage/__init__.py index 758bc5814..d8ddbccb2 100644 --- a/pym/portage/__init__.py +++ b/pym/portage/__init__.py @@ -915,6 +915,12 @@ class config(object): virtuals ...etc you look in here. """ + _env_blacklist = [ + "A", "AA", "CATEGORY", "EBUILD_PHASE", "EMERGE_FROM", + "PF", "PKGUSE", "PORTAGE_CONFIGROOT", "PORTAGE_IUSE", + "PORTAGE_USE", "ROOT", "EPREFIX", "EROOT" + ] + _environ_whitelist = [] # Whitelisted variables are always allowed to enter the ebuild @@ -1439,10 +1445,7 @@ class config(object): self.lookuplist.reverse() # Blacklist vars that could interfere with portage internals. - for blacklisted in "CATEGORY", "EBUILD_PHASE", \ - "EMERGE_FROM", "PKGUSE", "PORTAGE_CONFIGROOT", \ - "PORTAGE_IUSE", "PORTAGE_USE", "ROOT", \ - "EPREFIX", "EROOT": + for blacklisted in self._env_blacklist: for cfg in self.lookuplist: cfg.pop(blacklisted, None) del blacklisted, cfg @@ -1925,8 +1928,6 @@ class config(object): env_configdict = self.configdict["env"] pkg_configdict = self.configdict["pkg"] previous_iuse = pkg_configdict.get("IUSE") - for k in ("A", "AA", "CATEGORY", "PKGUSE", "PF", "PORTAGE_USE"): - env_configdict.pop(k, None) pkg_configdict["CATEGORY"] = cat pkg_configdict["PF"] = pf if mydb: @@ -4533,7 +4534,7 @@ def _check_build_log(mysettings, out=None): configure_opts_warn = [] configure_opts_warn_re = re.compile( - r'^configure: WARNING: Unrecognized options: ') + r'^configure: WARNING: [Uu]nrecognized options: ') am_maintainer_mode_re = re.compile(r'/missing --run ') am_maintainer_mode_exclude_re = \ re.compile(r'/missing --run (autoheader|makeinfo)')