Amaury Denoyelle | fc6ac53 | 2021-04-27 10:46:36 +0200 | [diff] [blame] | 1 | #define _GNU_SOURCE /* for cpu_set_t from haproxy/cpuset.h */ |
Willy Tarreau | 36b9e22 | 2018-11-11 15:19:52 +0100 | [diff] [blame] | 2 | #include <stdio.h> |
| 3 | #include <stdlib.h> |
| 4 | #include <string.h> |
| 5 | #include <netdb.h> |
| 6 | #include <ctype.h> |
| 7 | #include <pwd.h> |
| 8 | #include <grp.h> |
| 9 | #include <errno.h> |
| 10 | #include <sys/types.h> |
| 11 | #include <sys/stat.h> |
| 12 | #include <fcntl.h> |
| 13 | #include <unistd.h> |
| 14 | |
Eric Salama | 7cea606 | 2020-10-02 11:58:19 +0200 | [diff] [blame] | 15 | #include <haproxy/buf.h> |
Willy Tarreau | 6be7849 | 2020-06-05 00:00:29 +0200 | [diff] [blame] | 16 | #include <haproxy/cfgparse.h> |
Amaury Denoyelle | a6f9c5d | 2021-04-23 16:58:08 +0200 | [diff] [blame] | 17 | #ifdef USE_CPU_AFFINITY |
Amaury Denoyelle | c90932b | 2021-04-14 16:16:03 +0200 | [diff] [blame] | 18 | #include <haproxy/cpuset.h> |
Amaury Denoyelle | a6f9c5d | 2021-04-23 16:58:08 +0200 | [diff] [blame] | 19 | #endif |
Willy Tarreau | 0a3bd39 | 2020-06-04 08:52:38 +0200 | [diff] [blame] | 20 | #include <haproxy/compression.h> |
Willy Tarreau | dfd3de8 | 2020-06-04 23:46:14 +0200 | [diff] [blame] | 21 | #include <haproxy/global.h> |
Willy Tarreau | 36979d9 | 2020-06-05 17:27:29 +0200 | [diff] [blame] | 22 | #include <haproxy/log.h> |
Dragan Dosen | 13cd54c | 2020-06-18 18:24:05 +0200 | [diff] [blame] | 23 | #include <haproxy/peers.h> |
Willy Tarreau | 36979d9 | 2020-06-05 17:27:29 +0200 | [diff] [blame] | 24 | #include <haproxy/tools.h> |
Willy Tarreau | 36b9e22 | 2018-11-11 15:19:52 +0100 | [diff] [blame] | 25 | |
Willy Tarreau | a0e8eb8 | 2021-03-12 09:30:14 +0100 | [diff] [blame] | 26 | /* some keywords that are still being parsed using strcmp() and are not |
| 27 | * registered anywhere. They are used as suggestions for mistyped words. |
| 28 | */ |
| 29 | static const char *common_kw_list[] = { |
| 30 | "global", "daemon", "master-worker", "noepoll", "nokqueue", |
| 31 | "noevports", "nopoll", "busy-polling", "set-dumpable", |
| 32 | "insecure-fork-wanted", "insecure-setuid-wanted", "nosplice", |
| 33 | "nogetaddrinfo", "noreuseport", "quiet", "zero-warning", |
| 34 | "tune.runqueue-depth", "tune.maxpollevents", "tune.maxaccept", |
Willy Tarreau | eb9d90a | 2021-06-11 15:29:31 +0200 | [diff] [blame^] | 35 | "tune.recv_enough", "tune.buffers.limit", |
Willy Tarreau | a0e8eb8 | 2021-03-12 09:30:14 +0100 | [diff] [blame] | 36 | "tune.buffers.reserve", "tune.bufsize", "tune.maxrewrite", |
| 37 | "tune.idletimer", "tune.rcvbuf.client", "tune.rcvbuf.server", |
| 38 | "tune.sndbuf.client", "tune.sndbuf.server", "tune.pipesize", |
| 39 | "tune.http.cookielen", "tune.http.logurilen", "tune.http.maxhdr", |
| 40 | "tune.comp.maxlevel", "tune.pattern.cache-size", "uid", "gid", |
| 41 | "external-check", "user", "group", "nbproc", "nbthread", "maxconn", |
| 42 | "ssl-server-verify", "maxconnrate", "maxsessrate", "maxsslrate", |
| 43 | "maxcomprate", "maxpipes", "maxzlibmem", "maxcompcpuusage", "ulimit-n", |
| 44 | "chroot", "description", "node", "pidfile", "unix-bind", "log", |
| 45 | "log-send-hostname", "server-state-base", "server-state-file", |
| 46 | "log-tag", "spread-checks", "max-spread-checks", "cpu-map", "setenv", |
| 47 | "presetenv", "unsetenv", "resetenv", "strict-limits", "localpeer", |
Amaury Denoyelle | 0f50cb9 | 2021-03-26 18:50:33 +0100 | [diff] [blame] | 48 | "numa-cpu-mapping", "defaults", "listen", "frontend", "backend", |
| 49 | "peers", "resolvers", |
Willy Tarreau | a0e8eb8 | 2021-03-12 09:30:14 +0100 | [diff] [blame] | 50 | NULL /* must be last */ |
| 51 | }; |
| 52 | |
Willy Tarreau | 36b9e22 | 2018-11-11 15:19:52 +0100 | [diff] [blame] | 53 | /* |
| 54 | * parse a line in a <global> section. Returns the error code, 0 if OK, or |
| 55 | * any combination of : |
| 56 | * - ERR_ABORT: must abort ASAP |
| 57 | * - ERR_FATAL: we can continue parsing but not start the service |
| 58 | * - ERR_WARN: a warning has been emitted |
| 59 | * - ERR_ALERT: an alert has been emitted |
| 60 | * Only the two first ones can stop processing, the two others are just |
| 61 | * indicators. |
| 62 | */ |
| 63 | int cfg_parse_global(const char *file, int linenum, char **args, int kwm) |
| 64 | { |
| 65 | int err_code = 0; |
| 66 | char *errmsg = NULL; |
| 67 | |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 68 | if (strcmp(args[0], "global") == 0) { /* new section */ |
Willy Tarreau | 36b9e22 | 2018-11-11 15:19:52 +0100 | [diff] [blame] | 69 | /* no option, nothing special to do */ |
| 70 | alertif_too_many_args(0, file, linenum, args, &err_code); |
| 71 | goto out; |
| 72 | } |
Amaury Denoyelle | d2e53cd | 2021-05-06 16:21:39 +0200 | [diff] [blame] | 73 | else if (strcmp(args[0], "expose-experimental-directives") == 0) { |
| 74 | experimental_directives_allowed = 1; |
| 75 | } |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 76 | else if (strcmp(args[0], "daemon") == 0) { |
Willy Tarreau | 36b9e22 | 2018-11-11 15:19:52 +0100 | [diff] [blame] | 77 | if (alertif_too_many_args(0, file, linenum, args, &err_code)) |
| 78 | goto out; |
| 79 | global.mode |= MODE_DAEMON; |
| 80 | } |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 81 | else if (strcmp(args[0], "master-worker") == 0) { |
Willy Tarreau | 36b9e22 | 2018-11-11 15:19:52 +0100 | [diff] [blame] | 82 | if (alertif_too_many_args(1, file, linenum, args, &err_code)) |
| 83 | goto out; |
| 84 | if (*args[1]) { |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 85 | if (strcmp(args[1], "no-exit-on-failure") == 0) { |
Willy Tarreau | 36b9e22 | 2018-11-11 15:19:52 +0100 | [diff] [blame] | 86 | global.tune.options |= GTUNE_NOEXIT_ONFAILURE; |
| 87 | } else { |
| 88 | ha_alert("parsing [%s:%d] : '%s' only supports 'no-exit-on-failure' option.\n", file, linenum, args[0]); |
| 89 | err_code |= ERR_ALERT | ERR_FATAL; |
| 90 | goto out; |
| 91 | } |
| 92 | } |
| 93 | global.mode |= MODE_MWORKER; |
| 94 | } |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 95 | else if (strcmp(args[0], "noepoll") == 0) { |
Willy Tarreau | 36b9e22 | 2018-11-11 15:19:52 +0100 | [diff] [blame] | 96 | if (alertif_too_many_args(0, file, linenum, args, &err_code)) |
| 97 | goto out; |
| 98 | global.tune.options &= ~GTUNE_USE_EPOLL; |
| 99 | } |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 100 | else if (strcmp(args[0], "nokqueue") == 0) { |
Willy Tarreau | 36b9e22 | 2018-11-11 15:19:52 +0100 | [diff] [blame] | 101 | if (alertif_too_many_args(0, file, linenum, args, &err_code)) |
| 102 | goto out; |
| 103 | global.tune.options &= ~GTUNE_USE_KQUEUE; |
| 104 | } |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 105 | else if (strcmp(args[0], "noevports") == 0) { |
Emmanuel Hocdet | 0ba4f48 | 2019-04-08 16:53:32 +0000 | [diff] [blame] | 106 | if (alertif_too_many_args(0, file, linenum, args, &err_code)) |
| 107 | goto out; |
| 108 | global.tune.options &= ~GTUNE_USE_EVPORTS; |
| 109 | } |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 110 | else if (strcmp(args[0], "nopoll") == 0) { |
Willy Tarreau | 36b9e22 | 2018-11-11 15:19:52 +0100 | [diff] [blame] | 111 | if (alertif_too_many_args(0, file, linenum, args, &err_code)) |
| 112 | goto out; |
| 113 | global.tune.options &= ~GTUNE_USE_POLL; |
| 114 | } |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 115 | else if (strcmp(args[0], "busy-polling") == 0) { /* "no busy-polling" or "busy-polling" */ |
Willy Tarreau | beb859a | 2018-11-22 18:07:59 +0100 | [diff] [blame] | 116 | if (alertif_too_many_args(0, file, linenum, args, &err_code)) |
| 117 | goto out; |
| 118 | if (kwm == KWM_NO) |
| 119 | global.tune.options &= ~GTUNE_BUSY_POLLING; |
| 120 | else |
| 121 | global.tune.options |= GTUNE_BUSY_POLLING; |
| 122 | } |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 123 | else if (strcmp(args[0], "set-dumpable") == 0) { /* "no set-dumpable" or "set-dumpable" */ |
Willy Tarreau | 636848a | 2019-04-15 19:38:50 +0200 | [diff] [blame] | 124 | if (alertif_too_many_args(0, file, linenum, args, &err_code)) |
| 125 | goto out; |
| 126 | if (kwm == KWM_NO) |
| 127 | global.tune.options &= ~GTUNE_SET_DUMPABLE; |
| 128 | else |
| 129 | global.tune.options |= GTUNE_SET_DUMPABLE; |
| 130 | } |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 131 | else if (strcmp(args[0], "insecure-fork-wanted") == 0) { /* "no insecure-fork-wanted" or "insecure-fork-wanted" */ |
Willy Tarreau | d96f112 | 2019-12-03 07:07:36 +0100 | [diff] [blame] | 132 | if (alertif_too_many_args(0, file, linenum, args, &err_code)) |
| 133 | goto out; |
| 134 | if (kwm == KWM_NO) |
| 135 | global.tune.options &= ~GTUNE_INSECURE_FORK; |
| 136 | else |
| 137 | global.tune.options |= GTUNE_INSECURE_FORK; |
| 138 | } |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 139 | else if (strcmp(args[0], "insecure-setuid-wanted") == 0) { /* "no insecure-setuid-wanted" or "insecure-setuid-wanted" */ |
Willy Tarreau | a45a8b5 | 2019-12-06 16:31:45 +0100 | [diff] [blame] | 140 | if (alertif_too_many_args(0, file, linenum, args, &err_code)) |
| 141 | goto out; |
| 142 | if (kwm == KWM_NO) |
| 143 | global.tune.options &= ~GTUNE_INSECURE_SETUID; |
| 144 | else |
| 145 | global.tune.options |= GTUNE_INSECURE_SETUID; |
| 146 | } |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 147 | else if (strcmp(args[0], "nosplice") == 0) { |
Willy Tarreau | 36b9e22 | 2018-11-11 15:19:52 +0100 | [diff] [blame] | 148 | if (alertif_too_many_args(0, file, linenum, args, &err_code)) |
| 149 | goto out; |
| 150 | global.tune.options &= ~GTUNE_USE_SPLICE; |
| 151 | } |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 152 | else if (strcmp(args[0], "nogetaddrinfo") == 0) { |
Willy Tarreau | 36b9e22 | 2018-11-11 15:19:52 +0100 | [diff] [blame] | 153 | if (alertif_too_many_args(0, file, linenum, args, &err_code)) |
| 154 | goto out; |
| 155 | global.tune.options &= ~GTUNE_USE_GAI; |
| 156 | } |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 157 | else if (strcmp(args[0], "noreuseport") == 0) { |
Willy Tarreau | 36b9e22 | 2018-11-11 15:19:52 +0100 | [diff] [blame] | 158 | if (alertif_too_many_args(0, file, linenum, args, &err_code)) |
| 159 | goto out; |
| 160 | global.tune.options &= ~GTUNE_USE_REUSEPORT; |
| 161 | } |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 162 | else if (strcmp(args[0], "quiet") == 0) { |
Willy Tarreau | 36b9e22 | 2018-11-11 15:19:52 +0100 | [diff] [blame] | 163 | if (alertif_too_many_args(0, file, linenum, args, &err_code)) |
| 164 | goto out; |
| 165 | global.mode |= MODE_QUIET; |
| 166 | } |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 167 | else if (strcmp(args[0], "zero-warning") == 0) { |
Willy Tarreau | 3eb10b8 | 2020-04-15 16:42:39 +0200 | [diff] [blame] | 168 | if (alertif_too_many_args(0, file, linenum, args, &err_code)) |
| 169 | goto out; |
| 170 | global.mode |= MODE_ZERO_WARNING; |
| 171 | } |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 172 | else if (strcmp(args[0], "tune.runqueue-depth") == 0) { |
Willy Tarreau | 36b9e22 | 2018-11-11 15:19:52 +0100 | [diff] [blame] | 173 | if (alertif_too_many_args(1, file, linenum, args, &err_code)) |
| 174 | goto out; |
| 175 | if (global.tune.runqueue_depth != 0) { |
| 176 | ha_alert("parsing [%s:%d] : '%s' already specified. Continuing.\n", file, linenum, args[0]); |
| 177 | err_code |= ERR_ALERT; |
| 178 | goto out; |
| 179 | } |
| 180 | if (*(args[1]) == 0) { |
| 181 | ha_alert("parsing [%s:%d] : '%s' expects an integer argument.\n", file, linenum, args[0]); |
| 182 | err_code |= ERR_ALERT | ERR_FATAL; |
| 183 | goto out; |
| 184 | } |
| 185 | global.tune.runqueue_depth = atol(args[1]); |
| 186 | |
| 187 | } |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 188 | else if (strcmp(args[0], "tune.maxpollevents") == 0) { |
Willy Tarreau | 36b9e22 | 2018-11-11 15:19:52 +0100 | [diff] [blame] | 189 | if (alertif_too_many_args(1, file, linenum, args, &err_code)) |
| 190 | goto out; |
| 191 | if (global.tune.maxpollevents != 0) { |
| 192 | ha_alert("parsing [%s:%d] : '%s' already specified. Continuing.\n", file, linenum, args[0]); |
| 193 | err_code |= ERR_ALERT; |
| 194 | goto out; |
| 195 | } |
| 196 | if (*(args[1]) == 0) { |
| 197 | ha_alert("parsing [%s:%d] : '%s' expects an integer argument.\n", file, linenum, args[0]); |
| 198 | err_code |= ERR_ALERT | ERR_FATAL; |
| 199 | goto out; |
| 200 | } |
| 201 | global.tune.maxpollevents = atol(args[1]); |
| 202 | } |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 203 | else if (strcmp(args[0], "tune.maxaccept") == 0) { |
Christopher Faulet | 6b02ab8 | 2019-04-30 14:03:56 +0200 | [diff] [blame] | 204 | long max; |
| 205 | |
Willy Tarreau | 36b9e22 | 2018-11-11 15:19:52 +0100 | [diff] [blame] | 206 | if (alertif_too_many_args(1, file, linenum, args, &err_code)) |
| 207 | goto out; |
| 208 | if (global.tune.maxaccept != 0) { |
| 209 | ha_alert("parsing [%s:%d] : '%s' already specified. Continuing.\n", file, linenum, args[0]); |
| 210 | err_code |= ERR_ALERT; |
| 211 | goto out; |
| 212 | } |
| 213 | if (*(args[1]) == 0) { |
| 214 | ha_alert("parsing [%s:%d] : '%s' expects an integer argument.\n", file, linenum, args[0]); |
| 215 | err_code |= ERR_ALERT | ERR_FATAL; |
| 216 | goto out; |
| 217 | } |
Christopher Faulet | 6b02ab8 | 2019-04-30 14:03:56 +0200 | [diff] [blame] | 218 | max = atol(args[1]); |
| 219 | if (/*max < -1 || */max > INT_MAX) { |
| 220 | ha_alert("parsing [%s:%d] : '%s' expects -1 or an integer from 0 to INT_MAX.\n", file, linenum, args[0]); |
| 221 | err_code |= ERR_ALERT | ERR_FATAL; |
| 222 | goto out; |
| 223 | } |
| 224 | global.tune.maxaccept = max; |
Willy Tarreau | 36b9e22 | 2018-11-11 15:19:52 +0100 | [diff] [blame] | 225 | } |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 226 | else if (strcmp(args[0], "tune.chksize") == 0) { |
Willy Tarreau | eb9d90a | 2021-06-11 15:29:31 +0200 | [diff] [blame^] | 227 | ha_alert("parsing [%s:%d]: option '%s' is not supported any more (tune.bufsize is used instead).\n", file, linenum, args[0]); |
| 228 | err_code |= ERR_ALERT | ERR_FATAL; |
| 229 | goto out; |
Willy Tarreau | 36b9e22 | 2018-11-11 15:19:52 +0100 | [diff] [blame] | 230 | } |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 231 | else if (strcmp(args[0], "tune.recv_enough") == 0) { |
Willy Tarreau | 36b9e22 | 2018-11-11 15:19:52 +0100 | [diff] [blame] | 232 | if (alertif_too_many_args(1, file, linenum, args, &err_code)) |
| 233 | goto out; |
| 234 | if (*(args[1]) == 0) { |
| 235 | ha_alert("parsing [%s:%d] : '%s' expects an integer argument.\n", file, linenum, args[0]); |
| 236 | err_code |= ERR_ALERT | ERR_FATAL; |
| 237 | goto out; |
| 238 | } |
| 239 | global.tune.recv_enough = atol(args[1]); |
| 240 | } |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 241 | else if (strcmp(args[0], "tune.buffers.limit") == 0) { |
Willy Tarreau | 36b9e22 | 2018-11-11 15:19:52 +0100 | [diff] [blame] | 242 | if (alertif_too_many_args(1, file, linenum, args, &err_code)) |
| 243 | goto out; |
| 244 | if (*(args[1]) == 0) { |
| 245 | ha_alert("parsing [%s:%d] : '%s' expects an integer argument.\n", file, linenum, args[0]); |
| 246 | err_code |= ERR_ALERT | ERR_FATAL; |
| 247 | goto out; |
| 248 | } |
| 249 | global.tune.buf_limit = atol(args[1]); |
| 250 | if (global.tune.buf_limit) { |
| 251 | if (global.tune.buf_limit < 3) |
| 252 | global.tune.buf_limit = 3; |
| 253 | if (global.tune.buf_limit <= global.tune.reserved_bufs) |
| 254 | global.tune.buf_limit = global.tune.reserved_bufs + 1; |
| 255 | } |
| 256 | } |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 257 | else if (strcmp(args[0], "tune.buffers.reserve") == 0) { |
Willy Tarreau | 36b9e22 | 2018-11-11 15:19:52 +0100 | [diff] [blame] | 258 | if (alertif_too_many_args(1, file, linenum, args, &err_code)) |
| 259 | goto out; |
| 260 | if (*(args[1]) == 0) { |
| 261 | ha_alert("parsing [%s:%d] : '%s' expects an integer argument.\n", file, linenum, args[0]); |
| 262 | err_code |= ERR_ALERT | ERR_FATAL; |
| 263 | goto out; |
| 264 | } |
| 265 | global.tune.reserved_bufs = atol(args[1]); |
| 266 | if (global.tune.reserved_bufs < 2) |
| 267 | global.tune.reserved_bufs = 2; |
| 268 | if (global.tune.buf_limit && global.tune.buf_limit <= global.tune.reserved_bufs) |
| 269 | global.tune.buf_limit = global.tune.reserved_bufs + 1; |
| 270 | } |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 271 | else if (strcmp(args[0], "tune.bufsize") == 0) { |
Willy Tarreau | 36b9e22 | 2018-11-11 15:19:52 +0100 | [diff] [blame] | 272 | if (alertif_too_many_args(1, file, linenum, args, &err_code)) |
| 273 | goto out; |
| 274 | if (*(args[1]) == 0) { |
| 275 | ha_alert("parsing [%s:%d] : '%s' expects an integer argument.\n", file, linenum, args[0]); |
| 276 | err_code |= ERR_ALERT | ERR_FATAL; |
| 277 | goto out; |
| 278 | } |
| 279 | global.tune.bufsize = atol(args[1]); |
Willy Tarreau | c77d364 | 2018-12-12 06:19:42 +0100 | [diff] [blame] | 280 | /* round it up to support a two-pointer alignment at the end */ |
| 281 | global.tune.bufsize = (global.tune.bufsize + 2 * sizeof(void *) - 1) & -(2 * sizeof(void *)); |
Willy Tarreau | 36b9e22 | 2018-11-11 15:19:52 +0100 | [diff] [blame] | 282 | if (global.tune.bufsize <= 0) { |
| 283 | ha_alert("parsing [%s:%d] : '%s' expects a positive integer argument.\n", file, linenum, args[0]); |
| 284 | err_code |= ERR_ALERT | ERR_FATAL; |
| 285 | goto out; |
| 286 | } |
| 287 | } |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 288 | else if (strcmp(args[0], "tune.maxrewrite") == 0) { |
Willy Tarreau | 36b9e22 | 2018-11-11 15:19:52 +0100 | [diff] [blame] | 289 | if (alertif_too_many_args(1, file, linenum, args, &err_code)) |
| 290 | goto out; |
| 291 | if (*(args[1]) == 0) { |
| 292 | ha_alert("parsing [%s:%d] : '%s' expects an integer argument.\n", file, linenum, args[0]); |
| 293 | err_code |= ERR_ALERT | ERR_FATAL; |
| 294 | goto out; |
| 295 | } |
| 296 | global.tune.maxrewrite = atol(args[1]); |
| 297 | if (global.tune.maxrewrite < 0) { |
| 298 | ha_alert("parsing [%s:%d] : '%s' expects a positive integer argument.\n", file, linenum, args[0]); |
| 299 | err_code |= ERR_ALERT | ERR_FATAL; |
| 300 | goto out; |
| 301 | } |
| 302 | } |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 303 | else if (strcmp(args[0], "tune.idletimer") == 0) { |
Willy Tarreau | 36b9e22 | 2018-11-11 15:19:52 +0100 | [diff] [blame] | 304 | unsigned int idle; |
| 305 | const char *res; |
| 306 | |
| 307 | if (alertif_too_many_args(1, file, linenum, args, &err_code)) |
| 308 | goto out; |
| 309 | if (*(args[1]) == 0) { |
| 310 | ha_alert("parsing [%s:%d] : '%s' expects a timer value between 0 and 65535 ms.\n", file, linenum, args[0]); |
| 311 | err_code |= ERR_ALERT | ERR_FATAL; |
| 312 | goto out; |
| 313 | } |
| 314 | |
| 315 | res = parse_time_err(args[1], &idle, TIME_UNIT_MS); |
Willy Tarreau | 9faebe3 | 2019-06-07 19:00:37 +0200 | [diff] [blame] | 316 | if (res == PARSE_TIME_OVER) { |
| 317 | ha_alert("parsing [%s:%d]: timer overflow in argument <%s> to <%s>, maximum value is 65535 ms.\n", |
| 318 | file, linenum, args[1], args[0]); |
| 319 | err_code |= ERR_ALERT | ERR_FATAL; |
| 320 | goto out; |
| 321 | } |
| 322 | else if (res == PARSE_TIME_UNDER) { |
| 323 | ha_alert("parsing [%s:%d]: timer underflow in argument <%s> to <%s>, minimum non-null value is 1 ms.\n", |
| 324 | file, linenum, args[1], args[0]); |
| 325 | err_code |= ERR_ALERT | ERR_FATAL; |
| 326 | goto out; |
| 327 | } |
| 328 | else if (res) { |
Willy Tarreau | 36b9e22 | 2018-11-11 15:19:52 +0100 | [diff] [blame] | 329 | ha_alert("parsing [%s:%d]: unexpected character '%c' in argument to <%s>.\n", |
Willy Tarreau | 9faebe3 | 2019-06-07 19:00:37 +0200 | [diff] [blame] | 330 | file, linenum, *res, args[0]); |
Willy Tarreau | 36b9e22 | 2018-11-11 15:19:52 +0100 | [diff] [blame] | 331 | err_code |= ERR_ALERT | ERR_FATAL; |
| 332 | goto out; |
| 333 | } |
| 334 | |
| 335 | if (idle > 65535) { |
| 336 | ha_alert("parsing [%s:%d] : '%s' expects a timer value between 0 and 65535 ms.\n", file, linenum, args[0]); |
| 337 | err_code |= ERR_ALERT | ERR_FATAL; |
| 338 | goto out; |
| 339 | } |
| 340 | global.tune.idle_timer = idle; |
| 341 | } |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 342 | else if (strcmp(args[0], "tune.rcvbuf.client") == 0) { |
Willy Tarreau | 36b9e22 | 2018-11-11 15:19:52 +0100 | [diff] [blame] | 343 | if (alertif_too_many_args(1, file, linenum, args, &err_code)) |
| 344 | goto out; |
| 345 | if (global.tune.client_rcvbuf != 0) { |
| 346 | ha_alert("parsing [%s:%d] : '%s' already specified. Continuing.\n", file, linenum, args[0]); |
| 347 | err_code |= ERR_ALERT; |
| 348 | goto out; |
| 349 | } |
| 350 | if (*(args[1]) == 0) { |
| 351 | ha_alert("parsing [%s:%d] : '%s' expects an integer argument.\n", file, linenum, args[0]); |
| 352 | err_code |= ERR_ALERT | ERR_FATAL; |
| 353 | goto out; |
| 354 | } |
| 355 | global.tune.client_rcvbuf = atol(args[1]); |
| 356 | } |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 357 | else if (strcmp(args[0], "tune.rcvbuf.server") == 0) { |
Willy Tarreau | 36b9e22 | 2018-11-11 15:19:52 +0100 | [diff] [blame] | 358 | if (alertif_too_many_args(1, file, linenum, args, &err_code)) |
| 359 | goto out; |
| 360 | if (global.tune.server_rcvbuf != 0) { |
| 361 | ha_alert("parsing [%s:%d] : '%s' already specified. Continuing.\n", file, linenum, args[0]); |
| 362 | err_code |= ERR_ALERT; |
| 363 | goto out; |
| 364 | } |
| 365 | if (*(args[1]) == 0) { |
| 366 | ha_alert("parsing [%s:%d] : '%s' expects an integer argument.\n", file, linenum, args[0]); |
| 367 | err_code |= ERR_ALERT | ERR_FATAL; |
| 368 | goto out; |
| 369 | } |
| 370 | global.tune.server_rcvbuf = atol(args[1]); |
| 371 | } |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 372 | else if (strcmp(args[0], "tune.sndbuf.client") == 0) { |
Willy Tarreau | 36b9e22 | 2018-11-11 15:19:52 +0100 | [diff] [blame] | 373 | if (alertif_too_many_args(1, file, linenum, args, &err_code)) |
| 374 | goto out; |
| 375 | if (global.tune.client_sndbuf != 0) { |
| 376 | ha_alert("parsing [%s:%d] : '%s' already specified. Continuing.\n", file, linenum, args[0]); |
| 377 | err_code |= ERR_ALERT; |
| 378 | goto out; |
| 379 | } |
| 380 | if (*(args[1]) == 0) { |
| 381 | ha_alert("parsing [%s:%d] : '%s' expects an integer argument.\n", file, linenum, args[0]); |
| 382 | err_code |= ERR_ALERT | ERR_FATAL; |
| 383 | goto out; |
| 384 | } |
| 385 | global.tune.client_sndbuf = atol(args[1]); |
| 386 | } |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 387 | else if (strcmp(args[0], "tune.sndbuf.server") == 0) { |
Willy Tarreau | 36b9e22 | 2018-11-11 15:19:52 +0100 | [diff] [blame] | 388 | if (alertif_too_many_args(1, file, linenum, args, &err_code)) |
| 389 | goto out; |
| 390 | if (global.tune.server_sndbuf != 0) { |
| 391 | ha_alert("parsing [%s:%d] : '%s' already specified. Continuing.\n", file, linenum, args[0]); |
| 392 | err_code |= ERR_ALERT; |
| 393 | goto out; |
| 394 | } |
| 395 | if (*(args[1]) == 0) { |
| 396 | ha_alert("parsing [%s:%d] : '%s' expects an integer argument.\n", file, linenum, args[0]); |
| 397 | err_code |= ERR_ALERT | ERR_FATAL; |
| 398 | goto out; |
| 399 | } |
| 400 | global.tune.server_sndbuf = atol(args[1]); |
| 401 | } |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 402 | else if (strcmp(args[0], "tune.pipesize") == 0) { |
Willy Tarreau | 36b9e22 | 2018-11-11 15:19:52 +0100 | [diff] [blame] | 403 | if (alertif_too_many_args(1, file, linenum, args, &err_code)) |
| 404 | goto out; |
| 405 | if (*(args[1]) == 0) { |
| 406 | ha_alert("parsing [%s:%d] : '%s' expects an integer argument.\n", file, linenum, args[0]); |
| 407 | err_code |= ERR_ALERT | ERR_FATAL; |
| 408 | goto out; |
| 409 | } |
| 410 | global.tune.pipesize = atol(args[1]); |
| 411 | } |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 412 | else if (strcmp(args[0], "tune.http.cookielen") == 0) { |
Willy Tarreau | 36b9e22 | 2018-11-11 15:19:52 +0100 | [diff] [blame] | 413 | if (alertif_too_many_args(1, file, linenum, args, &err_code)) |
| 414 | goto out; |
| 415 | if (*(args[1]) == 0) { |
| 416 | ha_alert("parsing [%s:%d] : '%s' expects an integer argument.\n", file, linenum, args[0]); |
| 417 | err_code |= ERR_ALERT | ERR_FATAL; |
| 418 | goto out; |
| 419 | } |
| 420 | global.tune.cookie_len = atol(args[1]) + 1; |
| 421 | } |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 422 | else if (strcmp(args[0], "tune.http.logurilen") == 0) { |
Willy Tarreau | 36b9e22 | 2018-11-11 15:19:52 +0100 | [diff] [blame] | 423 | if (alertif_too_many_args(1, file, linenum, args, &err_code)) |
| 424 | goto out; |
| 425 | if (*(args[1]) == 0) { |
| 426 | ha_alert("parsing [%s:%d] : '%s' expects an integer argument.\n", file, linenum, args[0]); |
| 427 | err_code |= ERR_ALERT | ERR_FATAL; |
| 428 | goto out; |
| 429 | } |
| 430 | global.tune.requri_len = atol(args[1]) + 1; |
| 431 | } |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 432 | else if (strcmp(args[0], "tune.http.maxhdr") == 0) { |
Willy Tarreau | 36b9e22 | 2018-11-11 15:19:52 +0100 | [diff] [blame] | 433 | if (alertif_too_many_args(1, file, linenum, args, &err_code)) |
| 434 | goto out; |
| 435 | if (*(args[1]) == 0) { |
| 436 | ha_alert("parsing [%s:%d] : '%s' expects an integer argument.\n", file, linenum, args[0]); |
| 437 | err_code |= ERR_ALERT | ERR_FATAL; |
| 438 | goto out; |
| 439 | } |
| 440 | global.tune.max_http_hdr = atoi(args[1]); |
| 441 | if (global.tune.max_http_hdr < 1 || global.tune.max_http_hdr > 32767) { |
| 442 | ha_alert("parsing [%s:%d] : '%s' expects a numeric value between 1 and 32767\n", |
| 443 | file, linenum, args[0]); |
| 444 | err_code |= ERR_ALERT | ERR_FATAL; |
| 445 | goto out; |
| 446 | } |
| 447 | } |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 448 | else if (strcmp(args[0], "tune.comp.maxlevel") == 0) { |
Willy Tarreau | 36b9e22 | 2018-11-11 15:19:52 +0100 | [diff] [blame] | 449 | if (alertif_too_many_args(1, file, linenum, args, &err_code)) |
| 450 | goto out; |
| 451 | if (*args[1]) { |
| 452 | global.tune.comp_maxlevel = atoi(args[1]); |
| 453 | if (global.tune.comp_maxlevel < 1 || global.tune.comp_maxlevel > 9) { |
| 454 | ha_alert("parsing [%s:%d] : '%s' expects a numeric value between 1 and 9\n", |
| 455 | file, linenum, args[0]); |
| 456 | err_code |= ERR_ALERT | ERR_FATAL; |
| 457 | goto out; |
| 458 | } |
| 459 | } else { |
| 460 | ha_alert("parsing [%s:%d] : '%s' expects a numeric value between 1 and 9\n", |
| 461 | file, linenum, args[0]); |
| 462 | err_code |= ERR_ALERT | ERR_FATAL; |
| 463 | goto out; |
| 464 | } |
| 465 | } |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 466 | else if (strcmp(args[0], "tune.pattern.cache-size") == 0) { |
Willy Tarreau | 36b9e22 | 2018-11-11 15:19:52 +0100 | [diff] [blame] | 467 | if (*args[1]) { |
| 468 | global.tune.pattern_cache = atoi(args[1]); |
| 469 | if (global.tune.pattern_cache < 0) { |
| 470 | ha_alert("parsing [%s:%d] : '%s' expects a positive numeric value\n", |
| 471 | file, linenum, args[0]); |
| 472 | err_code |= ERR_ALERT | ERR_FATAL; |
| 473 | goto out; |
| 474 | } |
| 475 | } else { |
| 476 | ha_alert("parsing [%s:%d] : '%s' expects a positive numeric value\n", |
| 477 | file, linenum, args[0]); |
| 478 | err_code |= ERR_ALERT | ERR_FATAL; |
| 479 | goto out; |
| 480 | } |
| 481 | } |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 482 | else if (strcmp(args[0], "uid") == 0) { |
Willy Tarreau | 36b9e22 | 2018-11-11 15:19:52 +0100 | [diff] [blame] | 483 | if (alertif_too_many_args(1, file, linenum, args, &err_code)) |
| 484 | goto out; |
| 485 | if (global.uid != 0) { |
| 486 | ha_alert("parsing [%s:%d] : user/uid already specified. Continuing.\n", file, linenum); |
| 487 | err_code |= ERR_ALERT; |
| 488 | goto out; |
| 489 | } |
| 490 | if (*(args[1]) == 0) { |
| 491 | ha_alert("parsing [%s:%d] : '%s' expects an integer argument.\n", file, linenum, args[0]); |
| 492 | err_code |= ERR_ALERT | ERR_FATAL; |
| 493 | goto out; |
| 494 | } |
| 495 | if (strl2irc(args[1], strlen(args[1]), &global.uid) != 0) { |
| 496 | ha_warning("parsing [%s:%d] : uid: string '%s' is not a number.\n | You might want to use the 'user' parameter to use a system user name.\n", file, linenum, args[1]); |
| 497 | err_code |= ERR_WARN; |
| 498 | goto out; |
| 499 | } |
| 500 | |
| 501 | } |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 502 | else if (strcmp(args[0], "gid") == 0) { |
Willy Tarreau | 36b9e22 | 2018-11-11 15:19:52 +0100 | [diff] [blame] | 503 | if (alertif_too_many_args(1, file, linenum, args, &err_code)) |
| 504 | goto out; |
| 505 | if (global.gid != 0) { |
| 506 | ha_alert("parsing [%s:%d] : group/gid already specified. Continuing.\n", file, linenum); |
| 507 | err_code |= ERR_ALERT; |
| 508 | goto out; |
| 509 | } |
| 510 | if (*(args[1]) == 0) { |
| 511 | ha_alert("parsing [%s:%d] : '%s' expects an integer argument.\n", file, linenum, args[0]); |
| 512 | err_code |= ERR_ALERT | ERR_FATAL; |
| 513 | goto out; |
| 514 | } |
| 515 | if (strl2irc(args[1], strlen(args[1]), &global.gid) != 0) { |
| 516 | ha_warning("parsing [%s:%d] : gid: string '%s' is not a number.\n | You might want to use the 'group' parameter to use a system group name.\n", file, linenum, args[1]); |
| 517 | err_code |= ERR_WARN; |
| 518 | goto out; |
| 519 | } |
| 520 | } |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 521 | else if (strcmp(args[0], "external-check") == 0) { |
Willy Tarreau | 36b9e22 | 2018-11-11 15:19:52 +0100 | [diff] [blame] | 522 | if (alertif_too_many_args(0, file, linenum, args, &err_code)) |
| 523 | goto out; |
| 524 | global.external_check = 1; |
| 525 | } |
| 526 | /* user/group name handling */ |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 527 | else if (strcmp(args[0], "user") == 0) { |
Willy Tarreau | 36b9e22 | 2018-11-11 15:19:52 +0100 | [diff] [blame] | 528 | struct passwd *ha_user; |
| 529 | if (alertif_too_many_args(1, file, linenum, args, &err_code)) |
| 530 | goto out; |
| 531 | if (global.uid != 0) { |
| 532 | ha_alert("parsing [%s:%d] : user/uid already specified. Continuing.\n", file, linenum); |
| 533 | err_code |= ERR_ALERT; |
| 534 | goto out; |
| 535 | } |
| 536 | errno = 0; |
| 537 | ha_user = getpwnam(args[1]); |
| 538 | if (ha_user != NULL) { |
| 539 | global.uid = (int)ha_user->pw_uid; |
| 540 | } |
| 541 | else { |
| 542 | ha_alert("parsing [%s:%d] : cannot find user id for '%s' (%d:%s)\n", file, linenum, args[1], errno, strerror(errno)); |
| 543 | err_code |= ERR_ALERT | ERR_FATAL; |
| 544 | } |
| 545 | } |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 546 | else if (strcmp(args[0], "group") == 0) { |
Willy Tarreau | 36b9e22 | 2018-11-11 15:19:52 +0100 | [diff] [blame] | 547 | struct group *ha_group; |
| 548 | if (alertif_too_many_args(1, file, linenum, args, &err_code)) |
| 549 | goto out; |
| 550 | if (global.gid != 0) { |
| 551 | ha_alert("parsing [%s:%d] : gid/group was already specified. Continuing.\n", file, linenum); |
| 552 | err_code |= ERR_ALERT; |
| 553 | goto out; |
| 554 | } |
| 555 | errno = 0; |
| 556 | ha_group = getgrnam(args[1]); |
| 557 | if (ha_group != NULL) { |
| 558 | global.gid = (int)ha_group->gr_gid; |
| 559 | } |
| 560 | else { |
| 561 | ha_alert("parsing [%s:%d] : cannot find group id for '%s' (%d:%s)\n", file, linenum, args[1], errno, strerror(errno)); |
| 562 | err_code |= ERR_ALERT | ERR_FATAL; |
| 563 | } |
| 564 | } |
| 565 | /* end of user/group name handling*/ |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 566 | else if (strcmp(args[0], "nbproc") == 0) { |
Willy Tarreau | 36b9e22 | 2018-11-11 15:19:52 +0100 | [diff] [blame] | 567 | if (alertif_too_many_args(1, file, linenum, args, &err_code)) |
| 568 | goto out; |
| 569 | if (*(args[1]) == 0) { |
| 570 | ha_alert("parsing [%s:%d] : '%s' expects an integer argument.\n", file, linenum, args[0]); |
| 571 | err_code |= ERR_ALERT | ERR_FATAL; |
| 572 | goto out; |
| 573 | } |
| 574 | global.nbproc = atol(args[1]); |
Willy Tarreau | a38a717 | 2019-02-02 17:11:28 +0100 | [diff] [blame] | 575 | all_proc_mask = nbits(global.nbproc); |
Willy Tarreau | ff9c914 | 2019-02-07 10:39:36 +0100 | [diff] [blame] | 576 | if (global.nbproc < 1 || global.nbproc > MAX_PROCS) { |
Willy Tarreau | 36b9e22 | 2018-11-11 15:19:52 +0100 | [diff] [blame] | 577 | ha_alert("parsing [%s:%d] : '%s' must be between 1 and %d (was %d).\n", |
Willy Tarreau | ff9c914 | 2019-02-07 10:39:36 +0100 | [diff] [blame] | 578 | file, linenum, args[0], MAX_PROCS, global.nbproc); |
Willy Tarreau | 36b9e22 | 2018-11-11 15:19:52 +0100 | [diff] [blame] | 579 | err_code |= ERR_ALERT | ERR_FATAL; |
| 580 | goto out; |
| 581 | } |
| 582 | } |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 583 | else if (strcmp(args[0], "nbthread") == 0) { |
Willy Tarreau | 36b9e22 | 2018-11-11 15:19:52 +0100 | [diff] [blame] | 584 | if (alertif_too_many_args(1, file, linenum, args, &err_code)) |
| 585 | goto out; |
| 586 | if (*(args[1]) == 0) { |
| 587 | ha_alert("parsing [%s:%d] : '%s' expects an integer argument.\n", file, linenum, args[0]); |
| 588 | err_code |= ERR_ALERT | ERR_FATAL; |
| 589 | goto out; |
| 590 | } |
Amaury Denoyelle | c4d47d6 | 2021-03-29 10:41:15 +0200 | [diff] [blame] | 591 | |
| 592 | HA_DIAG_WARNING_COND(global.nbthread, |
| 593 | "parsing [%s:%d] : nbthread is already defined and will be overridden.\n", |
| 594 | file, linenum); |
| 595 | |
Willy Tarreau | 36b9e22 | 2018-11-11 15:19:52 +0100 | [diff] [blame] | 596 | global.nbthread = parse_nbthread(args[1], &errmsg); |
| 597 | if (!global.nbthread) { |
| 598 | ha_alert("parsing [%s:%d] : '%s' %s.\n", |
| 599 | file, linenum, args[0], errmsg); |
| 600 | err_code |= ERR_ALERT | ERR_FATAL; |
| 601 | goto out; |
| 602 | } |
| 603 | } |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 604 | else if (strcmp(args[0], "maxconn") == 0) { |
Willy Tarreau | 36b9e22 | 2018-11-11 15:19:52 +0100 | [diff] [blame] | 605 | if (alertif_too_many_args(1, file, linenum, args, &err_code)) |
| 606 | goto out; |
| 607 | if (global.maxconn != 0) { |
| 608 | ha_alert("parsing [%s:%d] : '%s' already specified. Continuing.\n", file, linenum, args[0]); |
| 609 | err_code |= ERR_ALERT; |
| 610 | goto out; |
| 611 | } |
| 612 | if (*(args[1]) == 0) { |
| 613 | ha_alert("parsing [%s:%d] : '%s' expects an integer argument.\n", file, linenum, args[0]); |
| 614 | err_code |= ERR_ALERT | ERR_FATAL; |
| 615 | goto out; |
| 616 | } |
| 617 | global.maxconn = atol(args[1]); |
| 618 | #ifdef SYSTEM_MAXCONN |
Willy Tarreau | ca783d4 | 2019-03-13 10:03:07 +0100 | [diff] [blame] | 619 | if (global.maxconn > SYSTEM_MAXCONN && cfg_maxconn <= SYSTEM_MAXCONN) { |
| 620 | ha_alert("parsing [%s:%d] : maxconn value %d too high for this system.\nLimiting to %d. Please use '-n' to force the value.\n", file, linenum, global.maxconn, SYSTEM_MAXCONN); |
| 621 | global.maxconn = SYSTEM_MAXCONN; |
Willy Tarreau | 36b9e22 | 2018-11-11 15:19:52 +0100 | [diff] [blame] | 622 | err_code |= ERR_ALERT; |
| 623 | } |
| 624 | #endif /* SYSTEM_MAXCONN */ |
| 625 | } |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 626 | else if (strcmp(args[0], "ssl-server-verify") == 0) { |
Willy Tarreau | 36b9e22 | 2018-11-11 15:19:52 +0100 | [diff] [blame] | 627 | if (alertif_too_many_args(1, file, linenum, args, &err_code)) |
| 628 | goto out; |
| 629 | if (*(args[1]) == 0) { |
| 630 | ha_alert("parsing [%s:%d] : '%s' expects an integer argument.\n", file, linenum, args[0]); |
| 631 | err_code |= ERR_ALERT | ERR_FATAL; |
| 632 | goto out; |
| 633 | } |
| 634 | if (strcmp(args[1],"none") == 0) |
| 635 | global.ssl_server_verify = SSL_SERVER_VERIFY_NONE; |
| 636 | else if (strcmp(args[1],"required") == 0) |
| 637 | global.ssl_server_verify = SSL_SERVER_VERIFY_REQUIRED; |
| 638 | else { |
| 639 | ha_alert("parsing [%s:%d] : '%s' expects 'none' or 'required' as argument.\n", file, linenum, args[0]); |
| 640 | err_code |= ERR_ALERT | ERR_FATAL; |
| 641 | goto out; |
| 642 | } |
| 643 | } |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 644 | else if (strcmp(args[0], "maxconnrate") == 0) { |
Willy Tarreau | 36b9e22 | 2018-11-11 15:19:52 +0100 | [diff] [blame] | 645 | if (alertif_too_many_args(1, file, linenum, args, &err_code)) |
| 646 | goto out; |
| 647 | if (global.cps_lim != 0) { |
| 648 | ha_alert("parsing [%s:%d] : '%s' already specified. Continuing.\n", file, linenum, args[0]); |
| 649 | err_code |= ERR_ALERT; |
| 650 | goto out; |
| 651 | } |
| 652 | if (*(args[1]) == 0) { |
| 653 | ha_alert("parsing [%s:%d] : '%s' expects an integer argument.\n", file, linenum, args[0]); |
| 654 | err_code |= ERR_ALERT | ERR_FATAL; |
| 655 | goto out; |
| 656 | } |
| 657 | global.cps_lim = atol(args[1]); |
| 658 | } |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 659 | else if (strcmp(args[0], "maxsessrate") == 0) { |
Willy Tarreau | 36b9e22 | 2018-11-11 15:19:52 +0100 | [diff] [blame] | 660 | if (alertif_too_many_args(1, file, linenum, args, &err_code)) |
| 661 | goto out; |
| 662 | if (global.sps_lim != 0) { |
| 663 | ha_alert("parsing [%s:%d] : '%s' already specified. Continuing.\n", file, linenum, args[0]); |
| 664 | err_code |= ERR_ALERT; |
| 665 | goto out; |
| 666 | } |
| 667 | if (*(args[1]) == 0) { |
| 668 | ha_alert("parsing [%s:%d] : '%s' expects an integer argument.\n", file, linenum, args[0]); |
| 669 | err_code |= ERR_ALERT | ERR_FATAL; |
| 670 | goto out; |
| 671 | } |
| 672 | global.sps_lim = atol(args[1]); |
| 673 | } |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 674 | else if (strcmp(args[0], "maxsslrate") == 0) { |
Willy Tarreau | 36b9e22 | 2018-11-11 15:19:52 +0100 | [diff] [blame] | 675 | if (alertif_too_many_args(1, file, linenum, args, &err_code)) |
| 676 | goto out; |
| 677 | if (global.ssl_lim != 0) { |
| 678 | ha_alert("parsing [%s:%d] : '%s' already specified. Continuing.\n", file, linenum, args[0]); |
| 679 | err_code |= ERR_ALERT; |
| 680 | goto out; |
| 681 | } |
| 682 | if (*(args[1]) == 0) { |
| 683 | ha_alert("parsing [%s:%d] : '%s' expects an integer argument.\n", file, linenum, args[0]); |
| 684 | err_code |= ERR_ALERT | ERR_FATAL; |
| 685 | goto out; |
| 686 | } |
| 687 | global.ssl_lim = atol(args[1]); |
| 688 | } |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 689 | else if (strcmp(args[0], "maxcomprate") == 0) { |
Willy Tarreau | 36b9e22 | 2018-11-11 15:19:52 +0100 | [diff] [blame] | 690 | if (alertif_too_many_args(1, file, linenum, args, &err_code)) |
| 691 | goto out; |
| 692 | if (*(args[1]) == 0) { |
| 693 | ha_alert("parsing [%s:%d] : '%s' expects an integer argument in kb/s.\n", file, linenum, args[0]); |
| 694 | err_code |= ERR_ALERT | ERR_FATAL; |
| 695 | goto out; |
| 696 | } |
| 697 | global.comp_rate_lim = atoi(args[1]) * 1024; |
| 698 | } |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 699 | else if (strcmp(args[0], "maxpipes") == 0) { |
Willy Tarreau | 36b9e22 | 2018-11-11 15:19:52 +0100 | [diff] [blame] | 700 | if (alertif_too_many_args(1, file, linenum, args, &err_code)) |
| 701 | goto out; |
| 702 | if (global.maxpipes != 0) { |
| 703 | ha_alert("parsing [%s:%d] : '%s' already specified. Continuing.\n", file, linenum, args[0]); |
| 704 | err_code |= ERR_ALERT; |
| 705 | goto out; |
| 706 | } |
| 707 | if (*(args[1]) == 0) { |
| 708 | ha_alert("parsing [%s:%d] : '%s' expects an integer argument.\n", file, linenum, args[0]); |
| 709 | err_code |= ERR_ALERT | ERR_FATAL; |
| 710 | goto out; |
| 711 | } |
| 712 | global.maxpipes = atol(args[1]); |
| 713 | } |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 714 | else if (strcmp(args[0], "maxzlibmem") == 0) { |
Willy Tarreau | 36b9e22 | 2018-11-11 15:19:52 +0100 | [diff] [blame] | 715 | if (alertif_too_many_args(1, file, linenum, args, &err_code)) |
| 716 | goto out; |
| 717 | if (*(args[1]) == 0) { |
| 718 | ha_alert("parsing [%s:%d] : '%s' expects an integer argument.\n", file, linenum, args[0]); |
| 719 | err_code |= ERR_ALERT | ERR_FATAL; |
| 720 | goto out; |
| 721 | } |
| 722 | global.maxzlibmem = atol(args[1]) * 1024L * 1024L; |
| 723 | } |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 724 | else if (strcmp(args[0], "maxcompcpuusage") == 0) { |
Willy Tarreau | 36b9e22 | 2018-11-11 15:19:52 +0100 | [diff] [blame] | 725 | if (alertif_too_many_args(1, file, linenum, args, &err_code)) |
| 726 | goto out; |
| 727 | if (*(args[1]) == 0) { |
| 728 | ha_alert("parsing [%s:%d] : '%s' expects an integer argument between 0 and 100.\n", file, linenum, args[0]); |
| 729 | err_code |= ERR_ALERT | ERR_FATAL; |
| 730 | goto out; |
| 731 | } |
| 732 | compress_min_idle = 100 - atoi(args[1]); |
| 733 | if (compress_min_idle > 100) { |
| 734 | ha_alert("parsing [%s:%d] : '%s' expects an integer argument between 0 and 100.\n", file, linenum, args[0]); |
| 735 | err_code |= ERR_ALERT | ERR_FATAL; |
| 736 | goto out; |
| 737 | } |
| 738 | } |
| 739 | |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 740 | else if (strcmp(args[0], "ulimit-n") == 0) { |
Willy Tarreau | 36b9e22 | 2018-11-11 15:19:52 +0100 | [diff] [blame] | 741 | if (alertif_too_many_args(1, file, linenum, args, &err_code)) |
| 742 | goto out; |
| 743 | if (global.rlimit_nofile != 0) { |
| 744 | ha_alert("parsing [%s:%d] : '%s' already specified. Continuing.\n", file, linenum, args[0]); |
| 745 | err_code |= ERR_ALERT; |
| 746 | goto out; |
| 747 | } |
| 748 | if (*(args[1]) == 0) { |
| 749 | ha_alert("parsing [%s:%d] : '%s' expects an integer argument.\n", file, linenum, args[0]); |
| 750 | err_code |= ERR_ALERT | ERR_FATAL; |
| 751 | goto out; |
| 752 | } |
| 753 | global.rlimit_nofile = atol(args[1]); |
| 754 | } |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 755 | else if (strcmp(args[0], "chroot") == 0) { |
Willy Tarreau | 36b9e22 | 2018-11-11 15:19:52 +0100 | [diff] [blame] | 756 | if (alertif_too_many_args(1, file, linenum, args, &err_code)) |
| 757 | goto out; |
| 758 | if (global.chroot != NULL) { |
| 759 | ha_alert("parsing [%s:%d] : '%s' already specified. Continuing.\n", file, linenum, args[0]); |
| 760 | err_code |= ERR_ALERT; |
| 761 | goto out; |
| 762 | } |
| 763 | if (*(args[1]) == 0) { |
| 764 | ha_alert("parsing [%s:%d] : '%s' expects a directory as an argument.\n", file, linenum, args[0]); |
| 765 | err_code |= ERR_ALERT | ERR_FATAL; |
| 766 | goto out; |
| 767 | } |
| 768 | global.chroot = strdup(args[1]); |
| 769 | } |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 770 | else if (strcmp(args[0], "description") == 0) { |
Willy Tarreau | 36b9e22 | 2018-11-11 15:19:52 +0100 | [diff] [blame] | 771 | int i, len=0; |
| 772 | char *d; |
| 773 | |
| 774 | if (!*args[1]) { |
| 775 | ha_alert("parsing [%s:%d]: '%s' expects a string argument.\n", |
| 776 | file, linenum, args[0]); |
| 777 | err_code |= ERR_ALERT | ERR_FATAL; |
| 778 | goto out; |
| 779 | } |
| 780 | |
| 781 | for (i = 1; *args[i]; i++) |
| 782 | len += strlen(args[i]) + 1; |
| 783 | |
| 784 | if (global.desc) |
| 785 | free(global.desc); |
| 786 | |
| 787 | global.desc = d = calloc(1, len); |
| 788 | |
| 789 | d += snprintf(d, global.desc + len - d, "%s", args[1]); |
| 790 | for (i = 2; *args[i]; i++) |
| 791 | d += snprintf(d, global.desc + len - d, " %s", args[i]); |
| 792 | } |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 793 | else if (strcmp(args[0], "node") == 0) { |
Willy Tarreau | 36b9e22 | 2018-11-11 15:19:52 +0100 | [diff] [blame] | 794 | int i; |
| 795 | char c; |
| 796 | |
| 797 | if (alertif_too_many_args(1, file, linenum, args, &err_code)) |
| 798 | goto out; |
| 799 | |
| 800 | for (i=0; args[1][i]; i++) { |
| 801 | c = args[1][i]; |
| 802 | if (!isupper((unsigned char)c) && !islower((unsigned char)c) && |
| 803 | !isdigit((unsigned char)c) && c != '_' && c != '-' && c != '.') |
| 804 | break; |
| 805 | } |
| 806 | |
| 807 | if (!i || args[1][i]) { |
| 808 | ha_alert("parsing [%s:%d]: '%s' requires valid node name - non-empty string" |
| 809 | " with digits(0-9), letters(A-Z, a-z), dot(.), hyphen(-) or underscode(_).\n", |
| 810 | file, linenum, args[0]); |
| 811 | err_code |= ERR_ALERT | ERR_FATAL; |
| 812 | goto out; |
| 813 | } |
| 814 | |
| 815 | if (global.node) |
| 816 | free(global.node); |
| 817 | |
| 818 | global.node = strdup(args[1]); |
| 819 | } |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 820 | else if (strcmp(args[0], "pidfile") == 0) { |
Willy Tarreau | 36b9e22 | 2018-11-11 15:19:52 +0100 | [diff] [blame] | 821 | if (alertif_too_many_args(1, file, linenum, args, &err_code)) |
| 822 | goto out; |
| 823 | if (global.pidfile != NULL) { |
| 824 | ha_alert("parsing [%s:%d] : '%s' already specified. Continuing.\n", file, linenum, args[0]); |
| 825 | err_code |= ERR_ALERT; |
| 826 | goto out; |
| 827 | } |
| 828 | if (*(args[1]) == 0) { |
| 829 | ha_alert("parsing [%s:%d] : '%s' expects a file name as an argument.\n", file, linenum, args[0]); |
| 830 | err_code |= ERR_ALERT | ERR_FATAL; |
| 831 | goto out; |
| 832 | } |
| 833 | global.pidfile = strdup(args[1]); |
| 834 | } |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 835 | else if (strcmp(args[0], "unix-bind") == 0) { |
Willy Tarreau | 36b9e22 | 2018-11-11 15:19:52 +0100 | [diff] [blame] | 836 | int cur_arg = 1; |
| 837 | while (*(args[cur_arg])) { |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 838 | if (strcmp(args[cur_arg], "prefix") == 0) { |
Willy Tarreau | 36b9e22 | 2018-11-11 15:19:52 +0100 | [diff] [blame] | 839 | if (global.unix_bind.prefix != NULL) { |
| 840 | ha_alert("parsing [%s:%d] : unix-bind '%s' already specified. Continuing.\n", file, linenum, args[cur_arg]); |
| 841 | err_code |= ERR_ALERT; |
| 842 | cur_arg += 2; |
| 843 | continue; |
| 844 | } |
| 845 | |
| 846 | if (*(args[cur_arg+1]) == 0) { |
| 847 | ha_alert("parsing [%s:%d] : unix_bind '%s' expects a path as an argument.\n", file, linenum, args[cur_arg]); |
| 848 | err_code |= ERR_ALERT | ERR_FATAL; |
| 849 | goto out; |
| 850 | } |
| 851 | global.unix_bind.prefix = strdup(args[cur_arg+1]); |
| 852 | cur_arg += 2; |
| 853 | continue; |
| 854 | } |
| 855 | |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 856 | if (strcmp(args[cur_arg], "mode") == 0) { |
Willy Tarreau | 36b9e22 | 2018-11-11 15:19:52 +0100 | [diff] [blame] | 857 | |
| 858 | global.unix_bind.ux.mode = strtol(args[cur_arg + 1], NULL, 8); |
| 859 | cur_arg += 2; |
| 860 | continue; |
| 861 | } |
| 862 | |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 863 | if (strcmp(args[cur_arg], "uid") == 0) { |
Willy Tarreau | 36b9e22 | 2018-11-11 15:19:52 +0100 | [diff] [blame] | 864 | |
| 865 | global.unix_bind.ux.uid = atol(args[cur_arg + 1 ]); |
| 866 | cur_arg += 2; |
| 867 | continue; |
| 868 | } |
| 869 | |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 870 | if (strcmp(args[cur_arg], "gid") == 0) { |
Willy Tarreau | 36b9e22 | 2018-11-11 15:19:52 +0100 | [diff] [blame] | 871 | |
| 872 | global.unix_bind.ux.gid = atol(args[cur_arg + 1 ]); |
| 873 | cur_arg += 2; |
| 874 | continue; |
| 875 | } |
| 876 | |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 877 | if (strcmp(args[cur_arg], "user") == 0) { |
Willy Tarreau | 36b9e22 | 2018-11-11 15:19:52 +0100 | [diff] [blame] | 878 | struct passwd *user; |
| 879 | |
| 880 | user = getpwnam(args[cur_arg + 1]); |
| 881 | if (!user) { |
| 882 | ha_alert("parsing [%s:%d] : '%s' : '%s' unknown user.\n", |
| 883 | file, linenum, args[0], args[cur_arg + 1 ]); |
| 884 | err_code |= ERR_ALERT | ERR_FATAL; |
| 885 | goto out; |
| 886 | } |
| 887 | |
| 888 | global.unix_bind.ux.uid = user->pw_uid; |
| 889 | cur_arg += 2; |
| 890 | continue; |
| 891 | } |
| 892 | |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 893 | if (strcmp(args[cur_arg], "group") == 0) { |
Willy Tarreau | 36b9e22 | 2018-11-11 15:19:52 +0100 | [diff] [blame] | 894 | struct group *group; |
| 895 | |
| 896 | group = getgrnam(args[cur_arg + 1]); |
| 897 | if (!group) { |
| 898 | ha_alert("parsing [%s:%d] : '%s' : '%s' unknown group.\n", |
| 899 | file, linenum, args[0], args[cur_arg + 1 ]); |
| 900 | err_code |= ERR_ALERT | ERR_FATAL; |
| 901 | goto out; |
| 902 | } |
| 903 | |
| 904 | global.unix_bind.ux.gid = group->gr_gid; |
| 905 | cur_arg += 2; |
| 906 | continue; |
| 907 | } |
| 908 | |
| 909 | ha_alert("parsing [%s:%d] : '%s' only supports the 'prefix', 'mode', 'uid', 'gid', 'user' and 'group' options.\n", |
| 910 | file, linenum, args[0]); |
| 911 | err_code |= ERR_ALERT | ERR_FATAL; |
| 912 | goto out; |
| 913 | } |
| 914 | } |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 915 | else if (strcmp(args[0], "log") == 0) { /* "no log" or "log ..." */ |
Emeric Brun | 9533a70 | 2021-04-02 10:13:43 +0200 | [diff] [blame] | 916 | if (!parse_logsrv(args, &global.logsrvs, (kwm == KWM_NO), file, linenum, &errmsg)) { |
Willy Tarreau | 36b9e22 | 2018-11-11 15:19:52 +0100 | [diff] [blame] | 917 | ha_alert("parsing [%s:%d] : %s : %s\n", file, linenum, args[0], errmsg); |
| 918 | err_code |= ERR_ALERT | ERR_FATAL; |
| 919 | goto out; |
| 920 | } |
| 921 | } |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 922 | else if (strcmp(args[0], "log-send-hostname") == 0) { /* set the hostname in syslog header */ |
Willy Tarreau | 36b9e22 | 2018-11-11 15:19:52 +0100 | [diff] [blame] | 923 | char *name; |
| 924 | |
| 925 | if (global.log_send_hostname != NULL) { |
| 926 | ha_alert("parsing [%s:%d] : '%s' already specified. Continuing.\n", file, linenum, args[0]); |
| 927 | err_code |= ERR_ALERT; |
| 928 | goto out; |
| 929 | } |
| 930 | |
| 931 | if (*(args[1])) |
| 932 | name = args[1]; |
| 933 | else |
| 934 | name = hostname; |
| 935 | |
| 936 | free(global.log_send_hostname); |
| 937 | global.log_send_hostname = strdup(name); |
| 938 | } |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 939 | else if (strcmp(args[0], "server-state-base") == 0) { /* path base where HAProxy can find server state files */ |
Willy Tarreau | 36b9e22 | 2018-11-11 15:19:52 +0100 | [diff] [blame] | 940 | if (global.server_state_base != NULL) { |
| 941 | ha_alert("parsing [%s:%d] : '%s' already specified. Continuing.\n", file, linenum, args[0]); |
| 942 | err_code |= ERR_ALERT; |
| 943 | goto out; |
| 944 | } |
| 945 | |
| 946 | if (!*(args[1])) { |
| 947 | ha_alert("parsing [%s:%d] : '%s' expects one argument: a directory path.\n", file, linenum, args[0]); |
| 948 | err_code |= ERR_FATAL; |
| 949 | goto out; |
| 950 | } |
| 951 | |
| 952 | global.server_state_base = strdup(args[1]); |
| 953 | } |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 954 | else if (strcmp(args[0], "server-state-file") == 0) { /* path to the file where HAProxy can load the server states */ |
Willy Tarreau | 36b9e22 | 2018-11-11 15:19:52 +0100 | [diff] [blame] | 955 | if (global.server_state_file != NULL) { |
| 956 | ha_alert("parsing [%s:%d] : '%s' already specified. Continuing.\n", file, linenum, args[0]); |
| 957 | err_code |= ERR_ALERT; |
| 958 | goto out; |
| 959 | } |
| 960 | |
| 961 | if (!*(args[1])) { |
| 962 | ha_alert("parsing [%s:%d] : '%s' expect one argument: a file path.\n", file, linenum, args[0]); |
| 963 | err_code |= ERR_FATAL; |
| 964 | goto out; |
| 965 | } |
| 966 | |
| 967 | global.server_state_file = strdup(args[1]); |
| 968 | } |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 969 | else if (strcmp(args[0], "log-tag") == 0) { /* tag to report to syslog */ |
Willy Tarreau | 36b9e22 | 2018-11-11 15:19:52 +0100 | [diff] [blame] | 970 | if (alertif_too_many_args(1, file, linenum, args, &err_code)) |
| 971 | goto out; |
| 972 | if (*(args[1]) == 0) { |
| 973 | ha_alert("parsing [%s:%d] : '%s' expects a tag for use in syslog.\n", file, linenum, args[0]); |
| 974 | err_code |= ERR_ALERT | ERR_FATAL; |
| 975 | goto out; |
| 976 | } |
| 977 | chunk_destroy(&global.log_tag); |
Eric Salama | 7cea606 | 2020-10-02 11:58:19 +0200 | [diff] [blame] | 978 | chunk_initlen(&global.log_tag, strdup(args[1]), strlen(args[1]), strlen(args[1])); |
| 979 | if (b_orig(&global.log_tag) == NULL) { |
| 980 | chunk_destroy(&global.log_tag); |
| 981 | ha_alert("parsing [%s:%d]: cannot allocate memory for '%s'.\n", file, linenum, args[0]); |
| 982 | err_code |= ERR_ALERT | ERR_FATAL; |
| 983 | goto out; |
| 984 | } |
Willy Tarreau | 36b9e22 | 2018-11-11 15:19:52 +0100 | [diff] [blame] | 985 | } |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 986 | else if (strcmp(args[0], "spread-checks") == 0) { /* random time between checks (0-50) */ |
Willy Tarreau | 36b9e22 | 2018-11-11 15:19:52 +0100 | [diff] [blame] | 987 | if (alertif_too_many_args(1, file, linenum, args, &err_code)) |
| 988 | goto out; |
| 989 | if (global.spread_checks != 0) { |
| 990 | ha_alert("parsing [%s:%d]: spread-checks already specified. Continuing.\n", file, linenum); |
| 991 | err_code |= ERR_ALERT; |
| 992 | goto out; |
| 993 | } |
| 994 | if (*(args[1]) == 0) { |
| 995 | ha_alert("parsing [%s:%d]: '%s' expects an integer argument (0..50).\n", file, linenum, args[0]); |
| 996 | err_code |= ERR_ALERT | ERR_FATAL; |
| 997 | goto out; |
| 998 | } |
| 999 | global.spread_checks = atol(args[1]); |
| 1000 | if (global.spread_checks < 0 || global.spread_checks > 50) { |
| 1001 | ha_alert("parsing [%s:%d]: 'spread-checks' needs a positive value in range 0..50.\n", file, linenum); |
| 1002 | err_code |= ERR_ALERT | ERR_FATAL; |
| 1003 | } |
| 1004 | } |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 1005 | else if (strcmp(args[0], "max-spread-checks") == 0) { /* maximum time between first and last check */ |
Willy Tarreau | 36b9e22 | 2018-11-11 15:19:52 +0100 | [diff] [blame] | 1006 | const char *err; |
| 1007 | unsigned int val; |
| 1008 | |
| 1009 | if (alertif_too_many_args(1, file, linenum, args, &err_code)) |
| 1010 | goto out; |
| 1011 | if (*(args[1]) == 0) { |
| 1012 | ha_alert("parsing [%s:%d]: '%s' expects an integer argument (0..50).\n", file, linenum, args[0]); |
| 1013 | err_code |= ERR_ALERT | ERR_FATAL; |
| 1014 | goto out; |
| 1015 | } |
| 1016 | |
| 1017 | err = parse_time_err(args[1], &val, TIME_UNIT_MS); |
Willy Tarreau | 9faebe3 | 2019-06-07 19:00:37 +0200 | [diff] [blame] | 1018 | if (err == PARSE_TIME_OVER) { |
| 1019 | ha_alert("parsing [%s:%d]: timer overflow in argument <%s> to <%s>, maximum value is 2147483647 ms (~24.8 days).\n", |
| 1020 | file, linenum, args[1], args[0]); |
Willy Tarreau | 36b9e22 | 2018-11-11 15:19:52 +0100 | [diff] [blame] | 1021 | err_code |= ERR_ALERT | ERR_FATAL; |
| 1022 | } |
Willy Tarreau | 9faebe3 | 2019-06-07 19:00:37 +0200 | [diff] [blame] | 1023 | else if (err == PARSE_TIME_UNDER) { |
| 1024 | ha_alert("parsing [%s:%d]: timer underflow in argument <%s> to <%s>, minimum non-null value is 1 ms.\n", |
| 1025 | file, linenum, args[1], args[0]); |
| 1026 | err_code |= ERR_ALERT | ERR_FATAL; |
| 1027 | } |
| 1028 | else if (err) { |
| 1029 | ha_alert("parsing [%s:%d]: unsupported character '%c' in '%s' (wants an integer delay).\n", file, linenum, *err, args[0]); |
Willy Tarreau | 36b9e22 | 2018-11-11 15:19:52 +0100 | [diff] [blame] | 1030 | err_code |= ERR_ALERT | ERR_FATAL; |
| 1031 | } |
Willy Tarreau | 9faebe3 | 2019-06-07 19:00:37 +0200 | [diff] [blame] | 1032 | global.max_spread_checks = val; |
Willy Tarreau | 36b9e22 | 2018-11-11 15:19:52 +0100 | [diff] [blame] | 1033 | } |
| 1034 | else if (strcmp(args[0], "cpu-map") == 0) { |
| 1035 | /* map a process list to a CPU set */ |
| 1036 | #ifdef USE_CPU_AFFINITY |
| 1037 | char *slash; |
Amaury Denoyelle | 982fb53 | 2021-04-21 18:39:58 +0200 | [diff] [blame] | 1038 | unsigned long proc = 0, thread = 0; |
| 1039 | int i, j, n, autoinc; |
| 1040 | struct hap_cpuset cpus, cpus_copy; |
Willy Tarreau | 36b9e22 | 2018-11-11 15:19:52 +0100 | [diff] [blame] | 1041 | |
| 1042 | if (!*args[1] || !*args[2]) { |
| 1043 | ha_alert("parsing [%s:%d] : %s expects a process number " |
| 1044 | " ('all', 'odd', 'even', a number from 1 to %d or a range), " |
| 1045 | " followed by a list of CPU ranges with numbers from 0 to %d.\n", |
Willy Tarreau | 5799e9c | 2019-03-05 18:14:03 +0100 | [diff] [blame] | 1046 | file, linenum, args[0], LONGBITS, LONGBITS - 1); |
Willy Tarreau | 36b9e22 | 2018-11-11 15:19:52 +0100 | [diff] [blame] | 1047 | err_code |= ERR_ALERT | ERR_FATAL; |
| 1048 | goto out; |
| 1049 | } |
| 1050 | |
| 1051 | if ((slash = strchr(args[1], '/')) != NULL) |
| 1052 | *slash = 0; |
| 1053 | |
Willy Tarreau | 5799e9c | 2019-03-05 18:14:03 +0100 | [diff] [blame] | 1054 | /* note: we silently ignore processes over MAX_PROCS and |
| 1055 | * threads over MAX_THREADS so as not to make configurations a |
| 1056 | * pain to maintain. |
| 1057 | */ |
| 1058 | if (parse_process_number(args[1], &proc, LONGBITS, &autoinc, &errmsg)) { |
Willy Tarreau | 36b9e22 | 2018-11-11 15:19:52 +0100 | [diff] [blame] | 1059 | ha_alert("parsing [%s:%d] : %s : %s\n", file, linenum, args[0], errmsg); |
| 1060 | err_code |= ERR_ALERT | ERR_FATAL; |
| 1061 | goto out; |
| 1062 | } |
| 1063 | |
| 1064 | if (slash) { |
Willy Tarreau | 5799e9c | 2019-03-05 18:14:03 +0100 | [diff] [blame] | 1065 | if (parse_process_number(slash+1, &thread, LONGBITS, NULL, &errmsg)) { |
Willy Tarreau | 36b9e22 | 2018-11-11 15:19:52 +0100 | [diff] [blame] | 1066 | ha_alert("parsing [%s:%d] : %s : %s\n", file, linenum, args[0], errmsg); |
| 1067 | err_code |= ERR_ALERT | ERR_FATAL; |
| 1068 | goto out; |
| 1069 | } |
| 1070 | *slash = '/'; |
| 1071 | |
| 1072 | if (autoinc && atleast2(proc) && atleast2(thread)) { |
| 1073 | ha_alert("parsing [%s:%d] : %s : '%s' : unable to automatically bind " |
| 1074 | "a process range _AND_ a thread range\n", |
| 1075 | file, linenum, args[0], args[1]); |
| 1076 | err_code |= ERR_ALERT | ERR_FATAL; |
| 1077 | goto out; |
| 1078 | } |
| 1079 | } |
| 1080 | |
Amaury Denoyelle | a808235 | 2021-04-06 16:46:15 +0200 | [diff] [blame] | 1081 | if (parse_cpu_set((const char **)args+2, &cpus, 0, &errmsg)) { |
Willy Tarreau | 36b9e22 | 2018-11-11 15:19:52 +0100 | [diff] [blame] | 1082 | ha_alert("parsing [%s:%d] : %s : %s\n", file, linenum, args[0], errmsg); |
| 1083 | err_code |= ERR_ALERT | ERR_FATAL; |
| 1084 | goto out; |
| 1085 | } |
Amaury Denoyelle | 982fb53 | 2021-04-21 18:39:58 +0200 | [diff] [blame] | 1086 | |
Willy Tarreau | 36b9e22 | 2018-11-11 15:19:52 +0100 | [diff] [blame] | 1087 | if (autoinc && |
Amaury Denoyelle | 982fb53 | 2021-04-21 18:39:58 +0200 | [diff] [blame] | 1088 | my_popcountl(proc) != ha_cpuset_count(&cpus) && |
| 1089 | my_popcountl(thread) != ha_cpuset_count(&cpus)) { |
Willy Tarreau | 36b9e22 | 2018-11-11 15:19:52 +0100 | [diff] [blame] | 1090 | ha_alert("parsing [%s:%d] : %s : PROC/THREAD range and CPU sets " |
| 1091 | "must have the same size to be automatically bound\n", |
| 1092 | file, linenum, args[0]); |
| 1093 | err_code |= ERR_ALERT | ERR_FATAL; |
| 1094 | goto out; |
| 1095 | } |
| 1096 | |
Willy Tarreau | 7764a57 | 2019-07-16 15:10:34 +0200 | [diff] [blame] | 1097 | /* we now have to deal with 3 real cases : |
| 1098 | * cpu-map P-Q => mapping for whole processes, numbers P to Q |
| 1099 | * cpu-map P-Q/1 => mapping of first thread of processes P to Q |
| 1100 | * cpu-map 1/T-U => mapping of threads T to U of process 1 |
| 1101 | * Otherwise other combinations are silently ignored since nbthread |
| 1102 | * and nbproc cannot both be >1 : |
| 1103 | * cpu-map P-Q/T => mapping for thread T for processes P to Q. |
| 1104 | * Only one of T,Q may be > 1, others ignored. |
| 1105 | * cpu-map P/T-U => mapping for threads T to U of process P. Only |
| 1106 | * one of P,U may be > 1, others ignored. |
| 1107 | */ |
| 1108 | if (!thread) { |
| 1109 | /* mapping for whole processes. E.g. cpu-map 1-4 0-3 */ |
Amaury Denoyelle | 982fb53 | 2021-04-21 18:39:58 +0200 | [diff] [blame] | 1110 | ha_cpuset_assign(&cpus_copy, &cpus); |
Willy Tarreau | 81492c9 | 2019-05-03 09:41:23 +0200 | [diff] [blame] | 1111 | for (i = n = 0; i < MAX_PROCS; i++) { |
| 1112 | /* No mapping for this process */ |
| 1113 | if (!(proc & (1UL << i))) |
| 1114 | continue; |
| 1115 | |
Willy Tarreau | 36b9e22 | 2018-11-11 15:19:52 +0100 | [diff] [blame] | 1116 | if (!autoinc) |
Amaury Denoyelle | fc6ac53 | 2021-04-27 10:46:36 +0200 | [diff] [blame] | 1117 | ha_cpuset_assign(&cpu_map.proc[i], &cpus); |
Willy Tarreau | 36b9e22 | 2018-11-11 15:19:52 +0100 | [diff] [blame] | 1118 | else { |
Amaury Denoyelle | fc6ac53 | 2021-04-27 10:46:36 +0200 | [diff] [blame] | 1119 | ha_cpuset_zero(&cpu_map.proc[i]); |
Amaury Denoyelle | 982fb53 | 2021-04-21 18:39:58 +0200 | [diff] [blame] | 1120 | n = ha_cpuset_ffs(&cpus_copy) - 1; |
| 1121 | ha_cpuset_clr(&cpus_copy, n); |
Amaury Denoyelle | fc6ac53 | 2021-04-27 10:46:36 +0200 | [diff] [blame] | 1122 | ha_cpuset_set(&cpu_map.proc[i], n); |
Willy Tarreau | 36b9e22 | 2018-11-11 15:19:52 +0100 | [diff] [blame] | 1123 | } |
Willy Tarreau | 36b9e22 | 2018-11-11 15:19:52 +0100 | [diff] [blame] | 1124 | } |
Willy Tarreau | 7764a57 | 2019-07-16 15:10:34 +0200 | [diff] [blame] | 1125 | } else { |
Amaury Denoyelle | af02c57 | 2021-04-15 16:29:58 +0200 | [diff] [blame] | 1126 | /* Mapping at the thread level. |
| 1127 | * Either proc and/or thread must be 1 and only 1. All |
| 1128 | * other combinations are silently ignored. |
Willy Tarreau | 7764a57 | 2019-07-16 15:10:34 +0200 | [diff] [blame] | 1129 | */ |
| 1130 | if (thread == 0x1) { |
| 1131 | /* first thread, iterate on processes. E.g. cpu-map 1-4/1 0-3 */ |
Amaury Denoyelle | 982fb53 | 2021-04-21 18:39:58 +0200 | [diff] [blame] | 1132 | struct hap_cpuset *dst; |
| 1133 | |
| 1134 | ha_cpuset_assign(&cpus_copy, &cpus); |
Willy Tarreau | 7764a57 | 2019-07-16 15:10:34 +0200 | [diff] [blame] | 1135 | for (i = n = 0; i < MAX_PROCS; i++) { |
| 1136 | /* No mapping for this process */ |
| 1137 | if (!(proc & (1UL << i))) |
| 1138 | continue; |
Amaury Denoyelle | af02c57 | 2021-04-15 16:29:58 +0200 | [diff] [blame] | 1139 | |
Amaury Denoyelle | 982fb53 | 2021-04-21 18:39:58 +0200 | [diff] [blame] | 1140 | /* For first process, thread[0] is used. |
| 1141 | * Use proc_t1[N] for all others |
| 1142 | */ |
Amaury Denoyelle | fc6ac53 | 2021-04-27 10:46:36 +0200 | [diff] [blame] | 1143 | dst = i ? &cpu_map.proc_t1[i] : |
| 1144 | &cpu_map.thread[0]; |
Amaury Denoyelle | 982fb53 | 2021-04-21 18:39:58 +0200 | [diff] [blame] | 1145 | |
Amaury Denoyelle | af02c57 | 2021-04-15 16:29:58 +0200 | [diff] [blame] | 1146 | if (!autoinc) { |
Amaury Denoyelle | 982fb53 | 2021-04-21 18:39:58 +0200 | [diff] [blame] | 1147 | ha_cpuset_assign(dst, &cpus); |
Amaury Denoyelle | af02c57 | 2021-04-15 16:29:58 +0200 | [diff] [blame] | 1148 | } |
Willy Tarreau | 7764a57 | 2019-07-16 15:10:34 +0200 | [diff] [blame] | 1149 | else { |
Amaury Denoyelle | 982fb53 | 2021-04-21 18:39:58 +0200 | [diff] [blame] | 1150 | ha_cpuset_zero(dst); |
| 1151 | n = ha_cpuset_ffs(&cpus_copy) - 1; |
| 1152 | ha_cpuset_clr(&cpus_copy, n); |
| 1153 | ha_cpuset_set(dst, n); |
Willy Tarreau | 7764a57 | 2019-07-16 15:10:34 +0200 | [diff] [blame] | 1154 | } |
| 1155 | } |
| 1156 | } |
Willy Tarreau | 36b9e22 | 2018-11-11 15:19:52 +0100 | [diff] [blame] | 1157 | |
Willy Tarreau | 7764a57 | 2019-07-16 15:10:34 +0200 | [diff] [blame] | 1158 | if (proc == 0x1) { |
| 1159 | /* first process, iterate on threads. E.g. cpu-map 1/1-4 0-3 */ |
Amaury Denoyelle | 982fb53 | 2021-04-21 18:39:58 +0200 | [diff] [blame] | 1160 | ha_cpuset_assign(&cpus_copy, &cpus); |
Willy Tarreau | 7764a57 | 2019-07-16 15:10:34 +0200 | [diff] [blame] | 1161 | for (j = n = 0; j < MAX_THREADS; j++) { |
| 1162 | /* No mapping for this thread */ |
| 1163 | if (!(thread & (1UL << j))) |
| 1164 | continue; |
Willy Tarreau | 36b9e22 | 2018-11-11 15:19:52 +0100 | [diff] [blame] | 1165 | |
Willy Tarreau | 7764a57 | 2019-07-16 15:10:34 +0200 | [diff] [blame] | 1166 | if (!autoinc) |
Amaury Denoyelle | fc6ac53 | 2021-04-27 10:46:36 +0200 | [diff] [blame] | 1167 | ha_cpuset_assign(&cpu_map.thread[j], &cpus); |
Willy Tarreau | 7764a57 | 2019-07-16 15:10:34 +0200 | [diff] [blame] | 1168 | else { |
Amaury Denoyelle | fc6ac53 | 2021-04-27 10:46:36 +0200 | [diff] [blame] | 1169 | ha_cpuset_zero(&cpu_map.thread[j]); |
Amaury Denoyelle | 982fb53 | 2021-04-21 18:39:58 +0200 | [diff] [blame] | 1170 | n = ha_cpuset_ffs(&cpus_copy) - 1; |
| 1171 | ha_cpuset_clr(&cpus_copy, n); |
Amaury Denoyelle | fc6ac53 | 2021-04-27 10:46:36 +0200 | [diff] [blame] | 1172 | ha_cpuset_set(&cpu_map.thread[j], n); |
Willy Tarreau | 7764a57 | 2019-07-16 15:10:34 +0200 | [diff] [blame] | 1173 | } |
Willy Tarreau | 36b9e22 | 2018-11-11 15:19:52 +0100 | [diff] [blame] | 1174 | } |
| 1175 | } |
Amaury Denoyelle | a2944ec | 2021-04-15 18:07:07 +0200 | [diff] [blame] | 1176 | |
| 1177 | HA_DIAG_WARNING_COND(proc != 0x1 && thread != 0x1, |
| 1178 | "parsing [%s:%d] : cpu-map statement is considered invalid and thus ignored as it addresses multiple processes and threads at the same time. At least one of them should be 1 and only 1.", file, linenum); |
Willy Tarreau | 36b9e22 | 2018-11-11 15:19:52 +0100 | [diff] [blame] | 1179 | } |
| 1180 | #else |
| 1181 | ha_alert("parsing [%s:%d] : '%s' is not enabled, please check build options for USE_CPU_AFFINITY.\n", |
| 1182 | file, linenum, args[0]); |
| 1183 | err_code |= ERR_ALERT | ERR_FATAL; |
| 1184 | goto out; |
| 1185 | #endif /* ! USE_CPU_AFFINITY */ |
| 1186 | } |
| 1187 | else if (strcmp(args[0], "setenv") == 0 || strcmp(args[0], "presetenv") == 0) { |
| 1188 | if (alertif_too_many_args(3, file, linenum, args, &err_code)) |
| 1189 | goto out; |
| 1190 | |
| 1191 | if (*(args[2]) == 0) { |
| 1192 | ha_alert("parsing [%s:%d]: '%s' expects a name and a value.\n", file, linenum, args[0]); |
| 1193 | err_code |= ERR_ALERT | ERR_FATAL; |
| 1194 | goto out; |
| 1195 | } |
| 1196 | |
| 1197 | /* "setenv" overwrites, "presetenv" only sets if not yet set */ |
| 1198 | if (setenv(args[1], args[2], (args[0][0] == 's')) != 0) { |
| 1199 | ha_alert("parsing [%s:%d]: '%s' failed on variable '%s' : %s.\n", file, linenum, args[0], args[1], strerror(errno)); |
| 1200 | err_code |= ERR_ALERT | ERR_FATAL; |
| 1201 | goto out; |
| 1202 | } |
| 1203 | } |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 1204 | else if (strcmp(args[0], "unsetenv") == 0) { |
Willy Tarreau | 36b9e22 | 2018-11-11 15:19:52 +0100 | [diff] [blame] | 1205 | int arg; |
| 1206 | |
| 1207 | if (*(args[1]) == 0) { |
| 1208 | ha_alert("parsing [%s:%d]: '%s' expects at least one variable name.\n", file, linenum, args[0]); |
| 1209 | err_code |= ERR_ALERT | ERR_FATAL; |
| 1210 | goto out; |
| 1211 | } |
| 1212 | |
| 1213 | for (arg = 1; *args[arg]; arg++) { |
| 1214 | if (unsetenv(args[arg]) != 0) { |
| 1215 | ha_alert("parsing [%s:%d]: '%s' failed on variable '%s' : %s.\n", file, linenum, args[0], args[arg], strerror(errno)); |
| 1216 | err_code |= ERR_ALERT | ERR_FATAL; |
| 1217 | goto out; |
| 1218 | } |
| 1219 | } |
| 1220 | } |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 1221 | else if (strcmp(args[0], "resetenv") == 0) { |
Willy Tarreau | 36b9e22 | 2018-11-11 15:19:52 +0100 | [diff] [blame] | 1222 | extern char **environ; |
| 1223 | char **env = environ; |
| 1224 | |
| 1225 | /* args contain variable names to keep, one per argument */ |
| 1226 | while (*env) { |
| 1227 | int arg; |
| 1228 | |
| 1229 | /* look for current variable in among all those we want to keep */ |
| 1230 | for (arg = 1; *args[arg]; arg++) { |
| 1231 | if (strncmp(*env, args[arg], strlen(args[arg])) == 0 && |
| 1232 | (*env)[strlen(args[arg])] == '=') |
| 1233 | break; |
| 1234 | } |
| 1235 | |
| 1236 | /* delete this variable */ |
| 1237 | if (!*args[arg]) { |
| 1238 | char *delim = strchr(*env, '='); |
| 1239 | |
| 1240 | if (!delim || delim - *env >= trash.size) { |
| 1241 | ha_alert("parsing [%s:%d]: '%s' failed to unset invalid variable '%s'.\n", file, linenum, args[0], *env); |
| 1242 | err_code |= ERR_ALERT | ERR_FATAL; |
| 1243 | goto out; |
| 1244 | } |
| 1245 | |
| 1246 | memcpy(trash.area, *env, delim - *env); |
| 1247 | trash.area[delim - *env] = 0; |
| 1248 | |
| 1249 | if (unsetenv(trash.area) != 0) { |
| 1250 | ha_alert("parsing [%s:%d]: '%s' failed to unset variable '%s' : %s.\n", file, linenum, args[0], *env, strerror(errno)); |
| 1251 | err_code |= ERR_ALERT | ERR_FATAL; |
| 1252 | goto out; |
| 1253 | } |
| 1254 | } |
| 1255 | else |
| 1256 | env++; |
| 1257 | } |
| 1258 | } |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 1259 | else if (strcmp(args[0], "strict-limits") == 0) { /* "no strict-limits" or "strict-limits" */ |
William Dauchy | 0fec3ab | 2019-10-27 20:08:11 +0100 | [diff] [blame] | 1260 | if (alertif_too_many_args(0, file, linenum, args, &err_code)) |
| 1261 | goto out; |
| 1262 | if (kwm == KWM_NO) |
| 1263 | global.tune.options &= ~GTUNE_STRICT_LIMITS; |
William Dauchy | 0fec3ab | 2019-10-27 20:08:11 +0100 | [diff] [blame] | 1264 | } |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 1265 | else if (strcmp(args[0], "localpeer") == 0) { |
Dragan Dosen | 13cd54c | 2020-06-18 18:24:05 +0200 | [diff] [blame] | 1266 | if (alertif_too_many_args(1, file, linenum, args, &err_code)) |
| 1267 | goto out; |
| 1268 | |
| 1269 | if (*(args[1]) == 0) { |
| 1270 | ha_alert("parsing [%s:%d] : '%s' expects a name as an argument.\n", |
| 1271 | file, linenum, args[0]); |
| 1272 | err_code |= ERR_ALERT | ERR_FATAL; |
| 1273 | goto out; |
| 1274 | } |
| 1275 | |
| 1276 | if (global.localpeer_cmdline != 0) { |
| 1277 | ha_warning("parsing [%s:%d] : '%s' ignored since it is already set by using the '-L' " |
| 1278 | "command line argument.\n", file, linenum, args[0]); |
| 1279 | err_code |= ERR_WARN; |
| 1280 | goto out; |
| 1281 | } |
| 1282 | |
| 1283 | if (cfg_peers) { |
| 1284 | ha_warning("parsing [%s:%d] : '%s' ignored since it is used after 'peers' section.\n", |
| 1285 | file, linenum, args[0]); |
| 1286 | err_code |= ERR_WARN; |
| 1287 | goto out; |
| 1288 | } |
| 1289 | |
| 1290 | free(localpeer); |
| 1291 | if ((localpeer = strdup(args[1])) == NULL) { |
| 1292 | ha_alert("parsing [%s:%d]: cannot allocate memory for '%s'.\n", |
| 1293 | file, linenum, args[0]); |
| 1294 | err_code |= ERR_ALERT | ERR_FATAL; |
| 1295 | goto out; |
| 1296 | } |
| 1297 | setenv("HAPROXY_LOCALPEER", localpeer, 1); |
| 1298 | } |
Amaury Denoyelle | 0f50cb9 | 2021-03-26 18:50:33 +0100 | [diff] [blame] | 1299 | else if (strcmp(args[0], "numa-cpu-mapping") == 0) { |
| 1300 | global.numa_cpu_mapping = (kwm == KWM_NO) ? 0 : 1; |
| 1301 | } |
Willy Tarreau | 36b9e22 | 2018-11-11 15:19:52 +0100 | [diff] [blame] | 1302 | else { |
| 1303 | struct cfg_kw_list *kwl; |
Willy Tarreau | a0e8eb8 | 2021-03-12 09:30:14 +0100 | [diff] [blame] | 1304 | const char *best; |
Willy Tarreau | 36b9e22 | 2018-11-11 15:19:52 +0100 | [diff] [blame] | 1305 | int index; |
| 1306 | int rc; |
| 1307 | |
| 1308 | list_for_each_entry(kwl, &cfg_keywords.list, list) { |
| 1309 | for (index = 0; kwl->kw[index].kw != NULL; index++) { |
| 1310 | if (kwl->kw[index].section != CFG_GLOBAL) |
| 1311 | continue; |
| 1312 | if (strcmp(kwl->kw[index].kw, args[0]) == 0) { |
Amaury Denoyelle | d2e53cd | 2021-05-06 16:21:39 +0200 | [diff] [blame] | 1313 | if (check_kw_experimental(&kwl->kw[index], file, linenum, &errmsg)) { |
Amaury Denoyelle | 86c1d0f | 2021-05-07 15:07:21 +0200 | [diff] [blame] | 1314 | ha_alert("%s\n", errmsg); |
Amaury Denoyelle | d2e53cd | 2021-05-06 16:21:39 +0200 | [diff] [blame] | 1315 | err_code |= ERR_ALERT | ERR_FATAL; |
| 1316 | goto out; |
| 1317 | } |
| 1318 | |
Willy Tarreau | 36b9e22 | 2018-11-11 15:19:52 +0100 | [diff] [blame] | 1319 | rc = kwl->kw[index].parse(args, CFG_GLOBAL, NULL, NULL, file, linenum, &errmsg); |
| 1320 | if (rc < 0) { |
| 1321 | ha_alert("parsing [%s:%d] : %s\n", file, linenum, errmsg); |
| 1322 | err_code |= ERR_ALERT | ERR_FATAL; |
| 1323 | } |
| 1324 | else if (rc > 0) { |
| 1325 | ha_warning("parsing [%s:%d] : %s\n", file, linenum, errmsg); |
| 1326 | err_code |= ERR_WARN; |
| 1327 | goto out; |
| 1328 | } |
| 1329 | goto out; |
| 1330 | } |
| 1331 | } |
| 1332 | } |
| 1333 | |
Willy Tarreau | 101df31 | 2021-03-15 09:12:41 +0100 | [diff] [blame] | 1334 | best = cfg_find_best_match(args[0], &cfg_keywords.list, CFG_GLOBAL, common_kw_list); |
Willy Tarreau | a0e8eb8 | 2021-03-12 09:30:14 +0100 | [diff] [blame] | 1335 | if (best) |
| 1336 | ha_alert("parsing [%s:%d] : unknown keyword '%s' in '%s' section; did you mean '%s' maybe ?\n", file, linenum, args[0], cursection, best); |
| 1337 | else |
| 1338 | ha_alert("parsing [%s:%d] : unknown keyword '%s' in '%s' section\n", file, linenum, args[0], "global"); |
Willy Tarreau | 36b9e22 | 2018-11-11 15:19:52 +0100 | [diff] [blame] | 1339 | err_code |= ERR_ALERT | ERR_FATAL; |
| 1340 | } |
| 1341 | |
| 1342 | out: |
| 1343 | free(errmsg); |
| 1344 | return err_code; |
| 1345 | } |
| 1346 | |