summaryrefslogtreecommitdiff
path: root/util-linux
diff options
context:
space:
mode:
authorDenys Vlasenko2013-01-21 01:22:12 +0100
committerDenys Vlasenko2013-01-21 01:22:12 +0100
commit4609f477c7e043a4f6147dfe6e86b775da2ef784 (patch)
treec4e51b6214438008026cd22744e57d3cb1cb27ba /util-linux
parent31dc8603eedc0140c798c9af3404a35ea190af2c (diff)
downloadbusybox-4609f477c7e043a4f6147dfe6e86b775da2ef784.zip
busybox-4609f477c7e043a4f6147dfe6e86b775da2ef784.tar.gz
mdev: fix mode of dir1 in =dir1/dir2/file rule
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'util-linux')
-rw-r--r--util-linux/mdev.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/util-linux/mdev.c b/util-linux/mdev.c
index 79871d3..75de14f 100644
--- a/util-linux/mdev.c
+++ b/util-linux/mdev.c
@@ -429,6 +429,18 @@ static const struct rule *next_rule(void)
#endif
+static void mkdir_recursive(char *name)
+{
+ /* if name has many levels ("dir1/dir2"),
+ * bb_make_directory() will create dir1 according to umask,
+ * not according to its "mode" parameter.
+ * Since we run with umask=0, need to temporarily switch it.
+ */
+ umask(022); /* "dir1" (if any) will be 0755 too */
+ bb_make_directory(name, 0755, FILEUTILS_RECUR);
+ umask(0);
+}
+
/* Builds an alias path.
* This function potentionally reallocates the alias parameter.
* Only used for ENABLE_FEATURE_MDEV_RENAME
@@ -442,7 +454,7 @@ static char *build_alias(char *alias, const char *device_name)
dest = strrchr(alias, '/');
if (dest) { /* ">bar/[baz]" ? */
*dest = '\0'; /* mkdir bar */
- bb_make_directory(alias, 0755, FILEUTILS_RECUR);
+ mkdir_recursive(alias);
*dest = '/';
if (dest[1] == '\0') { /* ">bar/" => ">bar/device_name" */
dest = alias;
@@ -641,7 +653,7 @@ static void make_device(char *device_name, char *path, int operation)
char *slash = strrchr(node_name, '/');
if (slash) {
*slash = '\0';
- bb_make_directory(node_name, 0755, FILEUTILS_RECUR);
+ mkdir_recursive(node_name);
*slash = '/';
}
if (G.verbose)