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