diff options
author | Lennart Poettering <lennart@poettering.net> | 2023-06-26 17:20:49 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2023-06-27 13:49:46 +0200 |
commit | f331434d13488425ccd8485327085d15f8f92aea (patch) | |
tree | 60feea760970e000ce33dc27e9bb5b19c7d14805 /src/basic/env-util.h | |
parent | env-util: make strv_env_get() a static inline wrapper around strv_env_get_n() (diff) | |
download | systemd-f331434d13488425ccd8485327085d15f8f92aea.tar.xz systemd-f331434d13488425ccd8485327085d15f8f92aea.zip |
env-file: when resolving env vars in command lines, collect list of unset/invalid ones
When resolving environment variables we currently silently resolve unset
and invalid environment variables to empty strings. Let's do this
slightly less silently: log about unset and invalid env vars, but still
resolve them to an empty string.
Fixes: #27036
Diffstat (limited to 'src/basic/env-util.h')
-rw-r--r-- | src/basic/env-util.h | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/basic/env-util.h b/src/basic/env-util.h index c3fc244798..ec3ac199ef 100644 --- a/src/basic/env-util.h +++ b/src/basic/env-util.h @@ -25,12 +25,12 @@ typedef enum ReplaceEnvFlags { REPLACE_ENV_ALLOW_EXTENDED = 1 << 2, } ReplaceEnvFlags; -char *replace_env_n(const char *format, size_t n, char **env, ReplaceEnvFlags flags); -static inline char *replace_env(const char *format, char **env, ReplaceEnvFlags flags) { - return replace_env_n(format, strlen(format), env, flags); +int replace_env_full(const char *format, size_t n, char **env, ReplaceEnvFlags flags, char **ret, char ***ret_unset_variables, char ***ret_bad_variables); +static inline int replace_env(const char *format, char **env, ReplaceEnvFlags flags, char **ret) { + return replace_env_full(format, SIZE_MAX, env, flags, ret, NULL, NULL); } -char **replace_env_argv(char **argv, char **env); +int replace_env_argv(char **argv, char **env, char ***ret, char ***ret_unset_variables, char ***ret_bad_variables); bool strv_env_is_valid(char **e); #define strv_env_clean(l) strv_env_clean_with_callback(l, NULL, NULL) |