Skip to content
GitLab
Projects Groups Topics Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Register
  • Sign in
  • G GLib
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributor statistics
    • Graph
    • Compare revisions
  • Issues 853
    • Issues 853
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 42
    • Merge requests 42
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Releases
  • Packages and registries
    • Packages and registries
    • Container Registry
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • GNOMEGNOME
  • GLib
  • Issues
  • #1203
Closed
Open
Issue created Sep 15, 2016 by Bugzilla@bugzilla-migration💬Reporter

Add a variant of g_file_set_contents() which accepts file mode

Submitted by Beniamino Galvani

Link to original bug (#771476)

Description

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?

Edited May 27, 2020 by Philip Withnall
Assignee
Assign to
Time tracking