From f1fb0b5e24b78d8ab7837d053d86deebf2e4d9bc Mon Sep 17 00:00:00 2001 From: Robert Love Date: Fri, 5 May 2006 19:42:20 +0000 Subject: [PATCH] 2006-05-05 Robert Love * src/NetworkManager.c: Set the umask to 0022 when daemonizing, in case root has a wacky default of its own (or, more common, a user has a bad umask and uses su/sudo to restart NetworkManager). Anything other than 0022 does not do what we want with, for example, resolv.conf. This problem is amplified by our judicious use of fopen(), which uses mode 0666 -- implying that the only way to get the permissions we want is with a umask of 0022. git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@1719 4912f4e0-d625-0410-9fb7-b9a5a253dbdc --- ChangeLog | 10 ++++++++++ src/NetworkManager.c | 7 +++++++ 2 files changed, 17 insertions(+) diff --git a/ChangeLog b/ChangeLog index 65cdfdcf57..ec09994899 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2006-05-05 Robert Love + + * src/NetworkManager.c: Set the umask to 0022 when daemonizing, in case + root has a wacky default of its own (or, more common, a user has a + bad umask and uses su/sudo to restart NetworkManager). Anything other + than 0022 does not do what we want with, for example, resolv.conf. This + problem is amplified by our judicious use of fopen(), which uses mode + 0666 -- implying that the only way to get the permissions we want is + with a umask of 0022. + 2006-05-05 Dan Williams * gnome/libnm_glib/libnm_glib.c diff --git a/src/NetworkManager.c b/src/NetworkManager.c index 33ea3b9d10..8953af0c53 100644 --- a/src/NetworkManager.c +++ b/src/NetworkManager.c @@ -743,6 +743,13 @@ int main( int argc, char *argv[] ) write_pidfile (pidfile); } + /* + * Set the umask to 0022, which results in 0666 & ~0022 = 0644. + * Otherwise, if root (or an su'ing user) has a wacky umask, we could + * write out an unreadable resolv.conf. + */ + umask (022); + g_type_init (); if (!g_thread_supported ()) g_thread_init (NULL);