env-util: add unsetenv_erase() helper

Let's unify how we remove secrets from the env block.
This commit is contained in:
Lennart Poettering
2021-08-17 13:17:44 +02:00
parent 8b474a437c
commit 7a6abbe937
8 changed files with 77 additions and 18 deletions
+2 -3
View File
@@ -3,6 +3,7 @@
#include <fcntl.h>
#include "ask-password-api.h"
#include "env-util.h"
#include "escape.h"
#include "fd-util.h"
#include "format-table.h"
@@ -245,9 +246,7 @@ int pkcs11_token_login(
if (!passwords)
return log_oom();
string_erase(e);
if (unsetenv("PIN") < 0)
return log_error_errno(errno, "Failed to unset $PIN: %m");
assert_se(unsetenv_erase("PIN") >= 0);
} else if (headless)
return log_error_errno(SYNTHETIC_ERRNO(ENOPKG), "PIN querying disabled via 'headless' option. Use the 'PIN' environment variable.");
else {