summaryrefslogtreecommitdiff
path: root/src/basic/fileio.c
diff options
context:
space:
mode:
authorTopi Miettinen <topimiettinen@users.noreply.github.com>2016-09-13 06:20:38 +0000
committerSven Eden <yamakuzure@gmx.net>2017-07-05 08:50:53 +0200
commit8d0461b82d5084290e9bfb71ab4aa848df196b50 (patch)
treea46f378c63da01f7dfb02975d3d8bb3eb01c5fca /src/basic/fileio.c
parent2aa9a6ee147f5dab268d9546af3ef3749153dadd (diff)
fileio: simplify mkostemp_safe() (#4090)
According to its manual page, flags given to mkostemp(3) shouldn't include O_RDWR, O_CREAT or O_EXCL flags as these are always included. Beyond those, the only flag that all callers (except a few tests where it probably doesn't matter) use is O_CLOEXEC, so set that unconditionally.
Diffstat (limited to 'src/basic/fileio.c')
-rw-r--r--src/basic/fileio.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/basic/fileio.c b/src/basic/fileio.c
index d60cd7620..4ad2acf3b 100644
--- a/src/basic/fileio.c
+++ b/src/basic/fileio.c
@@ -1046,7 +1046,7 @@ int fopen_temporary(const char *path, FILE **_f, char **_temp_path) {
if (r < 0)
return r;
- fd = mkostemp_safe(t, O_WRONLY|O_CLOEXEC);
+ fd = mkostemp_safe(t);
if (fd < 0) {
free(t);
return -errno;
@@ -1079,7 +1079,7 @@ int fflush_and_check(FILE *f) {
}
/* This is much like mkostemp() but is subject to umask(). */
-int mkostemp_safe(char *pattern, int flags) {
+int mkostemp_safe(char *pattern) {
_cleanup_umask_ mode_t u = 0;
int fd;
@@ -1087,7 +1087,7 @@ int mkostemp_safe(char *pattern, int flags) {
u = umask(077);
- fd = mkostemp(pattern, flags);
+ fd = mkostemp(pattern, O_CLOEXEC);
if (fd < 0)
return -errno;
@@ -1293,7 +1293,7 @@ int open_tmpfile_unlinkable(const char *directory, int flags) {
/* Fall back to unguessable name + unlinking */
p = strjoina(directory, "/systemd-tmp-XXXXXX");
- fd = mkostemp_safe(p, flags);
+ fd = mkostemp_safe(p);
if (fd < 0)
return fd;