From 7200ad64c132a654c601a8eef74e6adcbeddd807 Mon Sep 17 00:00:00 2001 From: Jaroslaw Swierczynski Date: Sun, 13 Jan 2008 15:06:25 +0100 Subject: [PATCH] FS#9183 : force correct permissions on tmp/. [Xav: removed unneeded makepath_internal function, and fixed the permission value : 1777 -> 01777] Signed-off-by: Chantry Xavier --- lib/libalpm/trans.c | 2 +- lib/libalpm/util.c | 9 +++++++-- lib/libalpm/util.h | 1 + 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/lib/libalpm/trans.c b/lib/libalpm/trans.c index 292c716..ecc40a0 100644 --- a/lib/libalpm/trans.c +++ b/lib/libalpm/trans.c @@ -487,7 +487,7 @@ int _alpm_runscriptlet(const char *root, const char *installfn, /* creates a directory in $root/tmp/ for copying/extracting the scriptlet */ snprintf(tmpdir, PATH_MAX, "%stmp/", root); if(stat(tmpdir, &buf)) { - _alpm_makepath(tmpdir); + _alpm_makepath_mode(tmpdir, 01777); } snprintf(tmpdir, PATH_MAX, "%stmp/alpm_XXXXXX", root); if(mkdtemp(tmpdir) == NULL) { diff --git a/lib/libalpm/util.c b/lib/libalpm/util.c index 64006d1..12bd1e6 100644 --- a/lib/libalpm/util.c +++ b/lib/libalpm/util.c @@ -178,9 +178,14 @@ char* strsep(char** str, const char* delims) } #endif -/* does the same thing as 'mkdir -p' */ int _alpm_makepath(const char *path) { + return(_alpm_makepath_mode(path, 0755)); +} + +/* does the same thing as 'mkdir -p' */ +int _alpm_makepath_mode(const char *path, mode_t mode) +{ char *orig, *str, *ptr; char full[PATH_MAX] = ""; mode_t oldmask; @@ -196,7 +201,7 @@ int _alpm_makepath(const char *path) strcat(full, "/"); strcat(full, ptr); if(stat(full, &buf)) { - if(mkdir(full, 0755)) { + if(mkdir(full, mode)) { FREE(orig); umask(oldmask); _alpm_log(PM_LOG_ERROR, _("failed to make path '%s' : %s\n"), diff --git a/lib/libalpm/util.h b/lib/libalpm/util.h index 3ffe632..e9e0af1 100644 --- a/lib/libalpm/util.h +++ b/lib/libalpm/util.h @@ -50,6 +50,7 @@ #define ASSERT(cond, action) do { if(!(cond)) { action; } } while(0) int _alpm_makepath(const char *path); +int _alpm_makepath_mode(const char *path, mode_t mode); int _alpm_copyfile(const char *src, const char *dest); char *_alpm_strtrim(char *str); char *_alpm_strreplace(const char *str, const char *needle, const char *replace); -- 1.5.4.rc3