~ubuntu-branches/ubuntu/oneiric/openvpn/oneiric

« back to all changes in this revision

Viewing changes to options.c

  • Committer: Bazaar Package Importer
  • Author(s): Thierry Carrez
  • Date: 2008-10-07 16:30:44 UTC
  • mfrom: (1.1.11 upstream) (10.1.1 lenny)
  • Revision ID: james.westby@ubuntu.com-20081007163044-ixx04wg588z1972e
Tags: 2.1~rc11-1ubuntu1
* Merge with Debian (LP: #279655), remaining diffs:
  - debian/openvpn.init.d: Added 'status' action to init script, show
    per-VPN result messages and add "--script-security 2" by default for
    backwards compatibility
  - debian/control: Added lsb-base>=3.2-14 depend to allow status_of_proc()
* Fixes regression when calling commands with arguments (LP: #277447)

Show diffs side-by-side

added added

removed removed

Lines of Context:
169
169
  "                  netmask default: 255.255.255.255\n"
170
170
  "                  gateway default: taken from --route-gateway or --ifconfig\n"
171
171
  "                  Specify default by leaving blank or setting to \"nil\".\n"
172
 
  "--route-gateway gw : Specify a default gateway for use with --route.\n"
 
172
  "--route-gateway gw|'dhcp' : Specify a default gateway for use with --route.\n"
173
173
  "--route-metric m : Specify a default metric for use with --route.\n"
174
174
  "--route-delay n [w] : Delay n seconds after connection initiation before\n"
175
175
  "                  adding routes (may be 0).  If not specified, routes will\n"
180
180
  "                  --route-up script using environmental variables.\n"
181
181
  "--route-nopull  : When used with --client or --pull, accept options pushed\n"
182
182
  "                  by server EXCEPT for routes.\n"
 
183
  "--allow-pull-fqdn : Allow client to pull DNS names from server for\n"
 
184
  "                    --ifconfig, --route, and --route-gateway.\n"
183
185
  "--redirect-gateway [flags]: (Experimental) Automatically execute routing\n"
184
186
  "                  commands to redirect all outgoing IP traffic through the\n"
185
187
  "                  VPN.  Add 'local' flag if both " PACKAGE_NAME " servers are directly\n"
339
341
  "\n"
340
342
  "Multi-Client Server options (when --mode server is used):\n"
341
343
  "--server network netmask : Helper option to easily configure server mode.\n"
342
 
  "--server-bridge IP netmask pool-start-IP pool-end-IP : Helper option to\n"
 
344
  "--server-bridge [IP netmask pool-start-IP pool-end-IP] : Helper option to\n"
343
345
  "                    easily configure ethernet bridging server mode.\n"
344
346
  "--push \"option\" : Push a config file option back to the peer for remote\n"
345
347
  "                  execution.  Peer must specify --pull in its config file.\n"
890
892
    }
891
893
  else
892
894
    {
893
 
      if (ip_addr_dotted_quad_safe (parm))
 
895
      if (ip_addr_dotted_quad_safe (parm)) /* FQDN -- IP address only */
894
896
        {
895
897
          bool error = false;
896
898
          const in_addr_t addr = get_ip_addr (parm, msglevel, &error);
1226
1228
  SHOW_INT (route_delay_window);
1227
1229
  SHOW_BOOL (route_delay_defined);
1228
1230
  SHOW_BOOL (route_nopull);
 
1231
  SHOW_BOOL (route_gateway_via_dhcp);
 
1232
  SHOW_BOOL (allow_pull_fqdn);
1229
1233
  if (o->routes)
1230
1234
    print_route_options (o->routes, D_SHOW_PARMS);
1231
1235
 
1888
1892
options_postprocess_mutate_ce (struct options *o, struct connection_entry *ce)
1889
1893
{
1890
1894
#if P2MP_SERVER
1891
 
  if (o->server_defined || o->server_bridge_defined)
 
1895
  if (o->server_defined || o->server_bridge_defined || o->server_bridge_proxy_dhcp)
1892
1896
    {
1893
1897
      if (ce->proto == PROTO_TCPv4)
1894
1898
        ce->proto = PROTO_TCPv4_SERVER;
3248
3252
            struct env_set *es)
3249
3253
{
3250
3254
  struct gc_arena gc = gc_new ();
 
3255
  const bool pull_mode = BOOL_CAST (permission_mask & OPT_P_PULL_MODE);
 
3256
 
3251
3257
  ASSERT (MAX_PARMS >= 5);
3252
 
  const bool pull_mode = BOOL_CAST (permission_mask & OPT_P_PULL_MODE);
3253
 
 
3254
3258
  if (!file)
3255
3259
    {
3256
3260
      file = "[CMD-LINE]";
3432
3436
  else if (streq (p[0], "lladdr") && p[1])
3433
3437
    {
3434
3438
      VERIFY_PERMISSION (OPT_P_UP);
3435
 
      if (ip_addr_dotted_quad_safe (p[1]))
 
3439
      if (ip_addr_dotted_quad_safe (p[1])) /* FQDN -- IP address only */
3436
3440
        options->lladdr = p[1];
3437
3441
      else
3438
3442
        {
3460
3464
  else if (streq (p[0], "ifconfig") && p[1] && p[2])
3461
3465
    {
3462
3466
      VERIFY_PERMISSION (OPT_P_UP);
3463
 
      if (ip_addr_dotted_quad_safe (p[1]) && ip_addr_dotted_quad_safe (p[2]))
 
3467
      if (ip_or_dns_addr_safe (p[1], options->allow_pull_fqdn) && ip_or_dns_addr_safe (p[2], options->allow_pull_fqdn)) /* FQDN -- may be DNS name */
3464
3468
        {
3465
3469
          options->ifconfig_local = p[1];
3466
3470
          options->ifconfig_remote_netmask = p[2];
3467
3471
        }
3468
3472
      else
3469
3473
        {
3470
 
          msg (msglevel, "ifconfig parms '%s' and '%s' must be IP addresses", p[1], p[2]);
 
3474
          msg (msglevel, "ifconfig parms '%s' and '%s' must be valid addresses", p[1], p[2]);
3471
3475
          goto err;
3472
3476
        }
3473
3477
    }
4216
4220
      rol_check_alloc (options);
4217
4221
      if (pull_mode)
4218
4222
        {
4219
 
          if (!ip_addr_dotted_quad_safe (p[1]) && !is_special_addr (p[1]))
4220
 
            {
4221
 
              msg (msglevel, "route parameter network/IP '%s' is not an IP address", p[1]);
4222
 
              goto err;
4223
 
            }
4224
 
          if (p[2] && !ip_addr_dotted_quad_safe (p[2]))
4225
 
            {
4226
 
              msg (msglevel, "route parameter netmask '%s' is not an IP address", p[2]);
4227
 
              goto err;
4228
 
            }
4229
 
          if (p[3] && !ip_addr_dotted_quad_safe (p[3]) && !is_special_addr (p[3]))
4230
 
            {
4231
 
              msg (msglevel, "route parameter gateway '%s' is not an IP address", p[3]);
 
4223
          if (!ip_or_dns_addr_safe (p[1], options->allow_pull_fqdn) && !is_special_addr (p[1])) /* FQDN -- may be DNS name */
 
4224
            {
 
4225
              msg (msglevel, "route parameter network/IP '%s' must be a valid address", p[1]);
 
4226
              goto err;
 
4227
            }
 
4228
          if (p[2] && !ip_addr_dotted_quad_safe (p[2])) /* FQDN -- must be IP address */
 
4229
            {
 
4230
              msg (msglevel, "route parameter netmask '%s' must be an IP address", p[2]);
 
4231
              goto err;
 
4232
            }
 
4233
          if (p[3] && !ip_or_dns_addr_safe (p[3], options->allow_pull_fqdn) && !is_special_addr (p[3])) /* FQDN -- may be DNS name */
 
4234
            {
 
4235
              msg (msglevel, "route parameter gateway '%s' must be a valid address", p[3]);
4232
4236
              goto err;
4233
4237
            }
4234
4238
        }
4237
4241
  else if (streq (p[0], "route-gateway") && p[1])
4238
4242
    {
4239
4243
      VERIFY_PERMISSION (OPT_P_ROUTE_EXTRAS);
4240
 
      if (ip_addr_dotted_quad_safe (p[1]) || is_special_addr (p[1]))
 
4244
      if (streq (p[1], "dhcp"))
4241
4245
        {
4242
 
          options->route_default_gateway = p[1];
 
4246
          options->route_gateway_via_dhcp = true;
4243
4247
        }
4244
4248
      else
4245
4249
        {
4246
 
          msg (msglevel, "route-gateway parm '%s' must be an IP address", p[1]);
4247
 
          goto err;
 
4250
          if (ip_or_dns_addr_safe (p[1], options->allow_pull_fqdn) || is_special_addr (p[1])) /* FQDN -- may be DNS name */
 
4251
            {
 
4252
              options->route_default_gateway = p[1];
 
4253
            }
 
4254
          else
 
4255
            {
 
4256
              msg (msglevel, "route-gateway parm '%s' must be a valid address", p[1]);
 
4257
              goto err;
 
4258
            }
4248
4259
        }
4249
4260
    }
4250
4261
  else if (streq (p[0], "route-metric") && p[1])
4286
4297
      VERIFY_PERMISSION (OPT_P_GENERAL);
4287
4298
      options->route_nopull = true;
4288
4299
    }
 
4300
  else if (streq (p[0], "allow-pull-fqdn"))
 
4301
    {
 
4302
      VERIFY_PERMISSION (OPT_P_GENERAL);
 
4303
      options->allow_pull_fqdn = true;
 
4304
    }
4289
4305
  else if (streq (p[0], "redirect-gateway"))
4290
4306
    {
4291
4307
      int j;
4395
4411
      options->server_bridge_pool_start = pool_start;
4396
4412
      options->server_bridge_pool_end = pool_end;
4397
4413
    }
 
4414
  else if (streq (p[0], "server-bridge") && !p[1])
 
4415
    {
 
4416
      VERIFY_PERMISSION (OPT_P_GENERAL);
 
4417
      options->server_bridge_proxy_dhcp = true;
 
4418
    }
4398
4419
  else if (streq (p[0], "push") && p[1])
4399
4420
    {
4400
4421
      VERIFY_PERMISSION (OPT_P_PUSH);