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