~ubuntu-branches/ubuntu/trusty/dante/trusty-proposed

« back to all changes in this revision

Viewing changes to sockd/config_parse.c

  • Committer: Bazaar Package Importer
  • Author(s): Adrian Bridgett
  • Date: 2002-04-07 12:45:55 UTC
  • Revision ID: james.westby@ubuntu.com-20020407124555-qke8rt2tdor0naz2
Tags: upstream-1.1.11.12p1
ImportĀ upstreamĀ versionĀ 1.1.11.12p1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#ifndef lint
 
2
/*static char yysccsid[] = "from: @(#)yaccpar   1.9 (Berkeley) 02/21/93";*/
 
3
static char yyrcsid[]
 
4
#if __GNUC__ == 2
 
5
  __attribute__ ((unused))
 
6
#endif /* __GNUC__ == 2 */
 
7
  = "$OpenBSD: skeleton.c,v 1.16 2001/02/26 00:03:33 tholo Exp $";
 
8
#endif
 
9
#include <stdlib.h>
 
10
#define YYBYACC 1
 
11
#define YYMAJOR 1
 
12
#define YYMINOR 9
 
13
#define YYLEX yylex()
 
14
#define YYEMPTY -1
 
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"
 
46
 
 
47
#include "common.h"
 
48
 
 
49
#include "yacconfig.h"
 
50
 
 
51
static const char rcsid[] =
 
52
"$Id: config_parse.y,v 1.180 2001/12/12 14:42:10 karls Exp $";
 
53
 
 
54
__BEGIN_DECLS
 
55
 
 
56
#if HAVE_LIBWRAP && SOCKS_SERVER
 
57
        extern jmp_buf tcpd_buf;
 
58
#endif /* HAVE_LIBWRAP && SOCKS_SERVER */
 
59
 
 
60
static void
 
61
addressinit __P((struct ruleaddress_t *address));
 
62
 
 
63
#if SOCKS_SERVER
 
64
static void
 
65
ruleinit __P((struct rule_t *rule));
 
66
#endif
 
67
 
 
68
__END_DECLS
 
69
 
 
70
extern int yylineno;
 
71
extern char *yytext;
 
72
 
 
73
#if SOCKS_SERVER
 
74
static struct rule_t                            ruleinitmem;
 
75
static struct rule_t                            rule;                           /* new rule.                                                    */
 
76
static struct protocol_t                protocolmem;    /* new protocolmem.                                     */
 
77
#endif
 
78
 
 
79
#if SOCKS_CLIENT
 
80
static struct serverstate_t     state;
 
81
static struct route_t                   route;                  /* new route.                                                   */
 
82
static struct ruleaddress_t     gw;                             /* new gateway.                                         */
 
83
#endif
 
84
 
 
85
 
 
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;
 
90
 
 
91
static struct ruleaddress_t     *ruleaddress;   /* current ruleaddress                          */
 
92
static struct extension_t               *extension;             /* new extensions                                               */
 
93
static struct proxyprotocol_t   *proxyprotocol;/* proxy protocol.                                       */
 
94
 
 
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.                                                  */
 
100
 
 
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.                                                */
 
108
 
 
109
static const struct {
 
110
        const char *name;
 
111
        const int value;
 
112
} syslogfacilityv[] = {
 
113
#ifdef LOG_AUTH
 
114
        { "auth",       LOG_AUTH                },
 
115
#endif /* LOG_AUTH */
 
116
#ifdef LOG_AUTHPRIV
 
117
        { "authpriv",   LOG_AUTHPRIV            },
 
118
#endif /* LOG_AUTHPRIV */
 
119
#ifdef LOG_DAEMON
 
120
        { "daemon",     LOG_DAEMON      },
 
121
#endif /* LOG_DAEMON */
 
122
#ifdef LOG_USER
 
123
        { "user",       LOG_USER                },
 
124
#endif /* LOG_USER */
 
125
#ifdef LOG_LOCAL0
 
126
        { "local0",     LOG_LOCAL0      },
 
127
#endif /* LOG_LOCAL0 */
 
128
#ifdef LOG_LOCAL1
 
129
        { "local1",     LOG_LOCAL1      },
 
130
#endif /* LOG_LOCAL1 */
 
131
#ifdef LOG_LOCAL2
 
132
        { "local2",     LOG_LOCAL2      },
 
133
#endif /* LOG_LOCAL2 */
 
134
#ifdef LOG_LOCAL3
 
135
        { "local3",     LOG_LOCAL3      },
 
136
#endif /* LOG_LOCAL3 */
 
137
#ifdef LOG_LOCAL4
 
138
        { "local4",     LOG_LOCAL4      },
 
139
#endif /* LOG_LOCAL4 */
 
140
#ifdef LOG_LOCAL5
 
141
        { "local5",     LOG_LOCAL5      },
 
142
#endif /* LOG_LOCAL5 */
 
143
#ifdef LOG_LOCAL6
 
144
        { "local6",     LOG_LOCAL6      },
 
145
#endif /* LOG_LOCAL6 */
 
146
#ifdef LOG_LOCAL7
 
147
        { "local7",     LOG_LOCAL7      }
 
148
#endif /* LOG_LOCAL7 */
 
149
};
 
150
 
 
151
 
 
152
#define YYDEBUG 1
 
153
 
 
154
#define ADDMETHOD(method) \
 
155
        do { \
 
156
                if (methodisset(method, methodv, *methodc)) \
 
157
                        yywarn("duplicate method: %s", method2string(method)); \
 
158
                else { \
 
159
                        if (*methodc >= MAXMETHOD)      \
 
160
                                yyerror("internal error");      \
 
161
                        methodv[(*methodc)++] = method; \
 
162
                } \
 
163
        } while (0)
 
164
 
 
165
#line 166 "config_parse.y"
 
166
typedef union {
 
167
        char    *string;
 
168
        uid_t   uid;
 
169
} YYSTYPE;
 
170
#line 171 "y.tab.c"
 
171
#define SERVERCONFIG 257
 
172
#define CLIENTCONFIG 258
 
173
#define DEPRECATED 259
 
174
#define CLIENTRULE 260
 
175
#define INTERNAL 261
 
176
#define EXTERNAL 262
 
177
#define EXTERNAL_ROTATION 263
 
178
#define DEBUGING 264
 
179
#define RESOLVEPROTOCOL 265
 
180
#define SRCHOST 266
 
181
#define NOMISMATCH 267
 
182
#define NOUNKNOWN 268
 
183
#define EXTENSION 269
 
184
#define BIND 270
 
