~smoser/ubuntu/oneiric/openvpn/lp-794916

« back to all changes in this revision

Viewing changes to options.c

  • Committer: Bazaar Package Importer
  • Author(s): Chuck Short
  • Date: 2010-05-05 03:06:19 UTC
  • mfrom: (10.2.6 sid)
  • Revision ID: james.westby@ubuntu.com-20100505030619-cwre0snhgx1mql53
Tags: 2.1.0-2ubuntu1
* Merge from debian unstable.  Remaining changes:
  + debian/openvpn.init.d:
    - Do not use start-stop-daemon and use </dev/null to avoid blocking boot
    - Show per-VPN result messages
    - Add "--script-security 2" by default for backwards compatablitiy
   + debian/control: Add lsb-base >= 3.2-14 to allow status_of_proc() 

Show diffs side-by-side

added added

removed removed

Lines of Context:
7
7
 *
8
8
 *  Copyright (C) 2002-2009 OpenVPN Technologies, Inc. <sales@openvpn.net>
9
9
 *
 
10
 *  Additions for eurephia plugin done by:
 
11
 *         David Sommerseth <dazo@users.sourceforge.net> Copyright (C) 2009
 
12
 *
10
13
 *  This program is free software; you can redistribute it and/or modify
11
14
 *  it under the terms of the GNU General Public License version 2
12
15
 *  as published by the Free Software Foundation.
73
76
#ifdef ENABLE_PKCS11
74
77
  " [PKCS11]"
75
78
#endif
 
79
#ifdef ENABLE_IP_PKTINFO
 
80
  " [MH]"
 
81
#endif
 
82
#ifdef USE_PF_INET6
 
83
  " [PF_INET6]"
 
84
#endif
 
85
  " [eurephia]"
76
86
  " built on " __DATE__
77
87
;
78
88
 
94
104
  "--mode m        : Major mode, m = 'p2p' (default, point-to-point) or 'server'.\n"
95
105
  "--proto p       : Use protocol p for communicating with peer.\n"
96
106
  "                  p = udp (default), tcp-server, or tcp-client\n"
 
107
#ifdef USE_PF_INET6
 
108
  "                  p = udp6, tcp6-server, or tcp6-client (ipv6)\n"
 
109
#endif
97
110
  "--connect-retry n : For --proto tcp-client, number of seconds to wait\n"
98
111
  "                    between connection retries (default=%d).\n"
99
112
  "--connect-timeout n : For --proto tcp-client, connection timeout (in seconds).\n"
1538
1551
   * Sanity check on TCP mode options
1539
1552
   */
1540
1553
 
1541
 
  if (ce->connect_retry_defined && ce->proto != PROTO_TCPv4_CLIENT)
1542
 
    msg (M_USAGE, "--connect-retry doesn't make sense unless also used with --proto tcp-client");
 
1554
  if (ce->connect_retry_defined && ce->proto != PROTO_TCPv4_CLIENT
 
1555
#ifdef USE_PF_INET6
 
1556
      && ce->proto != PROTO_TCPv6_CLIENT
 
1557
#endif
 
1558
      )
 
1559
    msg (M_USAGE, "--connect-retry doesn't make sense unless also used with --proto tcp-client"
 
1560
#ifdef USE_PF_INET6
 
1561
         " or tcp6-client"
 
1562
#endif
 
1563
         );
1543
1564
 
1544
 
  if (ce->connect_timeout_defined && ce->proto != PROTO_TCPv4_CLIENT)
1545
 
    msg (M_USAGE, "--connect-timeout doesn't make sense unless also used with --proto tcp-client");
 
1565
  if (ce->connect_timeout_defined && ce->proto != PROTO_TCPv4_CLIENT
 
1566
#ifdef USE_PF_INET6
 
1567
      && ce->proto != PROTO_TCPv6_CLIENT
 
1568
#endif
 
1569
      )
 
1570
    msg (M_USAGE, "--connect-timeout doesn't make sense unless also used with --proto tcp-client"
 
1571
#ifdef USE_PF_INET6
 
1572
         " or tcp6-client"
 
1573
#endif
 
1574
         );
1546
1575
 
