core: rename and add comment to ExecParameters cleanup functions
This commit is contained in:
committed by
Yu Watanabe
parent
f70a264cf3
commit
fba173ff6a
+10
-3
@@ -2464,10 +2464,13 @@ void exec_runtime_clear(ExecRuntime *rt) {
|
||||
rt->ephemeral_copy = mfree(rt->ephemeral_copy);
|
||||
}
|
||||
|
||||
void exec_params_clear(ExecParameters *p) {
|
||||
void exec_params_shallow_clear(ExecParameters *p) {
|
||||
if (!p)
|
||||
return;
|
||||
|
||||
/* This is called on the PID1 side, as many of the struct's FDs are only borrowed, and actually
|
||||
* owned by the manager or other objects, and reused across multiple units. */
|
||||
|
||||
p->environment = strv_free(p->environment);
|
||||
p->fd_names = strv_free(p->fd_names);
|
||||
p->files_env = strv_free(p->files_env);
|
||||
@@ -2481,10 +2484,14 @@ void exec_params_clear(ExecParameters *p) {
|
||||
p->confirm_spawn = mfree(p->confirm_spawn);
|
||||
}
|
||||
|
||||
void exec_params_serialized_done(ExecParameters *p) {
|
||||
void exec_params_deep_clear(ExecParameters *p) {
|
||||
if (!p)
|
||||
return;
|
||||
|
||||
/* This is called on the sd-executor side, where everything received is owned by the process and has
|
||||
* to be fully cleaned up to make sanitizers and analyzers happy, as opposed as the shallow clean
|
||||
* function above. */
|
||||
|
||||
close_many_unset(p->fds, p->n_socket_fds + p->n_storage_fds);
|
||||
|
||||
p->cgroup_path = mfree(p->cgroup_path);
|
||||
@@ -2512,7 +2519,7 @@ void exec_params_serialized_done(ExecParameters *p) {
|
||||
|
||||
p->fallback_smack_process_label = mfree(p->fallback_smack_process_label);
|
||||
|
||||
exec_params_clear(p);
|
||||
exec_params_shallow_clear(p);
|
||||
}
|
||||
|
||||
void exec_directory_done(ExecDirectory *d) {
|
||||
|
||||
+2
-2
@@ -552,9 +552,9 @@ ExecRuntime* exec_runtime_destroy(ExecRuntime *rt);
|
||||
void exec_runtime_clear(ExecRuntime *rt);
|
||||
|
||||
int exec_params_get_cgroup_path(const ExecParameters *params, const CGroupContext *c, char **ret);
|
||||
void exec_params_clear(ExecParameters *p);
|
||||
void exec_params_shallow_clear(ExecParameters *p);
|
||||
void exec_params_dump(const ExecParameters *p, FILE* f, const char *prefix);
|
||||
void exec_params_serialized_done(ExecParameters *p);
|
||||
void exec_params_deep_clear(ExecParameters *p);
|
||||
|
||||
bool exec_context_get_cpu_affinity_from_numa(const ExecContext *c);
|
||||
|
||||
|
||||
+1
-1
@@ -178,7 +178,7 @@ int main(int argc, char *argv[]) {
|
||||
_cleanup_(cgroup_context_done) CGroupContext cgroup_context = {};
|
||||
_cleanup_(exec_context_done) ExecContext context = {};
|
||||
_cleanup_(exec_command_done) ExecCommand command = {};
|
||||
_cleanup_(exec_params_serialized_done) ExecParameters params = EXEC_PARAMETERS_INIT(/* flags= */ 0);
|
||||
_cleanup_(exec_params_deep_clear) ExecParameters params = EXEC_PARAMETERS_INIT(/* flags= */ 0);
|
||||
_cleanup_(exec_shared_runtime_done) ExecSharedRuntime shared = {
|
||||
.netns_storage_socket = EBADF_PAIR,
|
||||
.ipcns_storage_socket = EBADF_PAIR,
|
||||
|
||||
@@ -26,14 +26,7 @@
|
||||
#include "service.h"
|
||||
|
||||
static void exec_fuzz_one(FILE *f, FDSet *fdset) {
|
||||
_cleanup_(exec_params_serialized_done) ExecParameters params = {
|
||||
.stdin_fd = -EBADF,
|
||||
.stdout_fd = -EBADF,
|
||||
.stderr_fd = -EBADF,
|
||||
.exec_fd = -EBADF,
|
||||
.user_lookup_fd = -EBADF,
|
||||
.bpf_outer_map_fd = -EBADF,
|
||||
};
|
||||
_cleanup_(exec_params_deep_clear) ExecParameters params = EXEC_PARAMETERS_INIT(/* flags= */ 0);
|
||||
_cleanup_(exec_context_done) ExecContext exec_context = {};
|
||||
_cleanup_(cgroup_context_done) CGroupContext cgroup_context = {};
|
||||
DynamicCreds dynamic_creds = {};
|
||||
|
||||
+1
-1
@@ -908,7 +908,7 @@ static void mount_dump(Unit *u, FILE *f, const char *prefix) {
|
||||
|
||||
static int mount_spawn(Mount *m, ExecCommand *c, PidRef *ret_pid) {
|
||||
|
||||
_cleanup_(exec_params_clear) ExecParameters exec_params = EXEC_PARAMETERS_INIT(
|
||||
_cleanup_(exec_params_shallow_clear) ExecParameters exec_params = EXEC_PARAMETERS_INIT(
|
||||
EXEC_APPLY_SANDBOXING|EXEC_APPLY_CHROOT|EXEC_APPLY_TTY_STDIN);
|
||||
_cleanup_(pidref_done) PidRef pidref = PIDREF_NULL;
|
||||
pid_t pid;
|
||||
|
||||
+1
-1
@@ -1611,7 +1611,7 @@ static int service_spawn_internal(
|
||||
ExecFlags flags,
|
||||
PidRef *ret_pid) {
|
||||
|
||||
_cleanup_(exec_params_clear) ExecParameters exec_params = EXEC_PARAMETERS_INIT(flags);
|
||||
_cleanup_(exec_params_shallow_clear) ExecParameters exec_params = EXEC_PARAMETERS_INIT(flags);
|
||||
_cleanup_(sd_event_source_unrefp) sd_event_source *exec_fd_source = NULL;
|
||||
_cleanup_strv_free_ char **final_env = NULL, **our_env = NULL;
|
||||
_cleanup_(pidref_done) PidRef pidref = PIDREF_NULL;
|
||||
|
||||
+1
-1
@@ -1913,7 +1913,7 @@ static int socket_coldplug(Unit *u) {
|
||||
|
||||
static int socket_spawn(Socket *s, ExecCommand *c, PidRef *ret_pid) {
|
||||
|
||||
_cleanup_(exec_params_clear) ExecParameters exec_params = EXEC_PARAMETERS_INIT(
|
||||
_cleanup_(exec_params_shallow_clear) ExecParameters exec_params = EXEC_PARAMETERS_INIT(
|
||||
EXEC_APPLY_SANDBOXING|EXEC_APPLY_CHROOT|EXEC_APPLY_TTY_STDIN);
|
||||
_cleanup_(pidref_done) PidRef pidref = PIDREF_NULL;
|
||||
pid_t pid;
|
||||
|
||||
+1
-1
@@ -632,7 +632,7 @@ static void swap_dump(Unit *u, FILE *f, const char *prefix) {
|
||||
|
||||
static int swap_spawn(Swap *s, ExecCommand *c, PidRef *ret_pid) {
|
||||
|
||||
_cleanup_(exec_params_clear) ExecParameters exec_params = EXEC_PARAMETERS_INIT(
|
||||
_cleanup_(exec_params_shallow_clear) ExecParameters exec_params = EXEC_PARAMETERS_INIT(
|
||||
EXEC_APPLY_SANDBOXING|EXEC_APPLY_CHROOT|EXEC_APPLY_TTY_STDIN);
|
||||
_cleanup_(pidref_done) PidRef pidref = PIDREF_NULL;
|
||||
pid_t pid;
|
||||
|
||||
Reference in New Issue
Block a user