]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
config: Add support for $ENV:name
authorAki Tuomi <aki.tuomi@open-xchange.com>
Wed, 22 Jan 2020 12:34:15 +0000 (14:34 +0200)
committeraki.tuomi <aki.tuomi@open-xchange.com>
Wed, 3 Feb 2021 08:00:29 +0000 (08:00 +0000)
Expands into given environment variable

src/config/config-parser.c

index aec5359eddf221338c79fd208f903e66fa8e2e84..47d0f18fd2139ab420c1bc849563352816c35485 100644 (file)
@@ -821,6 +821,11 @@ static int config_write_keyvariable(struct config_parser_context *ctx,
                        str_append(str, var_name);
                } else if (!ctx->expand_values && !expand_parent) {
                        str_append(str, var_name);
+               } else if (str_begins(var_name, "$ENV:")) {
+                       /* use environment variable */
+                       const char *envval = getenv(var_name+5);
+                       if (envval != NULL)
+                               str_append(str, envval);
                } else {
                        const char *var_value;
                        enum setting_type var_type;