commit:     18886e6e1c037ea95a05ff200a8a5097df80d9fe
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Mon Jun 10 10:01:35 2019 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Mon Jun 10 10:01:35 2019 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=18886e6e

qmerge: fix some issues regarding EPREFIX usage

- EROOT and ED don't have EPREFIX prefixed, but postfixed
- config_protect should expect the checked paths not to have EPREFIX

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qmerge.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/qmerge.c b/qmerge.c
index c11856b..31a9648 100644
--- a/qmerge.c
+++ b/qmerge.c
@@ -358,6 +358,10 @@ config_protected(const char *buf, int cp_argc, char 
**cp_argv,
        char dest[_Q_PATH_MAX];
        snprintf(dest, sizeof(dest), "%s%s", portroot, buf);
 
+       /* config protect paths don't carry EPREFIX */
+       if (strncmp(buf, CONFIG_EPREFIX, strlen(CONFIG_EPREFIX) - 1) == 0)
+               buf += strlen(CONFIG_EPREFIX) - 1;
+
        /* Check CONFIG_PROTECT_MASK */
        for (i = 1; i < cpm_argc; ++i)
                if (strncmp(cpm_argv[i], buf, strlen(cpm_argv[i])) == 0)
@@ -370,7 +374,7 @@ config_protected(const char *buf, int cp_argc, char 
**cp_argv,
                                return 1;
 
        /* this would probably be bad */
-       if (strcmp("/bin/sh", buf) == 0)
+       if (strcmp(CONFIG_EPREFIX "bin/sh", buf) == 0)
                return 1;
 
        return 0;
@@ -750,9 +754,9 @@ pkg_run_func_at(int dirfd, const char *vdb_path, const char 
*phases, const char
                "FILESDIR=/.does/not/exist/anywhere\n"
                "MERGE_TYPE=binary\n"
                "ROOT='%4$s'\n"
-               "EROOT=\"${EPREFIX%%/}/${ROOT#/}/\"\n"
+               "EROOT=\"/${ROOT#/}/${EPREFIX%%/}/\"\n"
                "D=\"%5$s\"\n"
-               "ED=\"${EPREFIX%%/}/${D#/}/\"\n"
+               "ED=\"${D%%/}/${EPREFIX%%/}/\"\n"
                "T=\"%6$s\"\n"
                /* Finally run the func */
                "%7$s%2$s\n"

Reply via email to