diff options
author | Tom Gundersen <teg@jklm.no> | 2015-05-18 17:19:38 +0200 |
---|---|---|
committer | Tom Gundersen <teg@jklm.no> | 2015-05-18 23:49:35 +0200 |
commit | 712cebf146b65136f02b49eb0f64a14f4628aec9 (patch) | |
tree | c4f5be0e30529f72473ab4576bd51041710ab2e7 /src | |
parent | 0561329d1f4e6634b3b20682b036c4f22e4b5b21 (diff) |
udevd: main - reshuffle
First parse config, then sanitize environment before donig any further setup.
No functional change.
Diffstat (limited to 'src')
-rw-r--r-- | src/udev/udevd.c | 56 |
1 files changed, 28 insertions, 28 deletions
diff --git a/src/udev/udevd.c b/src/udev/udevd.c index 933b60cdd5..4f43a6fe12 100644 --- a/src/udev/udevd.c +++ b/src/udev/udevd.c @@ -1434,57 +1434,57 @@ int main(int argc, char *argv[]) { goto exit; } - r = mac_selinux_init("/dev"); - if (r < 0) { - log_error_errno(r, "could not initialize labelling: %m"); - goto exit; - } + if (arg_children_max == 0) { + cpu_set_t cpu_set; - /* set umask before creating any file/directory */ - r = chdir("/"); - if (r < 0) { - r = log_error_errno(errno, "could not change dir to /: %m"); - goto exit; - } + arg_children_max = 8; - umask(022); + if (sched_getaffinity(0, sizeof (cpu_set), &cpu_set) == 0) { + arg_children_max += CPU_COUNT(&cpu_set) * 2; + } - r = mkdir("/run/udev", 0755); - if (r < 0 && errno != EEXIST) { - r = log_error_errno(errno, "could not create /run/udev: %m"); - goto exit; + log_debug("set children_max to %u", arg_children_max); } - dev_setup(NULL); - /* before opening new files, make sure std{in,out,err} fds are in a sane state */ if (arg_daemonize) { int fd; fd = open("/dev/null", O_RDWR); - if (fd >= 0) { + if (fd < 0) + log_error("cannot open /dev/null"); + else { if (write(STDOUT_FILENO, 0, 0) < 0) dup2(fd, STDOUT_FILENO); if (write(STDERR_FILENO, 0, 0) < 0) dup2(fd, STDERR_FILENO); if (fd > STDERR_FILENO) close(fd); - } else { - log_error("cannot open /dev/null"); } } - if (arg_children_max == 0) { - cpu_set_t cpu_set; + /* set umask before creating any file/directory */ + r = chdir("/"); + if (r < 0) { + r = log_error_errno(errno, "could not change dir to /: %m"); + goto exit; + } - arg_children_max = 8; + umask(022); - if (sched_getaffinity(0, sizeof (cpu_set), &cpu_set) == 0) { - arg_children_max += CPU_COUNT(&cpu_set) * 2; - } + r = mac_selinux_init("/dev"); + if (r < 0) { + log_error_errno(r, "could not initialize labelling: %m"); + goto exit; } - log_debug("set children_max to %u", arg_children_max); + r = mkdir("/run/udev", 0755); + if (r < 0 && errno != EEXIST) { + r = log_error_errno(errno, "could not create /run/udev: %m"); + goto exit; + } + + dev_setup(NULL); r = manager_new(&manager); if (r < 0) |