185
#define PRIVILEGED 271
 
186
#define IOTIMEOUT 272
 
187
#define CONNECTTIMEOUT 273
 
188
#define METHOD 274
 
189
#define CLIENTMETHOD 275
 
190
#define NONE 276
 
191
#define GSSAPI 277
 
192
#define UNAME 278
 
193
#define RFC931 279
 
194
#define PAM 280
 
195
#define COMPATIBILITY 281
 
196
#define REUSEADDR 282
 
197
#define SAMEPORT 283
 
198
#define USERNAME 284
 
199
#define USER_PRIVILEGED 285
 
200
#define USER_UNPRIVILEGED 286
 
201
#define USER_LIBWRAP 287
 
202
#define LOGOUTPUT 288
 
203
#define LOGFILE 289
 
204
#define ROUTE 290
 
205
#define VIA 291
 
206
#define VERDICT_BLOCK 292
 
207
#define VERDICT_PASS 293
 
208
#define PAMSERVICENAME 294
 
209
#define PROTOCOL 295
 
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
 
218
#define USER 304
 
219
#define COMMAND 305
 
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
 
225
#define ACTION 311
 
226
#define LINE 312
 
227
#define LIBWRAPSTART 313
 
228
#define OPERATOR 314
 
229
#define LOG 315
 
230
#define LOG_CONNECT 316
 
231
#define LOG_DATA 317
 
232
#define LOG_DISCONNECT 318
 
233
#define LOG_ERROR 319
 
234
#define LOG_IOOPERATION 320
 
235
#define IPADDRESS 321
 
236
#define DOMAINNAME 322
 
237
#define DIRECT 323
 
238
#define IFNAME 324
 
239
#define PORT 325
 
240
#define PORTNUMBER 326
 
241
#define SERVICENAME 327
 
242
#define NUMBER 328
 
243
#define FROM 329
 
244
#define TO 330
 
245
#define REDIRECT 331
 
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,
 
268
};
 
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,
 
289
};
 
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,
 
319
  172,  168,
 
320
};
 
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,
 
332
  276,
 
333
};
 
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,
 
363
    0,    0,
 
364
};
 
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,
 
394
    0,    0,
 
395
};
 
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,
 
407
    0,
 
408
};
 
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,
 
477
};
 
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,
 
545
};
 
546
#define YYFINAL 3
 
547
#ifndef YYDEBUG
 
548
#define YYDEBUG 0
 
549
#endif
 
550
#define YYMAXTOKEN 332
 
551
#if YYDEBUG
 
552
#if defined(__cplusplus) || __STDC__
 
553
const char * const socks_yyname[] =
 
554
#else
 
555
char *socks_yyname[] =
 
556
#endif
 
557
        {
 
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",
 
579
};
 
580
#if defined(__cplusplus) || __STDC__
 
581
const char * const socks_yyrule[] =
 
582
#else
 
583
char *socks_yyrule[] =
 
584
#endif
 
585
        {"$accept : configtype",
 
586
"configtype : serverinit serverline",
 
587
"configtype : clientinit clientline",
 
588
"serverinit : SERVERCONFIG",
 
589
"serverline :",
 
590
"serverline : serverline '\\n'",
 
591
"serverline : serverline serverconfig",
 
592
"serverline : serverline clientrule",
 
593
"serverline : serverline rule",
 
594
"clientline :",
 
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 '}'",
 
618
"routeinit :",
 
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",
 
635
"internalinit :",
 
636
"external : EXTERNAL externalinit ':' externaladdress",
 
637
"externalinit :",
 
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",
 
653
"userid : USERNAME",
 
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",
 
672
"$$1 :",
 
673
"global_authmethod : METHOD ':' $$1 authmethods",
 
674
"$$2 :",
 
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",
 
694
"ruleoptions :",
 
695
"ruleoptions : ruleoption ruleoptions",
 
696
"option : authmethod",
 
697
"option : libwrap",
 
698
"option : log",
 
699
"option : pamservicename",
 
700
"option : user",
 
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",
 
726
"logs : logname",
 
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",
 
740
"routeoptions :",
 
741
"routeoptions : routeoption routeoptions",
 
742
"from : FROM",
 
743
"to : TO",
 
744
"rdr_from : FROM",
 
745
"rdr_to : TO",
 
746
"via : VIA",
 
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",
 
760
"netmask : NUMBER",
 
761
"netmask : IPADDRESS",
 
762
"domain : DOMAINNAME",
 
763
"ifname : IFNAME",
 
764
"direct : DIRECT",
 
765
"port :",
 
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",
 
775
};
 
776
#endif
 
777
#ifdef YYSTACKSIZE
 
778
#undef YYMAXDEPTH
 
779
#define YYMAXDEPTH YYSTACKSIZE
 
780
#else
 
781
#ifdef YYMAXDEPTH
 
782
#define YYSTACKSIZE YYMAXDEPTH
 
783
#else
 
784
#define YYSTACKSIZE 10000
 
785
#define YYMAXDEPTH 10000
 
786
#endif
 
787
#endif
 
788
#define YYINITSTACKSIZE 200
 
789
int yydebug;
 
790
int yynerrs;
 
791
int yyerrflag;
 
792
int yychar;
 
793
short *yyssp;
 
794
YYSTYPE *yyvsp;
 
795
YYSTYPE yyval;
 
796
YYSTYPE yylval;
 
797
short *yyss;
 
798
short *yysslim;
 
799
YYSTYPE *yyvs;
 
800
int yystacksize;
 
801
#line 1150 "config_parse.y"
 
802
 
 
803
#define INTERACTIVE             0
 
804
 
 
805
extern FILE *yyin;
 
806
 
 
807
int socks_parseinit;
 
808
 
 
809
int
 
810
readconfig(filename)
 
811
        const char *filename;
 
812
{
 
813
        const char *function = "readconfig()";
 
814
        const int errno_s = errno;
 
815
 
 
816
/*      yydebug                         = 1;          */
 
817
        yylineno                                = 1;
 
818
        socks_parseinit = 0;
 
819
 
 
820
        if ((yyin = fopen(filename, "r")) == NULL) {
 
821
                swarn("%s: %s", function, filename);
 
822
                return -1;
 
823
        }
 
824
 
 
825
        yyparse();
 
826
        fclose(yyin);
 
827
 
 
828
        errno = errno_s; /* some buggy yacc's alter errno sometimes. */
 
829
 
 
830
        return 0;
 
831
}
 
832
 
 
833
 
 
834
void
 
835
#ifdef STDC_HEADERS
 
