Add a variant of g_file_set_contents() which accepts file mode
Submitted by Beniamino Galvani
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)