0
0
mirror of https://github.com/OpenVPN/openvpn.git synced 2024-09-20 12:02:28 +02:00
Commit Graph

1761 Commits

Author SHA1 Message Date
Selva Nair
d1bd37fd50 Avoid format specifier %zu for Windows compatibility
- Replace %zu by %u and cast the size_t variable to (unsigned int). The
  cast should be safe as in all instances the number involved is small.

Note: mingw64 targets msvcrt.dll runtime that doesn't support %zu and
      print "zu" instead of the number. With -Wformat the compiler
      does warn that z is an unknown conversion type.

v2: Cast to (unsigned int) instead of (int).

Signed-off-by: Selva Nair <selva.nair@gmail.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Acked-by: David Sommerseth <davids@openvpn.net>
Message-Id: <1470956309-31268-1-git-send-email-selva.nair@gmail.com>
URL: https://sourceforge.net/p/openvpn/mailman/message/35274787/
Signed-off-by: David Sommerseth <davids@openvpn.net>
2016-08-12 17:23:34 +02:00
Steffan Karger
dea8917a03 Fix '--cipher none --cipher' crash
As reported in trac #699, OpenVPN crashes when an "--cipher none" option
is followed by "--cipher" (without arguments).  Fix this by removing the
redudant ciphername_defined and authname_defined members of struct options,
and remove support to specify --cipher or --auth without an argument.  That
not only fixes the issue, but also cleans up the code a bit.

v2: don't print a deprecating warning (we'll do that in the 2.3 branch),
    but just rip out support for --cipher and --auth without an argument.

Signed-off-by: Steffan Karger <steffan@karger.me>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <1469541338-1530-1-git-send-email-steffan.karger@fox-it.com>
URL: http://article.gmane.org/gmane.network.openvpn.devel/12106
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2016-07-26 17:13:12 +02:00
Steffan Karger
834f602fd0 Allow ncp-disable and ncp-ciphers to be specified in ccd files
This allows the ncp-disable and ncp-ciphers options to be used in 'client
config dir' files, to disable or change the negotiable crypto parameter
settings for specific clients.

Signed-off-by: Steffan Karger <steffan@karger.me>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <1469472766-25131-1-git-send-email-steffan@karger.me>
URL: http://article.gmane.org/gmane.network.openvpn.devel/12096
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2016-07-25 21:19:29 +02:00
Steffan Karger
a17aa98180 Add server-side support for cipher negotiation
Pushes AES-256-GCM when a connection client advertises IV_NCP=2, and
supports serving connections to clients with different data channel
cipher configuration simultaneously.

v2:
 * Update manpage
 * Add Changes.rst entry

v3:
 * Do not regenerate keys if the client sends a second pull request
 * Don't postpone key generation if client has no IV_NCP support

v4:
 * rebase on client-side NCP v4

Signed-off-by: Steffan Karger <steffan@karger.me>
Acked-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <1467149771-10374-1-git-send-email-steffan@karger.me>
URL: http://article.gmane.org/gmane.network.openvpn.devel/12009
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2016-07-25 17:34:29 +02:00
Steffan Karger
d728ebeda8 Add options to restrict cipher negotiation
Add --ncp-disable to completely disable cipher negotiation, and
--ncp-ciphers to specify which ciphers to accept from the server.

v2:
 * fix --disable-crypto builds
 * use register_signal() instead of operating directly on c->sig
 * add man-page entry for new options

v3:
 * rebased on client-side NCP v3

v4:
 * rebased on client-side NCP v4

Signed-off-by: Steffan Karger <steffan@karger.me>
Acked-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <1467149700-10042-1-git-send-email-steffan@karger.me>
URL: http://article.gmane.org/gmane.network.openvpn.devel/12008
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2016-07-11 21:45:52 +02:00
Arne Schwabe
49817bf0ad Update android documentation to match source code
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <1468248659-27123-1-git-send-email-arne@rfc2549.org>
URL: http://article.gmane.org/gmane.network.openvpn.devel/12074

Signed-off-by: Gert Doering <gert@greenie.muc.de>
2016-07-11 20:54:23 +02:00
Steffan Karger
97894360fa Add client-side support for cipher negotiation
Based on the 'IV_NCP=2' mechanism described in
http://permalink.gmane.org/gmane.network.openvpn.devel/9385.

This is the first patch of a set that adds support for cipher negotiation.
Follow-up patches will add ways to restrict or disable the mechanism, and
add server-side support.

