From e92aaed30e0b5750e5633765f1bddd51c96678e5 Mon Sep 17 00:00:00 2001 From: Chris Down Date: Wed, 12 Dec 2018 14:58:46 +0000 Subject: [PATCH] tree-wide: Remove O_CLOEXEC from fdopen fdopen doesn't accept "e", it's ignored. Let's not mislead people into believing that it actually sets O_CLOEXEC. From `man 3 fdopen`: > e (since glibc 2.7): > Open the file with the O_CLOEXEC flag. See open(2) for more information. This flag is ignored for fdopen() As mentioned by @jlebon in #11131. --- src/basic/fileio.c | 2 +- src/basic/tmpfile-util.c | 2 +- src/boot/bootctl.c | 2 +- src/core/load-fragment.c | 2 +- src/core/smack-setup.c | 6 +++--- src/coredump/coredump.c | 2 +- src/fsck/fsck.c | 2 +- src/machine/machine-dbus.c | 2 +- src/machine/machined-dbus.c | 2 +- src/network/test-routing-policy-rule.c | 6 +++--- src/nspawn/nspawn-setuid.c | 4 ++-- src/portable/portable.c | 2 +- src/portable/portabled-image-bus.c | 2 +- src/shared/dissect-image.c | 2 +- src/shared/exec-util.c | 2 +- src/shared/install.c | 2 +- src/shared/os-util.c | 2 +- 17 files changed, 22 insertions(+), 22 deletions(-) diff --git a/src/basic/fileio.c b/src/basic/fileio.c index 4c200f8393e..11972a62138 100644 --- a/src/basic/fileio.c +++ b/src/basic/fileio.c @@ -156,7 +156,7 @@ int write_string_file_ts( goto fail; } - f = fdopen(fd, "we"); + f = fdopen(fd, "w"); if (!f) { r = -errno; safe_close(fd); diff --git a/src/basic/tmpfile-util.c b/src/basic/tmpfile-util.c index dba0492ba84..669eb2666ce 100644 --- a/src/basic/tmpfile-util.c +++ b/src/basic/tmpfile-util.c @@ -36,7 +36,7 @@ int fopen_temporary(const char *path, FILE **_f, char **_temp_path) { return -errno; } - f = fdopen(fd, "we"); + f = fdopen(fd, "w"); if (!f) { unlink_noerrno(t); free(t); diff --git a/src/boot/bootctl.c b/src/boot/bootctl.c index 2008341f631..fc4726e69a0 100644 --- a/src/boot/bootctl.c +++ b/src/boot/bootctl.c @@ -823,7 +823,7 @@ static int install_loader_config(const char *esp_path) { if (fd < 0) return log_error_errno(fd, "Failed to open \"%s\" for writing: %m", p); - f = fdopen(fd, "we"); + f = fdopen(fd, "w"); if (!f) { safe_close(fd); return log_oom(); diff --git a/src/core/load-fragment.c b/src/core/load-fragment.c index 36e874de294..fc5644f4896 100644 --- a/src/core/load-fragment.c +++ b/src/core/load-fragment.c @@ -4415,7 +4415,7 @@ static int open_follow(char **filename, FILE **_f, Set *names, char **_final) { free_and_replace(*filename, target); } - f = fdopen(fd, "re"); + f = fdopen(fd, "r"); if (!f) { safe_close(fd); return -errno; diff --git a/src/core/smack-setup.c b/src/core/smack-setup.c index 4bb2051aa3d..49b37aefc72 100644 --- a/src/core/smack-setup.c +++ b/src/core/smack-setup.c @@ -72,7 +72,7 @@ static int write_access2_rules(const char* srcdir) { continue; } - policy = fdopen(fd, "re"); + policy = fdopen(fd, "r"); if (!policy) { if (r == 0) r = -errno; @@ -154,7 +154,7 @@ static int write_cipso2_rules(const char* srcdir) { continue; } - policy = fdopen(fd, "re"); + policy = fdopen(fd, "r"); if (!policy) { if (r == 0) r = -errno; @@ -227,7 +227,7 @@ static int write_netlabel_rules(const char* srcdir) { continue; } - policy = fdopen(fd, "re"); + policy = fdopen(fd, "r"); if (!policy) { if (r == 0) r = -errno; diff --git a/src/coredump/coredump.c b/src/coredump/coredump.c index 79d627c465c..0c888b26f9c 100644 --- a/src/coredump/coredump.c +++ b/src/coredump/coredump.c @@ -553,7 +553,7 @@ static int compose_open_fds(pid_t pid, char **open_fds) { if (fd < 0) continue; - fdinfo = fdopen(fd, "re"); + fdinfo = fdopen(fd, "r"); if (!fdinfo) { safe_close(fd); continue; diff --git a/src/fsck/fsck.c b/src/fsck/fsck.c index 7fc4a283ce8..ba39f596fc7 100644 --- a/src/fsck/fsck.c +++ b/src/fsck/fsck.c @@ -177,7 +177,7 @@ static int process_progress(int fd) { if (fd < 0) return 0; - f = fdopen(fd, "re"); + f = fdopen(fd, "r"); if (!f) { safe_close(fd); return -errno; diff --git a/src/machine/machine-dbus.c b/src/machine/machine-dbus.c index 285918b4cc5..48270b3709a 100644 --- a/src/machine/machine-dbus.c +++ b/src/machine/machine-dbus.c @@ -370,7 +370,7 @@ int bus_machine_method_get_os_release(sd_bus_message *message, void *userdata, s pair[1] = safe_close(pair[1]); - f = fdopen(pair[0], "re"); + f = fdopen(pair[0], "r"); if (!f) return -errno; diff --git a/src/machine/machined-dbus.c b/src/machine/machined-dbus.c index d613414fded..9afae72ae5f 100644 --- a/src/machine/machined-dbus.c +++ b/src/machine/machined-dbus.c @@ -615,7 +615,7 @@ static int clean_pool_done(Operation *operation, int ret, sd_bus_error *error) { if (lseek(operation->extra_fd, 0, SEEK_SET) == (off_t) -1) return -errno; - f = fdopen(operation->extra_fd, "re"); + f = fdopen(operation->extra_fd, "r"); if (!f) return -errno; diff --git a/src/network/test-routing-policy-rule.c b/src/network/test-routing-policy-rule.c index f80f3c09a90..57bfb6af680 100644 --- a/src/network/test-routing-policy-rule.c +++ b/src/network/test-routing-policy-rule.c @@ -28,14 +28,14 @@ static void test_rule_serialization(const char *title, const char *ruleset, cons fd = mkostemp_safe(pattern); assert_se(fd >= 0); - assert_se(f = fdopen(fd, "a+e")); + assert_se(f = fdopen(fd, "a+")); assert_se(write_string_stream(f, ruleset, 0) == 0); assert_se(routing_policy_load_rules(pattern, &rules) == 0); fd2 = mkostemp_safe(pattern2); assert_se(fd2 >= 0); - assert_se(f2 = fdopen(fd2, "a+e")); + assert_se(f2 = fdopen(fd2, "a+")); assert_se(routing_policy_serialize_rules(rules, f2) == 0); assert_se(fflush_and_check(f2) == 0); @@ -46,7 +46,7 @@ static void test_rule_serialization(const char *title, const char *ruleset, cons fd3 = mkostemp_safe(pattern3); assert_se(fd3 >= 0); - assert_se(f3 = fdopen(fd3, "we")); + assert_se(f3 = fdopen(fd3, "w")); assert_se(write_string_stream(f3, expected ?: ruleset, 0) == 0); cmd = strjoina("diff -u ", pattern3, " ", pattern2); diff --git a/src/nspawn/nspawn-setuid.c b/src/nspawn/nspawn-setuid.c index 86fd9deec0f..0026e4e3fc7 100644 --- a/src/nspawn/nspawn-setuid.c +++ b/src/nspawn/nspawn-setuid.c @@ -91,7 +91,7 @@ int change_uid_gid(const char *user, char **_home) { if (fd < 0) return fd; - f = fdopen(fd, "re"); + f = fdopen(fd, "r"); if (!f) return log_oom(); fd = -1; @@ -164,7 +164,7 @@ int change_uid_gid(const char *user, char **_home) { if (fd < 0) return fd; - f = fdopen(fd, "re"); + f = fdopen(fd, "r"); if (!f) return log_oom(); fd = -1; diff --git a/src/portable/portable.c b/src/portable/portable.c index 5b62486ea9e..920bd866f56 100644 --- a/src/portable/portable.c +++ b/src/portable/portable.c @@ -1089,7 +1089,7 @@ static int test_chroot_dropin( return log_debug_errno(errno, "Failed to open %s/%s: %m", where, p); } - f = fdopen(fd, "re"); + f = fdopen(fd, "r"); if (!f) return log_debug_errno(errno, "Failed to convert file handle: %m"); fd = -1; diff --git a/src/portable/portabled-image-bus.c b/src/portable/portabled-image-bus.c index 1e618175c72..360559811fa 100644 --- a/src/portable/portabled-image-bus.c +++ b/src/portable/portabled-image-bus.c @@ -73,7 +73,7 @@ static int append_fd(sd_bus_message *m, PortableMetadata *d) { assert(d); assert(d->fd >= 0); - f = fdopen(d->fd, "re"); + f = fdopen(d->fd, "r"); if (!f) return -errno; diff --git a/src/shared/dissect-image.c b/src/shared/dissect-image.c index 4e572ac861c..6ea8e4df8d9 100644 --- a/src/shared/dissect-image.c +++ b/src/shared/dissect-image.c @@ -1300,7 +1300,7 @@ int dissected_image_acquire_metadata(DissectedImage *m) { fds[2*k+1] = safe_close(fds[2*k+1]); - f = fdopen(fds[2*k], "re"); + f = fdopen(fds[2*k], "r"); if (!f) { r = -errno; goto finish; diff --git a/src/shared/exec-util.c b/src/shared/exec-util.c index d66b3004590..17a278a00fc 100644 --- a/src/shared/exec-util.c +++ b/src/shared/exec-util.c @@ -308,7 +308,7 @@ static int gather_environment_consume(int fd, void *arg) { assert(env); - f = fdopen(fd, "re"); + f = fdopen(fd, "r"); if (!f) { safe_close(fd); return -errno; diff --git a/src/shared/install.c b/src/shared/install.c index 822645ef43b..51d33b80e98 100644 --- a/src/shared/install.c +++ b/src/shared/install.c @@ -1286,7 +1286,7 @@ static int unit_file_load( if (r < 0) return r; - f = fdopen(fd, "re"); + f = fdopen(fd, "r"); if (!f) return -errno; fd = -1; diff --git a/src/shared/os-util.c b/src/shared/os-util.c index f7d46d3c477..b2d5ce32e77 100644 --- a/src/shared/os-util.c +++ b/src/shared/os-util.c @@ -74,7 +74,7 @@ int fopen_os_release(const char *root, char **ret_path, FILE **ret_file) { if (r < 0) return r; - f = fdopen(fd, "re"); + f = fdopen(fd, "r"); if (!f) return -errno; fd = -1; -- 2.39.2