From 51c91957ae7378547604f1e008fabab28145d7b8 Mon Sep 17 00:00:00 2001 From: Panu Matilainen Date: Tue, 30 Oct 2007 14:31:42 +0200 Subject: Use rpmtsRootDir() instead of ts->rootDir + url guess-games in psm --- lib/psm.c | 24 +++++------------------- lib/rpmts.c | 1 + lib/rpmts.h | 1 + 3 files changed, 7 insertions(+), 19 deletions(-) diff --git a/lib/psm.c b/lib/psm.c index ffa1c868b..c811de8ef 100644 --- a/lib/psm.c +++ b/lib/psm.c @@ -795,13 +795,8 @@ static rpmRC runScript(rpmpsm psm, Header h, const char * sln, } } - rootDir = ts->rootDir; /* HACK: rootDir = rpmtsRootDir(ts); instead */ - if (rootDir != NULL) /* XXX can't happen */ - switch(urlIsURL(rootDir)) { - case URL_IS_PATH: - rootDir += sizeof("file://") - 1; - rootDir = strchr(rootDir, '/'); - case URL_IS_UNKNOWN: + rootDir = rpmtsRootDir(ts); + if (rootDir != NULL) { /* XXX can't happen */ if (!rpmtsChrootDone(ts) && !(rootDir[0] == '/' && rootDir[1] == '\0')) { @@ -818,21 +813,12 @@ static rpmRC runScript(rpmpsm psm, Header h, const char * sln, /* Permit libselinux to do the scriptlet exec. */ if (rpmtsSELinuxEnabled(ts) == 1) { xx = rpm_execcon(0, argv[0], (char ** const) argv, environ); - if (xx != 0) - break; } - xx = execv(argv[0], (char *const *)argv); - break; - case URL_IS_HTTPS: - case URL_IS_HTTP: - case URL_IS_FTP: - case URL_IS_DASH: - case URL_IS_HKP: - default: - break; + if (xx == 0) { + xx = execv(argv[0], (char *const *)argv); + } } - _exit(-1); } diff --git a/lib/rpmts.c b/lib/rpmts.c index c297b42d3..df6c47175 100644 --- a/lib/rpmts.c +++ b/lib/rpmts.c @@ -1051,6 +1051,7 @@ const char * rpmtsRootDir(rpmts ts) case URL_IS_UNKNOWN: case URL_IS_PATH: break; + /* XXX these shouldn't be allowed as rootdir! */ case URL_IS_HTTPS: case URL_IS_HTTP: case URL_IS_HKP: diff --git a/lib/rpmts.h b/lib/rpmts.h index 88f160135..ee6f660a9 100644 --- a/lib/rpmts.h +++ b/lib/rpmts.h @@ -586,6 +586,7 @@ extern const char * rpmtsRootDir(rpmts ts); /** \ingroup rpmts * Set transaction rootDir, i.e. path to chroot(2). + * @todo disallow funky http:// etc urls... * @param ts transaction set * @param rootDir new transaction rootDir (or NULL) */ -- cgit v1.2.3