diff options
author | Lennart Poettering <lennart@poettering.net> | 2013-04-04 03:39:39 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2013-04-04 03:39:39 +0200 |
commit | 5c0d398dfc4d79df2209515d28cafd9dc129838e (patch) | |
tree | 5ee8d20442689e6e50e3747e95ae939ce3815957 /src/core/manager.c | |
parent | 2fa4092c2829dd14e50c430ae2f23551d23c6c1d (diff) |
util: add a bit of syntactic sugar to run short code fragments with a different umask
Diffstat (limited to 'src/core/manager.c')
-rw-r--r-- | src/core/manager.c | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/src/core/manager.c b/src/core/manager.c index f90ccd5b5f..e26522a4dd 100644 --- a/src/core/manager.c +++ b/src/core/manager.c @@ -1984,7 +1984,6 @@ void manager_dispatch_bus_query_pid_done( int manager_open_serialization(Manager *m, FILE **_f) { char *path = NULL; - mode_t saved_umask; int fd; FILE *f; @@ -1998,9 +1997,9 @@ int manager_open_serialization(Manager *m, FILE **_f) { if (!path) return -ENOMEM; - saved_umask = umask(0077); - fd = mkostemp(path, O_RDWR|O_CLOEXEC); - umask(saved_umask); + RUN_WITH_UMASK(0077) { + fd = mkostemp(path, O_RDWR|O_CLOEXEC); + } if (fd < 0) { free(path); @@ -2515,7 +2514,6 @@ void manager_run_generators(Manager *m) { DIR *d = NULL; const char *generator_path; const char *argv[5]; - mode_t u; int r; assert(m); @@ -2549,9 +2547,9 @@ void manager_run_generators(Manager *m) { argv[3] = m->generator_unit_path_late; argv[4] = NULL; - u = umask(0022); - execute_directory(generator_path, d, (char**) argv); - umask(u); + RUN_WITH_UMASK(0022) { + execute_directory(generator_path, d, (char**) argv); + } trim_generator_dir(m, &m->generator_unit_path); trim_generator_dir(m, &m->generator_unit_path_early); |