blob: 62a58f6236c168920a5dd6d5691dd14fcc05c746 [file] [log] [blame]
Willy Tarreaua84d3742007-05-07 00:36:48 +02001/*
2 * ACL management functions.
3 *
Willy Tarreaud4c33c82013-01-07 21:59:07 +01004 * Copyright 2000-2013 Willy Tarreau <w@1wt.eu>
Willy Tarreaua84d3742007-05-07 00:36:48 +02005 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version
9 * 2 of the License, or (at your option) any later version.
10 *
11 */
12
Willy Tarreauae8b7962007-06-09 23:10:04 +020013#include <ctype.h>
Willy Tarreaua84d3742007-05-07 00:36:48 +020014#include <stdio.h>
15#include <string.h>
16
17#include <common/config.h>
18#include <common/mini-clist.h>
19#include <common/standard.h>
Krzysztof Piotr Oledzki8c8bd452010-01-29 19:29:32 +010020#include <common/uri_auth.h>
Willy Tarreaua84d3742007-05-07 00:36:48 +020021
Willy Tarreau2b5285d2010-05-09 23:45:24 +020022#include <types/global.h>
23
Willy Tarreaua84d3742007-05-07 00:36:48 +020024#include <proto/acl.h>
Willy Tarreau34db1082012-04-19 17:16:54 +020025#include <proto/arg.h>
Krzysztof Piotr Oledzkif9423ae2010-01-29 19:26:18 +010026#include <proto/auth.h>
Willy Tarreauc7e42382012-08-24 19:22:53 +020027#include <proto/channel.h>
Willy Tarreau404e8ab2009-07-26 19:40:40 +020028#include <proto/log.h>
Thierry FOURNIERed66c292013-11-28 11:05:19 +010029#include <proto/pattern.h>
Willy Tarreau0b1cd942010-05-16 22:18:27 +020030#include <proto/proxy.h>
Willy Tarreau8ed669b2013-01-11 15:49:37 +010031#include <proto/sample.h>
Willy Tarreaud28c3532012-04-19 19:28:33 +020032#include <proto/stick_table.h>
Willy Tarreaua84d3742007-05-07 00:36:48 +020033
Willy Tarreauc4262962010-05-10 23:42:40 +020034#include <ebsttree.h>
35
Willy Tarreaua84d3742007-05-07 00:36:48 +020036/* List head of all known ACL keywords */
37static struct acl_kw_list acl_keywords = {
38 .list = LIST_HEAD_INIT(acl_keywords.list)
39};
40
Willy Tarreau0cba6072013-11-28 22:21:02 +010041/* input values are 0 or 3, output is the same */
42static inline enum acl_test_res pat2acl(enum pat_match_res res)
43{
44 return (enum acl_test_res)res;
45}
46
Willy Tarreaua5909832007-06-17 20:40:25 +020047/*
Willy Tarreaua84d3742007-05-07 00:36:48 +020048 * Registers the ACL keyword list <kwl> as a list of valid keywords for next
49 * parsing sessions.
50 */
51void acl_register_keywords(struct acl_kw_list *kwl)
52{
53 LIST_ADDQ(&acl_keywords.list, &kwl->list);
54}
55
56/*
57 * Unregisters the ACL keyword list <kwl> from the list of valid keywords.
58 */
59void acl_unregister_keywords(struct acl_kw_list *kwl)
60{
61 LIST_DEL(&kwl->list);
62 LIST_INIT(&kwl->list);
63}
64
65/* Return a pointer to the ACL <name> within the list starting at <head>, or
66 * NULL if not found.
67 */
68struct acl *find_acl_by_name(const char *name, struct list *head)
69{
70 struct acl *acl;
71 list_for_each_entry(acl, head, list) {
72 if (strcmp(acl->name, name) == 0)
73 return acl;
74 }
75 return NULL;
76}
77
78/* Return a pointer to the ACL keyword <kw>, or NULL if not found. Note that if
79 * <kw> contains an opening parenthesis, only the left part of it is checked.
80 */
81struct acl_keyword *find_acl_kw(const char *kw)
82{
83 int index;
84 const char *kwend;
85 struct acl_kw_list *kwl;
86
87 kwend = strchr(kw, '(');
88 if (!kwend)
89 kwend = kw + strlen(kw);
90
91 list_for_each_entry(kwl, &acl_keywords.list, list) {
92 for (index = 0; kwl->kw[index].kw != NULL; index++) {
93 if ((strncmp(kwl->kw[index].kw, kw, kwend - kw) == 0) &&
94 kwl->kw[index].kw[kwend-kw] == 0)
95 return &kwl->kw[index];
96 }
97 }
98 return NULL;
99}
100
Willy Tarreaua84d3742007-05-07 00:36:48 +0200101static struct acl_expr *prune_acl_expr(struct acl_expr *expr)
102{
Willy Tarreau34db1082012-04-19 17:16:54 +0200103 struct arg *arg;
104
Thierry FOURNIERa65b3432013-11-28 18:22:00 +0100105 pattern_prune_expr(&expr->pat);
Willy Tarreau34db1082012-04-19 17:16:54 +0200106
Thierry FOURNIER348971e2013-11-21 10:50:10 +0100107 for (arg = expr->smp->arg_p; arg; arg++) {
Willy Tarreau34db1082012-04-19 17:16:54 +0200108 if (arg->type == ARGT_STOP)
109 break;
Willy Tarreau496aa012012-06-01 10:38:29 +0200110 if (arg->type == ARGT_STR || arg->unresolved) {
Willy Tarreau34db1082012-04-19 17:16:54 +0200111 free(arg->data.str.str);
112 arg->data.str.str = NULL;
Willy Tarreau496aa012012-06-01 10:38:29 +0200113 arg->unresolved = 0;
Willy Tarreau34db1082012-04-19 17:16:54 +0200114 }
Willy Tarreau34db1082012-04-19 17:16:54 +0200115 }
116
Thierry FOURNIER348971e2013-11-21 10:50:10 +0100117 if (expr->smp->arg_p != empty_arg_list)
118 free(expr->smp->arg_p);
Willy Tarreaua84d3742007-05-07 00:36:48 +0200119 return expr;
120}
121
Willy Tarreaub7451bb2012-04-27 12:38:15 +0200122/* Parse an ACL expression starting at <args>[0], and return it. If <err> is
123 * not NULL, it will be filled with a pointer to an error message in case of
Willy Tarreaua4312fa2013-04-02 16:34:32 +0200124 * error. This pointer must be freeable or NULL. <al> is an arg_list serving
125 * as a list head to report missing dependencies.
Willy Tarreaub7451bb2012-04-27 12:38:15 +0200126 *
Willy Tarreaua84d3742007-05-07 00:36:48 +0200127 * Right now, the only accepted syntax is :
128 * <subject> [<value>...]
129 */
Willy Tarreaua4312fa2013-04-02 16:34:32 +0200130struct acl_expr *parse_acl_expr(const char **args, char **err, struct arg_list *al)
Willy Tarreaua84d3742007-05-07 00:36:48 +0200131{
132 __label__ out_return, out_free_expr, out_free_pattern;
133 struct acl_expr *expr;
134 struct acl_keyword *aclkw;
Thierry FOURNIERa65b3432013-11-28 18:22:00 +0100135 struct pattern *pattern;
Willy Tarreauc8d7c962007-06-17 08:20:33 +0200136 int opaque, patflags;
Willy Tarreaua84d3742007-05-07 00:36:48 +0200137 const char *arg;
Thierry FOURNIER348971e2013-11-21 10:50:10 +0100138 struct sample_expr *smp = NULL;
139 const char *p;
140 int idx = 0;
141 char *ckw = NULL;
142 const char *begw;
143 const char *endw;
144 unsigned long prev_type;
145 int cur_type;
Willy Tarreaua84d3742007-05-07 00:36:48 +0200146
Willy Tarreaubef91e72013-03-31 23:14:46 +0200147 /* First, we lookd for an ACL keyword. And if we don't find one, then
148 * we look for a sample fetch keyword.
149 */
Willy Tarreaua84d3742007-05-07 00:36:48 +0200150 aclkw = find_acl_kw(args[0]);
Willy Tarreaub7451bb2012-04-27 12:38:15 +0200151 if (!aclkw || !aclkw->parse) {
Willy Tarreaubef91e72013-03-31 23:14:46 +0200152
Thierry FOURNIER348971e2013-11-21 10:50:10 +0100153 smp = sample_parse_expr((char **)args, &idx, trash.str, trash.size, al);
Willy Tarreaubef91e72013-03-31 23:14:46 +0200154
155 if (!smp) {
Willy Tarreau3d536ac2013-12-06 16:02:46 +0100156 memprintf(err, "%s in sample expression '%s'", trash.str, *args);
Willy Tarreaubef91e72013-03-31 23:14:46 +0200157 goto out_return;
158 }
Willy Tarreaub7451bb2012-04-27 12:38:15 +0200159 }
Willy Tarreaua84d3742007-05-07 00:36:48 +0200160
161 expr = (struct acl_expr *)calloc(1, sizeof(*expr));
Willy Tarreaub7451bb2012-04-27 12:38:15 +0200162 if (!expr) {
Willy Tarreaueb6cead2012-09-20 19:43:14 +0200163 memprintf(err, "out of memory when parsing ACL expression");
Willy Tarreaua84d3742007-05-07 00:36:48 +0200164 goto out_return;
Willy Tarreaub7451bb2012-04-27 12:38:15 +0200165 }
Willy Tarreaua84d3742007-05-07 00:36:48 +0200166
Thierry FOURNIERa65b3432013-11-28 18:22:00 +0100167 pattern_init_expr(&expr->pat);
Thierry FOURNIERd163e1c2013-11-28 11:41:23 +0100168
Thierry FOURNIER348971e2013-11-21 10:50:10 +0100169 expr->kw = aclkw ? aclkw->kw : smp->fetch->kw;
Thierry FOURNIERd163e1c2013-11-28 11:41:23 +0100170 expr->pat.parse = aclkw ? aclkw->parse : NULL;
171 expr->pat.match = aclkw ? aclkw->match : NULL;
Thierry FOURNIER348971e2013-11-21 10:50:10 +0100172 expr->smp = aclkw ? NULL : smp;
Willy Tarreaua84d3742007-05-07 00:36:48 +0200173
Thierry FOURNIERd163e1c2013-11-28 11:41:23 +0100174 if (!expr->pat.parse) {
Willy Tarreau9987ea92013-06-11 21:09:06 +0200175 /* some types can be automatically converted */
176
Thierry FOURNIER348971e2013-11-21 10:50:10 +0100177 switch (expr->smp ? expr->smp->fetch->out_type : aclkw->smp->out_type) {
Willy Tarreau9987ea92013-06-11 21:09:06 +0200178 case SMP_T_BOOL:
Thierry FOURNIERa65b3432013-11-28 18:22:00 +0100179 expr->pat.parse = pat_parse_fcts[PAT_MATCH_BOOL];
180 expr->pat.match = pat_match_fcts[PAT_MATCH_BOOL];
Willy Tarreau9987ea92013-06-11 21:09:06 +0200181 break;
182 case SMP_T_SINT:
183 case SMP_T_UINT:
Thierry FOURNIERa65b3432013-11-28 18:22:00 +0100184 expr->pat.parse = pat_parse_fcts[PAT_MATCH_INT];
185 expr->pat.match = pat_match_fcts[PAT_MATCH_INT];
Willy Tarreau9987ea92013-06-11 21:09:06 +0200186 break;
187 case SMP_T_IPV4:
188 case SMP_T_IPV6:
Thierry FOURNIERa65b3432013-11-28 18:22:00 +0100189 expr->pat.parse = pat_parse_fcts[PAT_MATCH_IP];
190 expr->pat.match = pat_match_fcts[PAT_MATCH_IP];
Willy Tarreau9987ea92013-06-11 21:09:06 +0200191 break;
192 }
193 }
194
Thierry FOURNIER348971e2013-11-21 10:50:10 +0100195 /* now parse the rest of acl only if "find_acl_kw" match */
196 if (aclkw) {
Willy Tarreau34db1082012-04-19 17:16:54 +0200197
Thierry FOURNIER348971e2013-11-21 10:50:10 +0100198 /* build new sample expression */
199 expr->smp = calloc(1, sizeof(struct sample_expr));
200 if (!expr->smp) {
201 memprintf(err, "out of memory when parsing ACL expression");
202 goto out_return;
203 }
204 LIST_INIT(&(expr->smp->conv_exprs));
205 expr->smp->fetch = aclkw->smp;
206 expr->smp->arg_p = empty_arg_list;
Willy Tarreau34db1082012-04-19 17:16:54 +0200207
Thierry FOURNIER348971e2013-11-21 10:50:10 +0100208 /* look for the begining of the subject arguments */
209 p = strchr(args[0], ',');
210 arg = strchr(args[0], '(');
211 if (p && arg && p < arg)
212 arg = NULL;
213
214 if (expr->smp->fetch->arg_mask) {
215 int nbargs = 0;
216 char *end;
217
218 if (arg != NULL) {
219 /* there are 0 or more arguments in the form "subject(arg[,arg]*)" */
220 arg++;
221 end = strchr(arg, ')');
222 if (!end) {
223 memprintf(err, "missing closing ')' after arguments to ACL keyword '%s'", expr->kw);
224 goto out_free_expr;
225 }
226
227 /* Parse the arguments. Note that currently we have no way to
228 * report parsing errors, hence the NULL in the error pointers.
229 * An error is also reported if some mandatory arguments are
230 * missing. We prepare the args list to report unresolved
231 * dependencies.
232 */
233 al->ctx = ARGC_ACL;
234 al->kw = expr->kw;
235 al->conv = NULL;
236 nbargs = make_arg_list(arg, end - arg, expr->smp->fetch->arg_mask, &expr->smp->arg_p,
237 err, NULL, NULL, al);
238 if (nbargs < 0) {
239 /* note that make_arg_list will have set <err> here */
240 memprintf(err, "in argument to '%s', %s", expr->kw, *err);
241 goto out_free_expr;
242 }
243
244 if (!expr->smp->arg_p)
245 expr->smp->arg_p = empty_arg_list;
246
247 if (expr->smp->fetch->val_args && !expr->smp->fetch->val_args(expr->smp->arg_p, err)) {
248 /* invalid keyword argument, error must have been
249 * set by val_args().
250 */
251 memprintf(err, "in argument to '%s', %s", expr->kw, *err);
252 goto out_free_expr;
253 }
Thierry FOURNIERab92cf32013-12-06 10:34:35 +0100254 arg = end;
Willy Tarreaub7451bb2012-04-27 12:38:15 +0200255 }
Thierry FOURNIER348971e2013-11-21 10:50:10 +0100256 else if (ARGM(expr->smp->fetch->arg_mask) == 1) {
257 int type = (expr->smp->fetch->arg_mask >> 4) & 15;
Willy Tarreauae52f062012-04-26 12:13:35 +0200258
Thierry FOURNIER348971e2013-11-21 10:50:10 +0100259 /* If a proxy is noted as a mandatory argument, we'll fake
260 * an empty one so that acl_find_targets() resolves it as
261 * the current one later.
262 */
263 if (type != ARGT_FE && type != ARGT_BE && type != ARGT_TAB) {
264 memprintf(err, "ACL keyword '%s' expects %d arguments", expr->kw, ARGM(expr->smp->fetch->arg_mask));
265 goto out_free_expr;
266 }
Willy Tarreau2e845be2012-10-19 19:49:09 +0200267
Thierry FOURNIER348971e2013-11-21 10:50:10 +0100268 /* Build an arg list containing the type as an empty string
269 * and the usual STOP.
Willy Tarreaub7451bb2012-04-27 12:38:15 +0200270 */
Thierry FOURNIER348971e2013-11-21 10:50:10 +0100271 expr->smp->arg_p = calloc(2, sizeof(*expr->smp->arg_p));
272 expr->smp->arg_p[0].type = type;
273 expr->smp->arg_p[0].unresolved = 1;
274 expr->smp->arg_p[0].data.str.str = strdup("");
275 expr->smp->arg_p[0].data.str.size = 1;
276 expr->smp->arg_p[0].data.str.len = 0;
277
278 al->ctx = ARGC_ACL;
279 al->kw = expr->kw;
280 al->conv = NULL;
281 arg_list_add(al, &expr->smp->arg_p[0], 0);
282
283 expr->smp->arg_p[1].type = ARGT_STOP;
284 }
285 else if (ARGM(expr->smp->fetch->arg_mask)) {
286 /* there were some mandatory arguments */
287 memprintf(err, "ACL keyword '%s' expects %d arguments", expr->kw, ARGM(expr->smp->fetch->arg_mask));
Willy Tarreaub7451bb2012-04-27 12:38:15 +0200288 goto out_free_expr;
289 }
Willy Tarreau61612d42012-04-19 18:42:05 +0200290 }
Thierry FOURNIER348971e2013-11-21 10:50:10 +0100291 else {
292 if (arg ) {
293 /* no argument expected */
294 memprintf(err, "ACL keyword '%s' takes no argument", expr->kw);
Willy Tarreaufc2c1fd2012-04-19 23:35:54 +0200295 goto out_free_expr;
Willy Tarreaub7451bb2012-04-27 12:38:15 +0200296 }
Thierry FOURNIER348971e2013-11-21 10:50:10 +0100297 }
Willy Tarreau9ca69362013-10-22 19:10:06 +0200298
Thierry FOURNIER348971e2013-11-21 10:50:10 +0100299 /* Now process the converters if any. We have two supported syntaxes
300 * for the converters, which can be combined :
301 * - comma-delimited list of converters just after the keyword and args ;
302 * - one converter per keyword
303 * The combination allows to have each keyword being a comma-delimited
304 * series of converters.
305 *
306 * We want to process the former first, then the latter. For this we start
307 * from the beginning of the supposed place in the exiting conv chain, which
308 * starts at the last comma (endt).
309 */
Willy Tarreauf75d0082013-04-07 21:20:44 +0200310
Thierry FOURNIER348971e2013-11-21 10:50:10 +0100311 /* look for the begining of the converters list */
Thierry FOURNIERab92cf32013-12-06 10:34:35 +0100312 if (arg)
313 arg = strchr(arg, ',');
314 else
315 arg = strchr(args[0], ',');
Willy Tarreau61612d42012-04-19 18:42:05 +0200316 if (arg) {
Thierry FOURNIER348971e2013-11-21 10:50:10 +0100317 prev_type = expr->smp->fetch->out_type;
318 while (1) {
319 struct sample_conv *conv;
320 struct sample_conv_expr *conv_expr;
321
322 if (*arg == ')') /* skip last closing parenthesis */
323 arg++;
324
325 if (*arg && *arg != ',') {
326 if (ckw)
327 memprintf(err, "ACL keyword '%s' : missing comma after conv keyword '%s'.",
328 expr->kw, ckw);
329 else
330 memprintf(err, "ACL keyword '%s' : missing comma after fetch keyword.",
331 expr->kw);
332 goto out_free_expr;
333 }
334
335 while (*arg == ',') /* then trailing commas */
336 arg++;
337
338 begw = arg; /* start of conv keyword */
339
340 if (!*begw)
341 /* none ? end of converters */
342 break;
343
344 for (endw = begw; *endw && *endw != '(' && *endw != ','; endw++);
345
346 free(ckw);
347 ckw = my_strndup(begw, endw - begw);
348
349 conv = find_sample_conv(begw, endw - begw);
350 if (!conv) {
351 /* Unknown converter method */
352 memprintf(err, "ACL keyword '%s' : unknown conv method '%s'.",
353 expr->kw, ckw);
354 goto out_free_expr;
355 }
356
357 arg = endw;
358 if (*arg == '(') {
359 /* look for the end of this term */
360 while (*arg && *arg != ')')
361 arg++;
362 if (*arg != ')') {
363 memprintf(err, "ACL keyword '%s' : syntax error: missing ')' after conv keyword '%s'.",
364 expr->kw, ckw);
365 goto out_free_expr;
366 }
367 }
368
369 if (conv->in_type >= SMP_TYPES || conv->out_type >= SMP_TYPES) {
370 memprintf(err, "ACL keyword '%s' : returns type of conv method '%s' is unknown.",
371 expr->kw, ckw);
372 goto out_free_expr;
373 }
374
375 /* If impossible type conversion */
376 if (!sample_casts[prev_type][conv->in_type]) {
377 memprintf(err, "ACL keyword '%s' : conv method '%s' cannot be applied.",
378 expr->kw, ckw);
379 goto out_free_expr;
380 }
381
382 prev_type = conv->out_type;
383 conv_expr = calloc(1, sizeof(struct sample_conv_expr));
384 if (!conv_expr)
385 goto out_free_expr;
386
387 LIST_ADDQ(&(expr->smp->conv_exprs), &(conv_expr->list));
388 conv_expr->conv = conv;
389
390 if (arg != endw) {
391 char *err_msg = NULL;
392 int err_arg;
393
394 if (!conv->arg_mask) {
395 memprintf(err, "ACL keyword '%s' : conv method '%s' does not support any args.",
396 expr->kw, ckw);
397 goto out_free_expr;
398 }
399
400 al->kw = expr->smp->fetch->kw;
401 al->conv = conv_expr->conv->kw;
402 if (make_arg_list(endw + 1, arg - endw - 1, conv->arg_mask, &conv_expr->arg_p, &err_msg, NULL, &err_arg, al) < 0) {
403 memprintf(err, "ACL keyword '%s' : invalid arg %d in conv method '%s' : %s.",
404 expr->kw, err_arg+1, ckw, err_msg);
405 free(err_msg);
406 goto out_free_expr;
407 }
408
409 if (!conv_expr->arg_p)
410 conv_expr->arg_p = empty_arg_list;
411
Thierry FOURNIER9c1d67e2013-11-21 13:37:41 +0100412 if (conv->val_args && !conv->val_args(conv_expr->arg_p, conv, &err_msg)) {
Thierry FOURNIER348971e2013-11-21 10:50:10 +0100413 memprintf(err, "ACL keyword '%s' : invalid args in conv method '%s' : %s.",
414 expr->kw, ckw, err_msg);
415 free(err_msg);
416 goto out_free_expr;
417 }
418 }
419 else if (ARGM(conv->arg_mask)) {
420 memprintf(err, "ACL keyword '%s' : missing args for conv method '%s'.",
421 expr->kw, ckw);
422 goto out_free_expr;
423 }
424 }
Willy Tarreau61612d42012-04-19 18:42:05 +0200425 }
Willy Tarreaua84d3742007-05-07 00:36:48 +0200426 }
427
Willy Tarreau3c3dfd52013-11-04 18:09:12 +0100428 /* Additional check to protect against common mistakes */
Thierry FOURNIER348971e2013-11-21 10:50:10 +0100429 cur_type = smp_expr_output_type(expr->smp);
Thierry FOURNIERd163e1c2013-11-28 11:41:23 +0100430 if (expr->pat.parse && cur_type != SMP_T_BOOL && !*args[1]) {
Willy Tarreau3c3dfd52013-11-04 18:09:12 +0100431 Warning("parsing acl keyword '%s' :\n"
432 " no pattern to match against were provided, so this ACL will never match.\n"
433 " If this is what you intended, please add '--' to get rid of this warning.\n"
434 " If you intended to match only for existence, please use '-m found'.\n"
435 " If you wanted to force an int to match as a bool, please use '-m bool'.\n"
436 "\n",
437 args[0]);
438 }
439
Willy Tarreaua84d3742007-05-07 00:36:48 +0200440 args++;
Willy Tarreauc8d7c962007-06-17 08:20:33 +0200441
442 /* check for options before patterns. Supported options are :
443 * -i : ignore case for all patterns by default
444 * -f : read patterns from those files
Willy Tarreau5adeda12013-03-31 22:13:34 +0200445 * -m : force matching method (must be used before -f)
Willy Tarreauc8d7c962007-06-17 08:20:33 +0200446 * -- : everything after this is not an option
447 */
448 patflags = 0;
449 while (**args == '-') {
450 if ((*args)[1] == 'i')
Thierry FOURNIERa65b3432013-11-28 18:22:00 +0100451 patflags |= PAT_F_IGNORE_CASE;
Willy Tarreau2b5285d2010-05-09 23:45:24 +0200452 else if ((*args)[1] == 'f') {
Thierry FOURNIERd163e1c2013-11-28 11:41:23 +0100453 if (!expr->pat.parse) {
Willy Tarreau9987ea92013-06-11 21:09:06 +0200454 memprintf(err, "matching method must be specified first (using '-m') when using a sample fetch of this type ('%s')", expr->kw);
Willy Tarreaubef91e72013-03-31 23:14:46 +0200455 goto out_free_expr;
456 }
457
Thierry FOURNIERa65b3432013-11-28 18:22:00 +0100458 if (!pattern_read_from_file(&expr->pat, args[1], patflags | PAT_F_FROM_FILE, err))
Willy Tarreau2b5285d2010-05-09 23:45:24 +0200459 goto out_free_expr;
Willy Tarreau5adeda12013-03-31 22:13:34 +0200460 args++;
461 }
462 else if ((*args)[1] == 'm') {
463 int idx;
464
Thierry FOURNIERd163e1c2013-11-28 11:41:23 +0100465 if (!LIST_ISEMPTY(&expr->pat.patterns) || !eb_is_empty(&expr->pat.pattern_tree)) {
Willy Tarreau5adeda12013-03-31 22:13:34 +0200466 memprintf(err, "'-m' must only be specified before patterns and files in parsing ACL expression");
467 goto out_free_expr;
468 }
469
Willy Tarreau6f8fe312013-11-28 22:24:25 +0100470 idx = pat_find_match_name(args[1]);
Willy Tarreau5adeda12013-03-31 22:13:34 +0200471 if (idx < 0) {
472 memprintf(err, "unknown matching method '%s' when parsing ACL expression", args[1]);
473 goto out_free_expr;
474 }
475
476 /* Note: -m found is always valid, bool/int are compatible, str/bin/reg/len are compatible */
Thierry FOURNIERa65b3432013-11-28 18:22:00 +0100477 if (idx == PAT_MATCH_FOUND || /* -m found */
478 ((idx == PAT_MATCH_BOOL || idx == PAT_MATCH_INT) && /* -m bool/int */
Thierry FOURNIER348971e2013-11-21 10:50:10 +0100479 (cur_type == SMP_T_BOOL ||
480 cur_type == SMP_T_UINT ||
481 cur_type == SMP_T_SINT)) ||
Thierry FOURNIERa65b3432013-11-28 18:22:00 +0100482 (idx == PAT_MATCH_IP && /* -m ip */
Thierry FOURNIER348971e2013-11-21 10:50:10 +0100483 (cur_type == SMP_T_IPV4 ||
484 cur_type == SMP_T_IPV6)) ||
Thierry FOURNIERa65b3432013-11-28 18:22:00 +0100485 ((idx == PAT_MATCH_BIN || idx == PAT_MATCH_LEN || idx == PAT_MATCH_STR ||
486 idx == PAT_MATCH_BEG || idx == PAT_MATCH_SUB || idx == PAT_MATCH_DIR ||
487 idx == PAT_MATCH_DOM || idx == PAT_MATCH_END || idx == PAT_MATCH_REG) && /* strings */
Thierry FOURNIER348971e2013-11-21 10:50:10 +0100488 (cur_type == SMP_T_STR ||
489 cur_type == SMP_T_BIN ||
490 cur_type == SMP_T_CSTR ||
491 cur_type == SMP_T_CBIN))) {
Thierry FOURNIERa65b3432013-11-28 18:22:00 +0100492 expr->pat.parse = pat_parse_fcts[idx];
493 expr->pat.match = pat_match_fcts[idx];
Willy Tarreau5adeda12013-03-31 22:13:34 +0200494 }
495 else {
Willy Tarreau93fddf12013-03-31 22:59:32 +0200496 memprintf(err, "matching method '%s' cannot be used with fetch keyword '%s'", args[1], expr->kw);
Willy Tarreau5adeda12013-03-31 22:13:34 +0200497 goto out_free_expr;
498 }
Willy Tarreau2b5285d2010-05-09 23:45:24 +0200499 args++;
500 }
Willy Tarreauc8d7c962007-06-17 08:20:33 +0200501 else if ((*args)[1] == '-') {
502 args++;
503 break;
504 }
505 else
506 break;
507 args++;
508 }
509
Thierry FOURNIERd163e1c2013-11-28 11:41:23 +0100510 if (!expr->pat.parse) {
Willy Tarreau9987ea92013-06-11 21:09:06 +0200511 memprintf(err, "matching method must be specified first (using '-m') when using a sample fetch of this type ('%s')", expr->kw);
Willy Tarreaubef91e72013-03-31 23:14:46 +0200512 goto out_free_expr;
513 }
514
Willy Tarreauc8d7c962007-06-17 08:20:33 +0200515 /* now parse all patterns */
Willy Tarreauae8b7962007-06-09 23:10:04 +0200516 opaque = 0;
Willy Tarreaua84d3742007-05-07 00:36:48 +0200517 while (**args) {
Willy Tarreauae8b7962007-06-09 23:10:04 +0200518 int ret;
Thierry FOURNIERa65b3432013-11-28 18:22:00 +0100519 pattern = (struct pattern *)calloc(1, sizeof(*pattern));
Willy Tarreaub7451bb2012-04-27 12:38:15 +0200520 if (!pattern) {
Willy Tarreaueb6cead2012-09-20 19:43:14 +0200521 memprintf(err, "out of memory when parsing ACL pattern");
Willy Tarreaua84d3742007-05-07 00:36:48 +0200522 goto out_free_expr;
Willy Tarreaub7451bb2012-04-27 12:38:15 +0200523 }
Willy Tarreauc8d7c962007-06-17 08:20:33 +0200524 pattern->flags = patflags;
525
Willy Tarreauc92ddbc2012-04-27 22:10:57 +0200526 pattern->type = SMP_TYPES; /* unspecified type */
Thierry FOURNIERd163e1c2013-11-28 11:41:23 +0100527 ret = expr->pat.parse(args, pattern, NULL, &opaque, err);
Willy Tarreau7dcb6482012-04-27 17:52:25 +0200528 if (!ret)
Willy Tarreaua84d3742007-05-07 00:36:48 +0200529 goto out_free_pattern;
Willy Tarreau7dcb6482012-04-27 17:52:25 +0200530
Thierry FOURNIERd163e1c2013-11-28 11:41:23 +0100531 LIST_ADDQ(&expr->pat.patterns, &pattern->list);
Willy Tarreauae8b7962007-06-09 23:10:04 +0200532 args += ret;
Willy Tarreaua84d3742007-05-07 00:36:48 +0200533 }
534
535 return expr;
536
537 out_free_pattern:
Thierry FOURNIERa65b3432013-11-28 18:22:00 +0100538 pattern_free(pattern);
Willy Tarreaua84d3742007-05-07 00:36:48 +0200539 out_free_expr:
540 prune_acl_expr(expr);
541 free(expr);
Thierry FOURNIER348971e2013-11-21 10:50:10 +0100542 free(ckw);
Willy Tarreaua84d3742007-05-07 00:36:48 +0200543 out_return:
544 return NULL;
545}
546
Krzysztof Piotr Oledzkia643baf2008-05-29 23:53:44 +0200547/* Purge everything in the acl <acl>, then return <acl>. */
548struct acl *prune_acl(struct acl *acl) {
549
550 struct acl_expr *expr, *exprb;
551
552 free(acl->name);
553
554 list_for_each_entry_safe(expr, exprb, &acl->expr, list) {
555 LIST_DEL(&expr->list);
556 prune_acl_expr(expr);
557 free(expr);
558 }
559
560 return acl;
561}
562
Willy Tarreaua84d3742007-05-07 00:36:48 +0200563/* Parse an ACL with the name starting at <args>[0], and with a list of already
564 * known ACLs in <acl>. If the ACL was not in the list, it will be added.
Willy Tarreau2a56c5e2010-03-15 16:13:29 +0100565 * A pointer to that ACL is returned. If the ACL has an empty name, then it's
Willy Tarreaub7451bb2012-04-27 12:38:15 +0200566 * an anonymous one and it won't be merged with any other one. If <err> is not
567 * NULL, it will be filled with an appropriate error. This pointer must be
Willy Tarreaua4312fa2013-04-02 16:34:32 +0200568 * freeable or NULL. <al> is the arg_list serving as a head for unresolved
569 * dependencies.
Willy Tarreaua84d3742007-05-07 00:36:48 +0200570 *
571 * args syntax: <aclname> <acl_expr>
572 */
Willy Tarreaua4312fa2013-04-02 16:34:32 +0200573struct acl *parse_acl(const char **args, struct list *known_acl, char **err, struct arg_list *al)
Willy Tarreaua84d3742007-05-07 00:36:48 +0200574{
575 __label__ out_return, out_free_acl_expr, out_free_name;
576 struct acl *cur_acl;
577 struct acl_expr *acl_expr;
578 char *name;
Willy Tarreaub7451bb2012-04-27 12:38:15 +0200579 const char *pos;
Willy Tarreaua84d3742007-05-07 00:36:48 +0200580
Willy Tarreaub7451bb2012-04-27 12:38:15 +0200581 if (**args && (pos = invalid_char(*args))) {
Willy Tarreaueb6cead2012-09-20 19:43:14 +0200582 memprintf(err, "invalid character in ACL name : '%c'", *pos);
Willy Tarreau2e74c3f2007-12-02 18:45:09 +0100583 goto out_return;
Willy Tarreaub7451bb2012-04-27 12:38:15 +0200584 }
Willy Tarreau2e74c3f2007-12-02 18:45:09 +0100585
Willy Tarreaua4312fa2013-04-02 16:34:32 +0200586 acl_expr = parse_acl_expr(args + 1, err, al);
Willy Tarreaub7451bb2012-04-27 12:38:15 +0200587 if (!acl_expr) {
588 /* parse_acl_expr will have filled <err> here */
Willy Tarreaua84d3742007-05-07 00:36:48 +0200589 goto out_return;
Willy Tarreaub7451bb2012-04-27 12:38:15 +0200590 }
Willy Tarreaua84d3742007-05-07 00:36:48 +0200591
Willy Tarreau404e8ab2009-07-26 19:40:40 +0200592 /* Check for args beginning with an opening parenthesis just after the
593 * subject, as this is almost certainly a typo. Right now we can only
594 * emit a warning, so let's do so.
595 */
Krzysztof Piotr Oledzki4cdd8312009-10-05 00:23:35 +0200596 if (!strchr(args[1], '(') && *args[2] == '(')
Willy Tarreau404e8ab2009-07-26 19:40:40 +0200597 Warning("parsing acl '%s' :\n"
598 " matching '%s' for pattern '%s' is likely a mistake and probably\n"
599 " not what you want. Maybe you need to remove the extraneous space before '('.\n"
600 " If you are really sure this is not an error, please insert '--' between the\n"
601 " match and the pattern to make this warning message disappear.\n",
602 args[0], args[1], args[2]);
603
Willy Tarreau2a56c5e2010-03-15 16:13:29 +0100604 if (*args[0])
605 cur_acl = find_acl_by_name(args[0], known_acl);
606 else
607 cur_acl = NULL;
608
Willy Tarreaua84d3742007-05-07 00:36:48 +0200609 if (!cur_acl) {
610 name = strdup(args[0]);
Willy Tarreaub7451bb2012-04-27 12:38:15 +0200611 if (!name) {
Willy Tarreaueb6cead2012-09-20 19:43:14 +0200612 memprintf(err, "out of memory when parsing ACL");
Willy Tarreaua84d3742007-05-07 00:36:48 +0200613 goto out_free_acl_expr;
Willy Tarreaub7451bb2012-04-27 12:38:15 +0200614 }
Willy Tarreaua84d3742007-05-07 00:36:48 +0200615 cur_acl = (struct acl *)calloc(1, sizeof(*cur_acl));
Willy Tarreaub7451bb2012-04-27 12:38:15 +0200616 if (cur_acl == NULL) {
Willy Tarreaueb6cead2012-09-20 19:43:14 +0200617 memprintf(err, "out of memory when parsing ACL");
Willy Tarreaua84d3742007-05-07 00:36:48 +0200618 goto out_free_name;
Willy Tarreaub7451bb2012-04-27 12:38:15 +0200619 }
Willy Tarreaua84d3742007-05-07 00:36:48 +0200620
621 LIST_INIT(&cur_acl->expr);
622 LIST_ADDQ(known_acl, &cur_acl->list);
623 cur_acl->name = name;
624 }
625
Willy Tarreaua91d0a52013-03-25 08:12:18 +0100626 /* We want to know what features the ACL needs (typically HTTP parsing),
627 * and where it may be used. If an ACL relies on multiple matches, it is
628 * OK if at least one of them may match in the context where it is used.
629 */
Thierry FOURNIER348971e2013-11-21 10:50:10 +0100630 cur_acl->use |= acl_expr->smp->fetch->use;
631 cur_acl->val |= acl_expr->smp->fetch->val;
Willy Tarreaua84d3742007-05-07 00:36:48 +0200632 LIST_ADDQ(&cur_acl->expr, &acl_expr->list);
633 return cur_acl;
634
635 out_free_name:
636 free(name);
637 out_free_acl_expr:
638 prune_acl_expr(acl_expr);
639 free(acl_expr);
640 out_return:
641 return NULL;
642}
643
Willy Tarreau16fbe822007-06-17 11:54:31 +0200644/* Some useful ACLs provided by default. Only those used are allocated. */
645
646const struct {
647 const char *name;
648 const char *expr[4]; /* put enough for longest expression */
649} default_acl_list[] = {
Willy Tarreau58393e12008-07-20 10:39:22 +0200650 { .name = "TRUE", .expr = {"always_true",""}},
651 { .name = "FALSE", .expr = {"always_false",""}},
Willy Tarreau16fbe822007-06-17 11:54:31 +0200652 { .name = "LOCALHOST", .expr = {"src","127.0.0.1/8",""}},
Willy Tarreau2492d5b2009-07-11 00:06:00 +0200653 { .name = "HTTP", .expr = {"req_proto_http",""}},
Willy Tarreau16fbe822007-06-17 11:54:31 +0200654 { .name = "HTTP_1.0", .expr = {"req_ver","1.0",""}},
655 { .name = "HTTP_1.1", .expr = {"req_ver","1.1",""}},
656 { .name = "METH_CONNECT", .expr = {"method","CONNECT",""}},
657 { .name = "METH_GET", .expr = {"method","GET","HEAD",""}},
658 { .name = "METH_HEAD", .expr = {"method","HEAD",""}},
659 { .name = "METH_OPTIONS", .expr = {"method","OPTIONS",""}},
660 { .name = "METH_POST", .expr = {"method","POST",""}},
661 { .name = "METH_TRACE", .expr = {"method","TRACE",""}},
662 { .name = "HTTP_URL_ABS", .expr = {"url_reg","^[^/:]*://",""}},
663 { .name = "HTTP_URL_SLASH", .expr = {"url_beg","/",""}},
664 { .name = "HTTP_URL_STAR", .expr = {"url","*",""}},
665 { .name = "HTTP_CONTENT", .expr = {"hdr_val(content-length)","gt","0",""}},
Emeric Brunbede3d02009-06-30 17:54:00 +0200666 { .name = "RDP_COOKIE", .expr = {"req_rdp_cookie_cnt","gt","0",""}},
Willy Tarreauc6317702008-07-20 09:29:50 +0200667 { .name = "REQ_CONTENT", .expr = {"req_len","gt","0",""}},
Willy Tarreaub6fb4202008-07-20 11:18:28 +0200668 { .name = "WAIT_END", .expr = {"wait_end",""}},
Willy Tarreau16fbe822007-06-17 11:54:31 +0200669 { .name = NULL, .expr = {""}}
670};
671
672/* Find a default ACL from the default_acl list, compile it and return it.
673 * If the ACL is not found, NULL is returned. In theory, it cannot fail,
674 * except when default ACLs are broken, in which case it will return NULL.
Willy Tarreaub7451bb2012-04-27 12:38:15 +0200675 * If <known_acl> is not NULL, the ACL will be queued at its tail. If <err> is
676 * not NULL, it will be filled with an error message if an error occurs. This
Willy Tarreaua4312fa2013-04-02 16:34:32 +0200677 * pointer must be freeable or NULL. <al> is an arg_list serving as a list head
678 * to report missing dependencies.
Willy Tarreau16fbe822007-06-17 11:54:31 +0200679 */
Willy Tarreaua4312fa2013-04-02 16:34:32 +0200680static struct acl *find_acl_default(const char *acl_name, struct list *known_acl,
681 char **err, struct arg_list *al)
Willy Tarreau16fbe822007-06-17 11:54:31 +0200682{
683 __label__ out_return, out_free_acl_expr, out_free_name;
684 struct acl *cur_acl;
685 struct acl_expr *acl_expr;
686 char *name;
687 int index;
688
689 for (index = 0; default_acl_list[index].name != NULL; index++) {
690 if (strcmp(acl_name, default_acl_list[index].name) == 0)
691 break;
692 }
693
Willy Tarreaub7451bb2012-04-27 12:38:15 +0200694 if (default_acl_list[index].name == NULL) {
Willy Tarreaueb6cead2012-09-20 19:43:14 +0200695 memprintf(err, "no such ACL : '%s'", acl_name);
Willy Tarreau16fbe822007-06-17 11:54:31 +0200696 return NULL;
Willy Tarreaub7451bb2012-04-27 12:38:15 +0200697 }
Willy Tarreau16fbe822007-06-17 11:54:31 +0200698
Willy Tarreaua4312fa2013-04-02 16:34:32 +0200699 acl_expr = parse_acl_expr((const char **)default_acl_list[index].expr, err, al);
Willy Tarreaub7451bb2012-04-27 12:38:15 +0200700 if (!acl_expr) {
701 /* parse_acl_expr must have filled err here */
Willy Tarreau16fbe822007-06-17 11:54:31 +0200702 goto out_return;
Willy Tarreaub7451bb2012-04-27 12:38:15 +0200703 }
Willy Tarreau16fbe822007-06-17 11:54:31 +0200704
705 name = strdup(acl_name);
Willy Tarreaub7451bb2012-04-27 12:38:15 +0200706 if (!name) {
Willy Tarreaueb6cead2012-09-20 19:43:14 +0200707 memprintf(err, "out of memory when building default ACL '%s'", acl_name);
Willy Tarreau16fbe822007-06-17 11:54:31 +0200708 goto out_free_acl_expr;
Willy Tarreaub7451bb2012-04-27 12:38:15 +0200709 }
710
Willy Tarreau16fbe822007-06-17 11:54:31 +0200711 cur_acl = (struct acl *)calloc(1, sizeof(*cur_acl));
Willy Tarreaub7451bb2012-04-27 12:38:15 +0200712 if (cur_acl == NULL) {
Willy Tarreaueb6cead2012-09-20 19:43:14 +0200713 memprintf(err, "out of memory when building default ACL '%s'", acl_name);
Willy Tarreau16fbe822007-06-17 11:54:31 +0200714 goto out_free_name;
Willy Tarreaub7451bb2012-04-27 12:38:15 +0200715 }
Willy Tarreau16fbe822007-06-17 11:54:31 +0200716
717 cur_acl->name = name;
Thierry FOURNIER348971e2013-11-21 10:50:10 +0100718 cur_acl->use |= acl_expr->smp->fetch->use;
719 cur_acl->val |= acl_expr->smp->fetch->val;
Willy Tarreau16fbe822007-06-17 11:54:31 +0200720 LIST_INIT(&cur_acl->expr);
721 LIST_ADDQ(&cur_acl->expr, &acl_expr->list);
722 if (known_acl)
723 LIST_ADDQ(known_acl, &cur_acl->list);
724
725 return cur_acl;
726
727 out_free_name:
728 free(name);
729 out_free_acl_expr:
730 prune_acl_expr(acl_expr);
731 free(acl_expr);
732 out_return:
733 return NULL;
734}
Willy Tarreaua84d3742007-05-07 00:36:48 +0200735
736/* Purge everything in the acl_cond <cond>, then return <cond>. */
737struct acl_cond *prune_acl_cond(struct acl_cond *cond)
738{
739 struct acl_term_suite *suite, *tmp_suite;
740 struct acl_term *term, *tmp_term;
741
742 /* iterate through all term suites and free all terms and all suites */
743 list_for_each_entry_safe(suite, tmp_suite, &cond->suites, list) {
744 list_for_each_entry_safe(term, tmp_term, &suite->terms, list)
745 free(term);
746 free(suite);
747 }
748 return cond;
749}
750
751/* Parse an ACL condition starting at <args>[0], relying on a list of already
752 * known ACLs passed in <known_acl>. The new condition is returned (or NULL in
Willy Tarreaub7451bb2012-04-27 12:38:15 +0200753 * case of low memory). Supports multiple conditions separated by "or". If
754 * <err> is not NULL, it will be filled with a pointer to an error message in
755 * case of error, that the caller is responsible for freeing. The initial
Willy Tarreaua4312fa2013-04-02 16:34:32 +0200756 * location must either be freeable or NULL. The list <al> serves as a list head
757 * for unresolved dependencies.
Willy Tarreaua84d3742007-05-07 00:36:48 +0200758 */
Willy Tarreaua4312fa2013-04-02 16:34:32 +0200759struct acl_cond *parse_acl_cond(const char **args, struct list *known_acl,
Willy Tarreau0cba6072013-11-28 22:21:02 +0100760 enum acl_cond_pol pol, char **err, struct arg_list *al)
Willy Tarreaua84d3742007-05-07 00:36:48 +0200761{
762 __label__ out_return, out_free_suite, out_free_term;
Willy Tarreau74b98a82007-06-16 19:35:18 +0200763 int arg, neg;
Willy Tarreaua84d3742007-05-07 00:36:48 +0200764 const char *word;
765 struct acl *cur_acl;
766 struct acl_term *cur_term;
767 struct acl_term_suite *cur_suite;
768 struct acl_cond *cond;
Willy Tarreaua91d0a52013-03-25 08:12:18 +0100769 unsigned int suite_val;
Willy Tarreaua84d3742007-05-07 00:36:48 +0200770
771 cond = (struct acl_cond *)calloc(1, sizeof(*cond));
Willy Tarreaub7451bb2012-04-27 12:38:15 +0200772 if (cond == NULL) {
Willy Tarreaueb6cead2012-09-20 19:43:14 +0200773 memprintf(err, "out of memory when parsing condition");
Willy Tarreaua84d3742007-05-07 00:36:48 +0200774 goto out_return;
Willy Tarreaub7451bb2012-04-27 12:38:15 +0200775 }
Willy Tarreaua84d3742007-05-07 00:36:48 +0200776
777 LIST_INIT(&cond->list);
778 LIST_INIT(&cond->suites);
779 cond->pol = pol;
Willy Tarreaua91d0a52013-03-25 08:12:18 +0100780 cond->val = 0;
Willy Tarreaua84d3742007-05-07 00:36:48 +0200781
782 cur_suite = NULL;
Willy Tarreaua91d0a52013-03-25 08:12:18 +0100783 suite_val = ~0U;
Willy Tarreau74b98a82007-06-16 19:35:18 +0200784 neg = 0;
Willy Tarreaua84d3742007-05-07 00:36:48 +0200785 for (arg = 0; *args[arg]; arg++) {
786 word = args[arg];
787
788 /* remove as many exclamation marks as we can */
789 while (*word == '!') {
790 neg = !neg;
791 word++;
792 }
793
794 /* an empty word is allowed because we cannot force the user to
795 * always think about not leaving exclamation marks alone.
796 */
797 if (!*word)
798 continue;
799
Willy Tarreau16fbe822007-06-17 11:54:31 +0200800 if (strcasecmp(word, "or") == 0 || strcmp(word, "||") == 0) {
Willy Tarreaua84d3742007-05-07 00:36:48 +0200801 /* new term suite */
Willy Tarreaua91d0a52013-03-25 08:12:18 +0100802 cond->val |= suite_val;
803 suite_val = ~0U;
Willy Tarreaua84d3742007-05-07 00:36:48 +0200804 cur_suite = NULL;
805 neg = 0;
806 continue;
807 }
808
Willy Tarreau95fa4692010-02-01 13:05:50 +0100809 if (strcmp(word, "{") == 0) {
810 /* we may have a complete ACL expression between two braces,
811 * find the last one.
812 */
813 int arg_end = arg + 1;
814 const char **args_new;
815
816 while (*args[arg_end] && strcmp(args[arg_end], "}") != 0)
817 arg_end++;
818
Willy Tarreaub7451bb2012-04-27 12:38:15 +0200819 if (!*args[arg_end]) {
Willy Tarreaueb6cead2012-09-20 19:43:14 +0200820 memprintf(err, "missing closing '}' in condition");
Willy Tarreau95fa4692010-02-01 13:05:50 +0100821 goto out_free_suite;
Willy Tarreaub7451bb2012-04-27 12:38:15 +0200822 }
Willy Tarreau95fa4692010-02-01 13:05:50 +0100823
824 args_new = calloc(1, (arg_end - arg + 1) * sizeof(*args_new));
Willy Tarreaub7451bb2012-04-27 12:38:15 +0200825 if (!args_new) {
Willy Tarreaueb6cead2012-09-20 19:43:14 +0200826 memprintf(err, "out of memory when parsing condition");
Willy Tarreau95fa4692010-02-01 13:05:50 +0100827 goto out_free_suite;
Willy Tarreaub7451bb2012-04-27 12:38:15 +0200828 }
Willy Tarreau95fa4692010-02-01 13:05:50 +0100829
Willy Tarreau2a56c5e2010-03-15 16:13:29 +0100830 args_new[0] = "";
Willy Tarreau95fa4692010-02-01 13:05:50 +0100831 memcpy(args_new + 1, args + arg + 1, (arg_end - arg) * sizeof(*args_new));
832 args_new[arg_end - arg] = "";
Willy Tarreaua4312fa2013-04-02 16:34:32 +0200833 cur_acl = parse_acl(args_new, known_acl, err, al);
Willy Tarreau95fa4692010-02-01 13:05:50 +0100834 free(args_new);
835
Willy Tarreaub7451bb2012-04-27 12:38:15 +0200836 if (!cur_acl) {
837 /* note that parse_acl() must have filled <err> here */
Willy Tarreau16fbe822007-06-17 11:54:31 +0200838 goto out_free_suite;
Willy Tarreaub7451bb2012-04-27 12:38:15 +0200839 }
Willy Tarreaua91d0a52013-03-25 08:12:18 +0100840 word = args[arg + 1];
Willy Tarreau95fa4692010-02-01 13:05:50 +0100841 arg = arg_end;
842 }
843 else {
844 /* search for <word> in the known ACL names. If we do not find
845 * it, let's look for it in the default ACLs, and if found, add
846 * it to the list of ACLs of this proxy. This makes it possible
847 * to override them.
848 */
849 cur_acl = find_acl_by_name(word, known_acl);
850 if (cur_acl == NULL) {
Willy Tarreaua4312fa2013-04-02 16:34:32 +0200851 cur_acl = find_acl_default(word, known_acl, err, al);
Willy Tarreaub7451bb2012-04-27 12:38:15 +0200852 if (cur_acl == NULL) {
853 /* note that find_acl_default() must have filled <err> here */
Willy Tarreau95fa4692010-02-01 13:05:50 +0100854 goto out_free_suite;
Willy Tarreaub7451bb2012-04-27 12:38:15 +0200855 }
Willy Tarreau95fa4692010-02-01 13:05:50 +0100856 }
Willy Tarreau16fbe822007-06-17 11:54:31 +0200857 }
Willy Tarreaua84d3742007-05-07 00:36:48 +0200858
859 cur_term = (struct acl_term *)calloc(1, sizeof(*cur_term));
Willy Tarreaub7451bb2012-04-27 12:38:15 +0200860 if (cur_term == NULL) {
Willy Tarreaueb6cead2012-09-20 19:43:14 +0200861 memprintf(err, "out of memory when parsing condition");
Willy Tarreaua84d3742007-05-07 00:36:48 +0200862 goto out_free_suite;
Willy Tarreaub7451bb2012-04-27 12:38:15 +0200863 }
Willy Tarreaua84d3742007-05-07 00:36:48 +0200864
865 cur_term->acl = cur_acl;
866 cur_term->neg = neg;
Willy Tarreaua91d0a52013-03-25 08:12:18 +0100867
868 /* Here it is a bit complex. The acl_term_suite is a conjunction
869 * of many terms. It may only be used if all of its terms are
870 * usable at the same time. So the suite's validity domain is an
871 * AND between all ACL keywords' ones. But, the global condition
872 * is valid if at least one term suite is OK. So it's an OR between
873 * all of their validity domains. We could emit a warning as soon
874 * as suite_val is null because it means that the last ACL is not
875 * compatible with the previous ones. Let's remain simple for now.
876 */
877 cond->use |= cur_acl->use;
878 suite_val &= cur_acl->val;
Willy Tarreaua84d3742007-05-07 00:36:48 +0200879
880 if (!cur_suite) {
881 cur_suite = (struct acl_term_suite *)calloc(1, sizeof(*cur_suite));
Willy Tarreauf678b7f2013-01-24 00:25:39 +0100882 if (cur_suite == NULL) {
Willy Tarreaueb6cead2012-09-20 19:43:14 +0200883 memprintf(err, "out of memory when parsing condition");
Willy Tarreaua84d3742007-05-07 00:36:48 +0200884 goto out_free_term;
Willy Tarreaub7451bb2012-04-27 12:38:15 +0200885 }
Willy Tarreaua84d3742007-05-07 00:36:48 +0200886 LIST_INIT(&cur_suite->terms);
887 LIST_ADDQ(&cond->suites, &cur_suite->list);
888 }
889 LIST_ADDQ(&cur_suite->terms, &cur_term->list);
Willy Tarreau74b98a82007-06-16 19:35:18 +0200890 neg = 0;
Willy Tarreaua84d3742007-05-07 00:36:48 +0200891 }
892
Willy Tarreaua91d0a52013-03-25 08:12:18 +0100893 cond->val |= suite_val;
Willy Tarreaua84d3742007-05-07 00:36:48 +0200894 return cond;
895
896 out_free_term:
897 free(cur_term);
898 out_free_suite:
899 prune_acl_cond(cond);
900 free(cond);
901 out_return:
902 return NULL;
903}
904
Willy Tarreau2bbba412010-01-28 16:48:33 +0100905/* Builds an ACL condition starting at the if/unless keyword. The complete
906 * condition is returned. NULL is returned in case of error or if the first
907 * word is neither "if" nor "unless". It automatically sets the file name and
Willy Tarreau25320b22013-03-24 07:22:08 +0100908 * the line number in the condition for better error reporting, and sets the
909 * HTTP intiailization requirements in the proxy. If <err> is not NULL, it will
Willy Tarreaub7451bb2012-04-27 12:38:15 +0200910 * be filled with a pointer to an error message in case of error, that the
911 * caller is responsible for freeing. The initial location must either be
912 * freeable or NULL.
Willy Tarreau2bbba412010-01-28 16:48:33 +0100913 */
Willy Tarreaub7451bb2012-04-27 12:38:15 +0200914struct acl_cond *build_acl_cond(const char *file, int line, struct proxy *px, const char **args, char **err)
Willy Tarreau2bbba412010-01-28 16:48:33 +0100915{
Willy Tarreau0cba6072013-11-28 22:21:02 +0100916 enum acl_cond_pol pol = ACL_COND_NONE;
Willy Tarreau2bbba412010-01-28 16:48:33 +0100917 struct acl_cond *cond = NULL;
918
Willy Tarreaub7451bb2012-04-27 12:38:15 +0200919 if (err)
920 *err = NULL;
921
Willy Tarreau2bbba412010-01-28 16:48:33 +0100922 if (!strcmp(*args, "if")) {
923 pol = ACL_COND_IF;
924 args++;
925 }
926 else if (!strcmp(*args, "unless")) {
927 pol = ACL_COND_UNLESS;
928 args++;
929 }
Willy Tarreaub7451bb2012-04-27 12:38:15 +0200930 else {
Willy Tarreaueb6cead2012-09-20 19:43:14 +0200931 memprintf(err, "conditions must start with either 'if' or 'unless'");
Willy Tarreau2bbba412010-01-28 16:48:33 +0100932 return NULL;
Willy Tarreaub7451bb2012-04-27 12:38:15 +0200933 }
Willy Tarreau2bbba412010-01-28 16:48:33 +0100934
Willy Tarreaua4312fa2013-04-02 16:34:32 +0200935 cond = parse_acl_cond(args, &px->acl, pol, err, &px->conf.args);
Willy Tarreaub7451bb2012-04-27 12:38:15 +0200936 if (!cond) {
937 /* note that parse_acl_cond must have filled <err> here */
Willy Tarreau2bbba412010-01-28 16:48:33 +0100938 return NULL;
Willy Tarreaub7451bb2012-04-27 12:38:15 +0200939 }
Willy Tarreau2bbba412010-01-28 16:48:33 +0100940
941 cond->file = file;
942 cond->line = line;
Willy Tarreaua91d0a52013-03-25 08:12:18 +0100943 px->http_needed |= !!(cond->use & SMP_USE_HTTP_ANY);
Willy Tarreau2bbba412010-01-28 16:48:33 +0100944 return cond;
945}
946
Thierry FOURNIERa65b3432013-11-28 18:22:00 +0100947/* Execute condition <cond> and return either ACL_TEST_FAIL, ACL_TEST_MISS or
948 * ACL_TEST_PASS depending on the test results. ACL_TEST_MISS may only be
Willy Tarreau32a6f2e2012-04-25 10:13:36 +0200949 * returned if <opt> does not contain SMP_OPT_FINAL, indicating that incomplete
Thierry FOURNIERa65b3432013-11-28 18:22:00 +0100950 * data is being examined. The function automatically sets SMP_OPT_ITERATE. This
951 * function only computes the condition, it does not apply the polarity required
952 * by IF/UNLESS, it's up to the caller to do this using something like this :
Willy Tarreau11382812008-07-09 16:18:21 +0200953 *
954 * res = acl_pass(res);
Thierry FOURNIERa65b3432013-11-28 18:22:00 +0100955 * if (res == ACL_TEST_MISS)
Willy Tarreaub6866442008-07-14 23:54:42 +0200956 * return 0;
Willy Tarreau11382812008-07-09 16:18:21 +0200957 * if (cond->pol == ACL_COND_UNLESS)
958 * res = !res;
Willy Tarreaua84d3742007-05-07 00:36:48 +0200959 */
Willy Tarreau0cba6072013-11-28 22:21:02 +0100960enum acl_test_res acl_exec_cond(struct acl_cond *cond, struct proxy *px, struct session *l4, void *l7, unsigned int opt)
Willy Tarreaua84d3742007-05-07 00:36:48 +0200961{
962 __label__ fetch_next;
963 struct acl_term_suite *suite;
964 struct acl_term *term;
965 struct acl_expr *expr;
966 struct acl *acl;
Willy Tarreau37406352012-04-23 16:16:37 +0200967 struct sample smp;
Willy Tarreau0cba6072013-11-28 22:21:02 +0100968 enum acl_test_res acl_res, suite_res, cond_res;
Willy Tarreaua84d3742007-05-07 00:36:48 +0200969
Willy Tarreau7a777ed2012-04-26 11:44:02 +0200970 /* ACLs are iterated over all values, so let's always set the flag to
971 * indicate this to the fetch functions.
972 */
973 opt |= SMP_OPT_ITERATE;
974
Willy Tarreau11382812008-07-09 16:18:21 +0200975 /* We're doing a logical OR between conditions so we initialize to FAIL.
976 * The MISS status is propagated down from the suites.
977 */
Thierry FOURNIERa65b3432013-11-28 18:22:00 +0100978 cond_res = ACL_TEST_FAIL;
Willy Tarreaua84d3742007-05-07 00:36:48 +0200979 list_for_each_entry(suite, &cond->suites, list) {
Willy Tarreau11382812008-07-09 16:18:21 +0200980 /* Evaluate condition suite <suite>. We stop at the first term
Willy Tarreau0cba6072013-11-28 22:21:02 +0100981 * which returns ACL_TEST_FAIL. The MISS status is still propagated
Willy Tarreau11382812008-07-09 16:18:21 +0200982 * in case of uncertainty in the result.
Willy Tarreaua84d3742007-05-07 00:36:48 +0200983 */
984
985 /* we're doing a logical AND between terms, so we must set the
986 * initial value to PASS.
987 */
Thierry FOURNIERa65b3432013-11-28 18:22:00 +0100988 suite_res = ACL_TEST_PASS;
Willy Tarreaua84d3742007-05-07 00:36:48 +0200989 list_for_each_entry(term, &suite->terms, list) {
990 acl = term->acl;
991
992 /* FIXME: use cache !
993 * check acl->cache_idx for this.
994 */
995
996 /* ACL result not cached. Let's scan all the expressions
997 * and use the first one to match.
998 */
Thierry FOURNIERa65b3432013-11-28 18:22:00 +0100999 acl_res = ACL_TEST_FAIL;
Willy Tarreaua84d3742007-05-07 00:36:48 +02001000 list_for_each_entry(expr, &acl->expr, list) {
Willy Tarreaud41f8d82007-06-10 10:06:18 +02001001 /* we need to reset context and flags */
Willy Tarreau37406352012-04-23 16:16:37 +02001002 memset(&smp, 0, sizeof(smp));
Willy Tarreaua84d3742007-05-07 00:36:48 +02001003 fetch_next:
Thierry FOURNIER348971e2013-11-21 10:50:10 +01001004 if (!sample_process(px, l4, l7, opt, expr->smp, &smp)) {
Willy Tarreaub6866442008-07-14 23:54:42 +02001005 /* maybe we could not fetch because of missing data */
Willy Tarreau32a6f2e2012-04-25 10:13:36 +02001006 if (smp.flags & SMP_F_MAY_CHANGE && !(opt & SMP_OPT_FINAL))
Thierry FOURNIERa65b3432013-11-28 18:22:00 +01001007 acl_res |= ACL_TEST_MISS;
Willy Tarreaua84d3742007-05-07 00:36:48 +02001008 continue;
Willy Tarreaub6866442008-07-14 23:54:42 +02001009 }
Willy Tarreauc4262962010-05-10 23:42:40 +02001010
Willy Tarreau0cba6072013-11-28 22:21:02 +01001011 acl_res |= pat2acl(pattern_exec_match(&expr->pat, &smp, NULL));
Willy Tarreaua84d3742007-05-07 00:36:48 +02001012 /*
Willy Tarreau11382812008-07-09 16:18:21 +02001013 * OK now acl_res holds the result of this expression
Thierry FOURNIERa65b3432013-11-28 18:22:00 +01001014 * as one of ACL_TEST_FAIL, ACL_TEST_MISS or ACL_TEST_PASS.
Willy Tarreaua84d3742007-05-07 00:36:48 +02001015 *
Willy Tarreau11382812008-07-09 16:18:21 +02001016 * Then if (!MISS) we can cache the result, and put
Willy Tarreau37406352012-04-23 16:16:37 +02001017 * (smp.flags & SMP_F_VOLATILE) in the cache flags.
Willy Tarreaua84d3742007-05-07 00:36:48 +02001018 *
1019 * FIXME: implement cache.
1020 *
1021 */
1022
Willy Tarreau11382812008-07-09 16:18:21 +02001023 /* we're ORing these terms, so a single PASS is enough */
Thierry FOURNIERa65b3432013-11-28 18:22:00 +01001024 if (acl_res == ACL_TEST_PASS)
Willy Tarreaua84d3742007-05-07 00:36:48 +02001025 break;
1026
Willy Tarreau37406352012-04-23 16:16:37 +02001027 if (smp.flags & SMP_F_NOT_LAST)
Willy Tarreaua84d3742007-05-07 00:36:48 +02001028 goto fetch_next;
Willy Tarreaub6866442008-07-14 23:54:42 +02001029
1030 /* sometimes we know the fetched data is subject to change
1031 * later and give another chance for a new match (eg: request
1032 * size, time, ...)
1033 */
Willy Tarreau32a6f2e2012-04-25 10:13:36 +02001034 if (smp.flags & SMP_F_MAY_CHANGE && !(opt & SMP_OPT_FINAL))
Thierry FOURNIERa65b3432013-11-28 18:22:00 +01001035 acl_res |= ACL_TEST_MISS;
Willy Tarreaua84d3742007-05-07 00:36:48 +02001036 }
1037 /*
1038 * Here we have the result of an ACL (cached or not).
1039 * ACLs are combined, negated or not, to form conditions.
1040 */
1041
Willy Tarreaua84d3742007-05-07 00:36:48 +02001042 if (term->neg)
Willy Tarreau11382812008-07-09 16:18:21 +02001043 acl_res = acl_neg(acl_res);
Willy Tarreaua84d3742007-05-07 00:36:48 +02001044
1045 suite_res &= acl_res;
Willy Tarreau11382812008-07-09 16:18:21 +02001046
Willy Tarreau79c412b2013-10-30 19:30:32 +01001047 /* we're ANDing these terms, so a single FAIL or MISS is enough */
Thierry FOURNIERa65b3432013-11-28 18:22:00 +01001048 if (suite_res != ACL_TEST_PASS)
Willy Tarreaua84d3742007-05-07 00:36:48 +02001049 break;
1050 }
1051 cond_res |= suite_res;
Willy Tarreau11382812008-07-09 16:18:21 +02001052
1053 /* we're ORing these terms, so a single PASS is enough */
Thierry FOURNIERa65b3432013-11-28 18:22:00 +01001054 if (cond_res == ACL_TEST_PASS)
Willy Tarreaua84d3742007-05-07 00:36:48 +02001055 break;
1056 }
Willy Tarreau11382812008-07-09 16:18:21 +02001057 return cond_res;
Willy Tarreaua84d3742007-05-07 00:36:48 +02001058}
1059
Willy Tarreaua91d0a52013-03-25 08:12:18 +01001060/* Returns a pointer to the first ACL conflicting with usage at place <where>
1061 * which is one of the SMP_VAL_* bits indicating a check place, or NULL if
1062 * no conflict is found. Only full conflicts are detected (ACL is not usable).
1063 * Use the next function to check for useless keywords.
Willy Tarreaudd64f8d2008-07-27 22:02:32 +02001064 */
Willy Tarreaua91d0a52013-03-25 08:12:18 +01001065const struct acl *acl_cond_conflicts(const struct acl_cond *cond, unsigned int where)
Willy Tarreaudd64f8d2008-07-27 22:02:32 +02001066{
1067 struct acl_term_suite *suite;
1068 struct acl_term *term;
1069 struct acl *acl;
1070
1071 list_for_each_entry(suite, &cond->suites, list) {
1072 list_for_each_entry(term, &suite->terms, list) {
1073 acl = term->acl;
Willy Tarreaua91d0a52013-03-25 08:12:18 +01001074 if (!(acl->val & where))
Willy Tarreaudd64f8d2008-07-27 22:02:32 +02001075 return acl;
1076 }
1077 }
1078 return NULL;
1079}
1080
Willy Tarreaua91d0a52013-03-25 08:12:18 +01001081/* Returns a pointer to the first ACL and its first keyword to conflict with
1082 * usage at place <where> which is one of the SMP_VAL_* bits indicating a check
1083 * place. Returns true if a conflict is found, with <acl> and <kw> set (if non
1084 * null), or false if not conflict is found. The first useless keyword is
1085 * returned.
1086 */
Willy Tarreau93fddf12013-03-31 22:59:32 +02001087int acl_cond_kw_conflicts(const struct acl_cond *cond, unsigned int where, struct acl const **acl, char const **kw)
Willy Tarreaua91d0a52013-03-25 08:12:18 +01001088{
1089 struct acl_term_suite *suite;
1090 struct acl_term *term;
1091 struct acl_expr *expr;
1092
1093 list_for_each_entry(suite, &cond->suites, list) {
1094 list_for_each_entry(term, &suite->terms, list) {
1095 list_for_each_entry(expr, &term->acl->expr, list) {
Thierry FOURNIER348971e2013-11-21 10:50:10 +01001096 if (!(expr->smp->fetch->val & where)) {
Willy Tarreaua91d0a52013-03-25 08:12:18 +01001097 if (acl)
1098 *acl = term->acl;
1099 if (kw)
1100 *kw = expr->kw;
1101 return 1;
1102 }
1103 }
1104 }
1105 }
1106 return 0;
1107}
1108
Krzysztof Piotr Oledzkif9423ae2010-01-29 19:26:18 +01001109/*
1110 * Find targets for userlist and groups in acl. Function returns the number
Willy Tarreaua4312fa2013-04-02 16:34:32 +02001111 * of errors or OK if everything is fine. It must be called only once sample
1112 * fetch arguments have been resolved (after smp_resolve_args()).
Krzysztof Piotr Oledzkif9423ae2010-01-29 19:26:18 +01001113 */
Willy Tarreaua4312fa2013-04-02 16:34:32 +02001114int acl_find_targets(struct proxy *p)
Krzysztof Piotr Oledzkif9423ae2010-01-29 19:26:18 +01001115{
1116
1117 struct acl *acl;
1118 struct acl_expr *expr;
Thierry FOURNIERa65b3432013-11-28 18:22:00 +01001119 struct pattern *pattern;
Krzysztof Piotr Oledzkif9423ae2010-01-29 19:26:18 +01001120 int cfgerr = 0;
1121
1122 list_for_each_entry(acl, &p->acl, list) {
1123 list_for_each_entry(expr, &acl->expr, list) {
Willy Tarreaua4312fa2013-04-02 16:34:32 +02001124 if (!strcmp(expr->kw, "http_auth_group")) {
1125 /* Note: the ARGT_USR argument may only have been resolved earlier
1126 * by smp_resolve_args().
1127 */
Thierry FOURNIER348971e2013-11-21 10:50:10 +01001128 if (expr->smp->arg_p->unresolved) {
Willy Tarreaua4312fa2013-04-02 16:34:32 +02001129 Alert("Internal bug in proxy %s: %sacl %s %s() makes use of unresolved userlist '%s'. Please report this.\n",
Thierry FOURNIER348971e2013-11-21 10:50:10 +01001130 p->id, *acl->name ? "" : "anonymous ", acl->name, expr->kw, expr->smp->arg_p->data.str.str);
Willy Tarreaua4312fa2013-04-02 16:34:32 +02001131 cfgerr++;
Willy Tarreau496aa012012-06-01 10:38:29 +02001132 continue;
Krzysztof Piotr Oledzkif9423ae2010-01-29 19:26:18 +01001133 }
Krzysztof Piotr Oledzkif9423ae2010-01-29 19:26:18 +01001134
Thierry FOURNIERd163e1c2013-11-28 11:41:23 +01001135 if (LIST_ISEMPTY(&expr->pat.patterns)) {
Krzysztof Piotr Oledzkif9423ae2010-01-29 19:26:18 +01001136 Alert("proxy %s: acl %s %s(): no groups specified.\n",
Willy Tarreau93fddf12013-03-31 22:59:32 +02001137 p->id, acl->name, expr->kw);
Krzysztof Piotr Oledzkif9423ae2010-01-29 19:26:18 +01001138 cfgerr++;
1139 continue;
1140 }
1141
Thierry FOURNIERd163e1c2013-11-28 11:41:23 +01001142 list_for_each_entry(pattern, &expr->pat.patterns, list) {
Willy Tarreau7d1df412012-11-23 23:47:36 +01001143 /* this keyword only has one argument */
Thierry FOURNIER348971e2013-11-21 10:50:10 +01001144 pattern->val.group_mask = auth_resolve_groups(expr->smp->arg_p->data.usr, pattern->ptr.str);
Krzysztof Piotr Oledzkif9423ae2010-01-29 19:26:18 +01001145
Krzysztof Piotr Oledzkif9423ae2010-01-29 19:26:18 +01001146 if (!pattern->val.group_mask) {
Willy Tarreaua4312fa2013-04-02 16:34:32 +02001147 Alert("proxy %s: acl %s %s(): invalid group '%s'.\n",
1148 p->id, acl->name, expr->kw, pattern->ptr.str);
Krzysztof Piotr Oledzkif9423ae2010-01-29 19:26:18 +01001149 cfgerr++;
Krzysztof Piotr Oledzkif9423ae2010-01-29 19:26:18 +01001150 }
Willy Tarreaua4312fa2013-04-02 16:34:32 +02001151 free(pattern->ptr.str);
1152 pattern->ptr.str = NULL;
1153 pattern->len = 0;
Krzysztof Piotr Oledzkif9423ae2010-01-29 19:26:18 +01001154 }
1155 }
1156 }
1157 }
1158
1159 return cfgerr;
1160}
Willy Tarreaudd64f8d2008-07-27 22:02:32 +02001161
Willy Tarreau8ed669b2013-01-11 15:49:37 +01001162/* initializes ACLs by resolving the sample fetch names they rely upon.
1163 * Returns 0 on success, otherwise an error.
1164 */
1165int init_acl()
1166{
1167 int err = 0;
1168 int index;
1169 const char *name;
1170 struct acl_kw_list *kwl;
1171 struct sample_fetch *smp;
1172
1173 list_for_each_entry(kwl, &acl_keywords.list, list) {
1174 for (index = 0; kwl->kw[index].kw != NULL; index++) {
1175 name = kwl->kw[index].fetch_kw;
1176 if (!name)
1177 name = kwl->kw[index].kw;
1178
1179 smp = find_sample_fetch(name, strlen(name));
1180 if (!smp) {
1181 Alert("Critical internal error: ACL keyword '%s' relies on sample fetch '%s' which was not registered!\n",
1182 kwl->kw[index].kw, name);
1183 err++;
1184 continue;
1185 }
1186 kwl->kw[index].smp = smp;
1187 }
1188 }
1189 return err;
1190}
Willy Tarreaud4c33c82013-01-07 21:59:07 +01001191
Willy Tarreaua84d3742007-05-07 00:36:48 +02001192/************************************************************************/
Willy Tarreaud4c33c82013-01-07 21:59:07 +01001193/* All supported sample and ACL keywords must be declared here. */
1194/************************************************************************/
1195
1196/* Note: must not be declared <const> as its list will be overwritten.
Willy Tarreau61612d42012-04-19 18:42:05 +02001197 * Please take care of keeping this list alphabetically sorted.
1198 */
Willy Tarreaudc13c112013-06-21 23:16:39 +02001199static struct acl_kw_list acl_kws = {ILH, {
Willy Tarreaud4c33c82013-01-07 21:59:07 +01001200 { /* END */ },
Willy Tarreaua84d3742007-05-07 00:36:48 +02001201}};
1202
Willy Tarreaua84d3742007-05-07 00:36:48 +02001203__attribute__((constructor))
1204static void __acl_init(void)
1205{
Willy Tarreaua84d3742007-05-07 00:36:48 +02001206 acl_register_keywords(&acl_kws);
1207}
1208
1209
1210/*
1211 * Local variables:
1212 * c-indent-level: 8
1213 * c-basic-offset: 8
1214 * End:
1215 */