diff --git a/src/util.c b/src/util.c index 086403d1b..0526a88dc 100644 --- a/src/util.c +++ b/src/util.c @@ -24,6 +24,7 @@ #include #include #include +#include #include #include @@ -54,11 +55,13 @@ void _netplan_safe_mkdir_p_dir(const char* file_path) { g_autofree char* dir = g_path_get_dirname(file_path); + mode_t orig_umask = umask(022); if (g_mkdir_with_parents(dir, 0755) < 0) { g_fprintf(stderr, "ERROR: cannot create directory %s: %m\n", dir); exit(1); } + umask(orig_umask); } /**