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.
This commit is contained in:
committed by
Lennart Poettering
parent
9be3c60570
commit
e92aaed30e
+1
-1
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
+1
-1
@@ -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();
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
+1
-1
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user