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