aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Andersen <andersen@codepoet.org>2004-10-13 06:25:52 +0000
committerEric Andersen <andersen@codepoet.org>2004-10-13 06:25:52 +0000
commit0e020d10257a7f1e4cd526eb6c49ba67a442ba85 (patch)
tree0f595c0a178264458bdeadab565bb5892f006d97
parent9315842242f18e3c5cf706b2bb349757928b2b40 (diff)
downloadbusybox-0e020d10257a7f1e4cd526eb6c49ba67a442ba85.tar.gz
Make certain clients of bb_make_directory default to honoring
the user's umask
-rw-r--r--archival/libunarchive/data_extract_all.c2
-rw-r--r--libbb/make_directory.c9
-rw-r--r--miscutils/devfsd.c2
3 files changed, 10 insertions, 3 deletions
diff --git a/archival/libunarchive/data_extract_all.c b/archival/libunarchive/data_extract_all.c
index 52edaa182..d10d665f6 100644
--- a/archival/libunarchive/data_extract_all.c
+++ b/archival/libunarchive/data_extract_all.c
@@ -35,7 +35,7 @@ extern void data_extract_all(archive_handle_t *archive_handle)
if (archive_handle->flags & ARCHIVE_CREATE_LEADING_DIRS) {
char *name = bb_xstrdup(file_header->name);
- bb_make_directory (dirname(name), 0777, FILEUTILS_RECUR);
+ bb_make_directory (dirname(name), -1, FILEUTILS_RECUR);
free(name);
}
diff --git a/libbb/make_directory.c b/libbb/make_directory.c
index d07ccb93c..d96acf0d9 100644
--- a/libbb/make_directory.c
+++ b/libbb/make_directory.c
@@ -49,7 +49,14 @@ int bb_make_directory (char *path, long mode, int flags)
struct stat st;
mask = umask(0);
- umask(mask & ~0300);
+ if (mode == -1) {
+ umask(mask);
+ mode = (S_IXUSR | S_IXGRP | S_IXOTH |
+ S_IWUSR | S_IWGRP | S_IWOTH |
+ S_IRUSR | S_IRGRP | S_IROTH) & ~mask;
+ } else {
+ umask(mask & ~0300);
+ }
do {
c = 0;
diff --git a/miscutils/devfsd.c b/miscutils/devfsd.c
index c2dde91c6..5e183e61f 100644
--- a/miscutils/devfsd.c
+++ b/miscutils/devfsd.c
@@ -1547,7 +1547,7 @@ static int make_dir_tree (const char *path)
#ifdef CONFIG_DEBUG
msg_logger( NO_DIE, LOG_INFO, "make_dir_tree()\n");
#endif
- if (bb_make_directory( dirname((char *)path), S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH ,FILEUTILS_RECUR )==-1)
+ if (bb_make_directory( dirname((char *)path), -1, FILEUTILS_RECUR )==-1)
{
#ifdef CONFIG_DEBUG
msg_logger( NO_DIE, LOG_ERR, "make_dir_tree(): %s: %m\n", path);