From 7752f7854a18e03959249f816229b5a93c9aaa8c Mon Sep 17 00:00:00 2001 From: Eric Salama Date: Tue, 16 Mar 2021 15:12:17 +0100 Subject: [PATCH] MINOR/BUG: mworker/cli: do not use the unix_bind prefix for the master CLI socket If the configuration file contains a 'unix-bind prefix' directive, and if we use the -S option and specify a UNIX socket path, the path of the socket will be prepended with the value of the unix-bind prefix. For instance, if we have 'unix-bind prefix /tmp/sockets/' and we use '-S /tmp/master-socket' on the command line, we will get this error: Starting proxy MASTER: cannot bind UNIX socket (No such file or directory) [/tmp/sockets/tmp/master-socket] So this patch adds an exception, and will ignore the unix-bind prefix for the master CLI socket. This patch can be backported as far as 1.9. (cherry picked from commit 1b8dacc858d7cb43488fb2ffca053274c571da1d) [wt: cli_fe was called stats_fe in 2.3 and older] Signed-off-by: Willy Tarreau (cherry picked from commit 2af5bc482c4cf6ff71f633bf6b78f31bc4637d79) [wt: context adjustments] Signed-off-by: Willy Tarreau (cherry picked from commit d746589321fabaf227c0029d59c7c9a2d4b669b2) Signed-off-by: Christopher Faulet --- src/cfgparse.c | 4 +++- src/cli.c | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/cfgparse.c b/src/cfgparse.c index c38c06a..32443ad 100644 --- a/src/cfgparse.c +++ b/src/cfgparse.c @@ -122,6 +122,8 @@ struct list sections = LIST_HEAD_INIT(sections); struct list postparsers = LIST_HEAD_INIT(postparsers); +extern struct proxy *mworker_proxy; + char *cursection = NULL; struct proxy defproxy = { }; /* fake proxy used to assign default values on all instances */ int cfg_maxpconn = 0; /* # of simultaneous connections per proxy (-N) */ @@ -163,7 +165,7 @@ int str2listener(char *str, struct proxy *curproxy, struct bind_conf *bind_conf, } ss2 = str2sa_range(str, NULL, &port, &end, err, - curproxy == global.stats_fe ? NULL : global.unix_bind.prefix, + (curproxy == global.stats_fe || curproxy == mworker_proxy) ? NULL : global.unix_bind.prefix, NULL, 1); if (!ss2) goto fail; diff --git a/src/cli.c b/src/cli.c index 54ff911..e3603b6 100644 --- a/src/cli.c +++ b/src/cli.c @@ -94,7 +94,7 @@ static struct cli_kw_list cli_keywords = { extern const char *stat_status_codes[]; -static struct proxy *mworker_proxy; /* CLI proxy of the master */ +struct proxy *mworker_proxy; /* CLI proxy of the master */ static char *cli_gen_usage_msg(struct appctx *appctx) { -- 1.7.10.4