1547
1576
  /*
1548
1577
   * Sanity check on MTU parameters
1551
1580
    msg (M_USAGE, "only one of --tun-mtu or --link-mtu may be defined (note that --ifconfig implies --link-mtu %d)", LINK_MTU_DEFAULT);
1552
1581
 
1553
1582
#ifdef ENABLE_OCC
1554
 
  if (ce->proto != PROTO_UDPv4 && options->mtu_test)
 
1583
  if (!proto_is_udp(ce->proto) && options->mtu_test)
1555
1584
    msg (M_USAGE, "--mtu-test only makes sense with --proto udp");
1556
1585
#endif
1557
1586
 
1564
1593
   * Sanity check on --local, --remote, and --ifconfig
1565
1594
   */
1566
1595
 
1567
 
  if (string_defined_equal (ce->local, ce->remote)
 
1596
  if (proto_is_net(ce->proto)
 
1597
      && string_defined_equal (ce->local, ce->remote)
1568
1598
      && ce->local_port == ce->remote_port)
1569
1599
    msg (M_USAGE, "--remote and --local addresses are the same");
1570
1600
  
1629
1659
   */
1630
1660
 
1631
1661
#ifdef ENABLE_FRAGMENT
1632
 
  if (ce->proto != PROTO_UDPv4 && options->fragment)
 
1662
  if (!proto_is_udp(ce->proto) && options->fragment)
1633
1663
    msg (M_USAGE, "--fragment can only be used with --proto udp");
1634
1664
#endif
1635
1665
 
1636
1666
#ifdef ENABLE_OCC
1637
 
  if (ce->proto != PROTO_UDPv4 && options->explicit_exit_notification)
 
1667
  if (!proto_is_udp(ce->proto) && options->explicit_exit_notification)
1638
1668
    msg (M_USAGE, "--explicit-exit-notify can only be used with --proto udp");
1639
1669
#endif
1640
1670
 
1641
 
  if (!ce->remote && ce->proto == PROTO_TCPv4_CLIENT)
 
1671
  if (!ce->remote && (ce->proto == PROTO_TCPv4_CLIENT 
 
1672
#ifdef USE_PF_INET6
 
1673
                      || ce->proto == PROTO_TCPv6_CLIENT
 
1674
#endif
 
1675
                      ))
1642
1676
    msg (M_USAGE, "--remote MUST be used in TCP Client mode");
1643
1677
 
1644
1678
#ifdef ENABLE_HTTP_PROXY
1656
1690
    msg (M_USAGE, "--socks-proxy can not be used in TCP Server mode");
1657
1691
#endif
1658
1692
 
1659
 
  if (ce->proto == PROTO_TCPv4_SERVER && connection_list_defined (options))
 
1693
  if ((ce->proto == PROTO_TCPv4_SERVER
 
1694
#ifdef USE_PF_INET6
 
1695
       || ce->proto == PROTO_TCPv6_SERVER
 
1696
#endif
 
1697
       )
 
1698
       && connection_list_defined (options))
1660
1699
    msg (M_USAGE, "TCP server mode allows at most one --remote address");
1661
1700
 
1662
1701
#if P2MP_SERVER
1670
1709
        msg (M_USAGE, "--mode server only works with --dev tun or --dev tap");
1671
1710
      if (options->pull)
1672
1711
        msg (M_USAGE, "--pull cannot be used with --mode server");
1673
 
      if (!(ce->proto == PROTO_UDPv4 || ce->proto == PROTO_TCPv4_SERVER))
1674
 
        msg (M_USAGE, "--mode server currently only supports --proto udp or --proto tcp-server");
 
1712
      if (!(proto_is_udp(ce->proto) || ce->proto == PROTO_TCPv4_SERVER
 
1713
#ifdef USE_PF_INET6
 
1714
            || ce->proto == PROTO_TCPv6_SERVER
 
1715
#endif
 
1716
            ))
 
1717
        msg (M_USAGE, "--mode server currently only supports --proto udp or --proto tcp-server"
 
1718
#ifdef USE_PF_INET6
 
1719
            " or proto tcp6-server"
 
1720
#endif
 
1721
             );
1675
1722
#if PORT_SHARE
1676
 
      if ((options->port_share_host || options->port_share_port) && ce->proto != PROTO_TCPv4_SERVER)
1677
 
        msg (M_USAGE, "--port-share only works in TCP server mode (--proto tcp-server)");
 
1723
      if ((options->port_share_host || options->port_share_port) && 
 
1724
            (ce->proto != PROTO_TCPv4_SERVER
 
1725
#ifdef USE_PF_INET6
 
1726
             && ce->proto != PROTO_TCPv6_SERVER
 
1727
#endif
 
1728
             ))
 
1729
        msg (M_USAGE, "--port-share only works in TCP server mode (--proto tcp-server"
 
1730
#ifdef USE_PF_INET6
 
1731
             " or tcp6-server"
 
1732
#endif
 
1733
          ")");
1678
1734
#endif
1679
1735
      if (!options->tls_server)
1680
1736
        msg (M_USAGE, "--mode server requires --tls-server");
1702
1758
        msg (M_USAGE, "--inetd cannot be used with --mode server");
1703
1759
      if (options->ipchange)
1704
1760
        msg (M_USAGE, "--ipchange cannot be used with --mode server (use --client-connect instead)");
1705
 
      if (!(ce->proto == PROTO_UDPv4 || ce->proto == PROTO_TCPv4_SERVER))
1706
 
        msg (M_USAGE, "--mode server currently only supports --proto udp or --proto tcp-server");
1707
 
      if (ce->proto != PROTO_UDPv4 && (options->cf_max || options->cf_per))
 
1761
      if (!(proto_is_dgram(ce->proto) || ce->proto == PROTO_TCPv4_SERVER
 
1762
#ifdef USE_PF_INET6
 
1763
            || ce->proto == PROTO_TCPv6_SERVER
 
1764
#endif
 
1765
            ))
 
1766
        msg (M_USAGE, "--mode server currently only supports --proto udp or --proto tcp-server"
 
1767
#ifdef USE_PF_INET6
 
1768
            " or --proto tcp6-server"
 
1769
#endif
 
1770
             );
 
1771
      if (!proto_is_udp(ce->proto) && (options->cf_max || options->cf_per))
1708
1772
        msg (M_USAGE, "--connect-freq only works with --mode server --proto udp.  Try --max-clients instead.");
1709
1773
      if (!(dev == DEV_TYPE_TAP || (dev == DEV_TYPE_TUN && options->topology == TOP_SUBNET)) && options->ifconfig_pool_netmask)
1710
1774
        msg (M_USAGE, "The third parameter to --ifconfig-pool (netmask) is only valid in --dev tap mode");
1797
1861
  /*
1798
1862
   * Check consistency of replay options
1799
1863
   */
1800
 
  if ((ce->proto != PROTO_UDPv4)
 
1864
  if ((!proto_is_udp(ce->proto))
1801
1865
      && (options->replay_window != defaults.replay_window
1802
1866
          || options->replay_time != defaults.replay_time))
1803
1867
    msg (M_USAGE, "--replay-window only makes sense with --proto udp");
1966
2030
    {
1967
2031
      if (ce->proto == PROTO_TCPv4)
1968
2032
        ce->proto = PROTO_TCPv4_CLIENT;
 
2033
#ifdef USE_PF_INET6
 
2034
      else if (ce->proto == PROTO_TCPv6)
 
2035
        ce->proto = PROTO_TCPv6_CLIENT;
 
2036
#endif
1969
2037
    }
1970
2038
#endif
1971
2039
 
5715
5783
      VERIFY_PERMISSION (OPT_P_GENERAL);
5716
5784
      options->pkcs11_id_management = true;
5717
5785
    }
 
5786
  else if (streq (p[0], "pkcs11-id-type") ||
 
5787
           streq (p[0], "pkcs11-sign-mode") ||
 
5788
           streq (p[0], "pkcs11-slot") ||
 
5789
           streq (p[0], "pkcs11-slot-type") ||
 
5790
           streq (p[0], "show-pkcs11-objects") ||
 
5791
           streq (p[0], "show-pkcs11-slots"))
 
5792
    {
 
5793
      if (file)
 
5794
        msg (msglevel, "You are using an obsolete parameter in %s:%d: %s (%s).\nPlease see /usr/share/doc/openvpn/NEWS.Debian.gz for details.",
 
5795
             file, line, p[0], PACKAGE_VERSION);
 
5796
      else
 
5797
        msg (msglevel, "You are using an obsolete parameter: --%s (%s).\nPlease see /usr/share/doc/openvpn/NEWS.Debian.gz for details.",
 
5798
             p[0], PACKAGE_VERSION);
 
5799
    }
5718
5800
#endif
5719
5801
#ifdef TUNSETPERSIST
5720
5802
  else if (streq (p[0], "rmtun"))