After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 771476 - Please add a variant of g_file_set_contents() which accepts file mode
Please add a variant of g_file_set_contents() which accepts file mode
Status: RESOLVED OBSOLETE
Product: glib
Classification: Platform
Component: general
unspecified
Other Linux
: Normal enhancement
: ---
Assigned To: gtkdev
gtkdev
Depends on:
Blocks:
 
 
Reported: 2016-09-15 08:23 UTC by Beniamino Galvani
Modified: 2018-05-24 19:06 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Beniamino Galvani 2016-09-15 08:23:39 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?
Comment 1 GNOME Infrastructure Team 2018-05-24 19:06:05 UTC
-- 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.