GNOME Bugzilla – Bug 771476
Please add a variant of g_file_set_contents() which accepts file mode
Last modified: 2018-05-24 19:06:05 UTC
Hi, I would like to request if it would make sense to provide a function equivalent to g_file_set_contents() but which accepts a file mode to be passed to mkstemp_full(), instead of the fixed 0666 used currently. At the moment if one wants to use g_file_set_contents() to create a file with more restricted permission it's necessary to use umask() but this has some disadvantages, like not being thread-safe and being ineffective in case the parent directory has a default ACL set (since the default ACL overrides the umask). For example, in NetworkManager we call umask() before g_file_set_contents() to create the connection files (restricted to root), but we received reports that this doesn't work well with ACLs; in my opinion it would be really helpful to have in GLib a function like: gboolean g_file_set_contents_mode (const gchar *filename, const gchar *contents, gssize length, mode_t mode GError **error) Any thoughts?
-- GitLab Migration Automatic Message -- This bug has been migrated to GNOME's GitLab instance and has been closed from further activity. You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.gnome.org/GNOME/glib/issues/1203.