diff options
author | Lennart Poettering <lennart@poettering.net> | 2021-08-16 16:41:34 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2021-08-17 13:17:44 +0200 |
commit | 7a6abbe93762fe23d415144ae7a040df3266bb5f (patch) | |
tree | 3c241ce87c245becbe36b6e3f1b366b32f2f6461 /src/basic/env-util.c | |
parent | 8b474a437ce980bd0909db59141b40d56f6d5688 (diff) | |
download | systemd-7a6abbe93762fe23d415144ae7a040df3266bb5f.tar.gz |
env-util: add unsetenv_erase() helper
Let's unify how we remove secrets from the env block.
Diffstat (limited to 'src/basic/env-util.c')
-rw-r--r-- | src/basic/env-util.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/basic/env-util.c b/src/basic/env-util.c index cb49125644..b42ca50b25 100644 --- a/src/basic/env-util.c +++ b/src/basic/env-util.c @@ -870,3 +870,20 @@ int getenv_path_list(const char *name, char ***ret_paths) { *ret_paths = TAKE_PTR(l); return 1; } + +int unsetenv_erase(const char *name) { + char *p; + + assert(name); + + p = getenv(name); + if (!p) + return 0; + + string_erase(p); + + if (unsetenv(name) < 0) + return -errno; + + return 1; +} |