Skip to content

Commit

Permalink
properly fix umask handling
Browse files Browse the repository at this point in the history
https://dev.openwrt.org/ticket/13752
https://dev.openwrt.org/ticket/13794

Signed-off-by: John Crispin <blogic@openwrt.org>
  • Loading branch information
John Crispin committed Jul 3, 2013
1 parent a295354 commit 4ec2545
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 1 deletion.
2 changes: 2 additions & 0 deletions hotplug.c
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ static void mkdir_p(char *dir)

static void handle_makedev(struct blob_attr *msg, struct blob_attr *data)
{
unsigned int oldumask = umask(0);
static struct blobmsg_policy mkdev_policy[2] = {
{ .type = BLOBMSG_TYPE_STRING },
{ .type = BLOBMSG_TYPE_STRING },
Expand All @@ -104,6 +105,7 @@ static void handle_makedev(struct blob_attr *msg, struct blob_attr *data)
m | strtoul(blobmsg_data(tb[1]), NULL, 8),
makedev(atoi(major), atoi(minor)));
}
umask(oldumask);
}

static void handle_rm(struct blob_attr *msg, struct blob_attr *data)
Expand Down
1 change: 0 additions & 1 deletion main.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ int main(int argc, char **argv)
return usage(argv[0]);
}
}
umask(0);
uloop_init();
procd_signal();
if (getpid() != 1)
Expand Down
3 changes: 3 additions & 0 deletions mkdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,15 @@ static bool find_pattern(const char *name)

static void make_dev(const char *path, bool block, int major, int minor)
{
unsigned int oldumask = umask(0);
unsigned int _mode = mode | (block ? S_IFBLK : S_IFCHR);

DEBUG(2, "Creating %s device %s(%d,%d)\n",
block ? "block" : "character",
path, major, minor);

mknod(path, _mode, makedev(major, minor));
umask(oldumask);
}

static void find_devs(bool block)
Expand Down

0 comments on commit 4ec2545

Please sign in to comment.