836
yyerror(const char *fmt, ...)
 
837
#else
 
838
yyerror(fmt, va_alist)
 
839
        const char *fmt;
 
840
        va_dcl
 
841
#endif  /* STDC_HEADERS */
 
842
{
 
843
        va_list ap;
 
844
        char buf[2048];
 
845
        size_t bufused;
 
846
 
 
847
#ifdef STDC_HEADERS
 
848
                /* LINTED pointer casts may be troublesome */
 
849
                va_start(ap, fmt);
 
850
#else
 
851
                va_start(ap);
 
852
#endif  /* STDC_HEADERS */
 
853
 
 
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);
 
858
 
 
859
        vsnprintf(&buf[bufused], sizeof(buf) - bufused, fmt, ap);
 
860
 
 
861
        /* LINTED expression has null effect */
 
862
        va_end(ap);
 
863
 
 
864
        if (errno)
 
865
                serr(EXIT_FAILURE, buf);
 
866
        serrx(EXIT_FAILURE, buf);
 
867
}
 
868
 
 
869
void
 
870
#ifdef STDC_HEADERS
 
871
yywarn(const char *fmt, ...)
 
872
#else
 
873
yywarn(fmt, va_alist)
 
874
        const char *fmt;
 
875
        va_dcl
 
876
#endif  /* STDC_HEADERS */
 
877
{
 
878
        va_list ap;
 
879
        char buf[2048];
 
880
        size_t bufused;
 
881
 
 
882
#ifdef STDC_HEADERS
 
883
                /* LINTED pointer casts may be troublesome */
 
884
                va_start(ap, fmt);
 
885
#else
 
886
                va_start(ap);
 
887
#endif  /* STDC_HEADERS */
 
888
 
 
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);
 
893
 
 
894
        vsnprintf(&buf[bufused], sizeof(buf) - bufused, fmt, ap);
 
895
 
 
896
        /* LINTED expression has null effect */
 
897
        va_end(ap);
 
898
 
 
899
        if (errno)
 
900
                swarn(buf);
 
901
        swarnx(buf);
 
902
}
 
903
 
 
904
static void
 
905
addressinit(address)
 
906
        struct ruleaddress_t *address;
 
907
{
 
908
                ruleaddress     = address;
 
909
 
 
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;
 
918
}
 
919
 
 
920
 
 
921
#if SOCKS_SERVER
 
922
static void
 
923
ruleinit(rule)
 
924
        struct rule_t *rule;
 
925
{
 
926
        rule->linenumber = yylineno;
 
927
 
 
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;
 
933
 
 
934
        bzero(&src, sizeof(src));
 
935
        bzero(&dst, sizeof(dst));
 
936
        *rule = ruleinitmem;
 
937
 
 
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);
 
941
 
 
942
        dst = rdr_from = rdr_to = src;
 
943
}
 
944
#endif
 
945
#line 937 "y.tab.c"
 
946
/* allocate initial stack or double stack size, up to YYMAXDEPTH */
 
947
#if defined(__cplusplus) || __STDC__
 
948
static int yygrowstack(void)
 
949
#else
 
950
static int yygrowstack()
 
951
#endif
 
952
{
 
953
    int newsize, i;
 
954
    short *newss;
 
955
    YYSTYPE *newvs;
 
956
 
 
957
    if ((newsize = yystacksize) == 0)
 
958
        newsize = YYINITSTACKSIZE;
 
959
    else if (newsize >= YYMAXDEPTH)
 
960
        return -1;
 
961
    else if ((newsize *= 2) > YYMAXDEPTH)
 
962
        newsize = YYMAXDEPTH;
 
963
    i = yyssp - yyss;
 
964
    newss = yyss ? (short *)realloc(yyss, newsize * sizeof *newss) :
 
965
      (short *)malloc(newsize * sizeof *newss);
 
966
    if (newss == NULL)
 
967
        goto bail;
 
968
    yyss = newss;
 
969
    yyssp = newss + i;
 
970
    newvs = yyvs ? (YYSTYPE *)realloc(yyvs, newsize * sizeof *newvs) :
 
971
      (YYSTYPE *)malloc(newsize * sizeof *newvs);
 
972
    if (newvs == NULL)
 
973
        goto bail;
 
974
    yyvs = newvs;
 
975
    yyvsp = newvs + i;
 
976
    yystacksize = newsize;
 
977
    yysslim = yyss + newsize - 1;
 
978
    return 0;
 
979
bail:
 
980
    if (yyss)
 
981
            free(yyss);
 
982
    if (yyvs)
 
983
            free(yyvs);
 
984
    yyss = yyssp = NULL;
 
985
    yyvs = yyvsp = NULL;
 
986
    yystacksize = 0;
 
987
    return -1;
 
988
}
 
989
 
 
990
#define YYABORT goto yyabort
 
991
#define YYREJECT goto yyabort
 
992
#define YYACCEPT goto yyaccept
 
993
#define YYERROR goto yyerrlab
 
994
int
 
995
#if defined(__cplusplus) || __STDC__
 
996
yyparse(void)
 
997
#else
 
998
yyparse()
 
999
#endif
 
1000
{
 
1001
    register int yym, yyn, yystate;
 
1002
#if YYDEBUG
 
1003
#if defined(__cplusplus) || __STDC__
 
1004
    register const char *yys;
 
1005
#else /* !(defined(__cplusplus) || __STDC__) */
 
1006
    register char *yys;
 
1007
#endif /* !(defined(__cplusplus) || __STDC__) */
 
1008
 
 
1009
    if ((yys = getenv("YYDEBUG")))
 
1010
    {
 
1011
        yyn = *yys;
 
1012
        if (yyn >= '0' && yyn <= '9')
 
1013
            yydebug = yyn - '0';
 
1014
    }
 
1015
#endif /* YYDEBUG */
 
1016
 
 
1017
    yynerrs = 0;
 
1018
    yyerrflag = 0;
 
1019
    yychar = (-1);
 
1020
 
 
1021
    if (yyss == NULL && yygrowstack()) goto yyoverflow;
 
1022
    yyssp = yyss;
 
1023
    yyvsp = yyvs;
 
1024
    *yyssp = yystate = 0;
 
1025
 
 
1026
yyloop:
 
1027
    if ((yyn = yydefred[yystate]) != 0) goto yyreduce;
 
1028
    if (yychar < 0)
 
1029
    {
 
1030
        if ((yychar = yylex()) < 0) yychar = 0;
 
1031
#if YYDEBUG
 
1032
        if (yydebug)
 
1033
        {
 
1034
            yys = 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);
 
1039
        }
 
1040
#endif
 
1041
    }
 
