42
42
#define yyname socks_yyname
43
43
#define yyrule socks_yyrule
44
44
#define YYPREFIX "socks_yy"
45
#line 45 "config_parse.y"
45
#line 45 "../lib/config_parse.y"
47
47
#include "common.h"
49
49
#include "yacconfig.h"
51
51
static const char rcsid[] =
52
"$Id: config_parse.y,v 1.183 2002/05/01 12:35:14 michaels Exp $";
52
"$Id: config_parse.y,v 1.191 2005/06/10 11:14:48 michaels Exp $";
157
161
yywarn("duplicate method: %s", method2string(method)); \
159
163
if (*methodc >= MAXMETHOD) \
160
yyerror("internal error"); \
164
yyerror("internal error, (%d >= %d)", *methodc, MAXMETHOD); \
161
165
methodv[(*methodc)++] = method; \
165
#line 166 "config_parse.y"
169
#line 170 "../lib/config_parse.y"
170
#ifndef YYSTYPE_DEFINED
171
#define YYSTYPE_DEFINED
176
#endif /* YYSTYPE_DEFINED */
177
#line 178 "config_parse.c"
171
178
#define SERVERCONFIG 257
172
179
#define CLIENTCONFIG 258
173
180
#define DEPRECATED 259
246
253
#define REDIRECT 332
247
254
#define BANDWIDTH 333
248
255
#define YYERRCODE 256
249
short socks_yylhs[] = { -1,
256
#if defined(__cplusplus) || defined(__STDC__)
257
const short socks_yylhs[] =
259
short socks_yylhs[] =
250
262
0, 0, 51, 1, 1, 1, 1, 1, 2, 2,
251
263
2, 2, 25, 26, 26, 52, 52, 52, 52, 52,
252
264
52, 52, 52, 52, 52, 50, 50, 50, 50, 50,
268
280
86, 90, 90, 90, 94, 94, 91, 92, 102, 95,
271
short socks_yylen[] = { 2,
283
#if defined(__cplusplus) || defined(__STDC__)
284
const short socks_yylen[] =
286
short socks_yylen[] =
272
289
2, 2, 1, 0, 2, 2, 2, 2, 0, 2,
273
290
2, 2, 1, 1, 1, 1, 1, 1, 1, 1,
274
291
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
290
307
1, 0, 3, 2, 1, 1, 3, 1, 1, 1,
293
short socks_yydefred[] = { 0,
310
#if defined(__cplusplus) || defined(__STDC__)
311
const short socks_yydefred[] =
313
short socks_yydefred[] =
294
316
3, 13, 0, 9, 4, 0, 0, 32, 0, 0,
295
317
0, 34, 10, 15, 58, 11, 14, 57, 56, 12,
296
318
0, 51, 53, 0, 0, 0, 0, 0, 0, 0,
321
343
172, 148, 181, 0, 151, 0, 175, 33, 189, 187,
322
344
178, 177, 0, 173, 174, 170,
324
short socks_yydgoto[] = { 3,
346
#if defined(__cplusplus) || defined(__STDC__)
347
const short socks_yydgoto[] =
349
short socks_yydgoto[] =
325
352
7, 6, 14, 126, 205, 206, 127, 211, 212, 128,
326
353
214, 215, 129, 15, 86, 41, 98, 99, 130, 221,
327
354
222, 131, 132, 65, 4, 16, 17, 18, 42, 43,
334
361
245, 246, 247, 267, 268, 105, 106, 182, 183, 184,
337
short socks_yysindex[] = { -152,
364
#if defined(__cplusplus) || defined(__STDC__)
365
const short socks_yysindex[] =
367
short socks_yysindex[] =
338
370
0, 0, 0, 0, 0, -10, 255, 0, -29, -26,
339
371
-18, 0, 0, 0, 0, 0, 0, 0, 0, 0,
340
372
-186, 0, 0, -8, -1, 3, 8, 18, 20, 43,
363
395
0, 0, 0, 152, -161, -161, 0, 0, -254, 0,
364
396
-277, 77, 0, -124, 0, 0, 0, 0, -295, 0,
365
397
0, 0, 0, -161, 0, -161, 0, 0, 0, 0,
368
short socks_yyrindex[] = { 0,
398
0, 0, -161, 0, 0, 0,};
399
#if defined(__cplusplus) || defined(__STDC__)
400
const short socks_yyrindex[] =
402
short socks_yyrindex[] =
369
405
0, 0, 0, 0, 0, 204, 205, 0, 0, 0,
370
406
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
371
407
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
394
430
0, 0, 0, 0, -120, -120, 0, 0, 0, 0,
395
431
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
396
432
0, 0, 0, -119, 0, -119, 0, 0, 0, 0,
399
short socks_yygindex[] = { 0,
433
0, 0, -120, 0, 0, 0,};
434
#if defined(__cplusplus) || defined(__STDC__)
435
const short socks_yygindex[] =
437
short socks_yygindex[] =
400
440
0, 0, 199, -78, 17, 0, -75, 0, 9, 0,
401
441
0, 13, 0, 218, 0, 0, 0, 130, -73, 12,
402
442
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
412
452
#define YYTABLESIZE 661
413
short socks_yytable[] = { 13,
453
#if defined(__cplusplus) || defined(__STDC__)
454
const short socks_yytable[] =
456
short socks_yytable[] =
414
459
98, 111, 157, 102, 182, 182, 192, 194, 154, 158,
415
460
98, 140, 155, 159, 141, 170, 142, 116, 144, 187,
416
461
149, 116, 198, 199, 257, 94, 281, 26, 62, 243,
479
524
0, 0, 0, 0, 0, 0, 0, 143, 0, 143,
482
short socks_yycheck[] = { 10,
527
#if defined(__cplusplus) || defined(__STDC__)
528
const short socks_yycheck[] =
530
short socks_yycheck[] =
483
533
0, 125, 125, 125, 125, 125, 145, 147, 92, 93,
484
534
10, 90, 92, 93, 90, 106, 90, 274, 90, 134,
485
535
91, 274, 155, 156, 232, 276, 322, 269, 58, 315,
572
622
"NOUNKNOWN","EXTENSION","BIND","PRIVILEGED","IOTIMEOUT","CONNECTTIMEOUT",
573
623
"METHOD","CLIENTMETHOD","NONE","GSSAPI","UNAME","RFC931","PAM","COMPATIBILITY",
574
624
"REUSEADDR","SAMEPORT","USERNAME","USER_PRIVILEGED","USER_UNPRIVILEGED",
575
"USER_LIBWRAP","LOGOUTPUT","LOGFILE","CHILD_MAXIDLENUMBER","ROUTE","VIA",
625
"USER_LIBWRAP","LOGOUTPUT","LOGFILE","CHILD_MAXIDLE","ROUTE","VIA",
576
626
"VERDICT_BLOCK","VERDICT_PASS","PAMSERVICENAME","PROTOCOL","PROTOCOL_TCP",
577
627
"PROTOCOL_UDP","PROTOCOL_FAKE","PROXYPROTOCOL","PROXYPROTOCOL_SOCKS_V4",
578
628
"PROXYPROTOCOL_SOCKS_V5","PROXYPROTOCOL_MSPROXY_V2","PROXYPROTOCOL_HTTP_V1_0",
582
632
"LOG_IOOPERATION","IPADDRESS","DOMAINNAME","DIRECT","IFNAME","PORT",
583
633
"PORTNUMBER","SERVICENAME","NUMBER","FROM","TO","REDIRECT","BANDWIDTH",
585
#if defined(__cplusplus) || __STDC__
635
#if defined(__cplusplus) || defined(__STDC__)
586
636
const char * const socks_yyrule[] =
588
638
char *socks_yyrule[] =
650
700
"logoutputdevice : LOGFILE",
651
701
"logoutputdevices : logoutputdevice",
652
702
"logoutputdevices : logoutputdevice logoutputdevices",
653
"childstate : CHILD_MAXIDLENUMBER ':' NUMBER",
703
"childstate : CHILD_MAXIDLE ':' NUMBER",
654
704
"userids : user_privileged",
655
705
"userids : user_unprivileged",
656
706
"userids : user_libwrap",
949
1003
dst = rdr_from = rdr_to = src;
1009
const char *function = "fixsettings()";
1014
* Check arguments and settings, do they make sense?
1017
if (sockscf.clientmethodc == 0)
1018
sockscf.clientmethodv[sockscf.clientmethodc++] = AUTHMETHOD_NONE;
1021
if (!sockscf.uid.privileged_isset)
1022
sockscf.uid.privileged = sockscf.state.euid;
1024
socks_seteuid(&euid, sockscf.uid.privileged);
1025
socks_reseteuid(sockscf.uid.privileged, euid);
1028
if (!sockscf.uid.unprivileged_isset)
1029
sockscf.uid.unprivileged = sockscf.state.euid;
1031
socks_seteuid(&euid, sockscf.uid.unprivileged);
1032
socks_reseteuid(sockscf.uid.unprivileged, euid);
1036
if (!sockscf.uid.libwrap_isset)
1037
sockscf.uid.libwrap = sockscf.state.euid;
1039
socks_seteuid(&euid, sockscf.uid.libwrap);
1040
socks_reseteuid(sockscf.uid.libwrap, euid);
1042
#endif /* HAVE_LIBWRAP */
1043
#endif /* !HAVE_DUMPCONF */
1045
if (sockscf.internalc == 0)
1046
serrx(EXIT_FAILURE, "%s: no internal address given", function);
1047
/* values will be used once and checked there. */
1049
if (sockscf.external.addrc == 0)
1050
serrx(EXIT_FAILURE, "%s: no external address given", function);
1052
for (i = 0; i < sockscf.external.addrc; ++i)
1053
if (!addressisbindable(&sockscf.external.addrv[i]))
1054
serrx(EXIT_FAILURE, NULL);
1055
#endif /* !HAVE_DUMPCONF */
1058
if (sockscf.methodc == 0)
1059
swarnx("%s: no methods enabled (total block)", function);
1061
if (sockscf.uid.unprivileged == 0)
1062
swarnx("%s: setting the unprivileged uid to %d is not recommended",
1063
function, sockscf.uid.unprivileged);
1066
if (sockscf.uid.libwrap == 0)
1067
swarnx("%s: setting the libwrap uid to %d is not recommended",
1068
function, sockscf.uid.libwrap);
1069
#endif /* HAVE_LIBWRAP */
1070
#endif /* !HAVE_DUMPCONF */
1073
#endif /* SOCKS_SERVER */
1074
#line 1023 "config_parse.c"
953
1075
/* allocate initial stack or double stack size, up to YYMAXDEPTH */
954
#if defined(__cplusplus) || __STDC__
1076
#if defined(__cplusplus) || defined(__STDC__)
955
1077
static int yygrowstack(void)
957
1079
static int yygrowstack()
1008
1130
int yym, yyn, yystate;
1010
#if defined(__cplusplus) || __STDC__
1132
#if defined(__cplusplus) || defined(__STDC__)
1011
1133
const char *yys;
1012
#else /* !(defined(__cplusplus) || __STDC__) */
1134
#else /* !(defined(__cplusplus) || defined(__STDC__)) */
1014
#endif /* !(defined(__cplusplus) || __STDC__) */
1136
#endif /* !(defined(__cplusplus) || defined(__STDC__)) */
1016
1138
if ((yys = getenv("YYDEBUG")))
1155
#line 281 "config_parse.y"
1277
#line 285 "../lib/config_parse.y"
1156
1278
{ yyval.string = NULL; }
1159
#line 288 "config_parse.y"
1281
#line 292 "../lib/config_parse.y"
1160
1282
{ yyval.string = NULL; }
1163
#line 295 "config_parse.y"
1285
#line 299 "../lib/config_parse.y"
1168
#line 324 "config_parse.y"
1290
#line 328 "../lib/config_parse.y"
1170
1292
yywarn("given keyword is deprecated");
1174
#line 328 "config_parse.y"
1296
#line 332 "../lib/config_parse.y"
1176
1298
#if SOCKS_CLIENT
1177
1299
route.src = src;
1208
#line 364 "config_parse.y"
1330
#line 368 "../lib/config_parse.y"
1210
1332
proxyprotocol->socks_v4 = 1;
1214
#line 367 "config_parse.y"
1336
#line 371 "../lib/config_parse.y"
1216
1338
proxyprotocol->socks_v5 = 1;
1220
#line 370 "config_parse.y"
1342
#line 374 "../lib/config_parse.y"
1222
1344
proxyprotocol->msproxy_v2 = 1;
1226
#line 373 "config_parse.y"
1348
#line 377 "../lib/config_parse.y"
1228
1350
proxyprotocol->http_v1_0 = 1;
1232
#line 385 "config_parse.y"
1354
#line 389 "../lib/config_parse.y"
1234
1356
#if SOCKS_SERVER
1235
1357
#if !HAVE_LIBWRAP
1408
#line 575 "config_parse.y"
1530
#line 579 "../lib/config_parse.y"
1410
1532
#if SOCKS_SERVER
1411
1533
if (atoi(yyvsp[0].string) < SOCKD_FREESLOTS)
1412
yyerror("child.maxidlenumber can't be less than SOCKD_FREESLOTS (%d)",
1415
sockscf.child.maxidlenumber = atoi(yyvsp[0].string);
1534
yyerror("%s (%s) can't be less than SOCKD_FREESLOTS (%d)",
1535
yyvsp[-2].string, yyvsp[0].string, SOCKD_FREESLOTS);
1536
sockscf.child.maxidle = atoi(yyvsp[0].string);
1420
#line 592 "config_parse.y"
1541
#line 595 "../lib/config_parse.y"
1422
1543
#if SOCKS_SERVER
1423
1544
sockscf.uid.privileged = yyvsp[0].uid;
1476
#line 643 "config_parse.y"
1597
#line 646 "../lib/config_parse.y"
1478
1599
sockscf.option.debug = atoi(yyvsp[0].string);
1482
#line 651 "config_parse.y"
1603
#line 654 "../lib/config_parse.y"
1484
1605
#if SOCKS_SERVER
1485
1606
sockscf.compat.reuseaddr = 1;
1489
#line 655 "config_parse.y"
1610
#line 658 "../lib/config_parse.y"
1491
1612
sockscf.compat.sameport = 1;
1496
#line 668 "config_parse.y"
1617
#line 671 "../lib/config_parse.y"
1498
1619
sockscf.resolveprotocol = RESOLVEPROTOCOL_FAKE;
1502
#line 671 "config_parse.y"
1623
#line 674 "../lib/config_parse.y"
1504
1625
#if HAVE_NO_RESOLVESTUFF
1505
1626
yyerror("resolveprotocol keyword not supported on this installation");
1512
#line 678 "config_parse.y"
1633
#line 681 "../lib/config_parse.y"
1514
1635
sockscf.resolveprotocol = RESOLVEPROTOCOL_UDP;
1518
#line 686 "config_parse.y"
1639
#line 689 "../lib/config_parse.y"
1520
1641
#if HAVE_LIBWRAP && SOCKS_SERVER
1521
1642
sockscf.srchost.nomismatch = 1;
1525
#line 690 "config_parse.y"
1646
#line 693 "../lib/config_parse.y"
1527
1648
sockscf.srchost.nounknown = 1;
1554
#line 724 "config_parse.y"
1675
#line 727 "../lib/config_parse.y"
1556
1677
ADDMETHOD(AUTHMETHOD_NONE);
1560
#line 727 "config_parse.y"
1681
#line 730 "../lib/config_parse.y"
1562
1683
yyerror("%s not supported", AUTHMETHOD_GSSAPIs);
1566
#line 730 "config_parse.y"
1687
#line 733 "../lib/config_parse.y"
1568
1689
ADDMETHOD(AUTHMETHOD_UNAME);
1572
#line 733 "config_parse.y"
1693
#line 736 "../lib/config_parse.y"
1574
1695
#if HAVE_LIBWRAP && SOCKS_SERVER
1575
1696
ADDMETHOD(AUTHMETHOD_RFC931);
1659
#line 832 "config_parse.y"
1780
#line 835 "../lib/config_parse.y"
1661
1782
command->bind = 1;
1665
#line 835 "config_parse.y"
1786
#line 838 "../lib/config_parse.y"
1667
1788
command->connect = 1;
1671
#line 838 "config_parse.y"
1792
#line 841 "../lib/config_parse.y"
1673
1794
command->udpassociate = 1;
1677
#line 844 "config_parse.y"
1798
#line 847 "../lib/config_parse.y"
1679
1800
command->bindreply = 1;
1683
#line 848 "config_parse.y"
1804
#line 851 "../lib/config_parse.y"
1685
1806
command->udpreply = 1;
1689
#line 860 "config_parse.y"
1810
#line 863 "../lib/config_parse.y"
1691
1812
protocol->tcp = 1;
1695
#line 863 "config_parse.y"
1816
#line 866 "../lib/config_parse.y"
1697
1818
protocol->udp = 1;
1701
#line 880 "config_parse.y"
1822
#line 883 "../lib/config_parse.y"
1703
1824
#if SOCKS_SERVER
1704
1825
static bw_t bwmeminit;
1720
#line 902 "config_parse.y"
1841
#line 905 "../lib/config_parse.y"
1722
1843
#if SOCKS_SERVER
1723
1844
rule.log.connect = 1;
1727
#line 906 "config_parse.y"
1848
#line 909 "../lib/config_parse.y"
1729
1850
rule.log.data = 1;
1733
#line 909 "config_parse.y"
1854
#line 912 "../lib/config_parse.y"
1735
1856
rule.log.disconnect = 1;
1739
#line 912 "config_parse.y"
1860
#line 915 "../lib/config_parse.y"
1741
1862
rule.log.error = 1;
1745
#line 915 "config_parse.y"
1866
#line 918 "../lib/config_parse.y"
1747
1868
rule.log.iooperation = 1;
1752
#line 926 "config_parse.y"
1873
#line 929 "../lib/config_parse.y"
1754
1875
#if HAVE_PAM && SOCKS_SERVER
1755
1876
if (strlen(yyvsp[0].string) >= sizeof(rule.pamservicename))
1791
#line 987 "config_parse.y"
1912
#line 990 "../lib/config_parse.y"
1792
1913
{ yyval.string = NULL; }
1795
#line 991 "config_parse.y"
1916
#line 994 "../lib/config_parse.y"
1797
1918
addressinit(&src);
1801
#line 996 "config_parse.y"
1922
#line 999 "../lib/config_parse.y"
1803
1924
addressinit(&dst);
1807
#line 1001 "config_parse.y"
1928
#line 1004 "../lib/config_parse.y"
1809
1930
addressinit(&rdr_from);
1813
#line 1006 "config_parse.y"
1934
#line 1009 "../lib/config_parse.y"
1815
1936
addressinit(&rdr_to);
1819
#line 1013 "config_parse.y"
1940
#line 1016 "../lib/config_parse.y"
1821
1942
#if SOCKS_CLIENT
1822
1943
addressinit(&gw);
1836
#line 1052 "config_parse.y"
1957
#line 1055 "../lib/config_parse.y"
1838
1959
if (atoi(yyvsp[0].string) < 0 || atoi(yyvsp[0].string) > 32)
1839
yyerror("bad netmask: %d", yyvsp[0].string);
1960
yyerror("bad netmask: %s", yyvsp[0].string);
1841
1962
netmask->s_addr
1842
1963
= atoi(yyvsp[0].string) == 0 ? 0 : htonl(0xffffffff << (32 - atoi(yyvsp[0].string)));
1846
#line 1059 "config_parse.y"
1967
#line 1062 "../lib/config_parse.y"
1848
1969
if (!inet_aton(yyvsp[0].string, netmask))
1849
1970
yyerror("bad netmask: %s", yyvsp[0].string);
1853
#line 1065 "config_parse.y"
1974
#line 1068 "../lib/config_parse.y"
1855
1976
*atype = SOCKS_ADDR_DOMAIN;
1887
#line 1097 "config_parse.y"
2008
#line 1100 "../lib/config_parse.y"
1888
2009
{ yyval.string = NULL; }
1891
#line 1110 "config_parse.y"
2012
#line 1113 "../lib/config_parse.y"
1893
2014
*port_tcp = htons((in_port_t)atoi(yyvsp[0].string));
1894
2015
*port_udp = htons((in_port_t)atoi(yyvsp[0].string));
1898
#line 1116 "config_parse.y"
2019
#line 1119 "../lib/config_parse.y"
1900
2021
ruleaddress->portend = htons((in_port_t)atoi(yyvsp[0].string));
1901
2022
ruleaddress->operator = range;
1905
#line 1122 "config_parse.y"
2026
#line 1125 "../lib/config_parse.y"
1907
2028
struct servent *service;
1908
2029
struct protocol_t protocolunset;