GNOME Bugzilla – Bug 564056
Protect against umask(0177)
Last modified: 2010-12-22 23:51:00 UTC
I found this bug because I mistakenly added a "umask(0177)" to gnome-settings-daemon. This causes both fontconfig and gstreamer to create their cache directory with that umask, effectively making it unusable. This was causing gstreamer to fail to update cache in its forked child, then trying again from parent, failing there too and deciding to die, crashing my gnome-settings-daemon process! I predicted that out in my previous mail... Anyway, other than not retrying from the parent, gstreamer should: 1) chmod() its directory after creating, 2) If writing to directory fails, try again after a chmod. That's also what I'm going to make fontconfig do. More details (much more than you'd ever want to read) at: http://mces.blogspot.com/2008/12/improving-login-time-part-3.html
I have half a mind to add: old_umask = umask(0); if (old_umask & 0700) { g_warning("Fix your broken umask"); umask (old_umask & ~0700); } else { umask (old_umask); } Have I mentioned that I despise umask()?
I like the g_warning, but changing umask is racy and should be avoided from library code.
It was mostly a joke. It appears the best way to guess the current umask is to create a file or directory and look at the permissions. Which returns us to what you say above.
So yeah, skip the look and go directly to chmod.
commit 5cdcdaee07c1f81a0abdd3885050118474e6c079 Author: David Schleef <ds@schleef.org> Date: Sat Dec 4 21:06:34 2010 -0800 registry: Fix permissions if umask is broken Fixes: #564056.