Skip to content
  • Beniamino Galvani's avatar
    core: introduce and use nm_utils_file_set_contents() · 21358edc
    Beniamino Galvani authored
    In some places we use g_file_set_contents() after a umask() to limit
    the permissions of the created file. Unfortunately if the containing
    directory has a default ACL the umask will be ignored and the new file
    will have a mode equal to the default ACL (since g_file_set_contents()
    opens the file with mode 0666).
    
    Calling a chmod() after the file gets created is insecure (see commit
    60b7ed3b) and so the only solution seems to be to reimplement
    g_file_set_contents() and accept a mode as parameter.
    
    We already had similar functions in the tree, consolidate them into a
    new generic utility function.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=769702
    21358edc