-
Notifications
You must be signed in to change notification settings - Fork 3
/
05-brace-expansion.patch
654 lines (633 loc) · 15.8 KB
/
05-brace-expansion.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
Copyright (c) 2021 - 2023 Matthias Pressfreund
Permission to use, copy, modify, and distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
Index: usr.sbin/httpd/httpd.conf.5
@@ -910,6 +910,71 @@
Include types definitions from an external file, for example
.Pa /usr/share/misc/mime.types .
.El
+.Sh BRACE EXPANSION
+Text enclosed by curly braces inside the
+.Ic alias Ar name ,
+.Ic include Ar path ,
+and
+.Ic location Ar path
+parameters will be handled as follows:
+.Pp
+Comma-separated lists in the form
+.Dl <list> ::= <text> | <text> ',' <list>
+.Pp
+expand according to the given list items, e.g.
+.Dl alias \(dqserver-{AAA,BBB,CCC,DDD}\(dq
+.Pp
+expands to
+.Bd -literal -offset indent -compact
+alias "server-AAA"
+alias "server-BBB"
+alias "server-CCC"
+alias "server-DDD"
+.Ed
+.Pp
+Number sequences formatted as
+.Dl <sequence> ::= <first> '..' <last>
+.Pp
+with
+.Dv <first>
+and
+.Dv <last>
+as decimal numbers denoting the respective elements expand as such, e.g.
+.Dl include \(dq/etc/httpd-{19..47}.conf\(dq
+.Pp
+expands to
+.Bd -literal -offset indent -compact
+include "/etc/httpd-19.conf"
+include "/etc/httpd-20.conf"
+\&...
+include "/etc/httpd-47.conf"
+.Ed
+.Pp
+In case one of the special characters
+.Pq So \(lC Sc , So \(rC Sc or Sq \&,
+is needed inside a brace extended parameter, a preceding back-slash
+.Pq Sq \e
+serving as escape character is required.
+This also applies to the back-slash character itself, i.e. in case for some
+reason a back-slash character is needed inside the parameter, it must be
+passed as
+.Sq \e\e .
+Escaping a regular character will be silently ignored.
+Escape characters inside number sequence braces are not allowed and will make
+the number sequence silently being handled as if it was a list.
+.Pp
+In case there are multiple brace sections inside a parameter, the following
+rules of thumb apply:
+.Pp
+.Bl -bullet -offset indent -compact
+.It
+Nested braces expand in depth first.
+.It
+For consecutive sections, the second will be fully traversed for each item of
+the first.
+.El
+.Pp
+Another example is available below.
.Sh FILES
.Bl -tag -width /etc/examples/httpd.conf -compact
.It Pa /etc/examples/httpd.conf
@@ -1054,6 +1119,28 @@
file will straighten things out.
.Bd -literal -offset indent
add_filter('got_url_rewrite', '__return_true');
+.Ed
+.Pp
+Brace expansion can help clarify configuration files in which several
+.Ic location
+sections share the same content:
+.Pp
+.Dl location \(dq/chapter/{A_0{1,2,5},F_{17..49}}-{B,C}/*\(dq { ... }
+.Pp
+replaces
+.Pp
+.Bd -literal -offset indent -compact
+location "/chapter/A_01-B/*" { ... }
+location "/chapter/A_01-C/*" { ... }
+location "/chapter/A_02-B/*" { ... }
+location "/chapter/A_02-C/*" { ... }
+location "/chapter/A_05-B/*" { ... }
+location "/chapter/A_05-C/*" { ... }
+location "/chapter/F_17-B/*" { ... }
+location "/chapter/F_17-C/*" { ... }
+\&...
+location "/chapter/F_49-B/*" { ... }
+location "/chapter/F_49-C/*" { ... }
.Ed
.Sh SEE ALSO
.Xr htpasswd 1 ,
Index: usr.sbin/httpd/parse.y
@@ -87,6 +87,20 @@
void lungetc(int);
int findeol(void);
+TAILQ_HEAD(bstrq, bstr) bstrq = TAILQ_HEAD_INITIALIZER(bstrq);
+struct bstr {
+ TAILQ_ENTRY(bstr) bstrs;
+ char *str;
+};
+int expand_braces(struct bstrq *, const char *);
+int expand_seq(struct bstrq *, const char *);
+int append_bstr(struct bstrq *, struct bstrq *, const char *);
+void append_bexp(struct bstrq *, struct bstrq *, const char *);
+char *unesc(char *);
+void free_bstrq(struct bstrq *);
+struct server *location_cpy(struct server *, int);
+int location_add(struct server *, struct bstr *);
+
TAILQ_HEAD(symhead, sym) symhead = TAILQ_HEAD_INITIALIZER(symhead);
struct sym {
TAILQ_ENTRY(sym) entry;
@@ -169,17 +183,31 @@
;
include : INCLUDE STRING {
+ struct bstr *bs;
struct file *nfile;
- if ((nfile = pushfile($2, 0)) == NULL) {
- yyerror("failed to include file %s", $2);
+ if (expand_braces(&bstrq, $2) == -1) {
+ yyerror("brace expansion error in include "
+ "\"%s\"", $2);
free($2);
YYERROR;
}
free($2);
- file = nfile;
- lungetc('\n');
+ while ((bs = TAILQ_FIRST(&bstrq)) != NULL) {
+ if ((nfile = pushfile(bs->str, 0)) == NULL) {
+ yyerror("failed to include file %s",
+ bs->str);
+ free_bstrq(&bstrq);
+ YYERROR;
+ }
+ TAILQ_REMOVE(&bstrq, bs, bstrs);
+ free(bs->str);
+ free(bs);
+
+ file = nfile;
+ lungetc('\n');
+ }
}
;
@@ -475,6 +503,7 @@
free($3);
}
| ALIAS optmatch STRING {
+ struct bstr *bs;
struct server_config *alias;
if (parentsrv != NULL) {
@@ -483,22 +512,37 @@
YYERROR;
}
- if ((alias = calloc(1, sizeof(*alias))) == NULL)
- fatal("out of memory");
-
- if (strlcpy(alias->name, $3, sizeof(alias->name)) >=
- sizeof(alias->name)) {
- yyerror("server alias truncated");
+ if (expand_braces(&bstrq, $3) == -1) {
+ yyerror("brace expansion error in alias "
+ "\"%s\"", $3);
free($3);
- free(alias);
YYERROR;
}
free($3);
- if ($2)
- alias->flags |= SRVFLAG_SERVER_MATCH;
+ while ((bs = TAILQ_FIRST(&bstrq)) != NULL) {
+ if ((alias = calloc(1,
+ sizeof(*alias))) == NULL)
+ fatal("out of memory");
- TAILQ_INSERT_TAIL(&srv->srv_hosts, alias, entry);
+ if (strlcpy(alias->name, bs->str,
+ sizeof(alias->name)) >=
+ sizeof(alias->name)) {
+ yyerror("server alias truncated");
+ free(alias);
+ free_bstrq(&bstrq);
+ YYERROR;
+ }
+ TAILQ_REMOVE(&bstrq, bs, bstrs);
+ free(bs->str);
+ free(bs);
+
+ if ($2)
+ alias->flags |= SRVFLAG_SERVER_MATCH;
+
+ TAILQ_INSERT_TAIL(&srv->srv_hosts, alias,
+ entry);
+ }
}
| ERRDOCS STRING {
if (parentsrv != NULL) {
@@ -563,6 +607,8 @@
| LOCATION optfound optmatch STRING optclientfilter {
struct server *s;
struct sockaddr_un *sun;
+ int n;
+ struct bstr *bs;
if (srv->srv_conf.ss.ss_family == AF_UNSPEC) {
yyerror("listen address not specified");
@@ -584,25 +630,44 @@
YYACCEPT;
}
+ if ((n = expand_braces(&bstrq, $4)) == -1) {
+ yyerror("brace expansion error in location "
+ "\"%s\"", $4);
+ free($4);
+ free($5);
+ YYERROR;
+ }
+ free($4);
+ if (last_server_id + n >= INT_MAX) {
+ yyerror("too many servers/locations defined");
+ free($5);
+ free_bstrq(&bstrq);
+ YYERROR;
+ }
+
if ((s = calloc(1, sizeof (*s))) == NULL)
fatal("out of memory");
- if (strlcpy(s->srv_conf.location, $4,
+ bs = TAILQ_FIRST(&bstrq);
+ if (strlcpy(s->srv_conf.location, bs->str,
sizeof(s->srv_conf.location)) >=
sizeof(s->srv_conf.location)) {
yyerror("server location truncated");
- free($4);
free($5);
+ free_bstrq(&bstrq);
free(s);
YYERROR;
}
- free($4);
+ TAILQ_REMOVE(&bstrq, bs, bstrs);
+ free(bs->str);
+ free(bs);
if (strlcpy(s->srv_conf.name, srv->srv_conf.name,
sizeof(s->srv_conf.name)) >=
sizeof(s->srv_conf.name)) {
yyerror("server name truncated");
free($5);
+ free_bstrq(&bstrq);
free(s);
YYERROR;
}
@@ -634,6 +699,7 @@
if (build_clientfilter(&s->srv_conf,
$5 + 1) == NULL) {
free($5);
+ free_bstrq(&bstrq);
free(s);
YYERROR;
}
@@ -657,51 +723,22 @@
s->srv_conf.prefixlen = srv->srv_conf.prefixlen;
s->srv_conf.tls_flags = srv->srv_conf.tls_flags;
- if (last_server_id == INT_MAX) {
- yyerror("too many servers/locations defined");
- free(s);
- YYERROR;
- }
parentsrv = srv;
srv = s;
srv_conf = &srv->srv_conf;
SPLAY_INIT(&srv->srv_clients);
} '{' optnl serveropts_l '}' {
- struct server *s = NULL;
- uint32_t f;
+ struct bstr *bs = NULL;
- f = SRVFLAG_CLIENT_FROM |
- SRVFLAG_CLIENT_NOT_FROM |
- SRVFLAG_LOCATION_FOUND |
- SRVFLAG_LOCATION_NOT_FOUND;
+ do {
+ if (location_add(bs == NULL ?
+ srv : location_cpy(srv, ++last_server_id),
+ bs) == -1) {
+ free_bstrq(&bstrq);
+ YYABORT;
+ }
+ } while ((bs = TAILQ_FIRST(&bstrq)) != NULL);
- TAILQ_FOREACH(s, conf->sc_servers, srv_entry) {
- /* Compare locations of same parent server */
- if ((s->srv_conf.flags & SRVFLAG_LOCATION) &&
- s->srv_conf.parent_id ==
- srv_conf->parent_id &&
- (s->srv_conf.flags & f) ==
- (srv_conf->flags & f) &&
- strcmp(s->srv_conf.location,
- srv_conf->location) == 0 &&
- clientfilter_cmp(s->srv_conf.clientfilter,
- srv_conf->clientfilter) == 0)
- break;
- }
- if (s != NULL) {
- yyerror("location \"%s\" defined twice",
- srv->srv_conf.location);
- serverconfig_free(srv_conf);
- free(srv);
- YYABORT;
- }
-
- DPRINTF("adding location \"%s\" for \"%s[%u]\"",
- srv->srv_conf.location,
- srv->srv_conf.name, srv->srv_conf.id);
-
- TAILQ_INSERT_TAIL(conf->sc_servers, srv, srv_entry);
-
srv = parentsrv;
srv_conf = &parentsrv->srv_conf;
parentsrv = NULL;
@@ -1768,6 +1805,296 @@
}
}
return (0);
+}
+
+int
+expand_braces(struct bstrq *resq, const char *cstr)
+{
+ struct bstrq bsq, trq;
+ char *sc, *str, *term, *end, *c, d, p;
+ int i, n;
+
+ if (cstr == NULL)
+ return (0);
+
+ if ((sc = strdup(cstr)) == NULL)
+ fatal("strdup");
+ str = sc;
+
+ TAILQ_INIT(&bsq);
+ TAILQ_INIT(&trq);
+
+ for (n = 0, c = str;; c++) {
+ if ((d = *c) == '\0') {
+ n += append_bstr(resq, &trq, str);
+ break;
+ }
+ if (d == '}')
+ goto fail; /* opening brace missing */
+
+ if (d == '\\')
+ c++;
+ else if (d == ',' && resq != &bstrq) {
+ *c = '\0';
+ n += append_bstr(resq, &trq, str);
+ str = c + 1;
+ } else if (d == '{') {
+ for (end = term = c, i = 1; i > 0;) {
+ if ((p = *++end) == '\0')
+ goto fail; /* closing brace missing */
+
+ if (p == '\\')
+ end++;
+ else if (p == '{')
+ i++;
+ else if (p == '}')
+ i--;
+ }
+ *term = *(c = end) = '\0';
+ if ((i = expand_seq(&bsq, ++term)) == -1 ||
+ (i == 0 && expand_braces(&bsq, term) == -1))
+ goto fail;
+
+ append_bexp(&trq, &bsq, str);
+ str = c + 1;
+ }
+ }
+
+ free(sc);
+ return (n);
+
+ fail:
+ free_bstrq(&trq);
+ free_bstrq(&bsq);
+ free(sc);
+ return (-1);
+}
+
+int
+expand_seq(struct bstrq *resq, const char *str)
+{
+ const char *errstr, d[] = "..";
+ char *sidx, *s, *c;
+ long long from, to, step;
+ struct bstr *bs;
+ int n;
+
+ if (strpbrk(str, "{\\") != NULL || (sidx = strstr(str, d)) == NULL)
+ return (0); /* not applicable */
+
+ if (sidx == str || *(sidx + sizeof(d) - 1) == '\0')
+ return (-1);
+
+ if ((s = strdup(str)) == NULL)
+ fatal("strdup");
+ c = &s[sidx - str];
+ *c = '\0';
+ from = strtonum(s, LLONG_MIN, LLONG_MAX, &errstr);
+ if (errstr != NULL)
+ goto fail;
+
+ to = strtonum(c + sizeof(d) - 1, LLONG_MIN, LLONG_MAX, &errstr);
+ if (errstr != NULL)
+ goto fail;
+
+ for (n = 0, step = from <= to ? 1 : -1;
+ (step == 1 && from <= to) || (step == -1 && from >= to);
+ from += step, n++) {
+ if ((bs = malloc(sizeof(*bs))) == NULL)
+ fatal("malloc");
+ if (asprintf(&bs->str, "%lld", from) == -1)
+ fatal("asprintf");
+ TAILQ_INSERT_TAIL(resq, bs, bstrs);
+ }
+ free(s);
+ return (n);
+
+ fail:
+ free(s);
+ return (-1);
+}
+
+int
+append_bstr(struct bstrq *resq, struct bstrq *trq, const char *str)
+{
+ struct bstr *bs;
+ char *s, *term;
+ int n;
+
+ if ((s = unesc(strdup(str))) == NULL)
+ fatal("strdup");
+
+ if (TAILQ_EMPTY(trq)) {
+ if ((bs = malloc(sizeof(*bs))) == NULL)
+ fatal("malloc");
+ bs->str = s;
+ TAILQ_INSERT_TAIL(resq, bs, bstrs);
+ return (1);
+ }
+
+ n = 0;
+ TAILQ_FOREACH(bs, trq, bstrs) {
+ if (asprintf(&term, "%s%s", bs->str, s) == -1)
+ fatal("asprintf");
+ free(bs->str);
+ bs->str = term;
+ n++;
+ }
+ free(s);
+ TAILQ_CONCAT(resq, trq, bstrs);
+ return (n);
+}
+
+void
+append_bexp(struct bstrq *trq, struct bstrq *exp, const char *str)
+{
+ struct bstr *bs, *tbs, *rbs, *nbs, *lbs;
+ char *s, *term;
+
+ if ((s = unesc(strdup(str))) == NULL)
+ fatal("strdup");
+
+ if (TAILQ_EMPTY(trq)) {
+ TAILQ_FOREACH_SAFE(bs, exp, bstrs, tbs) {
+ TAILQ_REMOVE(exp, bs, bstrs);
+ if (asprintf(&term, "%s%s", s, bs->str) == -1)
+ fatal("asprintf");
+ free(bs->str);
+ bs->str = term;
+ TAILQ_INSERT_TAIL(trq, bs, bstrs);
+ }
+ free(s);
+ return;
+ }
+
+ lbs = TAILQ_LAST(trq, bstrq);
+ TAILQ_FOREACH_SAFE(rbs, trq, bstrs, tbs) {
+ TAILQ_FOREACH(bs, exp, bstrs) {
+ if ((nbs = malloc(sizeof(*nbs))) == NULL)
+ fatal("malloc");
+ if (asprintf(&nbs->str, "%s%s%s", rbs->str, s,
+ bs->str) == -1)
+ fatal("asprintf");
+ TAILQ_INSERT_TAIL(trq, nbs, bstrs);
+ }
+ TAILQ_REMOVE(trq, rbs, bstrs);
+ free(rbs->str);
+ free(rbs);
+ if (rbs == lbs)
+ break;
+ }
+ free(s);
+ free_bstrq(exp);
+}
+
+char *
+unesc(char *str)
+{
+ char *c, *s;
+
+ if (str != NULL)
+ for (s = str; *s != '\0'; s++)
+ if (*s == '\\')
+ for (c = s; *c != '\0'; c++)
+ *c = *(c + 1);
+ return (str);
+}
+
+void
+free_bstrq(struct bstrq *bsq)
+{
+ struct bstr *bs;
+
+ while ((bs = TAILQ_FIRST(bsq)) != NULL) {
+ TAILQ_REMOVE(bsq, bs, bstrs);
+ free(bs->str);
+ free(bs);
+ }
+}
+
+struct server *
+location_cpy(struct server *src, int id)
+{
+ struct server *dst;
+ struct server_config *src_conf, *dst_conf;
+ struct server_fcgiparams *dst_fparams;
+ struct fastcgi_param *src_fparam, *dst_fparam;
+
+ if ((dst = calloc(1, sizeof(*dst))) == NULL)
+ fatal("calloc");
+
+ dst->srv_s = -1;
+
+ dst_conf = &dst->srv_conf;
+ src_conf = &src->srv_conf;
+ memcpy(dst_conf, src_conf, sizeof(*dst_conf));
+
+ dst_conf->id = id;
+
+ if (src_conf->return_uri != NULL &&
+ (dst_conf->return_uri = strdup(src_conf->return_uri)) == NULL)
+ fatal("strdup");
+
+ dst_fparams = &dst_conf->fcgiparams;
+ TAILQ_INIT(dst_fparams);
+ TAILQ_FOREACH(src_fparam, &src_conf->fcgiparams, entry) {
+ if ((dst_fparam = malloc(sizeof(*dst_fparam))) == NULL)
+ fatal("malloc");
+ memcpy(dst_fparam, src_fparam, sizeof(*dst_fparam));
+ TAILQ_INSERT_TAIL(dst_fparams, dst_fparam, entry);
+ }
+
+ SPLAY_INIT(&dst->srv_clients);
+
+ return (dst);
+}
+
+int
+location_add(struct server *nsrv, struct bstr *bs)
+{
+ struct server_config *nsrv_conf = &nsrv->srv_conf;
+ struct server *s;
+ const uint32_t f = SRVFLAG_CLIENT_FROM |
+ SRVFLAG_CLIENT_NOT_FROM |
+ SRVFLAG_LOCATION_FOUND |
+ SRVFLAG_LOCATION_NOT_FOUND;
+
+ if (bs != NULL) {
+ if (strlcpy(nsrv->srv_conf.location, bs->str,
+ sizeof(nsrv->srv_conf.location)) >=
+ sizeof(nsrv->srv_conf.location)) {
+ yyerror("server location \"%s\" truncated", bs->str);
+ goto fail;
+ }
+ TAILQ_REMOVE(&bstrq, bs, bstrs);
+ free(bs->str);
+ free(bs);
+ }
+
+ TAILQ_FOREACH(s, conf->sc_servers, srv_entry)
+ /* Compare locations of same parent server */
+ if ((s->srv_conf.flags & SRVFLAG_LOCATION) &&
+ s->srv_conf.parent_id == nsrv_conf->parent_id &&
+ (s->srv_conf.flags & f) == (nsrv_conf->flags & f) &&
+ strcmp(s->srv_conf.location, nsrv_conf->location) == 0 &&
+ clientfilter_cmp(s->srv_conf.clientfilter,
+ nsrv_conf->clientfilter) == 0)
+ break;
+ if (s != NULL) {
+ yyerror("location \"%s\" defined twice", nsrv_conf->location);
+ goto fail;
+ }
+
+ DPRINTF("adding location \"%s\" for \"%s[%u]\"", nsrv_conf->location,
+ nsrv_conf->name, nsrv_conf->id);
+
+ TAILQ_INSERT_TAIL(conf->sc_servers, nsrv, srv_entry);
+ return (0);
+
+ fail:
+ serverconfig_free(nsrv_conf);
+ free(nsrv);
+ return (-1);
}
int