v2:
 * Account for crypto overhead through struct frame.  This is less
   transparant, but the code has been built to work this way.  The
   previous approach didn't work with TCP mode (or --port-share).
 * Calculate the link-mtu sent in the options string based on the crypto
   parameters specified in the config file (prevents link-mtu warnings in
   older peers when connecting).

v3:
 * Use existing max_int() function, instead of new MAX() macro.
 * Fix typo in comment.
 * Do not regenerate keys if the server sends a second push msg
 * Only push IV_NCP if we're pull-client (and thus can do NCP)

v4:
 * Fix rebase errors (OPT_P_NCP sneaked in, but is not introduced till 4/5,
   and tls_peer_info_ncp_ver() is not needed until 5/5).
 * Don't remove comment about key_id increment behaviour in init.c (but
   still add the extra comments in the .h files).

Signed-off-by: Steffan Karger <steffan@karger.me>
Acked-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <1467149635-9726-1-git-send-email-steffan@karger.me>
URL: http://article.gmane.org/gmane.network.openvpn.devel/12007
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2016-07-11 20:29:17 +02:00
Samuli Seppänen
6dd307c864 Deprecate the automatic part of openvpnserv.exe in favor of openvpnserv2.exe
Signed-off-by: Samuli Seppänen <samuli@openvpn.net>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <1467624585-23515-1-git-send-email-samuli@openvpn.net>
URL: http://article.gmane.org/gmane.network.openvpn.devel/12036
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2016-07-11 20:25:17 +02:00
Selva Nair
6aa4c90913 Promptly close the netcmd_semaphore handle after use
If more than one openvpn processes are running and one aborts
without releasing the semaphore, subsequent processes fail to get
a lock for the semaphore. This may be avoided by not keeping open
handles to the semaphore so that Windows can destroy it when no
open handles remain.

See also: http://article.gmane.org/gmane.network.openvpn.devel/11913

Signed-off-by: Selva Nair <selva.nair@gmail.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <1465871689-13533-1-git-send-email-selva.nair@gmail.com>
URL: http://article.gmane.org/gmane.network.openvpn.devel/11919
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2016-07-11 20:07:35 +02:00
Selva Nair
5d429efd97 Exponentially back off on repeated connect retries
- When the number of retries per remote exceeds a limit
  (hard coded to 5), double the restart pause interval
  for each additional retry per remote.
- Trigger a SIGHUP to reset the retry count when the pause
  interval exceeds 1024 times the base value of restart pause.
  (removed in v2 of the patch)

The base value of restart pause is set using --connect-retry
(5 seconds by default).

v2 changes (based on suggestions from Arne Schwabe <arne@rfc2549.org>)

- Do not throw SIGHUP.
- Add an optional argument to "--connect-retry n [m]" where 'm'
  specifies the max value of restart pause interval (default
  300 sec).
  E.g., "--connect-retry 5 1800" will cause the restart pause to
  scale up starting at 5 until it exceeds 1800 seconds at which
  point it gets capped at 1800.
- If n == m no slow down will occur.
- While at it, fix typos and clarify the description of connect-retry-max
  in the man page and Changes.rst

v3 changes (on further feedback from arne@rfc2549.org):
- Limiting the base value of retry wait interval to 16 bits moved
  to options.c
