@@ -, +, @@ /etc/profile.env /etc/csh.env /etc/ld.so.conf /etc/prelink.conf.d/portage.conf --- lib/portage/util/env_update.py | 35 +++++++++++++++++++++++++--------- 1 file changed, 26 insertions(+), 9 deletions(-) --- a/lib/portage/util/env_update.py +++ a/lib/portage/util/env_update.py @@ -1,4 +1,4 @@ -# Copyright 2010-2014 Gentoo Foundation +# Copyright 2010-2019 Gentoo Authors # Distributed under the terms of the GNU General Public License v2 __all__ = ['env_update'] @@ -112,6 +112,7 @@ def _env_update(makelinks, target_root, prev_mtimes, contents, env, "CLASSPATH", "INFODIR", "INFOPATH", "KDEDIRS", "LDPATH", "MANPATH", "PATH", "PKG_CONFIG_PATH", "PRELINK_PATH", "PRELINK_PATH_MASK", "PYTHONPATH", "ROOTPATH"]) + canonicalization_exempted = set(["CONFIG_PROTECT", "CONFIG_PROTECT_MASK"]) config_list = [] @@ -135,6 +136,9 @@ def _env_update(makelinks, target_root, prev_mtimes, contents, env, if "COLON_SEPARATED" in myconfig: colon_separated.update(myconfig["COLON_SEPARATED"].split()) del myconfig["COLON_SEPARATED"] + if "CANONICALIZATION_EXEMPTED" in myconfig: + canonicalization_exempted.update(myconfig["CANONICALIZATION_EXEMPTED"].split()) + del myconfig["CANONICALIZATION_EXEMPTED"] env = {} specials = {} @@ -143,8 +147,12 @@ def _env_update(makelinks, target_root, prev_mtimes, contents, env, for myconfig in config_list: if var in myconfig: for item in myconfig[var].split(): - if item and not item in mylist: - mylist.append(item) + if item: + if var not in canonicalization_exempted and os.path.isabs(item): + # Canonicalize path + item = os.path.realpath(item) + if not item in mylist: + mylist.append(item) del myconfig[var] # prepare for env.update(myconfig) if mylist: env[var] = " ".join(mylist) @@ -155,16 +163,24 @@ def _env_update(makelinks, target_root, prev_mtimes, contents, env, for myconfig in config_list: if var in myconfig: for item in myconfig[var].split(":"): - if item and not item in mylist: - mylist.append(item) + if item: + if var not in canonicalization_exempted and os.path.isabs(item): + # Canonicalize path + item = os.path.realpath(item) + if not item in mylist: + mylist.append(item) del myconfig[var] # prepare for env.update(myconfig) if mylist: env[var] = ":".join(mylist) specials[var] = mylist for myconfig in config_list: - """Cumulative variables have already been deleted from myconfig so that - they won't be overwritten by this dict.update call.""" + for var in myconfig: + if var not in canonicalization_exempted and os.path.isabs(myconfig[var]): + # Canonicalize path + myconfig[var] = os.path.realpath(myconfig[var]) + # Cumulative variables have already been deleted from myconfig so that + # they won't be overwritten by this dict.update call. env.update(myconfig) ldsoconf_path = os.path.join(eroot, "etc", "ld.so.conf") @@ -206,7 +222,7 @@ def _env_update(makelinks, target_root, prev_mtimes, contents, env, except UnicodeDecodeError: continue if os.path.basename(y) != 'libexec': - potential_lib_dirs.add(y[len(eroot):]) + potential_lib_dirs.add(os.path.realpath(y)[len(eroot):]) # Update prelink.conf if we are prelink-enabled if prelink_capable: @@ -216,7 +232,8 @@ def _env_update(makelinks, target_root, prev_mtimes, contents, env, newprelink.write("# prelink.conf autogenerated by env-update; make all changes to\n") newprelink.write("# contents of /etc/env.d directory\n") - for x in sorted(potential_lib_dirs) + ['bin', 'sbin']: + for x in sorted(potential_lib_dirs) + \ + sorted(set(os.path.realpath(os.path.join(eroot, y))[len(eroot):] for y in ('bin', 'sbin'))): newprelink.write('-l /%s\n' % (x,)); prelink_paths = set() prelink_paths |= set(specials.get('LDPATH', [])) --