summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.svnignore2
-rw-r--r--COPYING4
-rw-r--r--ChangeLog175
-rw-r--r--INSTALL7
-rw-r--r--Makefile.am13
-rw-r--r--PORTS2
-rw-r--r--README2
-rw-r--r--base64.c8
-rw-r--r--base64.h2
-rw-r--r--basic.h2
-rw-r--r--buffer.c79
-rw-r--r--buffer.h14
-rw-r--r--circ_list.h2
-rw-r--r--common.h11
-rw-r--r--config-win32.h (renamed from config-win32.h.in)625
-rw-r--r--configure.ac56
-rw-r--r--contrib/OCSP_check/OCSP_check.sh111
-rw-r--r--contrib/pull-resolv-conf/client.down53
-rw-r--r--contrib/pull-resolv-conf/client.up90
-rw-r--r--crypto.c14
-rw-r--r--crypto.h2
-rw-r--r--dhcp.c2
-rw-r--r--dhcp.h2
-rwxr-xr-xdoclean1
-rwxr-xr-xeasy-rsa/2.0/build-ca2
-rwxr-xr-xeasy-rsa/2.0/build-dh2
-rwxr-xr-xeasy-rsa/2.0/build-inter2
-rwxr-xr-xeasy-rsa/2.0/build-key2
-rwxr-xr-xeasy-rsa/2.0/build-key-pass2
-rwxr-xr-xeasy-rsa/2.0/build-key-pkcs122
-rwxr-xr-xeasy-rsa/2.0/build-key-server2
-rwxr-xr-xeasy-rsa/2.0/build-req2
-rwxr-xr-xeasy-rsa/2.0/build-req-pass2
-rwxr-xr-xeasy-rsa/2.0/clean-all2
-rwxr-xr-xeasy-rsa/2.0/inherit-inter2
-rwxr-xr-xeasy-rsa/2.0/list-crl2
-rwxr-xr-xeasy-rsa/2.0/pkitool2
-rwxr-xr-xeasy-rsa/2.0/revoke-full2
-rwxr-xr-xeasy-rsa/2.0/sign-req2
-rw-r--r--errlevel.h2
-rw-r--r--error.c16
-rw-r--r--error.h2
-rw-r--r--event.c2
-rw-r--r--event.h2
-rw-r--r--fdmisc.c2
-rw-r--r--fdmisc.h2
-rw-r--r--forward-inline.h2
-rw-r--r--forward.c24
-rw-r--r--forward.h2
-rw-r--r--fragment.c2
-rw-r--r--fragment.h2
-rw-r--r--gremlin.c2
-rw-r--r--gremlin.h2
-rw-r--r--helper.c2
-rw-r--r--helper.h2
-rw-r--r--httpdigest.c143
-rw-r--r--httpdigest.h60
-rw-r--r--images/Makefile.am2
-rw-r--r--init.c285
-rw-r--r--init.h2
-rw-r--r--install-win32/Makefile.am2
-rw-r--r--install-win32/buildinstaller2
-rw-r--r--install-win32/getgui3
-rw-r--r--install-win32/getxgui6
-rw-r--r--install-win32/maketap100
-rw-r--r--install-win32/maketapinstall72
-rwxr-xr-xinstall-win32/openvpn.nsi2
-rw-r--r--install-win32/settings.in39
-rw-r--r--install-win32/winconfig3
-rw-r--r--integer.h2
-rw-r--r--interval.c2
-rw-r--r--interval.h2
-rw-r--r--list.c2
-rw-r--r--list.h2
-rw-r--r--lzo.c2
-rw-r--r--lzo.h2
-rw-r--r--makefile.w32-vc186
-rw-r--r--manage.c253
-rw-r--r--manage.h15
-rw-r--r--mbuf.c2
-rw-r--r--mbuf.h2
-rw-r--r--memcmp.c2
-rw-r--r--memdbg.h2
-rw-r--r--misc.c234
-rw-r--r--misc.h49
-rw-r--r--mroute.c2
-rw-r--r--mroute.h2
-rw-r--r--mss.c2
-rw-r--r--mss.h2
-rw-r--r--msvc/autodefs.h.in20
-rw-r--r--msvc/config.py93
-rw-r--r--msvc/msvc.mak52
-rw-r--r--mtcp.c2
-rw-r--r--mtcp.h2
-rw-r--r--mtu.c2
-rw-r--r--mtu.h2
-rw-r--r--mudp.c2
-rw-r--r--mudp.h2
-rw-r--r--multi.c39
-rw-r--r--multi.h2
-rw-r--r--occ-inline.h2
-rw-r--r--occ.c2
-rw-r--r--occ.h2
-rw-r--r--openvpn-plugin.h5
-rw-r--r--openvpn.81694
-rw-r--r--openvpn.c4
-rw-r--r--openvpn.h2
-rw-r--r--options.c283
-rw-r--r--options.h45
-rw-r--r--otime.c2
-rw-r--r--otime.h2
-rw-r--r--packet_id.c2
-rw-r--r--packet_id.h2
-rw-r--r--perf.c2
-rw-r--r--perf.h2
-rw-r--r--pf-inline.h2
-rw-r--r--pf.c40
-rw-r--r--pf.h2
-rw-r--r--ping-inline.h2
-rw-r--r--ping.c4
-rw-r--r--ping.h2
-rw-r--r--pkcs11.c2
-rw-r--r--pkcs11.h2
-rw-r--r--plugin.c2
-rw-r--r--plugin.h2
-rw-r--r--plugin/auth-pam/auth-pam.c44
-rw-r--r--plugin/defer/simple.c2
-rw-r--r--plugin/down-root/down-root.c2
-rw-r--r--plugin/examples/log.c2
-rw-r--r--plugin/examples/simple.c2
-rw-r--r--pool.c2
-rw-r--r--pool.h2
-rw-r--r--proto.c2
-rw-r--r--proto.h2
-rw-r--r--proxy.c534
-rw-r--r--proxy.h28
-rw-r--r--ps.c2
-rw-r--r--ps.h2
-rw-r--r--push.c45
-rw-r--r--push.h2
-rw-r--r--pushlist.h2
-rw-r--r--reliable.c2
-rw-r--r--reliable.h4
-rw-r--r--route.c59
-rw-r--r--route.h4
-rwxr-xr-xsample-config-files/firewall.sh2
-rwxr-xr-xsample-scripts/bridge-start2
-rwxr-xr-xsample-scripts/bridge-stop2
-rw-r--r--schedule.c2
-rw-r--r--schedule.h2
-rw-r--r--service-win32/Makefile.am2
-rwxr-xr-xservice-win32/openvpnserv.c2
-rw-r--r--service-win32/service.c4
-rw-r--r--session_id.c2
-rw-r--r--session_id.h2
-rw-r--r--shaper.c2
-rw-r--r--shaper.h2
-rw-r--r--sig.c4
-rw-r--r--sig.h2
-rw-r--r--socket.c46
-rw-r--r--socket.h20
-rw-r--r--socks.c2
-rw-r--r--socks.h2
-rw-r--r--ssl.c322
-rw-r--r--ssl.h34
-rw-r--r--status.c6
-rw-r--r--status.h2
-rw-r--r--syshead.h46
-rw-r--r--t_client.rc-sample83
-rwxr-xr-xt_client.sh.in298
-rwxr-xr-xtap-win32/SOURCES.in4
-rwxr-xr-xtap-win32/common.h12
-rwxr-xr-xtap-win32/constants.h2
-rwxr-xr-xtap-win32/dhcp.c2
-rwxr-xr-xtap-win32/dhcp.h2
-rwxr-xr-xtap-win32/endian.h2
-rwxr-xr-xtap-win32/error.c2
-rwxr-xr-xtap-win32/error.h2
-rwxr-xr-xtap-win32/hexdump.c2
-rwxr-xr-xtap-win32/hexdump.h2
-rwxr-xr-xtap-win32/i386/OemWin2k.inf.in2
-rwxr-xr-xtap-win32/instance.c2
-rwxr-xr-xtap-win32/lock.h2
-rwxr-xr-xtap-win32/macinfo.c2
-rwxr-xr-xtap-win32/macinfo.h2
-rwxr-xr-xtap-win32/mem.c2
-rwxr-xr-xtap-win32/proto.h2
-rwxr-xr-xtap-win32/prototypes.h2
-rwxr-xr-xtap-win32/resource.rc5
-rwxr-xr-xtap-win32/tapdrvr.c11
-rwxr-xr-xtap-win32/types.h2
-rw-r--r--tun.c65
-rw-r--r--tun.h7
-rw-r--r--version.m42
-rw-r--r--win/__init__.py0
-rw-r--r--win/autodefs.h.in31
-rw-r--r--win/build.py22
-rw-r--r--win/build_all.py59
-rw-r--r--win/build_ddk.py54
-rw-r--r--win/build_exe.py15
-rw-r--r--win/config.py18
-rw-r--r--win/config_all.py13
-rw-r--r--win/config_tap.py35
-rw-r--r--win/config_ti.py18
-rw-r--r--win/js.py10
-rw-r--r--win/make_dist.py56
-rw-r--r--win/msvc.mak.in57
-rw-r--r--win/settings.in68
-rw-r--r--win/show.py10
-rw-r--r--win/sign.py19
-rw-r--r--win/tap_span.py129
-rw-r--r--win/wb.py215
-rw-r--r--win32.c10
-rw-r--r--win32.h4
214 files changed, 5623 insertions, 2191 deletions
diff --git a/.svnignore b/.svnignore
index 34bbff2..c02d2b8 100644
--- a/.svnignore
+++ b/.svnignore
@@ -1,4 +1,5 @@
*.o
+*.obj
config.status
config.log
config.guess
@@ -12,7 +13,6 @@ config.h
Makefile
config.h.in
configure
-config-win32.h
config.sub
openvpn.spec
stamp-h1
diff --git a/COPYING b/COPYING
index 597c10a..f6e5c43 100644
--- a/COPYING
+++ b/COPYING
@@ -1,6 +1,6 @@
OpenVPN (TM) -- An Open Source VPN daemon
-Copyright (C) 2002-2009 OpenVPN Technologies, Inc. <sales@openvpn.net>
+Copyright (C) 2002-2010 OpenVPN Technologies, Inc. <sales@openvpn.net>
This distribution contains multiple components, some
of which fall under different licenses. By using OpenVPN
@@ -52,7 +52,7 @@ TAP-Win32/TAP-Win64 Driver license:
Damion K. Wilson.
The source and object code of the TAP-Win32/TAP-Win64 driver
- is Copyright (C) 2002-2009 OpenVPN Technologies, Inc., and is released under
+ is Copyright (C) 2002-2010 OpenVPN Technologies, Inc., and is released under
the GPL version 2.
Windows DDK Samples:
diff --git a/ChangeLog b/ChangeLog
index 3cb33e7..2ae829f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,178 @@
OpenVPN Change Log
-Copyright (C) 2002-2009 OpenVPN Technologies, Inc. <sales@openvpn.net>
+Copyright (C) 2002-2010 OpenVPN Technologies, Inc. <sales@openvpn.net>
+
+2010.11.18 -- Version 2.2-beta4
+
+David Sommerseth (10):
+ Clarified --explicit-exit-notify man page entry
+ Clean-up: Remove pthread and mutex locking code
+ Clean-up: Remove more dead and inactive code paths
+ Clean-up: Removing useless code - hash related functions
+ Use stricter snprintf() formatting in socks_username_password_auth() (v3)
+ Fix compiler warnings about not used dummy() functions
+ Fixed potential misinterpretation of boolean logic
+ Only add some functions when really needed
+ Removed functions not being used anywhere
+ Merged add_bypass_address() and add_host_route_if_nonlocal()
+
+Gert Doering (3):
+ Integrate support for TAP mode on Solaris, written by Kazuyoshi Aizawa <admin2@whiteboard.ne.jp>.
+ Make "topology subnet" work on Solaris
+ Improved man page entry for script_type
+
+James Yonan (5):
+ Fixed initialization bug in route_list_add_default_gateway (Gert Doering).
+ Implement challenge/response authentication support in client mode
+ Make base64.h have the same conditional compilation expression as base64.c.
+ Fixed compiling issues when using --disable-crypto
+ In verify_callback, the subject var should be freed by OPENSSL_free, not free
+
+Jesse Young (1):
+ Remove hardcoded path to resolvconf
+
+Lars Hupel (1):
+ Add HTTP/1.1 Host header
+
+Pierre Bourdon (1):
+ Adding support for SOCKS plain text authentication
+
+Samuli Seppänen (2):
+ Added check for variable CONFIGURE_DEFINES into options.c
+ Added command-line option parser and an unsigned build option to build_all.py
+
+2010.08.21 -- Version 2.2-beta3
+
+* Attempt to fix issue where domake-win build system was not properly
+ signing drivers and .exe files.
+
+ Added win/tap_span.py for building multiple versions of the TAP driver
+ and tapinstall binaries using different DDK versions to span from Win2K
+ to Win7 and beyond.
+
+* Community patches
+ David Sommerseth (2):
+ Test framework improvment - Do not FAIL if t_client.rc is missing
+ More t_client.sh updates - exit with SKIP when we want to skip
+
+ Gert Doering (4):
+ Fix compile problems on NetBSD and OpenBSD
+ Fix <net/if.h> compile time problems on OpenBSD for good
+ full "VPN client connect" test framework for OpenVPN
+ Build t_client.sh by configure at run-time.
+
+ chantra (1):
+ Fixes openssl-1.0.0 compilation warning
+
+2010.08.16 -- Version 2.2-beta2
+
+* Windows security issue:
+ Fixed potential local privilege escalation vulnerability in
+ Windows service. The Windows service did not properly quote the
+ executable filename passed to CreateService. A local attacker
+ with write access to the root directory C:\ could create an
+ executable that would be run with the same privilege level as
+ the OpenVPN Windows service. However, since non-Administrative
+ users normally lack write permission on C:\, this vulnerability
+ is generally not exploitable except on older versions of Windows
+ (such as Win2K) where the default permissions on C:\ would allow
+ any user to create files there.
+ Credit: Scott Laurie, MWR InfoSecurity
+
+* Added Python-based based alternative build system for Windows using
+ Visual Studio 2008 (in win directory).
+
+* When aborting in a non-graceful way, try to execute do_close_tun in
+ init.c prior to daemon exit to ensure that the tun/tap interface is
+ closed and any added routes are deleted.
+
+* Fixed an issue where AUTH_FAILED was not being properly delivered
+ to the client when a bad password is given for mid-session reauth,
+ causing the connection to fail without an error indication.
+
+* Don't advance to the next connection profile on AUTH_FAILED errors.
+
+* Fixed an issue in the Management Interface that could cause
+ a process hang with 100% CPU utilization in --management-client
+ mode if the management interface client disconnected at the
+ point where credentials are queried.
+
+* Fixed an issue where if reneg-sec was set to 0 on the client,
+ so that the server-side value would take precedence,
+ the auth_deferred_expire_window function would incorrectly
+ return a window period of 0 seconds. In this case, the
+ correct window period should be the handshake window
+ period.
+
+* Modified ">PASSWORD:Verification Failed" management interface
+ notification to include a client reason string:
+
+ >PASSWORD:Verification Failed: 'AUTH_TYPE' ['REASON_STRING']
+
+* Enable exponential backoff in reliability layer
+ retransmits.
+
+* Set socket buffers (SO_SNDBUF and SO_RCVBUF) immediately after
+ socket is created rather than waiting until after connect/listen.
+
+* Management interface performance optimizations:
+
+ 1. Added env-filter MI command to perform filtering on env vars
+ passed through as a part of --management-client-auth
+
+ 2. man_write will now try to aggregate output into larger blocks
+ (up to 1024 bytes) for more efficient i/o
+
+* Fixed minor issue in Windows TAP driver DEBUG builds
+ where non-null-terminated unicode strings were being
+ printed incorrectly.
+
+* Fixed issue on Windows with MSVC compiler, where TCP_NODELAY support
+ was not being compiled in.
+
+* Proxy improvements:
+
+ Improved the ability of http-auth "auto" flag to dynamically detect
+ the auth method required by the proxy.
+
+ Added http-auth "auto-nct" flag to reject weak proxy auth methods.
+
+ Added HTTP proxy digest authentication method.
+
+ Removed extraneous openvpn_sleep calls from proxy.c.
+
+* Implemented http-proxy-override and http-proxy-fallback directives to make it
+ easier for OpenVPN client UIs to start a pre-existing client config file with
+ proxy options, or to adaptively fall back to a proxy connection if a direct
+ connection fails.
+
+* Implemented a key/value auth channel from client to server.
+
+* Fixed issue where bad creds provided by the management interface
+ for HTTP Proxy Basic Authentication would go into an infinite
+ retry-fail loop instead of requerying the management interface for
+ new creds.
+
+* Added support for MSVC debugging of openvpn.exe in settings.in:
+
+ # Build debugging version of openvpn.exe
+ !define PRODUCT_OPENVPN_DEBUG
+
+* Implemented multi-address DNS expansion on the network field of route
+ commands.
+
+ When only a single IP address is desired from a multi-address DNS
+ expansion, use the first address rather than a random selection.
+
+* Added --register-dns option for Windows.
+
+ Fixed some issues on Windows with --log, subprocess creation
+ for command execution, and stdout/stderr redirection.
+
+* Fixed an issue where application payload transmissions on the
+ TLS control channel (such as AUTH_FAILED) that occur during
+ or immediately after a TLS renegotiation might be dropped.
+
+* Added warning about tls-remote option in man page.
2009.12.11 -- Version 2.1.1
diff --git a/INSTALL b/INSTALL
index ea1124a..7af6426 100644
--- a/INSTALL
+++ b/INSTALL
@@ -1,6 +1,6 @@
Installation instructions for OpenVPN, a Secure Tunneling Daemon
-Copyright (C) 2002-2009 OpenVPN Technologies, Inc. This program is free software;
+Copyright (C) 2002-2010 OpenVPN Technologies, Inc. This program is free software;
you can redistribute it and/or modify
it under the terms of the GNU General Public License version 2
as published by the Free Software Foundation.
@@ -12,9 +12,12 @@ QUICK START:
Unix:
./configure && make && make-install
- Windows:
+ Windows MinGW, using MSYS bash shell:
./domake-win (see comments in the script for more info)
+ Windows Visual Studio:
+ python win\build_all.py
+
*************************************************************************
To download OpenVPN, go to:
diff --git a/Makefile.am b/Makefile.am
index c7b91c8..41f2008 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -5,7 +5,7 @@
# packet encryption, packet authentication, and
# packet compression.
#
-# Copyright (C) 2002-2009 OpenVPN Technologies, Inc. <sales@openvpn.net>
+# Copyright (C) 2002-2010 OpenVPN Technologies, Inc. <sales@openvpn.net>
# Copyright (C) 2010 David Sommerseth <dazo@users.sourceforge.net>
#
# This program is free software; you can redistribute it and/or modify
@@ -37,7 +37,7 @@ MAINTAINERCLEANFILES = \
$(srcdir)/install-sh $(srcdir)/ltmain.sh $(srcdir)/missing \
$(srcdir)/depcomp $(srcdir)/aclocal.m4 \
$(srcdir)/config.guess $(srcdir)/config.sub \
- $(srcdir)/config-win32.h $(srcdir)/openvpn.spec
+ $(srcdir)/openvpn.spec
CLEANFILES = openvpn.8.html configure.h
EXTRA_DIST = \
@@ -49,18 +49,18 @@ EXTRA_DIST = \
tap-win32 \
contrib \
debug \
- plugin
+ plugin \
+ win
SUBDIRS = \
images \
service-win32 \
install-win32
-TESTS = t_lpback.sh t_cltsrv.sh
+TESTS = t_client.sh t_lpback.sh t_cltsrv.sh
sbin_PROGRAMS = openvpn
-dist_noinst_HEADERS = \
- config-win32.h
+dist_noinst_HEADERS =
dist_noinst_SCRIPTS = \
$(TESTS) \
@@ -91,6 +91,7 @@ openvpn_SOURCES = \
fragment.c fragment.h \
gremlin.c gremlin.h \
helper.c helper.h \
+ httpdigest.c httpdigest.h \
lladdr.c lladdr.h \
init.c init.h \
integer.h \
diff --git a/PORTS b/PORTS
index 5a1497e..735493c 100644
--- a/PORTS
+++ b/PORTS
@@ -1,5 +1,5 @@
OpenVPN
-Copyright (C) 2002-2009 OpenVPN Technologies, Inc. <sales@openvpn.net>
+Copyright (C) 2002-2010 OpenVPN Technologies, Inc. <sales@openvpn.net>
OpenVPN has been written to try to avoid features
that are not standardized well across different
diff --git a/README b/README
index f0e7a3e..2c5e6f6 100644
--- a/README
+++ b/README
@@ -1,6 +1,6 @@
OpenVPN -- A Secure tunneling daemon
-Copyright (C) 2002-2009 OpenVPN Technologies, Inc. This program is free software;
+Copyright (C) 2002-2010 OpenVPN Technologies, Inc. This program is free software;
you can redistribute it and/or modify
it under the terms of the GNU General Public License version 2
as published by the Free Software Foundation.
diff --git a/base64.c b/base64.c
index 7d876a6..3449ae5 100644
--- a/base64.c
+++ b/base64.c
@@ -33,7 +33,7 @@
#include "syshead.h"
-#if defined(ENABLE_HTTP_PROXY) || defined(ENABLE_PKCS11)
+#if defined(ENABLE_HTTP_PROXY) || defined(ENABLE_PKCS11) || defined(ENABLE_CLIENT_CR)
#include "base64.h"
@@ -80,8 +80,6 @@ base64_encode(const void *data, int size, char **str)
return strlen(s);
}
-#if NTLM
-
static int
pos(char c)
{
@@ -137,8 +135,6 @@ base64_decode(const char *str, void *data)
return q - (unsigned char *) data;
}
-#endif /* NTLM, PKCS#11 */
-
#else
static void dummy(void) {}
-#endif
+#endif /* ENABLE_HTTP_PROXY, ENABLE_PKCS11, ENABLE_CLIENT_CR */
diff --git a/base64.h b/base64.h
index a966b2d..968d18d 100644
--- a/base64.h
+++ b/base64.h
@@ -34,7 +34,7 @@
#ifndef _BASE64_H_
#define _BASE64_H_
-#ifdef ENABLE_HTTP_PROXY
+#if defined(ENABLE_HTTP_PROXY) || defined(ENABLE_PKCS11) || defined(ENABLE_CLIENT_CR)
int base64_encode(const void *data, int size, char **str);
int base64_decode(const char *str, void *data);
diff --git a/basic.h b/basic.h
index 6d8a8ad..88539e2 100644
--- a/basic.h
+++ b/basic.h
@@ -5,7 +5,7 @@
* packet encryption, packet authentication, and
* packet compression.
*
- * Copyright (C) 2002-2009 OpenVPN Technologies, Inc. <sales@openvpn.net>
+ * Copyright (C) 2002-2010 OpenVPN Technologies, Inc. <sales@openvpn.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2
diff --git a/buffer.c b/buffer.c
index 729495c..947df90 100644
--- a/buffer.c
+++ b/buffer.c
@@ -5,7 +5,7 @@
* packet encryption, packet authentication, and
* packet compression.
*
- * Copyright (C) 2002-2009 OpenVPN Technologies, Inc. <sales@openvpn.net>
+ * Copyright (C) 2002-2010 OpenVPN Technologies, Inc. <sales@openvpn.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2
@@ -42,7 +42,7 @@ array_mult_safe (const size_t m1, const size_t m2, const size_t extra)
}
void
-buf_size_error (size_t size)
+buf_size_error (const size_t size)
{
msg (M_FATAL, "fatal buffer size error, size=%lu", (unsigned long)size);
}
@@ -891,8 +891,11 @@ buffer_list_new (const int max_size)
void
buffer_list_free (struct buffer_list *ol)
{
- buffer_list_reset (ol);
- free (ol);
+ if (ol)
+ {
+ buffer_list_reset (ol);
+ free (ol);
+ }
}
bool
@@ -919,9 +922,21 @@ buffer_list_reset (struct buffer_list *ol)
void
buffer_list_push (struct buffer_list *ol, const unsigned char *str)
{
- if (!ol->max_size || ol->size < ol->max_size)
+ if (str)
+ {
+ const size_t len = strlen ((const char *)str);
+ struct buffer_entry *e = buffer_list_push_data (ol, str, len+1);
+ if (e)
+ e->buf.len = len; /* Don't count trailing '\0' as part of length */
+ }
+}
+
+struct buffer_entry *
+buffer_list_push_data (struct buffer_list *ol, const uint8_t *data, size_t size)
+{
+ struct buffer_entry *e = NULL;
+ if (data && (!ol->max_size || ol->size < ol->max_size))
{
- struct buffer_entry *e;
ALLOC_OBJ_CLEAR (e, struct buffer_entry);
++ol->size;
@@ -935,24 +950,66 @@ buffer_list_push (struct buffer_list *ol, const unsigned char *str)
ASSERT (!ol->head);
ol->head = e;
}
- e->buf = string_alloc_buf ((const char *) str, NULL);
+ e->buf = alloc_buf (size);
+ memcpy (e->buf.data, data, size);
+ e->buf.len = (int)size;
ol->tail = e;
}
+ return e;
}
-const struct buffer *
+struct buffer *
buffer_list_peek (struct buffer_list *ol)
{
- if (ol->head)
+ if (ol && ol->head)
return &ol->head->buf;
else
return NULL;
}
-static void
+void
+buffer_list_aggregate (struct buffer_list *bl, const size_t max)
+{
+ if (bl->head)
+ {
+ struct buffer_entry *more = bl->head;
+ size_t size = 0;
+ int count = 0;
+ for (count = 0; more && size <= max; ++count)
+ {
+ size += BLEN(&more->buf);
+ more = more->next;
+ }
+
+ if (count >= 2)
+ {
+ int i;
+ struct buffer_entry *e = bl->head, *f;
+
+ ALLOC_OBJ_CLEAR (f, struct buffer_entry);
+ f->buf.data = malloc (size);
+ check_malloc_return (f->buf.data);
+ f->buf.capacity = size;
+ for (i = 0; e && i < count; ++i)
+ {
+ struct buffer_entry *next = e->next;
+ buf_copy (&f->buf, &e->buf);
+ free_buf (&e->buf);
+ free (e);
+ e = next;
+ }
+ bl->head = f;
+ f->next = more;
+ if (!more)
+ bl->tail = f;
+ }
+ }
+}
+
+void
buffer_list_pop (struct buffer_list *ol)
{
- if (ol->head)
+ if (ol && ol->head)
{
struct buffer_entry *e = ol->head->next;
free_buf (&ol->head->buf);
diff --git a/buffer.h b/buffer.h
index 399a31b..3b24d09 100644
--- a/buffer.h
+++ b/buffer.h
@@ -5,7 +5,7 @@
* packet encryption, packet authentication, and
* packet compression.
*
- * Copyright (C) 2002-2009 OpenVPN Technologies, Inc. <sales@openvpn.net>
+ * Copyright (C) 2002-2010 OpenVPN Technologies, Inc. <sales@openvpn.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2
@@ -723,6 +723,12 @@ void gc_transfer (struct gc_arena *dest, struct gc_arena *src);
void x_gc_free (struct gc_arena *a);
+static inline bool
+gc_defined (struct gc_arena *a)
+{
+ return a->list != NULL;
+}
+
static inline void
gc_init (struct gc_arena *a)
{
@@ -844,8 +850,12 @@ bool buffer_list_defined (const struct buffer_list *ol);
void buffer_list_reset (struct buffer_list *ol);
void buffer_list_push (struct buffer_list *ol, const unsigned char *str);
-const struct buffer *buffer_list_peek (struct buffer_list *ol);
+struct buffer_entry *buffer_list_push_data (struct buffer_list *ol, const uint8_t *data, size_t size);
+struct buffer *buffer_list_peek (struct buffer_list *ol);
void buffer_list_advance (struct buffer_list *ol, int n);
+void buffer_list_pop (struct buffer_list *ol);
+
+void buffer_list_aggregate (struct buffer_list *bl, const size_t max);
struct buffer_list *buffer_list_file (const char *fn, int max_line_len);
diff --git a/circ_list.h b/circ_list.h
index 2b8305f..583701a 100644
--- a/circ_list.h
+++ b/circ_list.h
@@ -5,7 +5,7 @@
* packet encryption, packet authentication, and
* packet compression.
*
- * Copyright (C) 2002-2009 OpenVPN Technologies, Inc. <sales@openvpn.net>
+ * Copyright (C) 2002-2010 OpenVPN Technologies, Inc. <sales@openvpn.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2
diff --git a/common.h b/common.h
index 3ee3fc8..ff3a0d5 100644
--- a/common.h
+++ b/common.h
@@ -5,7 +5,7 @@
* packet encryption, packet authentication, and
* packet compression.
*
- * Copyright (C) 2002-2009 OpenVPN Technologies, Inc. <sales@openvpn.net>
+ * Copyright (C) 2002-2010 OpenVPN Technologies, Inc. <sales@openvpn.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2
@@ -76,8 +76,15 @@ typedef unsigned long ptr_type;
/*
* This parameter controls the TLS channel buffer size and the
* maximum size of a single TLS message (cleartext).
+ * This parameter must be >= PUSH_BUNDLE_SIZE
*/
-#define TLS_CHANNEL_BUF_SIZE 1024
+#define TLS_CHANNEL_BUF_SIZE 2048
+
+/*
+ * This parameter controls the maximum size of a bundle
+ * of pushed options.
+ */
+#define PUSH_BUNDLE_SIZE 1024
/*
* A sort of pseudo-filename for data provided inline within
diff --git a/config-win32.h.in b/config-win32.h
index a81de0c..be0b320 100644
--- a/config-win32.h.in
+++ b/config-win32.h
@@ -1,320 +1,305 @@
-/*
- * OpenVPN -- An application to securely tunnel IP networks
- * over a single UDP port, with support for SSL/TLS-based
- * session authentication and key exchange,
- * packet encryption, packet authentication, and
- * packet compression.
- *
- * Copyright (C) 2002-2009 OpenVPN Technologies, Inc. <sales@openvpn.net>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program (see the file COPYING included with this
- * distribution); if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-/*
- * Configuration header for Win32 using the mingw environment.
- * Manually edited based on linux version as generated by autoconf.
- *
- * config-win32.h is normally generated by copying
- * config-win32.h.in -> config-win32.h and replacing
- * [ampersand] VERSION [ampersand]
- * with the appropriate version #. This is normally
- * done automatically by configure.ac
- */
-
-#include <windows.h>
-#include <winsock2.h>
-#include "autodefs/defs.h"
-
-#define sleep(x) Sleep((x)*1000)
-
-#define random rand
-#define srandom srand
-
-typedef unsigned long in_addr_t;
-
-#ifndef _SSIZE_T_
-#define _SSIZE_T_
- typedef unsigned int ssize_t;
-#endif
-
-/* Append a label to program startup title */
-/*#define DEBUG_LABEL "DEBUG1"*/
-
-/* Should we print debug info from driver? */
-#ifdef PRODUCT_TAP_DEBUG
-#define TAP_WIN32_DEBUG
-#endif
-
-/*
- * Minimum TAP-Win32 version number expected by userspace
- *
- * The TAP-Win32 version number is defined in tap-win32/SOURCES
- */
-#define TAP_ID @TAP_ID@
-#define TAP_WIN32_MIN_MAJOR @TAP_WIN32_MIN_MAJOR@
-#define TAP_WIN32_MIN_MINOR @TAP_WIN32_MIN_MINOR@
-
-/* Enable client/server capability */
-#define ENABLE_CLIENT_SERVER 1
-
-/* Enable client capability only */
-/* #undef ENABLE_CLIENT_ONLY */
-
-/* Enable management server capability */
-#define ENABLE_MANAGEMENT 1
-
-/* Enable PKCS#11 support */
-#define USE_PKCS11 1
-
-/* Enable HTTP proxy support */
-#define ENABLE_HTTP_PROXY 1
-
-/* Enable Socks proxy support */
-#define ENABLE_SOCKS 1
-
-/* Enable internal fragmentation support */
-#define ENABLE_FRAGMENT 1
-
-/* Enable smaller executable size */
-/* #undef ENABLE_SMALL */
-
-/* Enable debugging support */
-#define ENABLE_DEBUG 1
-
-/* if defined, will allow usage of the --plugin directive */
-#define USE_LOAD_LIBRARY
-
-/* Dimension size to use for empty array declaration */
-#define EMPTY_ARRAY_SIZE 0
-
-/* Define to 1 if you have the `getsockname' function. */
-#define HAVE_GETSOCKNAME 1
-
-/* Define to 1 if you have the <openssl/engine.h> header file. */
-#define HAVE_OPENSSL_ENGINE_H 1
-
-/* Define to 1 if you have the `ENGINE_load_builtin_engines' function. */
-#define HAVE_ENGINE_LOAD_BUILTIN_ENGINES 1
-
-/* Define to 1 if you have the `ENGINE_register_all_complete' function. */
-#define HAVE_ENGINE_REGISTER_ALL_COMPLETE 1
-
-/* Define to 1 if you have the `ENGINE_cleanup' function. */
-#define HAVE_ENGINE_CLEANUP 1
-
-/* gettimeofday() is implemented in otime.c for Windows */
-#define HAVE_GETTIMEOFDAY 1
-
-/* Define to 1 if you have the 'chsize' function. */
-#define HAVE_CHSIZE 1
-
-/* Define to 1 if you have the `chdir' function. */
-#define HAVE_CHDIR 1
-
-/* Define to 1 if your compiler supports GNU GCC-style variadic macros */
-#ifndef _MSC_VER /* Defines MSFT compiler version. Defined as 1200 for MSVC++ 6.0. */
-#define HAVE_CPP_VARARG_MACRO_GCC 1
-#endif
-
-/* Define to 1 if you have the <ctype.h> header file. */
-#define HAVE_CTYPE_H 1
-
-/* Define to 1 if you have the <errno.h> header file. */
-#define HAVE_ERRNO_H 1
-
-/* Define to 1 if you have the `EVP_CIPHER_CTX_set_key_length' function. */
-#define HAVE_EVP_CIPHER_CTX_SET_KEY_LENGTH 1
-
-/* Define to 1 if you have the <fcntl.h> header file. */
-#define HAVE_FCNTL_H 1
-
-/* Define to 1 if you have the `getsockopt' function. */
-#define HAVE_GETSOCKOPT 1
-
-/* Define to 1 if you have the `inet_ntoa' function. */
-#define HAVE_INET_NTOA 1
-
-/* Define to 1 if your system has a GNU libc compatible `malloc' function, and
- to 0 otherwise. */
-#define HAVE_MALLOC 1
-
-/* Define to 1 if you have the `memset' function. */
-#define HAVE_MEMSET 1
-
-/* Define to 1 if you have the `setsockopt' function. */
-#define HAVE_SETSOCKOPT 1
-
-/* Define to 1 if you have the `socket' function. */
-#define HAVE_SOCKET 1
-
-/* Define to 1 if you have the <stdarg.h> header file. */
-#define HAVE_STDARG_H 1
-
-/* Define to 1 if you have the <stdint.h> header file. */
-#ifndef _MSC_VER
-#define HAVE_STDINT_H 1
-#endif
-
-/* Define to 1 if you have the <stdio.h> header file. */
-#define HAVE_STDIO_H 1
-
-/* Define to 1 if you have the <stdlib.h> header file. */
-#define HAVE_STDLIB_H 1
-
-/* Define to 1 if you have the `strerror' function. */
-#define HAVE_STRERROR 1
-
-/* Define to 1 if you have the <strings.h> header file. */
-#define HAVE_STRINGS_H 1
-
-/* Define to 1 if you have the <string.h> header file. */
-#define HAVE_STRING_H 1
-
-/* Define to 1 if you have the `system' function. */
-#define HAVE_SYSTEM 1
-
-/* Define to 1 if you have the <sys/file.h> header file. */
-#ifndef _MSC_VER
-#define HAVE_SYS_FILE_H 1
-#endif
-
-/* Define to 1 if you have the <sys/stat.h> header file. */
-#define HAVE_SYS_STAT_H 1
-
-/* Define to 1 if you have the <sys/time.h> header file. */
-#ifndef _MSC_VER
-#define HAVE_SYS_TIME_H 1
-#endif
-
-/* Define to 1 if you have the <sys/types.h> header file. */
-#define HAVE_SYS_TYPES_H 1
-
-/* Define to 1 if you have the `time' function. */
-#define HAVE_TIME 1
-
-/* Define to 1 if you have the <unistd.h> header file. */
-#ifndef _MSC_VER
-#define HAVE_UNISTD_H 1
-#endif
-
-/* Define to 1 if you have the `vsnprintf' function. */
-#define HAVE_VSNPRINTF 1
-
-/* Special Windows version of getpass() defined in io.c */
-#define HAVE_GETPASS 1
-
-/* Name of package */
-#define PACKAGE @PACKAGE@
-
-/* Define to the address where bug reports for this package should be sent. */
-//#define PACKAGE_BUGREPORT "openvpn-users@lists.sourceforge.net"
-
-/* Define to the full name of this package. */
-#define PACKAGE_NAME @PACKAGE_NAME@
-
-/* Define to the one symbol short name of this package. */
-#define PACKAGE_TARNAME @PACKAGE_TARNAME@
-
-/* Define to the version of this package. */
-#define PACKAGE_VERSION @PACKAGE_VERSION@
-
-/* Define to the full name and version of this package. */
-#ifdef DEBUG_LABEL
-#define PACKAGE_STRING PACKAGE_NAME " " PACKAGE_VERSION " " DEBUG_LABEL
-#else
-#define PACKAGE_STRING PACKAGE_NAME " " PACKAGE_VERSION
-#endif
-
-/* Define as the return type of signal handlers (`int' or `void'). */
-#define RETSIGTYPE void
-
-/* The size of a `unsigned int', as computed by sizeof. */
-#define SIZEOF_UNSIGNED_INT 4
-
-/* The size of a `unsigned long', as computed by sizeof. */
-#define SIZEOF_UNSIGNED_LONG 4
-
-/* Define to 1 if you have the ANSI C header files. */
-#define STDC_HEADERS 1
-
-/* A string representing our target */
-#ifdef _MSC_VER
-#define TARGET_ALIAS "Win32-MSVC++"
-#else
-#define TARGET_ALIAS "Win32-MinGW"
-#endif
-
-/* Define to 1 if you can safely include both <sys/time.h> and <time.h>. */
-#ifndef _MSC_VER
-#define TIME_WITH_SYS_TIME 1
-#endif
-
-/* Use OpenSSL crypto library */
-#define USE_CRYPTO 1
-
-/* Use LZO compression library */
-#define USE_LZO 1
-
-/* LZO version number */
-#define LZO_VERSION_NUM "2"
-
-/* Use lzo/ directory prefix for LZO header files (for LZO 2.0) */
-#define LZO_HEADER_DIR 1
-
-/* Use OpenSSL SSL library */
-#define USE_SSL 1
-
-/* Version number of package */
-#define VERSION PACKAGE_VERSION
-
-/* Define as `__inline' if that's what the C compiler calls it, or to nothing
- if it is not supported. */
-#define inline __inline
-
-/* type to use in place of socklen_t if not defined */
-#define socklen_t unsigned int
-
-/* 32-bit unsigned type */
-#define uint32_t unsigned int
-
-/* 16-bit unsigned type */
-#define uint16_t unsigned short
-
-/* 8-bit unsigned type */
-#define uint8_t unsigned char
-
-/* Route command */
-#define ROUTE_PATH "route"
-
-#ifdef _MSC_VER
-/* MSVC++ hacks */
-#include <io.h>
-#include <direct.h>
-#define vsnprintf _vsnprintf
-#define vsnwprintf _vsnwprintf
-#define snwprintf _snwprintf
-#define write _write
-#define open _open
-#define read _read
-#define close _close
-#define chdir _chdir
-#define S_IRUSR 0
-#define S_IWUSR 0
-typedef int intptr_t;
-/* Visual Studio 2005 supports vararg macros */
-#if _MSC_VER >= 1400
-#define HAVE_CPP_VARARG_MACRO_ISO 1
-#endif
-#endif
+/*
+ * OpenVPN -- An application to securely tunnel IP networks
+ * over a single UDP port, with support for SSL/TLS-based
+ * session authentication and key exchange,
+ * packet encryption, packet authentication, and
+ * packet compression.
+ *
+ * Copyright (C) 2002-2010 OpenVPN Technologies, Inc. <sales@openvpn.net>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program (see the file COPYING included with this
+ * distribution); if not, write to the Free Software Foundation, Inc.,
+ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+/*
+ * Configuration header for Win32 using the MSVC environment.
+ */
+
+#include <windows.h>
+#include <winsock2.h>
+#include "autodefs.h" /* machine generated */
+
+//#define sleep(x) Sleep((x)*1000)
+
+//#define random rand
+//#define srandom srand
+
+typedef unsigned long in_addr_t;
+
+#ifndef _SSIZE_T_
+#define _SSIZE_T_
+ typedef unsigned int ssize_t;
+#endif
+
+/* Append a label to program startup title */
+/*#define DEBUG_LABEL "DEBUG1"*/
+
+/* Should we print debug info from driver? */
+#ifdef PRODUCT_TAP_DEBUG
+#define TAP_WIN32_DEBUG
+#endif
+
+/* Enable client/server capability */
+#define ENABLE_CLIENT_SERVER 1
+
+/* Enable client capability only */
+#define ENABLE_CLIENT_ONLY
+
+/* Enable management server capability */
+#define ENABLE_MANAGEMENT 1
+
+/* Enable PKCS#11 support */
+/* #define USE_PKCS11 1 */
+
+/* Enable HTTP proxy support */
+#define ENABLE_HTTP_PROXY 1
+
+/* Enable Socks proxy support */
+#define ENABLE_SOCKS 1
+
+/* Enable internal fragmentation support */
+#define ENABLE_FRAGMENT 1
+
+/* Enable smaller executable size */
+/* #undef ENABLE_SMALL */
+
+/* Enable debugging support */
+#define ENABLE_DEBUG 1
+
+/* if defined, will allow usage of the --plugin directive */
+#define USE_LOAD_LIBRARY
+
+/* Dimension size to use for empty array declaration */
+#define EMPTY_ARRAY_SIZE 0
+
+/* Define to 1 if you have the `getsockname' function. */
+#define HAVE_GETSOCKNAME 1
+
+/* Define to 1 if you have the <openssl/engine.h> header file. */
+#define HAVE_OPENSSL_ENGINE_H 1
+
+/* Define to 1 if you have the `ENGINE_load_builtin_engines' function. */
+#define HAVE_ENGINE_LOAD_BUILTIN_ENGINES 1
+
+/* Define to 1 if you have the `ENGINE_register_all_complete' function. */
+#define HAVE_ENGINE_REGISTER_ALL_COMPLETE 1
+
+/* Define to 1 if you have the `ENGINE_cleanup' function. */
+#define HAVE_ENGINE_CLEANUP 1
+
+/* gettimeofday() is implemented in otime.c for Windows */
+#define HAVE_GETTIMEOFDAY 1
+
+/* Define to 1 if you have the 'chsize' function. */
+#define HAVE_CHSIZE 1
+
+/* Define to 1 if you have the `chdir' function. */
+#define HAVE_CHDIR 1
+
+/* Define to 1 if your compiler supports GNU GCC-style variadic macros */
+#ifndef _MSC_VER /* Defines MSFT compiler version. Defined as 1200 for MSVC++ 6.0. */
+#define HAVE_CPP_VARARG_MACRO_GCC 1
+#endif
+
+/* Define to 1 if you have the <ctype.h> header file. */
+#define HAVE_CTYPE_H 1
+
+/* Define to 1 if you have the <errno.h> header file. */
+#define HAVE_ERRNO_H 1
+
+/* Define to 1 if you have the `EVP_CIPHER_CTX_set_key_length' function. */
+#define HAVE_EVP_CIPHER_CTX_SET_KEY_LENGTH 1
+
+/* Define to 1 if you have the <fcntl.h> header file. */
+#define HAVE_FCNTL_H 1
+
+/* Define to 1 if you have the `getsockopt' function. */
+#define HAVE_GETSOCKOPT 1
+
+/* Define to 1 if you have the `inet_ntoa' function. */
+#define HAVE_INET_NTOA 1
+
+/* Define to 1 if your system has a GNU libc compatible `malloc' function, and
+ to 0 otherwise. */
+#define HAVE_MALLOC 1
+
+/* Define to 1 if you have the `memset' function. */
+#define HAVE_MEMSET 1
+
+/* Define to 1 if you have the `setsockopt' function. */
+#define HAVE_SETSOCKOPT 1
+
+/* Define to 1 if you have the `socket' function. */
+#define HAVE_SOCKET 1
+
+/* Define to 1 if you have the <stdarg.h> header file. */
+#define HAVE_STDARG_H 1
+
+/* Define to 1 if you have the <stdint.h> header file. */
+#ifndef _MSC_VER
+#define HAVE_STDINT_H 1
+#endif
+
+/* Define to 1 if you have the <stdio.h> header file. */
+#define HAVE_STDIO_H 1
+
+/* Define to 1 if you have the <stdlib.h> header file. */
+#define HAVE_STDLIB_H 1
+
+/* Define to 1 if you have the `strerror' function. */
+#define HAVE_STRERROR 1
+
+/* Define to 1 if you have the <strings.h> header file. */
+#define HAVE_STRINGS_H 1
+
+/* Define to 1 if you have the <string.h> header file. */
+#define HAVE_STRING_H 1
+
+/* Define to 1 if you have the `system' function. */
+#define HAVE_SYSTEM 1
+
+/* Define to 1 if you have the <sys/file.h> header file. */
+#ifndef _MSC_VER
+#define HAVE_SYS_FILE_H 1
+#endif
+
+/* Define to 1 if you have the <sys/stat.h> header file. */
+#define HAVE_SYS_STAT_H 1
+
+/* Define to 1 if you have the <sys/time.h> header file. */
+#ifndef _MSC_VER
+#define HAVE_SYS_TIME_H 1
+#endif
+
+/* Define to 1 if you have the <sys/types.h> header file. */
+#define HAVE_SYS_TYPES_H 1
+
+/* Define to 1 if you have the `time' function. */
+#define HAVE_TIME 1
+
+/* Define to 1 if you have the <unistd.h> header file. */
+#ifndef _MSC_VER
+#define HAVE_UNISTD_H 1
+#endif
+
+/* Define to 1 if you have the `vsnprintf' function. */
+#define HAVE_VSNPRINTF 1
+
+/* Special Windows version of getpass() defined in io.c */
+#define HAVE_GETPASS 1
+
+/* Define to the address where bug reports for this package should be sent. */
+//#define PACKAGE_BUGREPORT "openvpn-users@lists.sourceforge.net"
+
+/* Define to the full name and version of this package. */
+#ifdef DEBUG_LABEL
+#define PACKAGE_STRING PACKAGE_NAME " " PACKAGE_VERSION " " DEBUG_LABEL
+#else
+#define PACKAGE_STRING PACKAGE_NAME " " PACKAGE_VERSION
+#endif
+
+/* Define as the return type of signal handlers (`int' or `void'). */
+#define RETSIGTYPE void
+
+/* The size of a `unsigned int', as computed by sizeof. */
+#define SIZEOF_UNSIGNED_INT 4
+
+/* The size of a `unsigned long', as computed by sizeof. */
+#define SIZEOF_UNSIGNED_LONG 4
+
+/* Define to 1 if you have the ANSI C header files. */
+#define STDC_HEADERS 1
+
+/* A string representing our target */
+#ifdef _MSC_VER
+#define TARGET_ALIAS "Win32-MSVC++"
+#else
+#define TARGET_ALIAS "Win32-MinGW"
+#endif
+
+/* Define to 1 if you can safely include both <sys/time.h> and <time.h>. */
+#ifndef _MSC_VER
+#define TIME_WITH_SYS_TIME 1
+#endif
+
+/* Use OpenSSL crypto library */
+#define USE_CRYPTO 1
+
+/* Use LZO compression library */
+#define USE_LZO 1
+
+/* LZO version number */
+#define LZO_VERSION_NUM "2"
+
+/* Use lzo/ directory prefix for LZO header files (for LZO 2.0) */
+#define LZO_HEADER_DIR 1
+
+/* Use OpenSSL SSL library */
+#define USE_SSL 1
+
+/* Version number of package */
+#define VERSION PACKAGE_VERSION
+
+/* Define as `__inline' if that's what the C compiler calls it, or to nothing
+ if it is not supported. */
+#define inline __inline
+
+/* type to use in place of socklen_t if not defined */
+#define socklen_t unsigned int
+
+/* 32-bit unsigned type */
+#define uint32_t unsigned int
+
+/* 16-bit unsigned type */
+#define uint16_t unsigned short
+
+/* 8-bit unsigned type */
+#define uint8_t unsigned char
+
+/* Route command */
+#define ROUTE_PATH "route"
+
+/* Windows doesn't support PTHREAD yet */
+#ifdef USE_PTHREAD
+#error The Windows version of OpenVPN does not support PTHREAD yet
+#endif
+
+#ifdef _MSC_VER
+/* MSVC++ hacks */
+#pragma warning(disable:4244) // conversion from 'foo' to 'bar', possible loss of data
+#pragma warning(disable:4018) // signed/unsigned mismatch
+#include <io.h>
+#include <direct.h>
+//#define vsnprintf _vsnprintf
+//#define vsnwprintf _vsnwprintf
+#define snwprintf _snwprintf
+#define write _write
+#define open _open
+#define read _read
+#define close _close
+#define lseek _lseek
+#define chdir _chdir
+#define strdup _strdup
+#define strcasecmp _stricmp
+#define chsize _chsize
+#define S_IRUSR 0
+#define S_IWUSR 0
+#define TV_SEC_CAST (long)
+#define TV_USEC_CAST (long)
+typedef int intptr_t;
+/* Visual Studio 2005 supports vararg macros */
+#if _MSC_VER >= 1400
+#define HAVE_CPP_VARARG_MACRO_ISO 1
+#endif
+#endif
diff --git a/configure.ac b/configure.ac
index 9d8a515..1d55263 100644
--- a/configure.ac
+++ b/configure.ac
@@ -4,7 +4,7 @@ dnl session authentication and key exchange,
dnl packet encryption, packet authentication, and
dnl packet compression.
dnl
-dnl Copyright (C) 2002-2009 OpenVPN Technologies, Inc. <sales@openvpn.net>
+dnl Copyright (C) 2002-2010 OpenVPN Technologies, Inc. <sales@openvpn.net>
dnl
dnl This program is free software; you can redistribute it and/or modify
dnl it under the terms of the GNU General Public License as published by
@@ -32,7 +32,6 @@ AC_CONFIG_SRCDIR(syshead.h)
dnl Guess host type.
AC_CANONICAL_HOST
-AC_CANONICAL_SYSTEM
AM_INIT_AUTOMAKE(openvpn, [$PACKAGE_VERSION])
AC_ARG_WITH(cygwin-native,
@@ -48,7 +47,7 @@ case "${host}" in
WIN32="yes"
cross_compiling="yes"
;;
- *-cygwin*)
+ *-*-cygwin*)
AC_MSG_CHECKING([cygwin mode to use])
if test "${CYGWIN_NATIVE}" = "yes"; then
AC_MSG_RESULT([Using native win32])
@@ -99,6 +98,12 @@ AC_ARG_ENABLE(plugins,
[PLUGINS="yes"]
)
+AC_ARG_ENABLE(eurephia,
+ [ --disable-eurephia Disable support for the eurephia plug-in],
+ [EUREPHIA="$enableval"],
+ [EUREPHIA="yes"]
+)
+
AC_ARG_ENABLE(management,
[ --disable-management Disable management server support],
[MANAGEMENT="$enableval"],
@@ -261,6 +266,13 @@ AC_ARG_WITH(route-path,
)
AC_DEFINE_UNQUOTED(ROUTE_PATH, "$ROUTE", [Path to route tool])
+AC_ARG_WITH(netstat-path,
+ [ --with-netstat-path=PATH Path to netstat tool],
+ [NETSTAT="$withval"],
+ [AC_PATH_PROG([NETSTAT], [netstat], [netstat], [$PATH:/usr/local/sbin:/usr/sbin:/sbin:/etc])]
+)
+AC_DEFINE_UNQUOTED(NETSTAT_PATH, "$NETSTAT", [Path to netstat tool])
+
AC_ARG_WITH(mem-check,
[ --with-mem-check=TYPE Build with debug memory checking, TYPE = dmalloc or valgrind],
[MEMCHECK="$withval"]
@@ -269,38 +281,38 @@ AC_ARG_WITH(mem-check,
dnl fix search path, to allow compilers to find syshead.h
CPPFLAGS="$CPPFLAGS -I${srcdir}"
-dnl check target OS
-openvpn_target=$target
-if test $target_alias; then
- openvpn_target=$target_alias
+dnl check host OS
+openvpn_host=$host
+if test $host_alias; then
+ openvpn_host=$host_alias
fi
-AC_DEFINE_UNQUOTED(TARGET_ALIAS, "$openvpn_target", [A string representing our target])
-case "$target" in
-*linux*)
+AC_DEFINE_UNQUOTED(TARGET_ALIAS, "$openvpn_host", [A string representing our host])
+case "$host" in
+*-*-linux*)
AC_DEFINE(TARGET_LINUX, 1, [Are we running on Linux?])
dnl RH9 SSL headers workaround
if test -z $CS_HDR_DIR && test "$CRYPTO" = "yes"; then
CPPFLAGS="$CPPFLAGS $(pkg-config --cflags openssl 2>/dev/null)"
fi
;;
-*solaris*)
+*-*-solaris*)
AC_DEFINE(TARGET_SOLARIS, 1, [Are we running on Solaris?])
;;
-*openbsd*)
+*-*-openbsd*)
AC_DEFINE(TARGET_OPENBSD, 1, [Are we running on OpenBSD?])
;;
-*freebsd*)
+*-*-freebsd*)
AC_DEFINE(TARGET_FREEBSD, 1, [Are we running on FreeBSD?])
;;
-*netbsd*)
+*-*-netbsd*)
AC_DEFINE(TARGET_NETBSD, 1, [Are we running NetBSD?])
;;
-*darwin*)
+*-*-darwin*)
dnl some Mac OS X tendering (we use vararg macros...)
AC_DEFINE(TARGET_DARWIN, 1, [Are we running on Mac OS X?])
CPPFLAGS="$CPPFLAGS -no-cpp-precomp"
;;
-*mingw*)
+*-mingw*)
AC_DEFINE(TARGET_WIN32, 1, [Are we running WIN32?])
OPENVPN_ADD_LIBS(-lgdi32)
OPENVPN_ADD_LIBS(-lws2_32)
@@ -309,7 +321,7 @@ case "$target" in
OPENVPN_ADD_LIBS(-liphlpapi)
OPENVPN_ADD_LIBS(-lwinmm)
;;
-*dragonfly*)
+*-*-dragonfly*)
AC_DEFINE(TARGET_DRAGONFLY, 1, [Are we running on DragonFlyBSD?])
;;
@@ -363,7 +375,10 @@ if test "${WIN32}" != "yes"; then
linux/types.h sys/poll.h sys/epoll.h err.h dnl
)
AC_CHECK_HEADERS(net/if.h,,,
- [#ifdef HAVE_SYS_SOCKET_H
+ [#ifdef HAVE_SYS_TYPES_H
+ # include <sys/types.h>
+ #endif
+ #ifdef HAVE_SYS_SOCKET_H
# include <sys/socket.h>
#endif
])
@@ -596,6 +611,9 @@ if test "${WIN32}" != "yes"; then
)],
[AC_MSG_RESULT([libdl headers not found.])]
)
+ if test "$EUREPHIA" = "yes"; then
+ AC_DEFINE(ENABLE_EUREPHIA, 1, [Enable support for the eurephia plug-in])
+ fi
fi
fi
@@ -875,10 +893,10 @@ if test -z "${htmldir}"; then
fi
# end workaround
+AC_CONFIG_FILES([t_client.sh], [chmod +x t_client.sh])
AC_OUTPUT([
Makefile
openvpn.spec
- config-win32.h
images/Makefile
service-win32/Makefile
install-win32/Makefile
diff --git a/contrib/OCSP_check/OCSP_check.sh b/contrib/OCSP_check/OCSP_check.sh
new file mode 100644
index 0000000..847be45
--- /dev/null
+++ b/contrib/OCSP_check/OCSP_check.sh
@@ -0,0 +1,111 @@
+#!/bin/sh
+
+# Sample script to perform OCSP queries with OpenSSL
+# given a certificate serial number.
+
+# If you run your own CA, you can set up a very simple
+# OCSP server using the -port option to "openssl ocsp".
+
+# Full documentation and examples:
+# http://www.openssl.org/docs/apps/ocsp.html
+
+
+# Edit the following values to suit your needs
+
+# OCSP responder URL (mandatory)
+# YOU MUST UNCOMMENT ONE OF THESE AND SET IT TO A VALID SERVER
+#ocsp_url="http://ocsp.example.com/"
+#ocsp_url="https://ocsp.secure.example.com/"
+
+# Path to issuer certificate (mandatory)
+# YOU MUST SET THIS TO THE PATH TO THE CA CERTIFICATE
+issuer="/path/to/CAcert.crt"
+
+# use a nonce in the query, set to "-no_nonce" to not use it
+nonce="-nonce"
+
+# Verify the response
+# YOU MUST SET THIS TO THE PATH TO THE RESPONSE VERIFICATION CERT
+verify="/path/to/CAcert.crt"
+
+# Depth in the certificate chain where the cert to verify is.
+# Set to -1 to run the verification at every level (NOTE that
+# in that case you need a more complex script as the various
+# parameters for the query will likely be different at each level)
+# "0" is the usual value here, where the client certificate is
+check_depth=0
+
+cur_depth=$1 # this is the *CURRENT* depth
+common_name=$2 # CN in case you need it
+
+# minimal sanity checks
+
+err=0
+if [ -z "$issuer" ] || [ ! -e "$issuer" ]; then
+ echo "Error: issuer certificate undefined or not found!" >&2
+ err=1
+fi
+
+if [ -z "$verify" ] || [ ! -e "$verify" ]; then
+ echo "Error: verification certificate undefined or not found!" >&2
+ err=1
+fi
+
+if [ -z "$ocsp_url" ]; then
+ echo "Error: OCSP server URL not defined!" >&2
+ err=1
+fi
+
+if [ $err -eq 1 ]; then
+ echo "Did you forget to customize the variables in the script?" >&2
+ exit 1
+fi
+
+# begin
+if [ $check_depth -eq -1 ] || [ $cur_depth -eq $check_depth ]; then
+
+ eval serial="\$tls_serial_${cur_depth}"
+
+ # To successfully complete, the following must happen:
+ #
+ # - The serial number must not be empty
+ # - The exit status of "openssl ocsp" must be zero
+ # - The output of the above command must contain the line
+ # "0x${serial}: good"
+ #
+ # Everything else fails with exit status 1.
+
+ if [ -n "$serial" ]; then
+
+ # This is only an example; you are encouraged to run this command (without
+ # redirections) manually against your or your CA's OCSP server to see how
+ # it responds, and adapt accordingly.
+ # Sample output that is assumed here:
+ #
+ # Response verify OK
+ # 0x428740A5: good
+ # This Update: Apr 24 19:38:49 2010 GMT
+ # Next Update: May 2 14:23:42 2010 GMT
+ #
+ # NOTE: It is needed to check the exit code of OpenSSL explicitly. OpenSSL
+ # can in some circumstances give a "good" result if it could not
+ # reach the the OSCP server. In this case, the exit code will indicate
+ # if OpenSSL itself failed or not. If OpenSSL's exit code is not 0,
+ # don't trust the OpenSSL status.
+
+ status=$(openssl ocsp -issuer "$issuer" \
+ "$nonce" \
+ -CAfile "$verify" \
+ -url "$ocsp_url" \
+ -serial "0x${serial}" 2>/dev/null)
+
+ if [ $? -eq 0 ]; then
+ # check that it's good
+ if echo "$status" | grep -Fq "0x${serial}: good"; then
+ exit 0
+ fi
+ fi
+ fi
+ # if we get here, something was wrong
+ exit 1
+fi
diff --git a/contrib/pull-resolv-conf/client.down b/contrib/pull-resolv-conf/client.down
index c3f35e7..05f2d4d 100644
--- a/contrib/pull-resolv-conf/client.down
+++ b/contrib/pull-resolv-conf/client.down
@@ -1,6 +1,6 @@
-#!/bin/bash
+#!/bin/sh
-# Copyright (c) 2005-2009 OpenVPN Technologies, Inc.
+# Copyright (c) 2005-2010 OpenVPN Technologies, Inc.
# Licensed under the GPL version 2
# First version by Jesse Adelman
@@ -14,7 +14,6 @@
# Place this in /etc/openvpn/client.down
# Then, add the following to your /etc/openvpn/<clientconfig>.conf:
# client
-# pull dhcp-options
# up /etc/openvpn/client.up
# down /etc/openvpn/client.down
# Next, "chmod a+x /etc/openvpn/client.down"
@@ -23,8 +22,8 @@
# Note that this script is best served with the companion "client.up"
# script.
-# Only tested on Gentoo Linux 2005.0 with OpenVPN 2.0
-# It should work with any GNU/Linux with /etc/resolv.conf
+# Tested under Debian lenny with OpenVPN 2.1_rc11
+# It should work with any UNIX with a POSIX sh, /etc/resolv.conf or resolvconf
# This runs with the context of the OpenVPN UID/GID
# at the time of execution. This generally means that
@@ -35,42 +34,14 @@
# A horrid work around, from a security perspective,
# is to run OpenVPN as root. THIS IS NOT RECOMMENDED. You have
# been WARNED.
-
-# init variables
-
-i=1
-j=1
-unset fopt
-unset dns
-unset opt
-
-# Convert ENVs to an array
-
-while fopt=foreign_option_$i; [ -n "${!fopt}" ]; do
-{
- opt[i-1]=${!fopt}
- case ${opt[i-1]} in
- *DOMAIN* ) domain=`echo ${opt[i-1]} | \
- sed -e 's/dhcp-option DOMAIN //g'` ;;
- *DNS* ) dns[j-1]=`echo ${opt[i-1]} | \
- sed -e 's/dhcp-option DNS //g'`
- let j++ ;;
- esac
- let i++
-}
-done
-
-# Now, do the work
-
-if [ -n "${dns[*]}" ]; then
- for i in "${dns[@]}"; do
- sed -i -e "/nameserver ${i}/D" /etc/resolv.conf || die
- done
-fi
-
-if [ -n "${domain}" ]; then
- sed -i -e "/search ${domain}/D" /etc/resolv.conf || die
+PATH=/bin:/usr/bin:/usr/local/bin:/sbin:/usr/sbin:/usr/local/sbin
+
+if type resolvconf >/dev/null 2>&1; then
+ resolvconf -d "${1}" -f
+elif [ -e /etc/resolv.conf.ovpnsave ] ; then
+ # cp + rm rather than mv in case it's a symlink
+ cp /etc/resolv.conf.ovpnsave /etc/resolv.conf
+ rm -f /etc/resolv.conf.ovpnsave
fi
-# all done...
exit 0
diff --git a/contrib/pull-resolv-conf/client.up b/contrib/pull-resolv-conf/client.up
index 6ce7b57..b28d4d1 100644
--- a/contrib/pull-resolv-conf/client.up
+++ b/contrib/pull-resolv-conf/client.up
@@ -1,6 +1,6 @@
-#!/bin/bash
+#!/bin/sh
-# Copyright (c) 2005-2009 OpenVPN Technologies, Inc.
+# Copyright (c) 2005-2010 OpenVPN Technologies, Inc.
# Licensed under the GPL version 2
# First version by Jesse Adelman
@@ -14,7 +14,6 @@
# Place this in /etc/openvpn/client.up
# Then, add the following to your /etc/openvpn/<clientconfig>.conf:
# client
-# pull dhcp-options
# up /etc/openvpn/client.up
# Next, "chmod a+x /etc/openvpn/client.up"
@@ -22,8 +21,8 @@
# Note that this script is best served with the companion "client.down"
# script.
-# Only tested on Gentoo Linux 2005.0 with OpenVPN 2.0
-# It should work with any GNU/Linux with /etc/resolv.conf
+# Tested under Debian lenny with OpenVPN 2.1_rc11
+# It should work with any UNIX with a POSIX sh, /etc/resolv.conf or resolvconf
# This runs with the context of the OpenVPN UID/GID
# at the time of execution. This generally means that
@@ -34,42 +33,69 @@
# A horrid work around, from a security perspective,
# is to run OpenVPN as root. THIS IS NOT RECOMMENDED. You have
# been WARNED.
+PATH=/bin:/usr/bin:/usr/local/bin:/sbin:/usr/sbin:/usr/local/sbin
# init variables
i=1
-j=1
-unset fopt
-unset dns
-unset opt
-
-# Convert ENVs to an array
-
-while fopt=foreign_option_$i; [ -n "${!fopt}" ]; do
-{
- opt[i-1]=${!fopt}
- case ${opt[i-1]} in
- *DOMAIN* ) domain=`echo ${opt[i-1]} | \
- sed -e 's/dhcp-option DOMAIN //g'` ;;
- *DNS* ) dns[j-1]=`echo ${opt[i-1]} | \
- sed -e 's/dhcp-option DNS //g'`
- let j++ ;;
+domains=
+fopt=
+ndoms=0
+nns=0
+nl='
+'
+
+# $foreign_option_<n> is something like
+# "dhcp-option DOMAIN example.com" (multiple allowed)
+# or
+# "dhcp-option DNS 10.10.10.10" (multiple allowed)
+
+# each DNS option becomes a "nameserver" option in resolv.con
+# if we get one DOMAIN, that becomes "domain" in resolv.conf
+# if we get multiple DOMAINS, those become "search" lines in resolv.conf
+
+while true; do
+ eval fopt=\$foreign_option_${i}
+ [ -z "${fopt}" ] && break
+
+ case ${fopt} in
+ dhcp-option\ DOMAIN\ *)
+ ndoms=$((ndoms + 1))
+ domains="${domains} ${fopt#dhcp-option DOMAIN }"
+ ;;
+ dhcp-option\ DNS\ *)
+ nns=$((nns + 1))
+ if [ $nns -le 3 ]; then
+ dns="${dns}${dns:+$nl}nameserver ${fopt#dhcp-option DNS }"
+ else
+ printf "%s\n" "Too many nameservers - ignoring after third" >&2
+ fi
+ ;;
+ *)
+ printf "%s\n" "Unknown option \"${fopt}\" - ignored" >&2
+ ;;
esac
- let i++
-}
+ i=$((i + 1))
done
-# Now, do the work
-
-if [ -n "${dns[*]}" ]; then
- for i in "${dns[@]}"; do
- sed -i -e "1,1 i nameserver ${i}" /etc/resolv.conf || die
- done
+ds=domain
+if [ $ndoms -gt 1 ]; then
+ ds=search
fi
-if [ -n "${domain}" ]; then
- sed -i -e "$j,1 i search ${domain}" /etc/resolv.conf || die
+# This is the complete file - "$domains" has a leading space already
+out="# resolv.conf autogenerated by ${0} (${1})${nl}${dns}${nl}${ds}${domains}"
+
+# use resolvconf if it's available
+if type resolvconf >/dev/null 2>&1; then
+ printf "%s\n" "${out}" | resolvconf -p -a "${1}"
+else
+ # Preserve the existing resolv.conf
+ if [ -e /etc/resolv.conf ] ; then
+ cp /etc/resolv.conf /etc/resolv.conf.ovpnsave
+ fi
+ printf "%s\n" "${out}" > /etc/resolv.conf
+ chmod 644 /etc/resolv.conf
fi
-# all done...
exit 0
diff --git a/crypto.c b/crypto.c
index c73db93..5cfc34a 100644
--- a/crypto.c
+++ b/crypto.c
@@ -5,7 +5,7 @@
* packet encryption, packet authentication, and
* packet compression.
*
- * Copyright (C) 2002-2009 OpenVPN Technologies, Inc. <sales@openvpn.net>
+ * Copyright (C) 2002-2010 OpenVPN Technologies, Inc. <sales@openvpn.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2
@@ -984,8 +984,8 @@ get_tls_handshake_key (const struct key_type *key_type,
#endif
/* header and footer for static key file */
-static const char static_key_head[] = "-----BEGIN " PACKAGE_NAME " Static key V1-----";
-static const char static_key_foot[] = "-----END " PACKAGE_NAME " Static key V1-----";
+static const char static_key_head[] = "-----BEGIN OpenVPN Static key V1-----";
+static const char static_key_foot[] = "-----END OpenVPN Static key V1-----";
static const char printable_char_fmt[] =
"Non-Hex character ('%c') found at line %d in key file '%s' (%d/%d/%d bytes found/min/max)";
@@ -1064,8 +1064,8 @@ read_key_file (struct key2 *key2, const char *file, const unsigned int flags)
const unsigned char c = *cp;
#if 0
- msg (M_INFO, "char='%c' s=%d ln=%d li=%d m=%d c=%d",
- c, state, line_num, line_index, match, count);
+ msg (M_INFO, "char='%c'[%d] s=%d ln=%d li=%d m=%d c=%d",
+ c, (int)c, state, line_num, line_index, match, count);
#endif
if (c == '\n')
@@ -1149,7 +1149,7 @@ read_key_file (struct key2 *key2, const char *file, const unsigned int flags)
if (flags & RKF_MUST_SUCCEED)
{
if (!key2->n)
- msg (M_FATAL, "Insufficient key material or header text not found found in file '%s' (%d/%d/%d bytes found/min/max)",
+ msg (M_FATAL, "Insufficient key material or header text not found in file '%s' (%d/%d/%d bytes found/min/max)",
error_filename, count, onekeylen, keylen);
if (state != PARSE_FINISHED)
@@ -1296,7 +1296,7 @@ write_key_file (const int nkeys, const char *filename)
buf_printf (&out, "%s\n", static_key_foot);
/* write number of bits */
- buf_printf (&nbits_head_text, "#\n# %d bit " PACKAGE_NAME " static key\n#\n", nbits);
+ buf_printf (&nbits_head_text, "#\n# %d bit OpenVPN static key\n#\n", nbits);
buf_write_string_file (&nbits_head_text, filename, fd);
/* write key file, now formatted in out, to file */
diff --git a/crypto.h b/crypto.h
index 3a5d5f2..fcd4661 100644
--- a/crypto.h
+++ b/crypto.h
@@ -5,7 +5,7 @@
* packet encryption, packet authentication, and
* packet compression.
*
- * Copyright (C) 2002-2009 OpenVPN Technologies, Inc. <sales@openvpn.net>
+ * Copyright (C) 2002-2010 OpenVPN Technologies, Inc. <sales@openvpn.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2
diff --git a/dhcp.c b/dhcp.c
index 495e187..3474a17 100644
--- a/dhcp.c
+++ b/dhcp.c
@@ -5,7 +5,7 @@
* packet encryption, packet authentication, and
* packet compression.
*
- * Copyright (C) 2002-2009 OpenVPN Technologies, Inc. <sales@openvpn.net>
+ * Copyright (C) 2002-2010 OpenVPN Technologies, Inc. <sales@openvpn.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2
diff --git a/dhcp.h b/dhcp.h
index 4cd64ef..e823a4a 100644
--- a/dhcp.h
+++ b/dhcp.h
@@ -5,7 +5,7 @@
* packet encryption, packet authentication, and
* packet compression.
*
- * Copyright (C) 2002-2009 OpenVPN Technologies, Inc. <sales@openvpn.net>
+ * Copyright (C) 2002-2010 OpenVPN Technologies, Inc. <sales@openvpn.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2
diff --git a/doclean b/doclean
index d4f8157..8b35dd6 100755
--- a/doclean
+++ b/doclean
@@ -37,7 +37,6 @@ rm -f \
openvpn.spec \
install-sh \
openvpn.8.html \
- config-win32.h \
install-win32/*.exe \
install-win32/makensis.log \
install-win32/settings \
diff --git a/easy-rsa/2.0/build-ca b/easy-rsa/2.0/build-ca
index fb1e2ca..bce29a6 100755
--- a/easy-rsa/2.0/build-ca
+++ b/easy-rsa/2.0/build-ca
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/bin/sh
#
# Build a root certificate
diff --git a/easy-rsa/2.0/build-dh b/easy-rsa/2.0/build-dh
index f019222..4beb127 100755
--- a/easy-rsa/2.0/build-dh
+++ b/easy-rsa/2.0/build-dh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/bin/sh
# Build Diffie-Hellman parameters for the server side
# of an SSL/TLS connection.
diff --git a/easy-rsa/2.0/build-inter b/easy-rsa/2.0/build-inter
index f831d6f..87bf98d 100755
--- a/easy-rsa/2.0/build-inter
+++ b/easy-rsa/2.0/build-inter
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/bin/sh
# Make an intermediate CA certificate/private key pair using a locally generated
# root certificate.
diff --git a/easy-rsa/2.0/build-key b/easy-rsa/2.0/build-key
index 6196308..6c0fed8 100755
--- a/easy-rsa/2.0/build-key
+++ b/easy-rsa/2.0/build-key
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/bin/sh
# Make a certificate/private key pair using a locally generated
# root certificate.
diff --git a/easy-rsa/2.0/build-key-pass b/easy-rsa/2.0/build-key-pass
index 35543e0..8ef8307 100755
--- a/easy-rsa/2.0/build-key-pass
+++ b/easy-rsa/2.0/build-key-pass
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/bin/sh
# Similar to build-key, but protect the private key
# with a password.
diff --git a/easy-rsa/2.0/build-key-pkcs12 b/easy-rsa/2.0/build-key-pkcs12
index 5ef064f..ba90e6a 100755
--- a/easy-rsa/2.0/build-key-pkcs12
+++ b/easy-rsa/2.0/build-key-pkcs12
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/bin/sh
# Make a certificate/private key pair using a locally generated
# root certificate and convert it to a PKCS #12 file including the
diff --git a/easy-rsa/2.0/build-key-server b/easy-rsa/2.0/build-key-server
index 5502675..fee0194 100755
--- a/easy-rsa/2.0/build-key-server
+++ b/easy-rsa/2.0/build-key-server
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/bin/sh
# Make a certificate/private key pair using a locally generated
# root certificate.
diff --git a/easy-rsa/2.0/build-req b/easy-rsa/2.0/build-req
index 26587d1..559d512 100755
--- a/easy-rsa/2.0/build-req
+++ b/easy-rsa/2.0/build-req
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/bin/sh
# Build a certificate signing request and private key. Use this
# when your root certificate and key is not available locally.
diff --git a/easy-rsa/2.0/build-req-pass b/easy-rsa/2.0/build-req-pass
index 6e6c863..b73ee1b 100755
--- a/easy-rsa/2.0/build-req-pass
+++ b/easy-rsa/2.0/build-req-pass
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/bin/sh
# Like build-req, but protect your private key
# with a password.
diff --git a/easy-rsa/2.0/clean-all b/easy-rsa/2.0/clean-all
index 0576db5..cc6e3b2 100755
--- a/easy-rsa/2.0/clean-all
+++ b/easy-rsa/2.0/clean-all
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/bin/sh
# Initialize the $KEY_DIR directory.
# Note that this script does a
diff --git a/easy-rsa/2.0/inherit-inter b/easy-rsa/2.0/inherit-inter
index 2101951..aaa5168 100755
--- a/easy-rsa/2.0/inherit-inter
+++ b/easy-rsa/2.0/inherit-inter
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/bin/sh
# Build a new PKI which is rooted on an intermediate certificate generated
# by ./build-inter or ./pkitool --inter from a parent PKI. The new PKI should
diff --git a/easy-rsa/2.0/list-crl b/easy-rsa/2.0/list-crl
index afc0cd6..d1d8a69 100755
--- a/easy-rsa/2.0/list-crl
+++ b/easy-rsa/2.0/list-crl
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/bin/sh
# list revoked certificates
diff --git a/easy-rsa/2.0/pkitool b/easy-rsa/2.0/pkitool
index 2a0b2f3..49588f5 100755
--- a/easy-rsa/2.0/pkitool
+++ b/easy-rsa/2.0/pkitool
@@ -6,7 +6,7 @@
# packet encryption, packet authentication, and
# packet compression.
#
-# Copyright (C) 2002-2009 OpenVPN Technologies, Inc. <sales@openvpn.net>
+# Copyright (C) 2002-2010 OpenVPN Technologies, Inc. <sales@openvpn.net>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2
diff --git a/easy-rsa/2.0/revoke-full b/easy-rsa/2.0/revoke-full
index efc94e8..4169c4c 100755
--- a/easy-rsa/2.0/revoke-full
+++ b/easy-rsa/2.0/revoke-full
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/bin/sh
# revoke a certificate, regenerate CRL,
# and verify revocation
diff --git a/easy-rsa/2.0/sign-req b/easy-rsa/2.0/sign-req
index 38655d3..6cae7b4 100755
--- a/easy-rsa/2.0/sign-req
+++ b/easy-rsa/2.0/sign-req
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/bin/sh
# Sign a certificate signing request (a .csr file)
# with a local root certificate and key.
diff --git a/errlevel.h b/errlevel.h
index a092d3f..75c3194 100644
--- a/errlevel.h
+++ b/errlevel.h
@@ -5,7 +5,7 @@
* packet encryption, packet authentication, and
* packet compression.
*
- * Copyright (C) 2002-2009 OpenVPN Technologies, Inc. <sales@openvpn.net>
+ * Copyright (C) 2002-2010 OpenVPN Technologies, Inc. <sales@openvpn.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2
diff --git a/error.c b/error.c
index 2dfb978..5c53251 100644
--- a/error.c
+++ b/error.c
@@ -5,7 +5,7 @@
* packet encryption, packet authentication, and
* packet compression.
*
- * Copyright (C) 2002-2009 OpenVPN Technologies, Inc. <sales@openvpn.net>
+ * Copyright (C) 2002-2010 OpenVPN Technologies, Inc. <sales@openvpn.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2
@@ -462,14 +462,16 @@ redirect_stdout_stderr (const char *file, bool append)
{
HANDLE log_handle;
int log_fd;
- struct security_attributes sa;
- init_security_attributes_allow_all (&sa);
+ SECURITY_ATTRIBUTES saAttr;
+ saAttr.nLength = sizeof(SECURITY_ATTRIBUTES);
+ saAttr.bInheritHandle = TRUE;
+ saAttr.lpSecurityDescriptor = NULL;
log_handle = CreateFile (file,
GENERIC_WRITE,
FILE_SHARE_READ,
- &sa.sa,
+ &saAttr,
append ? OPEN_ALWAYS : CREATE_ALWAYS,
FILE_ATTRIBUTE_NORMAL,
NULL);
@@ -490,10 +492,12 @@ redirect_stdout_stderr (const char *file, bool append)
/* save original stderr for password prompts */
orig_stderr = GetStdHandle (STD_ERROR_HANDLE);
+#if 0 /* seems not be necessary with stdout/stderr redirection below*/
/* set up for redirection */
if (!SetStdHandle (STD_OUTPUT_HANDLE, log_handle)
|| !SetStdHandle (STD_ERROR_HANDLE, log_handle))
msg (M_ERR, "Error: cannot redirect stdout/stderr to --log file: %s", file);
+#endif
/* direct stdout/stderr to point to log_handle */
log_fd = _open_osfhandle ((intptr_t)log_handle, _O_TEXT);
@@ -506,6 +510,10 @@ redirect_stdout_stderr (const char *file, bool append)
if (msgfp == NULL)
msg (M_ERR, "Error: --log redirect failed due to _fdopen");
+ /* redirect C-library stdout/stderr to log file */
+ if (_dup2 (log_fd, 1) == -1 || _dup2 (log_fd, 2) == -1)
+ msg (M_WARN, "Error: --log redirect of stdout/stderr failed");
+
std_redir = true;
}
#elif defined(HAVE_DUP2)
diff --git a/error.h b/error.h
index d175533..4be3268 100644
--- a/error.h
+++ b/error.h
@@ -5,7 +5,7 @@
* packet encryption, packet authentication, and
* packet compression.
*
- * Copyright (C) 2002-2009 OpenVPN Technologies, Inc. <sales@openvpn.net>
+ * Copyright (C) 2002-2010 OpenVPN Technologies, Inc. <sales@openvpn.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2
diff --git a/event.c b/event.c
index 32b1c23..6a9161b 100644
--- a/event.c
+++ b/event.c
@@ -5,7 +5,7 @@
* packet encryption, packet authentication, and
* packet compression.
*
- * Copyright (C) 2002-2009 OpenVPN Technologies, Inc. <sales@openvpn.net>
+ * Copyright (C) 2002-2010 OpenVPN Technologies, Inc. <sales@openvpn.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2
diff --git a/event.h b/event.h
index a5698c5..bd29fdc 100644
--- a/event.h
+++ b/event.h
@@ -5,7 +5,7 @@
* packet encryption, packet authentication, and
* packet compression.
*
- * Copyright (C) 2002-2009 OpenVPN Technologies, Inc. <sales@openvpn.net>
+ * Copyright (C) 2002-2010 OpenVPN Technologies, Inc. <sales@openvpn.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2
diff --git a/fdmisc.c b/fdmisc.c
index b279fd4..5be3c8b 100644
--- a/fdmisc.c
+++ b/fdmisc.c
@@ -5,7 +5,7 @@
* packet encryption, packet authentication, and
* packet compression.
*
- * Copyright (C) 2002-2009 OpenVPN Technologies, Inc. <sales@openvpn.net>
+ * Copyright (C) 2002-2010 OpenVPN Technologies, Inc. <sales@openvpn.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2
diff --git a/fdmisc.h b/fdmisc.h
index aa03392..4b6b6d0 100644
--- a/fdmisc.h
+++ b/fdmisc.h
@@ -5,7 +5,7 @@
* packet encryption, packet authentication, and
* packet compression.
*
- * Copyright (C) 2002-2009 OpenVPN Technologies, Inc. <sales@openvpn.net>
+ * Copyright (C) 2002-2010 OpenVPN Technologies, Inc. <sales@openvpn.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2
diff --git a/forward-inline.h b/forward-inline.h
index bb8f542..64ca941 100644
--- a/forward-inline.h
+++ b/forward-inline.h
@@ -5,7 +5,7 @@
* packet encryption, packet authentication, and
* packet compression.
*
- * Copyright (C) 2002-2009 OpenVPN Technologies, Inc. <sales@openvpn.net>
+ * Copyright (C) 2002-2010 OpenVPN Technologies, Inc. <sales@openvpn.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2
diff --git a/forward.c b/forward.c
index 463a2e8..87d05cc 100644
--- a/forward.c
+++ b/forward.c
@@ -5,7 +5,7 @@
* packet encryption, packet authentication, and
* packet compression.
*
- * Copyright (C) 2002-2009 OpenVPN Technologies, Inc. <sales@openvpn.net>
+ * Copyright (C) 2002-2010 OpenVPN Technologies, Inc. <sales@openvpn.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2
@@ -685,14 +685,25 @@ read_incoming_link (struct context *c)
if (c->options.inetd)
{
c->sig->signal_received = SIGTERM;
+ c->sig->signal_text = "connection-reset-inetd";
msg (D_STREAM_ERRORS, "Connection reset, inetd/xinetd exit [%d]", status);
}
else
{
- c->sig->signal_received = SIGUSR1; /* SOFT-SIGUSR1 -- TCP connection reset */
- msg (D_STREAM_ERRORS, "Connection reset, restarting [%d]", status);
+#ifdef ENABLE_OCC
+ if (event_timeout_defined(&c->c2.explicit_exit_notification_interval))
+ {
+ msg (D_STREAM_ERRORS, "Connection reset during exit notification period, ignoring [%d]", status);
+ openvpn_sleep(1);
+ }
+ else
+#endif
+ {
+ c->sig->signal_received = SIGUSR1; /* SOFT-SIGUSR1 -- TCP connection reset */
+ c->sig->signal_text = "connection-reset";
+ msg (D_STREAM_ERRORS, "Connection reset, restarting [%d]", status);
+ }
}
- c->sig->signal_text = "connection-reset";
}
perf_pop ();
return;
@@ -1147,8 +1158,9 @@ process_outgoing_link (struct context *c)
size);
}
- /* indicate activity regarding --inactive parameter */
- register_activity (c, size);
+ /* if not a ping/control message, indicate activity regarding --inactive parameter */
+ if (c->c2.buf.len > 0 )
+ register_activity (c, size);
}
else
{
diff --git a/forward.h b/forward.h
index 671cd84..17cc928 100644
--- a/forward.h
+++ b/forward.h
@@ -5,7 +5,7 @@
* packet encryption, packet authentication, and
* packet compression.
*
- * Copyright (C) 2002-2009 OpenVPN Technologies, Inc. <sales@openvpn.net>
+ * Copyright (C) 2002-2010 OpenVPN Technologies, Inc. <sales@openvpn.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2
diff --git a/fragment.c b/fragment.c
index 891ff15..5ef3a47 100644
--- a/fragment.c
+++ b/fragment.c
@@ -5,7 +5,7 @@
* packet encryption, packet authentication, and
* packet compression.
*
- * Copyright (C) 2002-2009 OpenVPN Technologies, Inc. <sales@openvpn.net>
+ * Copyright (C) 2002-2010 OpenVPN Technologies, Inc. <sales@openvpn.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2
diff --git a/fragment.h b/fragment.h
index 675a427..fc2b1b8 100644
--- a/fragment.h
+++ b/fragment.h
@@ -5,7 +5,7 @@
* packet encryption, packet authentication, and
* packet compression.
*
- * Copyright (C) 2002-2009 OpenVPN Technologies, Inc. <sales@openvpn.net>
+ * Copyright (C) 2002-2010 OpenVPN Technologies, Inc. <sales@openvpn.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2
diff --git a/gremlin.c b/gremlin.c
index 37f32f7..c7c0206 100644
--- a/gremlin.c
+++ b/gremlin.c
@@ -5,7 +5,7 @@
* packet encryption, packet authentication, and
* packet compression.
*
- * Copyright (C) 2002-2009 OpenVPN Technologies, Inc. <sales@openvpn.net>
+ * Copyright (C) 2002-2010 OpenVPN Technologies, Inc. <sales@openvpn.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2
diff --git a/gremlin.h b/gremlin.h
index ca234d9..c0aeab1 100644
--- a/gremlin.h
+++ b/gremlin.h
@@ -5,7 +5,7 @@
* packet encryption, packet authentication, and
* packet compression.
*
- * Copyright (C) 2002-2009 OpenVPN Technologies, Inc. <sales@openvpn.net>
+ * Copyright (C) 2002-2010 OpenVPN Technologies, Inc. <sales@openvpn.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2
diff --git a/helper.c b/helper.c
index 43b64b4..a9d7fd9 100644
--- a/helper.c
+++ b/helper.c
@@ -5,7 +5,7 @@
* packet encryption, packet authentication, and
* packet compression.
*
- * Copyright (C) 2002-2009 OpenVPN Technologies, Inc. <sales@openvpn.net>
+ * Copyright (C) 2002-2010 OpenVPN Technologies, Inc. <sales@openvpn.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2
diff --git a/helper.h b/helper.h
index ec164de..444969c 100644
--- a/helper.h
+++ b/helper.h
@@ -5,7 +5,7 @@
* packet encryption, packet authentication, and
* packet compression.
*
- * Copyright (C) 2002-2009 OpenVPN Technologies, Inc. <sales@openvpn.net>
+ * Copyright (C) 2002-2010 OpenVPN Technologies, Inc. <sales@openvpn.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2
diff --git a/httpdigest.c b/httpdigest.c
new file mode 100644
index 0000000..ef77e12
--- /dev/null
+++ b/httpdigest.c
@@ -0,0 +1,143 @@
+/*
+ * OpenVPN -- An application to securely tunnel IP networks
+ * over a single TCP/UDP port, with support for SSL/TLS-based
+ * session authentication and key exchange,
+ * packet encryption, packet authentication, and
+ * packet compression.
+ *
+ * Copyright (C) 2002-2010 OpenVPN Technologies, Inc. <sales@openvpn.net>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program (see the file COPYING included with this
+ * distribution); if not, write to the Free Software Foundation, Inc.,
+ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include "syshead.h"
+
+#if PROXY_DIGEST_AUTH
+
+#include "crypto.h"
+#include "httpdigest.h"
+
+static void
+CvtHex(
+ IN HASH Bin,
+ OUT HASHHEX Hex
+ )
+{
+ unsigned short i;
+ unsigned char j;
+
+ for (i = 0; i < HASHLEN; i++) {
+ j = (Bin[i] >> 4) & 0xf;
+ if (j <= 9)
+ Hex[i*2] = (j + '0');
+ else
+ Hex[i*2] = (j + 'a' - 10);
+ j = Bin[i] & 0xf;
+ if (j <= 9)
+ Hex[i*2+1] = (j + '0');
+ else
+ Hex[i*2+1] = (j + 'a' - 10);
+ };
+ Hex[HASHHEXLEN] = '\0';
+};
+
+/* calculate H(A1) as per spec */
+void
+DigestCalcHA1(
+ IN char * pszAlg,
+ IN char * pszUserName,
+ IN char * pszRealm,
+ IN char * pszPassword,
+ IN char * pszNonce,
+ IN char * pszCNonce,
+ OUT HASHHEX SessionKey
+ )
+{
+ MD5_CTX Md5Ctx;
+ HASH HA1;
+
+ MD5_Init(&Md5Ctx);
+ MD5_Update(&Md5Ctx, pszUserName, strlen(pszUserName));
+ MD5_Update(&Md5Ctx, ":", 1);
+ MD5_Update(&Md5Ctx, pszRealm, strlen(pszRealm));
+ MD5_Update(&Md5Ctx, ":", 1);
+ MD5_Update(&Md5Ctx, pszPassword, strlen(pszPassword));
+ MD5_Final(HA1, &Md5Ctx);
+ if (pszAlg && strcasecmp(pszAlg, "md5-sess") == 0)
+ {
+ MD5_Init(&Md5Ctx);
+ MD5_Update(&Md5Ctx, HA1, HASHLEN);
+ MD5_Update(&Md5Ctx, ":", 1);
+ MD5_Update(&Md5Ctx, pszNonce, strlen(pszNonce));
+ MD5_Update(&Md5Ctx, ":", 1);
+ MD5_Update(&Md5Ctx, pszCNonce, strlen(pszCNonce));
+ MD5_Final(HA1, &Md5Ctx);
+ };
+ CvtHex(HA1, SessionKey);
+}
+
+/* calculate request-digest/response-digest as per HTTP Digest spec */
+void
+DigestCalcResponse(
+ IN HASHHEX HA1, /* H(A1) */
+ IN char * pszNonce, /* nonce from server */
+ IN char * pszNonceCount, /* 8 hex digits */
+ IN char * pszCNonce, /* client nonce */
+ IN char * pszQop, /* qop-value: "", "auth", "auth-int" */
+ IN char * pszMethod, /* method from the request */
+ IN char * pszDigestUri, /* requested URL */
+ IN HASHHEX HEntity, /* H(entity body) if qop="auth-int" */
+ OUT HASHHEX Response /* request-digest or response-digest */
+ )
+{
+ MD5_CTX Md5Ctx;
+ HASH HA2;
+ HASH RespHash;
+ HASHHEX HA2Hex;
+
+ // calculate H(A2)
+ MD5_Init(&Md5Ctx);
+ MD5_Update(&Md5Ctx, pszMethod, strlen(pszMethod));
+ MD5_Update(&Md5Ctx, ":", 1);
+ MD5_Update(&Md5Ctx, pszDigestUri, strlen(pszDigestUri));
+ if (strcasecmp(pszQop, "auth-int") == 0)
+ {
+ MD5_Update(&Md5Ctx, ":", 1);
+ MD5_Update(&Md5Ctx, HEntity, HASHHEXLEN);
+ };
+ MD5_Final(HA2, &Md5Ctx);
+ CvtHex(HA2, HA2Hex);
+
+ // calculate response
+ MD5_Init(&Md5Ctx);
+ MD5_Update(&Md5Ctx, HA1, HASHHEXLEN);
+ MD5_Update(&Md5Ctx, ":", 1);
+ MD5_Update(&Md5Ctx, pszNonce, strlen(pszNonce));
+ MD5_Update(&Md5Ctx, ":", 1);
+ if (*pszQop)
+ {
+ MD5_Update(&Md5Ctx, pszNonceCount, strlen(pszNonceCount));
+ MD5_Update(&Md5Ctx, ":", 1);
+ MD5_Update(&Md5Ctx, pszCNonce, strlen(pszCNonce));
+ MD5_Update(&Md5Ctx, ":", 1);
+ MD5_Update(&Md5Ctx, pszQop, strlen(pszQop));
+ MD5_Update(&Md5Ctx, ":", 1);
+ };
+ MD5_Update(&Md5Ctx, HA2Hex, HASHHEXLEN);
+ MD5_Final(RespHash, &Md5Ctx);
+ CvtHex(RespHash, Response);
+}
+
+#endif
diff --git a/httpdigest.h b/httpdigest.h
new file mode 100644
index 0000000..fb6d114
--- /dev/null
+++ b/httpdigest.h
@@ -0,0 +1,60 @@
+/*
+ * OpenVPN -- An application to securely tunnel IP networks
+ * over a single TCP/UDP port, with support for SSL/TLS-based
+ * session authentication and key exchange,
+ * packet encryption, packet authentication, and
+ * packet compression.
+ *
+ * Copyright (C) 2002-2010 OpenVPN Technologies, Inc. <sales@openvpn.net>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program (see the file COPYING included with this
+ * distribution); if not, write to the Free Software Foundation, Inc.,
+ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#if PROXY_DIGEST_AUTH
+
+#define HASHLEN 16
+typedef unsigned char HASH[HASHLEN];
+#define HASHHEXLEN 32
+typedef unsigned char HASHHEX[HASHHEXLEN+1];
+#undef IN
+#undef OUT
+#define IN const
+#define OUT
+
+/* calculate H(A1) as per HTTP Digest spec */
+void DigestCalcHA1(
+ IN char * pszAlg,
+ IN char * pszUserName,
+ IN char * pszRealm,
+ IN char * pszPassword,
+ IN char * pszNonce,
+ IN char * pszCNonce,
+ OUT HASHHEX SessionKey
+ );
+
+/* calculate request-digest/response-digest as per HTTP Digest spec */
+void DigestCalcResponse(
+ IN HASHHEX HA1, /* H(A1) */
+ IN char * pszNonce, /* nonce from server */
+ IN char * pszNonceCount, /* 8 hex digits */
+ IN char * pszCNonce, /* client nonce */
+ IN char * pszQop, /* qop-value: "", "auth", "auth-int" */
+ IN char * pszMethod, /* method from the request */
+ IN char * pszDigestUri, /* requested URL */
+ IN HASHHEX HEntity, /* H(entity body) if qop="auth-int" */
+ OUT HASHHEX Response /* request-digest or response-digest */
+ );
+
+#endif
diff --git a/images/Makefile.am b/images/Makefile.am
index adaed57..334554f 100644
--- a/images/Makefile.am
+++ b/images/Makefile.am
@@ -5,7 +5,7 @@
# packet encryption, packet authentication, and
# packet compression.
#
-# Copyright (C) 2002-2009 OpenVPN Technologies, Inc. <sales@openvpn.net>
+# Copyright (C) 2002-2010 OpenVPN Technologies, Inc. <sales@openvpn.net>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2
diff --git a/init.c b/init.c
index b4a0384..d47a4ef 100644
--- a/init.c
+++ b/init.c
@@ -5,7 +5,7 @@
* packet encryption, packet authentication, and
* packet compression.
*
- * Copyright (C) 2002-2009 OpenVPN Technologies, Inc. <sales@openvpn.net>
+ * Copyright (C) 2002-2010 OpenVPN Technologies, Inc. <sales@openvpn.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2
@@ -111,6 +111,101 @@ update_options_ce_post (struct options *options)
#endif
}
+#if HTTP_PROXY_FALLBACK
+
+static bool
+ce_http_proxy_fallback_defined(const struct context *c)
+{
+ const struct connection_list *l = c->options.connection_list;
+ if (l && l->current == 0)
+ {
+ int i;
+ for (i = 0; i < l->len; ++i)
+ {
+ const struct connection_entry *ce = l->array[i];
+ if (ce->flags & CE_HTTP_PROXY_FALLBACK)
+ return true;
+ }
+ }
+ return false;
+}
+
+static void
+ce_http_proxy_fallback_start(struct context *c, const char *remote_ip_hint)
+{
+ const struct connection_list *l = c->options.connection_list;
+ if (l)
+ {
+ int i;
+ for (i = 0; i < l->len; ++i)
+ {
+ struct connection_entry *ce = l->array[i];
+ if (ce->flags & CE_HTTP_PROXY_FALLBACK)
+ {
+ ce->http_proxy_options = NULL;
+ ce->ce_http_proxy_fallback_timestamp = 0;
+ if (!remote_ip_hint)
+ remote_ip_hint = ce->remote;
+ }
+ }
+ }
+
+ if (management)
+ management_http_proxy_fallback_notify(management, "NEED_LATER", remote_ip_hint);
+}
+
+static bool
+ce_http_proxy_fallback (struct context *c, volatile const struct connection_entry *ce)
+{
+ const int proxy_info_expire = 120; /* seconds before proxy info expires */
+
+ update_time();
+ if (management)
+ {
+ if (!ce->ce_http_proxy_fallback_timestamp)
+ {
+ management_http_proxy_fallback_notify(management, "NEED_NOW", NULL);
+ while (!ce->ce_http_proxy_fallback_timestamp)
+ {
+ management_event_loop_n_seconds (management, 1);
+ if (IS_SIG (c))
+ return false;
+ }
+ }
+ return (now < ce->ce_http_proxy_fallback_timestamp + proxy_info_expire && ce->http_proxy_options);
+ }
+ return false;
+}
+
+static bool
+management_callback_http_proxy_fallback_cmd (void *arg, const char *server, const char *port, const char *flags)
+{
+ struct context *c = (struct context *) arg;
+ const struct connection_list *l = c->options.connection_list;
+ int ret = false;
+ struct http_proxy_options *ho = parse_http_proxy_fallback (c, server, port, flags, M_WARN);
+
+ update_time();
+ if (l)
+ {
+ int i;
+ for (i = 0; i < l->len; ++i)
+ {
+ struct connection_entry *ce = l->array[i];
+ if (ce->flags & CE_HTTP_PROXY_FALLBACK)
+ {
+ ce->http_proxy_options = ho;
+ ce->ce_http_proxy_fallback_timestamp = now;
+ ret = true;
+ }
+ }
+ }
+
+ return ret;
+}
+
+#endif
+
/*
* Initialize and possibly randomize connection list.
*/
@@ -141,6 +236,30 @@ init_connection_list (struct context *c)
#endif
}
+#if 0 /* fixme -- disable for production */
+static void
+show_connection_list (const struct connection_list *l)
+{
+ int i;
+ dmsg (M_INFO, "CONNECTION_LIST len=%d current=%d",
+ l->len, l->current);
+ for (i = 0; i < l->len; ++i)
+ {
+ dmsg (M_INFO, "[%d] %s:%d proto=%s http_proxy=%d",
+ i,
+ l->array[i]->remote,
+ l->array[i]->remote_port,
+ proto2ascii(l->array[i]->proto, true),
+ BOOL_CAST(l->array[i]->http_proxy_options));
+ }
+}
+#else
+static inline void
+show_connection_list (const struct connection_list *l)
+{
+}
+#endif
+
/*
* Increment to next connection entry
*/
@@ -151,27 +270,66 @@ next_connection_entry (struct context *c)
struct connection_list *l = c->options.connection_list;
if (l)
{
- if (l->no_advance && l->current >= 0)
- {
- l->no_advance = false;
- }
- else
- {
- int i;
- if (++l->current >= l->len)
- l->current = 0;
+ bool ce_defined;
+ struct connection_entry *ce;
+ int n_cycles = 0;
- dmsg (D_CONNECTION_LIST, "CONNECTION_LIST len=%d current=%d",
- l->len, l->current);
- for (i = 0; i < l->len; ++i)
- {
- dmsg (D_CONNECTION_LIST, "[%d] %s:%d",
- i,
- l->array[i]->remote,
- l->array[i]->remote_port);
- }
- }
- c->options.ce = *l->array[l->current];
+ do {
+ const char *remote_ip_hint = NULL;
+ bool newcycle = false;
+
+ ce_defined = true;
+ if (l->no_advance && l->current >= 0)
+ {
+ l->no_advance = false;
+ }
+ else
+ {
+ if (++l->current >= l->len)
+ {
+ l->current = 0;
+ ++l->n_cycles;
+ if (++n_cycles >= 2)
+ msg (M_FATAL, "No usable connection profiles are present");
+ }
+
+ if (l->current == 0)
+ newcycle = true;
+ show_connection_list(l);
+ }
+
+ ce = l->array[l->current];
+
+ if (c->options.remote_ip_hint && !l->n_cycles)
+ remote_ip_hint = c->options.remote_ip_hint;
+
+#if HTTP_PROXY_FALLBACK
+ if (newcycle && ce_http_proxy_fallback_defined(c))
+ ce_http_proxy_fallback_start(c, remote_ip_hint);
+
+ if (ce->flags & CE_HTTP_PROXY_FALLBACK)
+ {
+ ce_defined = ce_http_proxy_fallback(c, ce);
+ if (IS_SIG (c))
+ break;
+ }
+#endif
+
+ if (ce->flags & CE_DISABLED)
+ ce_defined = false;
+
+ c->options.ce = *ce;
+
+ if (remote_ip_hint)
+ c->options.ce.remote = remote_ip_hint;
+
+#if 0 /* fixme -- disable for production, this code simulates a network where proxy fallback is the only method to reach the OpenVPN server */
+ if (!(c->options.ce.flags & CE_HTTP_PROXY_FALLBACK))
+ {
+ c->options.ce.remote = "10.10.0.1"; /* use an unreachable address here */
+ }
+#endif
+ } while (!ce_defined);
}
#endif
update_options_ce_post (&c->options);
@@ -458,7 +616,7 @@ init_static (void)
#ifdef STATUS_PRINTF_TEST
{
struct gc_arena gc = gc_new ();
- const char *tmp_file = create_temp_filename ("/tmp", "foo", &gc);
+ const char *tmp_file = create_temp_file ("/tmp", "foo", &gc);
struct status_output *so = status_open (tmp_file, 0, -1, NULL, STATUS_OUTPUT_WRITE);
status_printf (so, "%s", "foo");
status_printf (so, "%s", "bar");
@@ -500,6 +658,60 @@ init_static (void)
}
#endif
+#ifdef BUFFER_LIST_AGGREGATE_TEST
+ /* test buffer_list_aggregate function */
+ {
+ static const char *text[] = {
+ "It was a bright cold day in April, ",
+ "and the clocks were striking ",
+ "thirteen. ",
+ "Winston Smith, ",
+ "his chin nuzzled into his breast in an ",
+ "effort to escape the vile wind, ",
+ "slipped quickly through the glass doors ",
+ "of Victory Mansions, though not quickly ",
+ "enough to prevent a swirl of gritty dust from ",
+ "entering along with him."
+ };
+
+ int iter, listcap;
+ for (listcap = 0; listcap < 12; ++listcap)
+ {
+ for (iter = 0; iter < 512; ++iter)
+ {
+ struct buffer_list *bl = buffer_list_new(listcap);
+ {
+ int i;
+ for (i = 0; i < SIZE(text); ++i)
+ buffer_list_push(bl, (unsigned char *)text[i]);
+ }
+ printf("[cap=%d i=%d] *************************\n", listcap, iter);
+ if (!(iter & 8))
+ buffer_list_aggregate(bl, iter/2);
+ if (!(iter & 16))
+ buffer_list_push(bl, (unsigned char *)"Even more text...");
+ buffer_list_aggregate(bl, iter);
+ if (!(iter & 1))
+ buffer_list_push(bl, (unsigned char *)"More text...");
+ {
+ struct buffer *buf;
+ while ((buf = buffer_list_peek(bl)))
+ {
+ int c;
+ printf ("'");
+ while ((c = buf_read_u8(buf)) >= 0)
+ putchar(c);
+ printf ("'\n");
+ buffer_list_advance(bl, 0);
+ }
+ }
+ buffer_list_free(bl);
+ }
+ }
+ return false;
+ }
+#endif
+
return true;
}
@@ -925,6 +1137,10 @@ initialization_sequence_completed (struct context *c, const unsigned int flags)
if ((flags & (ISC_ERRORS|ISC_SERVER)) == 0 && connection_list_defined (&c->options))
connection_list_set_no_advance (&c->options);
+#ifdef WIN32
+ fork_register_dns_action (c->c1.tuntap);
+#endif
+
#ifdef ENABLE_MANAGEMENT
/* Tell management interface that we initialized */
if (management)
@@ -1793,6 +2009,9 @@ do_init_crypto_tls (struct context *c, const unsigned int flags)
to.renegotiate_packets = options->renegotiate_packets;
to.renegotiate_seconds = options->renegotiate_seconds;
to.single_session = options->single_session;
+#ifdef ENABLE_PUSH_PEER_INFO
+ to.push_peer_info = options->push_peer_info;
+#endif
/* should we not xmit any packets until we get an initial
response from client? */
@@ -2720,6 +2939,9 @@ init_management_callback_p2p (struct context *c)
cb.arg = c;
cb.status = management_callback_status_p2p;
cb.show_net = management_show_net_callback;
+#if HTTP_PROXY_FALLBACK
+ cb.http_proxy_fallback_cmd = management_callback_http_proxy_fallback_cmd;
+#endif
management_set_callback (management, &cb);
}
#endif
@@ -2844,6 +3066,17 @@ init_instance (struct context *c, const struct env_set *env, const unsigned int
c->sig->signal_text = NULL;
c->sig->hard = false;
+ if (c->mode == CM_P2P)
+ init_management_callback_p2p (c);
+
+ /* possible sleep or management hold if restart */
+ if (c->mode == CM_P2P || c->mode == CM_TOP)
+ {
+ do_startup_pause (c);
+ if (IS_SIG (c))
+ goto sig;
+ }
+
/* map in current connection entry */
next_connection_entry (c);
@@ -2862,14 +3095,6 @@ init_instance (struct context *c, const struct env_set *env, const unsigned int
if (c->first_time && options->mlock)
do_mlockall (true);
- /* possible sleep or management hold if restart */
- if (c->mode == CM_P2P || c->mode == CM_TOP)
- {
- do_startup_pause (c);
- if (IS_SIG (c))
- goto sig;
- }
-
#if P2MP
/* get passwords if undefined */
if (auth_retry_get () == AR_INTERACT)
diff --git a/init.h b/init.h
index d2c10f4..cf5ca8a 100644
--- a/init.h
+++ b/init.h
@@ -5,7 +5,7 @@
* packet encryption, packet authentication, and
* packet compression.
*
- * Copyright (C) 2002-2009 OpenVPN Technologies, Inc. <sales@openvpn.net>
+ * Copyright (C) 2002-2010 OpenVPN Technologies, Inc. <sales@openvpn.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2
diff --git a/install-win32/Makefile.am b/install-win32/Makefile.am
index 784f808..7211de2 100644
--- a/install-win32/Makefile.am
+++ b/install-win32/Makefile.am
@@ -5,7 +5,7 @@
# packet encryption, packet authentication, and
# packet compression.
#
-# Copyright (C) 2002-2009 OpenVPN Technologies, Inc. <sales@openvpn.net>
+# Copyright (C) 2002-2010 OpenVPN Technologies, Inc. <sales@openvpn.net>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2
diff --git a/install-win32/buildinstaller b/install-win32/buildinstaller
index 83057bb..a17a027 100644
--- a/install-win32/buildinstaller
+++ b/install-win32/buildinstaller
@@ -10,5 +10,5 @@ tail -20 makensis.log
# sign the installer
if [ -d "$SIGNTOOL" ]; then
- TARGET_EXE="$(echo $(pwd)/$GENOUT/*.exe)" $SIGNTOOL/signexe
+ python $SIGNTOOL/signapp.py "$(echo $(pwd)/$GENOUT/*.exe)"
fi
diff --git a/install-win32/getgui b/install-win32/getgui
index b53a8f7..aa83e85 100644
--- a/install-win32/getgui
+++ b/install-win32/getgui
@@ -10,9 +10,6 @@ GUI="$OPENVPN_GUI_DIR/$OPENVPN_GUI"
if [ -f "$GUI" ]; then
mkdir -p $GENOUT/bin &>/dev/null
cp $GUI $GENOUT/bin
- if [ -d "$SIGNTOOL" ]; then
- TARGET_EXE="$GENOUT/bin/$OPENVPN_GUI" $SIGNTOOL/signexe
- fi
fi
if [ -f "$GENOUT/bin/$OPENVPN_GUI" ]; then
diff --git a/install-win32/getxgui b/install-win32/getxgui
index d3a21b8..3a1e626 100644
--- a/install-win32/getxgui
+++ b/install-win32/getxgui
@@ -19,12 +19,6 @@ if [ -d "$OPENVPN_XGUI_DIR" ]; then
done
fi
- for f in $SIGNED_EXES; do
- if [ -d "$SIGNTOOL" ]; then
- TARGET_EXE="$GENOUT/bin/`basename $f`" $SIGNTOOL/signexe
- fi
- done
-
rm -rf $GENOUT/htdocs
cp -a $OPENVPN_XGUI_DIR/ajax/htdocs $GENOUT/htdocs
diff --git a/install-win32/maketap b/install-win32/maketap
index 0d33329..b9c4070 100644
--- a/install-win32/maketap
+++ b/install-win32/maketap
@@ -1,101 +1,17 @@
#!/bin/sh
-# Build the x86 and x64 versions of the TAP driver
-# Requires the Windows DDK
+# Get the x86 and x64 versions of the TAP driver
# get version.nsi definitions
. autodefs/defs.sh
-if [ -n "$DDKVER" ] && [ -d "/c/WINDDK/$DDKVER" ] ; then
-
-# common declarations for all DDK build targets
-. install-win32/ddk-common
-
-# configure tap driver sources
-MACRO="perl install-win32/macro.pl autodefs/defs.in"
-IFDEF="perl install-win32/ifdef.pl"
-rm -rf tap-win32/amd64
-mkdir tap-win32/amd64
-$MACRO <tap-win32/SOURCES.in >tap-win32/SOURCES
-$MACRO <tap-win32/i386/OemWin2k.inf.in | $IFDEF >tap-win32/i386/OemWin2k.inf
-$MACRO <tap-win32/i386/OemWin2k.inf.in | $IFDEF -DAMD64 >tap-win32/amd64/OemWin2k.inf
-
-if [ -n "$PRODUCT_TAP_DEBUG" ] ; then
- w2ktarget="w2k c"
- amdtarget="chk $x64_tag WNET"
-else
- w2ktarget="w2k f"
- amdtarget="fre $x64_tag WNET"
-fi
-
-if [ -z "$DRVBINSRC" ] ; then
- if [ -n "$TAP_BIN_AMD64" ]; then
- amdtarget=""
- fi
-
- cd tap-win32
- t=`pwd`
- cd ..
-
- for mode in "$w2ktarget" "$amdtarget"; do
- echo '**********' build TAP $mode
- cmd //c "C:\\WINDDK\\$DDKVER\\bin\\setenv.bat C:\\WINDDK\\$DDKVER $mode && cd `perl install-win32/dosname.pl $t` && build -cef"
- mv tap-win32/tapdrvr.cod "tap-win32/tapdrvr-$(echo $mode | tr ' ' '-').cod"
+if [ -d "$TAPBINSRC" ]; then
+ mkdir -p $GENOUT/driver/i386 &>/dev/null
+ mkdir -p $GENOUT/driver/amd64 &>/dev/null
+ for arch in i386 amd64; do
+ s=$TAPBINSRC/$arch
+ cp $s/*.sys $s/*.cat $s/*.inf $GENOUT/driver/$arch
done
-
- title openvpn-build &>/dev/null
-
- if [ -n "$TAP_BIN_AMD64" ]; then
- mkdir -p $t/amd64
- cp "$TAP_BIN_AMD64" $t/amd64
- fi
-
- # copy driver files into tap-win32/dist
- cd tap-win32
- rm -rf dist
- mkdir dist
- cd dist
- mkdir i386
- mkdir amd64
- cd i386
- x86=`pwd`
- cd ../amd64
- x64=`pwd`
- cd ../..
- cp i386/OemWin2k.inf $x86
- cp i386/*.sys $x86
- cp amd64/OemWin2k.inf $x64
- cp amd64/*.sys $x64
- out="TAP driver catalog file is undefined";
- echo "$out" >$x86/$PRODUCT_TAP_ID.cat
- echo "$out" >$x64/$PRODUCT_TAP_ID.cat
- cd ..
-fi
-
-# $DRVBINSRC, if defined, points to prebuilt TAP driver and
-# tapinstall.exe.
-mkdir $GENOUT &>/dev/null
-rm -rf $GENOUT/driver
-if [ -z "$DRVBINSRC" ] ; then
- # Get TAP drivers
- cp -a tap-win32/dist $GENOUT/driver
-
- # Sign TAP drivers
- if [ -d "$SIGNTOOL" ]; then
- $SIGNTOOL/signtap
- fi
-else
- cp -a $DRVBINSRC/driver $GENOUT/driver
-fi
-
-# $DRVBINDEST, if defined, points to a destination directory
-# where TAP driver and tapinstall.exe will be saved, to be used
-# as a $DRVBINSRC in future builds.
-if [ -n "$DRVBINDEST" ] ; then
- mkdir $DRVBINDEST &>/dev/null
- cp -a $GENOUT/driver $DRVBINDEST
-fi
-
else
- echo Not building TAP driver -- DDK version $DDKVER NOT FOUND
+ echo Cannot find pre-built tap drivers
fi
diff --git a/install-win32/maketapinstall b/install-win32/maketapinstall
index eae4471..9fe0470 100644
--- a/install-win32/maketapinstall
+++ b/install-win32/maketapinstall
@@ -1,77 +1,15 @@
#!/bin/sh
-# Build the x86 and x64 versions of the tapinstall tool
-# Requires the Windows DDK.
-# TISRC should be set to directory containing
-# tapinstall source code.
+# Get the x86 and x64 versions of the tapinstall tool
# get version.nsi definitions
. autodefs/defs.sh
-if [ -n "$DDKVER" ] && [ -d "/c/WINDDK/$DDKVER" ] ; then
-
-if ! [ -d "$TISRC" ] ; then
- echo "$TISRC" NOT INSTALLED
- exit 1
-fi
-
-# common declarations for all DDK build targets
-. install-win32/ddk-common
-
-amdtarget=""
-if [ -z "$TI_BIN_AMD64" ]; then
- amdtarget="fre $x64_tag WNET"
-fi
-
-if [ -z "$DRVBINSRC" ] ; then
- rm -rf tapinstall
- cp -a "$TISRC" tapinstall
-
- if [ -e tapinstall/sources.in ]; then
- perl install-win32/ifdef.pl autodefs/defs.in <tapinstall/sources.in >tapinstall/sources
- fi
-
- cd tapinstall
- t=`pwd`
- cd ..
-
- for mode in "w2k f" "$amdtarget"; do
- if [ -n "$mode" ]; then
- echo '**********' build TAPINSTALL $mode
- cmd //c "C:\\WINDDK\\$DDKVER\\bin\\setenv.bat C:\\WINDDK\\$DDKVER $mode && cd `perl install-win32/dosname.pl $t` && build -cef"
- fi
- done
-fi
-
-if [ -n "$TI_BIN_AMD64" ]; then
- mkdir -p $t/objfre_wnet_amd64/amd64
- cp "$TI_BIN_AMD64" $t/objfre_wnet_amd64/amd64
-fi
-
-# $DRVBINSRC, if defined, points to prebuilt TAP driver and
-# tapinstall.exe.
-if [ -z "$DRVBINSRC" ] ; then
- # Get tapinstall
+if [ -d "$TAPBINSRC" ]; then
mkdir -p $GENOUT/tapinstall/i386 &>/dev/null
mkdir -p $GENOUT/tapinstall/amd64 &>/dev/null
- cp tapinstall/objfre_w2k_x86/i386/tapinstall.exe $GENOUT/tapinstall/i386
- cp tapinstall/objfre_wnet_amd64/amd64/tapinstall.exe $GENOUT/tapinstall/amd64
-else
- mkdir $GENOUT &>/dev/null
- cp -a $DRVBINSRC/tapinstall $GENOUT/tapinstall
-fi
-
-# $DRVBINDEST, if defined, points to a destination directory
-# where TAP driver and tapinstall.exe will be saved, to be used
-# as a $DRVBINSRC in future builds.
-if [ -n "$DRVBINDEST" ] ; then
- mkdir $DRVBINDEST &>/dev/null
- cp -a $GENOUT/driver $DRVBINDEST
- cp -a $GENOUT/tapinstall $DRVBINDEST
-fi
-
-title openvpn-build &>/dev/null
-
+ cp $TAPBINSRC/i386/tapinstall.exe $GENOUT/tapinstall/i386
+ cp $TAPBINSRC/amd64/tapinstall.exe $GENOUT/tapinstall/amd64
else
- echo Not building tapinstall -- DDK version $DDKVER NOT BUILT
+ echo Cannot find pre-built tapinstall
fi
diff --git a/install-win32/openvpn.nsi b/install-win32/openvpn.nsi
index bd0298b..b6e4a07 100755
--- a/install-win32/openvpn.nsi
+++ b/install-win32/openvpn.nsi
@@ -1,5 +1,5 @@
; ****************************************************************************
-; * Copyright (C) 2002-2009 OpenVPN Technologies, Inc. *
+; * Copyright (C) 2002-2010 OpenVPN Technologies, Inc. *
; * This program is free software; you can redistribute it and/or modify *
; * it under the terms of the GNU General Public License version 2 *
; * as published by the Free Software Foundation. *
diff --git a/install-win32/settings.in b/install-win32/settings.in
index 643ef99..4a0a564 100644
--- a/install-win32/settings.in
+++ b/install-win32/settings.in
@@ -22,47 +22,24 @@
;!define OPENVPN_XGUI_DIR "../ovpnxml"
# Prebuilt libraries. DMALLOC is optional.
-!define OPENSSL_DIR "../openssl-0.9.8l"
+!define OPENSSL_DIR "../openssl.mingw/openssl-0.9.8o"
!define LZO_DIR "../lzo-2.02"
!define PKCS11_HELPER_DIR "../pkcs11-helper"
;!define DMALLOC_DIR "../dmalloc-5.4.2"
+# Prebuilt TAP drivers and tapinstall
+!define TAPBINSRC "../tap_dist"
+
+# Directory containing python script for signing .exe files
+!define SIGNTOOL "../signtool"
+
# Optional directory of prebuilt OpenVPN binary components,
# to be used as a source when build-from-scratch prerequisites
# are not met.
;!define GENOUT_PREBUILT "../gen-prebuilt"
-# tapinstall.exe source code.
-# Not needed if DRVBINSRC is defined
-# (or if using pre-built mode).
-!define TISRC "../tapinstall"
-
-# TAP Adapter parameters. Note that PRODUCT_TAP_ID is
-# defined in version.m4.
-!define PRODUCT_TAP_DEVICE_DESCRIPTION "TAP-Win32 Adapter V9"
-!define PRODUCT_TAP_PROVIDER "TAP-Win32 Provider V9"
-!define PRODUCT_TAP_MAJOR_VER 9
-!define PRODUCT_TAP_MINOR_VER 6
-!define PRODUCT_TAP_RELDATE "06/22/2009"
-
-# TAP adapter icon -- visible=0x81 or hidden=0x89
-!define PRODUCT_TAP_CHARACTERISTICS 0x81
-
-# Build debugging version of TAP driver
-;!define PRODUCT_TAP_DEBUG
-
-# DDK Version.
-# DDK distribution is assumed to be in C:\WINDDK\${DDKVER}
-!define DDKVER 6001.18002
-!define DDKVER_MAJOR 6001
-
-# Code Signing.
-# If undefined, don't sign any files.
-!define SIGNTOOL "../signtool"
-!define PRODUCT_SIGN_CN "openvpn"
-
# -j parameter passed to make
-!define MAKE_JOBS 2
+!define MAKE_JOBS 1
# output directory for built binaries
# and other generated files
diff --git a/install-win32/winconfig b/install-win32/winconfig
index 9beaca3..9d686c9 100644
--- a/install-win32/winconfig
+++ b/install-win32/winconfig
@@ -13,3 +13,6 @@ for g in "h" "sh" "nsi" "in" ; do
done
cat /dev/null >autodefs/guidefs.nsi
+
+echo '#include "autodefs/defs.h"' >autodefs.h
+echo '#include "config.h"' >>autodefs.h
diff --git a/integer.h b/integer.h
index 43ae64a..f0fc196 100644
--- a/integer.h
+++ b/integer.h
@@ -5,7 +5,7 @@
* packet encryption, packet authentication, and
* packet compression.
*
- * Copyright (C) 2002-2009 OpenVPN Technologies, Inc. <sales@openvpn.net>
+ * Copyright (C) 2002-2010 OpenVPN Technologies, Inc. <sales@openvpn.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2
diff --git a/interval.c b/interval.c
index fcda4b7..44d59d0 100644
--- a/interval.c
+++ b/interval.c
@@ -5,7 +5,7 @@
* packet encryption, packet authentication, and
* packet compression.
*
- * Copyright (C) 2002-2009 OpenVPN Technologies, Inc. <sales@openvpn.net>
+ * Copyright (C) 2002-2010 OpenVPN Technologies, Inc. <sales@openvpn.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2
diff --git a/interval.h b/interval.h
index f0e5875..4814ec9 100644
--- a/interval.h
+++ b/interval.h
@@ -5,7 +5,7 @@
* packet encryption, packet authentication, and
* packet compression.
*
- * Copyright (C) 2002-2009 OpenVPN Technologies, Inc. <sales@openvpn.net>
+ * Copyright (C) 2002-2010 OpenVPN Technologies, Inc. <sales@openvpn.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2
diff --git a/list.c b/list.c
index d4d4ea8..fb93d0a 100644
--- a/list.c
+++ b/list.c
@@ -5,7 +5,7 @@
* packet encryption, packet authentication, and
* packet compression.
*
- * Copyright (C) 2002-2009 OpenVPN Technologies, Inc. <sales@openvpn.net>
+ * Copyright (C) 2002-2010 OpenVPN Technologies, Inc. <sales@openvpn.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2
diff --git a/list.h b/list.h
index ab5ea09..adde36b 100644
--- a/list.h
+++ b/list.h
@@ -5,7 +5,7 @@
* packet encryption, packet authentication, and
* packet compression.
*
- * Copyright (C) 2002-2009 OpenVPN Technologies, Inc. <sales@openvpn.net>
+ * Copyright (C) 2002-2010 OpenVPN Technologies, Inc. <sales@openvpn.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2
diff --git a/lzo.c b/lzo.c
index a371573..6ea0d03 100644
--- a/lzo.c
+++ b/lzo.c
@@ -5,7 +5,7 @@
* packet encryption, packet authentication, and
* packet compression.
*
- * Copyright (C) 2002-2009 OpenVPN Technologies, Inc. <sales@openvpn.net>
+ * Copyright (C) 2002-2010 OpenVPN Technologies, Inc. <sales@openvpn.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2
diff --git a/lzo.h b/lzo.h
index b010f50..bb15753 100644
--- a/lzo.h
+++ b/lzo.h
@@ -5,7 +5,7 @@
* packet encryption, packet authentication, and
* packet compression.
*
- * Copyright (C) 2002-2009 OpenVPN Technologies, Inc. <sales@openvpn.net>
+ * Copyright (C) 2002-2010 OpenVPN Technologies, Inc. <sales@openvpn.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2
diff --git a/makefile.w32-vc b/makefile.w32-vc
deleted file mode 100644
index addf9da..0000000
--- a/makefile.w32-vc
+++ /dev/null
@@ -1,186 +0,0 @@
-# This makefile builds the user-mode component
-# of OpenVPN for WIN32 in the MSVC++ environment.
-#
-# Build Dependencies:
-# OpenSSL (SSL/TLS/crypto library)
-# LZO (real-time compression library)
-#
-# Targets:
-# static -- link statically with OpenSSL
-# dynamic -- link dynamically with OpenSSL
-#
-# Note that LZO is always linked statically.
-
-# Change these to point to your OpenSSL and LZO top-level
-# directories.
-
-OPENSSL = \src\openssl-0.9.7d
-OPENSSL_STATIC = libeay32s.lib ssleay32s.lib
-#OPENSSL_STATIC = libeay32sd.lib ssleay32sd.lib
-OPENSSL_DYNAMIC = libeay32.lib ssleay32.lib
-#OPENSSL_DYNAMIC = libeay32d.lib ssleay32d.lib
-
-LZO = \src\lzo-1.08.vc
-
-PKCS11_HELPER = \src\pkcs11-helper-1.02
-
-INCLUDE_DIRS = -I$(OPENSSL)/include -I$(LZO)/include -I$(PKCS11_HELPER)/include
-
-LIBS = lzo.lib libpkcs11-helper-1.lib ws2_32.lib crypt32.lib iphlpapi.lib winmm.lib user32.lib gdi32.lib advapi32.lib wininet.lib
-
-LIB_DIRS = -LIBPATH:$(OPENSSL)\out -LIBPATH:$(LZO) -LIBPATH:$(PKCS11_HELPER)\lib
-
-EXE = openvpn.exe
-
-CPP=cl.exe
-CPP_ARG_COMMON=/nologo /W3 /G5 /O2 -DWIN32 -DWIN32_LEAN_AND_MEAN -D_CONSOLE -D_MBCS -D_CRT_SECURE_NO_DEPRECATE $(INCLUDE_DIRS) /FD /c
-# release:
-CPP_PROJ=$(CPP_ARG_COMMON) /MD -DNDEBUG
-# debug:
-#CPP_PROJ=$(CPP_ARG_COMMON) /MDd /Zi /Od -D_DEBUG
-
-LINK32=link.exe
-# release:
-LINK32_FLAGS=/nologo /subsystem:console /incremental:no /out:"$(EXE)"
-# debug:
-#LINK32_FLAGS=/nologo /subsystem:console /incremental:no /debug /out:"$(EXE)"
-
-# Make sure the HEADERS and OBJS definitions below match the same
-# definitions in makefile.w32.
-
-HEADERS = \
- base64.h \
- basic.h \
- buffer.h \
- circ_list.h common.h \
- tap-win32/common.h \
- config-win32.h \
- crypto.h \
- cryptoapi.h \
- errlevel.h \
- error.h \
- event.h \
- fdmisc.h \
- forward-inline.h \
- forward.h \
- fragment.h \
- gremlin.h \
- helper.h \
- init.h \
- integer.h \
- interval.h \
- list.h \
- lzo.h \
- manage.h \
- mbuf.h \
- memdbg.h \
- misc.h \
- mroute.h \
- mss.h \
- mtcp.h \
- mtu.h \
- mudp.h \
- multi.h \
- ntlm.h \
- occ-inline.h \
- occ.h \
- pkcs11.h \
- openvpn.h \
- openvpn-plugin.h \
- options.h \
- otime.h \
- packet_id.h \
- perf.h \
- ping-inline.h \
- ping.h \
- plugin.h \
- pool.h \
- proto.h \
- proxy.h \
- push.h \
- reliable.h \
- route.h \
- schedule.h \
- session_id.h \
- shaper.h \
- sig.h \
- socket.h \
- socks.h \
- ssl.h \
- status.h \
- syshead.h \
- thread.h \
- tun.h \
- lladdr.h \
- win32.h
-
-OBJS = base64.obj \
- buffer.obj \
- crypto.obj \
- cryptoapi.obj \
- error.obj \
- event.obj \
- fdmisc.obj \
- forward.obj \
- fragment.obj \
- gremlin.obj \
- helper.obj \
- init.obj \
- interval.obj \
- list.obj \
- lzo.obj \
- manage.obj \
- mbuf.obj \
- misc.obj \
- mroute.obj \
- mss.obj \
- mtcp.obj \
- mtu.obj \
- mudp.obj \
- multi.obj \
- ntlm.obj \
- occ.obj \
- pkcs11.obj \
- openvpn.obj \
- options.obj \
- otime.obj \
- packet_id.obj \
- perf.obj \
- ping.obj \
- plugin.obj \
- pool.obj \
- proto.obj \
- proxy.obj \
- push.obj \
- reliable.obj \
- route.obj \
- schedule.obj \
- session_id.obj \
- shaper.obj \
- sig.obj \
- socket.obj \
- socks.obj \
- ssl.obj \
- status.obj \
- thread.obj \
- tun.obj \
- lladdr.obj \
- win32.obj
-
-dynamic : $(OBJS)
- $(LINK32) @<<
- $(LINK32_FLAGS) $(LIB_DIRS) $(LIBS) $(OPENSSL_DYNAMIC) $(OBJS)
-<<
-
-static : $(OBJS)
- $(LINK32) @<<
- $(LINK32_FLAGS) $(LIB_DIRS) $(LIBS) $(OPENSSL_STATIC) $(OBJS)
-<<
-
-clean :
- del /Q $(OBJS) $(EXE) *.idb *.pdb
-
-.c.obj::
- $(CPP) @<<
- $(CPP_PROJ) $<
-<<
diff --git a/manage.c b/manage.c
index f75aedd..820621e 100644
--- a/manage.c
+++ b/manage.c
@@ -5,7 +5,7 @@
* packet encryption, packet authentication, and
* packet compression.
*
- * Copyright (C) 2002-2009 OpenVPN Technologies, Inc. <sales@openvpn.net>
+ * Copyright (C) 2002-2010 OpenVPN Technologies, Inc. <sales@openvpn.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2
@@ -97,6 +97,7 @@ man_help ()
msg (M_CLIENT, "client-deny CID KID R [CR] : Deny auth client-id/key-id CID/KID with log reason");
msg (M_CLIENT, " text R and optional client reason text CR");
msg (M_CLIENT, "client-kill CID : Kill client instance CID");
+ msg (M_CLIENT, "env-filter [level] : Set env-var filter level");
#ifdef MANAGEMENT_PF
msg (M_CLIENT, "client-pf CID : Define packet filter for client CID (MULTILINE)");
#endif
@@ -109,6 +110,10 @@ man_help ()
msg (M_CLIENT, "username type u : Enter username u for a queried OpenVPN username.");
msg (M_CLIENT, "verb [n] : Set log verbosity level to n, or show if n is absent.");
msg (M_CLIENT, "version : Show current version number.");
+#if HTTP_PROXY_FALLBACK
+ msg (M_CLIENT, "http-proxy-fallback <server> <port> [flags] : Enter dynamic HTTP proxy fallback info.");
+ msg (M_CLIENT, "http-proxy-fallback-disable : Disable HTTP proxy fallback.");
+#endif
msg (M_CLIENT, "END");
}
@@ -203,12 +208,10 @@ man_update_io_state (struct management *man)
}
static void
-man_output_list_push (struct management *man, const char *str)
+man_output_list_push_finalize (struct management *man)
{
if (management_connected (man))
{
- if (str)
- buffer_list_push (man->connection.out, (const unsigned char *) str);
man_update_io_state (man);
if (!man->persist.standalone_disabled)
{
@@ -219,13 +222,29 @@ man_output_list_push (struct management *man, const char *str)
}
static void
+man_output_list_push_str (struct management *man, const char *str)
+{
+ if (management_connected (man) && str)
+ {
+ buffer_list_push (man->connection.out, (const unsigned char *) str);
+ }
+}
+
+static void
+man_output_list_push (struct management *man, const char *str)
+{
+ man_output_list_push_str (man, str);
+ man_output_list_push_finalize (man);
+}
+
+static void
man_prompt (struct management *man)
{
if (man_password_needed (man))
man_output_list_push (man, "ENTER PASSWORD:");
#if 0 /* should we use prompt? */
else
- man_output_list_push (man, PACKAGE_NAME ">");
+ man_output_list_push (man, ">");
#endif
}
@@ -255,12 +274,13 @@ man_close_socket (struct management *man, const socket_descriptor_t sd)
static void
virtual_output_callback_func (void *arg, const unsigned int flags, const char *str)
{
+ struct management *man = (struct management *) arg;
static int recursive_level = 0; /* GLOBAL */
+ bool did_push = false;
if (!recursive_level) /* don't allow recursion */
{
struct gc_arena gc = gc_new ();
- struct management *man = (struct management *) arg;
struct log_entry e;
const char *out = NULL;
@@ -288,13 +308,17 @@ virtual_output_callback_func (void *arg, const unsigned int flags, const char *s
| LOG_PRINT_LOG_PREFIX
| LOG_PRINT_CRLF, &gc);
if (out)
- man_output_list_push (man, out);
+ {
+ man_output_list_push_str (man, out);
+ did_push = true;
+ }
if (flags & M_FATAL)
{
out = log_entry_print (&e, LOG_FATAL_NOTIFY|LOG_PRINT_CRLF, &gc);
if (out)
{
- man_output_list_push (man, out);
+ man_output_list_push_str (man, out);
+ did_push = true;
man_reset_client_socket (man, true);
}
}
@@ -303,6 +327,9 @@ virtual_output_callback_func (void *arg, const unsigned int flags, const char *s
--recursive_level;
gc_free (&gc);
}
+
+ if (did_push)
+ man_output_list_push_finalize (man);
}
/*
@@ -935,6 +962,13 @@ man_client_n_clients (struct management *man)
}
}
+static void
+man_env_filter (struct management *man, const int level)
+{
+ man->connection.env_filter_level = level;
+ msg (M_CLIENT, "SUCCESS: env_filter_level=%d", level);
+}
+
#ifdef MANAGEMENT_PF
static void
@@ -990,6 +1024,31 @@ man_need (struct management *man, const char **p, const int n, unsigned int flag
return true;
}
+#if HTTP_PROXY_FALLBACK
+
+static void
+man_http_proxy_fallback (struct management *man, const char *server, const char *port, const char *flags)
+{
+ if (man->persist.callback.http_proxy_fallback_cmd)
+ {
+ const bool status = (*man->persist.callback.http_proxy_fallback_cmd)(man->persist.callback.arg, server, port, flags);
+ if (status)
+ {
+ msg (M_CLIENT, "SUCCESS: proxy-fallback command succeeded");
+ }
+ else
+ {
+ msg (M_CLIENT, "ERROR: proxy-fallback command failed");
+ }
+ }
+ else
+ {
+ msg (M_CLIENT, "ERROR: The proxy-fallback command is not supported by the current daemon mode");
+ }
+}
+
+#endif
+
static void
man_dispatch_command (struct management *man, struct status_output *so, const char **p, const int nparms)
{
@@ -1020,6 +1079,13 @@ man_dispatch_command (struct management *man, struct status_output *so, const ch
{
man_client_n_clients (man);
}
+ else if (streq (p[0], "env-filter"))
+ {
+ int level = 0;
+ if (p[1])
+ level = atoi (p[1]);
+ man_env_filter (man, level);
+ }
#endif
else if (streq (p[0], "signal"))
{
@@ -1195,6 +1261,17 @@ man_dispatch_command (struct management *man, struct status_output *so, const ch
man_pkcs11_id_get (man, atoi(p[1]));
}
#endif
+#if HTTP_PROXY_FALLBACK
+ else if (streq (p[0], "http-proxy-fallback"))
+ {
+ if (man_need (man, p, 2, MN_AT_LEAST))
+ man_http_proxy_fallback (man, p[1], p[2], p[3]);
+ }
+ else if (streq (p[0], "http-proxy-fallback-disable"))
+ {
+ man_http_proxy_fallback (man, NULL, NULL, NULL);
+ }
+#endif
#if 1
else if (streq (p[0], "test"))
{
@@ -1723,13 +1800,15 @@ man_read (struct management *man)
static int
man_write (struct management *man)
{
- const int max_send = 256;
+ const int size_hint = 1024;
int sent = 0;
+ const struct buffer *buf;
- const struct buffer *buf = buffer_list_peek (man->connection.out);
+ buffer_list_aggregate(man->connection.out, size_hint);
+ buf = buffer_list_peek (man->connection.out);
if (buf && BLEN (buf))
{
- const int len = min_int (max_send, BLEN (buf));
+ const int len = min_int (size_hint, BLEN (buf));
sent = send (man->connection.sd_cli, BPTR (buf), len, MSG_NOSIGNAL);
if (sent >= 0)
{
@@ -2086,7 +2165,7 @@ management_clear_callback (struct management *man)
man->persist.standalone_disabled = false;
man->persist.hold_release = false;
CLEAR (man->persist.callback);
- man_output_list_push (man, NULL); /* flush output queue */
+ man_output_list_push_finalize (man); /* flush output queue */
}
void
@@ -2130,15 +2209,51 @@ management_set_state (struct management *man,
#ifdef MANAGEMENT_DEF_AUTH
+static bool
+env_filter_match (const char *env_str, const int env_filter_level)
+{
+ static const char *env_names[] = {
+ "username=",
+ "password=",
+ "X509_0_CN=",
+ "tls_serial_0=",
+ "untrusted_ip=",
+ "ifconfig_local=",
+ "ifconfig_netmask=",
+ "daemon_start_time=",
+ "daemon_pid=",
+ "dev=",
+ "ifconfig_pool_remote_ip=",
+ "ifconfig_pool_netmask=",
+ "time_duration=",
+ "bytes_sent=",
+ "bytes_received="
+ };
+ if (env_filter_level >= 1)
+ {
+ size_t i;
+ for (i = 0; i < SIZE(env_names); ++i)
+ {
+ const char *en = env_names[i];
+ const size_t len = strlen(en);
+ if (strncmp(env_str, en, len) == 0)
+ return true;
+ }
+ return false;
+ }
+ else
+ return true;
+}
+
static void
-man_output_env (const struct env_set *es, const bool tail)
+man_output_env (const struct env_set *es, const bool tail, const int env_filter_level)
{
if (es)
{
struct env_item *e;
for (e = es->list; e != NULL; e = e->next)
{
- if (e->string)
+ if (e->string && (!env_filter_level || env_filter_match(e->string, env_filter_level)))
msg (M_CLIENT, ">CLIENT:ENV,%s", e->string);
}
}
@@ -2156,10 +2271,62 @@ man_output_extra_env (struct management *man)
const int nclients = (*man->persist.callback.n_clients) (man->persist.callback.arg);
setenv_int (es, "n_clients", nclients);
}
- man_output_env (es, false);
+ man_output_env (es, false, man->connection.env_filter_level);
gc_free (&gc);
}
+static bool
+validate_peer_info_line(const char *line)
+{
+ uint8_t c;
+ int state = 0;
+ while ((c=*line++))
+ {
+ switch (state)
+ {
+ case 0:
+ case 1:
+ if (c == '=' && state == 1)
+ state = 2;
+ else if (isalnum(c) || c == '_')
+ state = 1;
+ else
+ return false;
+ case 2:
+ if (isprint(c))
+ ;
+ else
+ return false;
+ }
+ }
+ return (state == 2);
+}
+
+static void
+man_output_peer_info_env (struct management *man, struct man_def_auth_context *mdac)
+{
+ char line[256];
+ if (man->persist.callback.get_peer_info)
+ {
+ const char *peer_info = (*man->persist.callback.get_peer_info) (man->persist.callback.arg, mdac->cid);
+ if (peer_info)
+ {
+ struct buffer buf;
+ buf_set_read (&buf, (const uint8_t *) peer_info, strlen(peer_info));
+ while (buf_parse (&buf, '\n', line, sizeof (line)))
+ {
+ chomp (line);
+ if (validate_peer_info_line(line))
+ {
+ msg (M_CLIENT, ">CLIENT:ENV,%s", line);
+ }
+ else
+ msg (D_MANAGEMENT, "validation failed on peer_info line received from client");
+ }
+ }
+ }
+}
+
void
management_notify_client_needing_auth (struct management *management,
const unsigned int mda_key_id,
@@ -2173,7 +2340,8 @@ management_notify_client_needing_auth (struct management *management,
mode = "REAUTH";
msg (M_CLIENT, ">CLIENT:%s,%lu,%u", mode, mdac->cid, mda_key_id);
man_output_extra_env (management);
- man_output_env (es, true);
+ man_output_peer_info_env(management, mdac);
+ man_output_env (es, true, management->connection.env_filter_level);
mdac->flags |= DAF_INITIAL_AUTH;
}
}
@@ -2186,7 +2354,7 @@ management_connection_established (struct management *management,
mdac->flags |= DAF_CONNECTION_ESTABLISHED;
msg (M_CLIENT, ">CLIENT:ESTABLISHED,%lu", mdac->cid);
man_output_extra_env (management);
- man_output_env (es, true);
+ man_output_env (es, true, management->connection.env_filter_level);
}
void
@@ -2197,7 +2365,7 @@ management_notify_client_close (struct management *management,
if ((mdac->flags & DAF_INITIAL_AUTH) && !(mdac->flags & DAF_CONNECTION_CLOSED))
{
msg (M_CLIENT, ">CLIENT:DISCONNECT,%lu", mdac->cid);
- man_output_env (es, true);
+ man_output_env (es, true, management->connection.env_filter_level);
mdac->flags |= DAF_CONNECTION_CLOSED;
}
}
@@ -2273,9 +2441,12 @@ management_pre_tunnel_close (struct management *man)
}
void
-management_auth_failure (struct management *man, const char *type)
+management_auth_failure (struct management *man, const char *type, const char *reason)
{
- msg (M_CLIENT, ">PASSWORD:Verification Failed: '%s'", type);
+ if (reason)
+ msg (M_CLIENT, ">PASSWORD:Verification Failed: '%s' ['%s']", type, reason);
+ else
+ msg (M_CLIENT, ">PASSWORD:Verification Failed: '%s'", type);
}
static inline bool
@@ -2346,7 +2517,7 @@ management_io (struct management *man)
net_event_win32_clear_selected_events (&man->connection.ne32, FD_ACCEPT);
}
}
- else if (man->connection.state == MS_CC_WAIT_READ)
+ else if (man->connection.state == MS_CC_WAIT_READ || man->connection.state == MS_CC_WAIT_WRITE)
{
if (net_events & FD_READ)
{
@@ -2354,18 +2525,13 @@ management_io (struct management *man)
;
net_event_win32_clear_selected_events (&man->connection.ne32, FD_READ);
}
- }
- if (man->connection.state == MS_CC_WAIT_WRITE)
- {
if (net_events & FD_WRITE)
{
int status;
- /* dmsg (M_INFO, "FD_WRITE set"); */
status = man_write (man);
if (status < 0 && WSAGetLastError() == WSAEWOULDBLOCK)
{
- /* dmsg (M_INFO, "FD_WRITE cleared"); */
net_event_win32_clear_selected_events (&man->connection.ne32, FD_WRITE);
}
}
@@ -2456,7 +2622,7 @@ man_block (struct management *man, volatile int *signal_received, const time_t e
if (man_standalone_ok (man))
{
- do
+ while (true)
{
event_reset (man->connection.es);
management_socket_set (man, man->connection.es, NULL, NULL);
@@ -2474,15 +2640,18 @@ man_block (struct management *man, volatile int *signal_received, const time_t e
status = -1;
break;
}
- /* set SIGINT signal if expiration time exceeded */
- if (expire && now >= expire)
+
+ if (status > 0)
+ break;
+ else if (expire && now >= expire)
{
+ /* set SIGINT signal if expiration time exceeded */
status = 0;
if (signal_received)
*signal_received = SIGINT;
break;
}
- } while (status != 1);
+ }
}
return status;
}
@@ -2559,28 +2728,29 @@ management_event_loop_n_seconds (struct management *man, int sec)
{
volatile int signal_received = 0;
const bool standalone_disabled_save = man->persist.standalone_disabled;
- time_t expire;
+ time_t expire = 0;
man->persist.standalone_disabled = false; /* This is so M_CLIENT messages will be correctly passed through msg() */
/* set expire time */
update_time ();
- expire = now + sec;
+ if (sec)
+ expire = now + sec;
/* if no client connection, wait for one */
man_wait_for_client_connection (man, &signal_received, expire, 0);
if (signal_received)
return;
- /* run command processing event loop until we get our username/password */
- while (true)
+ /* run command processing event loop */
+ do
{
man_standalone_event_loop (man, &signal_received, expire);
if (!signal_received)
man_check_for_signals (&signal_received);
if (signal_received)
return;
- }
+ } while (expire);
/* revert state */
man->persist.standalone_disabled = standalone_disabled_save;
@@ -2972,6 +3142,19 @@ log_history_ref (const struct log_history *h, const int index)
return NULL;
}
+#if HTTP_PROXY_FALLBACK
+
+void
+management_http_proxy_fallback_notify (struct management *man, const char *type, const char *remote_ip_hint)
+{
+ if (remote_ip_hint)
+ msg (M_CLIENT, ">PROXY:%s,%s", type, remote_ip_hint);
+ else
+ msg (M_CLIENT, ">PROXY:%s", type);
+}
+
+#endif /* HTTP_PROXY_FALLBACK */
+
#else
static void dummy(void) {}
#endif /* ENABLE_MANAGEMENT */
diff --git a/manage.h b/manage.h
index 6d6d710..6a9ccd8 100644
--- a/manage.h
+++ b/manage.h
@@ -5,7 +5,7 @@
* packet encryption, packet authentication, and
* packet compression.
*
- * Copyright (C) 2002-2009 OpenVPN Technologies, Inc. <sales@openvpn.net>
+ * Copyright (C) 2002-2010 OpenVPN Technologies, Inc. <sales@openvpn.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2
@@ -164,12 +164,16 @@ struct management_callback
const char *reason,
const char *client_reason,
struct buffer_list *cc_config); /* ownership transferred */
+ char *(*get_peer_info) (void *arg, const unsigned long cid);
#endif
#ifdef MANAGEMENT_PF
bool (*client_pf) (void *arg,
const unsigned long cid,
struct buffer_list *pf_config); /* ownership transferred */
#endif
+#if HTTP_PROXY_FALLBACK
+ bool (*http_proxy_fallback_cmd) (void *arg, const char *server, const char *port, const char *flags);
+#endif
};
/*
@@ -268,6 +272,7 @@ struct man_connection {
unsigned long in_extra_cid;
unsigned int in_extra_kid;
struct buffer_list *in_extra;
+ int env_filter_level;
#endif
struct event_set *es;
@@ -435,7 +440,7 @@ void management_echo (struct management *man, const char *string, const bool pul
* OpenVPN calls here to indicate a password failure
*/
-void management_auth_failure (struct management *man, const char *type);
+void management_auth_failure (struct management *man, const char *type, const char *reason);
/*
* These functions drive the bytecount in/out counters.
@@ -501,5 +506,11 @@ management_bytes_server (struct management *man,
#endif /* MANAGEMENT_DEF_AUTH */
+#if HTTP_PROXY_FALLBACK
+
+void management_http_proxy_fallback_notify (struct management *man, const char *type, const char *remote_ip_hint);
+
+#endif /* HTTP_PROXY_FALLBACK */
+
#endif
#endif
diff --git a/mbuf.c b/mbuf.c
index cb83ac7..0f36d3c 100644
--- a/mbuf.c
+++ b/mbuf.c
@@ -5,7 +5,7 @@
* packet encryption, packet authentication, and
* packet compression.
*
- * Copyright (C) 2002-2009 OpenVPN Technologies, Inc. <sales@openvpn.net>
+ * Copyright (C) 2002-2010 OpenVPN Technologies, Inc. <sales@openvpn.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2
diff --git a/mbuf.h b/mbuf.h
index 230b5b5..a0de679 100644
--- a/mbuf.h
+++ b/mbuf.h
@@ -5,7 +5,7 @@
* packet encryption, packet authentication, and
* packet compression.
*
- * Copyright (C) 2002-2009 OpenVPN Technologies, Inc. <sales@openvpn.net>
+ * Copyright (C) 2002-2010 OpenVPN Technologies, Inc. <sales@openvpn.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2
diff --git a/memcmp.c b/memcmp.c
index fc39d1c..d921aac 100644
--- a/memcmp.c
+++ b/memcmp.c
@@ -5,7 +5,7 @@
* packet encryption, packet authentication, and
* packet compression.
*
- * Copyright (C) 2002-2009 OpenVPN Technologies, Inc. <sales@openvpn.net>
+ * Copyright (C) 2002-2010 OpenVPN Technologies, Inc. <sales@openvpn.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2
diff --git a/memdbg.h b/memdbg.h
index a9ff959..1f6bb67 100644
--- a/memdbg.h
+++ b/memdbg.h
@@ -5,7 +5,7 @@
* packet encryption, packet authentication, and
* packet compression.
*
- * Copyright (C) 2002-2009 OpenVPN Technologies, Inc. <sales@openvpn.net>
+ * Copyright (C) 2002-2010 OpenVPN Technologies, Inc. <sales@openvpn.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2
diff --git a/misc.c b/misc.c
index 815c057..4067d85 100644
--- a/misc.c
+++ b/misc.c
@@ -5,7 +5,7 @@
* packet encryption, packet authentication, and
* packet compression.
*
- * Copyright (C) 2002-2009 OpenVPN Technologies, Inc. <sales@openvpn.net>
+ * Copyright (C) 2002-2010 OpenVPN Technologies, Inc. <sales@openvpn.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2
@@ -26,6 +26,7 @@
#include "buffer.h"
#include "misc.h"
+#include "base64.h"
#include "tun.h"
#include "error.h"
#include "otime.h"
@@ -154,9 +155,8 @@ set_nice (int niceval)
{
#ifdef HAVE_NICE
errno = 0;
- nice (niceval);
- if (errno != 0)
- msg (M_WARN | M_ERRNO, "WARNING: nice %d failed", niceval);
+ if (nice (niceval) < 0 && errno != 0)
+ msg (M_WARN | M_ERRNO, "WARNING: nice %d failed: %s", niceval, strerror(errno));
else
msg (M_INFO, "nice %d succeeded", niceval);
#else
@@ -1147,23 +1147,55 @@ test_file (const char *filename)
/* create a temporary filename in directory */
const char *
-create_temp_filename (const char *directory, const char *prefix, struct gc_arena *gc)
+create_temp_file (const char *directory, const char *prefix, struct gc_arena *gc)
{
static unsigned int counter;
struct buffer fname = alloc_buf_gc (256, gc);
+ int fd;
+ const char *retfname = NULL;
+ unsigned int attempts = 0;
- ++counter;
-
- {
- uint8_t rndbytes[16];
- const char *rndstr;
-
- prng_bytes (rndbytes, sizeof (rndbytes));
- rndstr = format_hex_ex (rndbytes, sizeof (rndbytes), 40, 0, NULL, gc);
- buf_printf (&fname, PACKAGE "_%s_%s.tmp", prefix, rndstr);
- }
+ do
+ {
+ uint8_t rndbytes[16];
+ const char *rndstr;
+
+ ++attempts;
+ ++counter;
+
+ prng_bytes (rndbytes, sizeof rndbytes);
+ rndstr = format_hex_ex (rndbytes, sizeof rndbytes, 40, 0, NULL, gc);
+ buf_printf (&fname, PACKAGE "_%s_%s.tmp", prefix, rndstr);
+
+ retfname = gen_path (directory, BSTR (&fname), gc);
+ if (!retfname)
+ {
+ msg (M_FATAL, "Failed to create temporary filename and path");
+ return NULL;
+ }
+
+ /* Atomically create the file. Errors out if the file already
+ exists. */
+ fd = open (retfname, O_CREAT | O_EXCL | O_WRONLY, S_IRUSR | S_IWUSR);
+ if (fd != -1)
+ {
+ close (fd);
+ return retfname;
+ }
+ else if (fd == -1 && errno != EEXIST)
+ {
+ /* Something else went wrong, no need to retry. */
+ struct gc_arena gcerr = gc_new ();
+ msg (M_FATAL, "Could not create temporary file '%s': %s",
+ retfname, strerror_ts (errno, &gcerr));
+ gc_free (&gcerr);
+ return NULL;
+ }
+ }
+ while (attempts < 6);
- return gen_path (directory, BSTR (&fname), gc);
+ msg (M_FATAL, "Failed to create temporary file after %i attempts", attempts);
+ return NULL;
}
/*
@@ -1174,7 +1206,7 @@ create_temp_filename (const char *directory, const char *prefix, struct gc_arena
const char *
hostname_randomize(const char *hostname, struct gc_arena *gc)
{
- const int n_rnd_bytes = 6;
+# define n_rnd_bytes 6
char *hst = string_alloc(hostname, gc);
char *dot = strchr(hst, '.');
@@ -1193,6 +1225,7 @@ hostname_randomize(const char *hostname, struct gc_arena *gc)
}
else
return hostname;
+# undef n_rnd_bytes
}
#else
@@ -1342,10 +1375,11 @@ get_console_input (const char *prompt, const bool echo, char *input, const int c
*/
bool
-get_user_pass (struct user_pass *up,
- const char *auth_file,
- const char *prefix,
- const unsigned int flags)
+get_user_pass_cr (struct user_pass *up,
+ const char *auth_file,
+ const char *prefix,
+ const unsigned int flags,
+ const char *auth_challenge)
{
struct gc_arena gc = gc_new ();
@@ -1353,14 +1387,20 @@ get_user_pass (struct user_pass *up,
{
const bool from_stdin = (!auth_file || !strcmp (auth_file, "stdin"));
+ if (flags & GET_USER_PASS_PREVIOUS_CREDS_FAILED)
+ msg (M_WARN, "Note: previous '%s' credentials failed", prefix);
+
#ifdef ENABLE_MANAGEMENT
/*
- * Get username/password from standard input?
+ * Get username/password from management interface?
*/
if (management
&& ((auth_file && streq (auth_file, "management")) || (from_stdin && (flags & GET_USER_PASS_MANAGEMENT)))
&& management_query_user_pass_enabled (management))
{
+ if (flags & GET_USER_PASS_PREVIOUS_CREDS_FAILED)
+ management_auth_failure (management, prefix, "previous auth credentials failed");
+
if (!management_query_user_pass (management, up, prefix, flags))
{
if ((flags & GET_USER_PASS_NOFATAL) != 0)
@@ -1392,22 +1432,47 @@ get_user_pass (struct user_pass *up,
*/
else if (from_stdin)
{
- struct buffer user_prompt = alloc_buf_gc (128, &gc);
- struct buffer pass_prompt = alloc_buf_gc (128, &gc);
-
- buf_printf (&user_prompt, "Enter %s Username:", prefix);
- buf_printf (&pass_prompt, "Enter %s Password:", prefix);
-
- if (!(flags & GET_USER_PASS_PASSWORD_ONLY))
+#ifdef ENABLE_CLIENT_CR
+ if (auth_challenge)
{
- if (!get_console_input (BSTR (&user_prompt), true, up->username, USER_PASS_LEN))
- msg (M_FATAL, "ERROR: could not read %s username from stdin", prefix);
- if (strlen (up->username) == 0)
- msg (M_FATAL, "ERROR: %s username is empty", prefix);
+ struct auth_challenge_info *ac = get_auth_challenge (auth_challenge, &gc);
+ if (ac)
+ {
+ char *response = (char *) gc_malloc (USER_PASS_LEN, false, &gc);
+ struct buffer packed_resp;
+
+ buf_set_write (&packed_resp, (uint8_t*)up->password, USER_PASS_LEN);
+ msg (M_INFO, "CHALLENGE: %s", ac->challenge_text);
+ if (!get_console_input ("Response:", BOOL_CAST(ac->flags&CR_ECHO), response, USER_PASS_LEN))
+ msg (M_FATAL, "ERROR: could not read challenge response from stdin");
+ strncpynt (up->username, ac->user, USER_PASS_LEN);
+ buf_printf (&packed_resp, "CRV1::%s::%s", ac->state_id, response);
+ }
+ else
+ {
+ msg (M_FATAL, "ERROR: received malformed challenge request from server");
+ }
}
+ else
+#endif
+ {
+ struct buffer user_prompt = alloc_buf_gc (128, &gc);
+ struct buffer pass_prompt = alloc_buf_gc (128, &gc);
+
+ buf_printf (&user_prompt, "Enter %s Username:", prefix);
+ buf_printf (&pass_prompt, "Enter %s Password:", prefix);
- if (!get_console_input (BSTR (&pass_prompt), false, up->password, USER_PASS_LEN))
- msg (M_FATAL, "ERROR: could not not read %s password from stdin", prefix);
+ if (!(flags & GET_USER_PASS_PASSWORD_ONLY))
+ {
+ if (!get_console_input (BSTR (&user_prompt), true, up->username, USER_PASS_LEN))
+ msg (M_FATAL, "ERROR: could not read %s username from stdin", prefix);
+ if (strlen (up->username) == 0)
+ msg (M_FATAL, "ERROR: %s username is empty", prefix);
+ }
+
+ if (!get_console_input (BSTR (&pass_prompt), false, up->password, USER_PASS_LEN))
+ msg (M_FATAL, "ERROR: could not not read %s password from stdin", prefix);
+ }
}
else
{
@@ -1471,6 +1536,101 @@ get_user_pass (struct user_pass *up,
return true;
}
+#ifdef ENABLE_CLIENT_CR
+
+/*
+ * Parse a challenge message returned along with AUTH_FAILED.
+ * The message is formatted as such:
+ *
+ * CRV1:<flags>:<state_id>:<username_base64>:<challenge_text>
+ *
+ * flags: a series of optional, comma-separated flags:
+ * E : echo the response when the user types it
+ * R : a response is required
+ *
+ * state_id: an opaque string that should be returned to the server
+ * along with the response.
+ *
+ * username_base64 : the username formatted as base64
+ *
+ * challenge_text : the challenge text to be shown to the user
+ *
+ * Example challenge:
+ *
+ * CRV1:R,E:Om01u7Fh4LrGBS7uh0SWmzwabUiGiW6l:Y3Ix:Please enter token PIN
+ *
+ * After showing the challenge_text and getting a response from the user
+ * (if R flag is specified), the client should submit the following
+ * auth creds back to the OpenVPN server:
+ *
+ * Username: [username decoded from username_base64]
+ * Password: CRV1::<state_id>::<response_text>
+ *
+ * Where state_id is taken from the challenge request and response_text
+ * is what the user entered in response to the challenge_text.
+ * If the R flag is not present, response_text may be the empty
+ * string.
+ *
+ * Example response (suppose the user enters "8675309" for the token PIN):
+ *
+ * Username: cr1 ("Y3Ix" base64 decoded)
+ * Password: CRV1::Om01u7Fh4LrGBS7uh0SWmzwabUiGiW6l::8675309
+ */
+struct auth_challenge_info *
+get_auth_challenge (const char *auth_challenge, struct gc_arena *gc)
+{
+ if (auth_challenge)
+ {
+ struct auth_challenge_info *ac;
+ const int len = strlen (auth_challenge);
+ char *work = (char *) gc_malloc (len+1, false, gc);
+ char *cp;
+
+ struct buffer b;
+ buf_set_read (&b, (const uint8_t *)auth_challenge, len);
+
+ ALLOC_OBJ_CLEAR_GC (ac, struct auth_challenge_info, gc);
+
+ /* parse prefix */
+ if (!buf_parse(&b, ':', work, len))
+ return NULL;
+ if (strcmp(work, "CRV1"))
+ return NULL;
+
+ /* parse flags */
+ if (!buf_parse(&b, ':', work, len))
+ return NULL;
+ for (cp = work; *cp != '\0'; ++cp)
+ {
+ const char c = *cp;
+ if (c == 'E')
+ ac->flags |= CR_ECHO;
+ else if (c == 'R')
+ ac->flags |= CR_RESPONSE;
+ }
+
+ /* parse state ID */
+ if (!buf_parse(&b, ':', work, len))
+ return NULL;
+ ac->state_id = string_alloc(work, gc);
+
+ /* parse user name */
+ if (!buf_parse(&b, ':', work, len))
+ return NULL;
+ ac->user = (char *) gc_malloc (strlen(work)+1, true, gc);
+ base64_decode(work, (void*)ac->user);
+
+ /* parse challenge text */
+ ac->challenge_text = string_alloc(BSTR(&b), gc);
+
+ return ac;
+ }
+ else
+ return NULL;
+}
+
+#endif
+
#if AUTO_USERID
static const char *
@@ -1535,14 +1695,16 @@ void
purge_user_pass (struct user_pass *up, const bool force)
{
const bool nocache = up->nocache;
+ static bool warn_shown = false;
if (nocache || force)
{
CLEAR (*up);
up->nocache = nocache;
}
- else
+ else if (!warn_shown)
{
msg (M_WARN, "WARNING: this configuration may cache passwords in memory -- use the auth-nocache option to prevent this");
+ warn_shown = true;
}
}
diff --git a/misc.h b/misc.h
index 4695d3e..3f22ca0 100644
--- a/misc.h
+++ b/misc.h
@@ -5,7 +5,7 @@
* packet encryption, packet authentication, and
* packet compression.
*
- * Copyright (C) 2002-2009 OpenVPN Technologies, Inc. <sales@openvpn.net>
+ * Copyright (C) 2002-2010 OpenVPN Technologies, Inc. <sales@openvpn.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2
@@ -227,8 +227,8 @@ long int get_random(void);
/* return true if filename can be opened for read */
bool test_file (const char *filename);
-/* create a temporary filename in directory */
-const char *create_temp_filename (const char *directory, const char *prefix, struct gc_arena *gc);
+/* create a temporary file in directory, returns the filename of the created file */
+const char *create_temp_file (const char *directory, const char *prefix, struct gc_arena *gc);
/* put a directory and filename together */
const char *gen_path (const char *directory, const char *filename, struct gc_arena *gc);
@@ -261,6 +261,26 @@ struct user_pass
char password[USER_PASS_LEN];
};
+#ifdef ENABLE_CLIENT_CR
+/*
+ * Challenge response info on client as pushed by server.
+ */
+struct auth_challenge_info {
+# define CR_ECHO (1<<0) /* echo response when typed by user */
+# define CR_RESPONSE (1<<1) /* response needed */
+ unsigned int flags;
+
+ const char *user;
+ const char *state_id;
+ const char *challenge_text;
+};
+
+struct auth_challenge_info *get_auth_challenge (const char *auth_challenge, struct gc_arena *gc);
+
+#else
+struct auth_challenge_info {};
+#endif
+
bool get_console_input (const char *prompt, const bool echo, char *input, const int capacity);
/*
@@ -272,11 +292,26 @@ bool get_console_input (const char *prompt, const bool echo, char *input, const
#define GET_USER_PASS_NEED_OK (1<<3)
#define GET_USER_PASS_NOFATAL (1<<4)
#define GET_USER_PASS_NEED_STR (1<<5)
+#define GET_USER_PASS_PREVIOUS_CREDS_FAILED (1<<6)
+
+bool get_user_pass_cr (struct user_pass *up,
+ const char *auth_file,
+ const char *prefix,
+ const unsigned int flags,
+ const char *auth_challenge);
+
+static inline bool
+get_user_pass (struct user_pass *up,
+ const char *auth_file,
+ const char *prefix,
+ const unsigned int flags)
+{
+ return get_user_pass_cr (up, auth_file, prefix, flags, NULL);
+}
-bool get_user_pass (struct user_pass *up,
- const char *auth_file,
- const char *prefix,
- const unsigned int flags);
+void fail_user_pass (const char *prefix,
+ const unsigned int flags,
+ const char *reason);
void purge_user_pass (struct user_pass *up, const bool force);
diff --git a/mroute.c b/mroute.c
index f068e06..3debd80 100644
--- a/mroute.c
+++ b/mroute.c
@@ -5,7 +5,7 @@
* packet encryption, packet authentication, and
* packet compression.
*
- * Copyright (C) 2002-2009 OpenVPN Technologies, Inc. <sales@openvpn.net>
+ * Copyright (C) 2002-2010 OpenVPN Technologies, Inc. <sales@openvpn.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2
diff --git a/mroute.h b/mroute.h
index 283d4c2..7265001 100644
--- a/mroute.h
+++ b/mroute.h
@@ -5,7 +5,7 @@
* packet encryption, packet authentication, and
* packet compression.
*
- * Copyright (C) 2002-2009 OpenVPN Technologies, Inc. <sales@openvpn.net>
+ * Copyright (C) 2002-2010 OpenVPN Technologies, Inc. <sales@openvpn.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2
diff --git a/mss.c b/mss.c
index 900c781..660b62c 100644
--- a/mss.c
+++ b/mss.c
@@ -5,7 +5,7 @@
* packet encryption, packet authentication, and
* packet compression.
*
- * Copyright (C) 2002-2009 OpenVPN Technologies, Inc. <sales@openvpn.net>
+ * Copyright (C) 2002-2010 OpenVPN Technologies, Inc. <sales@openvpn.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2
diff --git a/mss.h b/mss.h
index 3604929..0b290c3 100644
--- a/mss.h
+++ b/mss.h
@@ -5,7 +5,7 @@
* packet encryption, packet authentication, and
* packet compression.
*
- * Copyright (C) 2002-2009 OpenVPN Technologies, Inc. <sales@openvpn.net>
+ * Copyright (C) 2002-2010 OpenVPN Technologies, Inc. <sales@openvpn.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2
diff --git a/msvc/autodefs.h.in b/msvc/autodefs.h.in
new file mode 100644
index 0000000..9814022
--- /dev/null
+++ b/msvc/autodefs.h.in
@@ -0,0 +1,20 @@
+/*
+ * Minimum TAP-Win32 version number expected by userspace
+ *
+ * The TAP-Win32 version number is defined in tap-win32/SOURCES
+ */
+#define TAP_ID "@PRODUCT_TAP_ID@"
+#define TAP_WIN32_MIN_MAJOR @PRODUCT_TAP_WIN32_MIN_MAJOR@
+#define TAP_WIN32_MIN_MINOR @PRODUCT_TAP_WIN32_MIN_MINOR@
+
+/* Name of package */
+#define PACKAGE "@PRODUCT_UNIX_NAME@"
+
+/* Define to the full name of this package. */
+#define PACKAGE_NAME "@PRODUCT_NAME@"
+
+/* Define to the one symbol short name of this package. */
+#define PACKAGE_TARNAME "@PRODUCT_UNIX_NAME@"
+
+/* Define to the version of this package. */
+#define PACKAGE_VERSION "@PRODUCT_VERSION@"
diff --git a/msvc/config.py b/msvc/config.py
new file mode 100644
index 0000000..04ea4c5
--- /dev/null
+++ b/msvc/config.py
@@ -0,0 +1,93 @@
+# build autodefs.h and
+
+import re
+
+autogen = "Automatically generated by config.py"
+
+def parse_version_m4(kv, version_m4):
+ r = re.compile(r'^define\((\w+),\[(.*)\]\)$')
+ f = open(version_m4)
+ for line in f:
+ line = line.rstrip()
+ m = re.match(r, line)
+ if m:
+ g = m.groups()
+ kv[g[0]] = g[1]
+ f.close()
+
+def parse_settings_in(kv, settings_in):
+ r = re.compile(r'^!define\s+(\w+)(?:\s+"?(.*?)"?)$')
+ f = open(settings_in)
+ for line in f:
+ line = line.rstrip()
+ m = re.match(r, line)
+ if m:
+ g = m.groups()
+ kv[g[0]] = g[1] or ''
+ f.close()
+
+def build_autodefs(kv, autodefs_in, autodefs_out):
+ def repfn(m):
+ var, = m.groups()
+ return kv.get(var, '')
+
+ r = re.compile(r'@(\w+)@')
+ fin = open(autodefs_in)
+ fout = open(autodefs_out, 'w')
+ fout.write("/* %s */\n\n" % autogen)
+ for line in fin:
+ newline = re.sub(r, repfn, line)
+ fout.write(newline)
+ fin.close()
+ fout.close()
+
+def print_key_values(kv):
+ for k, v in sorted(kv.items()):
+ print "%s%s%s" % (k, ' '*(32-len(k)), repr(v))
+
+def get_sources(makefile_am):
+ c = set()
+ h = set()
+ f = open(makefile_am)
+ state = False
+ for line in f:
+ line = line.rstrip()
+ if line == 'openvpn_SOURCES = \\':
+ state = True
+ elif not line:
+ state = False
+ elif state:
+ for sf in line.split():
+ if sf.endswith('.c'):
+ c.add(sf[:-2])
+ elif sf.endswith('.h'):
+ h.add(sf[:-2])
+ elif sf == '\\':
+ pass
+ else:
+ print >>sys.stderr, "Unrecognized filename:", sf
+ f.close()
+ return [ sorted(list(s)) for s in (c, h) ]
+
+def output_mak_list(out, title, srclist, ext):
+ out.write("%s =" % (title,))
+ for x in srclist:
+ out.write(" \\\n\t%s.%s" % (x, ext))
+ out.write('\n\n')
+
+def output_mak(makefile_am, outfile):
+ c, h = get_sources(makefile_am)
+ out = open(outfile, 'w')
+ out.write("# %s\n\n" % autogen)
+ output_mak_list(out, 'HEADERS', h, 'h')
+ output_mak_list(out, 'OBJS', c, 'obj')
+ out.close()
+
+def main():
+ kv = {}
+ parse_version_m4(kv, 'version.m4')
+ parse_settings_in(kv, 'install-win32/settings.in')
+ build_autodefs(kv, 'msvc/autodefs.h.in', 'autodefs.h')
+ output_mak('Makefile.am', 'head_obj.mak')
+
+main()
diff --git a/msvc/msvc.mak b/msvc/msvc.mak
new file mode 100644
index 0000000..bca779f
--- /dev/null
+++ b/msvc/msvc.mak
@@ -0,0 +1,52 @@
+# This makefile builds the user-mode component
+# of OpenVPN for Windows in the Visual Studio 2008 environment.
+
+# To build:
+# python msvc\config.py
+# nmake /f msvc\msvc.mak
+
+# Each of the OPENSSL and LZO dirs should have 'lib' and 'include'
+# directories under them.
+
+OPENSSL = \src\openssl
+OPENSSL_DYNAMIC = libeay32.lib ssleay32.lib
+
+LZO = \src\lzo
+LZO_DYNAMIC = lzo2.lib
+
+INCLUDE_DIRS = -I$(OPENSSL)/include -I$(LZO)/include
+
+LIBS = $(OPENSSL_DYNAMIC) $(LZO_DYNAMIC) ws2_32.lib crypt32.lib iphlpapi.lib winmm.lib user32.lib gdi32.lib advapi32.lib wininet.lib
+
+LIB_DIRS = -LIBPATH:$(OPENSSL)\lib -LIBPATH:$(LZO)\lib
+
+EXE = openvpn.exe
+
+CPP=cl.exe
+CPP_ARG_COMMON=/nologo /W3 /O2 -DWIN32 -DWIN32_LEAN_AND_MEAN -D_CONSOLE -D_MBCS -D_CRT_SECURE_NO_DEPRECATE $(INCLUDE_DIRS) /FD /c
+# release:
+CPP_PROJ=$(CPP_ARG_COMMON) /MD -DNDEBUG
+# debug:
+#CPP_PROJ=$(CPP_ARG_COMMON) /MDd /Zi /Od -D_DEBUG
+
+LINK32=link.exe
+# release:
+LINK32_FLAGS=/nologo /subsystem:console /incremental:no /out:"$(EXE)"
+# debug:
+#LINK32_FLAGS=/nologo /subsystem:console /incremental:no /debug /out:"$(EXE)"
+
+# HEADERS and OBJS definitions, automatically generated
+!INCLUDE head_obj.mak
+
+openvpn : $(OBJS)
+ $(LINK32) @<<
+ $(LINK32_FLAGS) $(LIB_DIRS) $(LIBS) $(OBJS)
+<<
+
+clean :
+ del /Q $(OBJS) $(EXE) *.idb *.pdb
+
+.c.obj::
+ $(CPP) @<<
+ $(CPP_PROJ) $<
+<<
diff --git a/mtcp.c b/mtcp.c
index 3d68a9c..314aa44 100644
--- a/mtcp.c
+++ b/mtcp.c
@@ -5,7 +5,7 @@
* packet encryption, packet authentication, and
* packet compression.
*
- * Copyright (C) 2002-2009 OpenVPN Technologies, Inc. <sales@openvpn.net>
+ * Copyright (C) 2002-2010 OpenVPN Technologies, Inc. <sales@openvpn.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2
diff --git a/mtcp.h b/mtcp.h
index 5704171..3585af4 100644
--- a/mtcp.h
+++ b/mtcp.h
@@ -5,7 +5,7 @@
* packet encryption, packet authentication, and
* packet compression.
*
- * Copyright (C) 2002-2009 OpenVPN Technologies, Inc. <sales@openvpn.net>
+ * Copyright (C) 2002-2010 OpenVPN Technologies, Inc. <sales@openvpn.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2
diff --git a/mtu.c b/mtu.c
index 91c55d8..494f939 100644
--- a/mtu.c
+++ b/mtu.c
@@ -5,7 +5,7 @@
* packet encryption, packet authentication, and
* packet compression.
*
- * Copyright (C) 2002-2009 OpenVPN Technologies, Inc. <sales@openvpn.net>
+ * Copyright (C) 2002-2010 OpenVPN Technologies, Inc. <sales@openvpn.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2
diff --git a/mtu.h b/mtu.h
index 6079bf8..d9fa020 100644
--- a/mtu.h
+++ b/mtu.h
@@ -5,7 +5,7 @@
* packet encryption, packet authentication, and
* packet compression.
*
- * Copyright (C) 2002-2009 OpenVPN Technologies, Inc. <sales@openvpn.net>
+ * Copyright (C) 2002-2010 OpenVPN Technologies, Inc. <sales@openvpn.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2
diff --git a/mudp.c b/mudp.c
index 77468b2..a478b29 100644
--- a/mudp.c
+++ b/mudp.c
@@ -5,7 +5,7 @@
* packet encryption, packet authentication, and
* packet compression.
*
- * Copyright (C) 2002-2009 OpenVPN Technologies, Inc. <sales@openvpn.net>
+ * Copyright (C) 2002-2010 OpenVPN Technologies, Inc. <sales@openvpn.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2
diff --git a/mudp.h b/mudp.h
index 8525961..dc9cfde 100644
--- a/mudp.h
+++ b/mudp.h
@@ -5,7 +5,7 @@
* packet encryption, packet authentication, and
* packet compression.
*
- * Copyright (C) 2002-2009 OpenVPN Technologies, Inc. <sales@openvpn.net>
+ * Copyright (C) 2002-2010 OpenVPN Technologies, Inc. <sales@openvpn.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2
diff --git a/multi.c b/multi.c
index 4cd7468..22c0a3f 100644
--- a/multi.c
+++ b/multi.c
@@ -5,7 +5,7 @@
* packet encryption, packet authentication, and
* packet compression.
*
- * Copyright (C) 2002-2009 OpenVPN Technologies, Inc. <sales@openvpn.net>
+ * Copyright (C) 2002-2010 OpenVPN Technologies, Inc. <sales@openvpn.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2
@@ -720,7 +720,7 @@ multi_print_status (struct multi_context *m, struct status_output *so, const int
/*
* Status file version 1
*/
- status_printf (so, PACKAGE_NAME " CLIENT LIST");
+ status_printf (so, "OpenVPN CLIENT LIST");
status_printf (so, "Updated,%s", time_string (0, 0, false, &gc_top));
status_printf (so, "Common Name,Real Address,Bytes Received,Bytes Sent,Connected Since");
hash_iterator_init (m->hash, &hi);
@@ -1522,9 +1522,14 @@ multi_connection_established (struct multi_context *m, struct multi_instance *mi
if (plugin_defined (mi->context.plugins, OPENVPN_PLUGIN_CLIENT_CONNECT))
{
struct argv argv = argv_new ();
- const char *dc_file = create_temp_filename (mi->context.options.tmp_dir, "cc", &gc);
+ const char *dc_file = create_temp_file (mi->context.options.tmp_dir, "cc", &gc);
+
+ if( !dc_file ) {
+ cc_succeeded = false;
+ goto script_depr_failed;
+ }
+
argv_printf (&argv, "%s", dc_file);
- delete_file (dc_file);
if (plugin_call (mi->context.plugins, OPENVPN_PLUGIN_CLIENT_CONNECT, &argv, NULL, mi->context.c2.es) != OPENVPN_PLUGIN_FUNC_SUCCESS)
{
msg (M_WARN, "WARNING: client-connect plugin call failed");
@@ -1535,6 +1540,7 @@ multi_connection_established (struct multi_context *m, struct multi_instance *mi
multi_client_connect_post (m, mi, dc_file, option_permissions_mask, &option_types_found);
++cc_succeeded_count;
}
+ script_depr_failed:
argv_reset (&argv);
}
@@ -1570,9 +1576,11 @@ multi_connection_established (struct multi_context *m, struct multi_instance *mi
setenv_str (mi->context.c2.es, "script_type", "client-connect");
- dc_file = create_temp_filename (mi->context.options.tmp_dir, "cc", &gc);
-
- delete_file (dc_file);
+ dc_file = create_temp_file (mi->context.options.tmp_dir, "cc", &gc);
+ if( !dc_file ) {
+ cc_succeeded = false;
+ goto script_failed;
+ }
argv_printf (&argv, "%sc %s",
mi->context.options.client_connect_script,
@@ -1585,7 +1593,7 @@ multi_connection_established (struct multi_context *m, struct multi_instance *mi
}
else
cc_succeeded = false;
-
+ script_failed:
argv_reset (&argv);
}
@@ -2589,6 +2597,20 @@ management_client_auth (void *arg,
buffer_list_free (cc_config);
return ret;
}
+
+static char *
+management_get_peer_info (void *arg, const unsigned long cid)
+{
+ struct multi_context *m = (struct multi_context *) arg;
+ struct multi_instance *mi = lookup_by_cid (m, cid);
+ char *ret = NULL;
+
+ if (mi)
+ ret = tls_get_peer_info (mi->context.c2.tls_multi);
+
+ return ret;
+}
+
#endif
#ifdef MANAGEMENT_PF
@@ -2629,6 +2651,7 @@ init_management_callback_multi (struct multi_context *m)
#ifdef MANAGEMENT_DEF_AUTH
cb.kill_by_cid = management_kill_by_cid;
cb.client_auth = management_client_auth;
+ cb.get_peer_info = management_get_peer_info;
#endif
#ifdef MANAGEMENT_PF
cb.client_pf = management_client_pf;
diff --git a/multi.h b/multi.h
index 585d0d5..08964a2 100644
--- a/multi.h
+++ b/multi.h
@@ -5,7 +5,7 @@
* packet encryption, packet authentication, and
* packet compression.
*
- * Copyright (C) 2002-2009 OpenVPN Technologies, Inc. <sales@openvpn.net>
+ * Copyright (C) 2002-2010 OpenVPN Technologies, Inc. <sales@openvpn.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2
diff --git a/occ-inline.h b/occ-inline.h
index ff4dfdf..516eb4d 100644
--- a/occ-inline.h
+++ b/occ-inline.h
@@ -5,7 +5,7 @@
* packet encryption, packet authentication, and
* packet compression.
*
- * Copyright (C) 2002-2009 OpenVPN Technologies, Inc. <sales@openvpn.net>
+ * Copyright (C) 2002-2010 OpenVPN Technologies, Inc. <sales@openvpn.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2
diff --git a/occ.c b/occ.c
index 468067b..b84b18d 100644
--- a/occ.c
+++ b/occ.c
@@ -5,7 +5,7 @@
* packet encryption, packet authentication, and
* packet compression.
*
- * Copyright (C) 2002-2009 OpenVPN Technologies, Inc. <sales@openvpn.net>
+ * Copyright (C) 2002-2010 OpenVPN Technologies, Inc. <sales@openvpn.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2
diff --git a/occ.h b/occ.h
index 4b47b03..5d88cc9 100644
--- a/occ.h
+++ b/occ.h
@@ -5,7 +5,7 @@
* packet encryption, packet authentication, and
* packet compression.
*
- * Copyright (C) 2002-2009 OpenVPN Technologies, Inc. <sales@openvpn.net>
+ * Copyright (C) 2002-2010 OpenVPN Technologies, Inc. <sales@openvpn.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2
diff --git a/openvpn-plugin.h b/openvpn-plugin.h
index ac683f2..173a0c1 100644
--- a/openvpn-plugin.h
+++ b/openvpn-plugin.h
@@ -5,7 +5,7 @@
* packet encryption, packet authentication, and
* packet compression.
*
- * Copyright (C) 2002-2009 OpenVPN Technologies, Inc. <sales@openvpn.net>
+ * Copyright (C) 2002-2010 OpenVPN Technologies, Inc. <sales@openvpn.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2
@@ -41,6 +41,7 @@
* New Client Connection:
*
* FUNC: openvpn_plugin_client_constructor_v1
+ * FUNC: openvpn_plugin_func_v1 OPENVPN_PLUGIN_ENABLE_PF
* FUNC: openvpn_plugin_func_v1 OPENVPN_PLUGIN_TLS_VERIFY (called once for every cert
* in the server chain)
* FUNC: openvpn_plugin_func_v1 OPENVPN_PLUGIN_AUTH_USER_PASS_VERIFY
@@ -72,7 +73,7 @@
* [Client session continues]
*
* FUNC: openvpn_plugin_func_v1 OPENVPN_PLUGIN_CLIENT_DISCONNECT
- * FUNC: openvpn_plugin_client_constructor_v1
+ * FUNC: openvpn_plugin_client_destructor_v1
*
* [ some time may pass ]
*
diff --git a/openvpn.8 b/openvpn.8
index 17549d8..298c79a 100644
--- a/openvpn.8
+++ b/openvpn.8
@@ -4,7 +4,7 @@
.\" packet encryption, packet authentication, and
.\" packet compression.
.\"
-.\" Copyright (C) 2002-2009 OpenVPN Technologies, Inc. <sales@openvpn.net>
+.\" Copyright (C) 2002-2010 OpenVPN Technologies, Inc. <sales@openvpn.net>
.\"
.\" This program is free software; you can redistribute it and/or modify
.\" it under the terms of the GNU General Public License version 2
@@ -97,25 +97,25 @@ with a relatively lightweight footprint.
.SH OPTIONS
OpenVPN allows any option to be placed either on the command line
or in a configuration file. Though all command line options are preceded
-by a double-leading-dash ("--"), this prefix can be removed when
+by a double-leading-dash ("\-\-"), this prefix can be removed when
an option is placed in a configuration file.
.\"*********************************************************
.TP
-.B --help
+.B \-\-help
Show options.
.\"*********************************************************
.TP
-.B --config file
+.B \-\-config file
Load additional config options from
.B file
where each line corresponds to one command line option,
-but with the leading '--' removed.
+but with the leading '\-\-' removed.
If
-.B --config file
+.B \-\-config file
is the only option to the openvpn command,
the
-.B --config
+.B \-\-config
can be removed, and the command can be given as
.B openvpn file
@@ -187,25 +187,25 @@ secret static.key
.\"*********************************************************
.SS Tunnel Options:
.TP
-.B --mode m
+.B \-\-mode m
Set OpenVPN major mode. By default, OpenVPN runs in
point-to-point mode ("p2p"). OpenVPN 2.0 introduces
a new mode ("server") which implements a multi-client
server capability.
.\"*********************************************************
.TP
-.B --local host
+.B \-\-local host
Local host name or IP address for bind.
If specified, OpenVPN will bind to this address only.
If unspecified, OpenVPN will bind to all interfaces.
.\"*********************************************************
.TP
-.B --remote host [port] [proto]
+.B \-\-remote host [port] [proto]
Remote host name or IP address. On the client, multiple
-.B --remote
+.B \-\-remote
options may be specified for redundancy, each referring
to a different OpenVPN server. Specifying multiple
-.B --remote
+.B \-\-remote
options for this purpose is a special case of the more
general connection-profile feature. See the
.B <connection>
@@ -214,7 +214,7 @@ documentation below.
The OpenVPN client will try to connect to a server at
.B host:port
in the order specified by the list of
-.B --remote
+.B \-\-remote
options.
.B proto
@@ -229,18 +229,18 @@ one server.
Note that since UDP is connectionless, connection failure
is defined by the
-.B --ping
+.B \-\-ping
and
-.B --ping-restart
+.B \-\-ping-restart
options.
Note the following corner case: If you use multiple
-.B --remote
+.B \-\-remote
options, AND you are dropping root privileges on
the client with
-.B --user
+.B \-\-user
and/or
-.B --group,
+.B \-\-group,
AND the client is running a non-Windows OS, if the client needs
to switch to a different server, and that server pushes
back different TUN/TAP or route settings, the client may lack
@@ -248,7 +248,7 @@ the necessary privileges to close and reopen the TUN/TAP interface.
This could cause the client to exit with a fatal error.
If
-.B --remote
+.B \-\-remote
is unspecified, OpenVPN will listen
for packets from any IP address, but will not act on those packets unless
they pass all authentication tests. This requirement for authentication
@@ -257,7 +257,7 @@ trusted IP addresses (it is very easy to forge a source IP address on
a UDP packet).
When used in TCP mode,
-.B --remote
+.B \-\-remote
will act as a filter, rejecting connections from any host which does
not match
.B host.
@@ -283,7 +283,7 @@ and
An OpenVPN client will try each connection profile sequentially
until it achieves a successful connection.
-.B --remote-random
+.B \-\-remote-random
can be used to initially "scramble" the connection
list.
@@ -378,18 +378,24 @@ block. The effect would be as if
were declared in all
.B <connection>
blocks below it.
-
.\"*********************************************************
.TP
-.B --remote-random
+.B \-\-proto-force p
+When iterating through connection profiles,
+only consider profiles using protocol
+.B p
+('tcp'|'udp').
+.\"*********************************************************
+.TP
+.B \-\-remote-random
When multiple
-.B --remote
+.B \-\-remote
address/ports are specified, or if connection profiles are being
used, initially randomize the order of the list
as a kind of basic load-balancing measure.
.\"*********************************************************
.TP
-.B --proto p
+.B \-\-proto p
Use protocol
.B p
for communicating with remote host.
@@ -403,17 +409,17 @@ or
The default protocol is
.B udp
when
-.B --proto
+.B \-\-proto
is not specified.
For UDP operation,
-.B --proto udp
+.B \-\-proto udp
should be specified on both peers.
For TCP operation, one peer must use
-.B --proto tcp-server
+.B \-\-proto tcp-server
and the other must use
-.B --proto tcp-client.
+.B \-\-proto tcp-client.
A peer started with
.B tcp-server
will wait indefinitely for an incoming connection. A peer
@@ -421,9 +427,9 @@ started with
.B tcp-client
will attempt to connect, and if that fails, will sleep for 5
seconds (adjustable via the
-.B --connect-retry
+.B \-\-connect-retry
option) and try again infinite or up to N retries (adjustable via the
-.B --connect-retry-max
+.B \-\-connect-retry-max
option). Both TCP client and server will simulate
a SIGUSR1 restart signal if either side resets the connection.
@@ -443,9 +449,9 @@ application-level UDP protocols, or tunneling protocols which don't
possess a built-in reliability layer.
.\"*********************************************************
.TP
-.B --connect-retry n
+.B \-\-connect-retry n
For
-.B --proto tcp-client,
+.B \-\-proto tcp-client,
take
.B n
as the
@@ -453,16 +459,16 @@ number of seconds to wait
between connection retries (default=5).
.\"*********************************************************
.TP
-.B --connect-retry-max n
+.B \-\-connect-retry-max n
For
-.B --proto tcp-client,
+.B \-\-proto tcp-client,
take
.B n
as the
number of retries of connection attempt (default=infinite).
.\"*********************************************************
.TP
-.B --auto-proxy
+.B \-\-auto-proxy
Try to sense HTTP or SOCKS proxy settings automatically.
If no settings are present, a direct connection will be attempted.
If both HTTP and SOCKS settings are present, HTTP will be preferred.
@@ -474,7 +480,7 @@ InternetQueryOption API.
This option exists in OpenVPN 2.1 or higher.
.\"*********************************************************
.TP
-.B --http-proxy server port [authfile|'auto'] [auth-method]
+.B \-\-http-proxy server port [authfile|'auto'|'auto-nct'] [auth-method]
Connect to remote host through an HTTP proxy at address
.B server
and port
@@ -487,6 +493,13 @@ is a file containing a username and password on 2 lines, or
.B auth-method
should be one of "none", "basic", or "ntlm".
+HTTP Digest authentication is supported as well, but only via
+the
+.B auto
+or
+.B auto-nct
+flags (below).
+
The
.B auto
flag causes OpenVPN to automatically determine the
@@ -494,34 +507,40 @@ flag causes OpenVPN to automatically determine the
and query stdin or the management interface for
username/password credentials, if required. This flag
exists on OpenVPN 2.1 or higher.
+
+The
+.B auto-nct
+flag (no clear-text auth) instructs OpenVPN to automatically
+determine the authentication method, but to reject weak
+authentication protocols such as HTTP Basic Authentication.
.\"*********************************************************
.TP
-.B --http-proxy-retry
+.B \-\-http-proxy-retry
Retry indefinitely on HTTP proxy errors. If an HTTP proxy error
occurs, simulate a SIGUSR1 reset.
.\"*********************************************************
.TP
-.B --http-proxy-timeout n
+.B \-\-http-proxy-timeout n
Set proxy timeout to
.B n
seconds, default=5.
.\"*********************************************************
.TP
-.B --http-proxy-option type [parm]
+.B \-\-http-proxy-option type [parm]
Set extended HTTP proxy options.
Repeat to set multiple options.
-.B VERSION version --
+.B VERSION version \-\-
Set HTTP version number to
.B version
(default=1.0).
-.B AGENT user-agent --
+.B AGENT user-agent \-\-
Set HTTP "User-Agent" string to
.B user-agent.
.\"*********************************************************
.TP
-.B --socks-proxy server [port]
+.B \-\-socks-proxy server [port]
Connect to remote host through a Socks5 proxy at address
.B server
and port
@@ -529,14 +548,14 @@ and port
(default=1080).
.\"*********************************************************
.TP
-.B --socks-proxy-retry
+.B \-\-socks-proxy-retry
Retry indefinitely on Socks proxy errors. If a Socks proxy error
occurs, simulate a SIGUSR1 reset.
.\"*********************************************************
.TP
-.B --resolv-retry n
+.B \-\-resolv-retry n
If hostname resolve fails for
-.B --remote,
+.B \-\-remote,
retry resolve for
.B n
seconds before failing.
@@ -546,18 +565,18 @@ Set
to "infinite" to retry indefinitely.
By default,
-.B --resolv-retry infinite
+.B \-\-resolv-retry infinite
is enabled. You can disable by setting n=0.
.\"*********************************************************
.TP
-.B --float
+.B \-\-float
Allow remote peer to change its IP address and/or port number, such as due to
DHCP (this is the default if
-.B --remote
+.B \-\-remote
is not used).
-.B --float
+.B \-\-float
when specified with
-.B --remote
+.B \-\-remote
allows an OpenVPN session to initially connect to a peer
at a known address, however if packets arrive from a new
address and pass all authentication tests, the new address
@@ -566,14 +585,14 @@ you are connecting to a peer which holds a dynamic address
such as a dial-in user or DHCP client.
Essentially,
-.B --float
+.B \-\-float
tells OpenVPN to accept authenticated packets
from any address, not only the address which was specified in the
-.B --remote
+.B \-\-remote
option.
.\"*********************************************************
.TP
-.B --ipchange cmd
+.B \-\-ipchange cmd
Execute shell command
.B cmd
when our remote ip-address is initially authenticated or
@@ -584,11 +603,11 @@ Execute as:
.B cmd ip_address port_number
Don't use
-.B --ipchange
+.B \-\-ipchange
in
-.B --mode server
+.B \-\-mode server
mode. Use a
-.B --client-connect
+.B \-\-client-connect
script instead.
See the "Environmental Variables" section below for
@@ -623,41 +642,41 @@ reestablish a connection with its most recently authenticated
peer on its new IP address.
.\"*********************************************************
.TP
-.B --port port
+.B \-\-port port
TCP/UDP port number for both local and remote. The current
default of 1194 represents the official IANA port number
assignment for OpenVPN and has been used since version 2.0-beta17.
Previous versions used port 5000 as the default.
.\"*********************************************************
.TP
-.B --lport port
+.B \-\-lport port
TCP/UDP port number for bind.
.\"*********************************************************
.TP
-.B --rport port
+.B \-\-rport port
TCP/UDP port number for remote.
.\"*********************************************************
.TP
-.B --bind
+.B \-\-bind
Bind to local address and port. This is the default unless any of
-.B --proto tcp-client
+.B \-\-proto tcp-client
,
-.B --http-proxy
+.B \-\-http-proxy
or
-.B --socks-proxy
+.B \-\-socks-proxy
are used.
.\"*********************************************************
.TP
-.B --nobind
+.B \-\-nobind
Do not bind to local address and port. The IP stack will allocate
a dynamic port for returning packets. Since the value of the dynamic port
could not be known in advance by a peer, this option is only suitable for
peers which will be initiating connections by using the
-.B --remote
+.B \-\-remote
option.
.\"*********************************************************
.TP
-.B --dev tunX | tapX | null
+.B \-\-dev tunX | tapX | null
TUN/TAP virtual network device (
.B X
can be omitted for a dynamic device.)
@@ -675,7 +694,7 @@ devices encapsulate IPv4 or IPv6 (OSI Layer 3) while
devices encapsulate Ethernet 802.3 (OSI Layer 2).
.\"*********************************************************
.TP
-.B --dev-type device-type
+.B \-\-dev-type device-type
Which device type are we using?
.B device-type
should be
@@ -685,60 +704,60 @@ or
.B tap
(OSI Layer 2).
Use this option only if the TUN/TAP device used with
-.B --dev
+.B \-\-dev
does not begin with
.B tun
or
.B tap.
.\"*********************************************************
.TP
-.B --topology mode
+.B \-\-topology mode
Configure virtual addressing topology when running in
-.B --dev tun
+.B \-\-dev tun
mode. This directive has no meaning in
-.B --dev tap
+.B \-\-dev tap
mode, which always uses a
.B subnet
topology.
If you set this directive on the server, the
-.B --server
+.B \-\-server
and
-.B --server-bridge
+.B \-\-server-bridge
directives will automatically push your chosen topology setting to clients
as well. This directive can also be manually pushed to clients. Like the
-.B --dev
+.B \-\-dev
directive, this directive must always be compatible between client and server.
.B mode
can be one of:
-.B net30 --
+.B net30 \-\-
Use a point-to-point topology, by allocating one /30 subnet per client.
This is designed to allow point-to-point semantics when some
or all of the connecting clients might be Windows systems. This is the
default on OpenVPN 2.0.
-.B p2p --
+.B p2p \-\-
Use a point-to-point topology where the remote endpoint of the client's
tun interface always points to the local endpoint of the server's tun interface.
This mode allocates a single IP address per connecting client.
Only use
when none of the connecting clients are Windows systems. This mode
is functionally equivalent to the
-.B --ifconfig-pool-linear
+.B \-\-ifconfig-pool-linear
directive which is available in OpenVPN 2.0 and is now deprecated.
-.B subnet --
+.B subnet \-\-
Use a subnet rather than a point-to-point topology by
configuring the tun interface with a local IP address and subnet mask,
similar to the topology used in
-.B --dev tap
+.B \-\-dev tap
and ethernet bridging mode.
This mode allocates a single IP address per connecting client and works on
Windows as well. Only available when server and clients are OpenVPN 2.1 or
higher, or OpenVPN 2.0.x which has been manually patched with the
-.B --topology
+.B \-\-topology
directive code. When used on Windows, requires version 8.2 or higher
of the TAP-Win32 driver. When used on *nix, requires that the tun
driver supports an
@@ -748,26 +767,26 @@ command which sets a subnet instead of a remote endpoint IP address.
This option exists in OpenVPN 2.1 or higher.
.\"*********************************************************
.TP
-.B --tun-ipv6
+.B \-\-tun-ipv6
Build a tun link capable of forwarding IPv6 traffic.
Should be used in conjunction with
-.B --dev tun
+.B \-\-dev tun
or
-.B --dev tunX.
+.B \-\-dev tunX.
A warning will be displayed
if no specific IPv6 TUN support for your OS has been compiled into OpenVPN.
.\"*********************************************************
.TP
-.B --dev-node node
+.B \-\-dev-node node
Explicitly set the device node rather than using
/dev/net/tun, /dev/tun, /dev/tap, etc. If OpenVPN
cannot figure out whether
.B node
is a TUN or TAP device based on the name, you should
also specify
-.B --dev-type tun
+.B \-\-dev-type tun
or
-.B --dev-type tap.
+.B \-\-dev-type tap.
On Windows systems, select the TAP-Win32 adapter which
is named
@@ -775,24 +794,24 @@ is named
in the Network Connections Control Panel or the
raw GUID of the adapter enclosed by braces.
The
-.B --show-adapters
+.B \-\-show-adapters
option under Windows can also be used
to enumerate all available TAP-Win32
adapters and will show both the network
connections control panel name and the GUID for
each TAP-Win32 adapter.
.TP
-.B --lladdr address
+.B \-\-lladdr address
Specify the link layer address, more commonly known as the MAC address.
Only applied to TAP devices.
.\"*********************************************************
.TP
-.B --iproute cmd
+.B \-\-iproute cmd
Set alternate command to execute instead of default iproute2 command.
May be used in order to execute OpenVPN in unprivileged environment.
.\"*********************************************************
.TP
-.B --ifconfig l rn
+.B \-\-ifconfig l rn
Set TUN/TAP adapter parameters.
.B l
is the IP address of the local VPN endpoint.
@@ -807,7 +826,7 @@ which is being created or connected to.
For TUN devices, which facilitate virtual
point-to-point IP connections,
the proper usage of
-.B --ifconfig
+.B \-\-ifconfig
is to use two private IP addresses
which are not a member of any
existing subnet which is in use.
@@ -821,7 +840,7 @@ you will be pinging across the VPN.
For TAP devices, which provide
the ability to create virtual
ethernet segments,
-.B --ifconfig
+.B \-\-ifconfig
is used to set an IP address and
subnet mask just as a physical
ethernet adapter would be
@@ -842,42 +861,42 @@ standard interface to the different
ifconfig implementations on different
platforms.
-.B --ifconfig
+.B \-\-ifconfig
parameters which are IP addresses can
also be specified as a DNS or /etc/hosts
file resolvable name.
For TAP devices,
-.B --ifconfig
+.B \-\-ifconfig
should not be used if the TAP interface will be
getting an IP address lease from a DHCP
server.
.\"*********************************************************
.TP
-.B --ifconfig-noexec
+.B \-\-ifconfig-noexec
Don't actually execute ifconfig/netsh commands, instead
pass
-.B --ifconfig
+.B \-\-ifconfig
parameters to scripts using environmental variables.
.\"*********************************************************
.TP
-.B --ifconfig-nowarn
+.B \-\-ifconfig-nowarn
Don't output an options consistency check warning
if the
-.B --ifconfig
+.B \-\-ifconfig
option on this side of the
connection doesn't match the remote side. This is useful
when you want to retain the overall benefits of the
options consistency check (also see
-.B --disable-occ
+.B \-\-disable-occ
option) while only disabling the ifconfig component of
the check.
For example,
if you have a configuration where the local host uses
-.B --ifconfig
+.B \-\-ifconfig
but the remote host does not, use
-.B --ifconfig-nowarn
+.B \-\-ifconfig-nowarn
on the local host.
This option will also silence warnings about potential
@@ -885,7 +904,7 @@ address conflicts which occasionally annoy more experienced
users by triggering "false positive" warnings.
.\"*********************************************************
.TP
-.B --route network/IP [netmask] [gateway] [metric]
+.B \-\-route network/IP [netmask] [gateway] [metric]
Add route to routing table after connection is established.
Multiple routes can be specified. Routes will be
automatically torn down in reverse order prior to
@@ -899,20 +918,20 @@ while at the same time providing portable semantics
across OpenVPN's platform space.
.B netmask
-default -- 255.255.255.255
+default \-\- 255.255.255.255
.B gateway
-default -- taken from
-.B --route-gateway
+default \-\- taken from
+.B \-\-route-gateway
or the second parameter to
-.B --ifconfig
+.B \-\-ifconfig
when
-.B --dev tun
+.B \-\-dev tun
is specified.
.B metric
-default -- taken from
-.B --route-metric
+default \-\- taken from
+.B \-\-route-metric
otherwise 0.
The default can be specified by leaving an option blank or setting
@@ -927,37 +946,37 @@ also be specified as a DNS or /etc/hosts
file resolvable name, or as one of three special keywords:
.B vpn_gateway
--- The remote VPN endpoint address
+\-\- The remote VPN endpoint address
(derived either from
-.B --route-gateway
+.B \-\-route-gateway
or the second parameter to
-.B --ifconfig
+.B \-\-ifconfig
when
-.B --dev tun
+.B \-\-dev tun
is specified).
.B net_gateway
--- The pre-existing IP default gateway, read from the routing
+\-\- The pre-existing IP default gateway, read from the routing
table (not supported on all OSes).
.B remote_host
--- The
-.B --remote
+\-\- The
+.B \-\-remote
address if OpenVPN is being run in client mode, and is undefined in server mode.
.\"*********************************************************
.TP
-.B --max-routes n
+.B \-\-max-routes n
Allow a maximum number of n
-.B --route
+.B \-\-route
options to be specified, either in the local configuration file,
or pulled from an OpenVPN server. By default, n=100.
.\"*********************************************************
.TP
-.B --route-gateway gw|'dhcp'
+.B \-\-route-gateway gw|'dhcp'
Specify a default gateway
.B gw
for use with
-.B --route.
+.B \-\-route.
If
.B dhcp
@@ -966,14 +985,14 @@ the gateway address will be extracted from a DHCP
negotiation with the OpenVPN server-side LAN.
.\"*********************************************************
.TP
-.B --route-metric m
+.B \-\-route-metric m
Specify a default metric
.B m
for use with
-.B --route.
+.B \-\-route.
.\"*********************************************************
.TP
-.B --route-delay [n] [w]
+.B \-\-route-delay [n] [w]
Delay
.B n
seconds (default=0) after connection
@@ -981,16 +1000,16 @@ establishment, before adding routes. If
.B n
is 0, routes will be added immediately upon connection
establishment. If
-.B --route-delay
+.B \-\-route-delay
is omitted, routes will be added immediately after TUN/TAP device
open and
-.B --up
+.B \-\-up
script execution, before any
-.B --user
+.B \-\-user
or
-.B --group
+.B \-\-group
privilege downgrade (or
-.B --chroot
+.B \-\-chroot
execution.)
This option is designed to be useful in scenarios where DHCP is
@@ -999,18 +1018,18 @@ tap adapter addresses. The delay will give the DHCP handshake
time to complete before routes are added.
On Windows,
-.B --route-delay
+.B \-\-route-delay
tries to be more intelligent by waiting
.B w
seconds (w=30 by default)
for the TAP-Win32 adapter to come up before adding routes.
.\"*********************************************************
.TP
-.B --route-up cmd
+.B \-\-route-up cmd
Execute shell command
.B cmd
after routes are added, subject to
-.B --route-delay.
+.B \-\-route-delay.
See the "Environmental Variables" section below for
additional parameters passed as environmental variables.
@@ -1020,17 +1039,17 @@ Note that
can be a shell command with multiple arguments.
.\"*********************************************************
.TP
-.B --route-noexec
+.B \-\-route-noexec
Don't add or remove routes automatically. Instead pass routes to
-.B --route-up
+.B \-\-route-up
script using environmental variables.
.\"*********************************************************
.TP
-.B --route-nopull
+.B \-\-route-nopull
When used with
-.B --client
+.B \-\-client
or
-.B --pull,
+.B \-\-pull,
accept options pushed by server EXCEPT for routes.
When used on the client, this option effectively bars the
@@ -1039,16 +1058,16 @@ however note that this option still allows the server
to set the TCP/IP properties of the client's TUN/TAP interface.
.\"*********************************************************
.TP
-.B --allow-pull-fqdn
+.B \-\-allow-pull-fqdn
Allow client to pull DNS names from server (rather than being limited
to IP address) for
-.B --ifconfig,
-.B --route,
+.B \-\-ifconfig,
+.B \-\-route,
and
-.B --route-gateway.
+.B \-\-route-gateway.
.\"*********************************************************
.TP
-.B --redirect-gateway flags...
+.B \-\-redirect-gateway flags...
(Experimental) Automatically execute routing commands to cause all outgoing IP traffic
to be redirected over the VPN.
@@ -1056,7 +1075,7 @@ This option performs three steps:
.B (1)
Create a static route for the
-.B --remote
+.B \-\-remote
address which forwards to the pre-existing default gateway.
This is done so that
.B (3)
@@ -1067,11 +1086,11 @@ Delete the default gateway route.
.B (3)
Set the new default gateway to be the VPN endpoint address (derived either from
-.B --route-gateway
+.B \-\-route-gateway
or the second parameter to
-.B --ifconfig
+.B \-\-ifconfig
when
-.B --dev tun
+.B \-\-dev tun
is specified).
When the tunnel is torn down, all of the above steps are reversed so
@@ -1079,7 +1098,7 @@ that the original default route is restored.
Option flags:
-.B local --
+.B local \-\-
Add the
.B local
flag if both OpenVPN servers are directly connected via a common subnet,
@@ -1089,19 +1108,19 @@ flag will cause step
.B 1
above to be omitted.
-.B def1 --
+.B def1 \-\-
Use this flag to override
the default gateway by using 0.0.0.0/1 and 128.0.0.0/1
rather than 0.0.0.0/0. This has the benefit of overriding
but not wiping out the original default gateway.
-.B bypass-dhcp --
+.B bypass-dhcp \-\-
Add a direct route to the DHCP server (if it is non-local) which
bypasses the tunnel
(Available on Windows clients, may not be available
on non-Windows clients).
-.B bypass-dns --
+.B bypass-dns \-\-
Add a direct route to the DNS server(s) (if they are non-local) which
bypasses the tunnel
(Available on Windows clients, may not be available
@@ -1110,13 +1129,13 @@ on non-Windows clients).
Using the def1 flag is highly recommended.
.\"*********************************************************
.TP
-.B --link-mtu n
+.B \-\-link-mtu n
Sets an upper bound on the size of UDP packets which are sent
between OpenVPN peers. It's best not to set this parameter unless
you know what you're doing.
.\"*********************************************************
.TP
-.B --tun-mtu n
+.B \-\-tun-mtu n
Take the TUN device MTU to be
.B n
and derive the link MTU
@@ -1132,17 +1151,17 @@ MTU problems often manifest themselves as connections which
hang during periods of active usage.
It's best to use the
-.B --fragment
+.B \-\-fragment
and/or
-.B --mssfix
+.B \-\-mssfix
options to deal with MTU sizing issues.
.\"*********************************************************
.TP
-.B --tun-mtu-extra n
+.B \-\-tun-mtu-extra n
Assume that the TUN/TAP device might return as many as
.B n
bytes more than the
-.B --tun-mtu
+.B \-\-tun-mtu
size on read. This parameter defaults to 0, which is sufficient for
most TUN devices. TAP devices may introduce additional overhead in excess
of the MTU size, and a setting of 32 is the default when TAP devices are used.
@@ -1150,34 +1169,34 @@ This parameter only controls internal OpenVPN buffer sizing,
so there is no transmission overhead associated with using a larger value.
.\"*********************************************************
.TP
-.B --mtu-disc type
+.B \-\-mtu-disc type
Should we do Path MTU discovery on TCP/UDP channel? Only supported on OSes such
as Linux that supports the necessary system call to set.
.B 'no'
--- Never send DF (Don't Fragment) frames
+\-\- Never send DF (Don't Fragment) frames
.br
.B 'maybe'
--- Use per-route hints
+\-\- Use per-route hints
.br
.B 'yes'
--- Always DF (Don't Fragment)
+\-\- Always DF (Don't Fragment)
.br
.\"*********************************************************
.TP
-.B --mtu-test
+.B \-\-mtu-test
To empirically measure MTU on connection startup,
add the
-.B --mtu-test
+.B \-\-mtu-test
option to your configuration.
OpenVPN will send ping packets of various sizes
to the remote peer and measure the largest packets
which were successfully received. The
-.B --mtu-test
+.B \-\-mtu-test
process normally takes about 3 minutes to complete.
.\"*********************************************************
.TP
-.B --fragment max
+.B \-\-fragment max
Enable internal datagram fragmentation so
that no UDP datagrams are sent which
are larger than
@@ -1187,24 +1206,24 @@ bytes.
The
.B max
parameter is interpreted in the same way as the
-.B --link-mtu
+.B \-\-link-mtu
parameter, i.e. the UDP packet size after encapsulation
overhead has been added in, but not including
the UDP header itself.
The
-.B --fragment
+.B \-\-fragment
option only makes sense when you are using the UDP protocol (
-.B --proto udp
+.B \-\-proto udp
).
-.B --fragment
+.B \-\-fragment
adds 4 bytes of overhead per datagram.
See the
-.B --mssfix
+.B \-\-mssfix
option below for an important related option to
-.B --fragment.
+.B \-\-fragment.
It should also be noted that this option is not meant to replace
UDP fragmentation at the IP stack level. It is only meant as a
@@ -1217,44 +1236,45 @@ internal fragmentation capability may be your only option, such
as tunneling a UDP multicast stream which requires fragmentation.
.\"*********************************************************
.TP
-.B --mssfix max
+.B \-\-mssfix max
Announce to TCP sessions running over the tunnel that they should limit
their send packet sizes such that after OpenVPN has encapsulated them,
the resulting UDP packet size that OpenVPN sends to its peer will not
exceed
.B max
-bytes.
+bytes. The default value is
+.B 1450.
The
.B max
parameter is interpreted in the same way as the
-.B --link-mtu
+.B \-\-link-mtu
parameter, i.e. the UDP packet size after encapsulation
overhead has been added in, but not including
the UDP header itself.
The
-.B --mssfix
+.B \-\-mssfix
option only makes sense when you are using the UDP protocol
for OpenVPN peer-to-peer communication, i.e.
-.B --proto udp.
+.B \-\-proto udp.
-.B --mssfix
+.B \-\-mssfix
and
-.B --fragment
+.B \-\-fragment
can be ideally used together, where
-.B --mssfix
+.B \-\-mssfix
will try to keep TCP from needing
packet fragmentation in the first place,
and if big packets come through anyhow
(from protocols other than TCP),
-.B --fragment
+.B \-\-fragment
will internally fragment them.
Both
-.B --fragment
+.B \-\-fragment
and
-.B --mssfix
+.B \-\-mssfix
are designed to work around cases where Path MTU discovery
is broken on the network path between OpenVPN peers.
@@ -1263,35 +1283,35 @@ connection which successfully starts, but then stalls
during active usage.
If
-.B --fragment
+.B \-\-fragment
and
-.B --mssfix
+.B \-\-mssfix
are used together,
-.B --mssfix
+.B \-\-mssfix
will take its default
.B max
parameter from the
-.B --fragment max
+.B \-\-fragment max
option.
Therefore, one could lower the maximum UDP packet size
to 1300 (a good first try for solving MTU-related
connection problems) with the following options:
-.B --tun-mtu 1500 --fragment 1300 --mssfix
+.B \-\-tun-mtu 1500 \-\-fragment 1300 \-\-mssfix
.\"*********************************************************
.TP
-.B --sndbuf size
+.B \-\-sndbuf size
Set the TCP/UDP socket send buffer size.
Currently defaults to 65536 bytes.
.\"*********************************************************
.TP
-.B --rcvbuf size
+.B \-\-rcvbuf size
Set the TCP/UDP socket receive buffer size.
Currently defaults to 65536 bytes.
.\"*********************************************************
.TP
-.B --socket-flags flags...
+.B \-\-socket-flags flags...
Apply the given flags to the OpenVPN transport socket.
Currently, only
.B TCP_NODELAY
@@ -1308,12 +1328,12 @@ This option is pushable from server to client, and should be used
on both client and server for maximum effect.
.\"*********************************************************
.TP
-.B --txqueuelen n
+.B \-\-txqueuelen n
(Linux only) Set the TX queue length on the TUN/TAP interface.
Currently defaults to 100.
.\"*********************************************************
.TP
-.B --shaper n
+.B \-\-shaper n
Limit bandwidth of outgoing tunnel data to
.B n
bytes per second on the TCP/UDP port.
@@ -1349,32 +1369,42 @@ OpenVPN allows
to be between 100 bytes/sec and 100 Mbytes/sec.
.\"*********************************************************
.TP
-.B --inactive n [bytes]
+.B \-\-inactive n [bytes]
Causes OpenVPN to exit after
.B n
-seconds of inactivity on the TUN/TAP device. The time length
-of inactivity is measured since the last incoming tunnel packet.
+seconds of inactivity on the TUN/TAP device. The time length of
+inactivity is measured since the last incoming or outgoing tunnel
+packet.
If the optional
.B bytes
parameter is included,
-exit after n seconds of activity on tun/tap device
-produces a combined in/out byte count that is less than
-.B bytes.
+exit if less than
+.B bytes
+of combined in/out traffic are produced on the tun/tap device
+in
+.B n
+seconds.
+
+In any case, OpenVPN's internal ping packets (which are just
+keepalives) and TLS control packets are not considered
+"activity", nor are they counted as traffic, as they are used
+internally by OpenVPN and are not an indication of actual user
+activity.
.\"*********************************************************
.TP
-.B --ping n
+.B \-\-ping n
Ping remote over the TCP/UDP control channel
if no packets have been sent for at least
.B n
seconds (specify
-.B --ping
+.B \-\-ping
on both peers to cause ping packets to be sent in both directions since
OpenVPN ping packets are not echoed like IP ping packets).
When used in one of OpenVPN's secure modes (where
-.B --secret, --tls-server,
+.B \-\-secret, \-\-tls-server,
or
-.B --tls-client
+.B \-\-tls-client
is specified), the ping packet
will be cryptographically secure.
@@ -1387,33 +1417,33 @@ pass will not time out.
(2) To provide a basis for the remote to test the existence
of its peer using the
-.B --ping-exit
+.B \-\-ping-exit
option.
.\"*********************************************************
.TP
-.B --ping-exit n
+.B \-\-ping-exit n
Causes OpenVPN to exit after
.B n
seconds pass without reception of a ping
or other packet from remote.
This option can be combined with
-.B --inactive, --ping,
+.B \-\-inactive, \-\-ping,
and
-.B --ping-exit
+.B \-\-ping-exit
to create a two-tiered inactivity disconnect.
For example,
-.B openvpn [options...] --inactive 3600 --ping 10 --ping-exit 60
+.B openvpn [options...] \-\-inactive 3600 \-\-ping 10 \-\-ping-exit 60
when used on both peers will cause OpenVPN to exit within 60
seconds if its peer disconnects, but will exit after one
hour if no actual tunnel data is exchanged.
.\"*********************************************************
.TP
-.B --ping-restart n
+.B \-\-ping-restart n
Similar to
-.B --ping-exit,
+.B \-\-ping-exit,
but trigger a
.B SIGUSR1
restart after
@@ -1432,13 +1462,13 @@ as
If the peer cannot be reached, a restart will be triggered, causing
the hostname used with
-.B --remote
+.B \-\-remote
to be re-resolved (if
-.B --resolv-retry
+.B \-\-resolv-retry
is also specified).
In server mode,
-.B --ping-restart, --inactive,
+.B \-\-ping-restart, \-\-inactive,
or any other type of internally generated signal will always be
applied to
individual client instance objects, never to whole server itself.
@@ -1447,14 +1477,14 @@ which would normally cause a restart, will cause the deletion
of the client instance object instead.
In client mode, the
-.B --ping-restart
+.B \-\-ping-restart
parameter is set to 120 seconds by default. This default will
hold until the client pulls a replacement value from the server, based on
the
-.B --keepalive
+.B \-\-keepalive
setting in the server configuration.
To disable the 120 second default, set
-.B --ping-restart 0
+.B \-\-ping-restart 0
on the client.
See the signals section below for more information
@@ -1464,27 +1494,27 @@ on
Note that the behavior of
.B SIGUSR1
can be modified by the
-.B --persist-tun, --persist-key, --persist-local-ip,
+.B \-\-persist-tun, \-\-persist-key, \-\-persist-local-ip,
and
-.B --persist-remote-ip
+.B \-\-persist-remote-ip
options.
Also note that
-.B --ping-exit
+.B \-\-ping-exit
and
-.B --ping-restart
+.B \-\-ping-restart
are mutually exclusive and cannot be used together.
.\"*********************************************************
.TP
-.B --keepalive n m
+.B \-\-keepalive n m
A helper directive designed to simplify the expression of
-.B --ping
+.B \-\-ping
and
-.B --ping-restart
+.B \-\-ping-restart
in server mode configurations.
For example,
-.B --keepalive 10 60
+.B \-\-keepalive 10 60
expands as follows:
.nf
@@ -1503,24 +1533,24 @@ expands as follows:
.fi
.\"*********************************************************
.TP
-.B --ping-timer-rem
+.B \-\-ping-timer-rem
Run the
-.B --ping-exit
+.B \-\-ping-exit
/
-.B --ping-restart
+.B \-\-ping-restart
timer only if we have a remote address. Use this option if you are
starting the daemon in listen mode (i.e. without an explicit
-.B --remote
+.B \-\-remote
peer), and you don't want to start clocking timeouts until a remote
peer connects.
.\"*********************************************************
.TP
-.B --persist-tun
+.B \-\-persist-tun
Don't close and reopen TUN/TAP device or run up/down scripts
across
.B SIGUSR1
or
-.B --ping-restart
+.B \-\-ping-restart
restarts.
.B SIGUSR1
@@ -1530,14 +1560,14 @@ but which offers finer-grained control over
reset options.
.\"*********************************************************
.TP
-.B --persist-key
+.B \-\-persist-key
Don't re-read key files across
.B SIGUSR1
or
-.B --ping-restart.
+.B \-\-ping-restart.
This option can be combined with
-.B --user nobody
+.B \-\-user nobody
to allow restarts triggered by the
.B SIGUSR1
signal.
@@ -1550,29 +1580,29 @@ This option solves the problem by persisting keys across
resets, so they don't need to be re-read.
.\"*********************************************************
.TP
-.B --persist-local-ip
+.B \-\-persist-local-ip
Preserve initially resolved local IP address and port number
across
.B SIGUSR1
or
-.B --ping-restart
+.B \-\-ping-restart
restarts.
.\"*********************************************************
.TP
-.B --persist-remote-ip
+.B \-\-persist-remote-ip
Preserve most recently authenticated remote IP address and port number
across
.B SIGUSR1
or
-.B --ping-restart
+.B \-\-ping-restart
restarts.
.\"*********************************************************
.TP
-.B --mlock
+.B \-\-mlock
Disable paging by calling the POSIX mlockall function.
Requires that OpenVPN be initially run as root (though
OpenVPN can subsequently downgrade its UID using the
-.B --user
+.B \-\-user
option).
Using this option ensures that key material and tunnel
@@ -1584,33 +1614,33 @@ would not be able to scan the system swap file to
recover previously used
ephemeral keys, which are used for a period of time
governed by the
-.B --reneg
+.B \-\-reneg
options (see below), then are discarded.
The downside
of using
-.B --mlock
+.B \-\-mlock
is that it will reduce the amount of physical
memory available to other applications.
.\"*********************************************************
.TP
-.B --up cmd
+.B \-\-up cmd
Shell command to run after successful TUN/TAP device open
(pre
-.B --user
+.B \-\-user
UID change). The up script is useful for specifying route
commands which route IP traffic destined for
private subnets which exist at the other
end of the VPN connection into the tunnel.
For
-.B --dev tun
+.B \-\-dev tun
execute as:
.B cmd tun_dev tun_mtu link_mtu ifconfig_local_ip ifconfig_remote_ip [ init | restart ]
For
-.B --dev tap
+.B \-\-dev tap
execute as:
.B cmd tap_dev tap_mtu link_mtu ifconfig_local_ip ifconfig_netmask [ init | restart ]
@@ -1635,62 +1665,62 @@ In this context, the last command line parameter passed to the script
will be
.I init.
If the
-.B --up-restart
+.B \-\-up-restart
option is also used, the up script will be called for restarts as
well. A restart is considered to be a partial reinitialization
of OpenVPN where the TUN/TAP instance is preserved (the
-.B --persist-tun
+.B \-\-persist-tun
option will enable such preservation). A restart
can be generated by a SIGUSR1 signal, a
-.B --ping-restart
+.B \-\-ping-restart
timeout, or a connection reset when the TCP protocol is enabled
with the
-.B --proto
+.B \-\-proto
option. If a restart occurs, and
-.B --up-restart
+.B \-\-up-restart
has been specified, the up script will be called with
.I restart
as the last parameter.
The following standalone example shows how the
-.B --up
+.B \-\-up
script can be called in both an initialization and restart context.
(NOTE: for security reasons, don't run the following example unless UDP port
9999 is blocked by your firewall. Also, the example will run indefinitely,
so you should abort with control-c).
-.B openvpn --dev tun --port 9999 --verb 4 --ping-restart 10 --up 'echo up' --down 'echo down' --persist-tun --up-restart
+.B openvpn \-\-dev tun \-\-port 9999 \-\-verb 4 \-\-ping-restart 10 \-\-up 'echo up' \-\-down 'echo down' \-\-persist-tun \-\-up-restart
Note that OpenVPN also provides the
-.B --ifconfig
+.B \-\-ifconfig
option to automatically ifconfig the TUN device,
eliminating the need to define an
-.B --up
+.B \-\-up
script, unless you also want to configure routes
in the
-.B --up
+.B \-\-up
script.
If
-.B --ifconfig
+.B \-\-ifconfig
is also specified, OpenVPN will pass the ifconfig local
and remote endpoints on the command line to the
-.B --up
+.B \-\-up
script so that they can be used to configure routes such as:
.B route add -net 10.0.0.0 netmask 255.255.255.0 gw $5
.\"*********************************************************
.TP
-.B --up-delay
+.B \-\-up-delay
Delay TUN/TAP open and possible
-.B --up
+.B \-\-up
script execution
until after TCP/UDP connection establishment with peer.
In
-.B --proto udp
+.B \-\-proto udp
mode, this option normally requires the use of
-.B --ping
+.B \-\-ping
to allow connection initiation to be sensed in the absence
of tunnel data, since UDP is a "connectionless" protocol.
@@ -1699,50 +1729,50 @@ transitioning to "connected" until connection establishment,
i.e. the receipt of the first authenticated packet from the peer.
.\"*********************************************************
.TP
-.B --down cmd
+.B \-\-down cmd
Shell command to run after TUN/TAP device close
(post
-.B --user
+.B \-\-user
UID change and/or
-.B --chroot
+.B \-\-chroot
). Called with the same parameters and environmental
variables as the
-.B --up
+.B \-\-up
option above.
Note that if you reduce privileges by using
-.B --user
+.B \-\-user
and/or
-.B --group,
+.B \-\-group,
your
-.B --down
+.B \-\-down
script will also run at reduced privilege.
.\"*********************************************************
.TP
-.B --down-pre
+.B \-\-down-pre
Call
-.B --down
+.B \-\-down
cmd/script before, rather than after, TUN/TAP close.
.\"*********************************************************
.TP
-.B --up-restart
+.B \-\-up-restart
Enable the
-.B --up
+.B \-\-up
and
-.B --down
+.B \-\-down
scripts to be called for restarts as well as initial program start.
This option is described more fully above in the
-.B --up
+.B \-\-up
option documentation.
.\"*********************************************************
.TP
-.B --setenv name value
+.B \-\-setenv name value
Set a custom environmental variable
.B name=value
to pass to script.
.\"*********************************************************
.TP
-.B --setenv FORWARD_COMPATIBLE 1
+.B \-\-setenv FORWARD_COMPATIBLE 1
Relax config file syntax checking so that unknown directives
will trigger a warning but not a fatal error,
on the assumption that a given unknown directive might be valid
@@ -1755,7 +1785,7 @@ new software features to gracefully degrade when encountered by
older software versions.
.\"*********************************************************
.TP
-.B --setenv-safe name value
+.B \-\-setenv-safe name value
Set a custom environmental variable
.B OPENVPN_name=value
to pass to script.
@@ -1766,23 +1796,23 @@ is a safety precaution to prevent a LD_PRELOAD style attack
from a malicious or compromised server.
.\"*********************************************************
.TP
-.B --script-security level [method]
+.B \-\-script-security level [method]
This directive offers policy-level control over OpenVPN's usage of external programs
and scripts. Lower
.B level
values are more restrictive, higher values are more permissive. Settings for
.B level:
-.B 0 --
+.B 0 \-\-
Strictly no calling of external programs.
.br
-.B 1 --
+.B 1 \-\-
(Default) Only call built-in executables such as ifconfig, ip, route, or netsh.
.br
-.B 2 --
+.B 2 \-\-
Allow calling of built-in executables and user-defined scripts.
.br
-.B 3 --
+.B 3 \-\-
Allow passwords to be passed to scripts via environmental variables (potentially unsafe).
The
@@ -1791,33 +1821,33 @@ parameter indicates how OpenVPN should call external commands and scripts.
Settings for
.B method:
-.B execve --
+.B execve \-\-
(default) Use execve() function on Unix family OSes and CreateProcess() on Windows.
.br
-.B system --
+.B system \-\-
Use system() function (deprecated and less safe since the external program command
line is subject to shell expansion).
The
-.B --script-security
+.B \-\-script-security
option was introduced in OpenVPN 2.1_rc9. For configuration file compatibility
with previous OpenVPN versions, use:
-.B --script-security 3 system
+.B \-\-script-security 3 system
.\"*********************************************************
.TP
-.B --disable-occ
+.B \-\-disable-occ
Don't output a warning message if option inconsistencies are detected between
peers. An example of an option inconsistency would be where one peer uses
-.B --dev tun
+.B \-\-dev tun
while the other peer uses
-.B --dev tap.
+.B \-\-dev tap.
Use of this option is discouraged, but is provided as
a temporary fix in situations where a recent version of OpenVPN must
connect to an old version.
.\"*********************************************************
.TP
-.B --user user
+.B \-\-user user
Change the user ID of the OpenVPN process to
.B user
after initialization, dropping privileges in the process.
@@ -1839,7 +1869,7 @@ you want to reset an OpenVPN daemon with a
signal
(for example in response
to a DHCP reset), you should make use of one or more of the
-.B --persist
+.B \-\-persist
options to ensure that OpenVPN doesn't need to execute any privileged
operations in order to restart (such as re-reading key files
or running
@@ -1847,16 +1877,16 @@ or running
on the TUN device).
.\"*********************************************************
.TP
-.B --group group
+.B \-\-group group
Similar to the
-.B --user
+.B \-\-user
option,
this option changes the group ID of the OpenVPN process to
.B group
after initialization.
.\"*********************************************************
.TP
-.B --cd dir
+.B \-\-cd dir
Change directory to
.B dir
prior to reading any files such as
@@ -1868,16 +1898,16 @@ to the current directory such as "." or "..".
This option is useful when you are running
OpenVPN in
-.B --daemon
+.B \-\-daemon
mode, and you want to consolidate all of
your OpenVPN control files in one location.
.\"*********************************************************
.TP
-.B --chroot dir
+.B \-\-chroot dir
Chroot to
.B dir
after initialization.
-.B --chroot
+.B \-\-chroot
essentially redefines
.B dir
as being the top
@@ -1896,22 +1926,22 @@ complications can result when scripts or restarts
are executed after the chroot operation.
.\"*********************************************************
.TP
-.B --setcon context
+.B \-\-setcon context
Apply SELinux
.B context
after initialization. This
essentially provides the ability to restrict OpenVPN's
rights to only network I/O operations, thanks to
SELinux. This goes further than
-.B --user
+.B \-\-user
and
-.B --chroot
+.B \-\-chroot
in that those two, while being great security features,
unfortunately do not protect against privilege escalation
by exploitation of a vulnerable system call. You can of
course combine all three, but please note that since
setcon requires access to /proc you will have to provide
-it inside the chroot directory (e.g. with mount --bind).
+it inside the chroot directory (e.g. with mount \-\-bind).
Since the setcon operation is delayed until after
initialization, OpenVPN can be restricted to just
@@ -1923,13 +1953,13 @@ allow many things required only during initialization.
Like with chroot, complications can result when scripts
or restarts are executed after the setcon operation,
which is why you should really consider using the
-.B --persist-key
+.B \-\-persist-key
and
-.B --persist-tun
+.B \-\-persist-tun
options.
.\"*********************************************************
.TP
-.B --daemon [progname]
+.B \-\-daemon [progname]
Become a daemon after all initialization functions are completed.
This option will cause all message and error output to
be sent to the syslog file (such as /var/log/messages),
@@ -1938,10 +1968,10 @@ ifconfig commands,
which will go to /dev/null unless otherwise redirected.
The syslog redirection occurs immediately at the point
that
-.B --daemon
+.B \-\-daemon
is parsed on the command line even though
the daemonization point occurs later. If one of the
-.B --log
+.B \-\-log
options is present, it will supercede syslog
redirection.
@@ -1957,7 +1987,7 @@ When unspecified,
defaults to "openvpn".
When OpenVPN is run with the
-.B --daemon
+.B \-\-daemon
option, it will try to delay daemonization until the majority of initialization
functions which are capable of generating fatal errors are complete. This means
that initialization scripts can test the return status of the
@@ -1967,20 +1997,20 @@ has correctly initialized and entered the packet forwarding event loop.
In OpenVPN, the vast majority of errors which occur after initialization are non-fatal.
.\"*********************************************************
.TP
-.B --syslog [progname]
+.B \-\-syslog [progname]
Direct log output to system logger, but do not become a daemon.
See
-.B --daemon
+.B \-\-daemon
directive above for description of
.B progname
parameter.
.\"*********************************************************
.TP
-.B --passtos
+.B \-\-passtos
Set the TOS field of the tunnel packet to what the payload's TOS is.
.\"*********************************************************
.TP
-.B --inetd [wait|nowait] [progname]
+.B \-\-inetd [wait|nowait] [progname]
Use this option when OpenVPN is being run from the inetd or
.BR xinetd(8)
server.
@@ -1991,7 +2021,7 @@ option must match what is specified in the inetd/xinetd
config file. The
.B nowait
mode can only be used with
-.B --proto tcp-server.
+.B \-\-proto tcp-server.
The default is
.B wait.
The
@@ -2003,16 +2033,16 @@ see the OpenVPN FAQ:
.I http://openvpn.net/faq.html#oneport
This option precludes the use of
-.B --daemon, --local,
+.B \-\-daemon, \-\-local,
or
-.B --remote.
+.B \-\-remote.
Note that this option causes message and error output to be handled in the same
way as the
-.B --daemon
+.B \-\-daemon
option. The optional
.B progname
parameter is also handled exactly as in
-.B --daemon.
+.B \-\-daemon.
Also note that in
.B wait
@@ -2022,7 +2052,7 @@ on using OpenVPN with xinetd:
.I http://openvpn.net/1xhowto.html
.\"*********************************************************
.TP
-.B --log file
+.B \-\-log file
Output logging messages to
.B file,
including output to stdout/stderr which
@@ -2033,44 +2063,44 @@ already exists it will be truncated.
This option takes effect
immediately when it is parsed in the command line
and will supercede syslog output if
-.B --daemon
+.B \-\-daemon
or
-.B --inetd
+.B \-\-inetd
is also specified.
This option is persistent over the entire course of
an OpenVPN instantiation and will not be reset by SIGHUP,
SIGUSR1, or
-.B --ping-restart.
+.B \-\-ping-restart.
Note that on Windows, when OpenVPN is started as a service,
logging occurs by default without the need to specify
this option.
.\"*********************************************************
.TP
-.B --log-append file
+.B \-\-log-append file
Append logging messages to
.B file.
If
.B file
does not exist, it will be created.
This option behaves exactly like
-.B --log
+.B \-\-log
except that it appends to rather
than truncating the log file.
.\"*********************************************************
.TP
-.B --suppress-timestamps
+.B \-\-suppress-timestamps
Avoid writing timestamps to log messages, even when they
otherwise would be prepended. In particular, this applies to
log messages sent to stdout.
.\"*********************************************************
.TP
-.B --writepid file
+.B \-\-writepid file
Write OpenVPN's main process ID to
.B file.
.\"*********************************************************
.TP
-.B --nice n
+.B \-\-nice n
Change process priority after initialization
(
.B n
@@ -2079,14 +2109,14 @@ greater than 0 is lower priority,
less than zero is higher priority).
.\"*********************************************************
.\".TP
-.\".B --nice-work n
+.\".B \-\-nice-work n
.\"Change priority of background TLS work thread. The TLS thread
.\"feature is enabled when OpenVPN is built
.\"with pthread support, and you are running OpenVPN
.\"in TLS mode (i.e. with
-.\".B --tls-client
+.\".B \-\-tls-client
.\"or
-.\".B --tls-server
+.\".B \-\-tls-server
.\"specified).
.\"
.\"Using a TLS thread offloads the CPU-intensive process of SSL/TLS-based
@@ -2096,12 +2126,12 @@ less than zero is higher priority).
.\"The parameter
.\".B n
.\"is interpreted exactly as with the
-.\".B --nice
+.\".B \-\-nice
.\"option above, but in relation to the work thread rather
.\"than the main thread.
.\"*********************************************************
.TP
-.B --fast-io
+.B \-\-fast-io
(Experimental) Optimize TUN/TAP/UDP I/O writes by avoiding
a call to poll/epoll/select prior to the write operation. The purpose
of such a call would normally be to block until the device
@@ -2112,13 +2142,13 @@ by avoiding the poll/epoll/select call, improving CPU efficiency
by 5% to 10%.
This option can only be used on non-Windows systems, when
-.B --proto udp
+.B \-\-proto udp
is specified, and when
-.B --shaper
+.B \-\-shaper
is NOT specified.
.\"*********************************************************
.TP
-.B --multihome
+.B \-\-multihome
Configure a multi-homed UDP server. This option can be used when
OpenVPN has been configured to listen on all interfaces, and will
attempt to bind client sessions to the interface on which packets
@@ -2127,13 +2157,13 @@ of the same interface. Note that this option is only relevant for
UDP servers and currently is only implemented on Linux.
Note: clients connecting to a
-.B --multihome
+.B \-\-multihome
server should always use the
-.B --nobind
+.B \-\-nobind
option.
.\"*********************************************************
.TP
-.B --echo [parms...]
+.B \-\-echo [parms...]
Echo
.B parms
to log output.
@@ -2142,7 +2172,7 @@ Designed to be used to send messages to a controlling application
which is receiving the OpenVPN log output.
.\"*********************************************************
.TP
-.B --remap-usr1 signal
+.B \-\-remap-usr1 signal
Control whether internally or externally
generated SIGUSR1 signals are remapped to
SIGHUP (restart without persisting state) or
@@ -2153,20 +2183,20 @@ can be set to "SIGHUP" or "SIGTERM". By default, no remapping
occurs.
.\"*********************************************************
.TP
-.B --verb n
+.B \-\-verb n
Set output verbosity to
.B n
(default=1). Each level shows all info from the previous levels.
Level 3 is recommended if you want a good summary
of what's happening without being swamped by output.
-.B 0 --
+.B 0 \-\-
No output except fatal errors.
.br
-.B 1 to 4 --
+.B 1 to 4 \-\-
Normal usage range.
.br
-.B 5 --
+.B 5 \-\-
Output
.B R
and
@@ -2174,12 +2204,12 @@ and
characters to the console for each packet read and write, uppercase is
used for TCP/UDP packets and lowercase is used for TUN/TAP packets.
.br
-.B 6 to 11 --
+.B 6 to 11 \-\-
Debug info range (see errlevel.h for additional
information on debug levels).
.\"*********************************************************
.TP
-.B --status file [n]
+.B \-\-status file [n]
Write operational status to
.B file
every
@@ -2191,21 +2221,21 @@ Status can also be written to the syslog by sending a
signal.
.\"*********************************************************
.TP
-.B --status-version [n]
+.B \-\-status-version [n]
Choose the status file format version number. Currently
.B n
can be 1, 2, or 3 and defaults to 1.
.\"*********************************************************
.TP
-.B --mute n
+.B \-\-mute n
Log at most
.B n
consecutive messages in the same category. This is useful to
limit repetitive logging of similar message types.
.\"*********************************************************
.TP
-.B --comp-lzo [mode]
-Use fast LZO compression -- may add up to 1 byte per
+.B \-\-comp-lzo [mode]
+Use fast LZO compression \-\- may add up to 1 byte per
packet for incompressible data.
.B mode
may be "yes", "no", or "adaptive" (default).
@@ -2215,16 +2245,16 @@ compression on or off for individual clients.
First, make sure the client-side config file enables selective
compression by having at least one
-.B --comp-lzo
+.B \-\-comp-lzo
directive, such as
-.B --comp-lzo no.
+.B \-\-comp-lzo no.
This will turn off compression by default,
but allow a future directive push from the server to
dynamically change the
on/off/adaptive setting.
Next in a
-.B --client-config-dir
+.B \-\-client-config-dir
file, specify the compression setting for the client,
for example:
@@ -2243,12 +2273,12 @@ setting for the server
side of the link, the second sets the client side.
.\"*********************************************************
.TP
-.B --comp-noadapt
+.B \-\-comp-noadapt
When used in conjunction with
-.B --comp-lzo,
+.B \-\-comp-lzo,
this option will disable OpenVPN's adaptive compression algorithm.
Normally, adaptive compression is enabled with
-.B --comp-lzo.
+.B \-\-comp-lzo.
Adaptive compression tries to optimize the case where you have
compression enabled, but you are sending predominantly uncompressible
@@ -2260,7 +2290,7 @@ the compression efficiency will be very low, triggering openvpn to disable
compression for a period of time until the next re-sample test.
.\"*********************************************************
.TP
-.B --management IP port [pw-file]
+.B \-\-management IP port [pw-file]
Enable a TCP server on
.B IP:port
to handle daemon management functions.
@@ -2279,9 +2309,9 @@ and set
.B port
to 'unix'. While the default behavior is to create a unix domain socket
that may be connected to by any process, the
-.B --management-client-user
+.B \-\-management-client-user
and
-.B --management-client-group
+.B \-\-management-client-group
directives can be used to restrict access.
The management interface provides a special mode where the TCP
@@ -2310,24 +2340,24 @@ be set to 127.0.0.1
server to local clients.
.\"*********************************************************
.TP
-.B --management-query-passwords
+.B \-\-management-query-passwords
Query management channel for private key password and
-.B --auth-user-pass
+.B \-\-auth-user-pass
username/password. Only query the management channel
for inputs which ordinarily would have been queried from the
console.
.\"*********************************************************
.TP
-.B --management-forget-disconnect
+.B \-\-management-forget-disconnect
Make OpenVPN forget passwords when management session
disconnects.
This directive does not affect the
-.B --http-proxy
+.B \-\-http-proxy
username/password. It is always cached.
.\"*********************************************************
.TP
-.B --management-hold
+.B \-\-management-hold
Start OpenVPN in a hibernating state, until a client
of the management interface explicitly starts it
with the
@@ -2335,45 +2365,45 @@ with the
command.
.\"*********************************************************
.TP
-.B --management-signal
+.B \-\-management-signal
Send SIGUSR1 signal to OpenVPN if management session disconnects.
This is useful when you wish to disconnect an OpenVPN session on
user logoff.
.\"*********************************************************
.TP
-.B --management-log-cache n
+.B \-\-management-log-cache n
Cache the most recent
.B n
lines of log file history for usage
by the management channel.
.\"*********************************************************
.TP
-.B --management-client-auth
+.B \-\-management-client-auth
Gives management interface client the responsibility
to authenticate clients after their client certificate
has been verified. See management-notes.txt in OpenVPN
distribution for detailed notes.
.\"*********************************************************
.TP
-.B --management-client-pf
+.B \-\-management-client-pf
Management interface clients must specify a packet
filter file for each connecting client. See management-notes.txt
in OpenVPN distribution for detailed notes.
.\"*********************************************************
.TP
-.B --management-client-user u
+.B \-\-management-client-user u
When the management interface is listening on a unix domain socket,
only allow connections from user
.B u.
.\"*********************************************************
.TP
-.B --management-client-group g
+.B \-\-management-client-group g
When the management interface is listening on a unix domain socket,
only allow connections from group
.B g.
.\"*********************************************************
.TP
-.B --plugin module-pathname [init-string]
+.B \-\-plugin module-pathname [init-string]
Load plug-in module from the file
.B module-pathname,
passing
@@ -2409,7 +2439,7 @@ the connection to be authenticated.
.SS Server Mode
Starting with OpenVPN 2.0, a multi-client TCP/UDP server mode
is supported, and can be enabled with the
-.B --mode server
+.B \-\-mode server
option. In server mode, OpenVPN will listen on a single
port for incoming client connections. All client
connections will be routed through a single tun or tap
@@ -2419,7 +2449,7 @@ on sufficiently fast hardware. SSL/TLS authentication must
be used in this mode.
.\"*********************************************************
.TP
-.B --server network netmask
+.B \-\-server network netmask
A helper directive designed to simplify the configuration
of OpenVPN's server mode. This directive will set up an
OpenVPN server which will allocate addresses to clients
@@ -2429,7 +2459,7 @@ for use as the server-side endpoint of the local
TUN/TAP interface.
For example,
-.B --server 10.8.0.0 255.255.255.0
+.B \-\-server 10.8.0.0 255.255.255.0
expands as follows:
.nf
@@ -2459,23 +2489,23 @@ expands as follows:
.fi
Don't use
-.B --server
+.B \-\-server
if you are ethernet bridging. Use
-.B --server-bridge
+.B \-\-server-bridge
instead.
.\"*********************************************************
.TP
-.B --server-bridge gateway netmask pool-start-IP pool-end-IP
+.B \-\-server-bridge gateway netmask pool-start-IP pool-end-IP
.TP
-.B --server-bridge ['nogw']
+.B \-\-server-bridge ['nogw']
A helper directive similar to
-.B --server
+.B \-\-server
which is designed to simplify the configuration
of OpenVPN's server mode in ethernet bridging configurations.
If
-.B --server-bridge
+.B \-\-server-bridge
is used without any parameters, it will enable a DHCP-proxy
mode, where connecting OpenVPN clients will receive an IP
address for their TAP adapter from the DHCP server running
@@ -2503,7 +2533,7 @@ IP/netmask on the bridge interface. The
and
.B netmask
parameters to
-.B --server-bridge
+.B \-\-server-bridge
can be set to either the IP/netmask of the
bridge interface, or the IP/netmask of the
default gateway/router on the bridged
@@ -2535,7 +2565,7 @@ push "route-gateway 10.8.0.4"
.fi
In another example,
-.B --server-bridge
+.B \-\-server-bridge
(without parameters) expands as follows:
.nf
@@ -2550,7 +2580,7 @@ push "route-gateway dhcp"
.fi
Or
-.B --server-bridge nogw
+.B \-\-server-bridge nogw
expands as follows:
.nf
@@ -2563,13 +2593,13 @@ tls-server
.fi
.\"*********************************************************
.TP
-.B --push "option"
+.B \-\-push "option"
Push a config file option back to the client for remote
execution. Note that
.B
option
must be enclosed in double quotes (""). The client must specify
-.B --pull
+.B \-\-pull
in its config file. The set of options which can be
pushed is limited by both feasibility and security.
Some options such as those which would execute scripts
@@ -2580,44 +2610,44 @@ cannot be pushed because the client needs to know
them before the connection to the server can be initiated.
This is a partial list of options which can currently be pushed:
-.B --route, --route-gateway, --route-delay, --redirect-gateway,
-.B --ip-win32, --dhcp-option,
-.B --inactive, --ping, --ping-exit, --ping-restart,
-.B --setenv,
-.B --persist-key, --persist-tun, --echo,
-.B --comp-lzo,
-.B --socket-flags,
-.B --sndbuf, --rcvbuf
+.B \-\-route, \-\-route-gateway, \-\-route-delay, \-\-redirect-gateway,
+.B \-\-ip-win32, \-\-dhcp-option,
+.B \-\-inactive, \-\-ping, \-\-ping-exit, \-\-ping-restart,
+.B \-\-setenv,
+.B \-\-persist-key, \-\-persist-tun, \-\-echo,
+.B \-\-comp-lzo,
+.B \-\-socket-flags,
+.B \-\-sndbuf, \-\-rcvbuf
.\"*********************************************************
.TP
-.B --push-reset
+.B \-\-push-reset
Don't inherit the global push list for a specific client instance.
Specify this option in a client-specific context such
as with a
-.B --client-config-dir
+.B \-\-client-config-dir
configuration file. This option will ignore
-.B --push
+.B \-\-push
options at the global config file level.
.\"*********************************************************
.TP
-.B --disable
+.B \-\-disable
Disable a particular client (based on the common name)
from connecting. Don't use this option to disable a client
due to key or password compromise. Use a CRL (certificate
revocation list) instead (see the
-.B --crl-verify
+.B \-\-crl-verify
option).
This option must be associated with a specific client instance,
which means that it must be specified either in a client
instance config file using
-.B --client-config-dir
+.B \-\-client-config-dir
or dynamically generated using a
-.B --client-connect
+.B \-\-client-connect
script.
.\"*********************************************************
.TP
-.B --ifconfig-pool start-IP end-IP [netmask]
+.B \-\-ifconfig-pool start-IP end-IP [netmask]
Set aside a pool of subnets to be
dynamically allocated to connecting clients, similar
to a DHCP server. For tun-style
@@ -2630,7 +2660,7 @@ parameter will also be pushed to clients.
.\"*********************************************************
.TP
-.B --ifconfig-pool-persist file [seconds]
+.B \-\-ifconfig-pool-persist file [seconds]
Persist/unpersist ifconfig-pool
data to
.B file,
@@ -2645,7 +2675,7 @@ IP address assigned to them from the ifconfig-pool.
Maintaining a long-term
association is good for clients because it allows them
to effectively use the
-.B --persist-tun
+.B \-\-persist-tun
option.
.B file
@@ -2666,32 +2696,32 @@ suggestions only, based on past associations between
a common name and IP address. They do not guarantee that the given common
name will always receive the given IP address. If you want guaranteed
assignment, use
-.B --ifconfig-push
+.B \-\-ifconfig-push
.\"*********************************************************
.TP
-.B --ifconfig-pool-linear
+.B \-\-ifconfig-pool-linear
Modifies the
-.B --ifconfig-pool
+.B \-\-ifconfig-pool
directive to
allocate individual TUN interface addresses for
clients rather than /30 subnets. NOTE: This option
is incompatible with Windows clients.
This option is deprecated, and should be replaced with
-.B --topology p2p
+.B \-\-topology p2p
which is functionally equivalent.
.\"*********************************************************
.TP
-.B --ifconfig-push local remote-netmask
+.B \-\-ifconfig-push local remote-netmask
Push virtual IP endpoints for client tunnel,
-overriding the --ifconfig-pool dynamic allocation.
+overriding the \-\-ifconfig-pool dynamic allocation.
The parameters
.B local
and
.B remote-netmask
are set according to the
-.B --ifconfig
+.B \-\-ifconfig
directive which you want to execute on the client machine to
configure the remote end of the tunnel. Note that the parameters
.B local
@@ -2704,13 +2734,13 @@ on the server at the time of client connection.
This option must be associated with a specific client instance,
which means that it must be specified either in a client
instance config file using
-.B --client-config-dir
+.B \-\-client-config-dir
or dynamically generated using a
-.B --client-connect
+.B \-\-client-connect
script.
Remember also to include a
-.B --route
+.B \-\-route
directive in the main OpenVPN config file which encloses
.B local,
so that the kernel will know to route it
@@ -2720,23 +2750,23 @@ OpenVPN's internal client IP address selection algorithm works as
follows:
.B 1
--- Use
-.B --client-connect script
+\-\- Use
+.B \-\-client-connect script
generated file for static IP (first choice).
.br
.B 2
--- Use
-.B --client-config-dir
+\-\- Use
+.B \-\-client-config-dir
file for static IP (next choice).
.br
.B 3
--- Use
-.B --ifconfig-pool
+\-\- Use
+.B \-\-ifconfig-pool
allocation for dynamic IP (last choice).
.br
.\"*********************************************************
.TP
-.B --iroute network [netmask]
+.B \-\-iroute network [netmask]
Generate an internal route to a specific
client. The
.B netmask
@@ -2747,36 +2777,36 @@ the server to a particular client, regardless
of where the client is connecting from. Remember
that you must also add the route to the system
routing table as well (such as by using the
-.B --route
+.B \-\-route
directive). The reason why two routes are needed
is that the
-.B --route
+.B \-\-route
directive routes the packet from the kernel
to OpenVPN. Once in OpenVPN, the
-.B --iroute
+.B \-\-iroute
directive routes to the specific client.
This option must be specified either in a client
instance config file using
-.B --client-config-dir
+.B \-\-client-config-dir
or dynamically generated using a
-.B --client-connect
+.B \-\-client-connect
script.
The
-.B --iroute
+.B \-\-iroute
directive also has an important interaction with
-.B --push
+.B \-\-push
"route ...".
-.B --iroute
+.B \-\-iroute
essentially defines a subnet which is owned by a
particular client (we will call this client A).
If you would like other clients to be able to reach A's
subnet, you can use
-.B --push
+.B \-\-push
"route ..."
together with
-.B --client-to-client
+.B \-\-client-to-client
to effect this. In order for all clients to see
A's subnet, OpenVPN must push this route to all clients
EXCEPT for A, since the subnet is already owned by A.
@@ -2785,11 +2815,11 @@ not pushing a route to a client
if it matches one of the client's iroutes.
.\"*********************************************************
.TP
-.B --client-to-client
+.B \-\-client-to-client
Because the OpenVPN server mode handles multiple clients
through a single tun or tap interface, it is effectively
a router. The
-.B --client-to-client
+.B \-\-client-to-client
flag tells OpenVPN to internally route client-to-client
traffic rather than pushing all client-originating traffic
to the TUN/TAP interface.
@@ -2801,20 +2831,20 @@ if you want to firewall tunnel traffic using
custom, per-client rules.
.\"*********************************************************
.TP
-.B --duplicate-cn
+.B \-\-duplicate-cn
Allow multiple clients with the same common name to concurrently connect.
In the absence of this option, OpenVPN will disconnect a client instance
upon connection of a new client having the same common name.
.\"*********************************************************
.TP
-.B --client-connect script
+.B \-\-client-connect script
Run
.B script
on client connection. The script is passed the common name
and IP address of the just-authenticated client
as environmental variables (see environmental variable section
below). The script is also passed
-the pathname of a not-yet-created temporary file as $1
+the pathname of a freshly created temporary file as $1
(i.e. the first command line argument), to be used by the script
to pass dynamically generated config file directives back to OpenVPN.
@@ -2823,7 +2853,7 @@ to be applied on the server when the client connects,
it should write it to the file named by $1.
See the
-.B --client-config-dir
+.B \-\-client-config-dir
option below for options which
can be legally used in a dynamically generated config file.
@@ -2835,18 +2865,18 @@ returns a non-zero error status, it will cause the client
to be disconnected.
.\"*********************************************************
.TP
-.B --client-disconnect
+.B \-\-client-disconnect
Like
-.B --client-connect
+.B \-\-client-connect
but called on client instance shutdown. Will not be called
unless the
-.B --client-connect
+.B \-\-client-connect
script and plugins (if defined)
were previously called on this instance with
successful (0) status returns.
The exception to this rule is if the
-.B --client-disconnect
+.B \-\-client-disconnect
script or plugins are cascaded, and at least one client-connect
function succeeded, then ALL of the client-disconnect functions for
scripts and plugins will be called on client instance object deletion,
@@ -2855,7 +2885,7 @@ an error status.
.B
.\"*********************************************************
.TP
-.B --client-config-dir dir
+.B \-\-client-config-dir dir
Specify a directory
.B dir
for custom client config files. After
@@ -2869,9 +2899,9 @@ will instead try to open and parse a default file called
This file can specify a fixed IP address for a given
client using
-.B --ifconfig-push,
+.B \-\-ifconfig-push,
as well as fixed subnets owned by the client using
-.B --iroute.
+.B \-\-iroute.
One of the useful properties of this option is that it
allows client configuration files to be conveniently
@@ -2880,28 +2910,28 @@ without needing to restart the server.
The following
options are legal in a client-specific context:
-.B --push, --push-reset, --iroute, --ifconfig-push,
+.B \-\-push, \-\-push-reset, \-\-iroute, \-\-ifconfig-push,
and
-.B --config.
+.B \-\-config.
.\"*********************************************************
.TP
-.B --ccd-exclusive
+.B \-\-ccd-exclusive
Require, as a
condition of authentication, that a connecting client has a
-.B --client-config-dir
+.B \-\-client-config-dir
file.
.\"*********************************************************
.TP
-.B --tmp-dir dir
+.B \-\-tmp-dir dir
Specify a directory
.B dir
for temporary files. This directory will be used by
-.B --client-connect
+.B \-\-client-connect
scripts to dynamically generate client-specific
configuration files.
.\"*********************************************************
.TP
-.B --hash-size r v
+.B \-\-hash-size r v
Set the size of the real address hash table to
.B r
and the virtual address table to
@@ -2909,13 +2939,13 @@ and the virtual address table to
By default, both tables are sized at 256 buckets.
.\"*********************************************************
.TP
-.B --bcast-buffers n
+.B \-\-bcast-buffers n
Allocate
.B n
buffers for broadcast datagrams (default=256).
.\"*********************************************************
.TP
-.B --tcp-queue-limit n
+.B \-\-tcp-queue-limit n
Maximum number of output packets queued before TCP (default=64).
When OpenVPN is tunneling data from a TUN/TAP device to a
@@ -2927,7 +2957,7 @@ OpenVPN will start to drop outgoing packets directed
at this client.
.\"*********************************************************
.TP
-.B --tcp-nodelay
+.B \-\-tcp-nodelay
This macro sets the TCP_NODELAY socket flag on the server
as well as pushes it to connecting clients. The TCP_NODELAY
flag disables the Nagle algorithm on TCP sockets causing
@@ -2950,13 +2980,13 @@ The macro expands as follows:
.fi
.\"*********************************************************
.TP
-.B --max-clients n
+.B \-\-max-clients n
Limit server to a maximum of
.B n
concurrent clients.
.\"*********************************************************
.TP
-.B --max-routes-per-client n
+.B \-\-max-routes-per-client n
Allow a maximum of
.B n
internal routes per client (default=256).
@@ -2966,9 +2996,9 @@ server with packets appearing to come from many unique MAC addresses,
forcing the server to deplete
virtual memory as its internal routing table expands.
This directive can be used in a
-.B --client-config-dir
+.B \-\-client-config-dir
file or auto-generated by a
-.B --client-connect
+.B \-\-client-connect
script to override the global value for a particular client.
Note that this
@@ -2976,7 +3006,7 @@ directive affects OpenVPN's internal routing table, not the
kernel routing table.
.\"*********************************************************
.TP
-.B --connect-freq n sec
+.B \-\-connect-freq n sec
Allow a maximum of
.B n
new connections per
@@ -2990,12 +3020,12 @@ DoS scenario, legitimate connections might also be refused.
For the best protection against DoS attacks in server mode,
use
-.B --proto udp
+.B \-\-proto udp
and
-.B --tls-auth.
+.B \-\-tls-auth.
.\"*********************************************************
.TP
-.B --learn-address cmd
+.B \-\-learn-address cmd
Run script or shell command
.B cmd
to validate client virtual addresses or routes.
@@ -3003,19 +3033,19 @@ to validate client virtual addresses or routes.
.B cmd
will be executed with 3 parameters:
-.B [1] operation --
+.B [1] operation \-\-
"add", "update", or "delete" based on whether or not
the address is being added to, modified, or deleted from
OpenVPN's internal routing table.
.br
-.B [2] address --
+.B [2] address \-\-
The address being learned or unlearned. This can be
an IPv4 address such as "198.162.10.14", an IPv4 subnet
such as "198.162.10.0/24", or an ethernet MAC address (when
-.B --dev tap
+.B \-\-dev tap
is being used) such as "00:FF:01:02:03:04".
.br
-.B [3] common name --
+.B [3] common name \-\-
The common name on the certificate associated with the
client linked to this address. Only present for "add"
or "update" operations, not "delete".
@@ -3035,7 +3065,7 @@ policies with regard to the client's high-level common name,
rather than the low level client virtual addresses.
.\"*********************************************************
.TP
-.B --auth-user-pass-verify script method
+.B \-\-auth-user-pass-verify script method
Require the client to provide a username/password (possibly
in addition to a client certificate) for authentication.
@@ -3066,10 +3096,10 @@ will be passed as an argument to
and the file will be automatically deleted by OpenVPN after
the script returns. The location of the temporary file is
controlled by the
-.B --tmp-dir
+.B \-\-tmp-dir
option, and will default to the current directory if unspecified.
For security, consider setting
-.B --tmp-dir
+.B \-\-tmp-dir
to a volatile storage medium such as
.B /dev/shm
(if available) to prevent the username/password file from touching the hard drive.
@@ -3101,7 +3131,7 @@ For a sample script that performs PAM authentication, see
in the OpenVPN source distribution.
.\"*********************************************************
.TP
-.B --opt-verify
+.B \-\-opt-verify
Clients that connect with options that are incompatible
with those of the server will be disconnected.
@@ -3111,16 +3141,16 @@ comp-lzo, fragment, keydir, cipher, auth, keysize, secret,
no-replay, no-iv, tls-auth, key-method, tls-server, and tls-client.
This option requires that
-.B --disable-occ
+.B \-\-disable-occ
NOT be used.
.\"*********************************************************
.TP
-.B --auth-user-pass-optional
+.B \-\-auth-user-pass-optional
Allow connections by clients that do not specify a username/password.
Normally, when
-.B --auth-user-pass-verify
+.B \-\-auth-user-pass-verify
or
-.B --management-client-auth
+.B \-\-management-client-auth
is specified (or an authentication plugin module), the
OpenVPN server daemon will require connecting clients to specify a
username and password. This option makes the submission of a username/password
@@ -3133,35 +3163,35 @@ to empty strings (""). The authentication module/script MUST have logic
to detect this condition and respond accordingly.
.\"*********************************************************
.TP
-.B --client-cert-not-required
+.B \-\-client-cert-not-required
Don't require client certificate, client will authenticate
using username/password only. Be aware that using this directive
is less secure than requiring certificates from all clients.
If you use this directive, the
entire responsibility of authentication will rest on your
-.B --auth-user-pass-verify
+.B \-\-auth-user-pass-verify
script, so keep in mind that bugs in your script
could potentially compromise the security of your VPN.
If you don't use this directive, but you also specify an
-.B --auth-user-pass-verify
+.B \-\-auth-user-pass-verify
script, then OpenVPN will perform double authentication. The
client certificate verification AND the
-.B --auth-user-pass-verify
+.B \-\-auth-user-pass-verify
script will need to succeed in order for a client to be
authenticated and accepted onto the VPN.
.\"*********************************************************
.TP
-.B --username-as-common-name
+.B \-\-username-as-common-name
For
-.B --auth-user-pass-verify
+.B \-\-auth-user-pass-verify
authentication, use
the authenticated username as the common name,
rather than the common name from the client cert.
.\"*********************************************************
.TP
-.B --no-name-remapping
+.B \-\-no-name-remapping
Allow Common Name, X509 Subject, and username strings to include
any printable character including space, but excluding control
characters such as tab, newline, and carriage-return.
@@ -3182,7 +3212,7 @@ disable the remapping feature. Don't use this option unless you
know what you are doing!
.\"*********************************************************
.TP
-.B --port-share host port
+.B \-\-port-share host port
When run in TCP server mode, share the OpenVPN port with
another application, such as an HTTPS server. If OpenVPN
senses a connection to its port which is using a non-OpenVPN
@@ -3197,13 +3227,13 @@ Not implemented on Windows.
.SS Client Mode
Use client mode when connecting to an OpenVPN server
which has
-.B --server, --server-bridge,
+.B \-\-server, \-\-server-bridge,
or
-.B --mode server
+.B \-\-mode server
in it's configuration.
.\"*********************************************************
.TP
-.B --client
+.B \-\-client
A helper directive designed to simplify the configuration
of OpenVPN's client mode. This directive is equivalent to:
@@ -3217,33 +3247,33 @@ of OpenVPN's client mode. This directive is equivalent to:
.fi
.\"*********************************************************
.TP
-.B --pull
+.B \-\-pull
This option must be used on a client which is connecting
to a multi-client server. It indicates to OpenVPN that it
should accept options pushed by the server, provided they
are part of the legal set of pushable options (note that the
-.B --pull
+.B \-\-pull
option is implied by
-.B --client
+.B \-\-client
).
In particular,
-.B --pull
+.B \-\-pull
allows the server to push routes to the client, so you should
not use
-.B --pull
+.B \-\-pull
or
-.B --client
+.B \-\-client
in situations where you don't trust the server to have control
over the client's routing table.
.\"*********************************************************
.TP
-.B --auth-user-pass [up]
+.B \-\-auth-user-pass [up]
Authenticate with server using username/password.
.B up
is a file containing username/password on 2 lines (Note: OpenVPN
will only read passwords from a file if it has been built
-with the --enable-password-save configure option, or on Windows
+with the \-\-enable-password-save configure option, or on Windows
by defining ENABLE_PASSWORD_SAVE in config-win32.h).
If
@@ -3252,12 +3282,12 @@ is omitted, username/password will be prompted from the
console.
The server configuration must specify an
-.B --auth-user-pass-verify
+.B \-\-auth-user-pass-verify
script to verify the username/password provided by
the client.
.\"*********************************************************
.TP
-.B --auth-retry type
+.B \-\-auth-retry type
Controls how OpenVPN responds to username/password verification
errors such as the client-side response to an AUTH_FAILED message from the server
or verification failure of the private key password.
@@ -3268,60 +3298,61 @@ of error.
An AUTH_FAILED message is generated by the server if the client
fails
-.B --auth-user-pass
+.B \-\-auth-user-pass
authentication, or if the server-side
-.B --client-connect
+.B \-\-client-connect
script returns an error status when the client
tries to connect.
.B type
can be one of:
-.B none --
+.B none \-\-
Client will exit with a fatal error (this is the default).
.br
-.B nointeract --
+.B nointeract \-\-
Client will retry the connection without requerying for an
-.B --auth-user-pass
+.B \-\-auth-user-pass
username/password. Use this option for unattended clients.
.br
-.B interact --
+.B interact \-\-
Client will requery for an
-.B --auth-user-pass
+.B \-\-auth-user-pass
username/password and/or private key password before attempting a reconnection.
Note that while this option cannot be pushed, it can be controlled
from the management interface.
.\"*********************************************************
.TP
-.B --server-poll-timeout n
+.B \-\-server-poll-timeout n
when polling possible remote servers to connect to
in a round-robin fashion, spend no more than
.B n
seconds waiting for a response before trying the next server.
.\"*********************************************************
.TP
-.B --explicit-exit-notify [n]
+.B \-\-explicit-exit-notify [n]
In UDP client mode or point-to-point mode, send server/peer an exit notification
if tunnel is restarted or OpenVPN process is exited. In client mode, on
exit/restart, this
option will tell the server to immediately close its client instance object
rather than waiting for a timeout. The
.B n
-parameter (default=1) controls the maximum number of retries that the client
-will attempt to resend the exit notification message.
+parameter (default=1) controls the maximum number of attempts that the client
+will try to resend the exit notification message. OpenVPN will not send any exit
+notifications unless this option is enabled.
.\"*********************************************************
.SS Data Channel Encryption Options:
These options are meaningful for both Static & TLS-negotiated key modes
(must be compatible between peers).
.\"*********************************************************
.TP
-.B --secret file [direction]
+.B \-\-secret file [direction]
Enable Static Key encryption mode (non-TLS).
Use pre-shared secret
.B file
which was generated with
-.B --genkey.
+.B \-\-genkey.
The optional
.B direction
@@ -3352,7 +3383,7 @@ supports the
.B direction
parameter, will also support 2048 bit key file generation
using the
-.B --genkey
+.B \-\-genkey
option.
Static key encryption mode has certain advantages,
@@ -3382,7 +3413,7 @@ would see nothing
but random-looking data.
.\"*********************************************************
.TP
-.B --auth alg
+.B \-\-auth alg
Authenticate packets with HMAC using message
digest algorithm
.B alg.
@@ -3397,7 +3428,7 @@ OpenVPN's usage of HMAC is to first encrypt a packet, then HMAC the resulting ci
In static-key encryption mode, the HMAC key
is included in the key file generated by
-.B --genkey.
+.B \-\-genkey.
In TLS mode, the HMAC key is dynamically generated and shared
between peers via the TLS control channel. If OpenVPN receives a packet with
a bad HMAC it will drop the packet.
@@ -3410,7 +3441,7 @@ For more information on HMAC see
.I http://www.cs.ucsd.edu/users/mihir/papers/hmac.html
.\"*********************************************************
.TP
-.B --cipher alg
+.B \-\-cipher alg
Encrypt packets with cipher algorithm
.B alg.
The default is
@@ -3425,7 +3456,7 @@ For more information on blowfish, see
To see other ciphers that are available with
OpenVPN, use the
-.B --show-ciphers
+.B \-\-show-ciphers
option.
OpenVPN supports the CBC, CFB, and OFB cipher modes,
@@ -3437,10 +3468,10 @@ Set
to disable encryption.
.\"*********************************************************
.TP
-.B --keysize n
+.B \-\-keysize n
Size of cipher key in bits (optional).
If unspecified, defaults to cipher-specific default. The
-.B --show-ciphers
+.B \-\-show-ciphers
option (see below) shows all available OpenSSL ciphers,
their default key sizes, and whether the key size can
be changed. Use care in changing a cipher's default
@@ -3450,7 +3481,7 @@ larger key may offer no real guarantee of greater
security, or may even reduce security.
.\"*********************************************************
.TP
-.B --prng alg [nsl]
+.B \-\-prng alg [nsl]
(Advanced) For PRNG (Pseudo-random number generator),
use digest algorithm
.B alg
@@ -3465,19 +3496,19 @@ to disable the PRNG and use the OpenSSL RAND_bytes function
instead for all of OpenVPN's pseudo-random number needs.
.\"*********************************************************
.TP
-.B --engine [engine-name]
+.B \-\-engine [engine-name]
Enable OpenSSL hardware-based crypto engine functionality.
If
.B engine-name
is specified,
use a specific crypto engine. Use the
-.B --show-engines
+.B \-\-show-engines
standalone option to list the crypto engines which are
supported by OpenSSL.
.\"*********************************************************
.TP
-.B --no-replay
+.B \-\-no-replay
(Advanced) Disable OpenVPN's protection against replay attacks.
Don't use this option unless you are prepared to make
a tradeoff of greater efficiency in exchange for less
@@ -3521,7 +3552,7 @@ algorithm used
by IPSec.
.\"*********************************************************
.TP
-.B --replay-window n [t]
+.B \-\-replay-window n [t]
Use a replay protection sliding-window of size
.B n
and a time window of
@@ -3536,9 +3567,9 @@ is 15 seconds.
This option is only relevant in UDP mode, i.e.
when either
-.B --proto udp
+.B \-\-proto udp
is specifed, or no
-.B --proto
+.B \-\-proto
option is specified.
When OpenVPN tunnels IP packets over UDP, there is the possibility that
@@ -3550,7 +3581,7 @@ the TCP/IP protocol stack, provided they satisfy several constraints.
.B (a)
The packet cannot be a replay (unless
-.B --no-replay
+.B \-\-no-replay
is specified, which disables replay protection altogether).
.B (b)
@@ -3572,7 +3603,7 @@ a larger value for
Satellite links in particular often require this.
If you run OpenVPN at
-.B --verb 4,
+.B \-\-verb 4,
you will see the message "Replay-window backtrack occurred [x]"
every time the maximum sequence number backtrack seen thus far
increases. This can be used to calibrate
@@ -3608,7 +3639,7 @@ parameters of what is to be expected from the physical IP layer. The problem
is easily fixed by simply using TCP as the VPN transport layer.
.\"*********************************************************
.TP
-.B --mute-replay-warnings
+.B \-\-mute-replay-warnings
Silence the output of replay warnings, which are a common
false alarm on WiFi networks. This option preserves
the security of the replay protection code without
@@ -3616,7 +3647,7 @@ the verbosity associated with warnings about duplicate
packets.
.\"*********************************************************
.TP
-.B --replay-persist file
+.B \-\-replay-persist file
Persist replay-protection state across sessions using
.B file
to save and reload the state.
@@ -3624,7 +3655,7 @@ to save and reload the state.
This option will strengthen protection against replay attacks,
especially when you are using OpenVPN in a dynamic context (such
as with
-.B --inetd)
+.B \-\-inetd)
when OpenVPN sessions are frequently started and stopped.
This option will keep a disk copy of the current replay protection
@@ -3635,12 +3666,12 @@ which were already received by the prior session.
This option only makes sense when replay protection is enabled
(the default) and you are using either
-.B --secret
+.B \-\-secret
(shared-secret key mode) or TLS mode with
-.B --tls-auth.
+.B \-\-tls-auth.
.\"*********************************************************
.TP
-.B --no-iv
+.B \-\-no-iv
(Advanced) Disable OpenVPN's use of IV (cipher initialization vector).
Don't use this option unless you are prepared to make
a tradeoff of greater efficiency in exchange for less
@@ -3661,24 +3692,24 @@ space-saving optimization that uses the unique identifier for
datagram replay protection as the IV.
.\"*********************************************************
.TP
-.B --test-crypto
+.B \-\-test-crypto
Do a self-test of OpenVPN's crypto options by encrypting and
decrypting test packets using the data channel encryption options
specified above. This option does not require a peer to function,
and therefore can be specified without
-.B --dev
+.B \-\-dev
or
-.B --remote.
+.B \-\-remote.
The typical usage of
-.B --test-crypto
+.B \-\-test-crypto
would be something like this:
-.B openvpn --test-crypto --secret key
+.B openvpn \-\-test-crypto \-\-secret key
or
-.B openvpn --test-crypto --secret key --verb 9
+.B openvpn \-\-test-crypto \-\-secret key \-\-verb 9
This option is very useful to test OpenVPN after it has been ported to
a new platform, or to isolate problems in the compiler, OpenSSL
@@ -3702,17 +3733,17 @@ including certificate-based authentication and Diffie Hellman forward secrecy.
To use TLS mode, each peer that runs OpenVPN should have its own local
certificate/key pair (
-.B --cert
+.B \-\-cert
and
-.B --key
+.B \-\-key
), signed by the root certificate which is specified
in
-.B --ca.
+.B \-\-ca.
When two OpenVPN peers connect, each presents its local certificate to the
other. Each peer will then check that its partner peer presented a
certificate which was signed by the master root certificate as specified in
-.B --ca.
+.B \-\-ca.
If that check on both peers succeeds, then the TLS negotiation
will succeed, both OpenVPN
@@ -3729,18 +3760,18 @@ The easy-rsa package is also rendered in web form here:
.I http://openvpn.net/easyrsa.html
.\"*********************************************************
.TP
-.B --tls-server
+.B \-\-tls-server
Enable TLS and assume server role during TLS handshake. Note that
OpenVPN is designed as a peer-to-peer application. The designation
of client or server is only for the purpose of negotiating the TLS
control channel.
.\"*********************************************************
.TP
-.B --tls-client
+.B \-\-tls-client
Enable TLS and assume client role during TLS handshake.
.\"*********************************************************
.TP
-.B --ca file
+.B \-\-ca file
Certificate authority (CA) file in .pem format, also referred to as the
.I root
certificate. This file can have multiple
@@ -3762,10 +3793,10 @@ production environment, since by virtue of the fact that
they are distributed with OpenVPN, they are totally insecure.
.\"*********************************************************
.TP
-.B --dh file
+.B \-\-dh file
File containing Diffie Hellman parameters
in .pem format (required for
-.B --tls-server
+.B \-\-tls-server
only). Use
.B openssl dhparam -out dh1024.pem 1024
@@ -3775,15 +3806,15 @@ included with the OpenVPN distribution. Diffie Hellman parameters
may be considered public.
.\"*********************************************************
.TP
-.B --cert file
-Local peer's signed certificate in .pem format -- must be signed
+.B \-\-cert file
+Local peer's signed certificate in .pem format \-\- must be signed
by a certificate authority whose certificate is in
-.B --ca file.
+.B \-\-ca file.
Each peer in an OpenVPN link running in TLS mode should have its own
certificate and private key file. In addition, each certificate should
have been signed by the key of a certificate
authority whose public key resides in the
-.B --ca
+.B \-\-ca
certificate authority file.
You can easily make your own certificate authority (see above) or pay money
to use a commercial service such as thawte.com (in which case you will be
@@ -3808,7 +3839,7 @@ Note that the
command reads the location of the certificate authority key from its
configuration file such as
.B /usr/share/ssl/openssl.cnf
--- note also
+\-\- note also
that for certificate authority functions, you must set up the files
.B index.txt
(may be empty) and
@@ -3819,90 +3850,90 @@ that for certificate authority functions, you must set up the files
).
.\"*********************************************************
.TP
-.B --key file
+.B \-\-key file
Local peer's private key in .pem format. Use the private key which was generated
when you built your peer's certificate (see
.B -cert file
above).
.\"*********************************************************
.TP
-.B --pkcs12 file
+.B \-\-pkcs12 file
Specify a PKCS #12 file containing local private key,
local certificate, and root CA certificate.
This option can be used instead of
-.B --ca, --cert,
+.B \-\-ca, \-\-cert,
and
-.B --key.
+.B \-\-key.
.\"*********************************************************
.TP
-.B --pkcs11-cert-private [0|1]...
+.B \-\-pkcs11-cert-private [0|1]...
Set if access to certificate object should be performed after login.
Every provider has its own setting.
.\"*********************************************************
.TP
-.B --pkcs11-id name
+.B \-\-pkcs11-id name
Specify the serialized certificate id to be used. The id can be gotten
by the standalone
-.B --show-pkcs11-ids
+.B \-\-show-pkcs11-ids
option.
.\"*********************************************************
.TP
-.B --pkcs11-id-management
+.B \-\-pkcs11-id-management
Acquire PKCS#11 id from management interface. In this case a NEED-STR 'pkcs11-id-request'
real-time message will be triggered, application may use pkcs11-id-count command to
retrieve available number of certificates, and pkcs11-id-get command to retrieve certificate
id and certificate body.
.\"*********************************************************
.TP
-.B --pkcs11-pin-cache seconds
+.B \-\-pkcs11-pin-cache seconds
Specify how many seconds the PIN can be cached, the default is until the token is removed.
.\"*********************************************************
.TP
-.B --pkcs11-protected-authentication [0|1]...
+.B \-\-pkcs11-protected-authentication [0|1]...
Use PKCS#11 protected authentication path, useful for biometric and external
keypad devices.
Every provider has its own setting.
.\"*********************************************************
.TP
-.B --pkcs11-providers provider...
+.B \-\-pkcs11-providers provider...
Specify a RSA Security Inc. PKCS #11 Cryptographic Token Interface (Cryptoki) providers
to load.
This option can be used instead of
-.B --cert, --key,
+.B \-\-cert, \-\-key,
and
-.B --pkcs12.
+.B \-\-pkcs12.
.\"*********************************************************
.TP
-.B --pkcs11-private-mode mode...
+.B \-\-pkcs11-private-mode mode...
Specify which method to use in order to perform private key operations.
A different mode can be specified for each provider.
Mode is encoded as hex number, and can be a mask one of the following:
.B 0
-(default) -- Try to determind automatically.
+(default) \-\- Try to determind automatically.
.br
.B 1
--- Use sign.
+\-\- Use sign.
.br
.B 2
--- Use sign recover.
+\-\- Use sign recover.
.br
.B 4
--- Use decrypt.
+\-\- Use decrypt.
.br
.B 8
--- Use unwrap.
+\-\- Use unwrap.
.br
.\"*********************************************************
.TP
-.B --cryptoapicert select-string
+.B \-\-cryptoapicert select-string
Load the certificate and private key from the
Windows Certificate System Store (Windows Only).
Use this option instead of
-.B --cert
+.B \-\-cert
and
-.B --key.
+.B \-\-key.
This makes
it possible to use any smart card, supported by Windows, but also any
@@ -3928,7 +3959,7 @@ Certificate Store GUI.
.\"*********************************************************
.TP
-.B --key-method m
+.B \-\-key-method m
Use data channel key negotiation method
.B m.
The key method must match on both sides of the connection.
@@ -3956,16 +3987,16 @@ of keying occur:
of the connection producing certificates and verifying the certificate
(or other authentication info provided) of
the other side. The
-.B --key-method
+.B \-\-key-method
parameter has no effect on this process.
(2) After the TLS connection is established, the tunnel session keys are
separately negotiated over the existing secure TLS channel. Here,
-.B --key-method
+.B \-\-key-method
determines the derivation of the tunnel session keys.
.\"*********************************************************
.TP
-.B --tls-cipher l
+.B \-\-tls-cipher l
A list
.B l
of allowable TLS ciphers delimited by a colon (":").
@@ -3975,11 +4006,11 @@ version rollback attack where a man-in-the-middle attacker tries
to force two peers to negotiate to the lowest level
of security they both support.
Use
-.B --show-tls
+.B \-\-show-tls
to see a list of supported TLS ciphers.
.\"*********************************************************
.TP
-.B --tls-timeout n
+.B \-\-tls-timeout n
Packet retransmit timeout on TLS control channel
if no acknowledgment from remote within
.B n
@@ -3996,7 +4027,7 @@ the higher level network protocols running on top of the tunnel
such as TCP expect this role to be left to them.
.\"*********************************************************
.TP
-.B --reneg-bytes n
+.B \-\-reneg-bytes n
Renegotiate data channel key after
.B n
bytes sent or received (disabled by default).
@@ -4006,13 +4037,13 @@ a number of seconds. A key renegotiation will be forced
if any of these three criteria are met by either peer.
.\"*********************************************************
.TP
-.B --reneg-pkts n
+.B \-\-reneg-pkts n
Renegotiate data channel key after
.B n
packets sent and received (disabled by default).
.\"*********************************************************
.TP
-.B --reneg-sec n
+.B \-\-reneg-sec n
Renegotiate data channel key after
.B n
seconds (default=3600).
@@ -4023,16 +4054,16 @@ cause the end user to be challenged to reauthorize once per hour.
Also, keep in mind that this option can be used on both the client and server,
and whichever uses the lower value will be the one to trigger the renegotiation.
A common mistake is to set
-.B --reneg-sec
+.B \-\-reneg-sec
to a higher value on either the client or server, while the other side of the connection
is still using the default value of 3600 seconds, meaning that the renegotiation will
-still occur once per 3600 seconds. The solution is to increase --reneg-sec on both the
+still occur once per 3600 seconds. The solution is to increase \-\-reneg-sec on both the
client and server, or set it to 0 on one side of the connection (to disable), and to
your chosen value on the other side.
.\"*********************************************************
.TP
-.B --hand-window n
-Handshake Window -- the TLS-based key exchange must finalize within
+.B \-\-hand-window n
+Handshake Window \-\- the TLS-based key exchange must finalize within
.B n
seconds
of handshake initiation by any peer (default = 60 seconds).
@@ -4040,47 +4071,47 @@ If the handshake fails
we will attempt to reset our connection with our peer and try again.
Even in the event of handshake failure we will still use
our expiring key for up to
-.B --tran-window
+.B \-\-tran-window
seconds to maintain continuity of transmission of tunnel
data.
.\"*********************************************************
.TP
-.B --tran-window n
-Transition window -- our old key can live this many seconds
+.B \-\-tran-window n
+Transition window \-\- our old key can live this many seconds
after a new a key renegotiation begins (default = 3600 seconds).
This feature allows for a graceful transition from old to new
key, and removes the key renegotiation sequence from the critical
path of tunnel data forwarding.
.\"*********************************************************
.TP
-.B --single-session
+.B \-\-single-session
After initially connecting to a remote peer, disallow any new connections.
Using this
option means that a remote peer cannot connect, disconnect, and then
reconnect.
If the daemon is reset by a signal or
-.B --ping-restart,
+.B \-\-ping-restart,
it will allow one new connection.
-.B --single-session
+.B \-\-single-session
can be used with
-.B --ping-exit
+.B \-\-ping-exit
or
-.B --inactive
+.B \-\-inactive
to create a single dynamic session that will exit when finished.
.\"*********************************************************
.TP
-.B --tls-exit
+.B \-\-tls-exit
Exit on TLS negotiation failure.
.\"*********************************************************
.TP
-.B --tls-auth file [direction]
+.B \-\-tls-auth file [direction]
Add an additional layer of HMAC authentication on top of the TLS
control channel to protect against DoS attacks.
In a nutshell,
-.B --tls-auth
+.B \-\-tls-auth
enables a kind of "HMAC firewall" on OpenVPN's TCP/UDP port,
where TLS control channel packets
bearing an incorrect HMAC signature can be dropped immediately without
@@ -4091,7 +4122,7 @@ response.
.B (1)
An OpenVPN static key file generated by
-.B --genkey
+.B \-\-genkey
(required if
.B direction
parameter is used).
@@ -4109,19 +4140,19 @@ OpenVPN will first try format (1), and if the file fails to parse as
a static key file, format (2) will be used.
See the
-.B --secret
+.B \-\-secret
option for more information on the optional
.B direction
parameter.
-.B --tls-auth
+.B \-\-tls-auth
is recommended when you are running OpenVPN in a mode where
it is listening for packets from any IP address, such as when
-.B --remote
+.B \-\-remote
is not specified, or
-.B --remote
+.B \-\-remote
is specified with
-.B --float.
+.B \-\-float.
The rationale for
this feature is as follows. TLS requires a multi-packet exchange
@@ -4148,7 +4179,7 @@ An important rule of thumb in reducing vulnerability to DoS attacks is to
minimize the amount of resources a potential, but as yet unauthenticated,
client is able to consume.
-.B --tls-auth
+.B \-\-tls-auth
does this by signing every TLS control channel packet with an HMAC signature,
including packets which are sent before the TLS level has had a chance
to authenticate the peer.
@@ -4156,20 +4187,20 @@ The result is that packets without
the correct signature can be dropped immediately upon reception,
before they have a chance to consume additional system resources
such as by initiating a TLS handshake.
-.B --tls-auth
+.B \-\-tls-auth
can be strengthened by adding the
-.B --replay-persist
+.B \-\-replay-persist
option which will keep OpenVPN's replay protection state
in a file so that it is not lost across restarts.
It should be emphasized that this feature is optional and that the
passphrase/key file used with
-.B --tls-auth
+.B \-\-tls-auth
gives a peer nothing more than the power to initiate a TLS
handshake. It is not used to encrypt or authenticate any tunnel data.
.\"*********************************************************
.TP
-.B --askpass [file]
+.B \-\-askpass [file]
Get certificate password from console or
.B file
before we daemonize.
@@ -4178,7 +4209,7 @@ For the extremely
security conscious, it is possible to protect your private key with
a password. Of course this means that every time the OpenVPN
daemon is started you must be there to type the password. The
-.B --askpass
+.B \-\-askpass
option allows you to start OpenVPN from the command line. It will
query you for a password before it daemonizes. To protect a private
key with a password you should omit the
@@ -4195,15 +4226,15 @@ Keep in mind that storing your password in a file
to a certain extent invalidates the extra security provided by
using an encrypted key (Note: OpenVPN
will only read passwords from a file if it has been built
-with the --enable-password-save configure option, or on Windows
+with the \-\-enable-password-save configure option, or on Windows
by defining ENABLE_PASSWORD_SAVE in config-win32.h).
.\"*********************************************************
.TP
-.B --auth-nocache
+.B \-\-auth-nocache
Don't cache
-.B --askpass
+.B \-\-askpass
or
-.B --auth-user-pass
+.B \-\-auth-user-pass
username/passwords in virtual memory.
If specified, this directive will cause OpenVPN to immediately
@@ -4213,19 +4244,19 @@ from stdin, which may be multiple times during the duration of an
OpenVPN session.
This directive does not affect the
-.B --http-proxy
+.B \-\-http-proxy
username/password. It is always cached.
.\"*********************************************************
.TP
-.B --tls-verify cmd
+.B \-\-tls-verify cmd
Execute shell command
.B cmd
to verify the X509 name of a
pending TLS connection that has otherwise passed all other
tests of certification (except for revocation via
-.B --crl-verify
+.B \-\-crl-verify
directive; the revocation test occurs after the
-.B --tls-verify
+.B \-\-tls-verify
test).
.B cmd
@@ -4262,7 +4293,7 @@ See the "Environmental Variables" section below for
additional parameters passed as environmental variables.
.\"*********************************************************
.TP
-.B --tls-export-cert directory
+.B \-\-tls-export-cert directory
Store the certificates the clients uses upon connection to this
directory. This will be done before --tls-verify is called. The
certificates will use a temporary name and will be deleted when
@@ -4270,34 +4301,41 @@ the tls-verify script returns. The file name used for the certificate
is available via the peer_cert environment variable.
.\"*********************************************************
.TP
-.B --tls-remote name
+.B \-\-tls-remote name
Accept connections only from a host with X509 name
or common name equal to
.B name.
The remote host must also pass all other tests
of verification.
+.B NOTE:
+Because tls-remote may test against a common name prefix,
+only use this option when you are using OpenVPN with a custom CA
+certificate that is under your control.
+Never use this option when your client certificates are signed by
+a third party, such as a commercial web CA.
+
Name can also be a common name prefix, for example if you
want a client to only accept connections to "Server-1",
"Server-2", etc., you can simply use
-.B --tls-remote Server
+.B \-\-tls-remote Server
Using a common name prefix is a useful alternative to managing
a CRL (Certificate Revocation List) on the client, since it allows the client
to refuse all certificates except for those associated
with designated servers.
-.B --tls-remote
+.B \-\-tls-remote
is a useful replacement for the
-.B --tls-verify
+.B \-\-tls-verify
option to verify the remote host, because
-.B --tls-remote
+.B \-\-tls-remote
works in a
-.B --chroot
+.B \-\-chroot
environment too.
.\"*********************************************************
.TP
-.B --ns-cert-type client|server
+.B \-\-ns-cert-type client|server
Require that peer certificate was signed with an explicit
.B nsCertType
designation of "client" or "server".
@@ -4312,19 +4350,19 @@ field set to "server".
If the server certificate's nsCertType field is set
to "server", then the clients can verify this with
-.B --ns-cert-type server.
+.B \-\-ns-cert-type server.
This is an important security precaution to protect against
a man-in-the-middle attack where an authorized client
attempts to connect to another client by impersonating the server.
The attack is easily prevented by having clients verify
the server certificate using any one of
-.B --ns-cert-type, --tls-remote,
+.B \-\-ns-cert-type, \-\-tls-remote,
or
-.B --tls-verify.
+.B \-\-tls-verify.
.\"*********************************************************
.TP
-.B --remote-cert-ku v...
+.B \-\-remote-cert-ku v...
Require that peer certificate was signed with an explicit
.B key usage.
@@ -4335,7 +4373,7 @@ The key usage should be encoded in hex, more than one key
usage can be specified.
.\"*********************************************************
.TP
-.B --remote-cert-eku oid
+.B \-\-remote-cert-eku oid
Require that peer certificate was signed with an explicit
.B extended key usage.
@@ -4346,7 +4384,7 @@ The extended key usage should be encoded in oid notation, or
OpenSSL symbolic representation.
.\"*********************************************************
.TP
-.B --remote-cert-tls client|server
+.B \-\-remote-cert-tls client|server
Require that peer certificate was signed with an explicit
.B key usage
and
@@ -4357,18 +4395,18 @@ This is a useful security option for clients, to ensure that
the host they connect to is a designated server.
The
-.B --remote-cert-tls client
+.B \-\-remote-cert-tls client
option is equivalent to
.B
---remote-cert-ku 80 08 88 --remote-cert-eku "TLS Web Client Authentication"
+\-\-remote-cert-ku 80 08 88 \-\-remote-cert-eku "TLS Web Client Authentication"
The key usage is digitalSignature and/or keyAgreement.
The
-.B --remote-cert-tls server
+.B \-\-remote-cert-tls server
option is equivalent to
.B
---remote-cert-ku a0 88 --remote-cert-eku "TLS Web Server Authentication"
+\-\-remote-cert-ku a0 88 \-\-remote-cert-eku "TLS Web Server Authentication"
The key usage is digitalSignature and ( keyEncipherment or keyAgreement ).
@@ -4377,12 +4415,12 @@ a man-in-the-middle attack where an authorized client
attempts to connect to another client by impersonating the server.
The attack is easily prevented by having clients verify
the server certificate using any one of
-.B --remote-cert-tls, --tls-remote,
+.B \-\-remote-cert-tls, \-\-tls-remote,
or
-.B --tls-verify.
+.B \-\-tls-verify.
.\"*********************************************************
.TP
-.B --crl-verify crl
+.B \-\-crl-verify crl
Check peer certificate against the file
.B crl
in PEM format.
@@ -4402,28 +4440,28 @@ if the root certificate key itself was compromised.
.SS SSL Library information:
.\"*********************************************************
.TP
-.B --show-ciphers
+.B \-\-show-ciphers
(Standalone)
Show all cipher algorithms to use with the
-.B --cipher
+.B \-\-cipher
option.
.\"*********************************************************
.TP
-.B --show-digests
+.B \-\-show-digests
(Standalone)
Show all message digest algorithms to use with the
-.B --auth
+.B \-\-auth
option.
.\"*********************************************************
.TP
-.B --show-tls
+.B \-\-show-tls
(Standalone)
Show all TLS ciphers (TLS used only as a control channel). The TLS
ciphers will be sorted from highest preference (most secure) to
lowest.
.\"*********************************************************
.TP
-.B --show-engines
+.B \-\-show-engines
(Standalone)
Show currently available hardware-based crypto acceleration
engines supported by the OpenSSL library.
@@ -4432,18 +4470,18 @@ engines supported by the OpenSSL library.
Used only for non-TLS static key encryption mode.
.\"*********************************************************
.TP
-.B --genkey
+.B \-\-genkey
(Standalone)
Generate a random key to be used as a shared secret,
for use with the
-.B --secret
+.B \-\-secret
option. This file must be shared with the
peer over a pre-existing secure channel such as
.BR scp (1)
.
.\"*********************************************************
.TP
-.B --secret file
+.B \-\-secret file
Write key to
.B file.
.\"*********************************************************
@@ -4452,7 +4490,7 @@ Available with linux 2.4.7+. These options comprise a standalone mode
of OpenVPN which can be used to create and delete persistent tunnels.
.\"*********************************************************
.TP
-.B --mktun
+.B \-\-mktun
(Standalone)
Create a persistent tunnel on platforms which support them such
as Linux. Normally TUN/TAP tunnels exist only for
@@ -4463,9 +4501,9 @@ only when they are deleted or the machine is rebooted.
One of the advantages of persistent tunnels is that they eliminate the
need for separate
-.B --up
+.B \-\-up
and
-.B --down
+.B \-\-down
scripts to run the appropriate
.BR ifconfig (8)
and
@@ -4477,40 +4515,40 @@ Another advantage is that open connections through the TUN/TAP-based tunnel
will not be reset if the OpenVPN peer restarts. This can be useful to
provide uninterrupted connectivity through the tunnel in the event of a DHCP
reset of the peer's public IP address (see the
-.B --ipchange
+.B \-\-ipchange
option above).
One disadvantage of persistent tunnels is that it is harder to automatically
configure their MTU value (see
-.B --link-mtu
+.B \-\-link-mtu
and
-.B --tun-mtu
+.B \-\-tun-mtu
above).
On some platforms such as Windows, TAP-Win32 tunnels are persistent by
default.
.\"*********************************************************
.TP
-.B --rmtun
+.B \-\-rmtun
(Standalone)
Remove a persistent tunnel.
.\"*********************************************************
.TP
-.B --dev tunX | tapX
+.B \-\-dev tunX | tapX
TUN/TAP device
.\"*********************************************************
.TP
-.B --user user
+.B \-\-user user
Optional user to be owner of this tunnel.
.\"*********************************************************
.TP
-.B --group group
+.B \-\-group group
Optional group to be owner of this tunnel.
.\"*********************************************************
.SS Windows-Specific Options:
.\"*********************************************************
.TP
-.B --win-sys path|'env'
+.B \-\-win-sys path|'env'
Set the Windows system directory pathname to use when looking for system
executables such as
.B route.exe
@@ -4526,23 +4564,23 @@ indicates that the pathname should be read from the
environmental variable.
.\"*********************************************************
.TP
-.B --ip-win32 method
+.B \-\-ip-win32 method
When using
-.B --ifconfig
+.B \-\-ifconfig
on Windows, set the TAP-Win32 adapter
IP address and netmask using
.B method.
Don't use this option unless you are also using
-.B --ifconfig.
+.B \-\-ifconfig.
-.B manual --
+.B manual \-\-
Don't set the IP address or netmask automatically.
Instead output a message
to the console telling the user to configure the
adapter manually and indicating the IP/netmask which
OpenVPN expects the adapter to be set to.
-.B dynamic [offset] [lease-time] --
+.B dynamic [offset] [lease-time] \-\-
Automatically set the IP address and netmask by replying to
DHCP query messages generated by the kernel. This mode is
probably the "cleanest" solution
@@ -4552,13 +4590,13 @@ this mode: (1) The TCP/IP properties for the TAP-Win32
adapter must be set to "Obtain an IP address automatically," and
(2) OpenVPN needs to claim an IP address in the subnet for use
as the virtual DHCP server address. By default in
-.B --dev tap
+.B \-\-dev tap
mode, OpenVPN will
take the normally unused first address in the subnet. For example,
if your subnet is 192.168.4.0 netmask 255.255.255.0, then
OpenVPN will take the IP address 192.168.4.0 to use as the
virtual DHCP server address. In
-.B --dev tun
+.B \-\-dev tun
mode, OpenVPN will cause the DHCP server to masquerade as if it were
coming from the remote endpoint. The optional offset parameter is
an integer which is > -256 and < 256 and which defaults to 0.
@@ -4580,13 +4618,13 @@ because it prevents routes involving the TAP-Win32 adapter from
being lost when the system goes to sleep. The default
lease time is one year.
-.B netsh --
+.B netsh \-\-
Automatically set the IP address and netmask using
the Windows command-line "netsh"
command. This method appears to work correctly on
Windows XP but not Windows 2000.
-.B ipapi --
+.B ipapi \-\-
Automatically set the IP address and netmask using the
Windows IP Helper API. This approach
does not have ideal semantics, though testing has indicated
@@ -4595,7 +4633,7 @@ it is best to leave the TCP/IP properties for the TAP-Win32
adapter in their default state, i.e. "Obtain an IP address
automatically."
-.B adaptive --
+.B adaptive \-\-
(Default) Try
.B dynamic
method initially and fail over to
@@ -4625,55 +4663,55 @@ mode to restore the TAP-Win32 adapter TCP/IP properties
to a DHCP configuration.
.\"*********************************************************
.TP
-.B --route-method m
+.B \-\-route-method m
Which method
.B m
to use for adding routes on Windows?
.B adaptive
-(default) -- Try IP helper API first. If that fails, fall
+(default) \-\- Try IP helper API first. If that fails, fall
back to the route.exe shell command.
.br
.B ipapi
--- Use IP helper API.
+\-\- Use IP helper API.
.br
.B exe
--- Call the route.exe shell command.
+\-\- Call the route.exe shell command.
.\"*********************************************************
.TP
-.B --dhcp-option type [parm]
+.B \-\-dhcp-option type [parm]
Set extended TAP-Win32 TCP/IP properties, must
be used with
-.B --ip-win32 dynamic
+.B \-\-ip-win32 dynamic
or
-.B --ip-win32 adaptive.
+.B \-\-ip-win32 adaptive.
This option can be used to set additional TCP/IP properties
on the TAP-Win32 adapter, and is particularly useful for
configuring an OpenVPN client to access a Samba server
across the VPN.
-.B DOMAIN name --
+.B DOMAIN name \-\-
Set Connection-specific DNS Suffix.
-.B DNS addr --
+.B DNS addr \-\-
Set primary domain name server address. Repeat
this option to set secondary DNS server addresses.
-.B WINS addr --
+.B WINS addr \-\-
Set primary WINS server address (NetBIOS over TCP/IP Name Server).
Repeat this option to set secondary WINS server addresses.
-.B NBDD addr --
+.B NBDD addr \-\-
Set primary NBDD server address (NetBIOS over TCP/IP Datagram Distribution Server)
Repeat this option
to set secondary NBDD server addresses.
-.B NTP addr --
+.B NTP addr \-\-
Set primary NTP server address (Network Time Protocol).
Repeat this option
to set secondary NTP server addresses.
-.B NBT type --
+.B NBT type \-\-
Set NetBIOS over TCP/IP Node type. Possible options:
.B 1
= b-node (broadcasts),
@@ -4686,7 +4724,7 @@ then query name server), and
.B 8
= h-node (query name server, then broadcast).
-.B NBS scope-id --
+.B NBS scope-id \-\-
Set NetBIOS over TCP/IP Scope. A NetBIOS Scope ID provides an extended
naming service for the NetBIOS over TCP/IP (Known as NBT) module. The
primary purpose of a NetBIOS scope ID is to isolate NetBIOS traffic on
@@ -4698,19 +4736,19 @@ computers to use the same computer name, as they have different
scope IDs. The Scope ID becomes a part of the NetBIOS name, making the name unique.
(This description of NetBIOS scopes courtesy of NeonSurge@abyss.com)
-.B DISABLE-NBT --
+.B DISABLE-NBT \-\-
Disable Netbios-over-TCP/IP.
Note that if
-.B --dhcp-option
+.B \-\-dhcp-option
is pushed via
-.B --push
+.B \-\-push
to a non-windows client, the option will be saved in the client's
environment before the up script is called, under
the name "foreign_option_{n}".
.\"*********************************************************
.TP
-.B --tap-sleep n
+.B \-\-tap-sleep n
Cause OpenVPN to sleep for
.B n
seconds immediately after the TAP-Win32 adapter state
@@ -4718,21 +4756,21 @@ is set to "connected".
This option is intended to be used to troubleshoot problems
with the
-.B --ifconfig
+.B \-\-ifconfig
and
-.B --ip-win32
+.B \-\-ip-win32
options, and is used to give
the TAP-Win32 adapter time to come up before
Windows IP Helper API operations are applied to it.
.\"*********************************************************
.TP
-.B --show-net-up
+.B \-\-show-net-up
Output OpenVPN's view of the system routing table and network
adapter list to the syslog or log file after the TUN/TAP adapter
has been brought up and any routes have been added.
.\"*********************************************************
.TP
-.B --dhcp-renew
+.B \-\-dhcp-renew
Ask Windows to renew the TAP adapter lease on startup.
This option is normally unnecessary, as Windows automatically
triggers a DHCP renegotiation on the TAP adapter when it
@@ -4741,21 +4779,28 @@ Media Status property to "Always Connected", you may need this
flag.
.\"*********************************************************
.TP
-.B --dhcp-release
+.B \-\-dhcp-release
Ask Windows to release the TAP adapter lease on shutdown.
This option has the same caveats as
-.B --dhcp-renew
+.B \-\-dhcp-renew
above.
.\"*********************************************************
.TP
-.B --pause-exit
+.B \-\-register-dns
+Run net stop dnscache, net start dnscache, ipconfig /flushdns
+and ipconfig /registerdns on connection initiation.
+This is known to kick Windows into
+recognizing pushed DNS servers.
+.\"*********************************************************
+.TP
+.B \-\-pause-exit
Put up a "press any key to continue" message on the console prior
to OpenVPN program exit. This option is automatically used by the
Windows explorer when OpenVPN is run on a configuration
file using the right-click explorer menu.
.\"*********************************************************
.TP
-.B --service exit-event [0|1]
+.B \-\-service exit-event [0|1]
Should be used when OpenVPN is being automatically executed by another
program in such
a context that no interaction with the user via display or keyboard
@@ -4778,26 +4823,26 @@ parameter. In any case, the controlling process can signal
causing all such OpenVPN processes to exit.
When executing an OpenVPN process using the
-.B --service
+.B \-\-service
directive, OpenVPN will probably not have a console
window to output status/error
messages, therefore it is useful to use
-.B --log
+.B \-\-log
or
-.B --log-append
+.B \-\-log-append
to write these messages to a file.
.\"*********************************************************
.TP
-.B --show-adapters
+.B \-\-show-adapters
(Standalone)
Show available TAP-Win32 adapters which can be selected using the
-.B --dev-node
+.B \-\-dev-node
option. On non-Windows systems, the
.BR ifconfig (8)
command provides similar functionality.
.\"*********************************************************
.TP
-.B --allow-nonadmin [TAP-adapter]
+.B \-\-allow-nonadmin [TAP-adapter]
(Standalone)
Set
.B TAP-adapter
@@ -4812,10 +4857,10 @@ and reloaded.
This directive can only be used by an administrator.
.\"*********************************************************
.TP
-.B --show-valid-subnets
+.B \-\-show-valid-subnets
(Standalone)
Show valid subnets for
-.B --dev tun
+.B \-\-dev tun
emulation. Since the TAP-Win32 driver
exports an ethernet interface to Windows, and since TUN devices are
point-to-point in nature, it is necessary for the TAP-Win32 driver
@@ -4825,7 +4870,7 @@ Namely, the point-to-point endpoints used in TUN device emulation
must be the middle two addresses of a /30 subnet (netmask 255.255.255.252).
.\"*********************************************************
.TP
-.B --show-net
+.B \-\-show-net
(Standalone)
Show OpenVPN's view of the system routing table and network
adapter list.
@@ -4833,12 +4878,12 @@ adapter list.
.SS PKCS#11 Standalone Options:
.\"*********************************************************
.TP
-.B --show-pkcs11-ids provider [cert_private]
+.B \-\-show-pkcs11-ids provider [cert_private]
(Standalone)
Show PKCS#11 token object list. Specify cert_private as 1
if certificates are stored as private objects.
-.B --verb
+.B \-\-verb
option can be used BEFORE this option to produce debugging information.
.\"*********************************************************
.SH SCRIPTING AND ENVIRONMENTAL VARIABLES
@@ -4848,52 +4893,52 @@ of environmental variables for use by user-defined scripts.
.SS Script Order of Execution
.\"*********************************************************
.TP
-.B --up
+.B \-\-up
Executed after TCP/UDP socket bind and TUN/TAP open.
.\"*********************************************************
.TP
-.B --tls-verify
+.B \-\-tls-verify
Executed when we have a still untrusted remote peer.
.\"*********************************************************
.TP
-.B --ipchange
+.B \-\-ipchange
Executed after connection authentication, or remote IP address change.
.\"*********************************************************
.TP
-.B --client-connect
+.B \-\-client-connect
Executed in
-.B --mode server
+.B \-\-mode server
mode immediately after client authentication.
.\"*********************************************************
.TP
-.B --route-up
+.B \-\-route-up
Executed after connection authentication, either
immediately after, or some number of seconds after
as defined by the
-.B --route-delay
+.B \-\-route-delay
option.
.\"*********************************************************
.TP
-.B --client-disconnect
+.B \-\-client-disconnect
Executed in
-.B --mode server
+.B \-\-mode server
mode on client instance shutdown.
.\"*********************************************************
.TP
-.B --down
+.B \-\-down
Executed after TCP/UDP and TUN/TAP close.
.\"*********************************************************
.TP
-.B --learn-address
+.B \-\-learn-address
Executed in
-.B --mode server
+.B \-\-mode server
mode whenever an IPv4 address/route or MAC address is added to OpenVPN's
internal routing table.
.\"*********************************************************
.TP
-.B --auth-user-pass-verify
+.B \-\-auth-user-pass-verify
Executed in
-.B --mode server
+.B \-\-mode server
mode on new client connections, when the client is
still untrusted.
.\"*********************************************************
@@ -4917,7 +4962,7 @@ Can string remapping be disabled?
.B A:
Yes, by using the
-.B --no-name-remapping
+.B \-\-no-name-remapping
option, however this should be considered an advanced option.
Here is a brief rundown of OpenVPN's current string types and the
@@ -4933,17 +4978,17 @@ true.
Alphanumeric, underbar ('_'), dash ('-'), dot ('.'), and at
('@').
-.B --auth-user-pass username:
+.B \-\-auth-user-pass username:
Same as Common Name, with one exception: starting with OpenVPN 2.0.1,
the username is passed to the OPENVPN_PLUGIN_AUTH_USER_PASS_VERIFY plugin in its raw form,
without string remapping.
-.B --auth-user-pass password:
+.B \-\-auth-user-pass password:
Any "printable" character except CR or LF.
Printable is defined to be a character which will cause the C library
isprint() function to return true.
-.B --client-config-dir filename as derived from common name or username:
+.B \-\-client-config-dir filename as derived from common name or username:
Alphanumeric, underbar ('_'), dash ('-'), and dot ('.') except for "." or
".." as standalone strings. As of 2.0.1-rc6, the at ('@') character has
been added as well for compatibility with the common name character class.
@@ -4973,45 +5018,45 @@ which refer to different client instances.
.B bytes_received
Total number of bytes received from client during VPN session.
Set prior to execution of the
-.B --client-disconnect
+.B \-\-client-disconnect
script.
.\"*********************************************************
.TP
.B bytes_sent
Total number of bytes sent to client during VPN session.
Set prior to execution of the
-.B --client-disconnect
+.B \-\-client-disconnect
script.
.\"*********************************************************
.TP
.B common_name
The X509 common name of an authenticated client.
Set prior to execution of
-.B --client-connect, --client-disconnect,
+.B \-\-client-connect, \-\-client-disconnect,
and
-.B --auth-user-pass-verify
+.B \-\-auth-user-pass-verify
scripts.
.\"*********************************************************
.TP
.B config
Name of first
-.B --config
+.B \-\-config
file.
Set on program initiation and reset on SIGHUP.
.\"*********************************************************
.TP
.B daemon
Set to "1" if the
-.B --daemon
+.B \-\-daemon
directive is specified, or "0" otherwise.
Set on program initiation and reset on SIGHUP.
.\"*********************************************************
.TP
.B daemon_log_redirect
Set to "1" if the
-.B --log
+.B \-\-log
or
-.B --log-append
+.B \-\-log-append
directives are specified, or "0" otherwise.
Set on program initiation and reset on SIGHUP.
.\"*********************************************************
@@ -5020,30 +5065,30 @@ Set on program initiation and reset on SIGHUP.
The actual name of the TUN/TAP device, including
a unit number if it exists.
Set prior to
-.B --up
+.B \-\-up
or
-.B --down
+.B \-\-down
script execution.
.\"*********************************************************
.TP
.B foreign_option_{n}
An option pushed via
-.B --push
+.B \-\-push
to a client which does not natively support it,
such as
-.B --dhcp-option
+.B \-\-dhcp-option
on a non-Windows system, will be recorded to this
environmental variable sequence prior to
-.B --up
+.B \-\-up
script execution.
.\"*********************************************************
.TP
.B ifconfig_broadcast
The broadcast address for the virtual
ethernet segment which is derived from the
-.B --ifconfig
+.B \-\-ifconfig
option when
-.B --dev tap
+.B \-\-dev tap
is used.
Set prior to OpenVPN calling the
.I ifconfig
@@ -5051,13 +5096,13 @@ or
.I netsh
(windows version of ifconfig) commands which
normally occurs prior to
-.B --up
+.B \-\-up
script execution.
.\"*********************************************************
.TP
.B ifconfig_local
The local VPN endpoint IP address specified in the
-.B --ifconfig
+.B \-\-ifconfig
option (first parameter).
Set prior to OpenVPN calling the
.I ifconfig
@@ -5065,15 +5110,15 @@ or
.I netsh
(windows version of ifconfig) commands which
normally occurs prior to
-.B --up
+.B \-\-up
script execution.
.\"*********************************************************
.TP
.B ifconfig_remote
The remote VPN endpoint IP address specified in the
-.B --ifconfig
+.B \-\-ifconfig
option (second parameter) when
-.B --dev tun
+.B \-\-dev tun
is used.
Set prior to OpenVPN calling the
.I ifconfig
@@ -5081,16 +5126,16 @@ or
.I netsh
(windows version of ifconfig) commands which
normally occurs prior to
-.B --up
+.B \-\-up
script execution.
.\"*********************************************************
.TP
.B ifconfig_netmask
The subnet mask of the virtual ethernet segment
that is specified as the second parameter to
-.B --ifconfig
+.B \-\-ifconfig
when
-.B --dev tap
+.B \-\-dev tap
is being used.
Set prior to OpenVPN calling the
.I ifconfig
@@ -5098,61 +5143,61 @@ or
.I netsh
(windows version of ifconfig) commands which
normally occurs prior to
-.B --up
+.B \-\-up
script execution.
.\"*********************************************************
.TP
.B ifconfig_pool_local_ip
The local
virtual IP address for the TUN/TAP tunnel taken from an
-.B --ifconfig-push
+.B \-\-ifconfig-push
directive if specified, or otherwise from
the ifconfig pool (controlled by the
-.B --ifconfig-pool
+.B \-\-ifconfig-pool
config file directive).
Only set for
-.B --dev tun
+.B \-\-dev tun
tunnels.
This option is set on the server prior to execution
of the
-.B --client-connect
+.B \-\-client-connect
and
-.B --client-disconnect
+.B \-\-client-disconnect
scripts.
.\"*********************************************************
.TP
.B ifconfig_pool_netmask
The
virtual IP netmask for the TUN/TAP tunnel taken from an
-.B --ifconfig-push
+.B \-\-ifconfig-push
directive if specified, or otherwise from
the ifconfig pool (controlled by the
-.B --ifconfig-pool
+.B \-\-ifconfig-pool
config file directive).
Only set for
-.B --dev tap
+.B \-\-dev tap
tunnels.
This option is set on the server prior to execution
of the
-.B --client-connect
+.B \-\-client-connect
and
-.B --client-disconnect
+.B \-\-client-disconnect
scripts.
.\"*********************************************************
.TP
.B ifconfig_pool_remote_ip
The remote
virtual IP address for the TUN/TAP tunnel taken from an
-.B --ifconfig-push
+.B \-\-ifconfig-push
directive if specified, or otherwise from
the ifconfig pool (controlled by the
-.B --ifconfig-pool
+.B \-\-ifconfig-pool
config file directive).
This option is set on the server prior to execution
of the
-.B --client-connect
+.B \-\-client-connect
and
-.B --client-disconnect
+.B \-\-client-disconnect
scripts.
.\"*********************************************************
.TP
@@ -5160,31 +5205,31 @@ scripts.
The maximum packet size (not including the IP header)
of tunnel data in UDP tunnel transport mode.
Set prior to
-.B --up
+.B \-\-up
or
-.B --down
+.B \-\-down
script execution.
.\"*********************************************************
.TP
.B local
The
-.B --local
+.B \-\-local
parameter.
Set on program initiation and reset on SIGHUP.
.\"*********************************************************
.TP
.B local_port
The local port number, specified by
-.B --port
+.B \-\-port
or
-.B --lport.
+.B \-\-lport.
Set on program initiation and reset on SIGHUP.
.\"*********************************************************
.TP
.B password
The password provided by a connecting client.
Set prior to
-.B --auth-user-pass-verify
+.B \-\-auth-user-pass-verify
script execution only when the
.B via-env
modifier is specified, and deleted from the environment
@@ -5193,23 +5238,23 @@ after the script returns.
.TP
.B proto
The
-.B --proto
+.B \-\-proto
parameter.
Set on program initiation and reset on SIGHUP.
.\"*********************************************************
.TP
.B remote_{n}
The
-.B --remote
+.B \-\-remote
parameter.
Set on program initiation and reset on SIGHUP.
.\"*********************************************************
.TP
.B remote_port_{n}
The remote port number, specified by
-.B --port
+.B \-\-port
or
-.B --rport.
+.B \-\-rport.
Set on program initiation and reset on SIGHUP.
.\"*********************************************************
.TP
@@ -5217,29 +5262,29 @@ Set on program initiation and reset on SIGHUP.
The pre-existing default IP gateway in the system routing
table.
Set prior to
-.B --up
+.B \-\-up
script execution.
.\"*********************************************************
.TP
.B route_vpn_gateway
The default gateway used by
-.B --route
+.B \-\-route
options, as specified in either the
-.B --route-gateway
+.B \-\-route-gateway
option or the second parameter to
-.B --ifconfig
+.B \-\-ifconfig
when
-.B --dev tun
+.B \-\-dev tun
is specified.
Set prior to
-.B --up
+.B \-\-up
script execution.
.\"*********************************************************
.TP
.B route_{parm}_{n}
A set of variables which define each route to be added, and
are set prior to
-.B --up
+.B \-\-up
script execution.
.B parm
@@ -5263,31 +5308,31 @@ connection. Useful in conjunction with --tls-verify
Set to "init" or "restart" prior to up/down script execution.
For more information, see
documentation for
-.B --up.
+.B \-\-up.
.\"*********************************************************
.TP
.B script_type
-One of
+Prior to execution of any script, this variable is set to the type of
+script being run. It can be one of the following:
.B up, down, ipchange, route-up, tls-verify, auth-user-pass-verify,
.B client-connect, client-disconnect,
or
.B learn-address.
-Set prior to execution of any script.
.\"*********************************************************
.TP
.B signal
The reason for exit or restart. Can be one of
.B sigusr1, sighup, sigterm, sigint, inactive
(controlled by
-.B --inactive
+.B \-\-inactive
option),
.B ping-exit
(controlled by
-.B --ping-exit
+.B \-\-ping-exit
option),
.B ping-restart
(controlled by
-.B --ping-restart
+.B \-\-ping-restart
option),
.B connection-reset
(triggered on TCP connection reset),
@@ -5301,7 +5346,7 @@ or
Client connection timestamp, formatted as a human-readable
time string.
Set prior to execution of the
-.B --client-connect
+.B \-\-client-connect
script.
.\"*********************************************************
.TP
@@ -5309,7 +5354,7 @@ script.
The duration (in seconds) of the client session which is now
disconnecting.
Set prior to execution of the
-.B --client-disconnect
+.B \-\-client-disconnect
script.
.\"*********************************************************
.TP
@@ -5317,7 +5362,7 @@ script.
Client connection timestamp, formatted as a unix integer
date/time value.
Set prior to execution of the
-.B --client-connect
+.B \-\-client-connect
script.
.\"*********************************************************
.TP
@@ -5327,7 +5372,7 @@ where
.B n
is the verification level. Only set for TLS connections. Set prior
to execution of
-.B --tls-verify
+.B \-\-tls-verify
script.
.\"*********************************************************
.TP
@@ -5337,34 +5382,39 @@ where
.B n
is the verification level. Only set for TLS connections. Set prior
to execution of
-.B --tls-verify
-script.
+.B \-\-tls-verify
+script. This is in the form of a hex string like "37AB46E0", which is
+suitable for doing serial-based OCSP queries (with OpenSSL, you have
+to prepend "0x" to the string). If something goes wrong while reading
+the value from the certificate it will be an empty string, so your
+code should check that.
+See the contrib/OCSP_check/OCSP_check.sh script for an example.
.\"*********************************************************
.TP
.B tun_mtu
The MTU of the TUN/TAP device.
Set prior to
-.B --up
+.B \-\-up
or
-.B --down
+.B \-\-down
script execution.
.\"*********************************************************
.TP
.B trusted_ip
Actual IP address of connecting client or peer which has been authenticated.
Set prior to execution of
-.B --ipchange, --client-connect,
+.B \-\-ipchange, \-\-client-connect,
and
-.B --client-disconnect
+.B \-\-client-disconnect
scripts.
.\"*********************************************************
.TP
.B trusted_port
Actual port number of connecting client or peer which has been authenticated.
Set prior to execution of
-.B --ipchange, --client-connect,
+.B \-\-ipchange, \-\-client-connect,
and
-.B --client-disconnect
+.B \-\-client-disconnect
scripts.
.\"*********************************************************
.TP
@@ -5373,12 +5423,12 @@ Actual IP address of connecting client or peer which has not been authenticated
yet. Sometimes used to
.B nmap
the connecting host in a
-.B --tls-verify
+.B \-\-tls-verify
script to ensure it is firewalled properly.
Set prior to execution of
-.B --tls-verify
+.B \-\-tls-verify
and
-.B --auth-user-pass-verify
+.B \-\-auth-user-pass-verify
scripts.
.\"*********************************************************
.TP
@@ -5386,16 +5436,16 @@ scripts.
Actual port number of connecting client or peer which has not been authenticated
yet.
Set prior to execution of
-.B --tls-verify
+.B \-\-tls-verify
and
-.B --auth-user-pass-verify
+.B \-\-auth-user-pass-verify
scripts.
.\"*********************************************************
.TP
.B username
The username provided by a connecting client.
Set prior to
-.B --auth-user-pass-verify
+.B \-\-auth-user-pass-verify
script execution only when the
.B via-env
modifier is specified.
@@ -5407,7 +5457,7 @@ where
.B n
is the verification level. Only set for TLS connections. Set prior
to execution of
-.B --tls-verify
+.B \-\-tls-verify
script. This variable is similar to
.B tls_id_{n}
except the component X509 subject fields are broken out, and
@@ -5451,30 +5501,30 @@ Like
except don't re-read configuration file, and possibly don't close and reopen TUN/TAP
device, re-read key files, preserve local IP address/port, or preserve most recently authenticated
remote IP address/port based on
-.B --persist-tun, --persist-key, --persist-local-ip,
+.B \-\-persist-tun, \-\-persist-key, \-\-persist-local-ip,
and
-.B --persist-remote-ip
+.B \-\-persist-remote-ip
options respectively (see above).
This signal may also be internally generated by a timeout condition, governed
by the
-.B --ping-restart
+.B \-\-ping-restart
option.
This signal, when combined with
-.B --persist-remote-ip,
+.B \-\-persist-remote-ip,
may be
sent when the underlying parameters of the host's network interface change
such as when the host is a DHCP client and is assigned a new IP address.
See
-.B --ipchange
+.B \-\-ipchange
above for more information.
.\"*********************************************************
.TP
.B SIGUSR2
Causes OpenVPN to display its current statistics (to the syslog
file if
-.B --daemon
+.B \-\-daemon
is used, or stdout otherwise).
.\"*********************************************************
.TP
@@ -5529,7 +5579,7 @@ If firewalls exist between
the two machines, they should be set to forward UDP port 1194
in both directions. If you do not have control over the firewalls
between the two machines, you may still be able to use OpenVPN by adding
-.B --ping 15
+.B \-\-ping 15
to each of the
.B openvpn
commands used below in the examples (this will cause each peer to send out
@@ -5598,11 +5648,11 @@ you will get a weird feedback loop.
.LP
On may:
.IP
-.B openvpn --remote june.kg --dev tun1 --ifconfig 10.4.0.1 10.4.0.2 --verb 9
+.B openvpn \-\-remote june.kg \-\-dev tun1 \-\-ifconfig 10.4.0.1 10.4.0.2 \-\-verb 9
.LP
On june:
.IP
-.B openvpn --remote may.kg --dev tun1 --ifconfig 10.4.0.2 10.4.0.1 --verb 9
+.B openvpn \-\-remote may.kg \-\-dev tun1 \-\-ifconfig 10.4.0.2 10.4.0.1 \-\-verb 9
.LP
Now verify the tunnel is working by pinging across the tunnel.
.LP
@@ -5615,17 +5665,17 @@ On june:
.B ping 10.4.0.1
.LP
The
-.B --verb 9
+.B \-\-verb 9
option will produce verbose output, similar to the
.BR tcpdump (8)
program. Omit the
-.B --verb 9
+.B \-\-verb 9
option to have OpenVPN run quietly.
.\"*********************************************************
.SS Example 2: A tunnel with static-key security (i.e. using a pre-shared secret)
First build a static key on may.
.IP
-.B openvpn --genkey --secret key
+.B openvpn \-\-genkey \-\-secret key
.LP
This command will build a random key file called
.B key
@@ -5639,11 +5689,11 @@ program.
.LP
On may:
.IP
-.B openvpn --remote june.kg --dev tun1 --ifconfig 10.4.0.1 10.4.0.2 --verb 5 --secret key
+.B openvpn \-\-remote june.kg \-\-dev tun1 \-\-ifconfig 10.4.0.1 10.4.0.2 \-\-verb 5 \-\-secret key
.LP
On june:
.IP
-.B openvpn --remote may.kg --dev tun1 --ifconfig 10.4.0.2 10.4.0.1 --verb 5 --secret key
+.B openvpn \-\-remote may.kg \-\-dev tun1 \-\-ifconfig 10.4.0.2 10.4.0.1 \-\-verb 5 \-\-secret key
.LP
Now verify the tunnel is working by pinging across the tunnel.
.LP
@@ -5665,10 +5715,10 @@ as the TLS server.
First, build a separate certificate/key pair
for both may and june (see above where
-.B --cert
+.B \-\-cert
is discussed for more info). Then construct
Diffie Hellman parameters (see above where
-.B --dh
+.B \-\-dh
is discussed for more info). You can also use the
included test files client.crt, client.key,
server.crt, server.key and ca.crt.
@@ -5681,11 +5731,11 @@ parameters you can use the included file dh1024.pem.
.LP
On may:
.IP
-.B openvpn --remote june.kg --dev tun1 --ifconfig 10.4.0.1 10.4.0.2 --tls-client --ca ca.crt --cert client.crt --key client.key --reneg-sec 60 --verb 5
+.B openvpn \-\-remote june.kg \-\-dev tun1 \-\-ifconfig 10.4.0.1 10.4.0.2 \-\-tls-client \-\-ca ca.crt \-\-cert client.crt \-\-key client.key \-\-reneg-sec 60 \-\-verb 5
.LP
On june:
.IP
-.B openvpn --remote may.kg --dev tun1 --ifconfig 10.4.0.2 10.4.0.1 --tls-server --dh dh1024.pem --ca ca.crt --cert server.crt --key server.key --reneg-sec 60 --verb 5
+.B openvpn \-\-remote may.kg \-\-dev tun1 \-\-ifconfig 10.4.0.2 10.4.0.1 \-\-tls-server \-\-dh dh1024.pem \-\-ca ca.crt \-\-cert server.crt \-\-key server.key \-\-reneg-sec 60 \-\-verb 5
.LP
Now verify the tunnel is working by pinging across the tunnel.
.LP
@@ -5698,16 +5748,16 @@ On june:
.B ping 10.4.0.1
.LP
Notice the
-.B --reneg-sec 60
+.B \-\-reneg-sec 60
option we used above. That tells OpenVPN to renegotiate
the data channel keys every minute.
Since we used
-.B --verb 5
+.B \-\-verb 5
above, you will see status information on each new key negotiation.
For production operations, a key renegotiation interval of 60 seconds
is probably too frequent. Omit the
-.B --reneg-sec 60
+.B \-\-reneg-sec 60
option to use OpenVPN's default key renegotiation interval of one hour.
.\"*********************************************************
.SS Routing:
@@ -5743,7 +5793,7 @@ over the secure tunnel (or vice versa).
In a production environment, you could put the route command(s)
in a shell script and execute with the
-.B --up
+.B \-\-up
option.
.\"*********************************************************
.SH FIREWALLS
@@ -5751,7 +5801,7 @@ OpenVPN's usage of a single UDP port makes it fairly firewall-friendly.
You should add an entry to your firewall rules to allow incoming OpenVPN
packets. On Linux 2.4+:
.IP
-.B iptables -A INPUT -p udp -s 1.2.3.4 --dport 1194 -j ACCEPT
+.B iptables -A INPUT -p udp -s 1.2.3.4 \-\-dport 1194 -j ACCEPT
.LP
This will allow incoming packets on UDP port 1194 (OpenVPN's default UDP port)
from an OpenVPN peer at 1.2.3.4.
@@ -5762,7 +5812,7 @@ address can be considered optional, since HMAC packet authentication
is a much more secure method of verifying the authenticity of
a packet source. In that case:
.IP
-.B iptables -A INPUT -p udp --dport 1194 -j ACCEPT
+.B iptables -A INPUT -p udp \-\-dport 1194 -j ACCEPT
.LP
would be adequate and would not render the host inflexible with
respect to its peer having a dynamic IP address.
@@ -5771,7 +5821,7 @@ OpenVPN also works well on stateful firewalls. In some cases, you may
not need to add any static rules to the firewall list if you are
using a stateful firewall that knows how to track UDP connections.
If you specify
-.B --ping n,
+.B \-\-ping n,
OpenVPN will be guaranteed
to send a packet to its peer at least once every
.B n
@@ -5853,7 +5903,7 @@ For more information on the LZO real-time compression library see
.I http://www.oberhumer.com/opensource/lzo/
.\"*********************************************************
.SH COPYRIGHT
-Copyright (C) 2002-2009 OpenVPN Technologies, Inc. This program is free software;
+Copyright (C) 2002-2010 OpenVPN Technologies, Inc. This program is free software;
you can redistribute it and/or modify
it under the terms of the GNU General Public License version 2
as published by the Free Software Foundation.
diff --git a/openvpn.c b/openvpn.c
index 451fbe4..99b343b 100644
--- a/openvpn.c
+++ b/openvpn.c
@@ -5,7 +5,7 @@
* packet encryption, packet authentication, and
* packet compression.
*
- * Copyright (C) 2002-2009 OpenVPN Technologies, Inc. <sales@openvpn.net>
+ * Copyright (C) 2002-2010 OpenVPN Technologies, Inc. <sales@openvpn.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2
@@ -55,8 +55,6 @@ tunnel_point_to_point (struct context *c)
if (IS_SIG (c))
return;
- init_management_callback_p2p (c);
-
/* main event loop */
while (true)
{
diff --git a/openvpn.h b/openvpn.h
index 6e6e1f8..641bf93 100644
--- a/openvpn.h
+++ b/openvpn.h
@@ -5,7 +5,7 @@
* packet encryption, packet authentication, and
* packet compression.
*
- * Copyright (C) 2002-2009 OpenVPN Technologies, Inc. <sales@openvpn.net>
+ * Copyright (C) 2002-2010 OpenVPN Technologies, Inc. <sales@openvpn.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2
diff --git a/options.c b/options.c
index d0cec7d..524c781 100644
--- a/options.c
+++ b/options.c
@@ -5,7 +5,10 @@
* packet encryption, packet authentication, and
* packet compression.
*
- * Copyright (C) 2002-2009 OpenVPN Technologies, Inc. <sales@openvpn.net>
+ * Copyright (C) 2002-2010 OpenVPN Technologies, Inc. <sales@openvpn.net>
+ *
+ * Additions for eurephia plugin done by:
+ * David Sommerseth <dazo@users.sourceforge.net> Copyright (C) 2009
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2
@@ -45,6 +48,7 @@
#include "pool.h"
#include "helper.h"
#include "manage.h"
+#include "forward.h"
#include "configure.h"
#include <ctype.h>
@@ -72,6 +76,9 @@ const char title_string[] =
#ifdef ENABLE_PKCS11
" [PKCS11]"
#endif
+#ifdef ENABLE_EUREPHIA
+ " [eurephia]"
+#endif
" built on " __DATE__
;
@@ -93,6 +100,7 @@ static const char usage_message[] =
"--mode m : Major mode, m = 'p2p' (default, point-to-point) or 'server'.\n"
"--proto p : Use protocol p for communicating with peer.\n"
" p = udp (default), tcp-server, or tcp-client\n"
+ "--proto-force p : only consider protocol p in list of connection profiles.\n"
"--connect-retry n : For --proto tcp-client, number of seconds to wait\n"
" between connection retries (default=%d).\n"
"--connect-timeout n : For --proto tcp-client, connection timeout (in seconds).\n"
@@ -107,8 +115,9 @@ static const char usage_message[] =
" up is a file containing username/password on 2 lines, or\n"
" 'stdin' to prompt from console. Add auth='ntlm' if\n"
" the proxy requires NTLM authentication.\n"
- "--http-proxy s p 'auto': Like the above directive, but automatically determine\n"
- " auth method and query for username/password if needed.\n"
+ "--http-proxy s p 'auto[-nct]' : Like the above directive, but automatically\n"
+ " determine auth method and query for username/password\n"
+ " if needed. auto-nct disables weak proxy auth methods.\n"
"--http-proxy-retry : Retry indefinitely on HTTP proxy errors.\n"
"--http-proxy-timeout n : Proxy timeout in seconds, default=5.\n"
"--http-proxy-option type [parm] : Set extended HTTP proxy options.\n"
@@ -197,6 +206,9 @@ static const char usage_message[] =
" Add 'bypass-dns' flag to similarly bypass tunnel for DNS.\n"
"--redirect-private [flags]: Like --redirect-gateway, but omit actually changing\n"
" the default gateway. Useful when pushing private subnets.\n"
+#ifdef ENABLE_PUSH_PEER_INFO
+ "--push-peer-info : (client only) push client info to server.\n"
+#endif
"--setenv name value : Set a custom environmental variable to pass to script.\n"
"--setenv FORWARD_COMPATIBLE 1 : Relax config file syntax checking to allow\n"
" directives for future OpenVPN versions to be ignored.\n"
@@ -611,6 +623,8 @@ static const char usage_message[] =
"--dhcp-pre-release : Ask Windows to release the previous TAP adapter lease on\n"
" startup.\n"
"--dhcp-release : Ask Windows to release the TAP adapter lease on shutdown.\n"
+ "--register-dns : Run net stop dnscache, net start dnscache, ipconfig /flushdns\n"
+ " and ipconfig /registerdns on connection initiation.\n"
"--tap-sleep n : Sleep for n seconds after TAP adapter open before\n"
" attempting to set adapter properties.\n"
"--pause-exit : When run from a console window, pause before exiting.\n"
@@ -687,6 +701,7 @@ init_options (struct options *o, const bool init_gc)
o->route_delay_window = 30;
o->max_routes = MAX_ROUTES_DEFAULT;
o->resolve_retry_seconds = RESOLV_RETRY_INFINITE;
+ o->proto_force = -1;
#ifdef ENABLE_OCC
o->occ = true;
#endif
@@ -758,7 +773,9 @@ void
uninit_options (struct options *o)
{
if (o->gc_owned)
- gc_free (&o->gc);
+ {
+ gc_free (&o->gc);
+ }
}
#ifdef ENABLE_DEBUG
@@ -1341,6 +1358,9 @@ show_settings (const struct options *o)
SHOW_INT (transition_window);
SHOW_BOOL (single_session);
+#ifdef ENABLE_PUSH_PEER_INFO
+ SHOW_BOOL (push_peer_info);
+#endif
SHOW_BOOL (tls_exit);
SHOW_STR (tls_auth_file);
@@ -1407,6 +1427,142 @@ init_http_options_if_undefined (struct options *o)
#endif
+#if HTTP_PROXY_FALLBACK
+
+static struct http_proxy_options *
+parse_http_proxy_override (const char *server,
+ const char *port,
+ const char *flags,
+ const int msglevel,
+ struct gc_arena *gc)
+{
+ if (server && port)
+ {
+ struct http_proxy_options *ho;
+ const int int_port = atoi(port);
+
+ if (!legal_ipv4_port (int_port))
+ {
+ msg (msglevel, "Bad http-proxy port number: %s", port);
+ return NULL;
+ }
+
+ ALLOC_OBJ_CLEAR_GC (ho, struct http_proxy_options, gc);
+ ho->server = string_alloc(server, gc);
+ ho->port = int_port;
+ ho->retry = true;
+ ho->timeout = 5;
+ if (flags && !strcmp(flags, "nct"))
+ ho->auth_retry = PAR_NCT;
+ else
+ ho->auth_retry = PAR_ALL;
+ ho->http_version = "1.0";
+ ho->user_agent = "OpenVPN-Autoproxy/1.0";
+ return ho;
+ }
+ else
+ return NULL;
+}
+
+struct http_proxy_options *
+parse_http_proxy_fallback (struct context *c,
+ const char *server,
+ const char *port,
+ const char *flags,
+ const int msglevel)
+{
+ struct gc_arena gc = gc_new ();
+ struct http_proxy_options *ret = NULL;
+ struct http_proxy_options *hp = parse_http_proxy_override(server, port, flags, msglevel, &gc);
+ if (hp)
+ {
+ struct hpo_store *hpos = c->options.hpo_store;
+ if (!hpos)
+ {
+ ALLOC_OBJ_CLEAR_GC (hpos, struct hpo_store, &c->options.gc);
+ c->options.hpo_store = hpos;
+ }
+ hpos->hpo = *hp;
+ hpos->hpo.server = hpos->server;
+ strncpynt(hpos->server, hp->server, sizeof(hpos->server));
+ ret = &hpos->hpo;
+ }
+ gc_free (&gc);
+ return ret;
+}
+
+static void
+http_proxy_warn(const char *name)
+{
+ msg (M_WARN, "Note: option %s ignored because no TCP-based connection profiles are defined", name);
+}
+
+void
+options_postprocess_http_proxy_fallback (struct options *o)
+{
+ struct connection_list *l = o->connection_list;
+ if (l)
+ {
+ int i;
+ for (i = 0; i < l->len; ++i)
+ {
+ struct connection_entry *ce = l->array[i];
+ if (ce->proto == PROTO_TCPv4_CLIENT || ce->proto == PROTO_TCPv4)
+ {
+ if (l->len < CONNECTION_LIST_SIZE)
+ {
+ struct connection_entry *newce;
+ ALLOC_OBJ_GC (newce, struct connection_entry, &o->gc);
+ *newce = *ce;
+ newce->flags |= CE_HTTP_PROXY_FALLBACK;
+ newce->http_proxy_options = NULL;
+ newce->ce_http_proxy_fallback_timestamp = 0;
+ l->array[l->len++] = newce;
+ }
+ return;
+ }
+ }
+ }
+ http_proxy_warn("http-proxy-fallback");
+}
+
+void
+options_postprocess_http_proxy_override (struct options *o)
+{
+ const struct connection_list *l = o->connection_list;
+ if (l)
+ {
+ int i;
+ bool succeed = false;
+ for (i = 0; i < l->len; ++i)
+ {
+ struct connection_entry *ce = l->array[i];
+ if (ce->proto == PROTO_TCPv4_CLIENT || ce->proto == PROTO_TCPv4)
+ {
+ ce->http_proxy_options = o->http_proxy_override;
+ succeed = true;
+ }
+ }
+ if (succeed)
+ {
+ for (i = 0; i < l->len; ++i)
+ {
+ struct connection_entry *ce = l->array[i];
+ if (ce->proto == PROTO_UDPv4)
+ {
+ ce->flags |= CE_DISABLED;
+ }
+ }
+ }
+ else
+ {
+ http_proxy_warn("http-proxy-override");
+ }
+ }
+}
+
+#endif
+
#if ENABLE_CONNECTION
static struct connection_list *
@@ -1920,6 +2076,9 @@ options_postprocess_verify_ce (const struct options *options, const struct conne
MUST_BE_UNDEF (transition_window);
MUST_BE_UNDEF (tls_auth_file);
MUST_BE_UNDEF (single_session);
+#ifdef ENABLE_PUSH_PEER_INFO
+ MUST_BE_UNDEF (push_peer_info);
+#endif
MUST_BE_UNDEF (tls_exit);
MUST_BE_UNDEF (crl_file);
MUST_BE_UNDEF (key_method);
@@ -1976,6 +2135,10 @@ options_postprocess_mutate_ce (struct options *o, struct connection_entry *ce)
if (!ce->bind_local)
ce->local_port = 0;
+
+ /* if protocol forcing is enabled, disable all protocols except for the forced one */
+ if (o->proto_force >= 0 && is_proto_tcp(o->proto_force) != is_proto_tcp(ce->proto))
+ ce->flags |= CE_DISABLED;
}
static void
@@ -2091,7 +2254,7 @@ options_postprocess_mutate (struct options *o)
* For compatibility with 2.0.x, map multiple --remote options
* into connection list (connection lists added in 2.1).
*/
- if (o->remote_list->len > 1)
+ if (o->remote_list->len > 1 || o->force_connection_list)
{
const struct remote_list *rl = o->remote_list;
int i;
@@ -2108,7 +2271,7 @@ options_postprocess_mutate (struct options *o)
*ace = ce;
}
}
- else if (o->remote_list->len == 1) /* one --remote option specfied */
+ else if (o->remote_list->len == 1) /* one --remote option specified */
{
connection_entry_load_re (&o->ce, o->remote_list->array[0]);
}
@@ -2122,6 +2285,13 @@ options_postprocess_mutate (struct options *o)
int i;
for (i = 0; i < o->connection_list->len; ++i)
options_postprocess_mutate_ce (o, o->connection_list->array[i]);
+
+#if HTTP_PROXY_FALLBACK
+ if (o->http_proxy_override)
+ options_postprocess_http_proxy_override(o);
+ else if (o->http_proxy_fallback)
+ options_postprocess_http_proxy_fallback(o);
+#endif
}
else
#endif
@@ -2742,7 +2912,7 @@ usage_version (void)
{
msg (M_INFO|M_NOPREFIX, "%s", title_string);
msg (M_INFO|M_NOPREFIX, "Originally developed by James Yonan");
- msg (M_INFO|M_NOPREFIX, "Copyright (C) 2002-2009 OpenVPN Technologies, Inc. <sales@openvpn.net>");
+ msg (M_INFO|M_NOPREFIX, "Copyright (C) 2002-2010 OpenVPN Technologies, Inc. <sales@openvpn.net>");
#ifndef ENABLE_SMALL
#ifdef CONFIGURE_CALL
msg (M_INFO|M_NOPREFIX, "\n%s\n", CONFIGURE_CALL);
@@ -3335,6 +3505,15 @@ msglevel_forward_compatible (struct options *options, const int msglevel)
}
static void
+warn_multiple_script (const char *script, const char *type) {
+ if (script) {
+ msg (M_WARN, "Multiple --%s scripts defined. "
+ "The previously configured script is overridden.", type);
+ }
+}
+
+
+static void
add_option (struct options *options,
char *p[],
const char *file,
@@ -3639,6 +3818,29 @@ add_option (struct options *options,
}
}
#endif
+#ifdef ENABLE_CONNECTION
+ else if (streq (p[0], "remote-ip-hint") && p[1])
+ {
+ VERIFY_PERMISSION (OPT_P_GENERAL);
+ options->remote_ip_hint = p[1];
+ }
+#endif
+#if HTTP_PROXY_FALLBACK
+ else if (streq (p[0], "http-proxy-fallback"))
+ {
+ VERIFY_PERMISSION (OPT_P_GENERAL);
+ options->http_proxy_fallback = true;
+ options->force_connection_list = true;
+ }
+ else if (streq (p[0], "http-proxy-override") && p[1] && p[2])
+ {
+ VERIFY_PERMISSION (OPT_P_GENERAL);
+ options->http_proxy_override = parse_http_proxy_override(p[1], p[2], p[3], msglevel, &options->gc);
+ if (!options->http_proxy_override)
+ goto err;
+ options->force_connection_list = true;
+ }
+#endif
else if (streq (p[0], "remote") && p[1])
{
struct remote_entry re;
@@ -3711,6 +3913,7 @@ add_option (struct options *options,
VERIFY_PERMISSION (OPT_P_SCRIPT);
if (!no_more_than_n_args (msglevel, p, 2, NM_QUOTE_HINT))
goto err;
+ warn_multiple_script (options->ipchange, "ipchange");
options->ipchange = string_substitute (p[1], ',', ' ', &options->gc);
}
else if (streq (p[0], "float"))
@@ -3757,6 +3960,7 @@ add_option (struct options *options,
VERIFY_PERMISSION (OPT_P_SCRIPT);
if (!no_more_than_n_args (msglevel, p, 2, NM_QUOTE_HINT))
goto err;
+ warn_multiple_script (options->up_script, "up");
options->up_script = p[1];
}
else if (streq (p[0], "down") && p[1])
@@ -3764,6 +3968,7 @@ add_option (struct options *options,
VERIFY_PERMISSION (OPT_P_SCRIPT);
if (!no_more_than_n_args (msglevel, p, 2, NM_QUOTE_HINT))
goto err;
+ warn_multiple_script (options->down_script, "down");
options->down_script = p[1];
}
else if (streq (p[0], "down-pre"))
@@ -3823,7 +4028,7 @@ add_option (struct options *options,
{
if (options->inetd != -1)
{
- msg (msglevel, opterr);
+ msg (msglevel, "%s", opterr);
goto err;
}
else
@@ -3833,7 +4038,7 @@ add_option (struct options *options,
{
if (options->inetd != -1)
{
- msg (msglevel, opterr);
+ msg (msglevel, "%s", opterr);
goto err;
}
else
@@ -3843,7 +4048,7 @@ add_option (struct options *options,
{
if (name != NULL)
{
- msg (msglevel, opterr);
+ msg (msglevel, "%s", opterr);
goto err;
}
name = p[z];
@@ -4118,6 +4323,19 @@ add_option (struct options *options,
}
options->ce.proto = proto;
}
+ else if (streq (p[0], "proto-force") && p[1])
+ {
+ int proto_force;
+ VERIFY_PERMISSION (OPT_P_GENERAL);
+ proto_force = ascii2proto (p[1]);
+ if (proto_force < 0)
+ {
+ msg (msglevel, "Bad --proto-force protocol: '%s'", p[1]);
+ goto err;
+ }
+ options->proto_force = proto_force;
+ options->force_connection_list = true;
+ }
#ifdef GENERAL_PROXY_SUPPORT
else if (streq (p[0], "auto-proxy"))
{
@@ -4179,8 +4397,13 @@ add_option (struct options *options,
if (p[3])
{
+ /* auto -- try to figure out proxy addr, port, and type automatically */
+ /* semiauto -- given proxy addr:port, try to figure out type automatically */
+ /* (auto|semiauto)-nct -- disable proxy auth cleartext protocols (i.e. basic auth) */
if (streq (p[3], "auto"))
- ho->auth_retry = true;
+ ho->auth_retry = PAR_ALL;
+ else if (streq (p[3], "auto-nct"))
+ ho->auth_retry = PAR_NCT;
else
{
ho->auth_method_string = "basic";
@@ -4408,6 +4631,7 @@ add_option (struct options *options,
VERIFY_PERMISSION (OPT_P_SCRIPT);
if (!no_more_than_n_args (msglevel, p, 2, NM_QUOTE_HINT))
goto err;
+ warn_multiple_script (options->route_script, "route-up");
options->route_script = p[1];
}
else if (streq (p[0], "route-noexec"))
@@ -4737,6 +4961,7 @@ add_option (struct options *options,
msg (msglevel, "--auth-user-pass-verify requires a second parameter ('via-env' or 'via-file')");
goto err;
}
+ warn_multiple_script (options->auth_user_pass_verify_script, "auth-user-pass-verify");
options->auth_user_pass_verify_script = p[1];
}
else if (streq (p[0], "client-connect") && p[1])
@@ -4744,6 +4969,7 @@ add_option (struct options *options,
VERIFY_PERMISSION (OPT_P_SCRIPT);
if (!no_more_than_n_args (msglevel, p, 2, NM_QUOTE_HINT))
goto err;
+ warn_multiple_script (options->client_connect_script, "client-connect");
options->client_connect_script = p[1];
}
else if (streq (p[0], "client-disconnect") && p[1])
@@ -4751,6 +4977,7 @@ add_option (struct options *options,
VERIFY_PERMISSION (OPT_P_SCRIPT);
if (!no_more_than_n_args (msglevel, p, 2, NM_QUOTE_HINT))
goto err;
+ warn_multiple_script (options->client_disconnect_script, "client-disconnect");
options->client_disconnect_script = p[1];
}
else if (streq (p[0], "learn-address") && p[1])
@@ -4758,6 +4985,7 @@ add_option (struct options *options,
VERIFY_PERMISSION (OPT_P_SCRIPT);
if (!no_more_than_n_args (msglevel, p, 2, NM_QUOTE_HINT))
goto err;
+ warn_multiple_script (options->learn_address_script, "learn-address");
options->learn_address_script = p[1];
}
else if (streq (p[0], "tmp-dir") && p[1])
@@ -5093,7 +5321,7 @@ add_option (struct options *options,
VERIFY_PERMISSION (OPT_P_IPWIN32);
options->tuntap_options.dhcp_release = true;
}
- else if (streq (p[0], "dhcp-rr") && p[1]) /* standalone method for internal use */
+ else if (streq (p[0], "dhcp-internal") && p[1]) /* standalone method for internal use */
{
unsigned int adapter_index;
VERIFY_PERMISSION (OPT_P_GENERAL);
@@ -5104,13 +5332,26 @@ add_option (struct options *options,
dhcp_release_by_adapter_index (adapter_index);
if (options->tuntap_options.dhcp_renew)
dhcp_renew_by_adapter_index (adapter_index);
- openvpn_exit (OPENVPN_EXIT_STATUS_USAGE); /* exit point */
+ openvpn_exit (OPENVPN_EXIT_STATUS_GOOD); /* exit point */
+ }
+ else if (streq (p[0], "register-dns"))
+ {
+ VERIFY_PERMISSION (OPT_P_IPWIN32);
+ options->tuntap_options.register_dns = true;
+ }
+ else if (streq (p[0], "rdns-internal")) /* standalone method for internal use */
+ {
+ VERIFY_PERMISSION (OPT_P_GENERAL);
+ set_debug_level (options->verbosity, SDL_CONSTRAIN);
+ if (options->tuntap_options.register_dns)
+ ipconfig_register_dns (NULL);
+ openvpn_exit (OPENVPN_EXIT_STATUS_GOOD); /* exit point */
}
else if (streq (p[0], "show-valid-subnets"))
{
VERIFY_PERMISSION (OPT_P_GENERAL);
show_valid_win32_tun_subnets ();
- openvpn_exit (OPENVPN_EXIT_STATUS_USAGE); /* exit point */
+ openvpn_exit (OPENVPN_EXIT_STATUS_GOOD); /* exit point */
}
else if (streq (p[0], "pause-exit"))
{
@@ -5470,6 +5711,12 @@ add_option (struct options *options,
{
VERIFY_PERMISSION (OPT_P_GENERAL);
options->pkcs12_file = p[1];
+#if ENABLE_INLINE_FILES
+ if (streq (p[1], INLINE_FILE_TAG) && p[2])
+ {
+ options->pkcs12_file_inline = p[2];
+ }
+#endif
}
else if (streq (p[0], "askpass"))
{
@@ -5491,6 +5738,13 @@ add_option (struct options *options,
VERIFY_PERMISSION (OPT_P_GENERAL);
options->single_session = true;
}
+#ifdef ENABLE_PUSH_PEER_INFO
+ else if (streq (p[0], "push-peer-info"))
+ {
+ VERIFY_PERMISSION (OPT_P_GENERAL);
+ options->push_peer_info = true;
+ }
+#endif
else if (streq (p[0], "tls-exit"))
{
VERIFY_PERMISSION (OPT_P_GENERAL);
@@ -5511,6 +5765,7 @@ add_option (struct options *options,
VERIFY_PERMISSION (OPT_P_SCRIPT);
if (!no_more_than_n_args (msglevel, p, 2, NM_QUOTE_HINT))
goto err;
+ warn_multiple_script (options->tls_verify, "tls-verify");
options->tls_verify = string_substitute (p[1], ',', ' ', &options->gc);
}
else if (streq (p[0], "tls-export-cert") && p[1])
diff --git a/options.h b/options.h
index c1c96cd..7a61e3d 100644
--- a/options.h
+++ b/options.h
@@ -5,7 +5,7 @@
* packet encryption, packet authentication, and
* packet compression.
*
- * Copyright (C) 2002-2009 OpenVPN Technologies, Inc. <sales@openvpn.net>
+ * Copyright (C) 2002-2010 OpenVPN Technologies, Inc. <sales@openvpn.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2
@@ -98,6 +98,14 @@ struct connection_entry
const char *socks_proxy_authfile;
bool socks_proxy_retry;
#endif
+
+# define CE_DISABLED (1<<0)
+#if HTTP_PROXY_FALLBACK
+# define CE_HTTP_PROXY_FALLBACK (1<<1)
+ time_t ce_http_proxy_fallback_timestamp; /* time when fallback http_proxy_options was last updated */
+#endif
+
+ unsigned int flags;
};
struct remote_entry
@@ -115,6 +123,7 @@ struct connection_list
{
int len;
int current;
+ int n_cycles;
bool no_advance;
struct connection_entry *array[CONNECTION_LIST_SIZE];
};
@@ -127,6 +136,14 @@ struct remote_list
#endif
+#if HTTP_PROXY_FALLBACK
+struct hpo_store
+{
+ struct http_proxy_options hpo;
+ char server[80];
+};
+#endif
+
/* Command line options */
struct options
{
@@ -163,14 +180,22 @@ struct options
struct connection_entry ce;
#ifdef ENABLE_CONNECTION
+ char *remote_ip_hint;
struct connection_list *connection_list;
struct remote_list *remote_list;
+ bool force_connection_list;
#endif
#ifdef GENERAL_PROXY_SUPPORT
struct auto_proxy_info *auto_proxy_info;
#endif
+#if HTTP_PROXY_FALLBACK
+ bool http_proxy_fallback;
+ struct http_proxy_options *http_proxy_override;
+ struct hpo_store *hpo_store; /* used to store dynamic proxy info given by management interface */
+#endif
+
bool remote_random;
const char *ipchange;
const char *dev;
@@ -192,6 +217,8 @@ struct options
bool tun_mtu_defined; /* true if user overriding parm with command line option */
bool link_mtu_defined; /* true if user overriding parm with command line option */
+ int proto_force;
+
/* Advanced MTU negotiation and datagram fragmentation options */
int mtu_discover_type; /* used if OS supports setting Path MTU discovery options on socket */
@@ -445,6 +472,7 @@ struct options
const char *cert_file_inline;
char *priv_key_file_inline;
const char *dh_file_inline;
+ const char *pkcs12_file_inline; /* contains the base64 encoding of pkcs12 file */
#endif
int ns_cert_type; /* set to 0, NS_SSL_SERVER, or NS_SSL_CLIENT */
@@ -495,6 +523,10 @@ struct options
/* Allow only one session */
bool single_session;
+#ifdef ENABLE_PUSH_PEER_INFO
+ bool push_peer_info;
+#endif
+
bool tls_exit;
#endif /* USE_SSL */
@@ -710,4 +742,15 @@ connection_list_set_no_advance (struct options *o)
#endif
}
+#if HTTP_PROXY_FALLBACK
+
+struct http_proxy_options *
+parse_http_proxy_fallback (struct context *c,
+ const char *server,
+ const char *port,
+ const char *flags,
+ const int msglevel);
+
+#endif /* HTTP_PROXY_FALLBACK */
+
#endif
diff --git a/otime.c b/otime.c
index 5b55322..b295646 100644
--- a/otime.c
+++ b/otime.c
@@ -5,7 +5,7 @@
* packet encryption, packet authentication, and
* packet compression.
*
- * Copyright (C) 2002-2009 OpenVPN Technologies, Inc. <sales@openvpn.net>
+ * Copyright (C) 2002-2010 OpenVPN Technologies, Inc. <sales@openvpn.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2
diff --git a/otime.h b/otime.h
index 8e8aaaf..fd73bbd 100644
--- a/otime.h
+++ b/otime.h
@@ -5,7 +5,7 @@
* packet encryption, packet authentication, and
* packet compression.
*
- * Copyright (C) 2002-2009 OpenVPN Technologies, Inc. <sales@openvpn.net>
+ * Copyright (C) 2002-2010 OpenVPN Technologies, Inc. <sales@openvpn.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2
diff --git a/packet_id.c b/packet_id.c
index 6ccb311..b11e71f 100644
--- a/packet_id.c
+++ b/packet_id.c
@@ -5,7 +5,7 @@
* packet encryption, packet authentication, and
* packet compression.
*
- * Copyright (C) 2002-2009 OpenVPN Technologies, Inc. <sales@openvpn.net>
+ * Copyright (C) 2002-2010 OpenVPN Technologies, Inc. <sales@openvpn.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2
diff --git a/packet_id.h b/packet_id.h
index acb082a..12c1df3 100644
--- a/packet_id.h
+++ b/packet_id.h
@@ -5,7 +5,7 @@
* packet encryption, packet authentication, and
* packet compression.
*
- * Copyright (C) 2002-2009 OpenVPN Technologies, Inc. <sales@openvpn.net>
+ * Copyright (C) 2002-2010 OpenVPN Technologies, Inc. <sales@openvpn.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2
diff --git a/perf.c b/perf.c
index 67ea958..d9dbafc 100644
--- a/perf.c
+++ b/perf.c
@@ -5,7 +5,7 @@
* packet encryption, packet authentication, and
* packet compression.
*
- * Copyright (C) 2002-2009 OpenVPN Technologies, Inc. <sales@openvpn.net>
+ * Copyright (C) 2002-2010 OpenVPN Technologies, Inc. <sales@openvpn.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2
diff --git a/perf.h b/perf.h
index 5666a87..c531d9c 100644
--- a/perf.h
+++ b/perf.h
@@ -5,7 +5,7 @@
* packet encryption, packet authentication, and
* packet compression.
*
- * Copyright (C) 2002-2009 OpenVPN Technologies, Inc. <sales@openvpn.net>
+ * Copyright (C) 2002-2010 OpenVPN Technologies, Inc. <sales@openvpn.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2
diff --git a/pf-inline.h b/pf-inline.h
index 72ce435..6b5dcb2 100644
--- a/pf-inline.h
+++ b/pf-inline.h
@@ -5,7 +5,7 @@
* packet encryption, packet authentication, and
* packet compression.
*
- * Copyright (C) 2002-2009 OpenVPN Technologies, Inc. <sales@openvpn.net>
+ * Copyright (C) 2002-2010 OpenVPN Technologies, Inc. <sales@openvpn.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2
diff --git a/pf.c b/pf.c
index ee38ca6..6b4cba4 100644
--- a/pf.c
+++ b/pf.c
@@ -5,7 +5,7 @@
* packet encryption, packet authentication, and
* packet compression.
*
- * Copyright (C) 2002-2009 OpenVPN Technologies, Inc. <sales@openvpn.net>
+ * Copyright (C) 2002-2010 OpenVPN Technologies, Inc. <sales@openvpn.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2
@@ -109,6 +109,11 @@ add_subnet (const char *line, const char *prefix, const int line_num, struct pf_
return false;
}
netmask = netbits_to_netmask (netbits);
+ if ((network.s_addr & htonl (netmask)) != network.s_addr)
+ {
+ network.s_addr &= htonl (netmask);
+ msg (M_WARN, "WARNING: PF: %s/%d: incorrect subnet %s/%d changed to %s/%d", prefix, line_num, line, netbits, inet_ntoa (network), netbits);
+ }
}
else
{
@@ -554,24 +559,25 @@ pf_init_context (struct context *c)
#ifdef PLUGIN_PF
if (plugin_defined (c->plugins, OPENVPN_PLUGIN_ENABLE_PF))
{
- const char *pf_file = create_temp_filename (c->options.tmp_dir, "pf", &gc);
- delete_file (pf_file);
- setenv_str (c->c2.es, "pf_file", pf_file);
-
- if (plugin_call (c->plugins, OPENVPN_PLUGIN_ENABLE_PF, NULL, NULL, c->c2.es) == OPENVPN_PLUGIN_FUNC_SUCCESS)
- {
- event_timeout_init (&c->c2.pf.reload, 1, now);
- c->c2.pf.filename = string_alloc (pf_file, NULL);
- c->c2.pf.enabled = true;
+ const char *pf_file = create_temp_file (c->options.tmp_dir, "pf", &gc);
+ if( pf_file ) {
+ setenv_str (c->c2.es, "pf_file", pf_file);
+
+ if (plugin_call (c->plugins, OPENVPN_PLUGIN_ENABLE_PF, NULL, NULL, c->c2.es) == OPENVPN_PLUGIN_FUNC_SUCCESS)
+ {
+ event_timeout_init (&c->c2.pf.reload, 1, now);
+ c->c2.pf.filename = string_alloc (pf_file, NULL);
+ c->c2.pf.enabled = true;
#ifdef ENABLE_DEBUG
- if (check_debug_level (D_PF_DEBUG))
- pf_context_print (&c->c2.pf, "pf_init_context#1", D_PF_DEBUG);
+ if (check_debug_level (D_PF_DEBUG))
+ pf_context_print (&c->c2.pf, "pf_init_context#1", D_PF_DEBUG);
#endif
- }
- else
- {
- msg (M_WARN, "WARNING: OPENVPN_PLUGIN_ENABLE_PF disabled");
- }
+ }
+ else
+ {
+ msg (M_WARN, "WARNING: OPENVPN_PLUGIN_ENABLE_PF disabled");
+ }
+ }
}
#endif
#ifdef MANAGEMENT_PF
diff --git a/pf.h b/pf.h
index bbf77c1..04adf0e 100644
--- a/pf.h
+++ b/pf.h
@@ -5,7 +5,7 @@
* packet encryption, packet authentication, and
* packet compression.
*
- * Copyright (C) 2002-2009 OpenVPN Technologies, Inc. <sales@openvpn.net>
+ * Copyright (C) 2002-2010 OpenVPN Technologies, Inc. <sales@openvpn.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2
diff --git a/ping-inline.h b/ping-inline.h
index 6aace91..c724970 100644
--- a/ping-inline.h
+++ b/ping-inline.h
@@ -5,7 +5,7 @@
* packet encryption, packet authentication, and
* packet compression.
*
- * Copyright (C) 2002-2009 OpenVPN Technologies, Inc. <sales@openvpn.net>
+ * Copyright (C) 2002-2010 OpenVPN Technologies, Inc. <sales@openvpn.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2
diff --git a/ping.c b/ping.c
index 9692c1a..191ad74 100644
--- a/ping.c
+++ b/ping.c
@@ -5,7 +5,7 @@
* packet encryption, packet authentication, and
* packet compression.
*
- * Copyright (C) 2002-2009 OpenVPN Technologies, Inc. <sales@openvpn.net>
+ * Copyright (C) 2002-2010 OpenVPN Technologies, Inc. <sales@openvpn.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2
@@ -86,5 +86,7 @@ check_ping_send_dowork (struct context *c)
* encrypt, sign, etc.
*/
encrypt_sign (c, true);
+ /* Set length to 0, so it won't be counted as activity */
+ c->c2.buf.len = 0;
dmsg (D_PING, "SENT PING");
}
diff --git a/ping.h b/ping.h
index f788809..88f5f3a 100644
--- a/ping.h
+++ b/ping.h
@@ -5,7 +5,7 @@
* packet encryption, packet authentication, and
* packet compression.
*
- * Copyright (C) 2002-2009 OpenVPN Technologies, Inc. <sales@openvpn.net>
+ * Copyright (C) 2002-2010 OpenVPN Technologies, Inc. <sales@openvpn.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2
diff --git a/pkcs11.c b/pkcs11.c
index d90ac96..af781e0 100644
--- a/pkcs11.c
+++ b/pkcs11.c
@@ -5,7 +5,7 @@
* packet encryption, packet authentication, and
* packet compression.
*
- * Copyright (C) 2002-2009 OpenVPN Technologies, Inc. <sales@openvpn.net>
+ * Copyright (C) 2002-2010 OpenVPN Technologies, Inc. <sales@openvpn.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2
diff --git a/pkcs11.h b/pkcs11.h
index 48106bb..abe03b9 100644
--- a/pkcs11.h
+++ b/pkcs11.h
@@ -5,7 +5,7 @@
* packet encryption, packet authentication, and
* packet compression.
*
- * Copyright (C) 2002-2009 OpenVPN Technologies, Inc. <sales@openvpn.net>
+ * Copyright (C) 2002-2010 OpenVPN Technologies, Inc. <sales@openvpn.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2
diff --git a/plugin.c b/plugin.c
index 0e7779e..0d66611 100644
--- a/plugin.c
+++ b/plugin.c
@@ -5,7 +5,7 @@
* packet encryption, packet authentication, and
* packet compression.
*
- * Copyright (C) 2002-2009 OpenVPN Technologies, Inc. <sales@openvpn.net>
+ * Copyright (C) 2002-2010 OpenVPN Technologies, Inc. <sales@openvpn.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2
diff --git a/plugin.h b/plugin.h
index 02da000..969d451 100644
--- a/plugin.h
+++ b/plugin.h
@@ -5,7 +5,7 @@
* packet encryption, packet authentication, and
* packet compression.
*
- * Copyright (C) 2002-2009 OpenVPN Technologies, Inc. <sales@openvpn.net>
+ * Copyright (C) 2002-2010 OpenVPN Technologies, Inc. <sales@openvpn.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2
diff --git a/plugin/auth-pam/auth-pam.c b/plugin/auth-pam/auth-pam.c
index b029f85..5a8e269 100644
--- a/plugin/auth-pam/auth-pam.c
+++ b/plugin/auth-pam/auth-pam.c
@@ -5,7 +5,7 @@
* packet encryption, packet authentication, and
* packet compression.
*
- * Copyright (C) 2002-2009 OpenVPN Technologies, Inc. <sales@openvpn.net>
+ * Copyright (C) 2002-2010 OpenVPN Technologies, Inc. <sales@openvpn.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2
@@ -111,6 +111,35 @@ struct user_pass {
/* Background process function */
static void pam_server (int fd, const char *service, int verb, const struct name_value_list *name_value_list);
+/* Read 'tosearch', replace all occurences of 'searchfor' with 'replacewith' and return
+ * a pointer to the NEW string. Does not modify the input strings. Will not enter an
+ * infinite loop with clever 'searchfor' and 'replacewith' strings.
+ * Daniel Johnson - Progman2000@usa.net / djohnson@progman.us
+ */
+static char *
+searchandreplace(const char *tosearch, const char *searchfor, const char *replacewith)
+{
+ if (!tosearch || !searchfor || !replacewith) return 0;
+ if (!strlen(tosearch) || !strlen(searchfor) || !strlen(replacewith)) return 0;
+
+ const char *searching=tosearch;
+ char *scratch;
+ char temp[strlen(tosearch)*10];
+ temp[0]=0;
+
+ scratch = strstr(searching,searchfor);
+ if (!scratch) return strdup(tosearch);
+
+ while (scratch) {
+ strncat(temp,searching,scratch-searching);
+ strcat(temp,replacewith);
+
+ searching=scratch+strlen(searchfor);
+ scratch = strstr(searching,searchfor);
+ }
+ return strdup(temp);
+}
+
/*
* Given an environmental variable name, search
* the envp array for its value, returning it
@@ -551,7 +580,7 @@ my_conv (int n, const struct pam_message **msg_array,
if (name_value_match (msg->msg, match_name))
{
/* found name/value match */
- const char *return_value = NULL;
+ aresp[i].resp = NULL;
if (DEBUG (up->verb))
fprintf (stderr, "AUTH-PAM: BACKGROUND: name match found, query/match-string ['%s', '%s'] = '%s'\n",
@@ -559,14 +588,13 @@ my_conv (int n, const struct pam_message **msg_array,
match_name,
match_value);
- if (!strcmp (match_value, "USERNAME"))
- return_value = up->username;
- else if (!strcmp (match_value, "PASSWORD"))
- return_value = up->password;
+ if (strstr(match_value, "USERNAME"))
+ aresp[i].resp = searchandreplace(match_value, "USERNAME", up->username);
+ else if (strstr(match_value, "PASSWORD"))
+ aresp[i].resp = searchandreplace(match_value, "PASSWORD", up->password);
else
- return_value = match_value;
+ aresp[i].resp = strdup (match_value);
- aresp[i].resp = strdup (return_value);
if (aresp[i].resp == NULL)
ret = PAM_CONV_ERR;
break;
diff --git a/plugin/defer/simple.c b/plugin/defer/simple.c
index 4ee9b73..6539865 100644
--- a/plugin/defer/simple.c
+++ b/plugin/defer/simple.c
@@ -5,7 +5,7 @@
* packet encryption, packet authentication, and
* packet compression.
*
- * Copyright (C) 2002-2009 OpenVPN Technologies, Inc. <sales@openvpn.net>
+ * Copyright (C) 2002-2010 OpenVPN Technologies, Inc. <sales@openvpn.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2
diff --git a/plugin/down-root/down-root.c b/plugin/down-root/down-root.c
index 7cf8f18..fced23b 100644
--- a/plugin/down-root/down-root.c
+++ b/plugin/down-root/down-root.c
@@ -5,7 +5,7 @@
* packet encryption, packet authentication, and
* packet compression.
*
- * Copyright (C) 2002-2009 OpenVPN Technologies, Inc. <sales@openvpn.net>
+ * Copyright (C) 2002-2010 OpenVPN Technologies, Inc. <sales@openvpn.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2
diff --git a/plugin/examples/log.c b/plugin/examples/log.c
index 9304af7..1cc4650 100644
--- a/plugin/examples/log.c
+++ b/plugin/examples/log.c
@@ -5,7 +5,7 @@
* packet encryption, packet authentication, and
* packet compression.
*
- * Copyright (C) 2002-2009 OpenVPN Technologies, Inc. <sales@openvpn.net>
+ * Copyright (C) 2002-2010 OpenVPN Technologies, Inc. <sales@openvpn.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2
diff --git a/plugin/examples/simple.c b/plugin/examples/simple.c
index 44da53e..f26d89f 100644
--- a/plugin/examples/simple.c
+++ b/plugin/examples/simple.c
@@ -5,7 +5,7 @@
* packet encryption, packet authentication, and
* packet compression.
*
- * Copyright (C) 2002-2009 OpenVPN Technologies, Inc. <sales@openvpn.net>
+ * Copyright (C) 2002-2010 OpenVPN Technologies, Inc. <sales@openvpn.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2
diff --git a/pool.c b/pool.c
index 5600083..84333df 100644
--- a/pool.c
+++ b/pool.c
@@ -5,7 +5,7 @@
* packet encryption, packet authentication, and
* packet compression.
*
- * Copyright (C) 2002-2009 OpenVPN Technologies, Inc. <sales@openvpn.net>
+ * Copyright (C) 2002-2010 OpenVPN Technologies, Inc. <sales@openvpn.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2
diff --git a/pool.h b/pool.h
index d2a7ceb..81264a9 100644
--- a/pool.h
+++ b/pool.h
@@ -5,7 +5,7 @@
* packet encryption, packet authentication, and
* packet compression.
*
- * Copyright (C) 2002-2009 OpenVPN Technologies, Inc. <sales@openvpn.net>
+ * Copyright (C) 2002-2010 OpenVPN Technologies, Inc. <sales@openvpn.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2
diff --git a/proto.c b/proto.c
index 72a3c6b..65a6b67 100644
--- a/proto.c
+++ b/proto.c
@@ -5,7 +5,7 @@
* packet encryption, packet authentication, and
* packet compression.
*
- * Copyright (C) 2002-2009 OpenVPN Technologies, Inc. <sales@openvpn.net>
+ * Copyright (C) 2002-2010 OpenVPN Technologies, Inc. <sales@openvpn.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2
diff --git a/proto.h b/proto.h
index f26fc8c..55f0832 100644
--- a/proto.h
+++ b/proto.h
@@ -5,7 +5,7 @@
* packet encryption, packet authentication, and
* packet compression.
*
- * Copyright (C) 2002-2009 OpenVPN Technologies, Inc. <sales@openvpn.net>
+ * Copyright (C) 2002-2010 OpenVPN Technologies, Inc. <sales@openvpn.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2
diff --git a/proxy.c b/proxy.c
index 6e5a30a..fce64a1 100644
--- a/proxy.c
+++ b/proxy.c
@@ -5,7 +5,7 @@
* packet encryption, packet authentication, and
* packet compression.
*
- * Copyright (C) 2002-2009 OpenVPN Technologies, Inc. <sales@openvpn.net>
+ * Copyright (C) 2002-2010 OpenVPN Technologies, Inc. <sales@openvpn.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2
@@ -26,11 +26,13 @@
#include "common.h"
#include "misc.h"
+#include "crypto.h"
#include "win32.h"
#include "socket.h"
#include "fdmisc.h"
#include "proxy.h"
#include "base64.h"
+#include "httpdigest.h"
#include "ntlm.h"
#ifdef WIN32
@@ -41,6 +43,8 @@
#ifdef ENABLE_HTTP_PROXY
+#define UP_TYPE_PROXY "HTTP Proxy"
+
/* cached proxy username/password */
static struct user_pass static_proxy_user_pass;
@@ -220,13 +224,200 @@ get_user_pass_http (struct http_proxy_info *p, const bool force)
{
if (!static_proxy_user_pass.defined || force)
{
+ unsigned int flags = GET_USER_PASS_MANAGEMENT;
+ if (p->queried_creds)
+ flags |= GET_USER_PASS_PREVIOUS_CREDS_FAILED;
get_user_pass (&static_proxy_user_pass,
p->options.auth_file,
- "HTTP Proxy",
- GET_USER_PASS_MANAGEMENT);
+ UP_TYPE_PROXY,
+ flags);
+ p->queried_creds = true;
p->up = static_proxy_user_pass;
}
}
+static void
+clear_user_pass_http (void)
+{
+ purge_user_pass (&static_proxy_user_pass, true);
+}
+
+static void
+dump_residual (socket_descriptor_t sd,
+ int timeout,
+ volatile int *signal_received)
+{
+ char buf[256];
+ while (true)
+ {
+ if (!recv_line (sd, buf, sizeof (buf), timeout, true, NULL, signal_received))
+ return;
+ chomp (buf);
+ msg (D_PROXY, "PROXY HEADER: '%s'", buf);
+ }
+}
+
+/*
+ * Extract the Proxy-Authenticate header from the stream.
+ * Consumes all headers.
+ */
+static int
+get_proxy_authenticate (socket_descriptor_t sd,
+ int timeout,
+ char **data,
+ struct gc_arena *gc,
+ volatile int *signal_received)
+{
+ char buf[256];
+ int ret = HTTP_AUTH_NONE;
+ while (true)
+ {
+ if (!recv_line (sd, buf, sizeof (buf), timeout, true, NULL, signal_received))
+ {
+ *data = NULL;
+ return HTTP_AUTH_NONE;
+ }
+ chomp (buf);
+ if (!strlen(buf))
+ return ret;
+ if (ret == HTTP_AUTH_NONE && !strncmp(buf, "Proxy-Authenticate: ", 20))
+ {
+ if (!strncmp(buf+20, "Basic ", 6))
+ {
+ msg (D_PROXY, "PROXY AUTH BASIC: '%s'", buf);
+ *data = string_alloc(buf+26, gc);
+ ret = HTTP_AUTH_BASIC;
+ }
+#if PROXY_DIGEST_AUTH
+ else if (!strncmp(buf+20, "Digest ", 7))
+ {
+ msg (D_PROXY, "PROXY AUTH DIGEST: '%s'", buf);
+ *data = string_alloc(buf+27, gc);
+ ret = HTTP_AUTH_DIGEST;
+ }
+#endif
+#if NTLM
+ else if (!strncmp(buf+20, "NTLM", 4))
+ {
+ msg (D_PROXY, "PROXY AUTH HTLM: '%s'", buf);
+ *data = NULL;
+ ret = HTTP_AUTH_NTLM;
+ }
+#endif
+ }
+ }
+}
+
+static void
+store_proxy_authenticate (struct http_proxy_info *p, char *data)
+{
+ if (p->proxy_authenticate)
+ free (p->proxy_authenticate);
+ p->proxy_authenticate = data;
+}
+
+/*
+ * Parse out key/value pairs from Proxy-Authenticate string.
+ * Return true on success, or false on parse failure.
+ */
+static bool
+get_key_value(const char *str, /* source string */
+ char *key, /* key stored here */
+ char *value, /* value stored here */
+ int max_key_len,
+ int max_value_len,
+ const char **endptr) /* next search position */
+{
+ int c;
+ bool starts_with_quote = false;
+ bool escape = false;
+
+ for (c = max_key_len-1; (*str && (*str != '=') && c--); )
+ *key++ = *str++;
+ *key = '\0';
+
+ if('=' != *str++)
+ /* no key/value found */
+ return false;
+
+ if('\"' == *str)
+ {
+ /* quoted string */
+ str++;
+ starts_with_quote = true;
+ }
+
+ for (c = max_value_len-1; *str && c--; str++)
+ {
+ switch (*str)
+ {
+ case '\\':
+ if (!escape)
+ {
+ /* possibly the start of an escaped quote */
+ escape = true;
+ *value++ = '\\'; /* even though this is an escape character, we still
+ store it as-is in the target buffer */
+ continue;
+ }
+ break;
+ case ',':
+ if (!starts_with_quote)
+ {
+ /* this signals the end of the value if we didn't get a starting quote
+ and then we do "sloppy" parsing */
+ c=0; /* the end */
+ continue;
+ }
+ break;
+ case '\r':
+ case '\n':
+ /* end of string */
+ c=0;
+ continue;
+ case '\"':
+ if (!escape && starts_with_quote)
+ {
+ /* end of string */
+ c=0;
+ continue;
+ }
+ break;
+ }
+ escape = false;
+ *value++ = *str;
+ }
+ *value = '\0';
+
+ *endptr = str;
+
+ return true; /* success */
+}
+
+static char *
+get_pa_var (const char *key, const char *pa, struct gc_arena *gc)
+{
+ char k[64];
+ char v[256];
+ const char *content = pa;
+
+ while (true)
+ {
+ const int status = get_key_value(content, k, v, sizeof(k), sizeof(v), &content);
+ if (status)
+ {
+ if (!strcmp(key, k))
+ return string_alloc(v, gc);
+ }
+ else
+ return NULL;
+
+ /* advance to start of next key */
+ if (*content == ',')
+ ++content;
+ while (*content && isspace(*content))
+ ++content;
+ }
+}
struct http_proxy_info *
http_proxy_new (const struct http_proxy_options *o,
@@ -263,7 +454,8 @@ http_proxy_new (const struct http_proxy_options *o,
opt.server = auto_proxy_info->http.server;
opt.port = auto_proxy_info->http.port;
- opt.auth_retry = true;
+ if (!opt.auth_retry)
+ opt.auth_retry = PAR_ALL;
o = &opt;
}
@@ -285,12 +477,14 @@ http_proxy_new (const struct http_proxy_options *o,
p->auth_method = HTTP_AUTH_NONE;
else if (!strcmp (o->auth_method_string, "basic"))
p->auth_method = HTTP_AUTH_BASIC;
+#if NTLM
else if (!strcmp (o->auth_method_string, "ntlm"))
p->auth_method = HTTP_AUTH_NTLM;
else if (!strcmp (o->auth_method_string, "ntlm2"))
p->auth_method = HTTP_AUTH_NTLM2;
+#endif
else
- msg (M_FATAL, "ERROR: unknown HTTP authentication method: '%s' -- only the 'none', 'basic', 'ntlm', or 'ntlm2' methods are currently supported",
+ msg (M_FATAL, "ERROR: unknown HTTP authentication method: '%s'",
o->auth_method_string);
}
@@ -324,101 +518,117 @@ establish_http_proxy_passthru (struct http_proxy_info *p,
volatile int *signal_received)
{
struct gc_arena gc = gc_new ();
- char buf[256];
+ char buf[512];
char buf2[128];
char get[80];
int status;
int nparms;
bool ret = false;
+ bool processed = false;
/* get user/pass if not previously given or if --auto-proxy is being used */
if (p->auth_method == HTTP_AUTH_BASIC
+ || p->auth_method == HTTP_AUTH_DIGEST
|| p->auth_method == HTTP_AUTH_NTLM)
get_user_pass_http (p, false);
- /* format HTTP CONNECT message */
- openvpn_snprintf (buf, sizeof(buf), "CONNECT %s:%d HTTP/%s",
- host,
- port,
- p->options.http_version);
-
- msg (D_PROXY, "Send to HTTP proxy: '%s'", buf);
-
- /* send HTTP CONNECT message to proxy */
- if (!send_line_crlf (sd, buf))
- goto error;
-
- /* send User-Agent string if provided */
- if (p->options.user_agent)
+ /* are we being called again after getting the digest server nonce in the previous transaction? */
+ if (p->auth_method == HTTP_AUTH_DIGEST && p->proxy_authenticate)
{
- openvpn_snprintf (buf, sizeof(buf), "User-Agent: %s",
- p->options.user_agent);
- if (!send_line_crlf (sd, buf))
- goto error;
+ nparms = 1;
+ status = 407;
}
-
- /* auth specified? */
- switch (p->auth_method)
+ else
{
- case HTTP_AUTH_NONE:
- break;
+ /* format HTTP CONNECT message */
+ openvpn_snprintf (buf, sizeof(buf), "CONNECT %s:%d HTTP/%s",
+ host,
+ port,
+ p->options.http_version);
- case HTTP_AUTH_BASIC:
- openvpn_snprintf (buf, sizeof(buf), "Proxy-Authorization: Basic %s",
- username_password_as_base64 (p, &gc));
- msg (D_PROXY, "Attempting Basic Proxy-Authorization");
- dmsg (D_SHOW_KEYS, "Send to HTTP proxy: '%s'", buf);
- openvpn_sleep (1);
+ msg (D_PROXY, "Send to HTTP proxy: '%s'", buf);
+
+ /* send HTTP CONNECT message to proxy */
if (!send_line_crlf (sd, buf))
goto error;
- break;
+
+ openvpn_snprintf(buf, sizeof(buf), "Host: %s", host);
+ if (!send_line_crlf(sd, buf))
+ goto error;
+
+ /* send User-Agent string if provided */
+ if (p->options.user_agent)
+ {
+ openvpn_snprintf (buf, sizeof(buf), "User-Agent: %s",
+ p->options.user_agent);
+ if (!send_line_crlf (sd, buf))
+ goto error;
+ }
+
+ /* auth specified? */
+ switch (p->auth_method)
+ {
+ case HTTP_AUTH_NONE:
+ break;
+
+ case HTTP_AUTH_BASIC:
+ openvpn_snprintf (buf, sizeof(buf), "Proxy-Authorization: Basic %s",
+ username_password_as_base64 (p, &gc));
+ msg (D_PROXY, "Attempting Basic Proxy-Authorization");
+ dmsg (D_SHOW_KEYS, "Send to HTTP proxy: '%s'", buf);
+ if (!send_line_crlf (sd, buf))
+ goto error;
+ break;
#if NTLM
- case HTTP_AUTH_NTLM:
- case HTTP_AUTH_NTLM2:
- /* keep-alive connection */
- openvpn_snprintf (buf, sizeof(buf), "Proxy-Connection: Keep-Alive");
- if (!send_line_crlf (sd, buf))
- goto error;
+ case HTTP_AUTH_NTLM:
+ case HTTP_AUTH_NTLM2:
+ /* keep-alive connection */
+ openvpn_snprintf (buf, sizeof(buf), "Proxy-Connection: Keep-Alive");
+ if (!send_line_crlf (sd, buf))
+ goto error;
- openvpn_snprintf (buf, sizeof(buf), "Proxy-Authorization: NTLM %s",
- ntlm_phase_1 (p, &gc));
- msg (D_PROXY, "Attempting NTLM Proxy-Authorization phase 1");
- dmsg (D_SHOW_KEYS, "Send to HTTP proxy: '%s'", buf);
- openvpn_sleep (1);
- if (!send_line_crlf (sd, buf))
- goto error;
- break;
+ openvpn_snprintf (buf, sizeof(buf), "Proxy-Authorization: NTLM %s",
+ ntlm_phase_1 (p, &gc));
+ msg (D_PROXY, "Attempting NTLM Proxy-Authorization phase 1");
+ dmsg (D_SHOW_KEYS, "Send to HTTP proxy: '%s'", buf);
+ if (!send_line_crlf (sd, buf))
+ goto error;
+ break;
#endif
- default:
- ASSERT (0);
- }
+ default:
+ ASSERT (0);
+ }
- /* send empty CR, LF */
- openvpn_sleep (1);
- if (!send_crlf (sd))
- goto error;
+ /* send empty CR, LF */
+ if (!send_crlf (sd))
+ goto error;
- /* receive reply from proxy */
- if (!recv_line (sd, buf, sizeof(buf), p->options.timeout, true, NULL, signal_received))
- goto error;
+ /* receive reply from proxy */
+ if (!recv_line (sd, buf, sizeof(buf), p->options.timeout, true, NULL, signal_received))
+ goto error;
- /* remove trailing CR, LF */
- chomp (buf);
+ /* remove trailing CR, LF */
+ chomp (buf);
- msg (D_PROXY, "HTTP proxy returned: '%s'", buf);
+ msg (D_PROXY, "HTTP proxy returned: '%s'", buf);
- /* parse return string */
- nparms = sscanf (buf, "%*s %d", &status);
+ /* parse return string */
+ nparms = sscanf (buf, "%*s %d", &status);
+
+ }
/* check for a "407 Proxy Authentication Required" response */
- if (nparms >= 1 && status == 407)
+ while (nparms >= 1 && status == 407)
{
msg (D_PROXY, "Proxy requires authentication");
- /* check for NTLM */
- if (p->auth_method == HTTP_AUTH_NTLM || p->auth_method == HTTP_AUTH_NTLM2)
+ if (p->auth_method == HTTP_AUTH_BASIC && !processed)
+ {
+ processed = true;
+ }
+ else if ((p->auth_method == HTTP_AUTH_NTLM || p->auth_method == HTTP_AUTH_NTLM2) && !processed) /* check for NTLM */
{
#if NTLM
/* look for the phase 2 response */
@@ -446,7 +656,7 @@ establish_http_proxy_passthru (struct http_proxy_info *p,
msg (D_PROXY, "Received NTLM Proxy-Authorization phase 2 response");
/* receive and discard everything else */
- while (recv_line (sd, NULL, 0, p->options.timeout, true, NULL, signal_received))
+ while (recv_line (sd, NULL, 0, 2, true, NULL, signal_received))
;
/* now send the phase 3 reply */
@@ -470,7 +680,6 @@ establish_http_proxy_passthru (struct http_proxy_info *p,
/* send HOST etc, */
- openvpn_sleep (1);
openvpn_snprintf (buf, sizeof(buf), "Host: %s", host);
msg (D_PROXY, "Send to HTTP proxy: '%s'", buf);
if (!send_line_crlf (sd, buf))
@@ -488,12 +697,10 @@ establish_http_proxy_passthru (struct http_proxy_info *p,
}
msg (D_PROXY, "Send to HTTP proxy: '%s'", buf);
- openvpn_sleep (1);
if (!send_line_crlf (sd, buf))
goto error;
/* ok so far... */
/* send empty CR, LF */
- openvpn_sleep (1);
if (!send_crlf (sd))
goto error;
@@ -508,27 +715,167 @@ establish_http_proxy_passthru (struct http_proxy_info *p,
/* parse return string */
nparms = sscanf (buf, "%*s %d", &status);
-#else
- ASSERT (0); /* No NTLM support */
+ processed = true;
#endif
}
- else if (p->auth_method == HTTP_AUTH_NONE && p->options.auth_retry)
+#if PROXY_DIGEST_AUTH
+ else if (p->auth_method == HTTP_AUTH_DIGEST && !processed)
{
- /*
- * Proxy needs authentication, but we don't have a user/pass.
- * Now we will change p->auth_method and return true so that
- * our caller knows to call us again on a newly opened socket.
- * JYFIXME: This code needs to check proxy error output and set
- * JYFIXME: p->auth_method = HTTP_AUTH_NTLM if necessary.
- */
- p->auth_method = HTTP_AUTH_BASIC;
- ret = true;
- goto done;
+ char *pa = p->proxy_authenticate;
+ const int method = p->auth_method;
+ ASSERT(pa);
+
+ if (method == HTTP_AUTH_DIGEST)
+ {
+ const char *http_method = "CONNECT";
+ const char *nonce_count = "00000001";
+ const char *qop = "auth";
+ const char *username = p->up.username;
+ const char *password = p->up.password;
+ char *opaque_kv = "";
+ char uri[128];
+ uint8_t cnonce_raw[8];
+ uint8_t *cnonce;
+ HASHHEX session_key;
+ HASHHEX response;
+
+ const char *realm = get_pa_var("realm", pa, &gc);
+ const char *nonce = get_pa_var("nonce", pa, &gc);
+ const char *algor = get_pa_var("algorithm", pa, &gc);
+ const char *opaque = get_pa_var("opaque", pa, &gc);
+
+ /* generate a client nonce */
+ ASSERT(RAND_bytes(cnonce_raw, sizeof(cnonce_raw)));
+ cnonce = make_base64_string2(cnonce_raw, sizeof(cnonce_raw), &gc);
+
+
+ /* build the digest response */
+ openvpn_snprintf (uri, sizeof(uri), "%s:%d",
+ host,
+ port);
+
+ if (opaque)
+ {
+ const int len = strlen(opaque)+16;
+ opaque_kv = gc_malloc(len, false, &gc);
+ openvpn_snprintf (opaque_kv, len, ", opaque=\"%s\"", opaque);
+ }
+
+ DigestCalcHA1(algor,
+ username,
+ realm,
+ password,
+ nonce,
+ (char *)cnonce,
+ session_key);
+ DigestCalcResponse(session_key,
+ nonce,
+ nonce_count,
+ (char *)cnonce,
+ qop,
+ http_method,
+ uri,
+ NULL,
+ response);
+
+ /* format HTTP CONNECT message */
+ openvpn_snprintf (buf, sizeof(buf), "%s %s HTTP/%s",
+ http_method,
+ uri,
+ p->options.http_version);
+
+ msg (D_PROXY, "Send to HTTP proxy: '%s'", buf);
+
+ /* send HTTP CONNECT message to proxy */
+ if (!send_line_crlf (sd, buf))
+ goto error;
+
+ /* send HOST etc, */
+ openvpn_snprintf (buf, sizeof(buf), "Host: %s", host);
+ msg (D_PROXY, "Send to HTTP proxy: '%s'", buf);
+ if (!send_line_crlf (sd, buf))
+ goto error;
+
+ /* send digest response */
+ openvpn_snprintf (buf, sizeof(buf), "Proxy-Authorization: Digest username=\"%s\", realm=\"%s\", nonce=\"%s\", uri=\"%s\", qop=%s, nc=%s, cnonce=\"%s\", response=\"%s\"%s",
+ username,
+ realm,
+ nonce,
+ uri,
+ qop,
+ nonce_count,
+ cnonce,
+ response,
+ opaque_kv
+ );
+ msg (D_PROXY, "Send to HTTP proxy: '%s'", buf);
+ if (!send_line_crlf (sd, buf))
+ goto error;
+ if (!send_crlf (sd))
+ goto error;
+
+ /* receive reply from proxy */
+ if (!recv_line (sd, buf, sizeof(buf), p->options.timeout, true, NULL, signal_received))
+ goto error;
+
+ /* remove trailing CR, LF */
+ chomp (buf);
+
+ msg (D_PROXY, "HTTP proxy returned: '%s'", buf);
+
+ /* parse return string */
+ nparms = sscanf (buf, "%*s %d", &status);
+ processed = true;
+ }
+ else
+ {
+ msg (D_PROXY, "HTTP proxy: digest method not supported");
+ goto error;
+ }
+ }
+#endif
+ else if (p->options.auth_retry)
+ {
+ /* figure out what kind of authentication the proxy needs */
+ char *pa = NULL;
+ const int method = get_proxy_authenticate(sd,
+ p->options.timeout,
+ &pa,
+ NULL,
+ signal_received);
+ if (method != HTTP_AUTH_NONE)
+ {
+ if (pa)
+ msg (D_PROXY, "HTTP proxy authenticate '%s'", pa);
+ if (p->options.auth_retry == PAR_NCT && method == HTTP_AUTH_BASIC)
+ {
+ msg (D_PROXY, "HTTP proxy: support for basic auth and other cleartext proxy auth methods is disabled");
+ goto error;
+ }
+ p->auth_method = method;
+ store_proxy_authenticate(p, pa);
+ ret = true;
+ goto done;
+ }
+ else
+ {
+ msg (D_PROXY, "HTTP proxy: do not recognize the authentication method required by proxy");
+ free (pa);
+ goto error;
+ }
}
else
- goto error;
- }
+ {
+ if (!processed)
+ msg (D_PROXY, "HTTP proxy: no support for proxy authentication method");
+ goto error;
+ }
+ /* clear state */
+ if (p->options.auth_retry)
+ clear_user_pass_http();
+ store_proxy_authenticate(p, NULL);
+ }
/* check return code, success = 200 */
if (nparms < 1 || status != 200)
@@ -536,17 +883,13 @@ establish_http_proxy_passthru (struct http_proxy_info *p,
msg (D_LINK_ERRORS, "HTTP proxy returned bad status");
#if 0
/* DEBUGGING -- show a multi-line HTTP error response */
- while (true)
- {
- if (!recv_line (sd, buf, sizeof (buf), p->options.timeout, true, NULL, signal_received))
- goto error;
- chomp (buf);
- msg (D_PROXY, "HTTP proxy returned: '%s'", buf);
- }
+ dump_residual(sd, p->options.timeout, signal_received);
#endif
goto error;
}
+ /* SUCCESS */
+
/* receive line from proxy and discard */
if (!recv_line (sd, NULL, 0, p->options.timeout, true, NULL, signal_received))
goto error;
@@ -558,6 +901,9 @@ establish_http_proxy_passthru (struct http_proxy_info *p,
while (recv_line (sd, NULL, 0, 2, false, lookahead, signal_received))
;
+ /* reset queried_creds so that we don't think that the next creds request is due to an auth error */
+ p->queried_creds = false;
+
#if 0
if (lookahead && BLEN (lookahead))
msg (M_INFO, "HTTP PROXY: lookahead: %s", format_hex (BPTR (lookahead), BLEN (lookahead), 0));
diff --git a/proxy.h b/proxy.h
index 3f30eef..d89aa4a 100644
--- a/proxy.h
+++ b/proxy.h
@@ -5,7 +5,7 @@
* packet encryption, packet authentication, and
* packet compression.
*
- * Copyright (C) 2002-2009 OpenVPN Technologies, Inc. <sales@openvpn.net>
+ * Copyright (C) 2002-2010 OpenVPN Technologies, Inc. <sales@openvpn.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2
@@ -55,29 +55,43 @@ void show_win_proxy_settings (const int msglevel);
#ifdef ENABLE_HTTP_PROXY
/* HTTP CONNECT authentication methods */
-#define HTTP_AUTH_NONE 0
-#define HTTP_AUTH_BASIC 1
-#define HTTP_AUTH_NTLM 2
-#define HTTP_AUTH_N 3
-#define HTTP_AUTH_NTLM2 4
+#define HTTP_AUTH_NONE 0
+#define HTTP_AUTH_BASIC 1
+#define HTTP_AUTH_DIGEST 2
+#define HTTP_AUTH_NTLM 3
+#define HTTP_AUTH_NTLM2 4
+#define HTTP_AUTH_N 5 /* number of HTTP_AUTH methods */
struct http_proxy_options {
const char *server;
int port;
bool retry;
int timeout;
- bool auth_retry;
+
+# define PAR_NO 0 /* don't support any auth retries */
+# define PAR_ALL 1 /* allow all proxy auth protocols */
+# define PAR_NCT 2 /* disable cleartext proxy auth protocols */
+ int auth_retry;
+
const char *auth_method_string;
const char *auth_file;
const char *http_version;
const char *user_agent;
};
+struct http_proxy_options_simple {
+ const char *server;
+ int port;
+ int auth_retry;
+};
+
struct http_proxy_info {
bool defined;
int auth_method;
struct http_proxy_options options;
struct user_pass up;
+ char *proxy_authenticate;
+ bool queried_creds;
};
struct http_proxy_info *http_proxy_new (const struct http_proxy_options *o,
diff --git a/ps.c b/ps.c
index 0aaef62..9b9723c 100644
--- a/ps.c
+++ b/ps.c
@@ -5,7 +5,7 @@
* packet encryption, packet authentication, and
* packet compression.
*
- * Copyright (C) 2002-2009 OpenVPN Technologies, Inc. <sales@openvpn.net>
+ * Copyright (C) 2002-2010 OpenVPN Technologies, Inc. <sales@openvpn.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2
diff --git a/ps.h b/ps.h
index 89578dd..d488a72 100644
--- a/ps.h
+++ b/ps.h
@@ -5,7 +5,7 @@
* packet encryption, packet authentication, and
* packet compression.
*
- * Copyright (C) 2002-2009 OpenVPN Technologies, Inc. <sales@openvpn.net>
+ * Copyright (C) 2002-2010 OpenVPN Technologies, Inc. <sales@openvpn.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2
diff --git a/push.c b/push.c
index 70bb9a3..08c7f99 100644
--- a/push.c
+++ b/push.c
@@ -5,7 +5,7 @@
* packet encryption, packet authentication, and
* packet compression.
*
- * Copyright (C) 2002-2009 OpenVPN Technologies, Inc. <sales@openvpn.net>
+ * Copyright (C) 2002-2010 OpenVPN Technologies, Inc. <sales@openvpn.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2
@@ -63,13 +63,23 @@ receive_auth_failed (struct context *c, const struct buffer *buffer)
#ifdef ENABLE_MANAGEMENT
if (management)
{
- const char *reason = UP_TYPE_AUTH;
+ const char *reason = NULL;
struct buffer buf = *buffer;
if (buf_string_compare_advance (&buf, "AUTH_FAILED,") && BLEN (&buf))
reason = BSTR (&buf);
- management_auth_failure (management, reason);
- }
+ management_auth_failure (management, UP_TYPE_AUTH, reason);
+ } else
+#endif
+ {
+#ifdef ENABLE_CLIENT_CR
+ struct buffer buf = *buffer;
+ if (buf_string_match_head_str (&buf, "AUTH_FAILED,CRV1:") && BLEN (&buf))
+ {
+ buf_advance (&buf, 12); /* Length of "AUTH_FAILED," substring */
+ ssl_put_auth_challenge (BSTR (&buf));
+ }
#endif
+ }
}
}
@@ -102,8 +112,8 @@ send_auth_failed (struct context *c, const char *client_reason)
schedule_exit (c, c->options.scheduled_exit_interval, SIGTERM);
len = (client_reason ? strlen(client_reason)+1 : 0) + sizeof(auth_failed);
- if (len > TLS_CHANNEL_BUF_SIZE)
- len = TLS_CHANNEL_BUF_SIZE;
+ if (len > PUSH_BUNDLE_SIZE)
+ len = PUSH_BUNDLE_SIZE;
{
struct buffer buf = alloc_buf_gc (len, &gc);
@@ -171,14 +181,15 @@ bool
send_push_reply (struct context *c)
{
struct gc_arena gc = gc_new ();
- struct buffer buf = alloc_buf_gc (TLS_CHANNEL_BUF_SIZE, &gc);
+ struct buffer buf = alloc_buf_gc (PUSH_BUNDLE_SIZE, &gc);
struct push_entry *e = c->options.push_list.head;
bool multi_push = false;
static char cmd[] = "PUSH_REPLY";
const int extra = 64; /* extra space for possible trailing ifconfig and push-continuation */
const int safe_cap = BCAP (&buf) - extra;
+ bool push_sent = false;
- buf_printf (&buf, cmd);
+ buf_printf (&buf, "%s", cmd);
while (e)
{
@@ -192,9 +203,10 @@ send_push_reply (struct context *c)
const bool status = send_control_channel_string (c, BSTR (&buf), D_PUSH);
if (!status)
goto fail;
+ push_sent = true;
multi_push = true;
buf_reset_len (&buf);
- buf_printf (&buf, cmd);
+ buf_printf (&buf, "%s", cmd);
}
}
if (BLEN (&buf) + l >= safe_cap)
@@ -218,6 +230,21 @@ send_push_reply (struct context *c)
{
const bool status = send_control_channel_string (c, BSTR (&buf), D_PUSH);
if (!status)
+ goto fail;
+ push_sent = true;
+ }
+
+ /* If nothing have been pushed, send an empty push,
+ * as the client is expecting a response
+ */
+ if (!push_sent)
+ {
+ bool status = false;
+
+ buf_reset_len (&buf);
+ buf_printf (&buf, "%s", cmd);
+ status = send_control_channel_string (c, BSTR(&buf), D_PUSH);
+ if (!status)
goto fail;
}
diff --git a/push.h b/push.h
index 914b119..089cf45 100644
--- a/push.h
+++ b/push.h
@@ -5,7 +5,7 @@
* packet encryption, packet authentication, and
* packet compression.
*
- * Copyright (C) 2002-2009 OpenVPN Technologies, Inc. <sales@openvpn.net>
+ * Copyright (C) 2002-2010 OpenVPN Technologies, Inc. <sales@openvpn.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2
diff --git a/pushlist.h b/pushlist.h
index 1c2f4e0..b252676 100644
--- a/pushlist.h
+++ b/pushlist.h
@@ -5,7 +5,7 @@
* packet encryption, packet authentication, and
* packet compression.
*
- * Copyright (C) 2002-2009 OpenVPN Technologies, Inc. <sales@openvpn.net>
+ * Copyright (C) 2002-2010 OpenVPN Technologies, Inc. <sales@openvpn.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2
diff --git a/reliable.c b/reliable.c
index e68c236..1f238cc 100644
--- a/reliable.c
+++ b/reliable.c
@@ -5,7 +5,7 @@
* packet encryption, packet authentication, and
* packet compression.
*
- * Copyright (C) 2002-2009 OpenVPN Technologies, Inc. <sales@openvpn.net>
+ * Copyright (C) 2002-2010 OpenVPN Technologies, Inc. <sales@openvpn.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2
diff --git a/reliable.h b/reliable.h
index 6a62c3a..9cf8eec 100644
--- a/reliable.h
+++ b/reliable.h
@@ -5,7 +5,7 @@
* packet encryption, packet authentication, and
* packet compression.
*
- * Copyright (C) 2002-2009 OpenVPN Technologies, Inc. <sales@openvpn.net>
+ * Copyright (C) 2002-2010 OpenVPN Technologies, Inc. <sales@openvpn.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2
@@ -38,7 +38,7 @@
#include "session_id.h"
#include "mtu.h"
-/* #define EXPONENTIAL_BACKOFF */
+#define EXPONENTIAL_BACKOFF
#define RELIABLE_ACK_SIZE 8
diff --git a/route.c b/route.c
index f78893e..b5092fe 100644
--- a/route.c
+++ b/route.c
@@ -5,7 +5,7 @@
* packet encryption, packet authentication, and
* packet compression.
*
- * Copyright (C) 2002-2009 OpenVPN Technologies, Inc. <sales@openvpn.net>
+ * Copyright (C) 2002-2010 OpenVPN Technologies, Inc. <sales@openvpn.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2
@@ -199,6 +199,7 @@ is_special_addr (const char *addr_str)
static bool
init_route (struct route *r,
+ struct resolve_list *network_list,
const struct route_option *ro,
const struct route_special_addr *spec)
{
@@ -217,14 +218,15 @@ init_route (struct route *r,
if (!get_special_addr (spec, ro->network, &r->network, &status))
{
- r->network = getaddr (
- GETADDR_RESOLVE
- | GETADDR_HOST_ORDER
- | GETADDR_WARN_ON_SIGNAL,
- ro->network,
- 0,
- &status,
- NULL);
+ r->network = getaddr_multi (
+ GETADDR_RESOLVE
+ | GETADDR_HOST_ORDER
+ | GETADDR_WARN_ON_SIGNAL,
+ ro->network,
+ 0,
+ &status,
+ NULL,
+ network_list);
}
if (!status)
@@ -418,20 +420,47 @@ init_route_list (struct route_list *rl,
else
rl->spec.remote_endpoint_defined = false;
- if (!(opt->n >= 0 && opt->n <= rl->capacity))
- msg (M_FATAL, PACKAGE_NAME " ROUTE: (init) number of route options (%d) is greater than route list capacity (%d)", opt->n, rl->capacity);
-
/* parse the routes from opt to rl */
{
int i, j = 0;
+ bool warned = false;
for (i = 0; i < opt->n; ++i)
{
- if (!init_route (&rl->routes[j],
+ struct resolve_list netlist;
+ struct route r;
+ int k;
+
+ CLEAR(netlist); /* init_route() will not always init this */
+
+ if (!init_route (&r,
+ &netlist,
&opt->routes[i],
&rl->spec))
ret = false;
else
- ++j;
+ {
+ if (!netlist.len)
+ {
+ netlist.data[0] = r.network;
+ netlist.len = 1;
+ }
+ for (k = 0; k < netlist.len; ++k)
+ {
+ if (j < rl->capacity)
+ {
+ r.network = netlist.data[k];
+ rl->routes[j++] = r;
+ }
+ else
+ {
+ if (!warned)
+ {
+ msg (M_WARN, PACKAGE_NAME " ROUTE: routes dropped because number of expanded routes is greater than route list capacity (%d)", rl->capacity);
+ warned = true;
+ }
+ }
+ }
+ }
}
rl->n = j;
}
@@ -2174,7 +2203,7 @@ get_bypass_addresses (struct route_bypass *rb, const unsigned int flags) /* PLA
#endif
-#if AUTO_USERID
+#if AUTO_USERID || defined(ENABLE_PUSH_PEER_INFO)
#if defined(TARGET_LINUX)
diff --git a/route.h b/route.h
index 6f713ca..c5cbb7c 100644
--- a/route.h
+++ b/route.h
@@ -5,7 +5,7 @@
* packet encryption, packet authentication, and
* packet compression.
*
- * Copyright (C) 2002-2009 OpenVPN Technologies, Inc. <sales@openvpn.net>
+ * Copyright (C) 2002-2010 OpenVPN Technologies, Inc. <sales@openvpn.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2
@@ -174,7 +174,7 @@ bool get_default_gateway (in_addr_t *ip, in_addr_t *netmask);
#define TLA_LOCAL 2
int test_local_addr (const in_addr_t addr);
-#if AUTO_USERID
+#if AUTO_USERID || defined(ENABLE_PUSH_PEER_INFO)
bool get_default_gateway_mac_addr (unsigned char *macaddr);
#endif
diff --git a/sample-config-files/firewall.sh b/sample-config-files/firewall.sh
index f0db806..19d75ee 100755
--- a/sample-config-files/firewall.sh
+++ b/sample-config-files/firewall.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/bin/sh
# A Sample OpenVPN-aware firewall.
diff --git a/sample-scripts/bridge-start b/sample-scripts/bridge-start
index bfbbdc5..d20a260 100755
--- a/sample-scripts/bridge-start
+++ b/sample-scripts/bridge-start
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/bin/sh
#################################
# Set up Ethernet bridge on Linux
diff --git a/sample-scripts/bridge-stop b/sample-scripts/bridge-stop
index d452893..8192779 100755
--- a/sample-scripts/bridge-stop
+++ b/sample-scripts/bridge-stop
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/bin/sh
####################################
# Tear Down Ethernet bridge on Linux
diff --git a/schedule.c b/schedule.c
index e1b7a60..f0482ab 100644
--- a/schedule.c
+++ b/schedule.c
@@ -5,7 +5,7 @@
* packet encryption, packet authentication, and
* packet compression.
*
- * Copyright (C) 2002-2009 OpenVPN Technologies, Inc. <sales@openvpn.net>
+ * Copyright (C) 2002-2010 OpenVPN Technologies, Inc. <sales@openvpn.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2
diff --git a/schedule.h b/schedule.h
index d881c38..71c6d8c 100644
--- a/schedule.h
+++ b/schedule.h
@@ -5,7 +5,7 @@
* packet encryption, packet authentication, and
* packet compression.
*
- * Copyright (C) 2002-2009 OpenVPN Technologies, Inc. <sales@openvpn.net>
+ * Copyright (C) 2002-2010 OpenVPN Technologies, Inc. <sales@openvpn.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2
diff --git a/service-win32/Makefile.am b/service-win32/Makefile.am
index a59369d..4e4f55e 100644
--- a/service-win32/Makefile.am
+++ b/service-win32/Makefile.am
@@ -5,7 +5,7 @@
# packet encryption, packet authentication, and
# packet compression.
#
-# Copyright (C) 2002-2009 OpenVPN Technologies, Inc. <sales@openvpn.net>
+# Copyright (C) 2002-2010 OpenVPN Technologies, Inc. <sales@openvpn.net>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2
diff --git a/service-win32/openvpnserv.c b/service-win32/openvpnserv.c
index e189203..6c9ff1e 100755
--- a/service-win32/openvpnserv.c
+++ b/service-win32/openvpnserv.c
@@ -5,7 +5,7 @@
* packet encryption, packet authentication, and
* packet compression.
*
- * Copyright (C) 2002-2009 OpenVPN Technologies, Inc. <sales@openvpn.net>
+ * Copyright (C) 2002-2010 OpenVPN Technologies, Inc. <sales@openvpn.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2
diff --git a/service-win32/service.c b/service-win32/service.c
index d5211bd..91b5821 100644
--- a/service-win32/service.c
+++ b/service-win32/service.c
@@ -370,11 +370,13 @@ int CmdInstallService()
int ret = 0;
- if ( GetModuleFileName( NULL, szPath, 512 ) == 0 )
+ if ( GetModuleFileName( NULL, szPath+1, 510 ) == 0 )
{
_tprintf(TEXT("Unable to install %s - %s\n"), TEXT(SZSERVICEDISPLAYNAME), GetLastErrorText(szErr, 256));
return 1;
}
+ szPath[0] = '\"';
+ strcat(szPath, "\"");
schSCManager = OpenSCManager(
NULL, // machine (NULL == local)
diff --git a/session_id.c b/session_id.c
index 2552364..95fa5f7 100644
--- a/session_id.c
+++ b/session_id.c
@@ -5,7 +5,7 @@
* packet encryption, packet authentication, and
* packet compression.
*
- * Copyright (C) 2002-2009 OpenVPN Technologies, Inc. <sales@openvpn.net>
+ * Copyright (C) 2002-2010 OpenVPN Technologies, Inc. <sales@openvpn.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2
diff --git a/session_id.h b/session_id.h
index 0560e9c..10f30ed 100644
--- a/session_id.h
+++ b/session_id.h
@@ -5,7 +5,7 @@
* packet encryption, packet authentication, and
* packet compression.
*
- * Copyright (C) 2002-2009 OpenVPN Technologies, Inc. <sales@openvpn.net>
+ * Copyright (C) 2002-2010 OpenVPN Technologies, Inc. <sales@openvpn.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2
diff --git a/shaper.c b/shaper.c
index 762933d..1a89fc2 100644
--- a/shaper.c
+++ b/shaper.c
@@ -5,7 +5,7 @@
* packet encryption, packet authentication, and
* packet compression.
*
- * Copyright (C) 2002-2009 OpenVPN Technologies, Inc. <sales@openvpn.net>
+ * Copyright (C) 2002-2010 OpenVPN Technologies, Inc. <sales@openvpn.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2
diff --git a/shaper.h b/shaper.h
index 9f3693d..4825011 100644
--- a/shaper.h
+++ b/shaper.h
@@ -5,7 +5,7 @@
* packet encryption, packet authentication, and
* packet compression.
*
- * Copyright (C) 2002-2009 OpenVPN Technologies, Inc. <sales@openvpn.net>
+ * Copyright (C) 2002-2010 OpenVPN Technologies, Inc. <sales@openvpn.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2
diff --git a/sig.c b/sig.c
index 438f4e6..631a3a8 100644
--- a/sig.c
+++ b/sig.c
@@ -5,7 +5,7 @@
* packet encryption, packet authentication, and
* packet compression.
*
- * Copyright (C) 2002-2009 OpenVPN Technologies, Inc. <sales@openvpn.net>
+ * Copyright (C) 2002-2010 OpenVPN Technologies, Inc. <sales@openvpn.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2
@@ -248,7 +248,7 @@ print_status (const struct context *c, struct status_output *so)
status_reset (so);
- status_printf (so, PACKAGE_NAME " STATISTICS");
+ status_printf (so, "OpenVPN STATISTICS");
status_printf (so, "Updated,%s", time_string (0, 0, false, &gc));
status_printf (so, "TUN/TAP read bytes," counter_format, c->c2.tun_read_bytes);
status_printf (so, "TUN/TAP write bytes," counter_format, c->c2.tun_write_bytes);
diff --git a/sig.h b/sig.h
index 1cbad1b..be87fe4 100644
--- a/sig.h
+++ b/sig.h
@@ -5,7 +5,7 @@
* packet encryption, packet authentication, and
* packet compression.
*
- * Copyright (C) 2002-2009 OpenVPN Technologies, Inc. <sales@openvpn.net>
+ * Copyright (C) 2002-2010 OpenVPN Technologies, Inc. <sales@openvpn.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2
diff --git a/socket.c b/socket.c
index d330558..4720398 100644
--- a/socket.c
+++ b/socket.c
@@ -5,7 +5,7 @@
* packet encryption, packet authentication, and
* packet compression.
*
- * Copyright (C) 2002-2009 OpenVPN Technologies, Inc. <sales@openvpn.net>
+ * Copyright (C) 2002-2010 OpenVPN Technologies, Inc. <sales@openvpn.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2
@@ -88,12 +88,26 @@ getaddr (unsigned int flags,
bool *succeeded,
volatile int *signal_received)
{
+ return getaddr_multi (flags, hostname, resolve_retry_seconds, succeeded, signal_received, NULL);
+}
+
+in_addr_t
+getaddr_multi (unsigned int flags,
+ const char *hostname,
+ int resolve_retry_seconds,
+ bool *succeeded,
+ volatile int *signal_received,
+ struct resolve_list *reslist)
+{
struct in_addr ia;
int status;
int sigrec = 0;
int msglevel = (flags & GETADDR_FATAL) ? M_FATAL : D_RESOLVE_ERRORS;
struct gc_arena gc = gc_new ();
+ if (reslist)
+ reslist->len = 0;
+
if (flags & GETADDR_RANDOMIZE)
hostname = hostname_randomize(hostname, &gc);
@@ -211,11 +225,28 @@ getaddr (unsigned int flags,
++n;
ASSERT (n >= 2);
- msg (D_RESOLVE_ERRORS, "RESOLVE: NOTE: %s resolves to %d addresses, choosing the first resolved IP address",
+ msg (D_RESOLVE_ERRORS, "RESOLVE: NOTE: %s resolves to %d addresses",
hostname,
n);
+ /* choose address randomly, for basic load-balancing capability */
+ /*ia.s_addr = *(in_addr_t *) (h->h_addr_list[get_random () % n]);*/
+
+ /* choose first address */
ia.s_addr = *(in_addr_t *) (h->h_addr_list[0]);
+
+ if (reslist)
+ {
+ int i;
+ for (i = 0; i < n && i < SIZE(reslist->data); ++i)
+ {
+ in_addr_t a = *(in_addr_t *) (h->h_addr_list[i]);
+ if (flags & GETADDR_HOST_ORDER)
+ a = ntohl(a);
+ reslist->data[i] = a;
+ }
+ reslist->len = i;
+ }
}
}
@@ -484,7 +515,7 @@ socket_set_buffers (int fd, const struct socket_buffer_size *sbs)
static bool
socket_set_tcp_nodelay (int sd, int state)
{
-#if defined(HAVE_SETSOCKOPT) && defined(IPPROTO_TCP) && defined(TCP_NODELAY)
+#if defined(WIN32) || (defined(HAVE_SETSOCKOPT) && defined(IPPROTO_TCP) && defined(TCP_NODELAY))
if (setsockopt (sd, IPPROTO_TCP, TCP_NODELAY, (void *) &state, sizeof (state)) != 0)
{
msg (M_WARN, "NOTE: setsockopt TCP_NODELAY=%d failed", state);
@@ -1289,6 +1320,10 @@ link_socket_init_phase1 (struct link_socket *sock,
else if (mode != LS_MODE_TCP_ACCEPT_FROM)
{
create_socket (sock);
+
+ /* set socket buffers based on --sndbuf and --rcvbuf options */
+ socket_set_buffers (sock->sd, &sock->socket_buffer_sizes);
+
resolve_bind_local (sock);
resolve_remote (sock, 1, NULL, NULL);
}
@@ -1491,9 +1526,6 @@ link_socket_init_phase2 (struct link_socket *sock,
}
}
- /* set socket buffers based on --sndbuf and --rcvbuf options */
- socket_set_buffers (sock->sd, &sock->socket_buffer_sizes);
-
/* set misc socket parameters */
socket_set_flags (sock->sd, sock->sockflags);
@@ -1861,7 +1893,7 @@ stream_buf_added (struct stream_buf *sb,
if (sb->len < 1 || sb->len > sb->maxlen)
{
- msg (M_WARN, "WARNING: Bad encapsulated packet length from peer (%d), which must be > 0 and <= %d -- please ensure that --tun-mtu or --link-mtu is equal on both peers -- this condition could also indicate a possible active attack on the TCP link -- [Attemping restart...]", sb->len, sb->maxlen);
+ msg (M_WARN, "WARNING: Bad encapsulated packet length from peer (%d), which must be > 0 and <= %d -- please ensure that --tun-mtu or --link-mtu is equal on both peers -- this condition could also indicate a possible active attack on the TCP link -- [Attempting restart...]", sb->len, sb->maxlen);
stream_buf_reset (sb);
sb->error = true;
return false;
diff --git a/socket.h b/socket.h
index 6877e66..eef98d1 100644
--- a/socket.h
+++ b/socket.h
@@ -5,7 +5,7 @@
* packet encryption, packet authentication, and
* packet compression.
*
- * Copyright (C) 2002-2009 OpenVPN Technologies, Inc. <sales@openvpn.net>
+ * Copyright (C) 2002-2010 OpenVPN Technologies, Inc. <sales@openvpn.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2
@@ -439,6 +439,11 @@ bool unix_socket_get_peer_uid_gid (const socket_descriptor_t sd, int *uid, int *
* DNS resolution
*/
+struct resolve_list {
+ int len;
+ in_addr_t data[16];
+};
+
#define GETADDR_RESOLVE (1<<0)
#define GETADDR_FATAL (1<<1)
#define GETADDR_HOST_ORDER (1<<2)
@@ -456,6 +461,13 @@ in_addr_t getaddr (unsigned int flags,
bool *succeeded,
volatile int *signal_received);
+in_addr_t getaddr_multi (unsigned int flags,
+ const char *hostname,
+ int resolve_retry_seconds,
+ bool *succeeded,
+ volatile int *signal_received,
+ struct resolve_list *reslist);
+
/*
* Transport protocol naming and other details.
*/
@@ -497,6 +509,12 @@ legal_ipv4_port (int port)
return port > 0 && port < 65536;
}
+static inline int
+is_proto_tcp(const int p)
+{
+ return p > 0; /* depends on the definition of PROTO_x */
+}
+
static inline bool
link_socket_proto_connection_oriented (int proto)
{
diff --git a/socks.c b/socks.c
index 41e591a..8287274 100644
--- a/socks.c
+++ b/socks.c
@@ -5,7 +5,7 @@
* packet encryption, packet authentication, and
* packet compression.
*
- * Copyright (C) 2002-2009 OpenVPN Technologies, Inc. <sales@openvpn.net>
+ * Copyright (C) 2002-2010 OpenVPN Technologies, Inc. <sales@openvpn.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2
diff --git a/socks.h b/socks.h
index ddf674e..b748bb3 100644
--- a/socks.h
+++ b/socks.h
@@ -5,7 +5,7 @@
* packet encryption, packet authentication, and
* packet compression.
*
- * Copyright (C) 2002-2009 OpenVPN Technologies, Inc. <sales@openvpn.net>
+ * Copyright (C) 2002-2010 OpenVPN Technologies, Inc. <sales@openvpn.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2
diff --git a/ssl.c b/ssl.c
index 8644ae4..2fa091a 100644
--- a/ssl.c
+++ b/ssl.c
@@ -5,7 +5,11 @@
* packet encryption, packet authentication, and
* packet compression.
*
- * Copyright (C) 2002-2009 OpenVPN Technologies, Inc. <sales@openvpn.net>
+ * Copyright (C) 2002-2010 OpenVPN Technologies, Inc. <sales@openvpn.net>
+ *
+ * Additions for eurephia plugin done by:
+ * David Sommerseth <dazo@users.sourceforge.net> Copyright (C) 2008-2009
+ *
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2
@@ -285,6 +289,10 @@ pem_password_callback (char *buf, int size, int rwflag, void *u)
static bool auth_user_pass_enabled; /* GLOBAL */
static struct user_pass auth_user_pass; /* GLOBAL */
+#ifdef ENABLE_CLIENT_CR
+static char *auth_challenge; /* GLOBAL */
+#endif
+
void
auth_user_pass_setup (const char *auth_file)
{
@@ -293,6 +301,8 @@ auth_user_pass_setup (const char *auth_file)
{
#if AUTO_USERID
get_user_pass_auto_userid (&auth_user_pass, auth_file);
+#elif defined(ENABLE_CLIENT_CR)
+ get_user_pass_cr (&auth_user_pass, auth_file, UP_TYPE_AUTH, GET_USER_PASS_MANAGEMENT|GET_USER_PASS_SENSITIVE, auth_challenge);
#else
get_user_pass (&auth_user_pass, auth_file, UP_TYPE_AUTH, GET_USER_PASS_MANAGEMENT|GET_USER_PASS_SENSITIVE);
#endif
@@ -320,8 +330,29 @@ ssl_purge_auth (void)
#endif
purge_user_pass (&passbuf, true);
purge_user_pass (&auth_user_pass, true);
+#ifdef ENABLE_CLIENT_CR
+ ssl_purge_auth_challenge();
+#endif
}
+#ifdef ENABLE_CLIENT_CR
+
+void
+ssl_purge_auth_challenge (void)
+{
+ free (auth_challenge);
+ auth_challenge = NULL;
+}
+
+void
+ssl_put_auth_challenge (const char *cr_str)
+{
+ ssl_purge_auth_challenge();
+ auth_challenge = string_alloc(cr_str, NULL);
+}
+
+#endif
+
/*
* OpenSSL callback to get a temporary RSA key, mostly
* used for export ciphers.
@@ -709,7 +740,7 @@ get_peer_cert(X509_STORE_CTX *ctx, const char *tmp_dir, struct gc_arena *gc)
}
/* create tmp file to store peer cert */
- peercert_filename = create_temp_filename (tmp_dir, "pcf", gc);
+ peercert_filename = create_temp_file (tmp_dir, "pcf", gc);
/* write peer-cert in tmp-file */
peercert_file = fopen(peercert_filename, "w+");
@@ -826,6 +857,16 @@ verify_callback (int preverify_ok, X509_STORE_CTX * ctx)
openvpn_snprintf (envname, sizeof(envname), "tls_id_%d", ctx->error_depth);
setenv_str (opt->es, envname, subject);
+#ifdef ENABLE_EUREPHIA
+ /* export X509 cert SHA1 fingerprint */
+ {
+ struct gc_arena gc = gc_new ();
+ openvpn_snprintf (envname, sizeof(envname), "tls_digest_%d", ctx->error_depth);
+ setenv_str (opt->es, envname,
+ format_hex_ex(ctx->current_cert->sha1_hash, SHA_DIGEST_LENGTH, 0, 1, ":", &gc));
+ gc_free(&gc);
+ }
+#endif
#if 0
/* export common name string as environmental variable */
openvpn_snprintf (envname, sizeof(envname), "tls_common_name_%d", ctx->error_depth);
@@ -834,9 +875,30 @@ verify_callback (int preverify_ok, X509_STORE_CTX * ctx)
/* export serial number as environmental variable */
{
- const int serial = (int) ASN1_INTEGER_get (X509_get_serialNumber (ctx->current_cert));
- openvpn_snprintf (envname, sizeof(envname), "tls_serial_%d", ctx->error_depth);
- setenv_int (opt->es, envname, serial);
+ BIO *bio = NULL;
+ char serial[100];
+ int n1, n2;
+
+ CLEAR (serial);
+ if ((bio = BIO_new (BIO_s_mem ())) == NULL)
+ {
+ msg (M_WARN, "CALLBACK: Cannot create BIO (for tls_serial_%d)", ctx->error_depth);
+ }
+ else
+ {
+ /* "prints" the serial number onto the BIO and read it back */
+ if ( ! ( ( (n1 = i2a_ASN1_INTEGER(bio, X509_get_serialNumber (ctx->current_cert))) >= 0 ) &&
+ ( (n2 = BIO_read (bio, serial, sizeof (serial)-1)) >= 0 ) &&
+ ( n1 == n2 ) ) )
+ {
+ msg (M_WARN, "CALLBACK: Error reading/writing BIO (for tls_serial_%d)", ctx->error_depth);
+ CLEAR (serial); /* empty string */
+ }
+
+ openvpn_snprintf (envname, sizeof(envname), "tls_serial_%d", ctx->error_depth);
+ setenv_str (opt->es, envname, serial);
+ BIO_free(bio);
+ }
}
/* export current untrusted IP */
@@ -931,7 +993,7 @@ verify_callback (int preverify_ok, X509_STORE_CTX * ctx)
/* run --tls-verify script */
if (opt->verify_command)
{
- const char *tmp_file;
+ const char *tmp_file = NULL;
struct gc_arena gc;
int ret;
@@ -1003,10 +1065,10 @@ verify_callback (int preverify_ok, X509_STORE_CTX * ctx)
goto end;
}
- n = sk_num(X509_CRL_get_REVOKED(crl));
+ n = sk_X509_REVOKED_num(X509_CRL_get_REVOKED(crl));
for (i = 0; i < n; i++) {
- revoked = (X509_REVOKED *)sk_value(X509_CRL_get_REVOKED(crl), i);
+ revoked = (X509_REVOKED *)sk_X509_REVOKED_value(X509_CRL_get_REVOKED(crl), i);
if (ASN1_INTEGER_cmp(revoked->serialNumber, X509_get_serialNumber(ctx->current_cert)) == 0) {
msg (D_HANDSHAKE, "CRL CHECK FAILED: %s is REVOKED",subject);
goto end;
@@ -1028,13 +1090,13 @@ verify_callback (int preverify_ok, X509_STORE_CTX * ctx)
msg (D_HANDSHAKE, "VERIFY OK: depth=%d, %s", ctx->error_depth, subject);
session->verified = true;
- free (subject);
+ OPENSSL_free (subject);
argv_reset (&argv);
return 1; /* Accept connection */
err:
ERR_clear_error ();
- free (subject);
+ OPENSSL_free (subject);
argv_reset (&argv);
return 0; /* Reject connection */
}
@@ -1156,10 +1218,11 @@ key_state_gen_auth_control_file (struct key_state *ks, const struct tls_options
const char *acf;
key_state_rm_auth_control_file (ks);
- acf = create_temp_filename (opt->tmp_dir, "acf", &gc);
- ks->auth_control_file = string_alloc (acf, NULL);
- setenv_str (opt->es, "auth_control_file", ks->auth_control_file);
-
+ acf = create_temp_file (opt->tmp_dir, "acf", &gc);
+ if( acf ) {
+ ks->auth_control_file = string_alloc (acf, NULL);
+ setenv_str (opt->es, "auth_control_file", ks->auth_control_file);
+ } /* FIXME: Should have better error handling? */
gc_free (&gc);
}
@@ -1576,23 +1639,41 @@ init_ssl (const struct options *options)
if (options->pkcs12_file)
{
- /* Use PKCS #12 file for key, cert and CA certs */
+ /* Use PKCS #12 file for key, cert and CA certs */
FILE *fp;
EVP_PKEY *pkey;
X509 *cert;
STACK_OF(X509) *ca = NULL;
- PKCS12 *p12;
+ PKCS12 *p12=NULL;
int i;
char password[256];
- /* Load the PKCS #12 file */
- if (!(fp = fopen(options->pkcs12_file, "rb")))
- msg (M_SSLERR, "Error opening file %s", options->pkcs12_file);
- p12 = d2i_PKCS12_fp(fp, NULL);
- fclose (fp);
- if (!p12) msg (M_SSLERR, "Error reading PKCS#12 file %s", options->pkcs12_file);
-
+#if ENABLE_INLINE_FILES
+ if (!strcmp (options->pkcs12_file, INLINE_FILE_TAG) && options->pkcs12_file_inline)
+ {
+ BIO *b64 = BIO_new (BIO_f_base64());
+ BIO *bio = BIO_new_mem_buf ((void *)options->pkcs12_file_inline, (int)strlen(options->pkcs12_file_inline));
+ ASSERT(b64 && bio);
+ BIO_push (b64, bio);
+ p12 = d2i_PKCS12_bio(b64, NULL);
+ if (!p12)
+ msg (M_SSLERR, "Error reading inline PKCS#12 file");
+ BIO_free (b64);
+ BIO_free (bio);
+ }
+ else
+#endif
+ {
+ /* Load the PKCS #12 file */
+ if (!(fp = fopen(options->pkcs12_file, "rb")))
+ msg (M_SSLERR, "Error opening file %s", options->pkcs12_file);
+ p12 = d2i_PKCS12_fp(fp, NULL);
+ fclose (fp);
+ if (!p12)
+ msg (M_SSLERR, "Error reading PKCS#12 file %s", options->pkcs12_file);
+ }
+
/* Parse the PKCS #12 file */
if (!PKCS12_parse(p12, "", &pkey, &cert, &ca))
{
@@ -1601,8 +1682,12 @@ init_ssl (const struct options *options)
ca = NULL;
if (!PKCS12_parse(p12, password, &pkey, &cert, &ca))
{
+#ifdef ENABLE_MANAGEMENT
+ if (management && (ERR_GET_REASON (ERR_peek_error()) == PKCS12_R_MAC_VERIFY_FAILURE))
+ management_auth_failure (management, UP_TYPE_PRIVATE_KEY, NULL);
+#endif
PKCS12_free(p12);
- msg (M_WARN|M_SSL, "Error parsing PKCS#12 file %s", options->pkcs12_file);
+ msg (M_INFO, "OpenSSL ERROR code: %d", (ERR_GET_REASON (ERR_peek_error()))); // fixme
goto err;
}
}
@@ -1624,7 +1709,7 @@ init_ssl (const struct options *options)
/* Set Certificate Verification chain */
if (!options->ca_file)
{
- if (ca && sk_num(ca))
+ if (ca && sk_X509_num(ca))
{
for (i = 0; i < sk_X509_num(ca); i++)
{
@@ -1701,7 +1786,7 @@ init_ssl (const struct options *options)
{
#ifdef ENABLE_MANAGEMENT
if (management && (ERR_GET_REASON (ERR_peek_error()) == EVP_R_BAD_DECRYPT))
- management_auth_failure (management, UP_TYPE_PRIVATE_KEY);
+ management_auth_failure (management, UP_TYPE_PRIVATE_KEY, NULL);
#endif
msg (M_WARN|M_SSL, "Cannot load private key file %s", options->priv_key_file);
goto err;
@@ -2329,6 +2414,7 @@ key_state_free (struct key_state *ks, bool clear)
free_buf (&ks->plaintext_read_buf);
free_buf (&ks->plaintext_write_buf);
free_buf (&ks->ack_write_buf);
+ buffer_list_free(ks->paybuf);
if (ks->send_reliable)
{
@@ -2621,6 +2707,8 @@ tls_multi_free (struct tls_multi *multi, bool clear)
#ifdef MANAGEMENT_DEF_AUTH
man_def_auth_set_client_reason(multi, NULL);
+
+ free (multi->peer_info);
#endif
if (multi->locked_cn)
@@ -3125,6 +3213,17 @@ key_source2_read (struct key_source2 *k2,
return 1;
}
+static void
+flush_payload_buffer (struct tls_multi *multi, struct key_state *ks)
+{
+ struct buffer *b;
+ while ((b = buffer_list_peek (ks->paybuf)))
+ {
+ key_state_write_plaintext_const (multi, ks, b->data, b->len);
+ buffer_list_pop (ks->paybuf);
+ }
+}
+
/*
* Macros for key_state_soft_reset & tls_process
*/
@@ -3169,6 +3268,14 @@ write_string (struct buffer *buf, const char *str, const int maxlen)
}
static bool
+write_empty_string (struct buffer *buf)
+{
+ if (!buf_write_u16 (buf, 0))
+ return false;
+ return true;
+}
+
+static bool
read_string (struct buffer *buf, char *str, const unsigned int capacity)
{
const int len = buf_read_u16 (buf);
@@ -3180,6 +3287,33 @@ read_string (struct buffer *buf, char *str, const unsigned int capacity)
return true;
}
+static char *
+read_string_alloc (struct buffer *buf)
+{
+ const int len = buf_read_u16 (buf);
+ char *str;
+
+ if (len < 1)
+ return NULL;
+ str = (char *) malloc(len);
+ check_malloc_return(str);
+ if (!buf_read (buf, str, len))
+ {
+ free (str);
+ return NULL;
+ }
+ str[len-1] = '\0';
+ return str;
+}
+
+void
+read_string_discard (struct buffer *buf)
+{
+ char *data = read_string_alloc(buf);
+ if (data)
+ free (data);
+}
+
/*
* Authenticate a client using username/password.
* Runs on server.
@@ -3206,17 +3340,22 @@ verify_user_pass_script (struct tls_session *session, const struct user_pass *up
{
struct status_output *so;
- tmp_file = create_temp_filename (session->opt->tmp_dir, "up", &gc);
- so = status_open (tmp_file, 0, -1, NULL, STATUS_OUTPUT_WRITE);
- status_printf (so, "%s", up->username);
- status_printf (so, "%s", up->password);
- if (!status_close (so))
- {
- msg (D_TLS_ERRORS, "TLS Auth Error: could not write username/password to file: %s",
- tmp_file);
- goto done;
- }
- }
+ tmp_file = create_temp_file (session->opt->tmp_dir, "up", &gc);
+ if( tmp_file ) {
+ so = status_open (tmp_file, 0, -1, NULL, STATUS_OUTPUT_WRITE);
+ status_printf (so, "%s", up->username);
+ status_printf (so, "%s", up->password);
+ if (!status_close (so))
+ {
+ msg (D_TLS_ERRORS, "TLS Auth Error: could not write username/password to file: %s",
+ tmp_file);
+ goto done;
+ }
+ } else {
+ msg (D_TLS_ERRORS, "TLS Auth Error: could not create write "
+ "username/password to temp file");
+ }
+ }
else
{
setenv_str (session->opt->es, "username", up->username);
@@ -3245,7 +3384,7 @@ verify_user_pass_script (struct tls_session *session, const struct user_pass *up
}
done:
- if (strlen (tmp_file) > 0)
+ if (tmp_file && strlen (tmp_file) > 0)
delete_file (tmp_file);
argv_reset (&argv);
@@ -3385,6 +3524,73 @@ key_method_1_write (struct buffer *buf, struct tls_session *session)
}
static bool
+push_peer_info(struct buffer *buf, struct tls_session *session)
+{
+ struct gc_arena gc = gc_new ();
+ bool ret = false;
+
+#ifdef ENABLE_PUSH_PEER_INFO
+ if (session->opt->push_peer_info) /* write peer info */
+ {
+ struct env_set *es = session->opt->es;
+ struct env_item *e;
+ struct buffer out = alloc_buf_gc (512*3, &gc);
+
+ /* push version */
+ buf_printf (&out, "IV_VER=%s\n", PACKAGE_VERSION);
+
+ /* push platform */
+#if defined(TARGET_LINUX)
+ buf_printf (&out, "IV_PLAT=linux\n");
+#elif defined(TARGET_SOLARIS)
+ buf_printf (&out, "IV_PLAT=solaris\n");
+#elif defined(TARGET_OPENBSD)
+ buf_printf (&out, "IV_PLAT=openbsd\n");
+#elif defined(TARGET_DARWIN)
+ buf_printf (&out, "IV_PLAT=mac\n");
+#elif defined(TARGET_NETBSD)
+ buf_printf (&out, "IV_PLAT=netbsd\n");
+#elif defined(TARGET_FREEBSD)
+ buf_printf (&out, "IV_PLAT=freebsd\n");
+#elif defined(WIN32)
+ buf_printf (&out, "IV_PLAT=win\n");
+#endif
+
+ /* push mac addr */
+ {
+ bool get_default_gateway_mac_addr (unsigned char *macaddr);
+ uint8_t macaddr[6];
+ get_default_gateway_mac_addr (macaddr);
+ buf_printf (&out, "IV_HWADDR=%s\n", format_hex_ex (macaddr, 6, 0, 1, ":", &gc));
+ }
+
+ /* push env vars that begin with UV_ */
+ for (e=es->list; e != NULL; e=e->next)
+ {
+ if (e->string)
+ {
+ if (!strncmp(e->string, "UV_", 3) && buf_safe(&out, strlen(e->string)+1))
+ buf_printf (&out, "%s\n", e->string);
+ }
+ }
+
+ if (!write_string(buf, BSTR(&out), -1))
+ goto error;
+ }
+ else
+#endif
+ {
+ if (!write_empty_string (buf)) /* no peer info */
+ goto error;
+ }
+ ret = true;
+
+ error:
+ gc_free (&gc);
+ return ret;
+}
+
+static bool
key_method_2_write (struct buffer *buf, struct tls_session *session)
{
ASSERT (session->opt->key_method == 2);
@@ -3418,6 +3624,16 @@ key_method_2_write (struct buffer *buf, struct tls_session *session)
goto error;
purge_user_pass (&auth_user_pass, false);
}
+ else
+ {
+ if (!write_empty_string (buf)) /* no username */
+ goto error;
+ if (!write_empty_string (buf)) /* no password */
+ goto error;
+ }
+
+ if (!push_peer_info (buf, session))
+ goto error;
/*
* generate tunnel keys if server
@@ -3564,11 +3780,13 @@ key_method_2_read (struct buffer *buf, struct tls_multi *multi, struct tls_sessi
int s1 = OPENVPN_PLUGIN_FUNC_SUCCESS;
bool s2 = true;
char *raw_username;
+ bool username_status, password_status;
/* get username/password from plaintext buffer */
ALLOC_OBJ_CLEAR_GC (up, struct user_pass, &gc);
- if (!read_string (buf, up->username, USER_PASS_LEN)
- || !read_string (buf, up->password, USER_PASS_LEN))
+ username_status = read_string (buf, up->username, USER_PASS_LEN);
+ password_status = read_string (buf, up->password, USER_PASS_LEN);
+ if (!username_status || !password_status)
{
CLEAR (*up);
if (!(session->opt->ssl_flags & SSLF_AUTH_USER_PASS_OPTIONAL))
@@ -3589,6 +3807,10 @@ key_method_2_read (struct buffer *buf, struct tls_multi *multi, struct tls_sessi
/* call plugin(s) and/or script */
#ifdef MANAGEMENT_DEF_AUTH
+ /* get peer info from control channel */
+ free (multi->peer_info);
+ multi->peer_info = read_string_alloc (buf);
+
if (man_def_auth == KMDA_DEF)
man_def_auth = verify_user_pass_management (session, up, raw_username);
#endif
@@ -3759,9 +3981,12 @@ key_method_2_read (struct buffer *buf, struct tls_multi *multi, struct tls_sessi
static int
auth_deferred_expire_window (const struct tls_options *o)
{
- const int hw = o->handshake_window;
+ int ret = o->handshake_window;
const int r2 = o->renegotiate_seconds / 2;
- return min_int (hw, r2);
+
+ if (o->renegotiate_seconds && r2 < ret)
+ ret = r2;
+ return ret;
}
/*
@@ -3801,7 +4026,8 @@ tls_process (struct tls_multi *multi,
&& ks->n_packets >= session->opt->renegotiate_packets)
|| (packet_id_close_to_wrapping (&ks->packet_id.send))))
{
- msg (D_TLS_DEBUG_LOW, "TLS: soft reset sec=%d bytes=%d/%d pkts=%d/%d",
+ msg (D_TLS_DEBUG_LOW,
+ "TLS: soft reset sec=%d bytes=" counter_format "/%d pkts=" counter_format "/%d",
(int)(ks->established + session->opt->renegotiate_seconds - now),
ks->n_bytes, session->opt->renegotiate_bytes,
ks->n_packets, session->opt->renegotiate_packets);
@@ -3910,6 +4136,9 @@ tls_process (struct tls_multi *multi,
/* Set outgoing address for data channel packets */
link_socket_set_outgoing_addr (NULL, to_link_socket_info, &ks->remote_addr, session->common_name, session->opt->es);
+ /* Flush any payload packets that were buffered before our state transitioned to S_ACTIVE */
+ flush_payload_buffer (multi, ks);
+
#ifdef MEASURE_TLS_HANDSHAKE_STATS
show_tls_performance_stats();
#endif
@@ -5007,6 +5236,13 @@ tls_send_payload (struct tls_multi *multi,
if (key_state_write_plaintext_const (multi, ks, data, size) == 1)
ret = true;
}
+ else
+ {
+ if (!ks->paybuf)
+ ks->paybuf = buffer_list_new (0);
+ buffer_list_push_data (ks->paybuf, data, (size_t)size);
+ ret = true;
+ }
ERR_clear_error ();
diff --git a/ssl.h b/ssl.h
index 78ce57e..8464492 100644
--- a/ssl.h
+++ b/ssl.h
@@ -5,7 +5,7 @@
* packet encryption, packet authentication, and
* packet compression.
*
- * Copyright (C) 2002-2009 OpenVPN Technologies, Inc. <sales@openvpn.net>
+ * Copyright (C) 2002-2010 OpenVPN Technologies, Inc. <sales@openvpn.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2
@@ -378,8 +378,10 @@ struct key_state
struct reliable *rec_reliable; /* order incoming ciphertext packets before we pass to TLS */
struct reliable_ack *rec_ack; /* buffers all packet IDs we want to ACK back to sender */
- int n_bytes; /* how many bytes sent/recvd since last key exchange */
- int n_packets; /* how many packets sent/recvd since last key exchange */
+ struct buffer_list *paybuf;
+
+ counter_type n_bytes; /* how many bytes sent/recvd since last key exchange */
+ counter_type n_packets; /* how many packets sent/recvd since last key exchange */
/*
* If bad username/password, TLS connection will come up but 'authenticated' will be false.
@@ -434,6 +436,9 @@ struct tls_options
#ifdef ENABLE_OCC
bool disable_occ;
#endif
+#ifdef ENABLE_PUSH_PEER_INFO
+ bool push_peer_info;
+#endif
int transition_window;
int handshake_window;
interval_t packet_timeout;
@@ -618,6 +623,12 @@ struct tls_multi
*/
char *client_reason;
+ /*
+ * A multi-line string of general-purpose info received from peer
+ * over control channel.
+ */
+ char *peer_info;
+
/* Time of last call to tls_authentication_status */
time_t tas_last;
#endif
@@ -694,6 +705,17 @@ void auth_user_pass_setup (const char *auth_file);
void ssl_set_auth_nocache (void);
void ssl_purge_auth (void);
+
+#ifdef ENABLE_CLIENT_CR
+/*
+ * ssl_get_auth_challenge will parse the server-pushed auth-failed
+ * reason string and return a dynamically allocated
+ * auth_challenge_info struct.
+ */
+void ssl_purge_auth_challenge (void);
+void ssl_put_auth_challenge (const char *cr_str);
+#endif
+
void tls_set_verify_command (const char *cmd);
void tls_set_crl_verify (const char *crl);
void tls_set_verify_x509name (const char *x509name);
@@ -721,6 +743,12 @@ void tls_deauthenticate (struct tls_multi *multi);
#ifdef MANAGEMENT_DEF_AUTH
bool tls_authenticate_key (struct tls_multi *multi, const unsigned int mda_key_id, const bool auth, const char *client_reason);
+
+static inline char *
+tls_get_peer_info(const struct tls_multi *multi)
+{
+ return multi->peer_info;
+}
#endif
/*
diff --git a/status.c b/status.c
index 9834f1e..4bbea28 100644
--- a/status.c
+++ b/status.c
@@ -5,7 +5,7 @@
* packet encryption, packet authentication, and
* packet compression.
*
- * Copyright (C) 2002-2009 OpenVPN Technologies, Inc. <sales@openvpn.net>
+ * Copyright (C) 2002-2010 OpenVPN Technologies, Inc. <sales@openvpn.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2
@@ -168,7 +168,9 @@ status_flush (struct status_output *so)
#if defined(HAVE_FTRUNCATE)
{
const off_t off = lseek (so->fd, (off_t)0, SEEK_CUR);
- ftruncate (so->fd, off);
+ if (ftruncate (so->fd, off) != 0) {
+ msg (M_WARN, "Failed to truncate status file: %s", strerror(errno));
+ }
}
#elif defined(HAVE_CHSIZE)
{
diff --git a/status.h b/status.h
index 1ae1734..0bdad4e 100644
--- a/status.h
+++ b/status.h
@@ -5,7 +5,7 @@
* packet encryption, packet authentication, and
* packet compression.
*
- * Copyright (C) 2002-2009 OpenVPN Technologies, Inc. <sales@openvpn.net>
+ * Copyright (C) 2002-2010 OpenVPN Technologies, Inc. <sales@openvpn.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2
diff --git a/syshead.h b/syshead.h
index 3b8ab89..d75f881 100644
--- a/syshead.h
+++ b/syshead.h
@@ -5,7 +5,7 @@
* packet encryption, packet authentication, and
* packet compression.
*
- * Copyright (C) 2002-2009 OpenVPN Technologies, Inc. <sales@openvpn.net>
+ * Copyright (C) 2002-2010 OpenVPN Technologies, Inc. <sales@openvpn.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2
@@ -85,6 +85,10 @@
#endif
#ifdef HAVE_SYS_SOCKET_H
+# if defined(TARGET_LINUX) && !defined(_GNU_SOURCE)
+ /* needed for peercred support on glibc-2.8 */
+# define _GNU_SOURCE
+# endif
#include <sys/socket.h>
#endif
@@ -531,11 +535,9 @@ socket_defined (const socket_descriptor_t sd)
#endif
/*
- * Don't compile the struct buffer_list code unless something needs it
+ * Compile the struct buffer_list code
*/
-#if defined(ENABLE_MANAGEMENT) || defined(ENABLE_PF)
#define ENABLE_BUFFER_LIST
-#endif
/*
* Should we include OCC (options consistency check) code?
@@ -554,6 +556,15 @@ socket_defined (const socket_descriptor_t sd)
#endif
/*
+ * Should we include proxy digest auth functionality
+ */
+#if defined(USE_CRYPTO) && defined(ENABLE_HTTP_PROXY)
+#define PROXY_DIGEST_AUTH 1
+#else
+#define PROXY_DIGEST_AUTH 0
+#endif
+
+/*
* Should we include code common to all proxy methods?
*/
#if defined(ENABLE_HTTP_PROXY) || defined(ENABLE_SOCKS)
@@ -598,6 +609,22 @@ socket_defined (const socket_descriptor_t sd)
#define ENABLE_INLINE_FILES 1
/*
+ * Support "connection" directive
+ */
+#if ENABLE_INLINE_FILES
+#define ENABLE_CONNECTION 1
+#endif
+
+/*
+ * Should we include http proxy fallback functionality
+ */
+#if defined(ENABLE_CONNECTION) && defined(ENABLE_MANAGEMENT) && defined(ENABLE_HTTP_PROXY)
+#define HTTP_PROXY_FALLBACK 1
+#else
+#define HTTP_PROXY_FALLBACK 0
+#endif
+
+/*
* Reduce sensitivity to system clock instability
* and backtracks.
*/
@@ -620,10 +647,13 @@ socket_defined (const socket_descriptor_t sd)
#endif
/*
- * Support "connection" directive
+ * Do we support challenge/response authentication, as a console-based client?
*/
-#if ENABLE_INLINE_FILES
-#define ENABLE_CONNECTION 1
-#endif
+#define ENABLE_CLIENT_CR
+
+/*
+ * Do we support pushing peer info?
+ */
+#define ENABLE_PUSH_PEER_INFO
#endif
diff --git a/t_client.rc-sample b/t_client.rc-sample
new file mode 100644
index 0000000..ca59c68
--- /dev/null
+++ b/t_client.rc-sample
@@ -0,0 +1,83 @@
+#
+# this is sourced from t_client.sh and defines which openvpn client tests
+# to run
+#
+# (sample config, copy to t_client.rc and adapt to your environment)
+#
+#
+# define these - if empty, no tests will run
+#
+CA_CERT="/home/openvpn-test-ca/keys/ca.crt"
+CLIENT_KEY="/home/openvpn-test-ca/keys/client-test.key"
+CLIENT_CERT="/home/openvpn-test-ca/keys/client-test.crt"
+#
+# remote host (used as macro below)
+#
+REMOTE=mytestserver
+#
+# tests to run (list suffixes for config stanzas below)
+#
+TEST_RUN_LIST="1 2"
+
+#
+# base confic that is the same for all the p2mp test runs
+#
+OPENVPN_BASE_P2MP="--client --ca $CA_CERT \
+ --cert $CLIENT_CERT --key $CLIENT_KEY \
+ --ns-cert-type server --nobind --comp-lzo --verb 3"
+
+# base config for p2p tests
+#
+OPENVPN_BASE_P2P="..."
+
+#
+#
+# now define the individual tests - all variables suffixed with _1, _2 etc
+# will be used in test run "1", "2", etc.
+#
+# if something is not defined here, the corresponding test is not run
+#
+# possible test options:
+#
+# OPENVPN_CONF_x = "how to call ./openvpn" [mandatory]
+# EXPECT_IFCONFIG4_x = "this IPv4 address needs to show up in ifconfig"
+# EXPECT_IFCONFIG6_x = "this IPv6 address needs to show up in ifconfig"
+# PING4_HOSTS_x = "these hosts musts ping when openvpn is up (IPv4 fping)"
+# PING6_HOSTS_x = "these hosts musts ping when openvpn is up (IPv6 fping6)"
+#
+# Test 1: UDP / p2mp tun
+# specify IPv4+IPv6 addresses expected from server and ping targets
+#
+OPENVPN_CONF_1="$OPENVPN_BASE_P2MP --dev tun --proto udp --remote $REMOTE --port 51194"
+EXPECT_IFCONFIG4_1="10.100.50.6"
+EXPECT_IFCONFIG6_1="2001:dba:a050::1:0"
+PING4_HOSTS_1="10.100.50.1 10.100.0.1"
+PING6_HOSTS_1="2001:dba::1 2001:dba:a050::1"
+
+# Test 2: TCP / p2mp tun
+#
+OPENVPN_CONF_2="$OPENVPN_BASE_P2MP --dev tun --proto tcp --remote $REMOTE --port 51194"
+EXPECT_IFCONFIG4_2="10.100.51.6"
+EXPECT_IFCONFIG6_2="2001:dba:a051::1:0"
+PING4_HOSTS_2="10.100.51.1 10.100.0.1"
+PING6_HOSTS_1="2001:dba::1 2001:dba:a051::1"
+
+# Test 3: UDP / p2p tun
+# ...
+
+# Test 4: TCP / p2p tun
+# ...
+
+# Test 5: UDP / p2mp tap
+# ...
+
+# Test 6: TCP / p2mp tun
+# ...
+
+# Test 7: UDP / p2p tap
+# ...
+
+# Test 8: TCP / p2p tap
+# ...
+
+# Test 9: whatever you want to test... :-)
diff --git a/t_client.sh.in b/t_client.sh.in
new file mode 100755
index 0000000..b273964
--- /dev/null
+++ b/t_client.sh.in
@@ -0,0 +1,298 @@
+#!@SHELL@
+#
+# run OpenVPN client against ``test reference'' server
+# - check that ping, http, ... via tunnel works
+# - check that interface config / routes are properly cleaned after test end
+#
+# prerequisites:
+# - openvpn binary in current directory
+# - writable current directory to create subdir for logs
+# - t_client.rc in current directory OR source dir that specifies tests
+# - for "ping4" checks: fping binary in $PATH
+# - for "ping6" checks: fping6 binary in $PATH
+#
+
+if [ -r ./t_client.rc ] ; then
+ . ./t_client.rc
+elif [ -r "${srcdir}"/t_client.rc ] ; then
+ . "${srcdir}"/t_client.rc
+else
+ echo "$0: cannot find 't_client.rc' in current directory or" >&2
+ echo "$0: source dir ('${srcdir}'). SKIPPING TEST." >&2
+ exit 77
+fi
+
+if [ ! -x ./openvpn ]
+then
+ echo "no (executable) openvpn binary in current directory. FAIL." >&2
+ exit 1
+fi
+
+if [ ! -w . ]
+then
+ echo "current directory is not writable (required for logging). FAIL." >&2
+ exit 1
+fi
+
+if [ -z "$CA_CERT" ] ; then
+ echo "CA_CERT not defined in 't_client.rc'. SKIP test." >&2
+ exit 77
+fi
+
+if [ -z "$TEST_RUN_LIST" ] ; then
+ echo "TEST_RUN_LIST empty, no tests defined. SKIP test." >&2
+ exit 77
+fi
+
+# make sure we have permissions to run ifconfig/route from OpenVPN
+# can't use "id -u" here - doesn't work on Solaris
+ID=`id`
+if expr "$ID" : "uid=0" >/dev/null
+then :
+else
+ echo "$0: this test must run be as root. SKIP." >&2
+ exit 77
+fi
+
+LOGDIR=t_client-`hostname`-`date +%Y%m%d-%H%M%S`
+if mkdir $LOGDIR
+then :
+else
+ echo "can't create log directory '$LOGDIR'. FAIL." >&2
+ exit 1
+fi
+
+exit_code=0
+
+# ----------------------------------------------------------
+# helper functions
+# ----------------------------------------------------------
+# print failure message, increase FAIL counter
+fail()
+{
+ echo ""
+ echo "FAIL: $@" >&2
+ fail_count=$(( $fail_count + 1 ))
+}
+
+# print "all interface IP addresses" + "all routes"
+# this is higly system dependent...
+get_ifconfig_route()
+{
+ # linux / iproute2? (-> if configure got a path)
+ if [ "@IPROUTE@" != "ip" ]
+ then
+ echo "-- linux iproute2 --"
+ @IPROUTE@ addr show | grep -v valid_lft
+ @IPROUTE@ route show
+ @IPROUTE@ -6 route show | sed -e 's/expires [0-9]*sec //'
+ return
+ fi
+
+ # try uname
+ case `uname -s` in
+ Linux)
+ echo "-- linux / ifconfig --"
+ LANG=C @IFCONFIG@ -a |egrep "( addr:|encap:)"
+ LANG=C @NETSTAT@ -rn -4 -6
+ return
+ ;;
+ FreeBSD|NetBSD|Darwin)
+ echo "-- FreeBSD/NetBSD/Darwin [MacOS X] --"
+ @IFCONFIG@ -a | egrep "(flags=|inet)"
+ @NETSTAT@ -rn | awk '$3 !~ /^UHL/ { print $1,$2,$3,$NF }'
+ return
+ ;;
+ OpenBSD)
+ echo "-- OpenBSD --"
+ @IFCONFIG@ -a | egrep "(flags=|inet)" | \
+ sed -e 's/pltime [0-9]*//' -e 's/vltime [0-9]*//'
+ @NETSTAT@ -rn | awk '$3 !~ /^UHL/ { print $1,$2,$3,$NF }'
+ return
+ ;;
+ SunOS)
+ echo "-- Solaris --"
+ @IFCONFIG@ -a | egrep "(flags=|inet)"
+ @NETSTAT@ -rn | awk '$3 !~ /^UHL/ { print $1,$2,$3,$6 }'
+ return
+ ;;
+ esac
+
+ echo "get_ifconfig_route(): no idea how to get info on your OS. FAIL." >&2
+ exit 20
+}
+
+# ----------------------------------------------------------
+# check ifconfig
+# arg1: "4" or "6" -> for message
+# arg2: IPv4/IPv6 address that must show up in out of "get_ifconfig_route"
+check_ifconfig()
+{
+ proto=$1 ; shift
+ expect_list="$@"
+
+ if [ -z "$expect_list" ] ; then return ; fi
+
+ for expect in $expect_list
+ do
+ if get_ifconfig_route | fgrep "$expect" >/dev/null
+ then :
+ else
+ fail "check_ifconfig(): expected IPv$proto address '$expect' not found in ifconfig output."
+ fi
+ done
+}
+
+# ----------------------------------------------------------
+# run pings
+# arg1: "4" or "6" -> fping/fing6
+# arg2: "want_ok" or "want_fail" (expected ping result)
+# arg3... -> fping arguments (host list)
+run_ping_tests()
+{
+ proto=$1 ; want=$2 ; shift ; shift
+ targetlist="$@"
+
+ # "no targets" is fine
+ if [ -z "$targetlist" ] ; then return ; fi
+
+ case $proto in
+ 4) cmd=fping ;;
+ 6) cmd=fping6 ;;
+ *) echo "internal error in run_ping_tests arg 1: '$proto'" >&2
+ exit 1 ;;
+ esac
+
+ case $want in
+ want_ok) sizes_list="64 1440 3000" ;;
+ want_fail) sizes_list="64" ;;
+ esac
+
+ for bytes in $sizes_list
+ do
+ echo "run IPv$proto ping tests ($want), $bytes byte packets..."
+
+ echo "$cmd -b $bytes -C 20 -p 250 -q $targetlist" >>$LOGDIR/$SUF:fping.out
+ $cmd -b $bytes -C 20 -p 250 -q $targetlist >>$LOGDIR/$SUF:fping.out 2>&1
+
+ # while OpenVPN is running, pings must succeed (want='want_ok')
+ # before OpenVPN is up, pings must NOT succeed (want='want_fail')
+
+ rc=$?
+ if [ $rc = 0 ] # all ping OK
+ then
+ if [ $want = "want_fail" ] # not what we want
+ then
+ fail "IPv$proto ping test succeeded, but needs to *fail*."
+ fi
+ else # ping failed
+ if [ $want = "want_ok" ] # not what we wanted
+ then
+ fail "IPv$proto ping test ($bytes bytes) failed, but should succeed."
+ fi
+ fi
+ done
+}
+
+# ----------------------------------------------------------
+# main test loop
+# ----------------------------------------------------------
+for SUF in $TEST_RUN_LIST
+do
+ echo -e "\n### test run $SUF ###\n"
+ fail_count=0
+
+ echo "save pre-openvpn ifconfig + route"
+ get_ifconfig_route >$LOGDIR/$SUF:ifconfig_route_pre.txt
+
+ # get config variables
+ eval openvpn_conf=\"\$OPENVPN_CONF_$SUF\"
+ eval expect_ifconfig4=\"\$EXPECT_IFCONFIG4_$SUF\"
+ eval expect_ifconfig6=\"\$EXPECT_IFCONFIG6_$SUF\"
+ eval ping4_hosts=\"\$PING4_HOSTS_$SUF\"
+ eval ping6_hosts=\"\$PING6_HOSTS_$SUF\"
+
+ echo -e "\nrun pre-openvpn ping tests - targets must not be reachable..."
+ run_ping_tests 4 want_fail "$ping4_hosts"
+ run_ping_tests 6 want_fail "$ping6_hosts"
+ if [ "$fail_count" = 0 ] ; then
+ echo -e "OK.\n"
+ else
+ echo -e "FAIL: make sure that ping hosts are ONLY reachable via VPN, SKIP test $SUF".
+ exit_code=31
+ continue
+ fi
+
+ echo " run ./openvpn $openvpn_conf"
+ ./openvpn $openvpn_conf >$LOGDIR/$SUF:openvpn.log &
+ opid=$!
+
+ # make sure openvpn client is terminated in case shell exits
+ trap "kill $opid" 0
+ trap "kill $opid ; trap - 0 ; exit 1" 1 2 3 15
+
+ echo "wait for connection to establish..."
+ sleep 10
+
+ # test whether OpenVPN process is still there
+ if kill -0 $opid
+ then :
+ else
+ echo -e "OpenVPN process has failed to start up, check log ($LOGDIR/$SUF:openvpn.log). FAIL.\ntail of logfile follows:\n..." >&2
+ tail $LOGDIR/$SUF:openvpn.log >&2
+ trap - 0 1 2 3 15
+ exit 10
+ fi
+
+ # compare whether anything changed in ifconfig/route setup?
+ echo "save ifconfig+route"
+ get_ifconfig_route >$LOGDIR/$SUF:ifconfig_route.txt
+
+ echo -n "compare pre-openvpn ifconfig+route with current values..."
+ if diff $LOGDIR/$SUF:ifconfig_route_pre.txt \
+ $LOGDIR/$SUF:ifconfig_route.txt >/dev/null
+ then
+ fail "no differences between ifconfig/route before OpenVPN start and now."
+ else
+ echo -e " OK!\n"
+ fi
+
+ # expected ifconfig values in there?
+ check_ifconfig 4 "$expect_ifconfig4"
+ check_ifconfig 6 "$expect_ifconfig6"
+
+ run_ping_tests 4 want_ok "$ping4_hosts"
+ run_ping_tests 6 want_ok "$ping6_hosts"
+ echo -e "ping tests done.\n"
+
+ echo "stopping OpenVPN"
+ kill $opid
+ wait $!
+ rc=$?
+ if [ $rc != 0 ] ; then
+ fail "OpenVPN return code $rc, expect 0"
+ fi
+
+ echo -e "\nsave post-openvpn ifconfig + route..."
+ get_ifconfig_route >$LOGDIR/$SUF:ifconfig_route_post.txt
+
+ echo -n "compare pre- and post-openvpn ifconfig + route..."
+ if diff $LOGDIR/$SUF:ifconfig_route_pre.txt \
+ $LOGDIR/$SUF:ifconfig_route_post.txt >$LOGDIR/$SUF:ifconfig_route_diff.txt
+ then
+ echo -e " OK.\n"
+ else
+ cat $LOGDIR/$SUF:ifconfig_route_diff.txt >&2
+ fail "differences between pre- and post-ifconfig/route"
+ fi
+ if [ "$fail_count" = 0 ] ; then
+ echo -e "test run $SUF: all tests OK.\n"
+ else
+ echo -e "test run $SUF: $fail_count test failures. FAIL.\n";
+ exit_code=30
+ fi
+done
+
+# remove trap handler
+trap - 0 1 2 3 15
+exit $exit_code
diff --git a/tap-win32/SOURCES.in b/tap-win32/SOURCES.in
index 58e4c59..b7f0e18 100755
--- a/tap-win32/SOURCES.in
+++ b/tap-win32/SOURCES.in
@@ -8,7 +8,7 @@ TARGETNAME=@@PRODUCT_TAP_ID@@
TARGETTYPE=DRIVER
TARGETPATH=.
TARGETLIBS=$(DDK_LIB_PATH)\ndis.lib $(DDK_LIB_PATH)\ntstrsafe.lib
-INCLUDES=$(DDK_INCLUDE_PATH)
+INCLUDES=$(DDK_INCLUDE_PATH) ..
# The TAP version numbers here must be >=
# TAP_WIN32_MIN_x values defined in
@@ -53,7 +53,7 @@ MSC_OPTIMIZATION=/Od /Oi /Fc
!ENDIF
# Generate a linker map file just in case we need one for debugging
-LINKER_FLAGS=$(LINKER_FLAGS) /MAP /MAPINFO:EXPORTS /MAPINFO:LINES
+LINKER_FLAGS=$(LINKER_FLAGS) /INCREMENTAL:NO /MAP /MAPINFO:EXPORTS
# Generate a browser information file for use in IDE development
#BROWSER_INFO=1
diff --git a/tap-win32/common.h b/tap-win32/common.h
index c8dcd5d..6785a33 100755
--- a/tap-win32/common.h
+++ b/tap-win32/common.h
@@ -4,7 +4,7 @@
*
* This code was inspired by the CIPE-Win32 driver by Damion K. Wilson.
*
- * This source code is Copyright (C) 2002-2009 OpenVPN Technologies, Inc.,
+ * This source code is Copyright (C) 2002-2010 OpenVPN Technologies, Inc.,
* and is released under the GPL version 2 (see below).
*
* This program is free software; you can redistribute it and/or modify
@@ -28,15 +28,7 @@
// common to both.
//===============================================
-#if defined(HAVE_CONFIG_H)
-#include "config.h"
-#else
-#if defined(_MSC_VER) && !defined(TAP_DRIVER_MAJOR_VERSION)
-#include "config-win32.h"
-#else
-#include "../config.h"
-#endif
-#endif
+#include "autodefs.h"
//=============
// TAP IOCTLs
diff --git a/tap-win32/constants.h b/tap-win32/constants.h
index 220d3d3..9bbd7ee 100755
--- a/tap-win32/constants.h
+++ b/tap-win32/constants.h
@@ -4,7 +4,7 @@
*
* This code was inspired by the CIPE-Win32 driver by Damion K. Wilson.
*
- * This source code is Copyright (C) 2002-2009 OpenVPN Technologies, Inc.,
+ * This source code is Copyright (C) 2002-2010 OpenVPN Technologies, Inc.,
* and is released under the GPL version 2 (see below).
*
* This program is free software; you can redistribute it and/or modify
diff --git a/tap-win32/dhcp.c b/tap-win32/dhcp.c
index 8ef3917..3891d42 100755
--- a/tap-win32/dhcp.c
+++ b/tap-win32/dhcp.c
@@ -4,7 +4,7 @@
*
* This code was inspired by the CIPE-Win32 driver by Damion K. Wilson.
*
- * This source code is Copyright (C) 2002-2009 OpenVPN Technologies, Inc.,
+ * This source code is Copyright (C) 2002-2010 OpenVPN Technologies, Inc.,
* and is released under the GPL version 2 (see below).
*
* This program is free software; you can redistribute it and/or modify
diff --git a/tap-win32/dhcp.h b/tap-win32/dhcp.h
index babe31e..4215f81 100755
--- a/tap-win32/dhcp.h
+++ b/tap-win32/dhcp.h
@@ -4,7 +4,7 @@
*
* This code was inspired by the CIPE-Win32 driver by Damion K. Wilson.
*
- * This source code is Copyright (C) 2002-2009 OpenVPN Technologies, Inc.,
+ * This source code is Copyright (C) 2002-2010 OpenVPN Technologies, Inc.,
* and is released under the GPL version 2 (see below).
*
* This program is free software; you can redistribute it and/or modify
diff --git a/tap-win32/endian.h b/tap-win32/endian.h
index 7a298f4..128029a 100755
--- a/tap-win32/endian.h
+++ b/tap-win32/endian.h
@@ -4,7 +4,7 @@
*
* This code was inspired by the CIPE-Win32 driver by Damion K. Wilson.
*
- * This source code is Copyright (C) 2002-2009 OpenVPN Technologies, Inc.,
+ * This source code is Copyright (C) 2002-2010 OpenVPN Technologies, Inc.,
* and is released under the GPL version 2 (see below).
*
* This program is free software; you can redistribute it and/or modify
diff --git a/tap-win32/error.c b/tap-win32/error.c
index 82757cc..5b25f48 100755
--- a/tap-win32/error.c
+++ b/tap-win32/error.c
@@ -4,7 +4,7 @@
*
* This code was inspired by the CIPE-Win32 driver by Damion K. Wilson.
*
- * This source code is Copyright (C) 2002-2009 OpenVPN Technologies, Inc.,
+ * This source code is Copyright (C) 2002-2010 OpenVPN Technologies, Inc.,
* and is released under the GPL version 2 (see below).
*
* This program is free software; you can redistribute it and/or modify
diff --git a/tap-win32/error.h b/tap-win32/error.h
index d3deb28..d8436dc 100755
--- a/tap-win32/error.h
+++ b/tap-win32/error.h
@@ -4,7 +4,7 @@
*
* This code was inspired by the CIPE-Win32 driver by Damion K. Wilson.
*
- * This source code is Copyright (C) 2002-2009 OpenVPN Technologies, Inc.,
+ * This source code is Copyright (C) 2002-2010 OpenVPN Technologies, Inc.,
* and is released under the GPL version 2 (see below).
*
* This program is free software; you can redistribute it and/or modify
diff --git a/tap-win32/hexdump.c b/tap-win32/hexdump.c
index b30a8e7..49bc38c 100755
--- a/tap-win32/hexdump.c
+++ b/tap-win32/hexdump.c
@@ -4,7 +4,7 @@
*
* This code was inspired by the CIPE-Win32 driver by Damion K. Wilson.
*
- * This source code is Copyright (C) 2002-2009 OpenVPN Technologies, Inc.,
+ * This source code is Copyright (C) 2002-2010 OpenVPN Technologies, Inc.,
* and is released under the GPL version 2 (see below).
*
* This program is free software; you can redistribute it and/or modify
diff --git a/tap-win32/hexdump.h b/tap-win32/hexdump.h
index cfddcf1..c1af705 100755
--- a/tap-win32/hexdump.h
+++ b/tap-win32/hexdump.h
@@ -4,7 +4,7 @@
*
* This code was inspired by the CIPE-Win32 driver by Damion K. Wilson.
*
- * This source code is Copyright (C) 2002-2009 OpenVPN Technologies, Inc.,
+ * This source code is Copyright (C) 2002-2010 OpenVPN Technologies, Inc.,
* and is released under the GPL version 2 (see below).
*
* This program is free software; you can redistribute it and/or modify
diff --git a/tap-win32/i386/OemWin2k.inf.in b/tap-win32/i386/OemWin2k.inf.in
index 830fc11..031b06c 100755
--- a/tap-win32/i386/OemWin2k.inf.in
+++ b/tap-win32/i386/OemWin2k.inf.in
@@ -1,5 +1,5 @@
; ****************************************************************************
-; * Copyright (C) 2002-2009 OpenVPN Technologies, Inc. *
+; * Copyright (C) 2002-2010 OpenVPN Technologies, Inc. *
; * This program is free software; you can redistribute it and/or modify *
; * it under the terms of the GNU General Public License version 2 *
; * as published by the Free Software Foundation. *
diff --git a/tap-win32/instance.c b/tap-win32/instance.c
index ef994ee..182cee8 100755
--- a/tap-win32/instance.c
+++ b/tap-win32/instance.c
@@ -4,7 +4,7 @@
*
* This code was inspired by the CIPE-Win32 driver by Damion K. Wilson.
*
- * This source code is Copyright (C) 2002-2009 OpenVPN Technologies, Inc.,
+ * This source code is Copyright (C) 2002-2010 OpenVPN Technologies, Inc.,
* and is released under the GPL version 2 (see below).
*
* This program is free software; you can redistribute it and/or modify
diff --git a/tap-win32/lock.h b/tap-win32/lock.h
index 7c3a1a9..ea75414 100755
--- a/tap-win32/lock.h
+++ b/tap-win32/lock.h
@@ -4,7 +4,7 @@
*
* This code was inspired by the CIPE-Win32 driver by Damion K. Wilson.
*
- * This source code is Copyright (C) 2002-2009 OpenVPN Technologies, Inc.,
+ * This source code is Copyright (C) 2002-2010 OpenVPN Technologies, Inc.,
* and is released under the GPL version 2 (see below).
*
* This program is free software; you can redistribute it and/or modify
diff --git a/tap-win32/macinfo.c b/tap-win32/macinfo.c
index c03a8c5..8d512ec 100755
--- a/tap-win32/macinfo.c
+++ b/tap-win32/macinfo.c
@@ -4,7 +4,7 @@
*
* This code was inspired by the CIPE-Win32 driver by Damion K. Wilson.
*
- * This source code is Copyright (C) 2002-2009 OpenVPN Technologies, Inc.,
+ * This source code is Copyright (C) 2002-2010 OpenVPN Technologies, Inc.,
* and is released under the GPL version 2 (see below).
*
* This program is free software; you can redistribute it and/or modify
diff --git a/tap-win32/macinfo.h b/tap-win32/macinfo.h
index 774e5d6..51e930d 100755
--- a/tap-win32/macinfo.h
+++ b/tap-win32/macinfo.h
@@ -4,7 +4,7 @@
*
* This code was inspired by the CIPE-Win32 driver by Damion K. Wilson.
*
- * This source code is Copyright (C) 2002-2009 OpenVPN Technologies, Inc.,
+ * This source code is Copyright (C) 2002-2010 OpenVPN Technologies, Inc.,
* and is released under the GPL version 2 (see below).
*
* This program is free software; you can redistribute it and/or modify
diff --git a/tap-win32/mem.c b/tap-win32/mem.c
index 3f8d949..6fbbed5 100755
--- a/tap-win32/mem.c
+++ b/tap-win32/mem.c
@@ -4,7 +4,7 @@
*
* This code was inspired by the CIPE-Win32 driver by Damion K. Wilson.
*
- * This source code is Copyright (C) 2002-2009 OpenVPN Technologies, Inc.,
+ * This source code is Copyright (C) 2002-2010 OpenVPN Technologies, Inc.,
* and is released under the GPL version 2 (see below).
*
* This program is free software; you can redistribute it and/or modify
diff --git a/tap-win32/proto.h b/tap-win32/proto.h
index e059772..0390b08 100755
--- a/tap-win32/proto.h
+++ b/tap-win32/proto.h
@@ -4,7 +4,7 @@
*
* This code was inspired by the CIPE-Win32 driver by Damion K. Wilson.
*
- * This source code is Copyright (C) 2002-2009 OpenVPN Technologies, Inc.,
+ * This source code is Copyright (C) 2002-2010 OpenVPN Technologies, Inc.,
* and is released under the GPL version 2 (see below).
*
* This program is free software; you can redistribute it and/or modify
diff --git a/tap-win32/prototypes.h b/tap-win32/prototypes.h
index ff7733a..55454d5 100755
--- a/tap-win32/prototypes.h
+++ b/tap-win32/prototypes.h
@@ -4,7 +4,7 @@
*
* This code was inspired by the CIPE-Win32 driver by Damion K. Wilson.
*
- * This source code is Copyright (C) 2002-2009 OpenVPN Technologies, Inc.,
+ * This source code is Copyright (C) 2002-2010 OpenVPN Technologies, Inc.,
* and is released under the GPL version 2 (see below).
*
* This program is free software; you can redistribute it and/or modify
diff --git a/tap-win32/resource.rc b/tap-win32/resource.rc
index d7f25a8..84884cf 100755
--- a/tap-win32/resource.rc
+++ b/tap-win32/resource.rc
@@ -2,7 +2,6 @@
#include <ntverp.h>
/* get VERSION */
-#include "../config-win32.h"
#include "common.h"
/* VER_FILETYPE, VER_FILESUBTYPE, VER_FILEDESCRIPTION_STR
@@ -36,7 +35,7 @@
#define VER_COMPANYNAME_STR "The OpenVPN Project"
#define VER_FILEDESCRIPTION_STR "TAP-Win32 Virtual Network Driver"
#define VER_ORIGINALFILENAME_STR TAP_COMPONENT_ID ".sys"
-#define VER_LEGALCOPYRIGHT_YEARS "2003-2009"
+#define VER_LEGALCOPYRIGHT_YEARS "2003-2010"
#define VER_LEGALCOPYRIGHT_STR "OpenVPN Technologies, Inc."
@@ -46,7 +45,7 @@
#define XSTR(s) STR(s)
#define STR(s) #s
-#define VSTRING VERSION " " XSTR(TAP_DRIVER_MAJOR_VERSION) "/" XSTR(TAP_DRIVER_MINOR_VERSION)
+#define VSTRING PACKAGE_VERSION " " XSTR(TAP_DRIVER_MAJOR_VERSION) "/" XSTR(TAP_DRIVER_MINOR_VERSION)
#ifdef DBG
#define VER_PRODUCTVERSION_STR VSTRING " (DEBUG)"
diff --git a/tap-win32/tapdrvr.c b/tap-win32/tapdrvr.c
index 2c6af48..506f1f6 100755
--- a/tap-win32/tapdrvr.c
+++ b/tap-win32/tapdrvr.c
@@ -4,7 +4,7 @@
*
* This code was inspired by the CIPE-Win32 driver by Damion K. Wilson.
*
- * This source code is Copyright (C) 2002-2009 OpenVPN Technologies, Inc.,
+ * This source code is Copyright (C) 2002-2010 OpenVPN Technologies, Inc.,
* and is released under the GPL version 2 (see below).
*
* This program is free software; you can redistribute it and/or modify
@@ -35,7 +35,7 @@
// TAP_IOCTL_CONFIG_TUN ioctl.
//======================================================
-#include "../../autodefs/defs.h"
+#include "common.h"
#ifndef DDKVER_MAJOR
#error DDKVER_MAJOR must be defined as the major number of the DDK Version
#endif
@@ -78,7 +78,6 @@
#include "lock.h"
#include "constants.h"
-#include "common.h"
#include "proto.h"
#include "error.h"
#include "endian.h"
@@ -209,7 +208,7 @@ DriverEntry (IN PDRIVER_OBJECT p_DriverObject,
TAP_DRIVER_MINOR_VERSION,
__DATE__,
__TIME__));
- DEBUGP (("Registry Path: '%S'\n", p_RegistryPath->Buffer));
+ DEBUGP (("Registry Path: '%.*S'\n", p_RegistryPath->Length/2, p_RegistryPath->Buffer));
break;
}
@@ -414,7 +413,9 @@ NDIS_STATUS AdapterCreate
{
if (parm->ParameterType == NdisParameterString)
{
- DEBUGP (("[TAP] NdisReadConfiguration (MiniportName=%S)\n", parm->ParameterData.StringData.Buffer));
+ DEBUGP (("[TAP] NdisReadConfiguration (MiniportName=%.*S)\n",
+ parm->ParameterData.StringData.Length/2,
+ parm->ParameterData.StringData.Buffer));
if (RtlUnicodeStringToAnsiString (
&l_Adapter->m_NameAnsi,
diff --git a/tap-win32/types.h b/tap-win32/types.h
index 48bdff7..9406252 100755
--- a/tap-win32/types.h
+++ b/tap-win32/types.h
@@ -4,7 +4,7 @@
*
* This code was inspired by the CIPE-Win32 driver by Damion K. Wilson.
*
- * This source code is Copyright (C) 2002-2009 OpenVPN Technologies, Inc.,
+ * This source code is Copyright (C) 2002-2010 OpenVPN Technologies, Inc.,
* and is released under the GPL version 2 (see below).
*
* This program is free software; you can redistribute it and/or modify
diff --git a/tun.c b/tun.c
index a984369..0e4476e 100644
--- a/tun.c
+++ b/tun.c
@@ -5,7 +5,7 @@
* packet encryption, packet authentication, and
* packet compression.
*
- * Copyright (C) 2002-2009 OpenVPN Technologies, Inc. <sales@openvpn.net>
+ * Copyright (C) 2002-2010 OpenVPN Technologies, Inc. <sales@openvpn.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2
@@ -55,7 +55,7 @@ static void netsh_ifconfig (const struct tuntap_options *to,
const char *flex_name,
const in_addr_t ip,
const in_addr_t netmask,
- unsigned int flags);
+ const unsigned int flags);
static const char *netsh_get_id (const char *dev_node, struct gc_arena *gc);
@@ -1180,7 +1180,7 @@ open_tun (const char *dev, const char *dev_type, const char *dev_node, bool ipv6
* Try making the TX send queue bigger
*/
#if defined(IFF_ONE_QUEUE) && defined(SIOCSIFTXQLEN)
- {
+ if (tt->options.txqueuelen) {
struct ifreq netifr;
int ctl_fd;
@@ -3475,6 +3475,48 @@ netsh_command (const struct argv *a, int n)
}
void
+ipconfig_register_dns (const struct env_set *es)
+{
+ struct argv argv;
+ bool status;
+ const char err[] = "ERROR: Windows ipconfig command failed";
+
+ netcmd_semaphore_lock ();
+
+ argv_init (&argv);
+
+ argv_printf (&argv, "%s%sc stop dnscache",
+ get_win_sys_path(),
+ WIN_NET_PATH_SUFFIX);
+ argv_msg (D_TUNTAP_INFO, &argv);
+ status = openvpn_execve_check (&argv, es, 0, err);
+ argv_reset(&argv);
+
+ argv_printf (&argv, "%s%sc start dnscache",
+ get_win_sys_path(),
+ WIN_NET_PATH_SUFFIX);
+ argv_msg (D_TUNTAP_INFO, &argv);
+ status = openvpn_execve_check (&argv, es, 0, err);
+ argv_reset(&argv);
+
+ argv_printf (&argv, "%s%sc /flushdns",
+ get_win_sys_path(),
+ WIN_IPCONFIG_PATH_SUFFIX);
+ argv_msg (D_TUNTAP_INFO, &argv);
+ status = openvpn_execve_check (&argv, es, 0, err);
+ argv_reset(&argv);
+
+ argv_printf (&argv, "%s%sc /registerdns",
+ get_win_sys_path(),
+ WIN_IPCONFIG_PATH_SUFFIX);
+ argv_msg (D_TUNTAP_INFO, &argv);
+ status = openvpn_execve_check (&argv, es, 0, err);
+ argv_reset(&argv);
+
+ netcmd_semaphore_release ();
+}
+
+void
ip_addr_string_to_array (in_addr_t *dest, int *dest_len, const IP_ADDR_STRING *src)
{
int i = 0;
@@ -3909,8 +3951,23 @@ fork_dhcp_action (struct tuntap *tt)
buf_printf (&cmd, " --dhcp-pre-release");
if (tt->options.dhcp_renew)
buf_printf (&cmd, " --dhcp-renew");
- buf_printf (&cmd, " --dhcp-rr %u", (unsigned int)tt->adapter_index);
+ buf_printf (&cmd, " --dhcp-internal %u", (unsigned int)tt->adapter_index);
+
+ fork_to_self (BSTR (&cmd));
+ gc_free (&gc);
+ }
+}
+void
+fork_register_dns_action (struct tuntap *tt)
+{
+ if (tt && tt->options.register_dns)
+ {
+ struct gc_arena gc = gc_new ();
+ struct buffer cmd = alloc_buf_gc (256, &gc);
+ const int verb = 3;
+
+ buf_printf (&cmd, "openvpn --verb %d --register-dns --rdns-internal", verb);
fork_to_self (BSTR (&cmd));
gc_free (&gc);
}
diff --git a/tun.h b/tun.h
index 210278a..011ab54 100644
--- a/tun.h
+++ b/tun.h
@@ -5,7 +5,7 @@
* packet encryption, packet authentication, and
* packet compression.
*
- * Copyright (C) 2002-2009 OpenVPN Technologies, Inc. <sales@openvpn.net>
+ * Copyright (C) 2002-2010 OpenVPN Technologies, Inc. <sales@openvpn.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2
@@ -99,6 +99,8 @@ struct tuntap_options {
bool dhcp_renew;
bool dhcp_pre_release;
bool dhcp_release;
+
+ bool register_dns;
};
#elif TARGET_LINUX
@@ -335,6 +337,9 @@ void tun_show_debug (struct tuntap *tt);
bool dhcp_release_by_adapter_index(const DWORD adapter_index);
bool dhcp_renew_by_adapter_index (const DWORD adapter_index);
+void fork_register_dns_action (struct tuntap *tt);
+void ipconfig_register_dns (const struct env_set *es);
+
void tun_standby_init (struct tuntap *tt);
bool tun_standby (struct tuntap *tt);
diff --git a/version.m4 b/version.m4
index 5babcaa..e1f23d4 100644
--- a/version.m4
+++ b/version.m4
@@ -1,5 +1,5 @@
dnl define the OpenVPN version
-define(PRODUCT_VERSION,[2.1.1b])
+define(PRODUCT_VERSION,[2.2-beta4])
dnl define the TAP version
define(PRODUCT_TAP_ID,[tap0901])
define(PRODUCT_TAP_WIN32_MIN_MAJOR,[9])
diff --git a/win/__init__.py b/win/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/win/__init__.py
diff --git a/win/autodefs.h.in b/win/autodefs.h.in
new file mode 100644
index 0000000..2edd9b6
--- /dev/null
+++ b/win/autodefs.h.in
@@ -0,0 +1,31 @@
+#ifndef AUTODEFS_H
+#define AUTODEFS_H
+
+/*
+ * Minimum TAP-Win32 version number expected by userspace
+ *
+ * The TAP-Win32 version number is defined in tap-win32/SOURCES
+ */
+#define TAP_ID "@PRODUCT_TAP_ID@"
+#define TAP_WIN32_MIN_MAJOR @PRODUCT_TAP_WIN32_MIN_MAJOR@
+#define TAP_WIN32_MIN_MINOR @PRODUCT_TAP_WIN32_MIN_MINOR@
+
+/* Friendly name for TAP driver */
+#define PRODUCT_TAP_DEVICE_DESCRIPTION "@PRODUCT_TAP_DEVICE_DESCRIPTION@"
+
+/* Version number of DDK/WDK used to build TAP driver */
+#define DDKVER_MAJOR @DDKVER_MAJOR@
+
+/* Name of package */
+#define PACKAGE "@PRODUCT_UNIX_NAME@"
+
+/* Define to the full name of this package. */
+#define PACKAGE_NAME "@PRODUCT_NAME@"
+
+/* Define to the one symbol short name of this package. */
+#define PACKAGE_TARNAME "@PRODUCT_UNIX_NAME@"
+
+/* Define to the version of this package. */
+#define PACKAGE_VERSION "@PRODUCT_VERSION@"
+
+#endif
diff --git a/win/build.py b/win/build.py
new file mode 100644
index 0000000..3a9fbc7
--- /dev/null
+++ b/win/build.py
@@ -0,0 +1,22 @@
+import os, sys
+from wb import system, config, home_fn, cd_home
+
+os.environ['PATH'] += ";%s\\VC" % (os.path.normpath(config['MSVC']),)
+
+def build_vc(cmd):
+ system('cmd /c "vcvarsall.bat x86 && %s"' % (cmd,))
+
+def main():
+ cd_home()
+ build_vc("nmake /f %s" % (home_fn('msvc.mak'),))
+
+def clean():
+ cd_home()
+ build_vc("nmake /f %s clean" % (home_fn('msvc.mak'),))
+
+# if we are run directly, and not loaded as a module
+if __name__ == "__main__":
+ if len(sys.argv) == 2 and sys.argv[1] == 'clean':
+ clean()
+ else:
+ main()
diff --git a/win/build_all.py b/win/build_all.py
new file mode 100644
index 0000000..dec3a78
--- /dev/null
+++ b/win/build_all.py
@@ -0,0 +1,59 @@
+import getopt, sys
+from config_all import main as config_all
+from build import main as build_openvpn
+from build_ddk import main as build_ddk
+from make_dist import main as make_dist
+
+def Usage():
+ '''Show usage information'''
+ print "Usage: build_all.py [OPTIONS]..."
+ print "Build OpenVPN using Visual Studio tools"
+ print
+ print " -h, --help Show this help"
+ print " -u, --unsigned Do not sign the TAP drivers"
+ sys.exit(1)
+
+def main(config):
+
+ # Do a signed build by default
+ signedBuild=True
+
+ # Parse the command line argument(s)
+ try:
+ opts, args = getopt.getopt(sys.argv[1:], "hu", ["help", "unsigned"])
+ except getopt.GetoptError:
+ Usage()
+
+ for o, a in opts:
+ if o in ("-h","--help"):
+ Usage()
+ if o in ("-u", "--unsigned"):
+ signedBuild=False
+
+
+ # Check if the SignTool module is present. This avoids ImportErrors popping
+ # up annoyingly _after_ the build.
+ if signedBuild:
+ try:
+ from signtool import SignTool
+ except (ImportError):
+ print "ERROR: SignTool python module not found! Can't do a signed build."
+ sys.exit(1)
+ else:
+ print "Doing an unsigned build as requested"
+
+ # Start the build
+ config_all(config)
+ build_openvpn()
+ build_ddk(config, 'tap', 'all')
+ build_ddk(config, 'tapinstall', 'all')
+
+ if signedBuild:
+ sign(config, 'all')
+
+ make_dist(config)
+
+# if we are run directly, and not loaded as a module
+if __name__ == "__main__":
+ from wb import config
+ main(config)
diff --git a/win/build_ddk.py b/win/build_ddk.py
new file mode 100644
index 0000000..1a0cf82
--- /dev/null
+++ b/win/build_ddk.py
@@ -0,0 +1,54 @@
+import os
+from wb import system, home_fn, choose_arch
+
+def build_ddk(config, dir, x64):
+ ddk_path = config['DDK_PATH']
+ ddk_major = int(config['DDKVER_MAJOR'])
+ debug = 'PRODUCT_TAP_DEBUG' in config
+ return build_tap(ddk_path, ddk_major, debug, dir, x64)
+
+def build_tap(ddk_path, ddk_major, debug, dir, x64):
+ setenv_bat = os.path.realpath(os.path.join(ddk_path, 'bin/setenv.bat'))
+ target = 'chk' if debug else 'fre'
+ if x64:
+ target += ' x64'
+ else:
+ target += ' x86'
+ if ddk_major >= 7600:
+ if x64:
+ target += ' wlh' # vista
+ else:
+ target += ' wnet' # server 2003
+ else:
+ if x64:
+ target += ' wnet' # server 2003
+ else:
+ target += ' w2k' # 2000
+
+ system('cmd /c "%s %s %s && cd %s && build -cef"' % (
+ setenv_bat,
+ os.path.realpath(ddk_path),
+ target,
+ dir
+ ))
+
+def main(config, proj, arch):
+ if proj == 'tap':
+ dir = home_fn('tap-win32')
+ elif proj == 'tapinstall':
+ dir = home_fn('tapinstall')
+ else:
+ raise ValueError("unknown project: %s" % (proj,))
+
+ for x64 in choose_arch(arch):
+ build_ddk(config, dir, x64)
+
+# if we are run directly, and not loaded as a module
+if __name__ == "__main__":
+ import sys
+ from wb import config
+ if len(sys.argv) >= 3:
+ main(config, sys.argv[1], sys.argv[2])
+ else:
+ print "usage: build <tap|tapinstall> <x64|x86|all>"
+ sys.exit(2)
diff --git a/win/build_exe.py b/win/build_exe.py
new file mode 100644
index 0000000..087f9a3
--- /dev/null
+++ b/win/build_exe.py
@@ -0,0 +1,15 @@
+from config import main as config_main
+from build import main as build_openvpn
+from build_ddk import main as build_ddk
+from sign import main as sign
+from make_dist import main as make_dist
+
+def main(config):
+ config_main(config)
+ build_openvpn()
+ make_dist(config, tap=False)
+
+# if we are run directly, and not loaded as a module
+if __name__ == "__main__":
+ from wb import config
+ main(config)
diff --git a/win/config.py b/win/config.py
new file mode 100644
index 0000000..cf38cac
--- /dev/null
+++ b/win/config.py
@@ -0,0 +1,18 @@
+from wb import preprocess, autogen, mod_fn, home_fn, build_autodefs, make_headers_objs, dict_def
+
+def main(config):
+ build_autodefs(config, mod_fn('autodefs.h.in'), home_fn('autodefs.h'))
+ ho = make_headers_objs(home_fn('Makefile.am'))
+
+ preprocess(dict_def(config, [('HEADERS_OBJS', ho)]),
+ in_fn=mod_fn('msvc.mak.in'),
+ out_fn=home_fn('msvc.mak'),
+ quote_begin='@',
+ quote_end='@',
+ if_prefix='!',
+ head_comment='# %s\n\n' % autogen)
+
+# if we are run directly, and not loaded as a module
+if __name__ == "__main__":
+ from wb import config
+ main(config)
diff --git a/win/config_all.py b/win/config_all.py
new file mode 100644
index 0000000..2686780
--- /dev/null
+++ b/win/config_all.py
@@ -0,0 +1,13 @@
+from config import main as config_main
+from config_tap import main as config_tap
+from config_ti import main as config_ti
+
+def main(config):
+ config_main(config)
+ config_tap(config)
+ config_ti(config)
+
+# if we are run directly, and not loaded as a module
+if __name__ == "__main__":
+ from wb import config
+ main(config)
diff --git a/win/config_tap.py b/win/config_tap.py
new file mode 100644
index 0000000..e69ee9b
--- /dev/null
+++ b/win/config_tap.py
@@ -0,0 +1,35 @@
+import os
+from wb import preprocess, home_fn, autogen, dict_def
+
+def main(config):
+ preprocess(config,
+ in_fn=home_fn('tap-win32/SOURCES.in'),
+ out_fn=home_fn('tap-win32/SOURCES'),
+ quote_begin='@@',
+ quote_end='@@',
+ head_comment='# %s\n\n' % autogen)
+
+ preprocess(config,
+ in_fn=home_fn('tap-win32/i386/OemWin2k.inf.in'),
+ out_fn=home_fn('tap-win32/i386/OemWin2k.inf'),
+ quote_begin='@@',
+ quote_end='@@',
+ if_prefix='!',
+ head_comment='; %s\n\n' % autogen)
+
+ try:
+ os.mkdir(home_fn('tap-win32/amd64'))
+ except:
+ pass
+ preprocess(dict_def(config, [('AMD64', '1')]),
+ in_fn=home_fn('tap-win32/i386/OemWin2k.inf.in'),
+ out_fn=home_fn('tap-win32/amd64/OemWin2k.inf'),
+ quote_begin='@@',
+ quote_end='@@',
+ if_prefix='!',
+ head_comment='; %s\n\n' % autogen)
+
+# if we are run directly, and not loaded as a module
+if __name__ == "__main__":
+ from wb import config
+ main(config)
diff --git a/win/config_ti.py b/win/config_ti.py
new file mode 100644
index 0000000..4facaff
--- /dev/null
+++ b/win/config_ti.py
@@ -0,0 +1,18 @@
+import os, shutil
+from wb import preprocess, home_fn, autogen
+
+def main(config):
+ src = os.path.join(home_fn(config['TISRC']), config['DDKVER_MAJOR'])
+ dest = home_fn('tapinstall')
+ shutil.rmtree(dest, ignore_errors=True)
+ shutil.copytree(src, dest)
+ preprocess(config,
+ in_fn=os.path.join(dest, 'sources.in'),
+ out_fn=os.path.join(dest, 'sources'),
+ if_prefix='!',
+ head_comment='# %s\n\n' % autogen)
+
+# if we are run directly, and not loaded as a module
+if __name__ == "__main__":
+ from wb import config
+ main(config)
diff --git a/win/js.py b/win/js.py
new file mode 100644
index 0000000..c515824
--- /dev/null
+++ b/win/js.py
@@ -0,0 +1,10 @@
+import json
+
+# usage:
+# print JSON().encode(kv)
+
+class JSON(json.JSONEncoder):
+ def __init__(self, **kwargs):
+ args = dict(sort_keys=True, indent=2)
+ args.update(kwargs)
+ json.JSONEncoder.__init__(self, **args)
diff --git a/win/make_dist.py b/win/make_dist.py
new file mode 100644
index 0000000..a6a0563
--- /dev/null
+++ b/win/make_dist.py
@@ -0,0 +1,56 @@
+import os
+from wb import home_fn, rm_rf, mkdir, cp_a, cp
+
+def main(config, tap=True):
+ dist = config['DIST']
+ assert dist
+ dist = home_fn(dist)
+ bin = os.path.join(dist, 'bin')
+ i386 = os.path.join(dist, 'i386')
+ amd64 = os.path.join(dist, 'amd64')
+
+ # build dist and subdirectories
+ rm_rf(dist)
+ mkdir(dist)
+ mkdir(bin)
+ if tap:
+ mkdir(i386)
+ mkdir(amd64)
+
+ # copy openvpn.exe and manifest
+ cp(home_fn('openvpn.exe'), bin)
+ cp(home_fn('openvpn.exe.manifest'), bin)
+
+ # copy DLL dependencies
+ cp(home_fn(config['LZO_DIR']+'/bin/lzo2.dll'), bin)
+ cp(home_fn(config['OPENSSL_DIR']+'/bin/libeay32.dll'), bin)
+ cp(home_fn(config['OPENSSL_DIR']+'/bin/ssleay32.dll'), bin)
+
+ # copy MSVC CRT
+ cp_a(home_fn(config['MSVC_CRT']), bin)
+
+ if tap:
+ # copy TAP drivers
+ for dir_name, dest in (('amd64', amd64), ('i386', i386)):
+ dir = home_fn(os.path.join('tap-win32', dir_name))
+ for dirpath, dirnames, filenames in os.walk(dir):
+ for f in filenames:
+ root, ext = os.path.splitext(f)
+ if ext in ('.inf', '.cat', '.sys'):
+ cp(os.path.join(dir, f), dest)
+ break
+
+ # copy tapinstall
+ dest = {'amd64' : amd64, 'i386' : i386}
+ for dirpath, dirnames, filenames in os.walk(home_fn('tapinstall')):
+ for f in filenames:
+ if f == 'tapinstall.exe':
+ dir_name = os.path.basename(dirpath)
+ src = os.path.join(dirpath, f)
+ if dir_name in dest:
+ cp(src, dest[dir_name])
+
+# if we are run directly, and not loaded as a module
+if __name__ == "__main__":
+ from wb import config
+ main(config)
diff --git a/win/msvc.mak.in b/win/msvc.mak.in
new file mode 100644
index 0000000..5d94a6e
--- /dev/null
+++ b/win/msvc.mak.in
@@ -0,0 +1,57 @@
+# This makefile builds the user-mode component
+# of OpenVPN for Windows in the Visual Studio 2008 environment.
+
+# To build:
+# python win\config.py
+# nmake /f msvc.mak
+
+# Each of the OPENSSL and LZO dirs should have 'lib' and 'include'
+# directories under them.
+
+OPENSSL = @OPENSSL_DIR@
+OPENSSL_DYNAMIC = libeay32.lib ssleay32.lib
+
+LZO = @LZO_DIR@
+LZO_DYNAMIC = lzo2.lib
+
+INCLUDE_DIRS = -I$(OPENSSL)/include -I$(LZO)/include
+
+LIBS = $(OPENSSL_DYNAMIC) $(LZO_DYNAMIC) ws2_32.lib crypt32.lib iphlpapi.lib winmm.lib user32.lib gdi32.lib advapi32.lib wininet.lib
+
+LIB_DIRS = -LIBPATH:$(OPENSSL)\lib -LIBPATH:$(LZO)\lib
+
+EXE = openvpn.exe
+
+CPP=cl.exe
+CPP_ARG_COMMON=/nologo /W3 -DWIN32 -DWIN32_LEAN_AND_MEAN -D_CONSOLE -D_MBCS -D_CRT_SECURE_NO_DEPRECATE $(INCLUDE_DIRS) /FD /c
+
+LINK32=link.exe
+
+!ifdef PRODUCT_OPENVPN_DEBUG
+# debug:
+CPP_PROJ=$(CPP_ARG_COMMON) /MD /Z7
+LINK32_FLAGS=/nologo /subsystem:console /incremental:no /opt:ref /opt:icf /debug /out:"$(EXE)"
+# old debug:
+#CPP_PROJ=$(CPP_ARG_COMMON) /MDd /Zi /Od -D_DEBUG
+#LINK32_FLAGS=/nologo /subsystem:console /incremental:no /debug /out:"$(EXE)"
+!else
+# release:
+CPP_PROJ=$(CPP_ARG_COMMON) /O2 /MD -DNDEBUG
+LINK32_FLAGS=/nologo /subsystem:console /incremental:no /out:"$(EXE)"
+!endif
+
+# HEADERS and OBJS definitions, automatically generated
+@HEADERS_OBJS@
+
+openvpn : $(OBJS)
+ $(LINK32) @<<
+ $(LINK32_FLAGS) $(LIB_DIRS) $(LIBS) $(OBJS)
+<<
+
+clean :
+ del /Q $(OBJS) $(EXE) *.idb *.pdb
+
+.c.obj::
+ $(CPP) @<<
+ $(CPP_PROJ) $<
+<<
diff --git a/win/settings.in b/win/settings.in
new file mode 100644
index 0000000..f8eeb20
--- /dev/null
+++ b/win/settings.in
@@ -0,0 +1,68 @@
+# Version numbers, settings, and dependencies
+# for Windows OpenVPN installer.
+
+# Branding
+!define PRODUCT_NAME "OpenVPN"
+!define PRODUCT_UNIX_NAME "openvpn"
+!define PRODUCT_FILE_EXT "ovpn"
+
+# Allow --askpass and --auth-user-pass passwords to be read from a file
+;!define ENABLE_PASSWORD_SAVE
+
+# Include the OpenVPN GUI exe in the installer.
+# May be undefined.
+!define OPENVPN_GUI_DIR "../openvpn-gui"
+!define OPENVPN_GUI "openvpn-gui-1.0.3.exe"
+
+# Prebuilt libraries. DMALLOC is optional.
+!define OPENSSL_DIR "../openssl"
+!define LZO_DIR "../lzo"
+
+# write output files here
+!define DIST "dist"
+
+# tapinstall.exe source code.
+# Not needed if DRVBINSRC is defined
+# (or if using pre-built mode).
+!define TISRC "../tapinstall"
+
+# TAP Adapter parameters. Note that PRODUCT_TAP_ID is
+# defined in version.m4.
+!define PRODUCT_TAP_DEVICE_DESCRIPTION "TAP-Win32 Adapter V9"
+!define PRODUCT_TAP_PROVIDER "TAP-Win32 Provider V9"
+!define PRODUCT_TAP_MAJOR_VER 9
+!define PRODUCT_TAP_MINOR_VER 7
+!define PRODUCT_TAP_RELDATE "04/19/2010"
+
+# TAP adapter icon -- visible=0x81 or hidden=0x89
+!define PRODUCT_TAP_CHARACTERISTICS 0x81
+
+# Build debugging version of TAP driver
+;!define PRODUCT_TAP_DEBUG
+
+# Build debugging version of openvpn.exe
+;!define PRODUCT_OPENVPN_DEBUG
+
+# DDK path -- currently Windows 7 WDK
+!define DDK_PATH "c:/winddk/7600.16385.1"
+;!define DDK_PATH "c:/winddk/6001.18002"
+
+# output path for tap_span.py
+!define TAP_DIST "tap_dist"
+
+# Visual studio path
+!define MSVC "C:/Program Files/Microsoft Visual Studio 9.0"
+
+# Visual studio C run-time library path
+!define MSVC_CRT "../Microsoft.VC90.CRT"
+
+# Code Signing.
+# If undefined, don't sign any files.
+!define SIGNTOOL "../signtool"
+!define PRODUCT_SIGN_CN "openvpn"
+
+; DEBUGGING -- set to something like "-DBG2"
+!define OUTFILE_LABEL ""
+
+; DEBUGGING -- set to something like "DEBUG2"
+!define TITLE_LABEL ""
diff --git a/win/show.py b/win/show.py
new file mode 100644
index 0000000..9558c87
--- /dev/null
+++ b/win/show.py
@@ -0,0 +1,10 @@
+from wb import get_config
+from js import JSON
+
+def main():
+ kv = get_config()
+ print JSON().encode(kv)
+
+# if we are run directly, and not loaded as a module
+if __name__ == "__main__":
+ main()
diff --git a/win/sign.py b/win/sign.py
new file mode 100644
index 0000000..ee4ae72
--- /dev/null
+++ b/win/sign.py
@@ -0,0 +1,19 @@
+import sys
+from wb import config, choose_arch, home_fn
+
+if 'SIGNTOOL' in config:
+ sys.path.append(home_fn(config['SIGNTOOL']))
+
+def main(conf, arch):
+ from signtool import SignTool
+ st = SignTool(conf)
+ for x64 in choose_arch(arch):
+ st.sign_verify(x64=x64)
+
+# if we are run directly, and not loaded as a module
+if __name__ == "__main__":
+ if len(sys.argv) >= 2:
+ main(config, sys.argv[1])
+ else:
+ print "usage: sign <x64|x86|all>"
+ sys.exit(2)
diff --git a/win/tap_span.py b/win/tap_span.py
new file mode 100644
index 0000000..9cd127b
--- /dev/null
+++ b/win/tap_span.py
@@ -0,0 +1,129 @@
+import sys, os, shutil
+from wb import config, home_fn, mod_fn, preprocess, autogen, dict_def, build_autodefs, rm_rf, mkdir_silent, cp
+if 'SIGNTOOL' in config:
+ sys.path.append(home_fn(config['SIGNTOOL']))
+from signtool import SignTool
+from build_ddk import build_tap
+
+ti_dir = "c:/src/tapinstall"
+hi = ("c:/winddk/7600.16385.1", 7600, 7600, ("i386", "amd64"))
+low = ("c:/winddk/6001.18002", 6001, 5600, ("win2k",))
+dest_top = home_fn('tap_build')
+dist = home_fn(config['TAP_DIST'])
+
+def copy_tap(src, dest, x64):
+ dir = os.path.join(src, { False : 'i386', True: 'amd64' }[x64])
+ mkdir_silent(dest)
+ for dirpath, dirnames, filenames in os.walk(dir):
+ for f in filenames:
+ root, ext = os.path.splitext(f)
+ if ext in ('.inf', '.cat', '.sys'):
+ cp(os.path.join(dir, f), dest)
+ break
+
+def copy_tapinstall(src, dest, x64):
+ base = { False : 'i386', True: 'amd64' }[x64]
+ mkdir_silent(dest)
+ for dirpath, dirnames, filenames in os.walk(home_fn(src)):
+ for f in filenames:
+ if f == 'tapinstall.exe':
+ dir_name = os.path.basename(dirpath)
+ s = os.path.join(dirpath, f)
+ if dir_name == base:
+ cp(s, dest)
+
+def main():
+ rm_rf(dest_top)
+ os.mkdir(dest_top)
+
+ rm_rf(dist)
+ os.mkdir(dist)
+
+ for ver in hi, low:
+ top = os.path.join(dest_top, str(ver[1]))
+ os.mkdir(top)
+ tap_dest = os.path.join(top, "tap-win32")
+ ti_dest = os.path.join(top, "tapinstall")
+ ti_src = os.path.join(ti_dir, str(ver[2]))
+ shutil.copytree(home_fn("tap-win32"), tap_dest)
+ shutil.copytree(ti_src, ti_dest)
+
+ i386 = os.path.join(tap_dest, "i386")
+ amd64 = os.path.join(tap_dest, "amd64")
+
+ build_amd64 = (len(ver[3]) >= 2)
+
+ build_autodefs(config, mod_fn('autodefs.h.in'), os.path.join(top, 'autodefs.h'))
+
+ st = SignTool(config, tap_dest)
+
+ preprocess(config,
+ in_fn=os.path.join(tap_dest, 'SOURCES.in'),
+ out_fn=os.path.join(tap_dest, 'SOURCES'),
+ quote_begin='@@',
+ quote_end='@@',
+ head_comment='# %s\n\n' % autogen)
+
+ preprocess(config,
+ in_fn=os.path.join(i386, 'OemWin2k.inf.in'),
+ out_fn=os.path.join(i386, 'OemWin2k.inf'),
+ quote_begin='@@',
+ quote_end='@@',
+ if_prefix='!',
+ head_comment='; %s\n\n' % autogen)
+
+ preprocess(config,
+ in_fn=os.path.join(ti_dest, 'sources.in'),
+ out_fn=os.path.join(ti_dest, 'sources'),
+ if_prefix='!',
+ head_comment='# %s\n\n' % autogen)
+
+ build_tap(ddk_path=ver[0],
+ ddk_major=ver[1],
+ debug=False,
+ dir=tap_dest,
+ x64=False)
+
+ st.sign_verify(x64=False)
+
+ build_tap(ddk_path=ver[0],
+ ddk_major=ver[1],
+ debug=False,
+ dir=ti_dest,
+ x64=False)
+
+ tap_dist = os.path.join(dist, ver[3][0])
+
+ copy_tap(tap_dest, tap_dist, x64=False)
+ copy_tapinstall(ti_dest, tap_dist, x64=False)
+
+ if build_amd64:
+ os.mkdir(amd64)
+ preprocess(dict_def(config, [('AMD64', '1')]),
+ in_fn=os.path.join(i386, 'OemWin2k.inf.in'),
+ out_fn=os.path.join(amd64, 'OemWin2k.inf'),
+ quote_begin='@@',
+ quote_end='@@',
+ if_prefix='!',
+ head_comment='; %s\n\n' % autogen)
+
+ build_tap(ddk_path=ver[0],
+ ddk_major=ver[1],
+ debug=False,
+ dir=tap_dest,
+ x64=True)
+
+ build_tap(ddk_path=ver[0],
+ ddk_major=ver[1],
+ debug=False,
+ dir=ti_dest,
+ x64=True)
+
+ st.sign_verify(x64=True)
+
+ tap_dist_x64 = os.path.join(dist, ver[3][1])
+
+ copy_tap(tap_dest, tap_dist_x64, x64=True)
+ copy_tapinstall(ti_dest, tap_dist_x64, x64=True)
+
+main()
diff --git a/win/wb.py b/win/wb.py
new file mode 100644
index 0000000..8e23684
--- /dev/null
+++ b/win/wb.py
@@ -0,0 +1,215 @@
+# Python module containing general build functions
+# for OpenVPN on Windows
+
+import os, re, shutil, stat
+
+autogen = "Automatically generated by OpenVPN Windows build system"
+
+def get_config():
+ kv = {}
+ parse_version_m4(kv, home_fn('version.m4'))
+ parse_settings_in(kv, mod_fn('settings.in'))
+
+ # config fixups
+ kv['DDKVER'] = os.path.basename(kv['DDK_PATH'])
+ kv['DDKVER_MAJOR'] = re.match(r'^(\d+)\.', kv['DDKVER']).groups()[0]
+
+ if 'VERSION_SUFFIX' in kv:
+ kv['PRODUCT_VERSION'] += kv['VERSION_SUFFIX']
+
+ return kv
+
+def mod_fn(fn, src=__file__, real=True):
+ p = os.path.join(os.path.dirname(src), os.path.normpath(fn))
+ if real:
+ p = os.path.realpath(p)
+ return p
+
+def home_fn(fn, real=True):
+ return mod_fn(os.path.join('..', fn), real=real)
+
+def cd_home():
+ os.chdir(os.path.join(os.path.dirname(__file__), '..'))
+
+def system(cmd):
+ print "RUN:", cmd
+ os.system(cmd)
+
+def parse_version_m4(kv, version_m4):
+ r = re.compile(r'^define\((\w+),\[(.*)\]\)$')
+ f = open(version_m4)
+ for line in f:
+ line = line.rstrip()
+ m = re.match(r, line)
+ if m:
+ g = m.groups()
+ kv[g[0]] = g[1]
+ f.close()
+
+def parse_settings_in(kv, settings_in):
+ r = re.compile(r'^!define\s+(\w+)(?:\s+"?(.*?)"?)?$')
+ f = open(settings_in)
+ for line in f:
+ line = line.rstrip()
+ m = re.match(r, line)
+ if m:
+ g = m.groups()
+ kv[g[0]] = g[1] or ''
+ f.close()
+
+def dict_def(dict, newdefs):
+ ret = dict.copy()
+ ret.update(newdefs)
+ return ret
+
+def build_autodefs(kv, autodefs_in, autodefs_out):
+ preprocess(kv,
+ in_fn=autodefs_in,
+ out_fn=autodefs_out,
+ quote_begin='@',
+ quote_end='@',
+ head_comment='/* %s */\n\n' % autogen)
+
+def preprocess(kv, in_fn, out_fn, quote_begin=None, quote_end=None, if_prefix=None, head_comment=None):
+ def repfn(m):
+ var, = m.groups()
+ return kv.get(var, '')
+
+ re_macro = re_ifdef = None
+
+ if quote_begin and quote_end:
+ re_macro = re.compile(r'%s(\w+)%s' % (re.escape(quote_begin), re.escape(quote_end)))
+
+ if if_prefix:
+ re_ifdef = re.compile(r'^\s*%sifdef\s+(\w+)\b' % (re.escape(if_prefix),))
+ re_else = re.compile(r'^\s*%selse\b' % (re.escape(if_prefix),))
+ re_endif = re.compile(r'^\s*%sendif\b' % (re.escape(if_prefix),))
+
+ if_stack = []
+ fin = open(in_fn)
+ fout = open(out_fn, 'w')
+ if head_comment:
+ fout.write(head_comment)
+ for line in fin:
+ if re_ifdef:
+ m = re.match(re_ifdef, line)
+ if m:
+ var, = m.groups()
+ if_stack.append(int(var in kv))
+ continue
+ elif re.match(re_else, line):
+ if_stack[-1] ^= 1
+ continue
+ elif re.match(re_endif, line):
+ if_stack.pop()
+ continue
+ if not if_stack or min(if_stack):
+ if re_macro:
+ line = re.sub(re_macro, repfn, line)
+ fout.write(line)
+ assert not if_stack
+ fin.close()
+ fout.close()
+
+def print_key_values(kv):
+ for k, v in sorted(kv.items()):
+ print "%s%s%s" % (k, ' '*(32-len(k)), repr(v))
+
+def get_sources(makefile_am):
+ c = set()
+ h = set()
+ f = open(makefile_am)
+ state = False
+ for line in f:
+ line = line.rstrip()
+ if line == 'openvpn_SOURCES = \\':
+ state = True
+ elif not line:
+ state = False
+ elif state:
+ for sf in line.split():
+ if sf.endswith('.c'):
+ c.add(sf[:-2])
+ elif sf.endswith('.h'):
+ h.add(sf[:-2])
+ elif sf == '\\':
+ pass
+ else:
+ print >>sys.stderr, "Unrecognized filename:", sf
+ f.close()
+ return [ sorted(list(s)) for s in (c, h) ]
+
+def output_mak_list(title, srclist, ext):
+ ret = "%s =" % (title,)
+ for x in srclist:
+ ret += " \\\n\t%s.%s" % (x, ext)
+ ret += '\n\n'
+ return ret
+
+def make_headers_objs(makefile_am):
+ c, h = get_sources(makefile_am)
+ ret = output_mak_list('HEADERS', h, 'h')
+ ret += output_mak_list('OBJS', c, 'obj')
+ return ret
+
+def choose_arch(arch_name):
+ if arch_name == 'x64':
+ return (True,)
+ elif arch_name == 'x86':
+ return (False,)
+ elif arch_name == 'all':
+ return (True, False)
+ else:
+ raise ValueError("architecture ('%s') must be x86, x64, or all" % (arch_name,))
+
+def rm_rf(dir):
+ print "REMOVE", dir
+ shutil.rmtree(dir, ignore_errors=True)
+
+def mkdir(dir):
+ print "MKDIR", dir
+ os.mkdir(dir)
+
+def cp_a(src, dest, dest_is_dir=True):
+ if dest_is_dir:
+ dest = os.path.join(dest, os.path.basename(src))
+ print "COPY_DIR %s %s" % (src, dest)
+ shutil.copytree(src, dest)
+
+def cp(src, dest, dest_is_dir=True):
+ if dest_is_dir:
+ dest = os.path.join(dest, os.path.basename(src))
+ print "COPY %s %s" % (src, dest)
+ shutil.copyfile(src, dest)
+
+def rm_rf(path):
+ try:
+ shutil.rmtree(path, onerror=onerror)
+ except:
+ pass
+
+def onerror(func, path, exc_info):
+ """
+ Error handler for ``shutil.rmtree``.
+
+ If the error is due to an access error (read only file)
+ it attempts to add write permission and then retries.
+
+ If the error is for another reason it re-raises the error.
+
+ Usage : ``shutil.rmtree(path, onerror=onerror)``
+ """
+ if not os.access(path, os.W_OK):
+ # Is the error an access error ?
+ os.chmod(path, stat.S_IWUSR)
+ func(path)
+ else:
+ raise
+
+def mkdir_silent(dir):
+ try:
+ os.mkdir(dir)
+ except:
+ pass
+
+config = get_config()
diff --git a/win32.c b/win32.c
index 4de4139..7c9901e 100644
--- a/win32.c
+++ b/win32.c
@@ -5,7 +5,7 @@
* packet encryption, packet authentication, and
* packet compression.
*
- * Copyright (C) 2002-2009 OpenVPN Technologies, Inc. <sales@openvpn.net>
+ * Copyright (C) 2002-2010 OpenVPN Technologies, Inc. <sales@openvpn.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2
@@ -973,10 +973,8 @@ openvpn_execve (const struct argv *a, const struct env_set *es, const unsigned i
/* fill in STARTUPINFO struct */
GetStartupInfo(&start_info);
start_info.cb = sizeof(start_info);
- start_info.dwFlags = STARTF_USESTDHANDLES|STARTF_USESHOWWINDOW;
+ start_info.dwFlags = STARTF_USESHOWWINDOW;
start_info.wShowWindow = SW_HIDE;
- start_info.hStdInput = GetStdHandle(STD_INPUT_HANDLE);
- start_info.hStdOutput = start_info.hStdError = GetStdHandle(STD_OUTPUT_HANDLE);
if (CreateProcess (cmd, cl, NULL, NULL, FALSE, 0, env, NULL, &start_info, &proc_info))
{
@@ -1045,10 +1043,8 @@ fork_to_self (const char *cmdline)
/* fill in STARTUPINFO struct */
GetStartupInfo(&start_info);
start_info.cb = sizeof(start_info);
- start_info.dwFlags = STARTF_USESTDHANDLES|STARTF_USESHOWWINDOW;
+ start_info.dwFlags = STARTF_USESHOWWINDOW;
start_info.wShowWindow = SW_HIDE;
- start_info.hStdInput = GetStdHandle(STD_INPUT_HANDLE);
- start_info.hStdOutput = start_info.hStdError = GetStdHandle(STD_OUTPUT_HANDLE);
if (CreateProcess (self_exe, cl, NULL, NULL, FALSE, 0, NULL, NULL, &start_info, &proc_info))
{
diff --git a/win32.h b/win32.h
index a972a88..fcc3062 100644
--- a/win32.h
+++ b/win32.h
@@ -5,7 +5,7 @@
* packet encryption, packet authentication, and
* packet compression.
*
- * Copyright (C) 2002-2009 OpenVPN Technologies, Inc. <sales@openvpn.net>
+ * Copyright (C) 2002-2010 OpenVPN Technologies, Inc. <sales@openvpn.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2
@@ -33,6 +33,8 @@
#define DEFAULT_WIN_SYS_PATH "C:\\WINDOWS" /* --win-sys default value */
#define NETSH_PATH_SUFFIX "\\system32\\netsh.exe"
#define WIN_ROUTE_PATH_SUFFIX "\\system32\\route.exe"
+#define WIN_IPCONFIG_PATH_SUFFIX "\\system32\\ipconfig.exe"
+#define WIN_NET_PATH_SUFFIX "\\system32\\net.exe"
/*
* Win32-specific OpenVPN code, targetted at the mingw