From: William Lallemand Date: Fri, 12 Apr 2019 14:09:24 +0000 (+0200) Subject: MEDIUM: mworker/cli: export the HAPROXY_MASTER_CLI variable X-Git-Tag: v2.0-dev3~260 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=9a37fd0f196685ab39bb2e90c442d9e1d5ddba44;p=thirdparty%2Fhaproxy.git MEDIUM: mworker/cli: export the HAPROXY_MASTER_CLI variable It works the same way as the HAPROXY_CLI variable, it exports the listeners addresses separated by semicolons. --- diff --git a/src/cli.c b/src/cli.c index 54c67433a7..e21c7d21b3 100644 --- a/src/cli.c +++ b/src/cli.c @@ -373,16 +373,18 @@ static int stats_parse_global(char **args, int section_type, struct proxy *curpx } /* - * This function put a list of stats socket separated by a semicolon in the - * "HAPROXY_CLI" environment variable + * This function exports the bound addresses of a in the environment + * variable . Those addresses are separated by semicolons and prefixed + * with their type (abns@, unix@, sockpair@ etc) + * Return -1 upon error, 0 otherwise */ -int cli_socket_setenv() +int listeners_setenv(struct proxy *frontend, const char *varname) { struct buffer *trash = get_trash_chunk(); struct bind_conf *bind_conf; - if (global.stats_fe) { - list_for_each_entry(bind_conf, &global.stats_fe->conf.bind, by_fe) { + if (frontend) { + list_for_each_entry(bind_conf, &frontend->conf.bind, by_fe) { struct listener *l; list_for_each_entry(l, &bind_conf->listeners, by_bind) { @@ -414,13 +416,23 @@ int cli_socket_setenv() } } trash->area[trash->data++] = '\0'; - if (setenv("HAPROXY_CLI", trash->area, 1) < 0) + if (setenv(varname, trash->area, 1) < 0) return -1; } return 0; } +int cli_socket_setenv() +{ + if (listeners_setenv(global.stats_fe, "HAPROXY_CLI") < 0) + return -1; + if (listeners_setenv(mworker_proxy, "HAPROXY_MASTER_CLI") < 0) + return -1; + + return 0; +} + REGISTER_CONFIG_POSTPARSER("cli", cli_socket_setenv); /* Verifies that the CLI at least has a level at least as high as