]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
core: introduce exec_params_clear()
authorYu Watanabe <watanabe.yu+github@gmail.com>
Thu, 8 Nov 2018 05:08:10 +0000 (14:08 +0900)
committerLennart Poettering <lennart@poettering.net>
Thu, 8 Nov 2018 08:36:37 +0000 (09:36 +0100)
Follow-up for 1ad6e8b302e87b6891a2bfc35ad397b0afe3d940.

Fixes #10677.

src/core/execute.c
src/core/execute.h
src/core/mount.c
src/core/service.c
src/core/socket.c
src/core/swap.c

index 33aa1093a313feb12a4f1dda04967272d74152c3..435d94a86d646cb6a0195e3f3c0fc9959dfda5f9 100644 (file)
@@ -5112,6 +5112,13 @@ void exec_runtime_vacuum(Manager *m) {
         }
 }
 
+void exec_params_clear(ExecParameters *p) {
+        if (!p)
+                return;
+
+        strv_free(p->environment);
+}
+
 static const char* const exec_input_table[_EXEC_INPUT_MAX] = {
         [EXEC_INPUT_NULL] = "null",
         [EXEC_INPUT_TTY] = "tty",
index fa08746260a89c5f87a03bb81ddd11867f581add..11a9b45dccfe2c275150cd7a5e1c57284a06cf52 100644 (file)
@@ -383,6 +383,8 @@ int exec_runtime_deserialize_compat(Unit *u, const char *key, const char *value,
 void exec_runtime_deserialize_one(Manager *m, const char *value, FDSet *fds);
 void exec_runtime_vacuum(Manager *m);
 
+void exec_params_clear(ExecParameters *p);
+
 const char* exec_output_to_string(ExecOutput i) _const_;
 ExecOutput exec_output_from_string(const char *s) _pure_;
 
index 14f1fa9e50fda0b36820cb8dbb5f454291f93f16..5e1ef1e6acee52edd2e6a49fdb60f4281b66b311 100644 (file)
@@ -747,7 +747,7 @@ static void mount_dump(Unit *u, FILE *f, const char *prefix) {
 
 static int mount_spawn(Mount *m, ExecCommand *c, pid_t *_pid) {
 
-        ExecParameters exec_params = {
+        _cleanup_(exec_params_clear) ExecParameters exec_params = {
                 .flags     = EXEC_APPLY_SANDBOXING|EXEC_APPLY_CHROOT|EXEC_APPLY_TTY_STDIN,
                 .stdin_fd  = -1,
                 .stdout_fd = -1,
index 8fc8d1ff9496ee3d16efc4321601c2a6786e8111..50ceda7ac60f33a99025660653ee0857e300fd63 100644 (file)
@@ -1399,7 +1399,7 @@ static int service_spawn(
                 ExecFlags flags,
                 pid_t *_pid) {
 
-        ExecParameters exec_params = {
+        _cleanup_(exec_params_clear) ExecParameters exec_params = {
                 .flags      = flags,
                 .stdin_fd   = -1,
                 .stdout_fd  = -1,
@@ -1538,7 +1538,7 @@ static int service_spawn(
         SET_FLAG(exec_params.flags, EXEC_NSS_BYPASS_BUS,
                  MANAGER_IS_SYSTEM(UNIT(s)->manager) && unit_has_name(UNIT(s), SPECIAL_DBUS_SERVICE));
 
-        exec_params.environment = final_env;
+        strv_free_and_replace(exec_params.environment, final_env);
         exec_params.fds = fds;
         exec_params.fd_names = fd_names;
         exec_params.n_socket_fds = n_socket_fds;
index ad8b9b6a416e2cff2bddd4f7159a7e25a6a213ea..407ad1352c81fd046a8981ad7e6a8d763fc23ac3 100644 (file)
@@ -1860,7 +1860,7 @@ static int socket_coldplug(Unit *u) {
 
 static int socket_spawn(Socket *s, ExecCommand *c, pid_t *_pid) {
 
-        ExecParameters exec_params = {
+        _cleanup_(exec_params_clear) ExecParameters exec_params = {
                 .flags     = EXEC_APPLY_SANDBOXING|EXEC_APPLY_CHROOT|EXEC_APPLY_TTY_STDIN,
                 .stdin_fd  = -1,
                 .stdout_fd = -1,
index 429b2b1062ad1acbf2c33f62c797e18adc7e73da..ff1412879f30ea46cf0e2e31944db8032f0b12c9 100644 (file)
@@ -596,7 +596,7 @@ static void swap_dump(Unit *u, FILE *f, const char *prefix) {
 
 static int swap_spawn(Swap *s, ExecCommand *c, pid_t *_pid) {
 
-        ExecParameters exec_params = {
+        _cleanup_(exec_params_clear) ExecParameters exec_params = {
                 .flags     = EXEC_APPLY_SANDBOXING|EXEC_APPLY_CHROOT|EXEC_APPLY_TTY_STDIN,
                 .stdin_fd  = -1,
                 .stdout_fd = -1,