]> git.ipfire.org Git - thirdparty/openvpn.git/log
thirdparty/openvpn.git
13 years agobuild: move out config.h include from syshead
Alon Bar-Lev [Wed, 29 Feb 2012 20:12:13 +0000 (22:12 +0200)] 
build: move out config.h include from syshead

Yet another step in reducing the syshead.h content.

Conditional compilation of sources needs to be based on
a minimum program prefix (config.h only).

Signed-off-by: Alon Bar-Lev <alon.barlev@gmail.com>
Acked-by: David Sommerseth <davids@redhat.com>
Signed-off-by: David Sommerseth <davids@redhat.com>
13 years agobuild: win-msvc: msbuild format
Alon Bar-Lev [Wed, 29 Feb 2012 20:12:12 +0000 (22:12 +0200)] 
build: win-msvc: msbuild format

Signed-off-by: Alon Bar-Lev <alon.barlev@gmail.com>
Acked-by: Samuli Seppänen <samuli@openvpn.net>
Signed-off-by: David Sommerseth <davids@redhat.com>
13 years agobuild: autoconf: update defaults for options
Alon Bar-Lev [Wed, 29 Feb 2012 20:12:11 +0000 (22:12 +0200)] 
build: autoconf: update defaults for options

Signed-off-by: Alon Bar-Lev <alon.barlev@gmail.com>
Acked-by: Samuli Seppänen <samuli@openvpn.net>
Signed-off-by: David Sommerseth <davids@redhat.com>
13 years agobuild: proper crypto detection and usage
Alon Bar-Lev [Wed, 29 Feb 2012 20:12:10 +0000 (22:12 +0200)] 
build: proper crypto detection and usage

Signed-off-by: Alon Bar-Lev <alon.barlev@gmail.com>
Acked-by: Adriaan de Jong <dejong@fox-it.com>
Signed-off-by: David Sommerseth <davids@redhat.com>
13 years agobuild: proper lzo detection and usage
Alon Bar-Lev [Wed, 29 Feb 2012 20:12:09 +0000 (22:12 +0200)] 
build: proper lzo detection and usage

Signed-off-by: Alon Bar-Lev <alon.barlev@gmail.com>
Acked-by: Adriaan de Jong <dejong@fox-it.com>
Acked-by: David Sommerseth <davids@redhat.com>
Signed-off-by: David Sommerseth <davids@redhat.com>
13 years agobuild: properly process lzo-stub
Alon Bar-Lev [Wed, 29 Feb 2012 20:12:08 +0000 (22:12 +0200)] 
build: properly process lzo-stub

Signed-off-by: Alon Bar-Lev <alon.barlev@gmail.com>
Acked-by: Samuli Seppänen <samuli@openvpn.net>
Signed-off-by: David Sommerseth <davids@redhat.com>
13 years agobuild: proper pkcs11-helper detection and usage
Alon Bar-Lev [Wed, 29 Feb 2012 20:12:07 +0000 (22:12 +0200)] 
build: proper pkcs11-helper detection and usage

Signed-off-by: Alon Bar-Lev <alon.barlev@gmail.com>
Acked-by: Samuli Seppänen <samuli@openvpn.net>
Signed-off-by: David Sommerseth <davids@redhat.com>
13 years agobuild: distribute pkg.m4
Alon Bar-Lev [Wed, 29 Feb 2012 20:12:06 +0000 (22:12 +0200)] 
build: distribute pkg.m4

RHEL and others do not install this globally, so we provide our own copy.

Signed-off-by: Alon Bar-Lev <alon.barlev@gmail.com>
Acked-by: Samuli Seppänen <samuli@openvpn.net>
Signed-off-by: David Sommerseth <davids@redhat.com>
13 years agobuild: proper selinux detection and usage
Alon Bar-Lev [Wed, 29 Feb 2012 20:12:05 +0000 (22:12 +0200)] 
build: proper selinux detection and usage

Signed-off-by: Alon Bar-Lev <alon.barlev@gmail.com>
Acked-by: Samuli Seppänen <samuli@openvpn.net>
Signed-off-by: David Sommerseth <davids@redhat.com>
13 years agobuild: autoconf: minor cleanups
Alon Bar-Lev [Wed, 29 Feb 2012 20:12:04 +0000 (22:12 +0200)] 
build: autoconf: minor cleanups

Signed-off-by: Alon Bar-Lev <alon.barlev@gmail.com>
Acked-by: Adriaan de Jong <dejong@fox-it.com>
Acked-by: David Sommerseth <davids@redhat.com>
Signed-off-by: David Sommerseth <davids@redhat.com>
13 years agobuild: properly detect and use socket libs
Alon Bar-Lev [Wed, 29 Feb 2012 20:12:03 +0000 (22:12 +0200)] 
build: properly detect and use socket libs

Signed-off-by: Alon Bar-Lev <alon.barlev@gmail.com>
Acked-by: David Sommerseth <davids@redhat.com>
Signed-off-by: David Sommerseth <davids@redhat.com>
13 years agobuild: libdl usage
Alon Bar-Lev [Wed, 29 Feb 2012 20:12:02 +0000 (22:12 +0200)] 
build: libdl usage

1. properly detect.
2. Link only required components.
3. No way we don't have LoadLibrary on Windows.
4. ENABLE_PLUGIN should be controlled in autoconf.

Signed-off-by: Alon Bar-Lev <alon.barlev@gmail.com>
Acked-by: Adriaan de Jong <dejong@fox-it.com>
Acked-by: David Sommerseth <davids@redhat.com>
Signed-off-by: David Sommerseth <davids@redhat.com>
13 years agobuild: autoconf: commands as environment
Alon Bar-Lev [Wed, 29 Feb 2012 20:12:01 +0000 (22:12 +0200)] 
build: autoconf: commands as environment

Signed-off-by: Alon Bar-Lev <alon.barlev@gmail.com>
Acked-by: Adriaan de Jong <dejong@fox-it.com>
Signed-off-by: David Sommerseth <davids@redhat.com>
13 years agobuild: add libtool + windows resources for executables
Alon Bar-Lev [Wed, 29 Feb 2012 20:12:00 +0000 (22:12 +0200)] 
build: add libtool + windows resources for executables

Signed-off-by: Alon Bar-Lev <alon.barlev@gmail.com>
Acked-by: David Sommerseth <davids@redhat.com>
Acked-by: Samuli Seppänen <samuli@openvpn.net>
Signed-off-by: David Sommerseth <davids@redhat.com>
13 years agobuild: standard directory layout
Alon Bar-Lev [Wed, 29 Feb 2012 20:11:59 +0000 (22:11 +0200)] 
build: standard directory layout

Suitable for mature project.

root   - administrative stuff
doc    - documents
src    - sources
tests  - tests
distro - distro specific files
sample - samples

SIDE EFFECT: many changes to rpm spec.

Signed-off-by: Alon Bar-Lev <alon.barlev@gmail.com>
Acked-by: Adriaan de Jong <dejong@fox-it.com>
Signed-off-by: David Sommerseth <davids@redhat.com>
13 years agobuild: remove awk and non-standard autoconf output processing
Alon Bar-Lev [Wed, 29 Feb 2012 20:11:58 +0000 (22:11 +0200)] 
build: remove awk and non-standard autoconf output processing