1042
    if ((yyn = yysindex[yystate]) && (yyn += yychar) >= 0 &&
 
1043
            yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
 
1044
    {
 
1045
#if YYDEBUG
 
1046
        if (yydebug)
 
1047
            printf("%sdebug: state %d, shifting to state %d\n",
 
1048
                    YYPREFIX, yystate, yytable[yyn]);
 
1049
#endif
 
1050
        if (yyssp >= yysslim && yygrowstack())
 
1051
        {
 
1052
            goto yyoverflow;
 
1053
        }
 
1054
        *++yyssp = yystate = yytable[yyn];
 
1055
        *++yyvsp = yylval;
 
1056
        yychar = (-1);
 
1057
        if (yyerrflag > 0)  --yyerrflag;
 
1058
        goto yyloop;
 
1059
    }
 
1060
    if ((yyn = yyrindex[yystate]) && (yyn += yychar) >= 0 &&
 
1061
            yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
 
1062
    {
 
1063
        yyn = yytable[yyn];
 
1064
        goto yyreduce;
 
1065
    }
 
1066
    if (yyerrflag) goto yyinrecovery;
 
1067
#if defined(lint) || defined(__GNUC__)
 
1068
    goto yynewerror;
 
1069
#endif
 
1070
yynewerror:
 
1071
    yyerror("syntax error");
 
1072
#if defined(lint) || defined(__GNUC__)
 
1073
    goto yyerrlab;
 
1074
#endif
 
1075
yyerrlab:
 
1076
    ++yynerrs;
 
1077
yyinrecovery:
 
1078
    if (yyerrflag < 3)
 
1079
    {
 
1080
        yyerrflag = 3;
 
1081
        for (;;)
 
1082
        {
 
1083
            if ((yyn = yysindex[*yyssp]) && (yyn += YYERRCODE) >= 0 &&
 
1084
                    yyn <= YYTABLESIZE && yycheck[yyn] == YYERRCODE)
 
1085
            {
 
1086
#if YYDEBUG
 
1087
                if (yydebug)
 
1088
                    printf("%sdebug: state %d, error recovery shifting\
 
1089
 to state %d\n", YYPREFIX, *yyssp, yytable[yyn]);
 
1090
#endif
 
1091
                if (yyssp >= yysslim && yygrowstack())
 
1092
                {
 
1093
                    goto yyoverflow;
 
1094
                }
 
1095
                *++yyssp = yystate = yytable[yyn];
 
1096
                *++yyvsp = yylval;
 
1097
                goto yyloop;
 
1098
            }
 
1099
            else
 
1100
            {
 
1101
#if YYDEBUG
 
1102
                if (yydebug)
 
1103
                    printf("%sdebug: error recovery discarding state %d\n",
 
1104
                            YYPREFIX, *yyssp);
 
1105
#endif
 
1106
                if (yyssp <= yyss) goto yyabort;
 
1107
                --yyssp;
 
1108
                --yyvsp;
 
1109
            }
 
1110
        }
 
1111
    }
 
1112
    else
 
1113
    {
 
1114
        if (yychar == 0) goto yyabort;
 
1115
#if YYDEBUG
 
1116
        if (yydebug)
 
1117
        {
 
1118
            yys = 0;
 
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);
 
1123
        }
 
1124
#endif
 
1125
        yychar = (-1);
 
1126
        goto yyloop;
 
1127
    }
 
1128
yyreduce:
 
1129
#if YYDEBUG
 
1130
    if (yydebug)
 
1131
        printf("%sdebug: state %d, reducing by rule %d (%s)\n",
 
1132
                YYPREFIX, yystate, yyn, yyrule[yyn]);
 
1133
#endif
 
1134
    yym = yylen[yyn];
 
1135
    yyval = yyvsp[1-yym];
 
1136
    switch (yyn)
 
1137
    {
 
1138
case 3:
 
1139
#line 270 "config_parse.y"
 
1140
{
 
1141
#if SOCKS_SERVER
 
1142
                protocol                        = &protocolmem;
 
1143
                extension               = &sockscf.extension;
 
1144
#endif
 
1145
        }
 
1146
break;
 
1147
case 4:
 
1148
#line 279 "config_parse.y"
 
1149
{ yyval.string = NULL; }
 
1150
break;
 
1151
case 9:
 
1152
#line 286 "config_parse.y"
 
1153
{ yyval.string = NULL; }
 
1154
break;
 
1155
case 13:
 
1156
#line 293 "config_parse.y"
 
1157
{
 
1158
        }
 
1159
break;
 
1160
case 31:
 
1161
#line 321 "config_parse.y"
 
1162
{
 
1163
                yywarn("given keyword is deprecated");
 
1164
        }
 
1165
break;
 
1166
case 32:
 
1167
#line 325 "config_parse.y"
 
1168
{
 
1169
#if SOCKS_CLIENT
 
1170
                route.src               = src;
 
1171
                route.dst               = dst;
 
1172
                ruleaddress2sockshost(&gw, &route.gw.host, SOCKS_TCP);
 
1173
                route.gw.state  = state;
 
1174
 
 
1175
                addroute(&route);
 
1176
#endif
 
1177
        }
 
1178
break;
 
1179
case 33:
 
1180
#line 337 "config_parse.y"
 
1181
{
 
1182
#if SOCKS_CLIENT
 
1183
                command                 = &state.command;
 
1184
                extension               = &state.extension;
 
1185
                methodv                 = state.methodv;
 
1186
                methodc                 = &state.methodc;
 
1187
                protocol                        = &state.protocol;
 
1188
                proxyprotocol   = &state.proxyprotocol;
 
1189
 
 
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;
 
1197
#endif
 
1198
        }
 
1199
break;
 
1200
case 35:
 
1201
#line 361 "config_parse.y"
 
1202
{
 
1203
                        proxyprotocol->socks_v4         = 1;
 
1204
        }
 
1205
break;
 
1206
case 36:
 
1207
#line 364 "config_parse.y"
 
1208
{
 
1209
                        proxyprotocol->socks_v5         = 1;
 
1210
        }
 
1211
break;
 
1212
case 37:
 
1213
#line 367 "config_parse.y"
 
1214
{
 
1215
                        proxyprotocol->msproxy_v2       = 1;
 
1216
        }
 
1217
break;
 
1218
case 38:
 
1219
#line 370 "config_parse.y"
 
1220
{
 
1221
                        proxyprotocol->http_v1_0        = 1;
 
1222
        }
 
1223
break;
 
1224
case 42:
 
1225
#line 382 "config_parse.y"
 
1226
{
 
1227
#if SOCKS_SERVER
 
1228
#if !HAVE_LIBWRAP
 
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)
 
1233
                        yyerror(NOMEM);
 
1234
#endif /* SOCKS_SERVER */
 
1235
        }
 
1236
break;
 
1237
case 46:
 
1238
#line 401 "config_parse.y"
 
1239
{
 
1240
                        extension->bind = 1;
 
1241
        }
 
1242
break;
 
1243
case 49:
 
1244
#line 411 "config_parse.y"
 
1245
{
 
1246
#if SOCKS_SERVER
 
1247
                addinternal(ruleaddress);
 
1248
#endif
 
1249
        }
 
1250
break;
 
1251
case 50:
 
1252
#line 418 "config_parse.y"
 
1253
{
 
1254
#if SOCKS_SERVER
 
1255
        static struct ruleaddress_t mem;
 
1256
        struct servent  *service;
 
1257
 
 
1258
        addressinit(&mem);
 
1259
 
 
1260
        /* set default port. */
 
1261
        if ((service = getservbyname("socks", "tcp")) == NULL)
 
1262
                *port_tcp = htons(SOCKD_PORT);
 
1263
        else
 
1264
                *port_tcp = (in_port_t)service->s_port;
 
1265
#endif
 
1266
        }
 
1267
break;
 
1268
case 51:
 
1269
#line 434 "config_parse.y"
 
1270
{
 
1271
#if SOCKS_SERVER
 
1272
                addexternal(ruleaddress);
 
1273
#endif
 
1274
        }
 
1275
break;
 
1276
case 52:
 
1277
#line 441 "config_parse.y"
 
1278
{
 
1279
#if SOCKS_SERVER
 
1280
                static struct ruleaddress_t mem;
 
1281
 
 
1282
                addressinit(&mem);
 
1283
#endif
 
1284
        }
 
1285
break;
 
1286
case 53:
 
1287
#line 450 "config_parse.y"
 
1288
{
 
1289
#if SOCKS_SERVER
 
1290
                sockscf.external.rotation = ROTATION_NONE;
 
1291
        }
 
1292
break;
 
1293
case 54:
 
1294
#line 454 "config_parse.y"
 
1295
{
 
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 */
 
1302
        }
 
1303
break;
 
1304
case 59:
 
1305
#line 472 "config_parse.y"
 
1306
{
 
1307
                const char *syslogname = "syslog";
 
1308
 
 
1309
                if (strncmp(yyvsp[0].string, syslogname, strlen(syslogname)) == 0
 
1310
                && (yyvsp[0].string[strlen(syslogname)] == NUL || yyvsp[0].string[strlen(syslogname)] == '/')) {
 
1311
                        char *sl;
 
1312
 
 
1313
                        sockscf.log.type |= LOGTYPE_SYSLOG;
 
1314
 
 
1315
                        if (*(sl = &(yyvsp[0].string[strlen(syslogname)])) == '/') { /* facility. */
 
1316
                                size_t i;
 
1317
 
 
1318
                                for (i = 0, ++sl; i < ELEMENTS(syslogfacilityv); ++i)
 
1319
                                        if (strcmp(sl, syslogfacilityv[i].name) == 0)
 
1320
                                                break;
 
1321
 
 
1322
                                if (i == ELEMENTS(syslogfacilityv))
 
1323
                                        yyerror("unknown syslog facility \"%s\"", sl);
 
1324
 
 
1325
                                sockscf.log.facility = syslogfacilityv[i].value;
 
1326
                                sockscf.log.facilityname = syslogfacilityv[i].name;
 
1327
                        }
 
1328
                        else {
 
1329
                                sockscf.log.facility = LOG_DAEMON; /* default. */
 
1330
                                sockscf.log.facilityname = "daemon";
 
1331
                        }
 
1332
                }
 
1333
                else /* adding/changing filename. */
 
1334
                        if (!sockscf.state.init) {
 
1335
                                /*
 
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.
 
1339
                                 */
 
1340
                                int flag;
 
1341
 
 
1342
                                sockscf.log.type |= LOGTYPE_FILE;
 
1343
 
 
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)))
 
1350
                                == NULL)
 
