diff options
-rw-r--r-- | src/core/main.c | 5 | ||||
-rw-r--r-- | src/home/homectl.c | 12 | ||||
-rw-r--r-- | src/libsystemd/sd-daemon/sd-daemon.c | 13 | ||||
-rw-r--r-- | src/test/test-execute.c | 10 | ||||
-rw-r--r-- | src/test/test-path-util.c | 4 | ||||
-rw-r--r-- | src/test/test-time-util.c | 2 | ||||
-rw-r--r-- | src/udev/udevd.c | 2 | ||||
-rw-r--r-- | src/userdb/userdbctl.c | 6 |
8 files changed, 22 insertions, 32 deletions
diff --git a/src/core/main.c b/src/core/main.c index c08f541bc1..a280b756ff 100644 --- a/src/core/main.c +++ b/src/core/main.c @@ -1418,9 +1418,8 @@ static int fixup_environment(void) { return -errno; /* The kernels sets HOME=/ for init. Let's undo this. */ - if (path_equal_ptr(getenv("HOME"), "/") && - unsetenv("HOME") < 0) - log_warning_errno(errno, "Failed to unset $HOME: %m"); + if (path_equal_ptr(getenv("HOME"), "/")) + assert_se(unsetenv("HOME") == 0); return 0; } diff --git a/src/home/homectl.c b/src/home/homectl.c index 470e05b24e..7cfda7ed2f 100644 --- a/src/home/homectl.c +++ b/src/home/homectl.c @@ -215,9 +215,7 @@ static int acquire_existing_password(const char *user_name, UserRecord *hr, bool return log_error_errno(r, "Failed to store password: %m"); string_erase(e); - - if (unsetenv("PASSWORD") < 0) - return log_error_errno(errno, "Failed to unset $PASSWORD: %m"); + assert_se(unsetenv("PASSWORD") == 0); return 0; } @@ -255,9 +253,7 @@ static int acquire_token_pin(const char *user_name, UserRecord *hr) { return log_error_errno(r, "Failed to store token PIN: %m"); string_erase(e); - - if (unsetenv("PIN") < 0) - return log_error_errno(errno, "Failed to unset $PIN: %m"); + assert_se(unsetenv("PIN") == 0); return 0; } @@ -997,9 +993,7 @@ static int acquire_new_password( return log_error_errno(r, "Failed to store password: %m"); string_erase(e); - - if (unsetenv("NEWPASSWORD") < 0) - return log_error_errno(errno, "Failed to unset $NEWPASSWORD: %m"); + assert_se(unsetenv("NEWPASSWORD") == 0); if (ret) *ret = TAKE_PTR(copy); diff --git a/src/libsystemd/sd-daemon/sd-daemon.c b/src/libsystemd/sd-daemon/sd-daemon.c index 6336a0cce4..6f0b975627 100644 --- a/src/libsystemd/sd-daemon/sd-daemon.c +++ b/src/libsystemd/sd-daemon/sd-daemon.c @@ -30,13 +30,12 @@ #define SNDBUF_SIZE (8*1024*1024) static void unsetenv_all(bool unset_environment) { - if (!unset_environment) return; - unsetenv("LISTEN_PID"); - unsetenv("LISTEN_FDS"); - unsetenv("LISTEN_FDNAMES"); + assert_se(unsetenv("LISTEN_PID") == 0); + assert_se(unsetenv("LISTEN_FDS") == 0); + assert_se(unsetenv("LISTEN_FDNAMES") == 0); } _public_ int sd_listen_fds(int unset_environment) { @@ -548,7 +547,7 @@ _public_ int sd_pid_notify_with_fds( finish: if (unset_environment) - unsetenv("NOTIFY_SOCKET"); + assert_se(unsetenv("NOTIFY_SOCKET") == 0); return r; } @@ -672,9 +671,9 @@ _public_ int sd_watchdog_enabled(int unset_environment, uint64_t *usec) { finish: if (unset_environment && s) - unsetenv("WATCHDOG_USEC"); + assert_se(unsetenv("WATCHDOG_USEC") == 0); if (unset_environment && p) - unsetenv("WATCHDOG_PID"); + assert_se(unsetenv("WATCHDOG_PID") == 0); return r; } diff --git a/src/test/test-execute.c b/src/test/test-execute.c index e15b7a55fa..3b6a4be260 100644 --- a/src/test/test-execute.c +++ b/src/test/test-execute.c @@ -898,11 +898,11 @@ int main(int argc, char *argv[]) { } #endif - (void) unsetenv("USER"); - (void) unsetenv("LOGNAME"); - (void) unsetenv("SHELL"); - (void) unsetenv("HOME"); - (void) unsetenv("TMPDIR"); + assert_se(unsetenv("USER") == 0); + assert_se(unsetenv("LOGNAME") == 0); + assert_se(unsetenv("SHELL") == 0); + assert_se(unsetenv("HOME") == 0); + assert_se(unsetenv("TMPDIR") == 0); can_unshare = have_namespaces(); diff --git a/src/test/test-path-util.c b/src/test/test-path-util.c index 36108f548b..f4f8d0550b 100644 --- a/src/test/test-path-util.c +++ b/src/test/test-path-util.c @@ -184,7 +184,7 @@ static void test_find_executable_full(void) { if (p) assert_se(oldpath = strdup(p)); - assert_se(unsetenv("PATH") >= 0); + assert_se(unsetenv("PATH") == 0); assert_se(find_executable_full("sh", true, &p) == 0); puts(p); @@ -347,7 +347,7 @@ static void test_fsck_exists(void) { log_info("/* %s */", __func__); /* Ensure we use a sane default for PATH. */ - unsetenv("PATH"); + assert_se(unsetenv("PATH") == 0); /* fsck.minix is provided by util-linux and will probably exist. */ assert_se(fsck_exists("minix") == 1); diff --git a/src/test/test-time-util.c b/src/test/test-time-util.c index cfe8753441..cc391e81a0 100644 --- a/src/test/test-time-util.c +++ b/src/test/test-time-util.c @@ -480,7 +480,7 @@ static void test_in_utc_timezone(void) { assert_se(streq(tzname[0], "CET")); assert_se(streq(tzname[1], "CEST")); - assert_se(unsetenv("TZ") >= 0); + assert_se(unsetenv("TZ") == 0); } static void test_map_clock_usec(void) { diff --git a/src/udev/udevd.c b/src/udev/udevd.c index b6544988c6..d24b8d4398 100644 --- a/src/udev/udevd.c +++ b/src/udev/udevd.c @@ -565,7 +565,7 @@ static int worker_main(Manager *_manager, sd_device_monitor *monitor, sd_device assert(monitor); assert(dev); - unsetenv("NOTIFY_SOCKET"); + assert_se(unsetenv("NOTIFY_SOCKET") == 0); assert_se(sigprocmask_many(SIG_BLOCK, NULL, SIGTERM, -1) >= 0); diff --git a/src/userdb/userdbctl.c b/src/userdb/userdbctl.c index 0d0b2870ab..a0e22dff55 100644 --- a/src/userdb/userdbctl.c +++ b/src/userdb/userdbctl.c @@ -780,10 +780,8 @@ static int run(int argc, char *argv[]) { return log_error_errno(r, "Failed to set $SYSTEMD_ONLY_USERDB: %m"); log_info("Enabled services: %s", e); - } else { - if (unsetenv("SYSTEMD_ONLY_USERDB") < 0) - return log_error_errno(r, "Failed to unset $SYSTEMD_ONLY_USERDB: %m"); - } + } else + assert_se(unsetenv("SYSTEMD_ONLY_USERDB") == 0); return dispatch_verb(argc, argv, verbs, NULL); } |