Replace with simpler environment solution.

Signed-off-by: Alon Bar-Lev <alon.barlev@gmail.com>
Acked-by: Samuli Seppänen <samuli@openvpn.net>
Signed-off-by: David Sommerseth <davids@redhat.com>
13 years agobuild: autoconf: remove OPENVPN_ADD_LIBS useless macro
Alon Bar-Lev [Wed, 29 Feb 2012 20:11:57 +0000 (22:11 +0200)] 
build: autoconf: remove OPENVPN_ADD_LIBS useless macro

Signed-off-by: Alon Bar-Lev <alon.barlev@gmail.com>
Acked-by: Samuli Seppänen <samuli@openvpn.net>
Signed-off-by: David Sommerseth <davids@redhat.com>
13 years agobuild: autotools: first pass of trivial autotools changes
Alon Bar-Lev [Wed, 29 Feb 2012 20:11:56 +0000 (22:11 +0200)] 
build: autotools: first pass of trivial autotools changes

Signed-off-by: Alon Bar-Lev <alon.barlev@gmail.com>
Acked-by: Adriaan de Jong <dejong@fox-it.com>
Acked-by: David Sommerseth <davids@redhat.com>
Signed-off-by: David Sommerseth <davids@redhat.com>
13 years agobuild: m4/ax_socklen_t.m4: cleanup
Alon Bar-Lev [Wed, 29 Feb 2012 20:11:55 +0000 (22:11 +0200)] 
build: m4/ax_socklen_t.m4: cleanup

Signed-off-by: Alon Bar-Lev <alon.barlev@gmail.com>
Acked-by: David Sommerseth <davids@redhat.com>
Signed-off-by: David Sommerseth <davids@redhat.com>
13 years agobuild: m4/ax_emptyarray.m4: cleanup
Alon Bar-Lev [Wed, 29 Feb 2012 20:11:54 +0000 (22:11 +0200)] 
build: m4/ax_emptyarray.m4: cleanup

Signed-off-by: Alon Bar-Lev <alon.barlev@gmail.com>
Acked-by: David Sommerseth <davids@redhat.com>
Signed-off-by: David Sommerseth <davids@redhat.com>
13 years agobuild: m4/ax_varargs.m4: cleanup
Alon Bar-Lev [Wed, 29 Feb 2012 20:11:53 +0000 (22:11 +0200)] 
build: m4/ax_varargs.m4: cleanup

