diff options
Diffstat (limited to 'src/dopt.c')
-rw-r--r-- | src/dopt.c | 28 |
1 files changed, 27 insertions, 1 deletions
@@ -68,6 +68,8 @@ int arg_port = DISTCC_DEFAULT_PORT; int arg_stats = DISTCC_DEFAULT_STATS_ENABLED; int arg_stats_port = DISTCC_DEFAULT_STATS_PORT; +int opt_allow_private = 0; + /** If true, serve all requests directly from listening process without forking. Better for debugging. **/ int opt_no_fork = 0; @@ -115,8 +117,16 @@ enum { int opt_zeroconf = 0; #endif + +/*TODO: IPv6*/ +static const char *dcc_private_networks[] = {"192.168.0.0/16", + "10.0.0.0/8", + "172.16.0.0/12", + "127.0.0.0/8"}; + const struct poptOption options[] = { { "allow", 'a', POPT_ARG_STRING, 0, 'a', 0, 0 }, + { "allow-private", 0,POPT_ARG_STRING, &opt_allow_private, 0, 0, 0 }, #ifdef HAVE_GSSAPI { "auth", 0, POPT_ARG_NONE, &opt_auth_enabled, 'A', 0, 0 }, { "blacklist", 0, POPT_ARG_STRING, &arg_list_file, 'b', 0, 0 }, @@ -225,6 +235,7 @@ int distccd_parse_options(int argc, const char **argv) { poptContext po; int po_err, exitcode; + struct dcc_allow_list *new; po = poptGetContext("distccd", argc, argv, options, 0); @@ -238,7 +249,6 @@ int distccd_parse_options(int argc, const char **argv) case 'a': { /* TODO: Allow this to be a hostname, which is resolved to an address. */ /* TODO: Split this into a small function. */ - struct dcc_allow_list *new; new = malloc(sizeof *new); if (!new) { rs_log_crit("malloc failed"); @@ -367,6 +377,22 @@ int distccd_parse_options(int argc, const char **argv) } } + if (opt_allow_private) { + int i; + for (i = 0;i<3;i++) { + new = malloc(sizeof *new); + if (!new) { + rs_log_crit("malloc failed"); + exitcode = EXIT_OUT_OF_MEMORY; + goto out_exit; + } + new->next = opt_allowed; + opt_allowed = new; + if ((exitcode = dcc_parse_mask(dcc_private_networks[i], &new->addr, &new->mask))) + goto out_exit; + } + } + poptFreeContext(po); return 0; |