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