summaryrefslogtreecommitdiff
path: root/glnx-fdio.c
diff options
context:
space:
mode:
authorMatthew Barnes <mbarnes@redhat.com>2015-04-14 08:43:37 -0400
committerMatthew Barnes <mbarnes@redhat.com>2015-04-14 08:45:51 -0400
commit02af92ffefda4251d894f0ec7a3aff9bc26af1cd (patch)
treeae18a06ce8e2afba53b3cb7333f006aa00fedf78 /glnx-fdio.c
parent20fc302df59ea7ca928756b8221faede31bcbab4 (diff)
downloadlibglnx-02af92ffefda4251d894f0ec7a3aff9bc26af1cd.tar.gz
fdio: Fix default mode in glnx_file_replace_contents_with_perms_at()
mkostemp() defaults to 0600. Use 0644 instead unless a mode is explicitly provided. https://bugzilla.gnome.org/747813
Diffstat (limited to 'glnx-fdio.c')
-rw-r--r--glnx-fdio.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/glnx-fdio.c b/glnx-fdio.c
index db214dd..a529794 100644
--- a/glnx-fdio.c
+++ b/glnx-fdio.c
@@ -708,13 +708,13 @@ glnx_file_replace_contents_with_perms_at (int dfd,
}
}
- if (mode != (mode_t) -1)
+ if (mode == (mode_t) -1)
+ mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH;
+
+ if (fchmod (fd, mode) != 0)
{
- if (fchmod (fd, mode) != 0)
- {
- glnx_set_error_from_errno (error);
- goto out;
- }
+ glnx_set_error_from_errno (error);
+ goto out;
}
if (renameat (dfd, tmppath, dfd, subpath) != 0)