1351
                                        serrx(EXIT_FAILURE, NOMEM);
 
1352
 
 
1353
                                if ((sockscf.log.fplockv[sockscf.log.fpc]
 
1354
                                = socks_mklock(SOCKS_LOCKFILE)) == -1)
 
1355
                                        serr(EXIT_FAILURE, "socks_mklock()");
 
1356
 
 
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;
 
1361
                                else
 
1362
                                        if ((sockscf.log.fpv[sockscf.log.fpc] = fopen(yyvsp[0].string, "a"))
 
1363
                                        == NULL)
 
1364
                                                yyerror("fopen(%s)", yyvsp[0].string);
 
1365
 
 
1366
                                if ((flag = fcntl(fileno(sockscf.log.fpv[sockscf.log.fpc]),
 
1367
                                F_GETFD, 0)) == -1
 
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)");
 
1371
 
 
1372
                                if ((sockscf.log.fnamev[sockscf.log.fpc] = strdup(yyvsp[0].string)) == NULL)
 
1373
                                        serr(EXIT_FAILURE, NOMEM);
 
1374
 
 
1375
                                ++sockscf.log.fpc;
 
1376
                        }
 
1377
                        else {
 
1378
                                size_t i;
 
1379
 
 
1380
                                for (i = 0; i < sockscf.log.fpc; ++i)
 
1381
                                        if (strcmp(sockscf.log.fnamev[i], yyvsp[0].string) == 0) {
 
1382
 
 
1383
                                                if (fileno(sockscf.log.fpv[i]) == fileno(stdout)
 
1384
                                                ||       fileno(sockscf.log.fpv[i]) == fileno(stderr))
 
1385
                                                        break;
 
1386
 
 
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);
 
1392
                                                break;
 
1393
                                        }
 
1394
 
 
1395
                                if (i == sockscf.log.fpc) /* no match found. */
 
1396
                                        yywarn("can't change logoutput after startup");
 
1397
                        }
 
1398
        }
 
1399
break;
 
1400
case 65:
 
1401
#line 576 "config_parse.y"
 
1402
{
 
1403
#if SOCKS_SERVER
 
1404
                sockscf.uid.privileged                  = yyvsp[0].uid;
 
1405
                sockscf.uid.privileged_isset    = 1;
 
1406
#endif
 
1407
        }
 
1408
break;
 
1409
case 66:
 
