[systemd-devel] [PATCH] main: Set umask before creating any files
Lennart Poettering
lennart at poettering.net
Thu Sep 26 11:40:51 PDT 2013
On Thu, 26.09.13 10:50, Mike Gilbert (floppym at gentoo.org) wrote:
> This avoids a problem when we inherit a non-zero umask from the
> initramfs. This would cause /run/systemd to be created with the wrong
> mode.
Merged this, but ordered things so that umask() is only invoked at one
place.
> ---
> src/core/main.c | 9 ++++++---
> 1 file changed, 6 insertions(+), 3 deletions(-)
>
> diff --git a/src/core/main.c b/src/core/main.c
> index 72bd542..f532dca 100644
> --- a/src/core/main.c
> +++ b/src/core/main.c
> @@ -1276,6 +1276,9 @@ int main(int argc, char *argv[]) {
> if (in_initrd())
> initrd_timestamp = userspace_timestamp;
>
> + /* Set umask before creating any files. */
> + umask(0);
> +
> if (!skip_setup) {
> mount_setup_early();
> if (selinux_setup(&loaded_policy) < 0)
> @@ -1339,6 +1342,9 @@ int main(int argc, char *argv[]) {
> kernel_timestamp.monotonic = 0ULL;
> kernel_timestamp.realtime = 0ULL;
>
> + /* Set umask before creating any files. */
> + umask(0);
> +
> } else {
> /* Running as user instance */
> arg_running_as = SYSTEMD_USER;
> @@ -1441,9 +1447,6 @@ int main(int argc, char *argv[]) {
> if (arg_running_as == SYSTEMD_SYSTEM) {
> /* Become a session leader if we aren't one yet. */
> setsid();
> -
> - /* Disable the umask logic */
> - umask(0);
> }
>
> /* Move out of the way, so that we won't block unmounts */
Lennart
--
Lennart Poettering - Red Hat, Inc.
More information about the systemd-devel
mailing list