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