aboutsummaryrefslogtreecommitdiff
path: root/libbb/make_directory.c
diff options
context:
space:
mode:
Diffstat (limited to 'libbb/make_directory.c')
-rw-r--r--libbb/make_directory.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/libbb/make_directory.c b/libbb/make_directory.c
index 7b7fde911..a06a410d2 100644
--- a/libbb/make_directory.c
+++ b/libbb/make_directory.c
@@ -50,13 +50,17 @@ int make_directory (char *path, long mode, int flags)
50 50
51 if (stat (path, &st) < 0 && errno == ENOENT) { 51 if (stat (path, &st) < 0 && errno == ENOENT) {
52 int status; 52 int status;
53 char *parent = dirname (path); 53 char *buf, *parent;
54 mode_t mask = umask (0); 54 mode_t mask;
55
56 mask = umask (0);
55 umask (mask); 57 umask (mask);
56 58
59 buf = xstrdup (path);
60 parent = dirname (buf);
57 status = make_directory (parent, (0777 & ~mask) | 0300, 61 status = make_directory (parent, (0777 & ~mask) | 0300,
58 FILEUTILS_RECUR); 62 FILEUTILS_RECUR);
59 free (parent); 63 free (buf);
60 64
61 if (status < 0 || make_directory (path, mode, 0) < 0) 65 if (status < 0 || make_directory (path, mode, 0) < 0)
62 return -1; 66 return -1;