From e721508850af210b82dc35a399f36249add095a6 Mon Sep 17 00:00:00 2001 From: Chantry Xavier Date: Sun, 13 Jan 2008 12:39:14 +0100 Subject: [PATCH] runscriptlet: remove the tmp directory if it was created. The runscriptlet function needs the $root/tmp directory to extract scriptlets. If it doesn't exist, it creates it (with default permissions 755). So when the filesystem package is installed (which owns the /tmp dir with the correct permission), the /tmp/ dir is created first by pacman, and ends up with the wrong permission. So the runscriptlet function will now remove the /tmp/ dir if it created it, to allow the filesystem package to install it with the correct permissions. Fixes FS#9183. Signed-off-by: Chantry Xavier --- lib/libalpm/trans.c | 14 +++++++++++--- 1 files changed, 11 insertions(+), 3 deletions(-) diff --git a/lib/libalpm/trans.c b/lib/libalpm/trans.c index 292c716..fb56fc7 100644 --- a/lib/libalpm/trans.c +++ b/lib/libalpm/trans.c @@ -465,6 +465,7 @@ int _alpm_runscriptlet(const char *root, const char *installfn, char *scriptpath; struct stat buf; pid_t pid; + int clean_tmp = 0; int clean_tmpdir = 0; int restore_cwd = 0; int retval = 0; @@ -488,11 +489,13 @@ int _alpm_runscriptlet(const char *root, const char *installfn, snprintf(tmpdir, PATH_MAX, "%stmp/", root); if(stat(tmpdir, &buf)) { _alpm_makepath(tmpdir); + clean_tmp = 1; } snprintf(tmpdir, PATH_MAX, "%stmp/alpm_XXXXXX", root); if(mkdtemp(tmpdir) == NULL) { _alpm_log(PM_LOG_ERROR, _("could not create temp directory\n")); - return(1); + retval = 1; + goto cleanup; } else { clean_tmpdir = 1; } @@ -608,8 +611,13 @@ int _alpm_runscriptlet(const char *root, const char *installfn, } cleanup: - if(clean_tmpdir && _alpm_rmrf(tmpdir)) { - _alpm_log(PM_LOG_WARNING, _("could not remove tmpdir %s\n"), tmpdir); + if(clean_tmp || clean_tmpdir) { + if(clean_tmp) { + snprintf(tmpdir, PATH_MAX, "%stmp/", root); + } + if(_alpm_rmrf(tmpdir)) { + _alpm_log(PM_LOG_WARNING, _("could not remove tmpdir %s\n"), tmpdir); + } } if(restore_cwd) { chdir(cwd); -- 1.5.4.rc3