Signed-off-by: Alon Bar-Lev <alon.barlev@gmail.com>
Acked-by: David Sommerseth <davids@redhat.com>
Signed-off-by: David Sommerseth <davids@redhat.com>
13 years agobuild: split acinclude.m4 into m4/*
Alon Bar-Lev [Wed, 29 Feb 2012 20:11:52 +0000 (22:11 +0200)] 
build: split acinclude.m4 into m4/*

ax_emptyarray.m4  ax_openvpn_lib.m4  ax_socklen_t.m4  ax_varargs.m4

Signed-off-by: Alon Bar-Lev <alon.barlev@gmail.com>
Acked-by: Adriaan de Jong <dejong@fox-it.com>
Signed-off-by: David Sommerseth <davids@redhat.com>
13 years agobuild: remove windows specific build system
Alon Bar-Lev [Wed, 29 Feb 2012 20:11:51 +0000 (22:11 +0200)] 
build: remove windows specific build system

It will be completely re-written in future

Signed-off-by: Alon Bar-Lev <alon.barlev@gmail.com>
Acked-by: Samuli Seppänen <samuli@openvpn.net>
Signed-off-by: David Sommerseth <davids@redhat.com>
13 years agocleanup: rename tap-windows function from win32 to win
Alon Bar-Lev [Wed, 29 Feb 2012 20:11:50 +0000 (22:11 +0200)] 
cleanup: rename tap-windows function from win32 to win

Signed-off-by: Alon Bar-Lev <alon.barlev@gmail.com>
Acked-by: Samuli Seppänen <samuli@openvpn.net>
Signed-off-by: David Sommerseth <davids@redhat.com>
13 years agoRemove tap-win32
Alon Bar-Lev [Wed, 29 Feb 2012 20:11:49 +0000 (22:11 +0200)] 
Remove tap-win32

Introduce tap-windows.h which is modified tap-win32/common.h.
Except of function rename, it is the same without the tap_id.
This file should be provided as part of tap-win32 MSI.
For now we hold a copy.

Signed-off-by: Alon Bar-Lev <alon.barlev@gmail.com>
Acked-by: Samuli Seppänen <samuli@openvpn.net>
Signed-off-by: David Sommerseth <davids@redhat.com>
13 years agoRemove easy-rsa
Alon Bar-Lev [Wed, 29 Feb 2012 20:11:48 +0000 (22:11 +0200)] 
Remove easy-rsa

Signed-off-by: Alon Bar-Lev <alon.barlev@gmail.com>
Acked-by: Samuli Seppänen <samuli@openvpn.net>
Signed-off-by: David Sommerseth <davids@redhat.com>
13 years agoRemove install-win32
Alon Bar-Lev [Wed, 29 Feb 2012 20:11:47 +0000 (22:11 +0200)] 
Remove install-win32

Signed-off-by: Alon Bar-Lev <alon.barlev@gmail.com>
Acked-by: Samuli Seppänen <samuli@openvpn.net>
Signed-off-by: David Sommerseth <davids@redhat.com>
13 years agobuild: we need the sample.ovpn in future
Alon Bar-Lev [Wed, 29 Feb 2012 20:11:46 +0000 (22:11 +0200)] 
build: we need the sample.ovpn in future

Signed-off-by: Alon Bar-Lev <alon.barlev@gmail.com>
Acked-by: David Sommerseth <davids@redhat.com>
Signed-off-by: David Sommerseth <davids@redhat.com>
13 years agobuild: plugins: properly use CC, CFLAGS and LDFLAGS
Alon Bar-Lev [Wed, 29 Feb 2012 20:11:45 +0000 (22:11 +0200)] 
build: plugins: properly use CC, CFLAGS and LDFLAGS

Signed-off-by: Alon Bar-Lev <alon.barlev@gmail.com>
Acked-by: Adriaan de Jong <dejong@fox-it.com>
Acked-by: David Sommerseth <davids@redhat.com>
Signed-off-by: David Sommerseth <davids@redhat.com>
13 years agobuild: rename plugin directory to plugins
Alon Bar-Lev [Wed, 29 Feb 2012 20:11:44 +0000 (22:11 +0200)] 
build: rename plugin directory to plugins

This to avoid conflit with plugin.c rules

Signed-off-by: Alon Bar-Lev <alon.barlev@gmail.com>
Acked-by: David Sommerseth <davids@redhat.com>
Signed-off-by: David Sommerseth <davids@redhat.com>
13 years agobuild: handle printf style format in mingw
Alon Bar-Lev [Wed, 29 Feb 2012 20:11:43 +0000 (22:11 +0200)] 
build: handle printf style format in mingw

Signed-off-by: Alon Bar-Lev <alon.barlev@gmail.com>
Acked-by: David Sommerseth <davids@redhat.com>
Signed-off-by: David Sommerseth <davids@redhat.com>
13 years agoUpdate .gitignore
Alon Bar-Lev [Wed, 29 Feb 2012 20:11:42 +0000 (22:11 +0200)] 
Update .gitignore

Signed-off-by: Alon Bar-Lev <alon.barlev@gmail.com>
Acked-by: Samuli Seppänen <samuli@openvpn.net>
Signed-off-by: David Sommerseth <davids@redhat.com>
13 years agobuild: correct place to alter WINVER is at build system
Alon Bar-Lev [Wed, 29 Feb 2012 20:11:41 +0000 (22:11 +0200)] 
build: correct place to alter WINVER is at build system

Signed-off-by: Alon Bar-Lev <alon.barlev@gmail.com>
Acked-by: Samuli Seppänen <samuli@openvpn.net>
Signed-off-by: David Sommerseth <davids@redhat.com>
13 years agofixup: init.c: add missing conditional for ENABLE_CLIENT_CR
Alon Bar-Lev [Wed, 29 Feb 2012 20:11:40 +0000 (22:11 +0200)] 
fixup: init.c: add missing conditional for ENABLE_CLIENT_CR

Signed-off-by: Alon Bar-Lev <alon.barlev@gmail.com>
Acked-by: Adriaan de Jong <dejong@fox-it.com>
Acked-by: David Sommerseth <davids@redhat.com>
Signed-off-by: David Sommerseth <davids@redhat.com>
13 years agocleanup: memcmp.c: remove unused source
Alon Bar-Lev [Wed, 29 Feb 2012 20:11:39 +0000 (22:11 +0200)] 
cleanup: memcmp.c: remove unused source

Signed-off-by: Alon Bar-Lev <alon.barlev@gmail.com>
Acked-by: Samuli Seppänen <samuli@openvpn.net>
Signed-off-by: David Sommerseth <davids@redhat.com>
13 years agocleanup: tun.c: fix incorrect option in message (ip-win32)
Alon Bar-Lev [Wed, 29 Feb 2012 20:11:38 +0000 (22:11 +0200)] 
cleanup: tun.c: fix incorrect option in message (ip-win32)

Signed-off-by: Alon Bar-Lev <alon.barlev@gmail.com>
Acked-by: Samuli Seppänen <samuli@openvpn.net>
Signed-off-by: David Sommerseth <davids@redhat.com>
13 years agocleanup: crypto_openssl.c: remove support for pre-openssl-0.9.6
Alon Bar-Lev [Wed, 29 Feb 2012 20:11:37 +0000 (22:11 +0200)] 
cleanup: crypto_openssl.c: remove support for pre-openssl-0.9.6

autoconf rejecting this anyway:
----
AC_MSG_CHECKING([that OpenSSL Library is at least version 0.9.6])
<snip>
AC_MSG_ERROR([OpenSSL crypto Library is too old.])
----

Signed-off-by: Alon Bar-Lev <alon.barlev@gmail.com>
Acked-by: Samuli Seppänen <samuli@openvpn.net>
Signed-off-by: David Sommerseth <davids@redhat.com>
13 years agocleanup: remove redundant ';'
Alon Bar-Lev [Wed, 29 Feb 2012 20:11:36 +0000 (22:11 +0200)] 
cleanup: remove redundant ';'

Signed-off-by: Alon Bar-Lev <alon.barlev@gmail.com>
Acked-by: Samuli Seppänen <samuli@openvpn.net>
Signed-off-by: David Sommerseth <davids@redhat.com>
13 years agocleanup: win32.c: wrong printf format
Alon Bar-Lev [Wed, 29 Feb 2012 20:11:35 +0000 (22:11 +0200)] 
cleanup: win32.c: wrong printf format

Signed-off-by: Alon Bar-Lev <alon.barlev@gmail.com>
Acked-by: Adriaan de Jong <dejong@fox-it.com>
Acked-by: David Sommerseth <davids@redhat.com>
Signed-off-by: David Sommerseth <davids@redhat.com>
13 years agocleanup: remove C++ warnings
Alon Bar-Lev [Wed, 29 Feb 2012 20:11:34 +0000 (22:11 +0200)] 
cleanup: remove C++ warnings

Signed-off-by: Alon Bar-Lev <alon.barlev@gmail.com>
Acked-by: Samuli Seppänen <samuli@openvpn.net>
Signed-off-by: David Sommerseth <davids@redhat.com>
13 years agocleanup: options.c: remove redundant include
Alon Bar-Lev [Wed, 29 Feb 2012 20:11:33 +0000 (22:11 +0200)] 
cleanup: options.c: remove redundant include

Signed-off-by: Alon Bar-Lev <alon.barlev@gmail.com>
Acked-by: Adriaan de Jong <dejong@fox-it.com>
Acked-by: Samuli Seppänen <samuli@openvpn.net>
Signed-off-by: David Sommerseth <davids@redhat.com>
13 years agopackage: rpm: strip should be handled by package management
Alon Bar-Lev [Wed, 29 Feb 2012 20:11:32 +0000 (22:11 +0200)] 
package: rpm: strip should be handled by package management

Signed-off-by: Alon Bar-Lev <alon.barlev@gmail.com>
Acked-by: Samuli Seppänen <samuli@openvpn.net>
Signed-off-by: David Sommerseth <davids@redhat.com>
13 years agobuild: version should not contain '-'
Alon Bar-Lev [Wed, 29 Feb 2012 20:11:31 +0000 (22:11 +0200)] 
build: version should not contain '-'

Signed-off-by: Alon Bar-Lev <alon.barlev@gmail.com>
Acked-by: David Sommerseth <davids@redhat.com>
Signed-off-by: David Sommerseth <davids@redhat.com>
13 years agofix warnings in event.c when building for win32-64
Heiko Hund [Thu, 18 Aug 2011 12:12:11 +0000 (12:12 +0000)] 
fix warnings in event.c when building for win32-64

When compiling for 64-bit Windows gcc warns about

  "cast from pointer to integer of different size"

on two occasions in file event.c, due to invalid casting.
This patch removes the type casts and uses the correct
format specifier instead.

Signed-off-by: Heiko Hund <heiko.hund@sophos.com>
Acked-by: James Yonan <james@openvpn.net>
URL: http://article.gmane.org/gmane.network.openvpn.devel/4979
Signed-off-by: David Sommerseth <davids@redhat.com>
13 years agoremove wrapper code for Windows CryptoAPI function
Heiko Hund [Wed, 17 Aug 2011 15:53:01 +0000 (15:53 +0000)] 
remove wrapper code for Windows CryptoAPI function

The CryptoAPI function CryptAcquireCertificatePrivateKey() was previously
unsupported in MinGW. With recent w32api headers it's now defined, mostly.
Since the code used to load the CryptoAPI DLL is prone to a DLL hijacking
attack [1], it's now a good time to get rid of wrapper completely.

Just a few macros left that may still be undefined on some
systems using the original MinGW headers.

[1] http://isc.sans.edu/diary.html?storyid=9445

Signed-off-by: Heiko Hund <heiko.hund@sophos.com>
Acked-by: James Yonan <james@openvpn.net>
URL: http://article.gmane.org/gmane.network.openvpn.devel/4979
Signed-off-by: David Sommerseth <davids@redhat.com>
13 years agoPreparing OpenVPN 2.3-alpha1 release v2.3-alpha1
David Sommerseth [Tue, 21 Feb 2012 10:12:42 +0000 (11:12 +0100)] 
Preparing OpenVPN 2.3-alpha1 release

Signed-off-by: David Sommerseth <davids@redhat.com>
13 years agoRevamp check_file_access() checks in stdin scenarios
David Sommerseth [Mon, 20 Feb 2012 09:31:54 +0000 (10:31 +0100)] 
Revamp check_file_access() checks in stdin scenarios

It was discovered that --management also can take stdin as argument
instead of a file.  Enabled this by revamping the check_file_access()
flags by adding CHKACC_ACPTSTDIN.  Setting this flag will then consider
filenames as 'stdin' as always present.

The other place where 'stdin' was accepted is also modified to use this
flag instead.

Signed-off-by: David Sommerseth <davids@redhat.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
13 years agodefine access mode flag X_OK as 0 on Windows
Heiko Hund [Sat, 18 Feb 2012 19:44:12 +0000 (20:44 +0100)] 
define access mode flag X_OK as 0 on Windows

The _access and _waccess functions in Windows don't know about
X_OK (1). If you pass an uneven mode flag the C runtime's default
invalid parameter handler ends execution of openvpn.

Signed-off-by: Heiko Hund <heiko.hund@sophos.com>
Acked-by: David Sommerseth <davids@redhat.com>
Signed-off-by: David Sommerseth <davids@redhat.com>
13 years agoMakefile.am was missing ssl_common.h
David Sommerseth [Fri, 17 Feb 2012 11:29:27 +0000 (12:29 +0100)] 
Makefile.am was missing ssl_common.h

In commit 9a160b796e1a40f9635231e5533ce40d46dba25f ssl_common.h
was introduced, but never listed as a source file in Makefile.am

Signed-off-by: David Sommerseth <davids@redhat.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
13 years agoMakefile.am referenced a now non-existing config-win32.h
David Sommerseth [Fri, 17 Feb 2012 11:09:51 +0000 (12:09 +0100)] 
Makefile.am referenced a now non-existing config-win32.h

This file was moved to win/config.h.in and is the template used
by the Python build tools in win/.  This happened in
commit 4b312378e9e7084a0699ca6d4b895bdadb7540db

For all other autotools based environments, ./configure will take
care of creating the proper config.h

Signed-off-by: David Sommerseth <davids@redhat.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
13 years agomove variable declaration to top of function
Heiko Hund [Fri, 17 Feb 2012 08:39:35 +0000 (09:39 +0100)] 
move variable declaration to top of function

MSVC chokes on this as it's not according to C89.

Signed-off-by: Heiko Hund <heiko.hund@sophos.com>
Acked-by: David Sommerseth <davids@redhat.com>
Signed-off-by: David Sommerseth <davids@redhat.com>
13 years agomake MSVC link against shell32 as well
Heiko Hund [Thu, 16 Feb 2012 17:30:41 +0000 (18:30 +0100)] 
make MSVC link against shell32 as well

Windows API CommandLineToArgvW(), introduced in Windows unicode path
commit 71bbbd76c62630c88441237d72fe5b61f0b45b2a, is defined therein.

Signed-off-by: Heiko Hund <heiko.hund@sophos.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Signed-off-by: David Sommerseth <davids@redhat.com>
13 years agouse the underscore version of stat on Windows
Heiko Hund [Thu, 16 Feb 2012 17:30:40 +0000 (18:30 +0100)] 
use the underscore version of stat on Windows

MSVC does not know wstat(). Instead _wstat() must be used here.
Unfortunately _wstat() takes a 'struct _stat'. A type 'stat_t' is
introduced to handle this situation in a portable way.

[v2: Use openvpn_stat_t instead of stat_t (David Sommerseth)]

Signed-off-by: Heiko Hund <heiko.hund@sophos.com>
Signed-off-by: David Sommerseth <davids@redhat.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
13 years agodo not use mode_t on Windows
Heiko Hund [Thu, 16 Feb 2012 17:30:39 +0000 (18:30 +0100)] 
do not use mode_t on Windows

The MSVC headers do not define mode_t. open() uses an int for
the permissions instead. Fixes building with the MSVC based
buildsystem.

Signed-off-by: Heiko Hund <heiko.hund@sophos.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Signed-off-by: David Sommerseth <davids@redhat.com>
13 years agoreplace check for TARGET_WIN32 with WIN32
Heiko Hund [Thu, 16 Feb 2012 17:30:38 +0000 (18:30 +0100)] 
replace check for TARGET_WIN32 with WIN32

Use of TARGET_WIN32 breaks MSVC builds as it is only defined
for mingw builds done with the autotools buildsystem.

Signed-off-by: Heiko Hund <heiko.hund@sophos.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Signed-off-by: David Sommerseth <davids@redhat.com>
13 years agoFixed wrong return type of cipher_kt_mode
Frank de Brabander [Thu, 16 Feb 2012 12:51:04 +0000 (13:51 +0100)] 
Fixed wrong return type of cipher_kt_mode

The cipher_kt_mode uses bool as return type, this should be int. On
some platforms like OS X, any returned value larger than one will
be converted to 1.

Signed-off-by: Frank de Brabander <brabander@fox-it.com>
Acked-by: Adriaan de Jong <dejong@fox-it.com>
Signed-off-by: David Sommerseth <davids@redhat.com>
13 years agoConnection entry {tun,link}_mtu_defined not set correctly
David Sommerseth [Tue, 14 Feb 2012 10:45:27 +0000 (11:45 +0100)] 
Connection entry {tun,link}_mtu_defined not set correctly

Commit 76809cae0eae07817160b423d3f9551df1a1d68e enabled setting MTU
variables inside <connection> blocks.  But in that process, the
tun_mtu_defined and link_mtu_defined was not set as it should.

By moving this out of the options_postprocess_mutate_invariant()
function and into options_postprocess_mutate_ce(), these
{tun,link}_mtu_defined variables are set correctly in each
connection entry.

Signed-off-by: David Sommerseth <davids@redhat.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
13 years agoMade some options connection-entry specific
Jan Just Keijser [Tue, 7 Feb 2012 15:29:47 +0000 (16:29 +0100)] 
Made some options connection-entry specific

The following options may now be used in a connection block:

 fragment
 mssfix
 tun-mtu
 tun-mtu-extra
 link-mtu
 mtu_discover_type
 explicit-exit-notification

In order to support stuff like
<connection>
  remote host
  proto udp
  fragment
  explicit-exit-notification 3
</connection>
<connection>
  remote host
  proto tcp
</connection>

Signed-off-by: Jan Just Keijser <janjust@nikhef.nl>
Acked-by: David Sommerseth <davids@redhat.com>
Signed-off-by: David Sommerseth <davids@redhat.com>
13 years agoFix compile issues with status.c
David Sommerseth [Mon, 13 Feb 2012 16:29:52 +0000 (17:29 +0100)] 
Fix compile issues with status.c

Commit 71bbbd76c62630c88441237d72fe5b61f0b45b2a moved over from
calling open() directly to go via the openvpn_open().  It was not
detected that status.c had to include misc.h too.

Signed-off-by: David Sommerseth <davids@redhat.com>
Acked-by: Heiko Hund <heiko.hund@sophos.com>
13 years agoRemove --show-gateway if debug info is not enabled (--disable-debug)
David Sommerseth [Mon, 13 Feb 2012 15:03:46 +0000 (16:03 +0100)] 
Remove --show-gateway if debug info is not enabled (--disable-debug)

The --show-gateway feature depends on functions only being enabled when
--disable-debug is _not_ used.  As this I consider --show-gateway more
a handy function for debugging, removing this feature when --disable-debug
is used seems like the proper approach.

Signed-off-by: David Sommerseth <davids@redhat.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
13 years agoFix compile issues when plug-ins are disabled.
David Sommerseth [Mon, 13 Feb 2012 14:52:00 +0000 (15:52 +0100)] 
Fix compile issues when plug-ins are disabled.

Commit 1876ccd012e9e2ca6f8e1cd9e7e9bb4bf24ccecb modified
plugin_call() and introduced plugin_call_ssl().  But the similar
approach was missing for situations without plug-ins.

Solution: Rename plugin_call() in the #else !ENABLE_PLUGIN
section to plugin_call_ssl().  Then move the plugin_ssl() function
inside the #ifdef ENABLE_PLUGIN section outside the #ifdef, making
it available for builds with and without plug-ins enabled.

Signed-off-by: David Sommerseth <davids@redhat.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
13 years agohandle Windows unicode paths
Heiko Hund [Fri, 10 Feb 2012 14:13:42 +0000 (15:13 +0100)] 
handle Windows unicode paths

Openvpn for Windows is not compiled as a Unicode binary and thus cannot
handle paths which contain non-ASCII characters using the argv vector.
Characters that are not present in the system codepage are simply replaced
with a question mark, e.g. if started as 'openvpn --config домой.ovpn'
the file '?????.ovpn' is tried to be opened as configuration.

The same applies to paths in config files which need to be UTF-8
encoded if they contain non ASCII characters. The option line
'key лев.pem' will lead to openvpn trying to open 'лев.pem' on a
system with codepage 1252.

This patch makes openvpn read the command line in UCS-2 and convert
it to UTF-8 internally. Windows stores names in the filesystem in UCS-2.
When using a paths openvpn converts it from UTF-8 to UCS-2 and uses the
wide character Windows API function.

Signed-off-by: Heiko Hund <heiko.hund@sophos.com>
Acked-by: David Sommerseth <davids@redhat.com>
Signed-off-by: David Sommerseth <davids@redhat.com>
13 years agoThe code blocks enabled by ENABLE_CLIENT_CR depends on management
Igor Novgorodov [Sun, 12 Feb 2012 18:40:02 +0000 (22:40 +0400)] 
The code blocks enabled by ENABLE_CLIENT_CR depends on management

If the management interface is not enabled, it makes no sense in
including the ENABLE_CLIENT_CR #ifdef blocks.  This will also in
some configurations cause build issues if these blocks are enabled.

Signed-off-by: Igor Novgorodov <igor@novg.net>
Acked-by: David Sommerseth <davids@redhat.com>
Signed-off-by: David Sommerseth <davids@redhat.com>
13 years agoautoconf fixes for building on OSX
Byron Ellacott [Mon, 6 Feb 2012 18:57:00 +0000 (19:57 +0100)] 
autoconf fixes for building on OSX

[DS: a few whitespace fixes was added as well during the merge]

Signed-off-by: Byron Ellacott <bje@apnic.net>
Acked-by: Gilles Espinasse <g.esp@free.fr>
Signed-off-by: David Sommerseth <davids@redhat.com>
13 years agoFix assert() situations where gc_malloc() is called without a gc_arena object
David Sommerseth [Sun, 5 Feb 2012 23:30:47 +0000 (00:30 +0100)] 
Fix assert() situations where gc_malloc() is called without a gc_arena object

In commit bee92b479414d12035b0422f81ac5fcfe14fa645 the gc_malloc() was hardened
to always require a gc_arena object for garbage collection.  Some places in the
code expected the old behaviour of a normal malloc() in these cases, that is a
memory allocation without garbage collection.

This old behaviour is partly restored by allowing string_alloc() to do a non-gc
based allocation if no gc_arena object is available.  In addition some other
places string_alloc() will now be called with a gc_arena pointer where such an
object is available.

The alloc_buf() function has also been refactored to not use gc_malloc() at
all.

v2: - removes a memleak when --ifconfig-ipv6 is used several times
    - makes string_alloc() behave properly if DMALLOC is enabled

Signed-off-by: David Sommerseth <davids@redhat.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
13 years agoPlatform cleanup for OpenBSD
Gert Doering [Sun, 5 Feb 2012 12:35:03 +0000 (13:35 +0100)] 
Platform cleanup for OpenBSD

Turn around initialization order (IFCONFIG_AFTER_TUN_OPEN) to make it
"the same as all other platforms besides Windows" (tun.h).

Remove "ifconfig destroy / ifconfig create" from open_tun() and change
to generic "create tun device by opening /dev/tunN" approach, thus
cleaning up the IFCONFIG_BEFORE_TUN_OPEN bit.

Add "-link0" for ifconfig calls in tun mode, to make sure that even if
we happen to re-use a not-cleaned-up tun interface in tap mode, it will
then be setup correctly (-link0 -> tun, link0 -> tap).

Add correct ifconfig calls for "topology subnet".

On tunnel close, only call "ifconfig destroy" if it was a tap interface
(tun + link0), because those do not auto-disappear (OpenBSD bug?)

Get rid of READV/WRITEV #ifdef's - as per the man page, these calls have
been added to 4.2BSD, and there never was an OpenBSD version without.

Tested on OpenBSD 4.9 with tun+tap, ipv4+ipv6, topology net30+subnet

Signed-off-by: Gert Doering <gert@greenie.muc.de>
Acked-by: David Sommerseth <davids@redhat.com>
Signed-off-by: David Sommerseth <davids@redhat.com>
13 years agoDocumented --push-peer-info option
Robert Fischer [Sat, 10 Dec 2011 14:51:30 +0000 (15:51 +0100)] 
Documented --push-peer-info option

Signed-off-by: Robert Fischer <ml-openvpn@trispace.org>
Acked-by: David Sommerseth <davids@redhat.com>
Signed-off-by: David Sommerseth <davids@redhat.com>
13 years agoDocumented --errors-to-stderr option
Robert Fischer [Sat, 10 Dec 2011 13:56:40 +0000 (14:56 +0100)] 
Documented --errors-to-stderr option

Signed-off-by: Robert Fischer <ml-openvpn@trispace.org>
Acked-by: David Sommerseth <davids@redhat.com>
Signed-off-by: David Sommerseth <davids@redhat.com>
13 years agoset Windows environment variables as UCS-2
Heiko Hund [Wed, 7 Dec 2011 17:59:21 +0000 (18:59 +0100)] 
set Windows environment variables as UCS-2

Windows uses 16 bit wide characters to represent Unicode in the
process environment. Convert UTF-8 to UCS-2 and use the wide
character API to set environment variables.

Signed-off-by: Heiko Hund <heiko.hund@sophos.com>
13 years agoDocument IPv6-related environment variables.
Gert Doering [Sat, 4 Feb 2012 17:18:45 +0000 (18:18 +0100)] 
Document IPv6-related environment variables.

(ifconfig_ipv6_local, ifconfig_ipv6_netbits, ifconfig_ipv6_remote,
route_ipv6_network_{n}, route_ipv6_gateway_{n})

Signed-off-by: Gert Doering <gert@greenie.muc.de>
Acked-by: David Sommerseth <davids@redhat.com>
Signed-off-by: David Sommerseth <davids@redhat.com>
13 years agoRemoved support for calling gc_malloc with a NULL gc_arena struct
Adriaan de Jong [Sun, 5 Feb 2012 11:51:25 +0000 (12:51 +0100)] 
Removed support for calling gc_malloc with a NULL gc_arena struct

Signed-off-by: Adriaan de Jong <dejong@fox-it.com>
Acked-by: David Sommerseth <davids@redhat.com>
Signed-off-by: David Sommerseth <davids@redhat.com>
13 years agoMoved out of memory prototype to error.h, as the definition is in error.c
Adriaan de Jong [Sun, 5 Feb 2012 11:51:24 +0000 (12:51 +0100)] 
Moved out of memory prototype to error.h, as the definition is in error.c

Signed-off-by: Adriaan de Jong <dejong@fox-it.com>
Acked-by: David Sommerseth <davids@redhat.com>
Signed-off-by: David Sommerseth <davids@redhat.com>
13 years agoMinor code cleanup: cleaned up error handling in verify_cert.
Adriaan de Jong [Sat, 4 Feb 2012 13:16:13 +0000 (14:16 +0100)] 
Minor code cleanup: cleaned up error handling in verify_cert.

Removed done label and cleaned up return values.

Signed-off-by: Adriaan de Jong <dejong@fox-it.com>
Acked-by: David Sommerseth <davids@redhat.com>
Signed-off-by: David Sommerseth <davids@redhat.com>
13 years agoEnhance the error handling in _openssl_get_subject()
David Sommerseth [Sat, 4 Feb 2012 13:51:54 +0000 (14:51 +0100)] 
Enhance the error handling in _openssl_get_subject()

Avoid an extra goto label and make the code a bit simpler.

Signed-off-by: David Sommerseth <davids@redhat.com>
Acked-by: Heiko Hund <heiko.hund@sophos.com>
Acked-by: Adriaan de Jong <dejong@fox-it.com>
13 years agoUTF-8 X.509 distinguished names
Heiko Hund [Sat, 4 Feb 2012 12:56:24 +0000 (12:56 +0000)] 
UTF-8 X.509 distinguished names

The UTF-8 support that came with commit 2627335 does allow international
usernames and passwords. This patch introduces UTF-8 support for X.509 DNs.
Additionally, instead of using the legacy openssl format, DNs are now
displayed in RFC 2253 format; "/C=ru/L=\xD0\x9C\xD0\xBE\xD1\x81\xD0\xBA\xD0
\xB2\xD0\xB0/O=\xD0\x9A\xD1\x80\xD0\xB5\xD0\xBC\xD0\xBB\xD1\x8C/CN=kreml.ru"
becomes "C=ru, L=Москва, O=Кремль, CN=kreml.ru".

Since the specific character classes for X.509 names are removed, the
"no-name-remapping" configuration option has no use anymore and is removed
as well.

Signed-off-by: Heiko Hund <heiko.hund@sophos.com>
Acked-by: Adriaan de Jong <dejong@fox-it.com>
Acked-by: David Sommerseth <davids@redhat.com>
Signed-off-by: David Sommerseth <davids@redhat.com>
13 years agoFix RUN_SUDO functionality for t_client.sh
Gert Doering [Fri, 3 Feb 2012 17:18:07 +0000 (19:18 +0200)] 
Fix RUN_SUDO functionality for t_client.sh

Commit 9c6ee9d1ecd85535c was incomplete - while it will run openvpn with
sudo, it will not use sudo for the "kill" commands needed to test whether
the background process is still there, and for actually stopping openvpn
after the test has finished.

Signed-off-by: Gert Doering <gert@greenie.muc.de>
Acked-by: David Sommerseth <davids@redhat.com>
Signed-off-by: David Sommerseth <davids@redhat.com>
13 years agoImplement IPv6 interface config with non-/64 prefix lengths.
Gert Doering [Fri, 3 Feb 2012 16:11:03 +0000 (17:11 +0100)] 
Implement IPv6 interface config with non-/64 prefix lengths.

Add "ifconfig_ipv6_netbits_parm" parameter to init_tun(), use that to
initialize tt->netbits_ipv6 (previously: always /64).  Actual interface
setup code already used tt->netbits_ipv6, so no changes needed there.

Remove restrictions on "/netbits" value for --server-ipv6 config option
(can now be /64.../112, previously had to be exactly /64).  Supporting
even smaller networks could cause problems with ipv6-pool handling and
are only allowed for explicit "ifconfig-ipv6", not for "server-ipv6".

Add /netbits to pushed "ifconfig-ipv6" values on server side (client
side always accepted this, but ignored it so far, so this does not
break compatibility).

Tested on Linux/ifconfig, Linux/iproute2 and FreeBSD 7.4

Signed-off-by: Gert Doering <gert@greenie.muc.de>
Acked-by: David Sommerseth <davids@redhat.com>
Signed-off-by: David Sommerseth <davids@redhat.com>
13 years agoWindows UTF-8 input/output
Heiko Hund [Wed, 23 Nov 2011 18:08:34 +0000 (19:08 +0100)] 
Windows UTF-8 input/output

This patch makes openvpn read unicode from the console and convert the input
to UTF-8. And then display UTF-8 output to the console correctly.

Signed-off-by: Heiko Hund <heiko.hund@sophos.com>
Acked-by: David Sommerseth <davids@redhat.com>
Signed-off-by: David Sommerseth <davids@redhat.com>
13 years agoAdded support for "on-link" routes on Linux client
James Yonan [Mon, 26 Dec 2011 00:18:50 +0000 (00:18 +0000)] 
Added support for "on-link" routes on Linux client

These are routes where the gateway is specified as an interface rather
than an address. This allows redirect-gateway to work on Linux clients
whose connection to the internet is via a point-to-point link such as
PPP.

Note that at the moment, this capability is incompatible with
the "redirect-gateway block-local" directive -- this is because
the block-local directive blocks all traffic from the local LAN
except for the local and gateway addresses.  Since a PPP link
is essentially a subnet of two addresses, local and remote (i.e.
gateway), the set of addresses that would be blocked by block-local
is empty.  Therefore, the "redirect-gateway block-local" directive
will be ignored on PPP links.

To view the OpenVPN client's current determination of the default
gateway, use this command:

  ./openvpn --show-gateway

git-svn-id: http://svn.openvpn.net/projects/openvpn/branches/BETA21/openvpn@7794 e7ae566f-a301-0410-adde-c780ea21d3b5
Signed-off-by: James Yonan <james@openvpn.net>
Signed-off-by: David Sommerseth <davids@redhat.com>
13 years agoAdd --route-pre-down/OPENVPN_PLUGIN_ROUTE_PREDOWN script/plug-in hook
David Sommerseth [Tue, 24 Jan 2012 11:32:46 +0000 (12:32 +0100)] 
Add --route-pre-down/OPENVPN_PLUGIN_ROUTE_PREDOWN script/plug-in hook

This patchs adds a script/plug-in hook which is called right before the
network routes are taken down.  This gives external processes a
possibility to tear down communication over the VPN before the VPN
disappears.

One use case can be to mount a networked file system over the VPN via
--route-up.  And then to unmount this file system via --route-pre-down

Signed-off-by: David Sommerseth <davids@redhat.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
13 years agoPlatform cleanup for FreeBSD
Gert Doering [Sun, 22 Jan 2012 21:21:22 +0000 (23:21 +0200)] 
Platform cleanup for FreeBSD

- cleanup TUN/TAP devices at program end ("ifconfig ... destroy")
- make TUN device setup for "topology subnet" work together with IPv6
  (setup correct netmask and route, but do not use IFF_BROADCAST)

There's one catch for FreeBSD 8.2 if you use pf(4): it will block IPv6
fragments by default, so the standard t_client.sh test sets fail unless
you specifically add "pass in on tun1 fragment" rules - but there's
nothing OpenVPN can do about it.

Tested with IPv4 and IPv6 on 7.4-RELEASE/amd64 and 8.2-RELEASE/amd64

Signed-off-by: Gert Doering <gert@greenie.muc.de>
URL: http://thread.gmane.org/gmane.network.openvpn.devel/5303
Acked-by: David Sommerseth <davids@redhat.com>
Signed-off-by: David Sommerseth <davids@redhat.com>
13 years agoadd "print test titles" and "use sudo" functionality to t_client.rc
Gert Doering [Sun, 22 Jan 2012 21:37:25 +0000 (22:37 +0100)] 
add "print test titles" and "use sudo" functionality to t_client.rc

Signed-off-by: Gert Doering <gert@greenie.muc.de>
Acked-by: David Sommerseth <davids@redhat.com>
Signed-off-by: David Sommerseth <davids@redhat.com>
13 years agoDon't check for file presence on inline files
David Sommerseth [Mon, 16 Jan 2012 11:00:33 +0000 (12:00 +0100)] 
Don't check for file presence on inline files

The configuration file supports inline files for --ca, --cert, --dh,
--extra-certs, --key, --pkcs12, --secret and --tls-auth.  When this
is used, the filename is set to [[INLINE]] (defined by INLINE_FILE_TAG).

If the filename is set to INLINE_FILE_TAG for these options, don't
call check_file_access().

[v2 Simplify the code, using a flag to check_file_access()]

Signed-off-by: David Sommerseth <davids@redhat.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
13 years agoFix pool logging when IPv6 is not enabled
David Sommerseth [Sat, 14 Jan 2012 11:34:59 +0000 (12:34 +0100)] 
Fix pool logging when IPv6 is not enabled

If IPv6 tunnelling is not enabled, a bogus IPv6 address would be
printed in the log, like this:

  MULTI_sva: pool returned IPv4=10.8.0.4, IPv6=2180:8:2100:0:d4b4:f11d:18bf:2f00

It turns out that the remote_ipv6 buffer was not cleared.  Added
an extra check to also replace a "IPv6=::" log message with
information that the IPv6 feature is disabled in these cases.

Signed-off-by: David Sommerseth <dazo@users.sourceforge.net>
Acked-by: Gert Doering <gert@greenie.muc.de>
13 years agoautotools ./configure don't like compat.h
David Sommerseth [Wed, 11 Jan 2012 13:52:21 +0000 (14:52 +0100)] 
autotools ./configure don't like compat.h

The compat.h include file cannot be loaded when ./configure runs,
as many of the HAVE_* declarations are not set.  This makes test
compilations when looking for features fail.

As ./configure will load syshead.h, it pulls in compat.h this way.
Looking more carefully at syshead.h, there's a #ifndef PACKAGE_NAME
check if config.h should be included.  This looks like a check if
syshead.h is loaded via ./configure or if it is a more normal
compilation.  Moving the compat.h inclusion into this #ifndef block.

Signed-off-by: David Sommerseth <davids@redhat.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
13 years agoFix compilation errors on Linux platforms without SO_MARK
David Sommerseth [Mon, 21 Nov 2011 15:17:44 +0000 (16:17 +0100)] 
Fix compilation errors on Linux platforms without SO_MARK

When trying to compile OpenVPN on RHEL5/CentOS5, it would fail
due to missing declaration of SO_MARK.  SO_MARK is a feature which
first arrived in 2.6.26, and was never backported to RHEL5's 2.6.18
kernel base.

This patch adds a check at configure time, to see if SO_MARK is
available or not.

Signed-off-by: David Sommerseth <davids@redhat.com>
13 years agoNew Windows build fixes
David Sommerseth [Wed, 11 Jan 2012 14:30:28 +0000 (15:30 +0100)] 
New Windows build fixes

compat.c: In basename() a typo had gone undetected through the review process,
and also that the declaration was a little bit different from what's defined in
compat.h

misc.c: commit 9449e6a9eba30c9ed054f57d630a88c9f087080f adds #include <unistd.h>.
This breaks building on Windows.  As unistd.h is already loaded via syshead.h on
systems where unistd.h exists, we don't need it here.

Signed-off-by: David Sommerseth <davids@redhat.com>
Tested-by: Samuli Seppänen <samuli@openvpn.net>
13 years agoEnable access() when building in Visual Studio
David Sommerseth [Thu, 8 Dec 2011 11:38:57 +0000 (12:38 +0100)] 
Enable access() when building in Visual Studio

Visual Studio does not enable certiain standard Unix functions,
such as access().  By defining _CRT_NONSTDC_NO_WARNINGS and
_CRT_SECURE_NO_WARNINGS, these functions are enabled.

This patch also adds a ./configure check for access() as well,
in case this needs to be implemented on other platforms lacking
this feature.  Which is why HAVE_ACCESS is defined in win/config.h.in

Thanks to Alon Bar-Lev for helping solving this.

Signed-off-by: David Sommerseth <davids@redhat.com>
Acked-by: Alon Bar-Lev <alon.barlev@gmail.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
URL: http://thread.gmane.org/gmane.network.openvpn.devel/5179/focus=5200

13 years agoMove away from openvpn_basename() over to platform provided basename()
David Sommerseth [Wed, 7 Dec 2011 23:40:45 +0000 (00:40 +0100)] 
Move away from openvpn_basename() over to platform provided basename()

This kicks out the openvpn_basename() function from misc.[ch] and puts
glibc equivalents into compat.[ch].  This is to provide the same
functionality on platforms not having a native basename() function
available.

In addition this patch adds dirname() which commit 0f2bc0dd92f43c91e
depends.  Without dirname(), openvpn won't build in Visual Studio.

v2: Move all functions from compat.h to compat.c
v3: Use glibc versions of basename() and dirname() instead

Signed-off-by: David Sommerseth <davids@redhat.com>
Acked-by: Alon Bar-Lev <alon.barlev@gmail.com>
URL: http://thread.gmane.org/gmane.network.openvpn.devel/5178/focus=5215

13 years agoFix a couple of issues in openvpn_execve()
David Sommerseth [Mon, 9 Jan 2012 17:07:28 +0000 (18:07 +0100)] 
Fix a couple of issues in openvpn_execve()

If openvpn_execve() is not able to fork(), it would not make any noise
about it.  So this patch adds a log notification if this happens.

In addition, if openvpn_execve() is called with an empty argv array,
it should exit instantly.  This is not expected to happen at all and
might indicate a much more serious issue (or programming error)
somewhere else in the code.  Thus, abort execution to get these issues
flushed out as quickly as possible.

Signed-off-by: David Sommerseth <davids@redhat.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
13 years agoAdd support to forward console query to systemd
Frederic Crozat [Mon, 31 Oct 2011 14:51:53 +0000 (15:51 +0100)] 
Add support to forward console query to systemd

Systemd requires console query to be forwarded using its own
tool.

Signed-off-by: Frederic Crozat <fcrozat@suse.com>
Acked-by: David Sommerseth <davids@redhat.com>
URL: http://thread.gmane.org/gmane.network.openvpn.devel/5073/focus=5277
Signed-off-by: David Sommerseth <davids@redhat.com>
13 years agoFix list-overrun checks in copy_route_[ipv6_]option_list()
Gert Doering [Fri, 30 Dec 2011 20:42:13 +0000 (21:42 +0100)] 
Fix list-overrun checks in copy_route_[ipv6_]option_list()

The old code checks how many items are in use(!) in the source
list, but then copies the full list over the destination memory
arena.  Check the source list *capacity*.

Signed-off-by: Gert Doering <gert@greenie.muc.de>
Acked-by: David Sommerseth <davids@redhat.com>
Signed-off-by: David Sommerseth <davids@redhat.com>
13 years agoFix build-up of duplicate IPv6 routes on reconnect.
Gert Doering [Fri, 30 Dec 2011 20:08:49 +0000 (21:08 +0100)] 
Fix build-up of duplicate IPv6 routes on reconnect.

options.c: extend pre_pull_save() and pre_pull_restore() to
   save/restore options->routes_ipv6 as well
options.h: add routes_ipv6 to "struct options_pre_pull"
route.h, route.c: add clone_route_ipv6_option_list() and
   copy_route_ipv6_option_list() helper functions

Signed-off-by: Gert Doering <gert@greenie.muc.de>
Acked-by: David Sommerseth <davids@redhat.com>
Signed-off-by: David Sommerseth <davids@redhat.com>
13 years agoFix compiling with --disable-crypto and/or --disable-ssl
David Sommerseth [Wed, 14 Dec 2011 17:12:23 +0000 (18:12 +0100)] 
Fix compiling with --disable-crypto and/or --disable-ssl

The checks introduced in commit 0f2bc0dd92f43c91e33bba8a66b06b98f281efc1
didn't properly remove checks if crypto or SSL was disabled at compile time.

Signed-off-by: David Sommerseth <davids@redhat.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
13 years agoAllow "tap-win32 dynamic <offset>" to be used in topology
James Yonan [Fri, 11 Nov 2011 23:24:55 +0000 (23:24 +0000)] 
Allow "tap-win32 dynamic <offset>" to be used in topology
subnet mode.

Version 2.1.18

git-svn-id: http://svn.openvpn.net/projects/openvpn/branches/BETA21/openvpn@7706 e7ae566f-a301-0410-adde-c780ea21d3b5

13 years agoFixed client issues with DHCP Router option extraction/deletion when
James Yonan [Thu, 3 Nov 2011 02:03:35 +0000 (02:03 +0000)] 
Fixed client issues with DHCP Router option extraction/deletion when
using layer 2 with DHCP proxy:

* Extract/delete Router option from both DHCPOFFER and DHCPACK
  messages.  Prevously we only considered DHCPACK messages.
  With DHCPACK messages, we extract the Router IP for
  use as the vpn_gateway, as well as delete the Router option from
  the DHCP message.  For DHCPOFFER, we only delete the Router
  message.

* Monitor all DHCPOFFER and DHCPACK messages for possible Router
  options needing to be extracted/deleted.  Previously, we turned
  off monitoring after the first successful extraction/deletion
  from a DHCPACK message.

* Previously, we deleted Router options by padding them with DHCP
  PAD options.  This has proven not to work with some DHCP clients,
  so we now delete the message entirely, and add PADs to the end of
  the message so as not to change its length.

* In some cases, UDP checksum was not being correctly updated for
  modified DHCP packets.

To properly use this feature on Linux, after tunnel comes up,
run these commands:

  ifconfig tap0 up
  dhclient tap0

Version 2.1.17

git-svn-id: http://svn.openvpn.net/projects/openvpn/branches/BETA21/openvpn@7682 e7ae566f-a301-0410-adde-c780ea21d3b5

13 years agoAdded "memstats" option to maintain real-time operating stats
James Yonan [Tue, 18 Oct 2011 08:12:51 +0000 (08:12 +0000)] 
Added "memstats" option to maintain real-time operating stats
in a memory-mapped file.

Version 2.1.16

git-svn-id: http://svn.openvpn.net/projects/openvpn/branches/BETA21/openvpn@7653 e7ae566f-a301-0410-adde-c780ea21d3b5

13 years agoRaised D_PID_DEBUG_LOW from level 3 to 4 to reduce replay error
James Yonan [Tue, 11 Oct 2011 02:27:27 +0000 (02:27 +0000)] 
Raised D_PID_DEBUG_LOW from level 3 to 4 to reduce replay error
verbosity at level 3.

git-svn-id: http://svn.openvpn.net/projects/openvpn/branches/BETA21/openvpn@7645 e7ae566f-a301-0410-adde-c780ea21d3b5

13 years agoDon't look for 'stdin' file when using --auth-user-pass
David Sommerseth [Fri, 2 Dec 2011 15:32:56 +0000 (16:32 +0100)] 
Don't look for 'stdin' file when using --auth-user-pass

This argument allows the keyword 'stdin' to indicate that the input
is to be read from the stdin.  Don't check for file existence if the
file name is set to 'stdin'

Signed-off-by: David Sommerseth <davids@redhat.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
13 years agoFix bug after removing Linux 2.2 support
David Sommerseth [Thu, 24 Nov 2011 21:45:21 +0000 (22:45 +0100)] 
Fix bug after removing Linux 2.2 support

In commit ce637abdafdc19547fc97192033a4d1703ecaf23 the Linux 2.2 support
was removed.  When this happened an extra error check was avoided which
would normally kicked in if the tun/tap device would not be available.
Instead the following line was filling the log continously:

   Thu Nov 24 22:33:15 2011 read from TUN/TAP : File descriptor in bad state (code=77)

This patch changes the msg() declarations to use the M_FATAL *) flag,
which will halt the execution of the program in these error sitauations.
As the program will really halt, the return declarations was also removed.

*) #define M_ERR   (M_FATAL | M_ERRNO)  (from error.h)

Signed-off-by: David Sommerseth <dazo@users.sourceforge.net>
Acked-by: Gert Doering <gert@greenie.muc.de>