diff options
author | Luca Boccassi <bluca@debian.org> | 2023-11-23 20:14:45 +0100 |
---|---|---|
committer | Luca Boccassi <bluca@debian.org> | 2023-11-23 20:14:52 +0100 |
commit | 2d042c75ffb71f59ebd4689c3972786c29b4bf51 (patch) | |
tree | 405db79a4d234f6f63a21a2b47a39b1479f5dabc /src | |
parent | core: pass bpf_outer_map_fd to sd-executor only if RestrictFileSystems was set (diff) | |
download | systemd-2d042c75ffb71f59ebd4689c3972786c29b4bf51.tar.xz systemd-2d042c75ffb71f59ebd4689c3972786c29b4bf51.zip |
core: remove redundant check when serializing FDs
The helpers already skip if the FD is < 0
Diffstat (limited to 'src')
-rw-r--r-- | src/core/execute-serialize.c | 50 |
1 files changed, 19 insertions, 31 deletions
diff --git a/src/core/execute-serialize.c b/src/core/execute-serialize.c index 60c121a0d1..56c4f4da8a 100644 --- a/src/core/execute-serialize.c +++ b/src/core/execute-serialize.c @@ -1274,11 +1274,9 @@ static int exec_parameters_serialize(const ExecParameters *p, const ExecContext return r; } - if (p->n_socket_fds + p->n_storage_fds > 0) { - r = serialize_fd_many(f, fds, "exec-parameters-fds", p->fds, p->n_socket_fds + p->n_storage_fds); - if (r < 0) - return r; - } + r = serialize_fd_many(f, fds, "exec-parameters-fds", p->fds, p->n_socket_fds + p->n_storage_fds); + if (r < 0) + return r; } r = serialize_strv(f, "exec-parameters-fd-names", p->fd_names); @@ -1351,31 +1349,23 @@ static int exec_parameters_serialize(const ExecParameters *p, const ExecContext return r; } - if (p->stdin_fd >= 0) { - r = serialize_fd(f, fds, "exec-parameters-stdin-fd", p->stdin_fd); - if (r < 0) - return r; - } + r = serialize_fd(f, fds, "exec-parameters-stdin-fd", p->stdin_fd); + if (r < 0) + return r; - if (p->stdout_fd >= 0) { - r = serialize_fd(f, fds, "exec-parameters-stdout-fd", p->stdout_fd); - if (r < 0) - return r; - } + r = serialize_fd(f, fds, "exec-parameters-stdout-fd", p->stdout_fd); + if (r < 0) + return r; - if (p->stderr_fd >= 0) { - r = serialize_fd(f, fds, "exec-parameters-stderr-fd", p->stderr_fd); - if (r < 0) - return r; - } + r = serialize_fd(f, fds, "exec-parameters-stderr-fd", p->stderr_fd); + if (r < 0) + return r; - if (p->exec_fd >= 0) { - r = serialize_fd(f, fds, "exec-parameters-exec-fd", p->exec_fd); - if (r < 0) - return r; - } + r = serialize_fd(f, fds, "exec-parameters-exec-fd", p->exec_fd); + if (r < 0) + return r; - if (c && exec_context_restrict_filesystems_set(c) && p->bpf_outer_map_fd >= 0) { + if (c && exec_context_restrict_filesystems_set(c)) { r = serialize_fd(f, fds, "exec-parameters-bpf-outer-map-fd", p->bpf_outer_map_fd); if (r < 0) return r; @@ -1401,11 +1391,9 @@ static int exec_parameters_serialize(const ExecParameters *p, const ExecContext if (r < 0) return r; - if (p->user_lookup_fd >= 0) { - r = serialize_fd(f, fds, "exec-parameters-user-lookup-fd", p->user_lookup_fd); - if (r < 0) - return r; - } + r = serialize_fd(f, fds, "exec-parameters-user-lookup-fd", p->user_lookup_fd); + if (r < 0) + return r; r = serialize_strv(f, "exec-parameters-files-env", p->files_env); if (r < 0) |