2
/*static char yysccsid[] = "from: @(#)yaccpar 1.9 (Berkeley) 02/21/93";*/
5
__attribute__ ((unused))
6
#endif /* __GNUC__ == 2 */
7
= "$OpenBSD: skeleton.c,v 1.16 2001/02/26 00:03:33 tholo Exp $";
15
#define yyclearin (yychar=(YYEMPTY))
16
#define yyerrok (yyerrflag=0)
17
#define YYRECOVERING() (yyerrflag!=0)
18
#define yyparse socks_yyparse
19
#define yylex socks_yylex
20
#define yyerror socks_yyerror
21
#define yychar socks_yychar
22
#define yyval socks_yyval
23
#define yylval socks_yylval
24
#define yydebug socks_yydebug
25
#define yynerrs socks_yynerrs
26
#define yyerrflag socks_yyerrflag
27
#define yyss socks_yyss
28
#define yysslim socks_yysslim
29
#define yyssp socks_yyssp
30
#define yyvs socks_yyvs
31
#define yyvsp socks_yyvsp
32
#define yystacksize socks_yystacksize
33
#define yylhs socks_yylhs
34
#define yylen socks_yylen
35
#define yydefred socks_yydefred
36
#define yydgoto socks_yydgoto
37
#define yysindex socks_yysindex
38
#define yyrindex socks_yyrindex
39
#define yygindex socks_yygindex
40
#define yytable socks_yytable
41
#define yycheck socks_yycheck
42
#define yyname socks_yyname
43
#define yyrule socks_yyrule
44
#define YYPREFIX "socks_yy"
45
#line 45 "config_parse.y"
49
#include "yacconfig.h"
51
static const char rcsid[] =
52
"$Id: config_parse.y,v 1.180 2001/12/12 14:42:10 karls Exp $";
56
#if HAVE_LIBWRAP && SOCKS_SERVER
57
extern jmp_buf tcpd_buf;
58
#endif /* HAVE_LIBWRAP && SOCKS_SERVER */
61
addressinit __P((struct ruleaddress_t *address));
65
ruleinit __P((struct rule_t *rule));
74
static struct rule_t ruleinitmem;
75
static struct rule_t rule; /* new rule. */
76
static struct protocol_t protocolmem; /* new protocolmem. */
80
static struct serverstate_t state;
81
static struct route_t route; /* new route. */
82
static struct ruleaddress_t gw; /* new gateway. */
86
static struct ruleaddress_t src; /* new src. */
87
static struct ruleaddress_t dst; /* new dst. */
88
static struct ruleaddress_t rdr_from;
89
static struct ruleaddress_t rdr_to;
91
static struct ruleaddress_t *ruleaddress; /* current ruleaddress */
92
static struct extension_t *extension; /* new extensions */
93
static struct proxyprotocol_t *proxyprotocol;/* proxy protocol. */
95
static char *atype; /* atype of new address. */
96
static struct in_addr *ipaddr; /* new ipaddress */
97
static struct in_addr *netmask; /* new netmask */
98
static char *domain; /* new domain. */
99
static char *ifname; /* new ifname. */
101
static in_port_t *port_tcp; /* new TCP portnumber. */
102
static in_port_t *port_udp; /* new UDP portnumber. */
103
static int *methodv; /* new authmethods. */
104
static size_t *methodc; /* number of them. */
105
static struct protocol_t *protocol; /* new protocol. */
106
static struct command_t *command; /* new command. */
107
static enum operator_t *operator; /* new operator. */
109
static const struct {
112
} syslogfacilityv[] = {
114
{ "auth", LOG_AUTH },
115
#endif /* LOG_AUTH */
117
{ "authpriv", LOG_AUTHPRIV },
118
#endif /* LOG_AUTHPRIV */
120
{ "daemon", LOG_DAEMON },
121
#endif /* LOG_DAEMON */
123
{ "user", LOG_USER },
124
#endif /* LOG_USER */
126
{ "local0", LOG_LOCAL0 },
127
#endif /* LOG_LOCAL0 */
129
{ "local1", LOG_LOCAL1 },
130
#endif /* LOG_LOCAL1 */
132
{ "local2", LOG_LOCAL2 },
133
#endif /* LOG_LOCAL2 */
135
{ "local3", LOG_LOCAL3 },
136
#endif /* LOG_LOCAL3 */
138
{ "local4", LOG_LOCAL4 },
139
#endif /* LOG_LOCAL4 */
141
{ "local5", LOG_LOCAL5 },
142
#endif /* LOG_LOCAL5 */
144
{ "local6", LOG_LOCAL6 },
145
#endif /* LOG_LOCAL6 */
147
{ "local7", LOG_LOCAL7 }
148
#endif /* LOG_LOCAL7 */
154
#define ADDMETHOD(method) \
156
if (methodisset(method, methodv, *methodc)) \
157
yywarn("duplicate method: %s", method2string(method)); \
159
if (*methodc >= MAXMETHOD) \
160
yyerror("internal error"); \
161
methodv[(*methodc)++] = method; \
165
#line 166 "config_parse.y"
171
#define SERVERCONFIG 257
172
#define CLIENTCONFIG 258
173
#define DEPRECATED 259
174
#define CLIENTRULE 260
177
#define EXTERNAL_ROTATION 263
179
#define RESOLVEPROTOCOL 265
181
#define NOMISMATCH 267
182
#define NOUNKNOWN 268
183
#define EXTENSION 269
185
#define PRIVILEGED 271
186
#define IOTIMEOUT 272
187
#define CONNECTTIMEOUT 273
189
#define CLIENTMETHOD 275
195
#define COMPATIBILITY 281
196
#define REUSEADDR 282
199
#define USER_PRIVILEGED 285
200
#define USER_UNPRIVILEGED 286
201
#define USER_LIBWRAP 287
202
#define LOGOUTPUT 288
206
#define VERDICT_BLOCK 292
207
#define VERDICT_PASS 293
208
#define PAMSERVICENAME 294
210
#define PROTOCOL_TCP 296
211
#define PROTOCOL_UDP 297
212
#define PROTOCOL_FAKE 298
213
#define PROXYPROTOCOL 299
214
#define PROXYPROTOCOL_SOCKS_V4 300
215
#define PROXYPROTOCOL_SOCKS_V5 301
216
#define PROXYPROTOCOL_MSPROXY_V2 302
217
#define PROXYPROTOCOL_HTTP_V1_0 303
220
#define COMMAND_BIND 306
221
#define COMMAND_CONNECT 307
222
#define COMMAND_UDPASSOCIATE 308
223
#define COMMAND_BINDREPLY 309
224
#define COMMAND_UDPREPLY 310
227
#define LIBWRAPSTART 313
230
#define LOG_CONNECT 316
232
#define LOG_DISCONNECT 318
233
#define LOG_ERROR 319
234
#define LOG_IOOPERATION 320
235
#define IPADDRESS 321
236
#define DOMAINNAME 322
240
#define PORTNUMBER 326
241
#define SERVICENAME 327
246
#define BANDWIDTH 332
247
#define YYERRCODE 256
248
short socks_yylhs[] = { -1,
249
0, 0, 51, 1, 1, 1, 1, 1, 2, 2,
250
2, 2, 25, 26, 26, 52, 52, 52, 52, 52,
251
52, 52, 52, 52, 50, 50, 50, 50, 50, 50,
252
3, 58, 24, 7, 8, 8, 8, 8, 9, 9,
253
10, 11, 12, 12, 31, 32, 33, 33, 34, 35,
254
36, 37, 38, 38, 27, 27, 27, 39, 40, 41,
255
41, 53, 53, 53, 54, 55, 56, 57, 29, 30,
256
28, 42, 43, 43, 44, 44, 14, 15, 15, 15,
257
16, 17, 17, 18, 18, 47, 95, 45, 96, 46,
258
49, 49, 49, 49, 49, 48, 48, 66, 67, 68,
259
68, 63, 64, 64, 64, 64, 64, 64, 65, 65,
260
69, 69, 69, 69, 69, 70, 70, 19, 21, 21,
261
21, 21, 21, 20, 20, 4, 6, 6, 5, 5,
262
71, 22, 22, 23, 72, 74, 74, 74, 74, 74,
263
73, 73, 13, 75, 76, 77, 97, 98, 60, 61,
264
61, 61, 61, 61, 62, 62, 86, 87, 99, 100,
265
59, 78, 78, 78, 79, 79, 79, 80, 80, 80,
266
82, 82, 82, 81, 88, 88, 83, 84, 85, 89,
267
89, 89, 93, 93, 90, 91, 101, 94, 92,
269
short socks_yylen[] = { 2,
270
2, 2, 1, 0, 2, 2, 2, 2, 0, 2,
271
2, 2, 1, 1, 1, 1, 1, 1, 1, 1,
272
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
273
1, 8, 0, 3, 1, 1, 1, 1, 1, 2,
274
3, 1, 1, 2, 3, 1, 1, 2, 4, 0,
275
4, 0, 3, 3, 1, 1, 1, 3, 1, 1,
276
2, 1, 1, 1, 3, 3, 3, 1, 3, 3,
277
3, 3, 1, 1, 1, 2, 3, 1, 1, 1,
278
3, 1, 1, 1, 2, 3, 0, 4, 0, 4,
279
1, 1, 1, 1, 1, 1, 2, 7, 1, 0,
280
2, 6, 1, 1, 1, 1, 1, 1, 0, 2,
281
1, 1, 1, 1, 1, 1, 1, 3, 1, 1,
282
1, 1, 1, 1, 2, 3, 1, 1, 1, 2,
283
2, 2, 2, 3, 3, 1, 1, 1, 1, 1,
284
1, 2, 3, 3, 3, 3, 3, 3, 3, 1,
285
1, 1, 1, 1, 0, 2, 1, 1, 1, 1,
286
1, 2, 2, 2, 1, 1, 1, 4, 2, 2,
287
2, 2, 1, 1, 1, 1, 1, 1, 1, 0,
288
3, 2, 1, 1, 3, 1, 1, 1, 1,
290
short socks_yydefred[] = { 0,
291
3, 13, 0, 9, 4, 0, 0, 31, 0, 0,
292
0, 33, 10, 15, 57, 11, 14, 56, 55, 12,
293
0, 50, 52, 0, 0, 0, 0, 0, 0, 0,
294
0, 0, 0, 0, 116, 117, 5, 18, 29, 30,
295
28, 26, 27, 19, 20, 21, 22, 25, 16, 17,
296
23, 6, 24, 62, 63, 64, 8, 7, 0, 0,
297
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
298
0, 87, 89, 0, 0, 0, 0, 0, 71, 79,
299
80, 78, 77, 59, 0, 58, 0, 0, 0, 0,
300
53, 54, 82, 83, 0, 81, 46, 0, 45, 69,
301
70, 0, 0, 73, 74, 0, 72, 68, 65, 66,
302
67, 0, 0, 0, 0, 0, 0, 0, 0, 0,
303
0, 106, 107, 115, 114, 105, 108, 104, 111, 0,
304
0, 103, 113, 112, 61, 152, 153, 150, 151, 154,
305
0, 0, 0, 0, 99, 174, 177, 178, 49, 0,
306
0, 0, 51, 165, 166, 167, 85, 48, 91, 92,
307
93, 94, 95, 88, 0, 90, 76, 0, 0, 0,
308
0, 0, 0, 0, 0, 159, 160, 132, 133, 0,
309
0, 0, 110, 157, 0, 0, 0, 156, 0, 101,
310
0, 0, 162, 163, 164, 97, 86, 143, 127, 128,
311
126, 0, 35, 36, 37, 38, 0, 34, 42, 0,
312
41, 119, 120, 121, 122, 123, 118, 0, 144, 136,
313
137, 138, 139, 140, 135, 0, 0, 0, 134, 0,
314
158, 131, 0, 0, 161, 0, 0, 0, 189, 186,
315
182, 0, 0, 130, 40, 44, 125, 142, 147, 0,
316
0, 0, 148, 102, 0, 145, 0, 0, 98, 0,
317
188, 184, 181, 183, 0, 169, 170, 146, 179, 0,
318
149, 0, 173, 32, 187, 185, 176, 175, 0, 171,
321
short socks_yydgoto[] = { 3,
322
7, 6, 14, 122, 201, 202, 123, 207, 208, 124,
323
210, 211, 125, 15, 83, 40, 95, 96, 126, 217,
324
218, 127, 128, 63, 4, 16, 17, 18, 41, 42,
325
139, 98, 99, 44, 65, 45, 66, 46, 19, 85,
326
86, 48, 106, 107, 49, 50, 129, 164, 165, 51,
327
5, 52, 53, 54, 55, 56, 109, 20, 236, 237,
328
141, 142, 57, 130, 131, 58, 143, 144, 132, 59,
329
185, 133, 225, 226, 134, 186, 232, 149, 153, 249,
330
250, 271, 251, 252, 273, 187, 233, 279, 193, 241,
331
242, 243, 263, 264, 102, 103, 178, 179, 180, 181,
334
short socks_yysindex[] = { -151,
335
0, 0, 0, 0, 0, -10, 249, 0, -21, -18,
336
-15, 0, 0, 0, 0, 0, 0, 0, 0, 0,
337
-182, 0, 0, -9, -4, 2, 16, 18, 23, 30,
338
50, 60, 74, 75, 0, 0, 0, 0, 0, 0,
339
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
340
0, 0, 0, 0, 0, 0, 0, 0, -65, -194,
341
-245, -154, 13, 14, 80, 81, -248, -155, -130, -183,
342
-181, 0, 0, -168, -142, -142, -142, -249, 0, 0,
343
0, 0, 0, 0, -154, 0, -230, -226, -286, -286,
344
0, 0, 0, 0, -155, 0, 0, -130, 0, 0,
345
0, -186, -186, 0, 0, -168, 0, 0, 0, 0,
346
0, 88, 90, 91, 94, 98, 99, 101, 102, -213,
347
103, 0, 0, 0, 0, 0, 0, 0, 0, -249,
348
-167, 0, 0, 0, 0, 0, 0, 0, 0, 0,
349
-230, -167, -226, -167, 0, 0, 0, 0, 0, -161,
350
-161, -161, 0, 0, 0, 0, 0, 0, 0, 0,
351
0, 0, 0, 0, -186, 0, 0, -186, -158, -176,
352
-270, -110, -211, -139, -215, 0, 0, 0, 0, 117,
353
120, -143, 0, 0, -249, -144, 138, 0, -94, 0,
354
-226, -285, 0, 0, 0, 0, 0, 0, 0, 0,
355
0, -176, 0, 0, 0, 0, -270, 0, 0, -110,
356
0, 0, 0, 0, 0, 0, 0, -211, 0, 0,
357
0, 0, 0, 0, 0, -215, -286, -286, 0, 73,
358
0, 0, 141, -286, 0, 142, -230, 78, 0, 0,
359
0, 160, -202, 0, 0, 0, 0, 0, 0, 166,
360
-161, -161, 0, 0, -286, 0, -237, 92, 0, -107,
361
0, 0, 0, 0, -294, 0, 0, 0, 0, -161,
362
0, -161, 0, 0, 0, 0, 0, 0, -161, 0,
365
short socks_yyrindex[] = { 0,
366
0, 0, 0, 0, 0, 215, 216, 0, 0, 0,
367
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
368
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
369
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
370
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
371
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
372
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
373
0, 0, 0, 0, 0, 0, 0, -106, 0, 0,
374
0, 0, 0, 0, 109, 0, -103, -102, 0, 0,
375
0, 0, 0, 0, 144, 0, 0, 62, 0, 0,
376
0, 0, 0, 0, 0, 179, 0, 0, 0, 0,
377
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
378
0, 0, 0, 0, 0, 0, 0, 0, 0, -119,
379
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
380
-118, 0, -117, 0, 0, 0, 0, 0, 0, 214,
381
214, 214, 0, 0, 0, 0, 0, 0, 0, 0,
382
0, 0, 0, 0, 1, 0, 0, 0, 0, 0,
383
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
384
0, 0, 0, 0, 97, 0, 0, 0, 0, 0,
385
100, 0, 0, 0, 0, 0, 0, 0, 0, 0,
386
0, -111, 0, 0, 0, 0, 251, 0, 0, 310,
387
0, 0, 0, 0, 0, 0, 0, 264, 0, 0,
388
0, 0, 0, 0, 0, 325, 0, 0, 0, 0,
389
0, 0, 0, 0, 0, 0, 104, 0, 0, 0,
390
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
391
-123, -123, 0, 0, 0, 0, 0, 0, 0, 0,
392
0, 0, 0, 0, 0, 0, 0, 0, 0, -104,
393
0, -104, 0, 0, 0, 0, 0, 0, -123, 0,
396
short socks_yygindex[] = { 0,
397
0, 0, 221, -84, 28, 0, -82, 0, 24, 0,
398
0, 22, 0, 226, 0, 0, 0, 139, -71, 17,
399
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
400
229, 0, 140, 0, 0, 0, 0, 0, 230, 0,
401
154, 0, 0, 134, 0, 0, -70, -88, 0, 0,
402
0, 0, 0, 0, 0, 0, 52, 0, 0, 0,
403
0, -137, 0, 0, -112, 0, 0, -124, -64, 220,
404
-81, 0, 19, 0, 0, 0, 0, 0, 0, -208,
405
-80, 0, -77, 41, 0, 0, 0, 0, -129, 0,
406
-1, 0, 0, 0, 0, 0, 0, 0, 0, 0,
409
#define YYTABLESIZE 657
410
short socks_yytable[] = { 13,
411
96, 180, 136, 188, 137, 109, 155, 100, 150, 154,
412
96, 151, 155, 129, 166, 138, 140, 183, 190, 253,
413
180, 194, 195, 145, 112, 256, 277, 91, 239, 203,
414
204, 205, 206, 278, 146, 147, 60, 148, 26, 61,
415
240, 92, 62, 112, 113, 114, 268, 112, 67, 115,
416
80, 81, 82, 68, 116, 117, 136, 78, 137, 69,
417
189, 47, 191, 118, 114, 119, 238, 113, 115, 138,
418
140, 47, 230, 70, 117, 71, 196, 116, 145, 197,
419
72, 120, 121, 146, 147, 269, 118, 73, 119, 159,
420
160, 161, 162, 163, 212, 213, 214, 215, 216, 258,
421
220, 221, 222, 223, 224, 1, 2, 74, 60, 35,
422
36, 93, 94, 104, 105, 176, 177, 75, 60, 199,
423
200, 266, 267, 240, 261, 96, 145, 110, 111, 152,
424
156, 76, 77, 79, 84, 87, 88, 89, 90, 97,
425
280, 108, 281, 84, 100, 168, 101, 169, 170, 282,
426
180, 171, 136, 84, 137, 172, 173, 129, 174, 175,
427
182, 184, 129, 192, 180, 138, 140, 180, 198, 180,
428
180, 180, 219, 209, 227, 180, 270, 228, 75, 272,
429
180, 180, 129, 129, 229, 231, 47, 129, 75, 180,
430
180, 180, 129, 129, 180, 234, 235, 254, 255, 257,
431
180, 129, 259, 129, 260, 180, 180, 180, 180, 109,
432
155, 100, 265, 180, 2, 1, 274, 129, 275, 129,
433
129, 109, 109, 180, 100, 155, 100, 38, 155, 244,
434
245, 246, 39, 157, 247, 43, 47, 158, 135, 167,
435
64, 262, 0, 0, 248, 0, 0, 0, 8, 0,
436
0, 0, 0, 9, 10, 0, 0, 0, 37, 96,
437
96, 96, 96, 96, 0, 96, 96, 0, 0, 96,
438
0, 0, 96, 96, 96, 96, 0, 11, 0, 12,
439
0, 96, 0, 0, 0, 96, 96, 96, 96, 0,
440
0, 0, 96, 96, 96, 96, 0, 0, 0, 96,
441
0, 0, 0, 0, 96, 96, 0, 0, 0, 0,
442
0, 0, 0, 96, 0, 96, 0, 0, 0, 0,
443
47, 47, 47, 47, 47, 0, 47, 47, 0, 96,
444
47, 96, 96, 47, 47, 47, 47, 0, 0, 0,
445
0, 0, 47, 0, 0, 0, 47, 47, 47, 47,
446
0, 0, 0, 47, 47, 0, 47, 0, 0, 0,
447
47, 0, 0, 0, 0, 0, 47, 60, 60, 60,
448
60, 60, 60, 60, 60, 39, 0, 60, 0, 0,
449
60, 60, 60, 60, 0, 0, 0, 0, 124, 60,
450
47, 0, 0, 60, 60, 60, 60, 0, 60, 0,
451
60, 60, 84, 84, 84, 84, 84, 0, 84, 84,
452
0, 0, 84, 0, 0, 84, 84, 84, 84, 0,
453
0, 0, 0, 0, 84, 0, 0, 0, 84, 84,
454
84, 84, 0, 0, 43, 84, 84, 75, 75, 75,
455
75, 75, 0, 75, 75, 0, 0, 75, 0, 141,
456
75, 75, 75, 75, 0, 0, 0, 0, 0, 75,
457
0, 0, 0, 75, 75, 75, 75, 0, 0, 0,
458
75, 75, 180, 180, 180, 180, 180, 0, 180, 180,
459
0, 0, 180, 0, 0, 180, 180, 180, 180, 0,
460
0, 0, 0, 0, 180, 0, 0, 0, 180, 180,
461
180, 180, 0, 0, 0, 180, 180, 8, 21, 22,
462
23, 24, 0, 10, 25, 0, 0, 26, 0, 39,
463
27, 28, 29, 30, 39, 0, 0, 0, 0, 31,
464
0, 0, 124, 32, 33, 34, 11, 124, 0, 0,
465
35, 36, 0, 0, 39, 39, 0, 0, 0, 39,
466
0, 0, 0, 0, 39, 39, 0, 124, 124, 0,
467
0, 0, 124, 39, 0, 39, 0, 124, 124, 0,
468
0, 0, 0, 0, 0, 0, 124, 0, 124, 39,
469
0, 39, 39, 43, 0, 0, 0, 0, 0, 0,
470
0, 0, 124, 0, 124, 124, 0, 0, 141, 0,
471
0, 0, 0, 43, 43, 0, 0, 0, 43, 0,
472
0, 0, 0, 43, 43, 0, 0, 0, 141, 141,
473
0, 0, 43, 141, 43, 0, 0, 0, 141, 141,
474
0, 0, 0, 0, 0, 0, 0, 141, 43, 141,
475
43, 43, 0, 0, 0, 0, 0, 0, 0, 0,
476
0, 0, 0, 141, 0, 141, 141,
478
short socks_yycheck[] = { 10,
479
0, 125, 87, 141, 87, 125, 125, 125, 89, 90,
480
10, 89, 90, 125, 103, 87, 87, 130, 143, 228,
481
125, 151, 152, 88, 274, 234, 321, 276, 314, 300,
482
301, 302, 303, 328, 321, 322, 58, 324, 269, 58,
483
326, 290, 58, 274, 294, 295, 255, 274, 58, 299,
484
296, 297, 298, 58, 304, 305, 141, 123, 141, 58,
485
142, 0, 144, 313, 295, 315, 191, 294, 299, 141,
486
141, 10, 185, 58, 305, 58, 165, 304, 143, 168,
487
58, 331, 332, 321, 322, 323, 313, 58, 315, 276,
488
277, 278, 279, 280, 306, 307, 308, 309, 310, 237,
489
316, 317, 318, 319, 320, 257, 258, 58, 0, 292,
490
293, 267, 268, 282, 283, 329, 330, 58, 10, 296,
491
297, 251, 252, 326, 327, 125, 191, 76, 77, 89,
492
90, 58, 58, 328, 289, 123, 123, 58, 58, 270,
493
270, 284, 272, 0, 328, 58, 328, 58, 58, 279,
494
274, 58, 237, 10, 237, 58, 58, 269, 58, 58,
495
58, 329, 274, 325, 269, 237, 237, 291, 327, 274,
496
294, 295, 312, 284, 58, 299, 257, 58, 0, 257,
497
304, 305, 294, 295, 328, 330, 125, 299, 10, 313,
498
295, 315, 304, 305, 299, 58, 291, 125, 58, 58,
499
305, 313, 125, 315, 45, 329, 330, 331, 332, 329,
500
329, 329, 47, 0, 0, 0, 125, 329, 326, 331,
501
332, 125, 329, 10, 125, 329, 329, 7, 125, 202,
502
207, 210, 7, 95, 218, 7, 7, 98, 85, 106,
503
21, 243, -1, -1, 226, -1, -1, -1, 259, -1,
504
-1, -1, -1, 264, 265, -1, -1, -1, 10, 259,
505
260, 261, 262, 263, -1, 265, 266, -1, -1, 269,
506
-1, -1, 272, 273, 274, 275, -1, 288, -1, 290,
507
-1, 281, -1, -1, -1, 285, 286, 287, 288, -1,
508
-1, -1, 292, 293, 294, 295, -1, -1, -1, 299,
509
-1, -1, -1, -1, 304, 305, -1, -1, -1, -1,
510
-1, -1, -1, 313, -1, 315, -1, -1, -1, -1,
511
259, 260, 261, 262, 263, -1, 265, 266, -1, 329,
512
269, 331, 332, 272, 273, 274, 275, -1, -1, -1,
513
-1, -1, 281, -1, -1, -1, 285, 286, 287, 288,
514
-1, -1, -1, 292, 293, -1, 295, -1, -1, -1,
515
299, -1, -1, -1, -1, -1, 305, 259, 260, 261,
516
262, 263, 264, 265, 266, 125, -1, 269, -1, -1,
517
272, 273, 274, 275, -1, -1, -1, -1, 125, 281,
518
329, -1, -1, 285, 286, 287, 288, -1, 290, -1,
519
292, 293, 259, 260, 261, 262, 263, -1, 265, 266,
520
-1, -1, 269, -1, -1, 272, 273, 274, 275, -1,
521
-1, -1, -1, -1, 281, -1, -1, -1, 285, 286,
522
287, 288, -1, -1, 125, 292, 293, 259, 260, 261,
523
262, 263, -1, 265, 266, -1, -1, 269, -1, 125,
524
272, 273, 274, 275, -1, -1, -1, -1, -1, 281,
525
-1, -1, -1, 285, 286, 287, 288, -1, -1, -1,
526
292, 293, 259, 260, 261, 262, 263, -1, 265, 266,
527
-1, -1, 269, -1, -1, 272, 273, 274, 275, -1,
528
-1, -1, -1, -1, 281, -1, -1, -1, 285, 286,
529
287, 288, -1, -1, -1, 292, 293, 259, 260, 261,
530
262, 263, -1, 265, 266, -1, -1, 269, -1, 269,
531
272, 273, 274, 275, 274, -1, -1, -1, -1, 281,
532
-1, -1, 269, 285, 286, 287, 288, 274, -1, -1,
533
292, 293, -1, -1, 294, 295, -1, -1, -1, 299,
534
-1, -1, -1, -1, 304, 305, -1, 294, 295, -1,
535
-1, -1, 299, 313, -1, 315, -1, 304, 305, -1,
536
-1, -1, -1, -1, -1, -1, 313, -1, 315, 329,
537
-1, 331, 332, 274, -1, -1, -1, -1, -1, -1,
538
-1, -1, 329, -1, 331, 332, -1, -1, 274, -1,
539
-1, -1, -1, 294, 295, -1, -1, -1, 299, -1,
540
-1, -1, -1, 304, 305, -1, -1, -1, 294, 295,
541
-1, -1, 313, 299, 315, -1, -1, -1, 304, 305,
542
-1, -1, -1, -1, -1, -1, -1, 313, 329, 315,
543
331, 332, -1, -1, -1, -1, -1, -1, -1, -1,
544
-1, -1, -1, 329, -1, 331, 332,
550
#define YYMAXTOKEN 332
552
#if defined(__cplusplus) || __STDC__
553
const char * const socks_yyname[] =
555
char *socks_yyname[] =
558
"end-of-file",0,0,0,0,0,0,0,0,0,"'\\n'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
559
0,0,0,0,0,0,0,0,0,0,0,0,0,0,"'-'",0,"'/'",0,0,0,0,0,0,0,0,0,0,"':'",0,0,0,0,0,0,
560
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
561
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"'{'",0,"'}'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
562
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
563
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
564
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
565
"SERVERCONFIG","CLIENTCONFIG","DEPRECATED","CLIENTRULE","INTERNAL","EXTERNAL",
566
"EXTERNAL_ROTATION","DEBUGING","RESOLVEPROTOCOL","SRCHOST","NOMISMATCH",
567
"NOUNKNOWN","EXTENSION","BIND","PRIVILEGED","IOTIMEOUT","CONNECTTIMEOUT",
568
"METHOD","CLIENTMETHOD","NONE","GSSAPI","UNAME","RFC931","PAM","COMPATIBILITY",
569
"REUSEADDR","SAMEPORT","USERNAME","USER_PRIVILEGED","USER_UNPRIVILEGED",
570
"USER_LIBWRAP","LOGOUTPUT","LOGFILE","ROUTE","VIA","VERDICT_BLOCK",
571
"VERDICT_PASS","PAMSERVICENAME","PROTOCOL","PROTOCOL_TCP","PROTOCOL_UDP",
572
"PROTOCOL_FAKE","PROXYPROTOCOL","PROXYPROTOCOL_SOCKS_V4",
573
"PROXYPROTOCOL_SOCKS_V5","PROXYPROTOCOL_MSPROXY_V2","PROXYPROTOCOL_HTTP_V1_0",
574
"USER","COMMAND","COMMAND_BIND","COMMAND_CONNECT","COMMAND_UDPASSOCIATE",
575
"COMMAND_BINDREPLY","COMMAND_UDPREPLY","ACTION","LINE","LIBWRAPSTART",
576
"OPERATOR","LOG","LOG_CONNECT","LOG_DATA","LOG_DISCONNECT","LOG_ERROR",
577
"LOG_IOOPERATION","IPADDRESS","DOMAINNAME","DIRECT","IFNAME","PORT",
578
"PORTNUMBER","SERVICENAME","NUMBER","FROM","TO","REDIRECT","BANDWIDTH",
580
#if defined(__cplusplus) || __STDC__
581
const char * const socks_yyrule[] =
583
char *socks_yyrule[] =
585
{"$accept : configtype",
586
"configtype : serverinit serverline",
587
"configtype : clientinit clientline",
588
"serverinit : SERVERCONFIG",
590
"serverline : serverline '\\n'",
591
"serverline : serverline serverconfig",
592
"serverline : serverline clientrule",
593
"serverline : serverline rule",
595
"clientline : clientline '\\n'",
596
"clientline : clientline clientconfig",
597
"clientline : clientline route",
598
"clientinit : CLIENTCONFIG",
599
"clientconfig : clientoption",
600
"clientconfig : deprecated",
601
"serverconfig : global_authmethod",
602
"serverconfig : global_clientauthmethod",
603
"serverconfig : deprecated",
604
"serverconfig : internal",
605
"serverconfig : external",
606
"serverconfig : external_rotation",
607
"serverconfig : logoutput",
608
"serverconfig : serveroption",
609
"serverconfig : userids",
610
"serveroption : compatibility",
611
"serveroption : connecttimeout",
612
"serveroption : extension",
613
"serveroption : iotimeout",
614
"serveroption : resolveprotocol",
615
"serveroption : srchost",
616
"deprecated : DEPRECATED",
617
"route : ROUTE routeinit '{' routeoptions fromto gateway routeoptions '}'",
619
"proxyprotocol : PROXYPROTOCOL ':' proxyprotocols",
620
"proxyprotocolname : PROXYPROTOCOL_SOCKS_V4",
621
"proxyprotocolname : PROXYPROTOCOL_SOCKS_V5",
622
"proxyprotocolname : PROXYPROTOCOL_MSPROXY_V2",
623
"proxyprotocolname : PROXYPROTOCOL_HTTP_V1_0",
624
"proxyprotocols : proxyprotocolname",
625
"proxyprotocols : proxyprotocolname proxyprotocols",
626
"user : USER ':' usernames",
627
"username : USERNAME",
628
"usernames : username",
629
"usernames : username usernames",
630
"extension : EXTENSION ':' extensions",
631
"extensionname : BIND",
632
"extensions : extensionname",
633
"extensions : extensionname extensions",
634
"internal : INTERNAL internalinit ':' internaladdress",
636
"external : EXTERNAL externalinit ':' externaladdress",
638
"external_rotation : EXTERNAL_ROTATION ':' NONE",
639
"external_rotation : EXTERNAL_ROTATION ':' ROUTE",
640
"clientoption : logoutput",
641
"clientoption : debuging",
642
"clientoption : resolveprotocol",
643
"logoutput : LOGOUTPUT ':' logoutputdevices",
644
"logoutputdevice : LOGFILE",
645
"logoutputdevices : logoutputdevice",
646
"logoutputdevices : logoutputdevice logoutputdevices",
647
"userids : user_privileged",
648
"userids : user_unprivileged",
649
"userids : user_libwrap",
650
"user_privileged : USER_PRIVILEGED ':' userid",
651
"user_unprivileged : USER_UNPRIVILEGED ':' userid",
652
"user_libwrap : USER_LIBWRAP ':' userid",
654
"iotimeout : IOTIMEOUT ':' NUMBER",
655
"connecttimeout : CONNECTTIMEOUT ':' NUMBER",
656
"debuging : DEBUGING ':' NUMBER",
657
"compatibility : COMPATIBILITY ':' compatibilitys",
658
"compatibilityname : REUSEADDR",
659
"compatibilityname : SAMEPORT",
660
"compatibilitys : compatibilityname",
661
"compatibilitys : compatibilityname compatibilitys",
662
"resolveprotocol : RESOLVEPROTOCOL ':' resolveprotocolname",
663
"resolveprotocolname : PROTOCOL_FAKE",
664
"resolveprotocolname : PROTOCOL_TCP",
665
"resolveprotocolname : PROTOCOL_UDP",
666
"srchost : SRCHOST ':' srchostoptions",
667
"srchostoption : NOMISMATCH",
668
"srchostoption : NOUNKNOWN",
669
"srchostoptions : srchostoption",
670
"srchostoptions : srchostoption srchostoptions",
671
"authmethod : METHOD ':' authmethods",
673
"global_authmethod : METHOD ':' $$1 authmethods",
675
"global_clientauthmethod : CLIENTMETHOD ':' $$2 authmethods",
676
"authmethodname : NONE",
677
"authmethodname : GSSAPI",
678
"authmethodname : UNAME",
679
"authmethodname : RFC931",
680
"authmethodname : PAM",
681
"authmethods : authmethodname",
682
"authmethods : authmethodname authmethods",
683
"clientrule : CLIENTRULE verdict '{' clientruleoptions fromto clientruleoptions '}'",
684
"clientruleoption : option",
685
"clientruleoptions :",
686
"clientruleoptions : clientruleoption clientruleoptions",
687
"rule : verdict '{' ruleoptions fromto ruleoptions '}'",
688
"ruleoption : option",
689
"ruleoption : bandwidth",
690
"ruleoption : command",
691
"ruleoption : protocol",
692
"ruleoption : proxyprotocol",
693
"ruleoption : redirect",
695
"ruleoptions : ruleoption ruleoptions",
696
"option : authmethod",
699
"option : pamservicename",
701
"verdict : VERDICT_BLOCK",
702
"verdict : VERDICT_PASS",
703
"command : COMMAND ':' commands",
704
"commandname : COMMAND_BIND",
705
"commandname : COMMAND_CONNECT",
706
"commandname : COMMAND_UDPASSOCIATE",
707
"commandname : COMMAND_BINDREPLY",
708
"commandname : COMMAND_UDPREPLY",
709
"commands : commandname",
710
"commands : commandname commands",
711
"protocol : PROTOCOL ':' protocols",
712
"protocolname : PROTOCOL_TCP",
713
"protocolname : PROTOCOL_UDP",
714
"protocols : protocolname",
715
"protocols : protocolname protocols",
716
"fromto : srcaddress dstaddress",
717
"redirect : REDIRECT rdr_fromaddress",
718
"redirect : REDIRECT rdr_toaddress",
719
"bandwidth : BANDWIDTH ':' NUMBER",
720
"log : LOG ':' logs",
721
"logname : LOG_CONNECT",
722
"logname : LOG_DATA",
723
"logname : LOG_DISCONNECT",
724
"logname : LOG_ERROR",
725
"logname : LOG_IOOPERATION",
727
"logs : logname logs",
728
"pamservicename : PAMSERVICENAME ':' SERVICENAME",
729
"libwrap : LIBWRAPSTART ':' LINE",
730
"srcaddress : from ':' address",
731
"dstaddress : to ':' address",
732
"rdr_fromaddress : rdr_from ':' address",
733
"rdr_toaddress : rdr_to ':' address",
734
"gateway : via ':' gwaddress",
735
"routeoption : command",
736
"routeoption : extension",
737
"routeoption : protocol",
738
"routeoption : proxyprotocol",
739
"routeoption : authmethod",
741
"routeoptions : routeoption routeoptions",
747
"internaladdress : ipaddress port",
748
"internaladdress : domain port",
749
"internaladdress : ifname port",
750
"externaladdress : ipaddress",
751
"externaladdress : domain",
752
"externaladdress : ifname",
753
"address : ipaddress '/' netmask port",
754
"address : domain port",
755
"address : ifname port",
756
"gwaddress : ipaddress port",
757
"gwaddress : domain port",
758
"gwaddress : direct",
759
"ipaddress : IPADDRESS",
761
"netmask : IPADDRESS",
762
"domain : DOMAINNAME",
766
"port : PORT portoperator portnumber",
767
"port : PORT portrange",
768
"portnumber : portservice",
769
"portnumber : portstart",
770
"portrange : portstart '-' portend",
771
"portstart : PORTNUMBER",
772
"portend : PORTNUMBER",
773
"portservice : SERVICENAME",
774
"portoperator : OPERATOR",
779
#define YYMAXDEPTH YYSTACKSIZE
782
#define YYSTACKSIZE YYMAXDEPTH
784
#define YYSTACKSIZE 10000
785
#define YYMAXDEPTH 10000
788
#define YYINITSTACKSIZE 200
801
#line 1150 "config_parse.y"
803
#define INTERACTIVE 0
811
const char *filename;
813
const char *function = "readconfig()";
814
const int errno_s = errno;
820
if ((yyin = fopen(filename, "r")) == NULL) {
821
swarn("%s: %s", function, filename);
828
errno = errno_s; /* some buggy yacc's alter errno sometimes. */
836
yyerror(const char *fmt, ...)
838
yyerror(fmt, va_alist)
841
#endif /* STDC_HEADERS */
848
/* LINTED pointer casts may be troublesome */
852
#endif /* STDC_HEADERS */
854
bufused = snprintfn(buf, sizeof(buf),
855
"%s: error on line %d, near '%.10s': ",
856
sockscf.option.configfile, yylineno,
857
(yytext == NULL || *yytext == NUL) ? "'start of line'" : yytext);
859
vsnprintf(&buf[bufused], sizeof(buf) - bufused, fmt, ap);
861
/* LINTED expression has null effect */
865
serr(EXIT_FAILURE, buf);
866
serrx(EXIT_FAILURE, buf);
871
yywarn(const char *fmt, ...)
873
yywarn(fmt, va_alist)
876
#endif /* STDC_HEADERS */
883
/* LINTED pointer casts may be troublesome */
887
#endif /* STDC_HEADERS */
889
bufused = snprintfn(buf, sizeof(buf),
890
"%s: warning on line %d, near '%.10s': ",
891
sockscf.option.configfile, yylineno,
892
(yytext == NULL || *yytext == NUL) ? "'start of line'" : yytext);
894
vsnprintf(&buf[bufused], sizeof(buf) - bufused, fmt, ap);
896
/* LINTED expression has null effect */
906
struct ruleaddress_t *address;
908
ruleaddress = address;
910
atype = &ruleaddress->atype;
911
ipaddr = &ruleaddress->addr.ipv4.ip;
912
netmask = &ruleaddress->addr.ipv4.mask;
913
domain = ruleaddress->addr.domain;
914
ifname = ruleaddress->addr.ifname;
915
port_tcp = &ruleaddress->port.tcp;
916
port_udp = &ruleaddress->port.udp;
917
operator = &ruleaddress->operator;
926
rule->linenumber = yylineno;
928
command = &rule->state.command;
929
methodv = rule->state.methodv;
930
methodc = &rule->state.methodc;
931
protocol = &rule->state.protocol;
932
proxyprotocol = &rule->state.proxyprotocol;
934
bzero(&src, sizeof(src));
935
bzero(&dst, sizeof(dst));
938
src.atype = SOCKS_ADDR_IPV4;
939
src.addr.ipv4.ip.s_addr = htonl(INADDR_ANY);
940
src.port.tcp = src.port.udp = src.portend = htons(0);
942
dst = rdr_from = rdr_to = src;
946
/* allocate initial stack or double stack size, up to YYMAXDEPTH */
947
#if defined(__cplusplus) || __STDC__
948
static int yygrowstack(void)
950
static int yygrowstack()
957
if ((newsize = yystacksize) == 0)
958
newsize = YYINITSTACKSIZE;
959
else if (newsize >= YYMAXDEPTH)
961
else if ((newsize *= 2) > YYMAXDEPTH)
962
newsize = YYMAXDEPTH;
964
newss = yyss ? (short *)realloc(yyss, newsize * sizeof *newss) :
965
(short *)malloc(newsize * sizeof *newss);
970
newvs = yyvs ? (YYSTYPE *)realloc(yyvs, newsize * sizeof *newvs) :
971
(YYSTYPE *)malloc(newsize * sizeof *newvs);
976
yystacksize = newsize;
977
yysslim = yyss + newsize - 1;
990
#define YYABORT goto yyabort
991
#define YYREJECT goto yyabort
992
#define YYACCEPT goto yyaccept
993
#define YYERROR goto yyerrlab
995
#if defined(__cplusplus) || __STDC__
1001
register int yym, yyn, yystate;
1003
#if defined(__cplusplus) || __STDC__
1004
register const char *yys;
1005
#else /* !(defined(__cplusplus) || __STDC__) */
1007
#endif /* !(defined(__cplusplus) || __STDC__) */
1009
if ((yys = getenv("YYDEBUG")))
1012
if (yyn >= '0' && yyn <= '9')
1013
yydebug = yyn - '0';
1015
#endif /* YYDEBUG */
1021
if (yyss == NULL && yygrowstack()) goto yyoverflow;
1024
*yyssp = yystate = 0;
1027
if ((yyn = yydefred[yystate]) != 0) goto yyreduce;
1030
if ((yychar = yylex()) < 0) yychar = 0;
1035
if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
1036
if (!yys) yys = "illegal-symbol";
1037
printf("%sdebug: state %d, reading %d (%s)\n",
1038
YYPREFIX, yystate, yychar, yys);
1042
if ((yyn = yysindex[yystate]) && (yyn += yychar) >= 0 &&
1043
yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
1047
printf("%sdebug: state %d, shifting to state %d\n",
1048
YYPREFIX, yystate, yytable[yyn]);
1050
if (yyssp >= yysslim && yygrowstack())
1054
*++yyssp = yystate = yytable[yyn];
1057
if (yyerrflag > 0) --yyerrflag;
1060
if ((yyn = yyrindex[yystate]) && (yyn += yychar) >= 0 &&
1061
yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
1066
if (yyerrflag) goto yyinrecovery;
1067
#if defined(lint) || defined(__GNUC__)
1071
yyerror("syntax error");
1072
#if defined(lint) || defined(__GNUC__)
1083
if ((yyn = yysindex[*yyssp]) && (yyn += YYERRCODE) >= 0 &&
1084
yyn <= YYTABLESIZE && yycheck[yyn] == YYERRCODE)
1088
printf("%sdebug: state %d, error recovery shifting\
1089
to state %d\n", YYPREFIX, *yyssp, yytable[yyn]);
1091
if (yyssp >= yysslim && yygrowstack())
1095
*++yyssp = yystate = yytable[yyn];
1103
printf("%sdebug: error recovery discarding state %d\n",
1106
if (yyssp <= yyss) goto yyabort;
1114
if (yychar == 0) goto yyabort;
1119
if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
1120
if (!yys) yys = "illegal-symbol";
1121
printf("%sdebug: state %d, error recovery discards token %d (%s)\n",
1122
YYPREFIX, yystate, yychar, yys);
1131
printf("%sdebug: state %d, reducing by rule %d (%s)\n",
1132
YYPREFIX, yystate, yyn, yyrule[yyn]);
1135
yyval = yyvsp[1-yym];
1139
#line 270 "config_parse.y"
1142
protocol = &protocolmem;
1143
extension = &sockscf.extension;
1148
#line 279 "config_parse.y"
1149
{ yyval.string = NULL; }
1152
#line 286 "config_parse.y"
1153
{ yyval.string = NULL; }
1156
#line 293 "config_parse.y"
1161
#line 321 "config_parse.y"
1163
yywarn("given keyword is deprecated");
1167
#line 325 "config_parse.y"
1172
ruleaddress2sockshost(&gw, &route.gw.host, SOCKS_TCP);
1173
route.gw.state = state;
1180
#line 337 "config_parse.y"
1183
command = &state.command;
1184
extension = &state.extension;
1185
methodv = state.methodv;
1186
methodc = &state.methodc;
1187
protocol = &state.protocol;
1188
proxyprotocol = &state.proxyprotocol;
1190
bzero(&state, sizeof(state));
1191
bzero(&route, sizeof(route));
1192
bzero(&gw, sizeof(gw));
1193
bzero(&src, sizeof(src));
1194
bzero(&dst, sizeof(dst));
1195
src.atype = SOCKS_ADDR_IPV4;
1196
dst.atype = SOCKS_ADDR_IPV4;
1201
#line 361 "config_parse.y"
1203
proxyprotocol->socks_v4 = 1;
1207
#line 364 "config_parse.y"
1209
proxyprotocol->socks_v5 = 1;
1213
#line 367 "config_parse.y"
1215
proxyprotocol->msproxy_v2 = 1;
1219
#line 370 "config_parse.y"
1221
proxyprotocol->http_v1_0 = 1;
1225
#line 382 "config_parse.y"
1229
if (strcmp(yyvsp[0].string, method2string(AUTHMETHOD_RFC931)) == 0)
1230
yyerror("method %s requires libwrap", AUTHMETHOD_RFC931s);
1231
#endif /* !HAVE_LIBWRAP */
1232
if (adduser(&rule.user, yyvsp[0].string) == NULL)
1234
#endif /* SOCKS_SERVER */
1238
#line 401 "config_parse.y"
1240
extension->bind = 1;
1244
#line 411 "config_parse.y"
1247
addinternal(ruleaddress);
1252
#line 418 "config_parse.y"
1255
static struct ruleaddress_t mem;
1256
struct servent *service;
1260
/* set default port. */
1261
if ((service = getservbyname("socks", "tcp")) == NULL)
1262
*port_tcp = htons(SOCKD_PORT);
1264
*port_tcp = (in_port_t)service->s_port;
1269
#line 434 "config_parse.y"
1272
addexternal(ruleaddress);
1277
#line 441 "config_parse.y"
1280
static struct ruleaddress_t mem;
1287
#line 450 "config_parse.y"
1290
sockscf.external.rotation = ROTATION_NONE;
1294
#line 454 "config_parse.y"
1296
#if !HAVE_ROUTE_SOURCE
1297
yyerror("don't have code to discover route/address source on platform");
1298
#else /* !HAVE_ROUTE_SOURCE */
1299
sockscf.external.rotation = ROTATION_ROUTE;
1300
#endif /* HAVE_ROUTE_SOURCE */
1301
#endif /* SOCKS_SERVER */
1305
#line 472 "config_parse.y"
1307
const char *syslogname = "syslog";
1309
if (strncmp(yyvsp[0].string, syslogname, strlen(syslogname)) == 0
1310
&& (yyvsp[0].string[strlen(syslogname)] == NUL || yyvsp[0].string[strlen(syslogname)] == '/')) {
1313
sockscf.log.type |= LOGTYPE_SYSLOG;
1315
if (*(sl = &(yyvsp[0].string[strlen(syslogname)])) == '/') { /* facility. */
1318
for (i = 0, ++sl; i < ELEMENTS(syslogfacilityv); ++i)
1319
if (strcmp(sl, syslogfacilityv[i].name) == 0)
1322
if (i == ELEMENTS(syslogfacilityv))
1323
yyerror("unknown syslog facility \"%s\"", sl);
1325
sockscf.log.facility = syslogfacilityv[i].value;
1326
sockscf.log.facilityname = syslogfacilityv[i].name;
1329
sockscf.log.facility = LOG_DAEMON; /* default. */
1330
sockscf.log.facilityname = "daemon";
1333
else /* adding/changing filename. */
1334
if (!sockscf.state.init) {
1336
* Can't change filenames we log to after startup (well,
1337
* to be exact, we can't add new filenames, but we complain
1338
* about changing too for now since it's easier.
1342
sockscf.log.type |= LOGTYPE_FILE;
1344
if ((sockscf.log.fpv = (FILE **)realloc(sockscf.log.fpv,
1345
sizeof(*sockscf.log.fpv) * (sockscf.log.fpc + 1))) == NULL
1346
|| (sockscf.log.fplockv = (int *)realloc(sockscf.log.fplockv,
1347
sizeof(*sockscf.log.fplockv) * (sockscf.log.fpc + 1))) == NULL
1348
|| (sockscf.log.fnamev = (char **)realloc(sockscf.log.fnamev,
1349
sizeof(*sockscf.log.fnamev) * (sockscf.log.fpc + 1)))
1351
serrx(EXIT_FAILURE, NOMEM);
1353
if ((sockscf.log.fplockv[sockscf.log.fpc]
1354
= socks_mklock(SOCKS_LOCKFILE)) == -1)
1355
serr(EXIT_FAILURE, "socks_mklock()");
1357
if (strcmp(yyvsp[0].string, "stdout") == 0)
1358
sockscf.log.fpv[sockscf.log.fpc] = stdout;
1359
else if (strcmp(yyvsp[0].string, "stderr") == 0)
1360
sockscf.log.fpv[sockscf.log.fpc] = stderr;
1362
if ((sockscf.log.fpv[sockscf.log.fpc] = fopen(yyvsp[0].string, "a"))
1364
yyerror("fopen(%s)", yyvsp[0].string);
1366
if ((flag = fcntl(fileno(sockscf.log.fpv[sockscf.log.fpc]),
1368
|| fcntl(fileno(sockscf.log.fpv[sockscf.log.fpc]), F_SETFD,
1369
flag | FD_CLOEXEC) == -1)
1370
serr(EXIT_FAILURE, "fcntl(F_GETFD/F_SETFD)");
1372
if ((sockscf.log.fnamev[sockscf.log.fpc] = strdup(yyvsp[0].string)) == NULL)
1373
serr(EXIT_FAILURE, NOMEM);
1380
for (i = 0; i < sockscf.log.fpc; ++i)
1381
if (strcmp(sockscf.log.fnamev[i], yyvsp[0].string) == 0) {
1383
if (fileno(sockscf.log.fpv[i]) == fileno(stdout)
1384
|| fileno(sockscf.log.fpv[i]) == fileno(stderr))
1387
/* reopen logfiles. */
1388
fclose(sockscf.log.fpv[i]);
1389
if ((sockscf.log.fpv[i]
1390
= fopen(sockscf.log.fnamev[i], "a")) == NULL)
1391
yyerror("fopen(%s)", yyvsp[0].string);
1395
if (i == sockscf.log.fpc) /* no match found. */
1396
yywarn("can't change logoutput after startup");
1401
#line 576 "config_parse.y"
1404
sockscf.uid.privileged = yyvsp[0].uid;
1405
sockscf.uid.privileged_isset = 1;
1410
#line 584 "config_parse.y"
1413
sockscf.uid.unprivileged = yyvsp[0].uid;
1414
sockscf.uid.unprivileged_isset = 1;
1419
#line 592 "config_parse.y"
1421
#if HAVE_LIBWRAP && SOCKS_SERVER
1422
sockscf.uid.libwrap = yyvsp[0].uid;
1423
sockscf.uid.libwrap_isset = 1;
1424
#else /* HAVE_LIBWRAP */
1425
yyerror("libwrapsupport not compiled in");
1426
#endif /* !HAVE_LIBWRAP */
1430
#line 603 "config_parse.y"
1434
if ((pw = getpwnam(yyvsp[0].string)) == NULL)
1435
serrx(EXIT_FAILURE, "no such user \"%s\"", yyvsp[0].string);
1437
yyval.uid = pw->pw_uid;
1441
#line 613 "config_parse.y"
1444
sockscf.timeout.io = (time_t)atol(yyvsp[0].string);
1449
#line 620 "config_parse.y"
1452
sockscf.timeout.negotiate = (time_t)atol(yyvsp[0].string);
1457
#line 627 "config_parse.y"
1459
sockscf.option.debug = atoi(yyvsp[0].string);
1463
#line 635 "config_parse.y"
1466
sockscf.compat.reuseaddr = 1;
1470
#line 639 "config_parse.y"
1472
sockscf.compat.sameport = 1;
1477
#line 652 "config_parse.y"
1479
sockscf.resolveprotocol = RESOLVEPROTOCOL_FAKE;
1483
#line 655 "config_parse.y"
1485
#if HAVE_NO_RESOLVESTUFF
1486
yyerror("resolveprotocol keyword not supported on this installation");
1487
#else /* HAVE_NO_RESOLVESTUFF */
1488
sockscf.resolveprotocol = RESOLVEPROTOCOL_TCP;
1489
#endif /* !HAVE_NO_RESOLVESTUFF */
1493
#line 662 "config_parse.y"
1495
sockscf.resolveprotocol = RESOLVEPROTOCOL_UDP;
1499
#line 670 "config_parse.y"
1501
#if HAVE_LIBWRAP && SOCKS_SERVER
1502
sockscf.srchost.nomismatch = 1;
1506
#line 674 "config_parse.y"
1508
sockscf.srchost.nounknown = 1;
1510
yyerror("srchostoption requires libwrap");
1515
#line 690 "config_parse.y"
1518
methodv = sockscf.methodv;
1519
methodc = &sockscf.methodc;
1520
*methodc = 0; /* reset. */
1525
#line 699 "config_parse.y"
1528
methodv = sockscf.clientmethodv;
1529
methodc = &sockscf.clientmethodc;
1530
*methodc = 0; /* reset. */
1535
#line 708 "config_parse.y"
1537
ADDMETHOD(AUTHMETHOD_NONE);
1541
#line 711 "config_parse.y"
1543
yyerror("%s not supported", AUTHMETHOD_GSSAPIs);
1547
#line 714 "config_parse.y"
1549
ADDMETHOD(AUTHMETHOD_UNAME);
1553
#line 717 "config_parse.y"
1555
#if HAVE_LIBWRAP && SOCKS_SERVER
1556
ADDMETHOD(AUTHMETHOD_RFC931);
1557
#else /* !HAVE_LIBWRAP */
1558
yyerror("method %s requires libwraplibrary", AUTHMETHOD_RFC931s);
1559
#endif /* !HAVE_LIBWRAP */
1563
#line 724 "config_parse.y"
1566
yyerror("method %s requires pamlibrary", AUTHMETHOD_PAMs);
1567
#else /* HAVE_PAM */
1568
ADDMETHOD(AUTHMETHOD_PAM);
1569
#endif /* !HAVE_PAM */
1573
#line 740 "config_parse.y"
1578
rule.rdr_from = rdr_from;
1579
rule.rdr_to = rdr_to;
1581
addclientrule(&rule);
1587
#line 756 "config_parse.y"
1588
{ yyval.string = NULL; }
1591
#line 760 "config_parse.y"
1596
rule.rdr_from = rdr_from;
1597
rule.rdr_to = rdr_to;
1599
addsocksrule(&rule);
1604
#line 774 "config_parse.y"
1605
{ checkmodule("bandwidth"); }
1608
#line 778 "config_parse.y"
1609
{ checkmodule("redirect"); }
1612
#line 781 "config_parse.y"
1613
{ yyval.string = NULL; }
1616
#line 792 "config_parse.y"
1620
rule.verdict = VERDICT_BLOCK;
1624
#line 797 "config_parse.y"
1627
rule.verdict = VERDICT_PASS;
1632
#line 808 "config_parse.y"
1638
#line 811 "config_parse.y"
1640
command->connect = 1;
1644
#line 814 "config_parse.y"
1646
command->udpassociate = 1;
1650
#line 820 "config_parse.y"
1652
command->bindreply = 1;
1656
#line 824 "config_parse.y"
1658
command->udpreply = 1;
1662
#line 836 "config_parse.y"
1668
#line 839 "config_parse.y"
1674
#line 856 "config_parse.y"
1677
static bw_t bwmeminit;
1680
* temporarily allocate ordinary memory, later on point it to
1681
* the correct index in sockscf.bwv.
1683
if ((rule.bw = (bw_t *)malloc(sizeof(*rule.bw))) == NULL)
1684
serr(EXIT_FAILURE, NOMEM);
1685
*rule.bw = bwmeminit;
1686
rule.bw->maxbps = atoi(yyvsp[0].string);
1687
#endif /* SOCKS_SERVER */
1691
#line 876 "config_parse.y"
1694
rule.log.connect = 1;
1698
#line 880 "config_parse.y"
1704
#line 883 "config_parse.y"
1706
rule.log.disconnect = 1;
1710
#line 886 "config_parse.y"
1716
#line 889 "config_parse.y"
1718
rule.log.iooperation = 1;
1723
#line 900 "config_parse.y"
1725
#if HAVE_PAM && SOCKS_SERVER
1726
if (strlen(yyvsp[0].string) >= sizeof(rule.pamservicename))
1727
yyerror("servicename too long");
1728
strcpy(rule.pamservicename, yyvsp[0].string);
1729
#else /* !HAVE_PAM */
1730
yyerror("pamsupport not compiled in");
1731
#endif /* HAVE_PAM */
1735
#line 911 "config_parse.y"
1737
#if HAVE_LIBWRAP && SOCKS_SERVER
1738
struct request_info request;
1739
char libwrap[LIBWRAPBUF];
1741
if (strlen(yyvsp[0].string) >= sizeof(rule.libwrap))
1742
yyerror("libwrapline too long, make LIBWRAPBUF bigger");
1743
strcpy(rule.libwrap, yyvsp[0].string);
1745
/* libwrap modifies the passed buffer. */
1746
SASSERTX(strlen(rule.libwrap) < sizeof(libwrap));
1747
strcpy(libwrap, rule.libwrap);
1750
request_init(&request, RQ_FILE, -1, RQ_DAEMON, __progname, 0);
1751
if (setjmp(tcpd_buf) != 0)
1752
yyerror("bad libwrap line");
1753
process_options(libwrap, &request);
1756
#else /* !HAVE_LIBWRAP */
1757
yyerror("libwrapsupport not compiled in");
1762
#line 961 "config_parse.y"
1763
{ yyval.string = NULL; }
1766
#line 965 "config_parse.y"
1772
#line 970 "config_parse.y"
1778
#line 975 "config_parse.y"
1780
addressinit(&rdr_from);
1784
#line 980 "config_parse.y"
1786
addressinit(&rdr_to);
1790
#line 987 "config_parse.y"
1798
#line 1017 "config_parse.y"
1800
*atype = SOCKS_ADDR_IPV4;
1802
if (inet_aton(yyvsp[0].string, ipaddr) != 1)
1803
yyerror("bad address: %s", yyvsp[0].string);
1807
#line 1026 "config_parse.y"
1809
if (atoi(yyvsp[0].string) < 0 || atoi(yyvsp[0].string) > 32)
1810
yyerror("bad netmask: %d", yyvsp[0].string);
1813
= atoi(yyvsp[0].string) == 0 ? 0 : htonl(0xffffffff << (32 - atoi(yyvsp[0].string)));
1817
#line 1033 "config_parse.y"
1819
if (!inet_aton(yyvsp[0].string, netmask))
1820
yyerror("bad netmask: %s", yyvsp[0].string);
1824
#line 1039 "config_parse.y"
1826
*atype = SOCKS_ADDR_DOMAIN;
1828
if (strlen(yyvsp[0].string) >= MAXHOSTNAMELEN)
1829
yyerror("domainname too long");
1830
strcpy(domain, yyvsp[0].string);
1834
#line 1048 "config_parse.y"
1836
*atype = SOCKS_ADDR_IFNAME;
1838
if (strlen(yyvsp[0].string) >= MAXIFNAMELEN)
1839
yyerror("interfacename too long");
1840
strcpy(ifname, yyvsp[0].string);
1844
#line 1058 "config_parse.y"
1846
*atype = SOCKS_ADDR_DOMAIN;
1848
if (strlen(yyvsp[0].string) >= MAXHOSTNAMELEN)
1849
yyerror("domainname too long");
1850
strcpy(domain, yyvsp[0].string);
1853
route.state.direct = 1;
1858
#line 1071 "config_parse.y"
1859
{ yyval.string = NULL; }
1862
#line 1084 "config_parse.y"
1864
*port_tcp = htons((in_port_t)atoi(yyvsp[0].string));
1865
*port_udp = htons((in_port_t)atoi(yyvsp[0].string));
1869
#line 1090 "config_parse.y"
1871
ruleaddress->portend = htons((in_port_t)atoi(yyvsp[0].string));
1872
ruleaddress->operator = range;
1876
#line 1096 "config_parse.y"
1878
struct servent *service;
1879
struct protocol_t protocolunset;
1882
bzero(&protocolunset, sizeof(protocolunset));
1884
/* set all protocols if none set, default. */
1885
if (memcmp(protocol, &protocolunset, sizeof(*protocol)) == 0) {
1886
memset(protocol, UCHAR_MAX, sizeof(*protocol));
1892
if (protocol->tcp) {
1893
if ((service = getservbyname(yyvsp[0].string, "tcp")) == NULL) {
1895
yyerror("bad servicename for tcp: %s", yyvsp[0].string);
1897
*port_tcp = htons(0);
1900
*port_tcp = (in_port_t)service->s_port;
1903
if (protocol->udp) {
1904
if ((service = getservbyname(yyvsp[0].string, "udp")) == NULL) {
1906
yyerror("bad servicename for udp: %s", yyvsp[0].string);
1908
*port_udp = htons(0);
1911
*port_udp = (in_port_t)service->s_port;
1914
/* check we got both protocol ports set right. */
1915
if (*port_tcp == htons(0) && *port_udp == htons(0))
1916
yyerror("bad service name for tcp/udp");
1917
if (*port_tcp == htons(0))
1918
*port_tcp = *port_udp;
1919
else if (*port_udp == htons(0))
1920
*port_udp = *port_tcp;
1924
#line 1144 "config_parse.y"
1926
*operator = string2operator(yyvsp[0].string);
1929
#line 1921 "y.tab.c"
1935
if (yystate == 0 && yym == 0)
1939
printf("%sdebug: after reduction, shifting from state 0 to\
1940
state %d\n", YYPREFIX, YYFINAL);
1947
if ((yychar = yylex()) < 0) yychar = 0;
1952
if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
1953
if (!yys) yys = "illegal-symbol";
1954
printf("%sdebug: state %d, reading %d (%s)\n",
1955
YYPREFIX, YYFINAL, yychar, yys);
1959
if (yychar == 0) goto yyaccept;
1962
if ((yyn = yygindex[yym]) && (yyn += yystate) >= 0 &&
1963
yyn <= YYTABLESIZE && yycheck[yyn] == yystate)
1964
yystate = yytable[yyn];
1966
yystate = yydgoto[yym];
1969
printf("%sdebug: after reduction, shifting from state %d \
1970
to state %d\n", YYPREFIX, *yyssp, yystate);
1972
if (yyssp >= yysslim && yygrowstack())
1980
yyerror("yacc stack overflow");