1410
#line 584 "config_parse.y"
 
1411
{
 
1412
#if SOCKS_SERVER
 
1413
                sockscf.uid.unprivileged                        = yyvsp[0].uid;
 
1414
                sockscf.uid.unprivileged_isset  = 1;
 
1415
#endif
 
1416
        }
 
1417
break;
 
1418
case 67:
 
1419
#line 592 "config_parse.y"
 
1420
{
 
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 */
 
1427
        }
 
1428
break;
 
1429
case 68:
 
1430
#line 603 "config_parse.y"
 
1431
{
 
1432
                struct passwd *pw;
 
1433
 
 
1434
                if ((pw = getpwnam(yyvsp[0].string)) == NULL)
 
1435
                        serrx(EXIT_FAILURE, "no such user \"%s\"", yyvsp[0].string);
 
1436
                else
 
1437
                        yyval.uid = pw->pw_uid;
 
1438
        }
 
1439
break;
 
1440
case 69:
 
1441
#line 613 "config_parse.y"
 
1442
{
 
1443
#if SOCKS_SERVER
 
1444
                sockscf.timeout.io = (time_t)atol(yyvsp[0].string);
 
1445
#endif
 
1446
        }
 
1447
break;
 
1448
case 70:
 
1449
#line 620 "config_parse.y"
 
1450
{
 
1451
#if SOCKS_SERVER
 
1452
                sockscf.timeout.negotiate = (time_t)atol(yyvsp[0].string);
 
1453
#endif
 
1454
        }
 
1455
break;
 
1456
case 71:
 
1457
#line 627 "config_parse.y"
 
1458
{
 
1459
                sockscf.option.debug = atoi(yyvsp[0].string);
 
1460
        }
 
1461
break;
 
1462
case 73:
 
1463
#line 635 "config_parse.y"
 
1464
{
 
1465
#if SOCKS_SERVER
 
1466
                sockscf.compat.reuseaddr = 1;
 
1467
        }
 
1468
break;
 
1469
case 74:
 
1470
#line 639 "config_parse.y"
 
1471
{
 
1472
                sockscf.compat.sameport = 1;
 
1473
#endif
 
1474
        }
 
1475
break;
 
1476
case 78:
 
1477
#line 652 "config_parse.y"
 
1478
{
 
1479
                        sockscf.resolveprotocol = RESOLVEPROTOCOL_FAKE;
 
1480
        }
 
1481
break;
 
1482
case 79:
 
1483
#line 655 "config_parse.y"
 
1484
{
 
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 */
 
1490
        }
 
1491
break;
 
1492
case 80:
 
1493
#line 662 "config_parse.y"
 
1494
{
 
1495
                        sockscf.resolveprotocol = RESOLVEPROTOCOL_UDP;
 
1496
        }
 
1497
break;
 
1498
case 82:
 
1499
#line 670 "config_parse.y"
 
1500
{
 
1501
#if HAVE_LIBWRAP && SOCKS_SERVER
 
1502
                        sockscf.srchost.nomismatch = 1;
 
1503
        }
 
1504
break;
 
1505
case 83:
 
1506
#line 674 "config_parse.y"
 
1507
{
 
1508
                        sockscf.srchost.nounknown = 1;
 
1509
#else
 
1510
                yyerror("srchostoption requires libwrap");
 
1511
#endif
 
1512
        }
 
1513
break;
 
1514
case 87:
 
1515
#line 690 "config_parse.y"
 
1516
{
 
1517
#if SOCKS_SERVER
 
1518
        methodv = sockscf.methodv;
 
1519
        methodc = &sockscf.methodc;
 
1520
        *methodc = 0; /* reset. */
 
1521
#endif
 
1522
        }
 
1523
break;
 
1524
case 89:
 
1525
#line 699 "config_parse.y"
 
1526
{
 
1527
#if SOCKS_SERVER
 
1528
        methodv = sockscf.clientmethodv;
 
1529
        methodc = &sockscf.clientmethodc;
 
1530
        *methodc = 0; /* reset. */
 
1531
#endif
 
1532
        }
 
1533
break;
 
1534
case 91:
 
1535
#line 708 "config_parse.y"
 
1536
{
 
1537
                ADDMETHOD(AUTHMETHOD_NONE);
 
1538
        }
 
1539
break;
 
1540
case 92:
 
1541
#line 711 "config_parse.y"
 
1542
{
 
1543
                yyerror("%s not supported", AUTHMETHOD_GSSAPIs);
 
1544
        }
 
1545
break;
 
1546
case 93:
 
1547
#line 714 "config_parse.y"
 
1548
{
 
1549
                ADDMETHOD(AUTHMETHOD_UNAME);
 
1550
        }
 
1551
break;
 
1552
case 94:
 
1553
#line 717 "config_parse.y"
 
1554
{
 
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 */
 
1560
        }
 
1561
break;
 
1562
case 95:
 
1563
#line 724 "config_parse.y"
 
1564
{
 
1565
#if !HAVE_PAM
 
1566
                yyerror("method %s requires pamlibrary", AUTHMETHOD_PAMs);
 
1567
#else /* HAVE_PAM */
 
1568
                ADDMETHOD(AUTHMETHOD_PAM);
 
1569
#endif /* !HAVE_PAM */
 
1570
        }
 
1571
break;
 
1572
case 98:
 
1573
#line 740 "config_parse.y"
 
1574
{
 
1575
#if SOCKS_SERVER
 
1576
                rule.src                        = src;
 
1577
                rule.dst                        = dst;
 
1578
                rule.rdr_from   = rdr_from;
 
1579
                rule.rdr_to             = rdr_to;
 
1580
 
 
1581
                addclientrule(&rule);
 
1582
 
 
1583
#endif
 
1584
        }
 
1585
break;
 
1586
case 100:
 
1587
#line 756 "config_parse.y"
 
1588
{ yyval.string = NULL; }
 
1589
break;
 
1590
case 102:
 
1591
#line 760 "config_parse.y"
 
1592
{
 
1593
#if SOCKS_SERVER
 
1594
                rule.src                        = src;
 
1595
                rule.dst                        = dst;
 
1596
                rule.rdr_from   = rdr_from;
 
1597
                rule.rdr_to             = rdr_to;
 
1598
 
 
1599
                addsocksrule(&rule);
 
1600
#endif
 
1601
        }
 
1602
break;
 
1603
case 104:
 
1604
#line 774 "config_parse.y"
 
1605
{ checkmodule("bandwidth"); }
 
1606
break;
 
1607
case 108:
 
1608
#line 778 "config_parse.y"
 