- Apply backoff only in the udp and tcp-client modes. Backing off on
  tcp-server could be exploited by a client in p2p-mode to maliciously
  slow it down (thanks to Arne Schwabe for pointing this out.
- Fix typo in Changes.rst: "third argument" -> "second argument"

Signed-off-by: Selva Nair <selva.nair@gmail.com>
Acked-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <1467732770-19110-1-git-send-email-selva.nair@gmail.com>
URL: http://article.gmane.org/gmane.network.openvpn.devel/12050
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2016-07-11 16:19:12 +02:00
David Sommerseth
365506d170 Remove NOP function and callers
multi_release_io_lock() and the calls to this function are not providing
anything at all.  Lets remove it and make the overall code less suprising.

Signed-off-by: David Sommerseth <dazo@privateinternetaccess.com>
Acked-by: Arne Schwabe <arne@rfc2549.org>
Message-Id: <1467889519-8193-1-git-send-email-openvpn@sf.lists.topphemmelig.net>
URL: http://article.gmane.org/gmane.network.openvpn.devel/12058
2016-07-07 17:22:25 +02:00
Arne Schwabe
2011b8324f Remove http-proxy-retry and socks-proxy-retry.
These options were probably introduced long before we had multiple
remote/connection entries. For all other connection entries, OpenVPN will
go on with the next connection if it fails. For proxies, if it fails in
some ways it works the same, for other failures it completely stops.

Removing the *-proxy-retry and defaulting to retry makes the behavior more
predictiable. Stopping after one try (regardless of reason) can be achieved
with --max-connect-retry 1

V2: Add reason for removing, remove from manpage, give a hint at
   --max-connet-retry
V3: Collapse the two ifs in options.c to one block
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <1466771230-5266-1-git-send-email-arne@rfc2549.org>
URL: http://article.gmane.org/gmane.network.openvpn.devel/11988

Signed-off-by: Gert Doering <gert@greenie.muc.de>
2016-06-24 14:38:09 +02:00
Selva Nair
e4c9bbe6c3 Return process id of openvpn from interactive service to client
- The process id is returned as a message formatted in the same manner
  as error messages from the service to the client: i.e., a three-line
  message with error number formatted as 0x%08x on line 1, followed by
  the PID in format 0x%08x on line 2 and a description that reads as
  "Process ID" on line 3. Error number is set to zero to indicate
  this is an informational message.

This provides a way for service clients to check the status of openvpn
and terminate it without needing management interface or exit event.
Useful when the interactive service is used from a launch script, or
to force-terminate openvpn from the GUI if/when needed.

v2 changes: format of the message changed as described above.

Signed-off-by: Selva Nair <selva.nair@gmail.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <1466736656-27501-1-git-send-email-selva.nair@gmail.com>
URL: http://article.gmane.org/gmane.network.openvpn.devel/11984
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2016-06-24 08:24:07 +02:00
Selva Nair
d023fb661c Fix management-external-cert option parsing error
- Allow --management-external-cert as an alternative to --cert
 - Also make sure --cert and --management-external-cert are not
   both specified, and clarify in the man page that the latter
   must be used with --management-external-key.

Signed-off-by: Selva Nair <selva.nair@gmail.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <1466132093-1178-1-git-send-email-selva.nair@gmail.com>
URL: http://article.gmane.org/gmane.network.openvpn.devel/11929
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2016-06-23 13:42:42 +02:00
Samuli Seppänen
3f0edd8a5a Clarify which Windows versions require which TUN/TAP driver
Signed-off-by: Samuli Seppänen <samuli@openvpn.net>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <1466665610-19289-1-git-send-email-samuli@openvpn.net>
URL: http://article.gmane.org/gmane.network.openvpn.devel/11966
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2016-06-23 11:42:10 +02:00
Samuli Seppänen
d16ea8ba5a Use an up-to-date easy-rsa URL on the man-page
Signed-off-by: Samuli Seppänen <samuli@openvpn.net>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <1466615164-15527-2-git-send-email-samuli@openvpn.net>
URL: http://article.gmane.org/gmane.network.openvpn.devel/11955
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2016-06-23 11:42:00 +02:00
Samuli Seppänen
ac341e6dc6 Mention tap-windows6 in INSTALL file
Signed-off-by: Samuli Seppänen <samuli@openvpn.net>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <1466615164-15527-1-git-send-email-samuli@openvpn.net>
URL: http://article.gmane.org/gmane.network.openvpn.devel/11956
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2016-06-23 11:41:49 +02:00
Arne Schwabe
ec0c1dcabd Add documentation for http-proxy-user-pass option
Patch V2: fix formatting problems
Acked-by: Selva Nair <selva.nair@gmail.com>
Message-Id: <1466167786-13748-1-git-send-email-arne@rfc2549.org>
URL: http://article.gmane.org/gmane.network.openvpn.devel/11933

Signed-off-by: Gert Doering <gert@greenie.muc.de>
2016-06-20 20:25:27 +02:00
James Yonan
c9a35a2081 Added directive to specify HTTP proxy credentials in config.
The inline directive http-proxy-user-pass can be used to
specify proxy credentials in config, e.g.:

http-proxy proxy.tld 3128 auto-nct
<http-proxy-user-pass>
foo
bar
</http-proxy-user-pass>

This usage is already supported by OpenVPN 3.

Signed-off-by: James Yonan <james@openvpn.net>
Acked-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <1456993146-63968-9-git-send-email-james@openvpn.net>
URL: http://article.gmane.org/gmane.network.openvpn.devel/11283
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2016-06-20 20:15:47 +02:00
Steffan Karger
b63f98633d mbedtls: don't set debug threshold if compiled without MBEDTLS_DEBUG_C
For targets with space constraints, one might want to compile mbed TLS
without MBEDTLS_DEBUG_C defined, to save some tens of kilobytes.  Make
sure OpenVPN still compiles if that is the case.

Signed-off-by: Steffan Karger <steffan@karger.me>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <1465934403-22226-1-git-send-email-steffan@karger.me>
URL: http://article.gmane.org/gmane.network.openvpn.devel/11922
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2016-06-14 22:31:31 +02:00
Arne Schwabe
f2134b7bea Remove http-proxy-timeout, socks timeout and set default of server-poll-timeout to 120s
With this change all timeouts before the first packet from the OpenVPN
server are unified into the server-poll-timeout option.

The default of 120s has been chosen to be a safe value is larger as it is
larger the sums of the old small timeouts.

V3: fix some whitespace/typos problems
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <1465656195-12722-1-git-send-email-arne@rfc2549.org>
URL: http://article.gmane.org/gmane.network.openvpn.devel/11899

Signed-off-by: Gert Doering <gert@greenie.muc.de>
2016-06-11 20:01:29 +02:00
Arne Schwabe
960524a9af Complete push-peer-info documentation and allow IV_PLAT_VER for other platforms than Windows if the client UI supplies it.
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <1455624280-3165-1-git-send-email-arne@rfc2549.org>
URL: http://article.gmane.org/gmane.network.openvpn.devel/11175

Signed-off-by: Gert Doering <gert@greenie.muc.de>
2016-06-11 13:25:40 +02:00
Gert Doering
d16072cf17 Change --enable-pedantic to use -std=c99 and not -ansi (C90).
There's quite a bit of our code that fails compilation with
"gcc -pedantic -ansi" and should not be changed - like, LZ4 using
"long long" variables which C90 does not have.  Be pragmatic.

trac #616

Signed-off-by: Gert Doering <gert@greenie.muc.de>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <1465477232-25826-1-git-send-email-gert@greenie.muc.de>
URL: http://article.gmane.org/gmane.network.openvpn.devel/11882
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2016-06-09 15:07:34 +02:00
Gert Doering
46e4b6639a Upgrade bundled compat-lz4 to upstream release r131.
Take upstream release from https://github.com/Cyan4973/lz4/releases,
  copy lz4-r131/lib/lz4.c to src/compat/compat-lz4.c
  copy lz4-r131/lib/lz4.h to src/compat/compat-lz4.h
  change #include line in compat-lz4.c to use "compat-lz4.h" not "lz4.h"
  add "config.h" block and wrap in #ifdef NEED_COMPAT_LZ4 / #endif

No other changes to upstream code.

This commit is quite huge, but this is because we bundled a fairly old
version and upstream refactored quite a lot of code, changed // comments
to /* */ style, etc - to review, compare compat-lz4.* files to upstream.

v2: add missing #ifdef NEED_COMPAT_LZ4 wrapping

Signed-off-by: Gert Doering <gert@greenie.muc.de>
Acked-by: Steffan Karger <steffan.karger@fox-it.com>
Message-Id: <1465473089-20754-1-git-send-email-gert@greenie.muc.de>
URL: http://article.gmane.org/gmane.network.openvpn.devel/11879
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2016-06-09 14:38:13 +02:00
Steffan Karger
d927181412 cleanup: remove alloc_buffers argument from multi_top_init()
multi_top_init() is always called with alloc_buffers=true, so just remove
the argument and alloc unconditionally.

Signed-off-by: Steffan Karger <steffan@karger.me>
Acked-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <1465388443-15484-3-git-send-email-steffan@karger.me>
URL: http://article.gmane.org/gmane.network.openvpn.devel/11851
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2016-06-08 19:55:53 +02:00
Steffan Karger
3c1b19e047 Don't limit max incoming message size based on c2->frame
"Be conservative in what you send, be liberal in what you accept"

When receiving packets, the real limitation of how much data we can accept
is the size of our internal buffers, not the maximum size we expect
incoming packets to have.

I ran into this while working on cipher negotiation, which will need
separate bookkeeping for the required internal buffer size, and the
link/tun MTU.  Basing this code on the buffer size instead of c2->frame
makes that easier.  A nice side-effect of this change is that it
simplifies the code.

This should also reduce the impact of using asymmetric tun/link MTU's,
such as in trac ticket #647.

Signed-off-by: Steffan Karger <steffan@karger.me>
Acked-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <1465388443-15484-2-git-send-email-steffan@karger.me>
URL: http://article.gmane.org/gmane.network.openvpn.devel/11850
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2016-06-08 19:50:22 +02:00
Selva Nair
63b3e000c9 Ignore SIGUSR1/SIGHUP during exit notification
This allows exit notification to complete and finally trigger SIGTERM.
The current practice of allowing a restart in this state clears
the exit notification timer data and thus loses the SIGTERM.

Trac #687

Signed-off-by: Selva Nair <selva.nair@gmail.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <1465274660-11009-2-git-send-email-selva.nair@gmail.com>
URL: http://article.gmane.org/gmane.network.openvpn.devel/11814
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2016-06-07 22:54:38 +02:00
Selva Nair
7f74c27e10 Add an option to filter options received from server
v2 changes:
 - Add the flag "ignore" and have "reject" trigger a restart.
 - Unlimited number of filters: yes, going against the consensus,
   but the code looks simpler and cleaner this way.
 - New commit message to reflect the changes.

Usage: --pull-filter accept|ignore|reject "option"

Permit a client to selectively accept, ignore or reject options
pushed by the server. May be used multiple times. The filters
are applied in the order specified to each pushed option received.
The filtering stops as soon as a match is found. The action "ignore"
removes the option and continues processing the next option, while
"reject" flags an error and restarts the connection with SIGUSR1.

Prefix matching is used so that all options starting with the
specified "option" string are filtered.

Example:

  pull-filter accept "route 192.168."
  pull-filter ignore "route "
  pull-filter accept "ifconfig 10.9.0."
  pull-filter reject "ifconfig "

will ignore all pushed routes except those starting with "192.168."
and reject the assigned ip unless its in the "10.9.0.0/24"
range. A match of the reject filter will trigger a restart. SIGUSR1
restart is used instead of SIGHUP so as to try the next remote
for reconnection.

Note the space at the end of "route " to not reject "route-gateway",
for example. All options not matched by any filter are accepted.

Acknowledges shameless imitation of --push-remove.
Inspired by Trac #682.

Signed-off-by: Selva Nair <selva.nair@gmail.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <1465162884-32520-1-git-send-email-selva.nair@gmail.com>
URL: http://article.gmane.org/gmane.network.openvpn.devel/11808
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2016-06-07 22:31:18 +02:00
Selva Nair
451d2177d7 Make block-outside-dns work with persist-tun
- Remove and recreate WFP filters during restart even when
  tun/tap is not re-opened. This is needed for resolving the remote.
  Patch same as for v2.3 except for passing 'msg_channel'.

See also: http://article.gmane.org/gmane.network.openvpn.user/36990

Signed-off-by: Selva Nair <selva.nair@gmail.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <1465055833-13681-1-git-send-email-selva.nair@gmail.com>
URL: http://article.gmane.org/gmane.network.openvpn.devel/11788
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2016-06-05 19:14:57 +02:00
Selva Nair
895d75cf99 Set WFP engine handle to NULL in win_wfp_uninit()
This was missed by commit 6a33a34dee

Signed-off-by: Selva Nair <selva.nair@gmail.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <1465070945-5426-1-git-send-email-selva.nair@gmail.com>
URL: http://article.gmane.org/gmane.network.openvpn.devel/11789
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2016-06-05 19:07:04 +02:00
Selva Nair
1899393543 Fix the comparison of pull options hash on restart
Signed-off-by: Selva Nair <selva.nair@gmail.com>
Acked-by: Steffan Karger <steffan.karger@fox-it.com>
Message-Id: <1465016263-23048-1-git-send-email-selva.nair@gmail.com>
URL: http://article.gmane.org/gmane.network.openvpn.devel/11783
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2016-06-05 17:18:01 +02:00
David Sommerseth
41ab12f062 Another fix related to unit test framework
Continuing to fix breakage caused by commit 40cb4cfc5d.

It seems it was a conflict in vendor/Makefile.am's distdir target,
confusing autotools so it wouldn't actually parse that directory
properly.  The result was that 'make distcheck' would fail and
tarballs created would just ship with an empty vendor/ directory.

Also remove the 'foreign' AUTOMAKE_OPTIONS flag, as we don't use
that many places at all.  Things work well without this flag.

The comment had to be moved to a single line, otherwise the
white spaces between the end of the variable assignment and the
hash character got added to the variable.

 [v3 - Further improve white space issues, now 'make clean'
       should work too]
 [v2 - Fix white space issues in path variables]

Signed-off-by: David Sommerseth <dazo@privateinternetaccess.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <1464976163-6162-1-git-send-email-openvpn@sf.lists.topphemmelig.net>
URL: http://article.gmane.org/gmane.network.openvpn.devel/11778
2016-06-03 20:31:41 +02:00
Samuli Seppänen
fdc24f1e98 Clarify the fact that build instructions in README are for release tarballs
URL: https://github.com/OpenVPN/openvpn/pull/51
Signed-off-by: Samuli Seppänen <samuli@openvpn.net>
Acked-by: David Sommerseth <dazo@privateinternetaccess.com>
Message-Id: <1464677635-24251-1-git-send-email-samuli@openvpn.net>
URL: http://article.gmane.org/gmane.network.openvpn.devel/11746
Signed-off-by: David Sommerseth <dazo@privateinternetaccess.com>
2016-05-31 19:47:21 +02:00
Ivo Manca
cd538f2c7a Plug memory leak in mbedTLS backend
Signed-off-by: Ivo Manca <pinkel@gmail.com>
Acked-by: Steffan Karger <steffan.karger@fox-it.com>
Acked-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <1464694920-3624-1-git-send-email-pinkel@gmail.com>
URL: http://article.gmane.org/gmane.network.openvpn.devel/11751
Signed-off-by: David Sommerseth <dazo@privateinternetaccess.com>
2016-05-31 17:24:30 +02:00
David Sommerseth
45f6e7991c Only build and run cmocka unit tests if its submodule is initialized
Commit 40cb4cfc5d added infrastructure to write unit tests using
cmocka.  This was implemented using a git submodule to fetch an
up-to-date cmocka test framework.

The issue which appeared was that 'make check' stopped working if
the cmocka submodule was not initialized and updated.  As we do not
want this to be a hard depenency, this patch makes running these
unit tests conditional.  If cmocka has not been initialized, skip
them or if it has been initialized all unit tests will be run.

 [v2 - Also check if cmake is available, as cmocka depends on that
       to be built ]

Signed-off-by: David Sommerseth <dazo@privateinternetaccess.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <1464703645-26640-1-git-send-email-openvpn@sf.lists.topphemmelig.net>
URL: http://article.gmane.org/gmane.network.openvpn.devel/11758
2016-05-31 16:40:29 +02:00
Jeffrey Cutter
4a506b9ca2 Update contrib/pull-resolv-conf/client.up for no DOMAIN
When no DOMAIN is received from push/pull, do not add either domain or
search to the resolv.conf. Fix typo in comment resolv.con[f]. Only add
new line when using domain or search.

URL: https://github.com/OpenVPN/openvpn/pull/34
Acked-by: Steffan Karger <steffan@karger.me>
Signed-off-by: Samuli Seppänen <samuli@openvpn.net>
Acked-by: Steffan Karger <steffan@karger.me>
Message-Id: <1463736310-17846-1-git-send-email-samuli@openvpn.net>
URL: http://article.gmane.org/gmane.network.openvpn.devel/11682
Signed-off-by: David Sommerseth <dazo@privateinternetaccess.com>
2016-05-31 00:17:26 +02:00
Leon Klingele
ac2309b889 Add link to bug tracker
URL: https://github.com/OpenVPN/openvpn/pull/25
Signed-off-by: Samuli Seppänen <samuli@openvpn.net>
Acked-by: David Sommerseth <dazo@privateinternetaccess.com>
Message-Id: <1464638098-19187-1-git-send-email-samuli@openvpn.net>
URL: http://article.gmane.org/gmane.network.openvpn.devel/11735
Signed-off-by: David Sommerseth <dazo@privateinternetaccess.com>
2016-05-31 00:08:42 +02:00
Jens Neuhalfen
4507bb6cd1 Add a test for auth-pam searchandreplace
No functional changes.

Utility functions of auth-pam are split into a dedicated file. This allows
the test programs to easily test these functions without adding
dependencies.

Add a minimal test for searchandreplace as a proof of concept.

[ Modified during commit: Enhanced documentation of functions in utils.h
  to comply with doxygen standards ]

Signed-off-by: Jens Neuhalfen <jens@neuhalfen.name>
Acked-by: Steffan Karger <steffan@karger.me>
Message-Id: <20160525175756.56186-3-openvpn-devel@neuhalfen.name>
URL: http://article.gmane.org/gmane.network.openvpn.devel/11724
Signed-off-by: David Sommerseth <dazo@privateinternetaccess.com>
2016-05-30 23:18:09 +02:00
Jens Neuhalfen
40cb4cfc5d Add unit testing support via cmocka
cmocka [1,2] is a testing framework for C. Adding unit test
capabilities to the openvpn repository will greatly ease the
task of writing correct code.

cmocka source code is added as git submodule in ./vendor. A
submodule approach has been chosen over a classical library
dependency because libcmocka is not available, or only
available in very old versions (e.g. on Ubuntu).

cmocka is build during 'make check' and installed in vendor/dist/.

[1] https://cmocka.org/
[2] https://lwn.net/Articles/558106/

Signed-off-by: Jens Neuhalfen <jens@neuhalfen.name>
Acked-by: Steffan Karger <steffan@karger.me>
Message-Id: <20160525175756.56186-2-openvpn-devel@neuhalfen.name>
URL: http://article.gmane.org/gmane.network.openvpn.devel/11725
Signed-off-by: David Sommerseth <dazo@privateinternetaccess.com>
2016-05-30 22:40:55 +02:00
Selva Nair
600dd9a16f Fix handling of out of memory error in interactive service
Currently realloc failure in UpdateWaitHandles() is handled by
triggering exit_event and waiting for all active worker threads
to terminate. However, at this point the wait handles array
will contain an invalid value (handle of the latest thread that
is terminated), causing a cycle of WAIT_FAILED <-> continue and
trashing of the eventlog.

Fix:
- Update the wait handles again after removing the last thread:
  this should not fail as no extra memory is needed. Do not set
  the exit event; existing connections are not terminated.

- In case of WAIT_FAILED, break out of the while loop and exit
  instead of continue. This usually happens when one or more
  handles are invalid, which is hard to recover from.

Other changes:
- Use minimal initial allocation size so that the realloc code path
  gets exercised (2 or more connections will cause realloc).
- Use a temp variable to check the return value of realloc().
- Initialize handles array pointer to NULL.

v2 changes:
- Increased initial allocation to 10 (warn: now 10 or more connections
  needed to exercise the realloc code path).
- Moved up the declaration of "LPHANDLE tmp" to please stone-age MSVC.

Tested using a dummy realloc that returns NULL.

Signed-off-by: Selva Nair <selva.nair@gmail.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <1463942372-26958-1-git-send-email-selva.nair@gmail.com>
URL: http://article.gmane.org/gmane.network.openvpn.devel/11708
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2016-05-22 22:34:40 +02:00
Samuli Seppänen
698f0dab76 Update CONTRIBUTING.rst to allow GitHub PRs for code review purposes
Signed-off-by: Samuli Seppänen <samuli@openvpn.net>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <1463647909-18383-1-git-send-email-samuli@openvpn.net>
URL: http://article.gmane.org/gmane.network.openvpn.devel/11679
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2016-05-19 11:22:50 +02:00
Josh Cepek
0d8a4ffa22 Push an IPv6 CIDR mask used by the server, not the pool's size
Correctly handle CIDR masks when pushing clients addressing from an IPv6
pool. This change ignores the incorrectly used `bits` argument to the
--ifconfig-ipv6-pool option.

The code to save any provided CIDR mask after the pool IP is left in;
this may someday become useful when we move to allow IPv6 pools without
relying on an IPv4 pool assignment.

Signed-off-by: Josh Cepek <josh.cepek@usa.net>
Acked-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <53F1DA95.7020701@usa.net>
URL: http://article.gmane.org/gmane.network.openvpn.devel/8990
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2016-05-18 08:25:42 +02:00
Gert Doering
970312f185 Implement push-remove option to selectively remove pushed options.
With this option, the server can remove individual options from the
set pushed to a client (call from --client-config-dir file, or from
--client-connect script or plugin).  Options are removed at parse
time, so it is possible to do stuff like:

  push-remove route-ipv6
  push "route-ipv6 fd00::/8"

to first remove all IPv6 route options set so far, then add something
specific (what "push-reset" does to all the options).

Arguments to push-remove are strncmp()'ed to option string, so partial
matches like

  push-remove "route-ipv6 2001:"

are possible ("remove all IPv6 routes starting with 2001:").

Implementation of remove_iroutes_from_push_route_list() had to be changed
slightly to stop it from re-enabling all disabled options again.

v2: documentation (Changes.rst, doc/openvpn.8)
    remove surplus gc_arena
    implement filtering of "ifconfig-ipv6"

v3: correct quoting in commit message
    only handle a single argument per push-remove statement - if multiple
    options are to be removed, just use multiple push-remove statements

Trac #29, #614

Signed-off-by: Gert Doering <gert@greenie.muc.de>
Acked-by: Arne Schwabe <arne@rfc2549.org>
Message-Id: <1463393584-8318-1-git-send-email-gert@greenie.muc.de>
URL: http://article.gmane.org/gmane.network.openvpn.devel/11665
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2016-05-16 20:25:06 +02:00
Selva Nair
3e42a55810 Add support for register-dns through interactive service
The call to the service returns promptly after delegating the job to
a thread, before the task is completed. In the thread, "net stop dnscache",
"net start dnscache", "ipconfig /flushdns" and "ipconfig /register-dns"
are executed in that order.

Parallel execution of these commands is prevented by a lock that is
common to all connections started by the service.

Note: "net stop .." is used instead of "sc stop.." as the latter can
return before the service has fully stopped (in STOP_PENDING state),
causing the subsequent start to fail.

Signed-off-by: Selva Nair <selva.nair@gmail.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <1457671646-4322-1-git-send-email-selva.nair@gmail.com>
URL: http://article.gmane.org/gmane.network.openvpn.devel/11354
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2016-05-16 17:44:45 +02:00
Selva Nair
e3420d5683 Make error non-fatal while deleting address using netsh
During windows power events such as sleep or suspend, the TUN/TAP
I/O aborts and openvpn signals SIGHUP so as to automatically reconnect
on resume (since commit ea66a2b5cdb2..). During the SIGHUP processing
operations such as address and route deletion are expected to fail. Such
failures should be treated as non-fatal to allow for this automatic
recovery logic to work. Currently, when the address deletion is handled
by netsh, errors are treated as M_FATAL. This patch changes the error
level to M_WARN.

Resolves Trac #71 (comments 37 to 43)

Signed-off-by: Selva Nair <selva.nair@gmail.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <1463185884-4355-2-git-send-email-selva.nair@gmail.com>
URL: http://article.gmane.org/gmane.network.openvpn.devel/11656
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2016-05-16 13:34:43 +02:00
Dorian Harmans
e7ec6a3a11 Add CHACHA20-POLY1305 ciphersuite IANA name translations.
Acked-by: Steffan Karger <steffan.karger@fox-it.com>
Message-Id: <1463157892-701-1-git-send-email-dorian@woohooyeah.nl>
URL: http://article.gmane.org/gmane.network.openvpn.devel/11651

Signed-off-by: Gert Doering <gert@greenie.muc.de>
2016-05-15 14:18:00 +02:00
James Yonan
007738e9d6 Fixed port-share bug with DoS potential
Fixed port-share bug that can cause segfault when the number
of concurrent connections is large.

The issue is that the port-share code calls openvpn_connect()
which in turn calls select().  When there are a high number
of concurrent port-share connections, the fd passed to select
can potentially exceed FD_SETSIZE, causing undefined behavior.

The fix is to use poll() (if available) instead of select().

Signed-off-by: James Yonan <james@openvpn.net>
Acked-by: Steffan Karger <steffan.karger@fox-it.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <CAA1Abx+2E2FZN-y6P=mkKpSuZ7bOV5m6rUMTx3V7UP2qPMjZPg@mail.gmail.com>
URL: http://article.gmane.org/gmane.network.openvpn.devel/11626
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2016-05-09 20:58:17 +02:00
Jens Neuhalfen
f40f10ea96 Prevent integration test timeout bc. of sudo
Integration tests run by t_client.sh use sudo to run openvpn as root.

If the t_client.sh script is configured to use sudo then the user
must enter the password quickly because t_client assumes a startup
failure if openvpn does not start quick enough.

If the user is not quick enough, then the tests fails.

This change will refresh the sudo timestamp at the start of the script.

Tested on MacOS X & Ubuntu Precise

Signed-off-by: Jens Neuhalfen <jens@neuhalfen.name>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <280154CA-9468-429B-BCAC-DB632C0AFB32@neuhalfen.name>
URL: http://article.gmane.org/gmane.network.openvpn.devel/11622
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2016-05-09 20:17:01 +02:00
Steffan Karger
d54a2488a0 Remove trailing newline from verify callback error messages
Signed-off-by: Steffan Karger <steffan@karger.me>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <1462453347-3272-1-git-send-email-steffan@karger.me>
URL: http://article.gmane.org/gmane.network.openvpn.devel/11609
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2016-05-05 20:10:05 +02:00
Gert Doering
1ae17b7e97 Fix library order in -lmbedtls test.
-lmbedx509 needs to be before -lmbedcrypto, otherwise you end up with
unresolved symbols mbedtls_pk_load_file and mbedtls_pk_parse_subpubkey
on systems with static mbedtls libraries and a linker that only does
one left-to-right resolving pass through these.

Signed-off-by: Gert Doering <gert@greenie.muc.de>
Acked-by: Steffan Karger <steffan.karger@fox-it.com>
Message-Id: <20160505115050.GA81579@greenie.muc.de>
URL: http://article.gmane.org/gmane.network.openvpn.devel/11605
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2016-05-05 14:29:01 +02:00