1609
{ checkmodule("redirect"); }
 
1610
break;
 
1611
case 109:
 
1612
#line 781 "config_parse.y"
 
1613
{ yyval.string = NULL; }
 
1614
break;
 
1615
case 116:
 
1616
#line 792 "config_parse.y"
 
1617
{
 
1618
#if SOCKS_SERVER
 
1619
                ruleinit(&rule);
 
1620
                rule.verdict    = VERDICT_BLOCK;
 
1621
        }
 
1622
break;
 
1623
case 117:
 
1624
#line 797 "config_parse.y"
 
1625
{
 
1626
                ruleinit(&rule);
 
1627
                rule.verdict    = VERDICT_PASS;
 
1628
#endif
 
1629
        }
 
1630
break;
 
1631
case 119:
 
1632
#line 808 "config_parse.y"
 
1633
{
 
1634
                        command->bind = 1;
 
1635
        }
 
1636
break;
 
1637
case 120:
 
1638
#line 811 "config_parse.y"
 
1639
{
 
1640
                        command->connect = 1;
 
1641
        }
 
1642
break;
 
1643
case 121:
 
1644
#line 814 "config_parse.y"
 
1645
{
 
1646
                        command->udpassociate = 1;
 
1647
        }
 
1648
break;
 
1649
case 122:
 
1650
#line 820 "config_parse.y"
 
1651
{
 
1652
                        command->bindreply = 1;
 
1653
        }
 
1654
break;
 
1655
case 123:
 
1656
#line 824 "config_parse.y"
 
1657
{
 
1658
                        command->udpreply = 1;
 
1659
        }
 
1660
break;
 
1661
case 127:
 
1662
#line 836 "config_parse.y"
 
1663
{
 
1664
                protocol->tcp = 1;
 
1665
        }
 
1666
break;
 
1667
case 128:
 
1668
#line 839 "config_parse.y"
 
1669
{
 
1670
                protocol->udp = 1;
 
1671
        }
 
1672
break;
 
1673
case 134:
 
1674
#line 856 "config_parse.y"
 
1675
{
 
1676
#if SOCKS_SERVER
 
1677
                static bw_t bwmeminit;
 
1678
 
 
1679
     /*
 
1680
                * temporarily allocate ordinary memory, later on point it to
 
1681
                * the correct index in sockscf.bwv.
 
1682
                */
 
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 */
 
1688
        }
 
1689
break;
 
1690
case 136:
 
1691
#line 876 "config_parse.y"
 
1692
{
 
1693
#if SOCKS_SERVER
 
1694
        rule.log.connect = 1;
 
1695
        }
 
1696
break;
 
1697
case 137:
 
1698
#line 880 "config_parse.y"
 
1699
{
 
1700
                        rule.log.data = 1;
 
1701
        }
 
1702
break;
 
1703
case 138:
 
1704
#line 883 "config_parse.y"
 
1705
{
 
1706
                        rule.log.disconnect = 1;
 
1707
        }
 
1708
break;
 
1709
case 139:
 
1710
#line 886 "config_parse.y"
 
1711
{
 
1712
                        rule.log.error = 1;
 
1713
        }
 
1714
break;
 
1715
case 140:
 
1716
#line 889 "config_parse.y"
 
1717
{
 
1718
                        rule.log.iooperation = 1;
 
1719
#endif
 
1720
        }
 
1721
break;
 
1722
case 143:
 
1723
#line 900 "config_parse.y"
 
1724
{
 
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 */
 
1732
        }
 
1733
break;
 
1734
case 144:
 
1735
#line 911 "config_parse.y"
 
1736
{
 
1737
#if HAVE_LIBWRAP && SOCKS_SERVER
 
1738
                struct request_info request;
 
1739
                char libwrap[LIBWRAPBUF];
 
1740
 
 
1741
                if (strlen(yyvsp[0].string) >= sizeof(rule.libwrap))
 
1742
                        yyerror("libwrapline too long, make LIBWRAPBUF bigger");
 
1743
                strcpy(rule.libwrap, yyvsp[0].string);
 
1744
 
 
1745
                /* libwrap modifies the passed buffer. */
 
1746
                SASSERTX(strlen(rule.libwrap) < sizeof(libwrap));
 
1747
                strcpy(libwrap, rule.libwrap);
 
1748
 
 
1749
                ++dry_run;
 
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);
 
1754
                --dry_run;
 
1755
 
 
1756
#else /* !HAVE_LIBWRAP */
 
1757
                yyerror("libwrapsupport not compiled in");
 
1758
#endif
 
1759
        }
 
1760
break;
 
1761
case 155:
 
1762
#line 961 "config_parse.y"
 
1763
{ yyval.string = NULL; }
 
1764
break;
 
1765
case 157:
 
1766
#line 965 "config_parse.y"
 
1767
{
 
1768
                addressinit(&src);
 
1769
        }
 
1770
break;
 
1771
case 158:
 
1772
#line 970 "config_parse.y"
 
1773
{
 
1774
                addressinit(&dst);
 
1775
        }
 
1776
break;
 
1777
case 159:
 
1778
#line 975 "config_parse.y"
 
1779
{
 
1780
                addressinit(&rdr_from);
 
1781
        }
 
1782
break;
 
1783
case 160:
 
1784
#line 980 "config_parse.y"
 
1785
{
 
1786
                addressinit(&rdr_to);
 
1787
        }
 
1788
break;
 
1789
case 161:
 
1790
#line 987 "config_parse.y"
 
1791
{
 
1792
#if SOCKS_CLIENT
 
1793
                addressinit(&gw);
 
1794
#endif
 
1795
        }
 
1796
break;
 
1797
case 174:
 
1798
#line 1017 "config_parse.y"
 
1799
{
 
1800
                *atype = SOCKS_ADDR_IPV4;
 
1801
 
 
1802
                if (inet_aton(yyvsp[0].string, ipaddr) != 1)
 
1803
                        yyerror("bad address: %s", yyvsp[0].string);
 
1804
        }
 
1805
break;
 
1806
case 175:
 
1807
#line 1026 "config_parse.y"
 
1808
{
 
1809
                if (atoi(yyvsp[0].string) < 0 || atoi(yyvsp[0].string) > 32)
 
1810
                        yyerror("bad netmask: %d", yyvsp[0].string);
 
1811
 
 
1812
                netmask->s_addr
 
1813
                = atoi(yyvsp[0].string) == 0 ? 0 : htonl(0xffffffff << (32 - atoi(yyvsp[0].string)));
 
1814
        }
 
1815
break;
 
1816
case 176:
 
1817
#line 1033 "config_parse.y"
 
1818
{
 
1819
                        if (!inet_aton(yyvsp[0].string, netmask))
 
1820
                                yyerror("bad netmask: %s", yyvsp[0].string);
 
1821
        }
 
1822
break;
 
1823
case 177:
 
1824
#line 1039 "config_parse.y"
 
1825
{
 
1826
                *atype = SOCKS_ADDR_DOMAIN;
 
1827
 
 
1828
                if (strlen(yyvsp[0].string) >= MAXHOSTNAMELEN)
 
1829
                        yyerror("domainname too long");
 
1830
                strcpy(domain, yyvsp[0].string);
 
1831
        }
 
1832
break;
 
1833
case 178:
 
1834
#line 1048 "config_parse.y"
 
1835
{
 
1836
                *atype = SOCKS_ADDR_IFNAME;
 
1837
 
 
1838
                if (strlen(yyvsp[0].string) >= MAXIFNAMELEN)
 
1839
                        yyerror("interfacename too long");
 
1840
                strcpy(ifname, yyvsp[0].string);
 
1841
        }
 
1842
break;
 
1843
case 179:
 
1844
#line 1058 "config_parse.y"
 
1845
{
 
1846
                *atype = SOCKS_ADDR_DOMAIN;
 
1847
 
 
1848
                if (strlen(yyvsp[0].string) >= MAXHOSTNAMELEN)
 
1849
                        yyerror("domainname too long");
 
1850
                strcpy(domain, yyvsp[0].string);
 
1851
 
 
1852
#if SOCKS_CLIENT
 
1853
                route.state.direct = 1;
 
1854
#endif
 
1855
        }
 
1856
break;
 
1857
case 180:
 
1858
#line 1071 "config_parse.y"
 
1859
{ yyval.string = NULL; }
 
1860
break;
 
1861
case 186:
 
1862
#line 1084 "config_parse.y"
 
1863
{
 
1864
                *port_tcp       = htons((in_port_t)atoi(yyvsp[0].string));
 
1865
                *port_udp       = htons((in_port_t)atoi(yyvsp[0].string));
 
1866
        }
 
1867
break;
 
1868
case 187:
 
1869
#line 1090 "config_parse.y"
 
1870
{
 
1871
                ruleaddress->portend            = htons((in_port_t)atoi(yyvsp[0].string));
 
1872
                ruleaddress->operator   = range;
 
1873
        }
 
1874
break;
 
1875
case 188:
 
1876
#line 1096 "config_parse.y"
 
1877
{
 
1878
                struct servent  *service;
 
1879
                struct protocol_t       protocolunset;
 
1880
                int set;
 
1881
 
 
1882
                bzero(&protocolunset, sizeof(protocolunset));
 
1883
 
 
1884
                /* set all protocols if none set, default. */
 
1885
                if (memcmp(protocol, &protocolunset, sizeof(*protocol)) == 0) {
 
1886
                        memset(protocol, UCHAR_MAX, sizeof(*protocol));
 
1887
                        set = 0;
 
1888
                }
 
1889
                else
 
1890
                        set = 1;
 
1891
 
 
1892
                if (protocol->tcp) {
 
1893
                        if ((service = getservbyname(yyvsp[0].string, "tcp")) == NULL) {
 
1894
                                if (set)
 
1895
                                        yyerror("bad servicename for tcp: %s", yyvsp[0].string);
 
1896
                                else
 
1897
                                        *port_tcp = htons(0);
 
1898
                        }
 
1899
                        else
 
1900
                                *port_tcp = (in_port_t)service->s_port;
 
1901
                }
 
1902
 
 
1903
                if (protocol->udp) {
 
1904
                        if ((service = getservbyname(yyvsp[0].string, "udp")) == NULL) {
 
1905
                                if (set)
 
1906
                                        yyerror("bad servicename for udp: %s", yyvsp[0].string);
 
1907
                                else
 
1908
                                        *port_udp = htons(0);
 
1909
                        }
 
1910
                        else
 
1911
                                *port_udp = (in_port_t)service->s_port;
 
1912
                }
 
1913
 
 
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;
 
1921
        }
 
1922
break;
 
1923
case 189:
 
1924
#line 1144 "config_parse.y"
 
1925
{
 
1926
                *operator = string2operator(yyvsp[0].string);
 
1927
        }
 
1928
break;
 
1929
#line 1921 "y.tab.c"
 
1930
    }
 
1931
    yyssp -= yym;
 
1932
    yystate = *yyssp;
 
1933
    yyvsp -= yym;
 
1934
    yym = yylhs[yyn];
 
1935
    if (yystate == 0 && yym == 0)
 
1936
    {
 
1937
#if YYDEBUG
 
1938
        if (yydebug)
 
1939
            printf("%sdebug: after reduction, shifting from state 0 to\
 
1940
 state %d\n", YYPREFIX, YYFINAL);
 
1941
#endif
 
1942
        yystate = YYFINAL;
 
1943
        *++yyssp = YYFINAL;
 
1944
        *++yyvsp = yyval;
 
1945
        if (yychar < 0)
 
1946
        {
 
1947
            if ((yychar = yylex()) < 0) yychar = 0;
 
1948
#if YYDEBUG
 
1949
            if (yydebug)
 
1950
            {
 
1951
                yys = 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);
 
1956
            }
 
1957
#endif
 
1958
        }
 
1959
        if (yychar == 0) goto yyaccept;
 
1960
        goto yyloop;
 
1961
    }
 
1962
    if ((yyn = yygindex[yym]) && (yyn += yystate) >= 0 &&
 
1963
            yyn <= YYTABLESIZE && yycheck[yyn] == yystate)
 
1964
        yystate = yytable[yyn];
 
1965
    else
 
1966
        yystate = yydgoto[yym];
 
1967
#if YYDEBUG
 
1968
    if (yydebug)
 
1969
        printf("%sdebug: after reduction, shifting from state %d \
 
1970
to state %d\n", YYPREFIX, *yyssp, yystate);
 
1971
#endif
 
1972
    if (yyssp >= yysslim && yygrowstack())
 
1973
    {
 
1974
        goto yyoverflow;
 
1975
    }
 
1976
    *++yyssp = yystate;
 
1977
    *++yyvsp = yyval;
 
1978
    goto yyloop;
 
1979
yyoverflow:
 
1980
    yyerror("yacc stack overflow");
 
1981
yyabort:
 
1982
    return (1);
 
1983
yyaccept:
 
1984
    return (0);
 
1985
}