Skip to contentSkip to conversation

build revolution

PATCH In review Alon Bar-Lev 7 participants 187 messages Feb 29, 2012 – Apr 26, 2012 1 message not in the archive Kbuild Page 3 of 4

lore
Share & tools
lore
#40 lore raw

Re: [Openvpn-devel] [PATCH 21/52] build: remove windows specific build system

In reply to Alon Bar-Lev

There goes all the sweat and tears I poured onto that buildsystem :).

I say let it burn. ACK.

Samuli

Quoted 3,136 lines

It will be completely re-written in future

---
 Makefile.am            |    8 +-
 doclean                |   73 -----
 domake-win             |  138 --------
 msvc/autodefs.h.in     |   20 --
 msvc/config.py         |   93 ------
 msvc/msvc.mak          |   52 ---
 service-win32/msvc.mak |   30 --
 win/autodefs.h.in      |   31 --
 win/build.py           |   23 --
 win/build_all.py       |   69 ----
 win/build_ddk.py       |   55 ----
 win/build_exe.py       |   15 -
 win/config.h.in        |  363 ---------------------
 win/config.py          |   21 --
 win/config_all.py      |   13 -
 win/config_tap.py      |   35 --
 win/config_ti.py       |   18 -
 win/js.py              |   10 -
 win/make_dist.py       |  107 -------
 win/msvc.mak.in        |   69 ----
 win/openvpn.nsi        |  822 ------------------------------------------------
 win/setpath.nsi        |  231 --------------
 win/settings.in        |  100 ------
 win/show.py            |    9 -
 win/sign.py            |   23 --
 win/tap_span.py        |  129 --------
 win/wb.py              |  322 -------------------
 27 files changed, 2 insertions(+), 2877 deletions(-)
 delete mode 100755 doclean
 delete mode 100644 domake-win
 delete mode 100644 msvc/autodefs.h.in
 delete mode 100644 msvc/config.py
 delete mode 100644 msvc/msvc.mak
 delete mode 100644 service-win32/msvc.mak
 delete mode 100644 win/__init__.py
 delete mode 100644 win/autodefs.h.in
 delete mode 100644 win/build.py
 delete mode 100644 win/build_all.py
 delete mode 100644 win/build_ddk.py
 delete mode 100644 win/build_exe.py
 delete mode 100644 win/config.h.in
 delete mode 100644 win/config.py
 delete mode 100644 win/config_all.py
 delete mode 100644 win/config_tap.py
 delete mode 100644 win/config_ti.py
 delete mode 100644 win/js.py
 delete mode 100644 win/make_dist.py
 delete mode 100644 win/msvc.mak.in
 delete mode 100755 win/openvpn.nsi
 delete mode 100755 win/setpath.nsi
 delete mode 100644 win/settings.in
 delete mode 100644 win/show.py
 delete mode 100644 win/sign.py
 delete mode 100644 win/tap_span.py
 delete mode 100644 win/wb.py
Makefile.am +2 -6
index 74f388a..a14f4e1 100644
@@ -46,8 +46,7 @@ EXTRA_DIST = \
        suse \
        contrib \
        debug \
-       plugins \
-       win
+       plugins
 
 SUBDIRS = service-win32
 
@@ -59,8 +58,6 @@ dist_doc_DATA = \
 
 dist_noinst_SCRIPTS = \
        $(TESTS) \
-       doclean \
-       domake-win \
        t_cltsrv-down.sh \
        configure_h.awk configure_log.awk
 
@@ -68,8 +65,7 @@ dist_noinst_DATA = \
        openvpn.spec \
        COPYRIGHT.GPL \
        PORTS \
-       INSTALL-win32.txt \
-       service-win32/msvc.mak
+       INSTALL-win32.txt
 
 openvpn_SOURCES = \
         base64.c base64.h \
doclean deleted +0 -73
deleted file mode 100755
index 8b35dd6..0000000
@@ -1,73 +0,0 @@
-#!/bin/sh
-
-# Let's have a fresh start.  Remove all
-# generated files.
-#
-# Run this script, then:
-#        autoreconf -i -v
-#        ./configure
-#        make
-#        make install
-
-if ! [ "$KEEPAUTODEFS" = "yes" ]; then
-    rm -rf autodefs
-fi
-
-rm -f \
-    *.o \
-    service-win32/*.o \
-    service-win32/*.exe \
-    *.exe \
-    openvpn \
-    config.cache \
-    configure \
-    Makefile \
-    Makefile.in \
-    stamp-h* \
-    config.guess \
-    config.sub \
-    depcomp \
-    missing \
-    mkinstalldirs \
-    config.log \
-    config.status \
-    config.h \
-    config.h.in \
-    aclocal.m4 \
-    openvpn.spec \
-    install-sh \
-    openvpn.8.html \
-    install-win32/*.exe \
-    install-win32/makensis.log \
-    install-win32/settings \
-    install-win32/Makefile \
-    install-win32/Makefile.in \
-    images/Makefile \
-    images/Makefile.in \
-    service-win32/Makefile \
-    service-win32/Makefile.in
-
-rm -rf \
-    autom4te*.cache \
-    .deps \
-    */.deps \
-    windest \
-    gen \
-    tapinstall \
-    install-win32/tmp
-
-rm -rf \
-    tap-win32/objfre_w2k_x86 \
-    tap-win32/dist \
-    tap-win32/SOURCES \
-    tap-win32/tapdrvr.cod \
-    tap-win32/buildfre_wnet_amd64.wrn \
-    tap-win32/buildfre_w2k_x86.wrn \
-    tap-win32/objfre_wnet_amd64 \
-    tap-win32/buildfre_wnet_amd64.log \
-    tap-win32/buildfre_w2k_x86.log \
-    tap-win32/amd64 \
-    tap-win32/i386/tap0901.pdb \
-    tap-win32/i386/OemWin2k.inf \
-    tap-win32/i386/tap0901.map \
-    tap-win32/i386/tap0901.sys
domake-win deleted +0 -138
deleted file mode 100644
index bd730e0..0000000
@@ -1,138 +0,0 @@
-#!/bin/sh
-
-# This is the master OpenVPN build script for Windows.
-# This script will build OpenVPN, the TAP driver, and
-# the installer from source, targeting x86 on Windows
-# 2000 and higher, and x64 on Windows 2003 and higher.
-# For quick start options, see pre-built notes below.
-#
-# Note that if you are only looking to build the
-# openvpn user-space binaries (openvpn.exe
-# and openvpnserv.exe) you can use the
-# provided autoconf/automake build environment.
-#
-# If you are building from an expanded .tar.gz file,
-# make sure to run "./doclean" before "./domake-win".
-#
-# See top-level build configuration and settings in:
-#
-#   version.m4
-#   install-win32/settings.in
-#
-# Mandatory prerequisites:
-#
-# MinGW     -- for GNU C compiler
-# MSYS      -- for bash
-# msysDTK   -- for perl
-# NSIS      -- for building installer
-#
-# The following additional prerequisites may be omitted
-# when building in pre-built mode (see note below).
-#
-# svn       -- for checking out source code (or TortoiseSVN)
-# Windows Driver Kit (6001_17121_HyperV_WDK.iso) -- for building
-#    TAP driver + tapinstall
-#
-# Required libraries (must be prebuilt)
-#
-# OpenSSL       -- define OPENSSL_DIR in settings.in
-# LZO           -- define LZO_DIR in settings.in
-# PKCS11-HELPER -- define PKCS11_HELPER_DIR
-#
-# Optional OpenVPN GUI binary (prebuilt)
-#           -- define OPENVPN_GUI_DIR and OPENVPN_GUI in settings.in
-#
-# Required source code not included in OpenVPN SVN repository
-# because of MS licensing restrictions:
-#
-# ../tapinstall -- This is based on 'devcon' which is found in the
-#                  Windows Driver Kit (formerly known as DDK).
-#                  Copy the 'devcon' source tree to ../tapinstall
-#                  Edit 'sources' and modify TARGETNAME=tapinstall
-
-# Note that all variables referenced here such as GENOUT,
-# GENOUT_PREBUILT, and CLEAN are defined in install-win32/settings.in
-
-# SPECIAL NOTES ON PRE-BUILT MODE
-#   Setting up a complete tool chain to build OpenVPN and all
-#   dependencies on Windows can be an onerous task, so the capability
-#   is provided to reference a directory of pre-built components during
-#   the build process.  When dependencies are missing to build a given
-#   component (such as the TAP driver), the build script will auto-detect
-#   this and use the pre-built version instead.  This would allow you, for
-#   example, to build an OpenVPN installer with custom edits to
-#   install-win32/settings.in, but then avoid needing to build all other
-#   components (such as OpenSSL, LZO, Pkcs11-helper, TAP driver, Windows
-#   service, etc.).  The procedure is as follows. First Download and expand
-#   the pre-built binaries from:
-#
-#     http://openvpn.net/prebuilt/ (choose the most recent -prebuilt .tbz file)
-#
-#   After expanding the .tbz file, cd to the top level directory and
-#   expand an OpenVPN source distribution taken from either the subversion
-#   repository or a source .tar.gz file.  It's best to use an OpenVPN source
-#   version that is the same or slightly later than the pre-built binaries
-#   file.  So now you have a directory containing something that looks like
-#   this:
-#
-#   gen-prebuilt     -> from prebuilt .tbz file
-#   lzo-2.02         -> from prebuilt .tbz file
-#   openssl-0.9.8i   -> from prebuilt .tbz file
-#   pkcs11-helper    -> from prebuilt .tbz file
-#   openvpn-2.1_rc13.tar.gz  -> downloaded from openvpn.net
-#   openvpn-2.1_rc13 -> directory expanded from above file
-#
-#   Now cd to your expanded source tree (openvpn-2.1_rc13 in the
-#   example above), make edits to install-win32/settings.in (or even
-#   patch the OpenVPN source code directly), and run this script:
-#
-#       ./domake-win
-#
-#   If everything runs correctly, you should have a custom installer
-#   written to ./gen/install
-
-# First build the autodefs directory, containing C, sh, and NSIS versions
-# of global settings, using install-win32/settings.in as source.
-# These settings will then drive the rest of the build process.
-install-win32/winconfig
-
-# clean all generated files
-install-win32/doclean
-
-# Load a pre-built GENOUT directory if GENOUT_PREBUILT is defined
-# and the GENOUT directory is non-existing
-install-win32/getprebuilt
-
-# Each of the scripts below build, get, and/or possibly sign a different
-# OpenVPN component, placing the generated files in GENOUT.  Each of these
-# steps is fully indepedent, and can be executed in any order or omitted.
-# The exception is the last script which gathers together all files from
-# GENOUT and builds the installer.
-
-# Make the OpenVPN user-space components (OpenVPN and service)
-install-win32/makeopenvpn
-
-# Make the OpenVPN TAP driver
-install-win32/maketap
-
-# Make the tapinstall utility, used to install the TAP driver
-install-win32/maketapinstall
-
-# Get the OpenSSL libraries from a pre-build OpenSSL tree
-install-win32/getopenssl
-
-# Get the PKCS-11 helper library from a pre-built OpenSSL tree
-install-win32/getpkcs11helper
-
-# Get the OpenVPN GUI (must be prebuilt)
-install-win32/getgui
-
-# Get the OpenVPN XML-based GUI (must be prebuilt)
-install-win32/getxgui
-
-# Produce the license text, install README, and sample config files
-install-win32/maketext
-
-# This final step builds the OpenVPN installer using generated
-# files from GENOUT
-install-win32/buildinstaller
msvc/autodefs.h.in deleted +0 -20
deleted file mode 100644
index b0fa7f5..0000000
@@ -1,20 +0,0 @@
-/*
- * 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@"
msvc/config.py deleted +0 -93
deleted file mode 100644
index 9915cd0..0000000
@@ -1,93 +0,0 @@
-# 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()
msvc/msvc.mak deleted +0 -52
deleted file mode 100644
index 2d99de7..0000000
@@ -1,52 +0,0 @@
-# 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) $<
-<<
service-win32/msvc.mak deleted +0 -30
deleted file mode 100644
index ba4bab7..0000000
@@ -1,30 +0,0 @@
-# This makefile builds the OpenVPN service wrapper for Windows in the
-# Visual Studio 2008 environment.
-
-# Some of these libs may not be needed
-LIBS = ws2_32.lib crypt32.lib iphlpapi.lib winmm.lib user32.lib gdi32.lib advapi32.lib wininet.lib
-EXE = openvpnserv.exe
-
-CPP=cl.exe
-CPP_ARG_COMMON=/nologo /W3 -DWIN32 -DWIN32_LEAN_AND_MEAN -D_CONSOLE -D_MBCS -D_CRT_SECURE_NO_DEPRECATE /FD /c -I".."
-CPP_PROJ=$(CPP_ARG_COMMON) /O2 /MD -DNDEBUG
-
-LINK32=link.exe
-LINK32_FLAGS=/nologo /subsystem:console /incremental:no
-
-OBJS = \
-       openvpnserv.obj \
-       service.obj
-
-openvpnserv : $(OBJS)
-       $(LINK32) @<<
-       $(LINK32_FLAGS) "/out:$(EXE)" $(LIBS) $(OBJS)
-<<
-
-clean :
-       del /Q $(OBJS) $(EXE) *.idb *.pdb
-
-.c.obj::
-   $(CPP) @<<
-   $(CPP_PROJ) $<
-<<
win/__init__.py deleted +0 -0
deleted file mode 100644
index e69de29..0000000
win/autodefs.h.in deleted +0 -31
deleted file mode 100644
index 760b0df..0000000
@@ -1,31 +0,0 @@
-#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_WIN_COMPONENT_ID "@PRODUCT_TAP_WIN_COMPONENT_ID@"
-#define TAP_WIN_MIN_MAJOR @PRODUCT_TAP_WIN_MIN_MAJOR@
-#define TAP_WIN_MIN_MINOR @PRODUCT_TAP_WIN_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
win/build.py deleted +0 -23
deleted file mode 100644
index 69137f2..0000000
@@ -1,23 +0,0 @@
-import os, sys
-from wb import system, config, home_fn, cd_home, cd_service_win32, run_in_vs_shell
-
-def main():
-    """Build openvpn.exe and openvpnserv.exe"""
-    cd_home()
-    run_in_vs_shell("nmake /f %s" % (home_fn('msvc.mak'),))
-    cd_service_win32()
-    run_in_vs_shell("nmake /f %s" % ('msvc.mak'))
-
-def clean():
-    """Clean up after openvpn.exe and openvpnserv.exe build"""
-    cd_home()
-    run_in_vs_shell("nmake /f %s clean" % (home_fn('msvc.mak'),))
-    os.chdir("service-win32")
-    run_in_vs_shell("nmake /f %s clean" % ('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()
win/build_all.py deleted +0 -69
deleted file mode 100644
index 47716a1..0000000
@@ -1,69 +0,0 @@
-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"
-    print " -n, --notap                Don't build the TAP driver"
-    sys.exit(1)
-
-def main(config):
-
-    # Do a signed build by default
-    signedBuild=True
-
-    # Build the TAP driver by default
-    tap=True
-
-    # Parse the command line argument(s)
-    try:
-       opts, args = getopt.getopt(sys.argv[1:], "hun", ["help", "unsigned", "notap"])
-    except getopt.GetoptError:
-       Usage()
-
-    for o, a in opts:
-       if o in ("-h","--help"):
-          Usage()
-       if o in ("-u", "--unsigned"):
-          signedBuild=False
-       if o in ("-n", "--notap"):
-          tap=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()
-
-    if tap:
-       build_ddk(config, 'tap', 'all')
-       build_ddk(config, 'tapinstall', 'all')
-       if signedBuild:
-          sign(config, 'all')
-       make_dist(config,tap=True)
-
-    else:
-       if 'TAP_PREBUILT' in config:
-          print "Using prebuilt TAP driver"
-          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)
win/build_ddk.py deleted +0 -55
deleted file mode 100644
index a197bf5..0000000
@@ -1,55 +0,0 @@
-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):
-    """Build drivers using WinDDK tools"""
-    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)
win/build_exe.py deleted +0 -15
deleted file mode 100644
index dae4825..0000000
@@ -1,15 +0,0 @@
-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)
win/config.h.in deleted +0 -363
deleted file mode 100644
index fcb8d6c..0000000
@@ -1,363 +0,0 @@
-/*
- *  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. <[email protected]...>
- *
- *  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.
- */
-
-#ifndef OPENVPN_CONFIG_H
-#define OPENVPN_CONFIG_H
-
-#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 reading credentials from a file */
-#if @ENABLE_PASSWORD_SAVE@ != 0
-#define ENABLE_PASSWORD_SAVE @ENABLE_PASSWORD_SAVE@
-#endif
-
-/* Enable client/server capability */
-#if @ENABLE_CLIENT_SERVER@ != 0
-#define ENABLE_CLIENT_SERVER @ENABLE_CLIENT_SERVER@
-#endif
-
-/* Enable client capability only */
-#if @ENABLE_CLIENT_ONLY@ != 0
-#define ENABLE_CLIENT_ONLY @ENABLE_CLIENT_ONLY@
-#endif
-
-/* Enable management server capability */
-#if @ENABLE_MANAGEMENT@ != 0
-#define ENABLE_MANAGEMENT @ENABLE_MANAGEMENT@
-#endif
-
-/* Enable PKCS#11 support */
-#if @USE_PKCS11@ != 0
-#define USE_PKCS11 1
-#endif
-
-/* Enable HTTP proxy support */
-#if @ENABLE_HTTP_PROXY@ != 0
-#define ENABLE_HTTP_PROXY @ENABLE_HTTP_PROXY@
-#endif
-
-/* Enable Socks proxy support */
-#if @ENABLE_SOCKS@ != 0
-#define ENABLE_SOCKS @ENABLE_SOCKS@
-#endif
-
-/* Enable internal fragmentation support */
-#if @ENABLE_FRAGMENT@ != 0
-#define ENABLE_FRAGMENT @ENABLE_FRAGMENT@
-#endif
-
-/* Enable smaller executable size */
-/* #undef ENABLE_SMALL */
-
-/* Enable debugging support */
-#if @ENABLE_DEBUG@ != 0
-#define ENABLE_DEBUG @ENABLE_DEBUG@
-#endif
-
-/* 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
-
-
-/* The POSIX access() function is available, but requires
- * _CRT_NONSTDC_NO_WARNINGS and _CRT_SECURE_NO_WARNINGS
- * to be defined
- */
-#define HAVE_ACCESS 1
-
-/* Macros used by the POSIX access() function might not be available on Windows.
- * Based on information found here:
- * http://msdn.microsoft.com/en-us/library/1w06ktdy%28v=vs.80%29.aspx
- */
-#ifndef R_OK
-#define R_OK 4
-#endif
-
-#ifndef W_OK
-#define W_OK 2
-#endif
-
-#ifndef X_OK
-#define X_OK 0
-#endif
-
-#ifndef F_OK
-#define F_OK 0
-#endif
-
-
-/* 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 the PolarSSL crypto library */
-#if @USE_POLARSSL@ != 0
-#define USE_POLARSSL 1
-#endif
-
-/* Use the OpenSSL crypto library */
-#if @USE_OPENSSL@ != 0
-#define USE_OPENSSL 1
-#endif
-
-/* Use the 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 the 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*/
-
-#ifndef __MINGW32__
-/* 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
-#endif /* __MINGW32__ */
-
-/* Route command */
-#define ROUTE_PATH "route"
-
-#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
-
-#endif /* OPENVPN_CONFIG_H */
win/config.py deleted +0 -21
deleted file mode 100644
index b820510..0000000
@@ -1,21 +0,0 @@
-from wb import preprocess, autogen, mod_fn, home_fn, build_config_h, build_configure_h, build_version_m4_vars, build_autodefs, make_headers_objs, dict_def
-
-def main(config):
-    build_config_h(config)
-    build_configure_h(config, mod_fn(home_fn('configure.h')), head_comment='/* %s */\n\n' % autogen)
-    build_version_m4_vars(mod_fn(mod_fn('version_m4_vars.tmp')), head_comment='/* %s */\n\n' % autogen)
-    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)
win/config_all.py deleted +0 -13
deleted file mode 100644
index ba6affe..0000000
@@ -1,13 +0,0 @@
-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)
win/config_tap.py deleted +0 -35
deleted file mode 100644
index a5b1d6c..0000000
@@ -1,35 +0,0 @@
-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)
win/config_ti.py deleted +0 -18
deleted file mode 100644
index 8742caa..0000000
@@ -1,18 +0,0 @@
-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(src, 'sources'),
-               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)
win/js.py deleted +0 -10
deleted file mode 100644
index d1d4db3..0000000
@@ -1,10 +0,0 @@
-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)
win/make_dist.py deleted +0 -107
deleted file mode 100644
index edb0e6a..0000000
@@ -1,107 +0,0 @@
-import os
-from wb import home_fn, rm_rf, mkdir, cp_a, cp, rename, run_in_vs_shell
-
-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')
-    samples = os.path.join(dist, 'samples')
-
-    # build dist and subdirectories
-    rm_rf(dist)
-    mkdir(dist)
-    mkdir(bin)
-    mkdir(i386)
-    mkdir(amd64)
-    mkdir(samples)
-
-    # copy openvpn.exe, openvpnserv.exe and their manifests
-    cp(home_fn('openvpn.exe'), bin)
-    cp(home_fn('openvpn.exe.manifest'), bin)
-    cp(home_fn('service-win32/openvpnserv.exe'), bin)
-    cp(home_fn('service-win32/openvpnserv.exe.manifest'), bin)
-
-    # copy openvpn-gui
-    cp(home_fn(config['OPENVPN_GUI_DIR']+"/"+config['OPENVPN_GUI']), bin)
-
-    # copy DLL dependencies
-    cp(home_fn(config['LZO_DIR']+'/bin/lzo2.dll'), bin)
-    cp(home_fn(config['LZO_DIR']+'/bin/lzo2.dll.manifest'), bin)
-    cp(home_fn(config['OPENSSL_DIR']+'/bin/libeay32.dll'), bin)
-    cp(home_fn(config['OPENSSL_DIR']+'/bin/ssleay32.dll'), bin)
-    cp(home_fn(config['PKCS11_HELPER_DIR']+'/lib/libpkcs11-helper-1.dll'), bin)
-    cp(home_fn(config['PKCS11_HELPER_DIR']+'/lib/libpkcs11-helper-1.dll.manifest'), bin)
-
-    # copy OpenSSL utilities (=openvpn.exe)
-    cp(home_fn(config['OPENSSL_DIR']+'/bin/openssl.exe'), bin)
-
-    # copy sample config files; renaming is necessary due to openvpn.nsi script
-    cp(home_fn('install-win32/sample.ovpn'), samples)
-    cp(home_fn('sample-config-files/client.conf'), samples)
-    cp(home_fn('sample-config-files/server.conf'), samples)
-    rename(os.path.join(samples,'client.conf'), os.path.join(samples, 'client.ovpn'))
-    rename(os.path.join(samples,'server.conf'), os.path.join(samples, 'server.ovpn'))
-
-    # embed manifests to executables and DLLs
-    for f in [ "openvpn.exe", "openvpnserv.exe", "lzo2.dll", "libpkcs11-helper-1.dll" ]:
-
-        outputresource = os.path.join(bin,f)
-        manifest = outputresource+".manifest"
-
-        # EXEs and DLLs require slightly different treatment
-        if f.endswith(".exe"):
-            type = "1"
-        elif f.endswith(".dll"):
-            type = "2"
-        else:
-            print "ERROR: Could not embed manifest to "+outputresouce+", bailing out."
-            sys.exit(1)
-
-        # Embed the manifest
-        run_in_vs_shell('mt.exe -manifest %s -outputresource:%s;%s' % (manifest, outputresource, type))
-
-    # copy MSVC CRT
-    cp_a(home_fn(config['MSVC_CRT']), bin)
-
-    # TAP-driver and tapinstall.exe were built, so copy those over
-    if tap:
-        drv_dir = 'tap-win32'
-        ti_dir = 'tapinstall'
-
-    # we're using prebuilt TAP-driver and tapinstall.exe
-    elif 'TAP_PREBUILT' in config:
-        drv_dir = config['TAP_PREBUILT']
-        ti_dir = config['TAP_PREBUILT']
-
-    else:
-        print "ERROR: Could not find prebuilt TAP-drivers or tapinstall.exe. Please check win/settings.in"
-        sys.exit(1)
-
-    # copy TAP drivers
-    for dir_name, dest in (('amd64', amd64), ('i386', i386)):
-        dir = home_fn(os.path.join(drv_dir, 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.exe (usually known as devcon.exe)
-    dest = {'amd64' : amd64, 'i386' : i386}
-    for dirpath, dirnames, filenames in os.walk(home_fn(ti_dir)):
-        for f in filenames:
-            if f in ( 'devcon.exe', 'tapinstall.exe' ):
-                dir_name = os.path.basename(dirpath)
-                src = os.path.join(dirpath, f)
-                dst = os.path.join(dest[dir_name],'tapinstall.exe')
-                if dir_name in dest:
-                    cp(src, dst, dest_is_dir=False)
-
-# if we are run directly, and not loaded as a module
-if __name__ == "__main__":
-    from wb import config
-    main(config)
win/msvc.mak.in deleted +0 -69
deleted file mode 100644
index 43c3335..0000000
@@ -1,69 +0,0 @@
-# This makefile builds the user-mode component of OpenVPN for Windows in the
-# Visual Studio 2008 environment. Note that this file is basis for the real
-# makefile (..\msvc.mak) but unusable as is. The real makefile is automatically
-# generated during the build process by the Python build scripts.
-#
-# A few details are in order:
-#
-# - Everything between @<< and << is inserted into a s.c. "in-line file". This
-#   file drives the linker (link.exe).
-# - HEADERS_OBJS is expanded to all all header and source files listed in
-#  ..\Makefile.am
-# - OPENSSL_DIR and LZO_DIR are dynamically created from settings.in
-
-OPENSSL = @OPENSSL_DIR@
-!ifdef INCLUDE_OPENSSL
-OPENSSL_DYNAMIC = libeay32.lib ssleay32.lib
-!endif
-
-POLARSSL = @POLARSSL_DIR@
-!ifdef INCLUDE_POLARSSL
-POLARSSL_DYNAMIC = polarssl.lib
-!endif
-
-PKCS11_HELPER = @PKCS11_HELPER_DIR@
-!ifdef INCLUDE_PKCS11
-PKCS11_HELPER_DYNAMIC = pkcs11-helper.lib
-!endif
-
-LZO = @LZO_DIR@
-LZO_DYNAMIC = lzo2.lib
-
-INCLUDE_DIRS = -I$(OPENSSL)/include -I$(POLARSSL)/include -I$(LZO)/include -I$(PKCS11_HELPER)/include
-
-LIBS = $(OPENSSL_DYNAMIC) $(POLARSSL_DYNAMIC) $(PKCS11_HELPER_DYNAMIC) $(LZO_DYNAMIC) ws2_32.lib crypt32.lib iphlpapi.lib winmm.lib user32.lib gdi32.lib advapi32.lib wininet.lib shell32.lib
-
-LIB_DIRS = -LIBPATH:$(OPENSSL)\lib -LIBPATH:$(POLARSSL)\build\library -LIBPATH:$(PKCS11_HELPER)\lib -LIBPATH:$(LZO)\lib
-
-EXE = openvpn.exe
-
-CPP=cl.exe
-CPP_ARG_COMMON=/nologo /W3 -DWIN32 -DWIN32_LEAN_AND_MEAN -DWINVER=0x0501 -D_CONSOLE -D_MBCS -D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_WARNINGS -D_CRT_SECURE_NO_WARNINGS $(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
-!else
-# release:
-CPP_PROJ=$(CPP_ARG_COMMON) /O2 /MD -DNDEBUG
-LINK32_FLAGS=/nologo /subsystem:console /incremental:no
-!endif
-
-# HEADERS and OBJS definitions, automatically generated from ../Makefile.am
[email protected]...@
-
-openvpn : $(OBJS)
-       $(LINK32) @<<
-       $(LINK32_FLAGS) "/out:$(EXE)" $(LIB_DIRS) $(LIBS) $(OBJS)
-<<
-
-clean :
-       del /Q $(OBJS) $(EXE) *.idb *.pdb
-
-.c.obj::
-   $(CPP) @<<
-   $(CPP_PROJ) $<
-<<
win/openvpn.nsi deleted +0 -822
deleted file mode 100755
index 4167c89..0000000
@@ -1,822 +0,0 @@
-; ****************************************************************************
-; * 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.                           *
-; ****************************************************************************
-
-; OpenVPN install script for Windows, using NSIS
-
-; Start menu entries don't get uninstalled properly on Windows Vista/7 unless we
-; explicitly state that the installer requires admin privileges. This is
-; caused by backwards compatibility tricks used on those platforms. For details,
-; see http://nsis.sourceforge.net/Shortcuts_removal_fails_on_Windows_Vista
-RequestExecutionLevel admin
-
-SetCompressor lzma
-
-!include "MUI.nsh"
-
-# Include basic build settings
-!include "settings.in"
-
-# Include variables generated dynamically from version.m4 by wb.py
-!include "version_m4_vars.tmp"
-
-;!include "guidefs.nsi"
-!include "setpath.nsi"
-
-!ifdef EXTRACT_FILES
-!include "MultiFileExtract.nsi"
-!endif
-
-!define GEN "..\dist"
-!define BIN "${GEN}\bin"
-!define EASYRSA "..\easy-rsa"
-
-!define PRODUCT_ICON "icon.ico"
-
-!ifdef PRODUCT_TAP_DEBUG
-!define DBG_POSTFIX "-DBG"
-!else
-!define DBG_POSTFIX ""
-!endif
-
-!define VERSION "${PRODUCT_VERSION}${DBG_POSTFIX}"
-
-!define TAP "${PRODUCT_TAP_WIN_COMPONENT_ID}"
-!define TAPDRV "${TAP}.sys"
-
-; Default service settings
-!define SERV_CONFIG_DIR   "$INSTDIR\config"
-!define SERV_CONFIG_EXT   "${PRODUCT_FILE_EXT}"
-!define SERV_EXE_PATH     "$INSTDIR\bin\${PRODUCT_UNIX_NAME}.exe"
-!define SERV_LOG_DIR      "$INSTDIR\log"
-!define SERV_PRIORITY     "NORMAL_PRIORITY_CLASS"
-!define SERV_LOG_APPEND   "0"
-
-;--------------------------------
-;Configuration
-
-  ;General
-
-  OutFile "${GEN}\${PRODUCT_UNIX_NAME}-${VERSION}${OUTFILE_LABEL}-install.exe"
-
-  ShowInstDetails show
-  ShowUninstDetails show
-
-  ;Folder selection page
-  InstallDir "$PROGRAMFILES\${PRODUCT_NAME}"
-
-  ;Remember install folder
-  InstallDirRegKey HKCU "Software\${PRODUCT_NAME}" ""
-
-;--------------------------------
-;Modern UI Configuration
-
-  Name "${PRODUCT_NAME} ${VERSION} ${TITLE_LABEL}"
-
-  !define MUI_WELCOMEPAGE_TEXT "This wizard will guide you through the installation of ${PRODUCT_NAME}, an Open Source VPN package by James Yonan.\r\n\r\nNote that the Windows version of ${PRODUCT_NAME} only runs on XP, or higher.\r\n\r\n\r\n"
-
-  !define MUI_COMPONENTSPAGE_TEXT_TOP "Select the components to install/upgrade.  Stop any ${PRODUCT_NAME} processes or the ${PRODUCT_NAME} service if it is running.  All DLLs are installed locally."
-
-  !define MUI_COMPONENTSPAGE_SMALLDESC
-  !define MUI_FINISHPAGE_SHOWREADME "$INSTDIR\INSTALL-win32.txt"
-  !define MUI_FINISHPAGE_NOAUTOCLOSE
-  !define MUI_ABORTWARNING
-  !define MUI_ICON "..\images\${PRODUCT_ICON}"
-  !define MUI_UNICON "..\images\${PRODUCT_ICON}"
-  !define MUI_HEADERIMAGE
-  !define MUI_HEADERIMAGE_BITMAP "..\images\install-whirl.bmp"
-  !define MUI_UNFINISHPAGE_NOAUTOCLOSE
-
-  !insertmacro MUI_PAGE_WELCOME
-  !insertmacro MUI_PAGE_LICENSE "..\COPYRIGHT.GPL"
-  !insertmacro MUI_PAGE_COMPONENTS
-  !insertmacro MUI_PAGE_DIRECTORY
-  !insertmacro MUI_PAGE_INSTFILES
-  !insertmacro MUI_PAGE_FINISH
-
-  !insertmacro MUI_UNPAGE_CONFIRM
-  !insertmacro MUI_UNPAGE_INSTFILES
-  !insertmacro MUI_UNPAGE_FINISH
-
-
-;--------------------------------
-;Languages
-
-  !insertmacro MUI_LANGUAGE "English"
-
-;--------------------------------
-;Language Strings
-
-  LangString DESC_SecOpenVPNUserSpace ${LANG_ENGLISH} "Install ${PRODUCT_NAME} user-space components, including ${PRODUCT_UNIX_NAME}.exe."
-
-!ifdef USE_GUI
-  LangString DESC_SecOpenVPNGUI ${LANG_ENGLISH} "Install ${PRODUCT_NAME} GUI by Mathias Sundman"
-!endif
-
-  LangString DESC_SecOpenVPNEasyRSA ${LANG_ENGLISH} "Install ${PRODUCT_NAME} RSA scripts for X509 certificate management."
-
-  LangString DESC_SecOpenSSLDLLs ${LANG_ENGLISH} "Install OpenSSL DLLs locally (may be omitted if DLLs are already installed globally)."
-
-  LangString DESC_SecPKCS11DLLs ${LANG_ENGLISH} "Install PKCS#11 helper DLLs locally (may be omitted if DLLs are already installed globally)."
-
-  LangString DESC_SecLZO2DLLs ${LANG_ENGLISH} "Install LZO2 DLLs locally (may be omitted if DLLs are already installed globally)."
-
-  LangString DESC_SecMSVCR90DLL ${LANG_ENGLISH} "Install Microsoft Visual C 9.0 Runtime (may be omitted if it is already installed globally)."
-
-  LangString DESC_SecTAP ${LANG_ENGLISH} "Install/Upgrade the TAP virtual device driver.  Will not interfere with CIPE."
-
-  LangString DESC_SecService ${LANG_ENGLISH} "Install the ${PRODUCT_NAME} service wrapper (${PRODUCT_UNIX_NAME}serv.exe)"
-
-  LangString DESC_SecOpenSSLUtilities ${LANG_ENGLISH} "Install the OpenSSL Utilities (used for generating public/private key pairs)."
-
-  LangString DESC_SecAddPath ${LANG_ENGLISH} "Add ${PRODUCT_NAME} executable directory to the current user's PATH."
-
-  LangString DESC_SecAddShortcuts ${LANG_ENGLISH} "Add ${PRODUCT_NAME} shortcuts to the current user's Start Menu."
-
-  LangString DESC_SecFileAssociation ${LANG_ENGLISH} "Register ${PRODUCT_NAME} config file association (*.${SERV_CONFIG_EXT})"
-
-;--------------------------------
-;Reserve Files
-
-  ;Things that need to be extracted on first (keep these lines before any File command!)
-  ;Only useful for BZIP2 compression
-
-  ReserveFile "..\images\install-whirl.bmp"
-
-;--------------------------------
-;Macros
-
-!macro WriteRegStringIfUndef ROOT SUBKEY KEY VALUE
-Push $R0
-ReadRegStr $R0 "${ROOT}" "${SUBKEY}" "${KEY}"
-StrCmp $R0 "" +1 +2
-WriteRegStr "${ROOT}" "${SUBKEY}" "${KEY}" '${VALUE}'
-Pop $R0
-!macroend
-
-!macro DelRegStringIfUnchanged ROOT SUBKEY KEY VALUE
-Push $R0
-ReadRegStr $R0 "${ROOT}" "${SUBKEY}" "${KEY}"
-StrCmp $R0 '${VALUE}' +1 +2
-DeleteRegValue "${ROOT}" "${SUBKEY}" "${KEY}"
-Pop $R0
-!macroend
-
-!macro DelRegKeyIfUnchanged ROOT SUBKEY VALUE
-Push $R0
-ReadRegStr $R0 "${ROOT}" "${SUBKEY}" ""
-StrCmp $R0 '${VALUE}' +1 +2
-DeleteRegKey "${ROOT}" "${SUBKEY}"
-Pop $R0
-!macroend
-
-!macro DelRegKeyIfEmpty ROOT SUBKEY
-Push $R0
-EnumRegValue $R0 "${ROOT}" "${SUBKEY}" 1
-StrCmp $R0 "" +1 +2
-DeleteRegKey /ifempty "${ROOT}" "${SUBKEY}"
-Pop $R0
-!macroend
-
-;------------------------------------------
-;Set reboot flag based on tapinstall return
-
-Function CheckReboot
-  IntCmp $R0 1 "" noreboot noreboot
-  IntOp $R0 0 & 0
-  SetRebootFlag true
-  DetailPrint "REBOOT flag set"
- noreboot:
-FunctionEnd
-
-;--------------------------------
-;Installer Sections
-
-Function .onInit
-  ClearErrors
-
-# Verify that user has admin privs
-  UserInfo::GetName
-  IfErrors ok
-  Pop $R0
-  UserInfo::GetAccountType
-  Pop $R1
-  StrCmp $R1 "Admin" ok
-    Messagebox MB_OK "Administrator privileges required to install ${PRODUCT_NAME} [$R0/$R1]"
-    Abort
-  ok:
-
-# Delete previous start menu
-  RMDir /r $SMPROGRAMS\${PRODUCT_NAME}
-
-# FIXME: reimplement Windows version checking code that was located here, but
-# disabled intentionally to avoid Windows 7 issues. This should do it:
-#
-# http://nsis.sourceforge.net/Get_Windows_version
-#
-# Blacklisting should be safer than whitelisting used originally.
-
-FunctionEnd
-
-!ifndef SF_SELECTED
-!define SF_SELECTED 1
-!endif
-
-;--------------------
-;Pre-install section
-
-Section -pre
-
-  ; Stop OpenVPN if currently running
-  DetailPrint "Previous Service REMOVE (if exists)"
-  nsExec::ExecToLog '"$INSTDIR\bin\${PRODUCT_UNIX_NAME}serv.exe" -remove'
-  Pop $R0 # return value/error/timeout
-
-  Sleep 3000
-
-  # Fix for Trac ticket 120. Remove after 2.3 has been released.
-  !ifdef USE_GUI
-    SetShellVarContext current
-    Delete "$DESKTOP\${PRODUCT_NAME} GUI.lnk"
-  !endif
-
-SectionEnd
-
-Section "${PRODUCT_NAME} User-Space Components" SecOpenVPNUserSpace
-
-  SetOverwrite on
-  SetOutPath "$INSTDIR\bin"
-
-  File "${BIN}\${PRODUCT_UNIX_NAME}.exe"
-
-SectionEnd
-
-!ifdef USE_GUI
-Section "${PRODUCT_NAME} GUI" SecOpenVPNGUI
-
-  SetOverwrite on
-  SetOutPath "$INSTDIR\bin"
-
-  File "${BIN}\${OPENVPN_GUI}"
-
-SectionEnd
-!endif
-
-Section "${PRODUCT_NAME} RSA Certificate Management Scripts" SecOpenVPNEasyRSA
-
-  SetOverwrite on
-  SetOutPath "$INSTDIR\easy-rsa"
-
-  # FIXME: the easy-rsa directory would need cleaning up
-
-  # Original nsi script looked for ${EASYRSA}\2.0\openssl.cnf.sample. A newer
-  # openssl.cnf is needed on OpenVPN 2.2+.
-  File "${EASYRSA}\2.0\openssl-1.0.0.cnf"
-
-  File "${EASYRSA}\Windows\vars.bat.sample"
-
-  File "${EASYRSA}\Windows\init-config.bat"
-
-  File "${EASYRSA}\Windows\README.txt"
-  File "${EASYRSA}\Windows\build-ca.bat"
-  File "${EASYRSA}\Windows\build-dh.bat"
-  File "${EASYRSA}\Windows\build-key-server.bat"
-  File "${EASYRSA}\Windows\build-key.bat"
-  File "${EASYRSA}\Windows\build-key-pkcs12.bat"
-  File "${EASYRSA}\Windows\clean-all.bat"
-  File "${EASYRSA}\Windows\index.txt.start"
-  File "${EASYRSA}\Windows\revoke-full.bat"
-  File "${EASYRSA}\Windows\serial.start"
-
-SectionEnd
-
-Section "${PRODUCT_NAME} Service" SecService
-
-  SetOverwrite on
-
-  SetOutPath "$INSTDIR\bin"
-  File "${BIN}\${PRODUCT_UNIX_NAME}serv.exe"
-
-  SetOutPath "$INSTDIR\config"
-
-  FileOpen $R0 "$INSTDIR\config\README.txt" w
-  FileWrite $R0 "This directory should contain ${PRODUCT_NAME} configuration files$\r$\n"
-  FileWrite $R0 "each having an extension of .${SERV_CONFIG_EXT}$\r$\n"
-  FileWrite $R0 "$\r$\n"
-  FileWrite $R0 "When ${PRODUCT_NAME} is started as a service, a separate ${PRODUCT_NAME}$\r$\n"
-  FileWrite $R0 "process will be instantiated for each configuration file.$\r$\n"
-  FileClose $R0
-
-  SetOutPath "$INSTDIR\sample-config"
-  File "${GEN}\samples\sample.${SERV_CONFIG_EXT}"
-  File "${GEN}\samples\client.${SERV_CONFIG_EXT}"
-  File "${GEN}\samples\server.${SERV_CONFIG_EXT}"
-
-  CreateDirectory "$INSTDIR\log"
-  FileOpen $R0 "$INSTDIR\log\README.txt" w
-  FileWrite $R0 "This directory will contain the log files for ${PRODUCT_NAME}$\r$\n"
-  FileWrite $R0 "sessions which are being run as a service.$\r$\n"
-  FileClose $R0
-
-SectionEnd
-
-Section "${PRODUCT_NAME} File Associations" SecFileAssociation
-SectionEnd
-
-Section "OpenSSL DLLs" SecOpenSSLDLLs
-
-  SetOverwrite on
-  SetOutPath "$INSTDIR\bin"
-  File "${BIN}\libeay32.dll"
-  File "${BIN}\ssleay32.dll"
-
-SectionEnd
-
-Section "OpenSSL Utilities" SecOpenSSLUtilities
-
-  SetOverwrite on
-  SetOutPath "$INSTDIR\bin"
-  File "${BIN}\openssl.exe"
-
-SectionEnd
-
-Section "PKCS#11 DLLs" SecPKCS11DLLs
-
-  SetOverwrite on
-  SetOutPath "$INSTDIR\bin"
-  File "${BIN}\libpkcs11-helper-1.dll"
-
-SectionEnd
-
-Section "LZO2 DLLs" SecLZO2DLLs
-
-  SetOverwrite on
-  SetOutPath "$INSTDIR\bin"
-  File "${BIN}\lzo2.dll"
-
-SectionEnd
-
-Section "Microsoft Visual C 9.0 Runtime DLL" SecMSVCR90DLL
-
-  SetOverwrite on
-  SetOutPath "$INSTDIR\bin"
-  File "${BIN}\Microsoft.VC90.CRT\msvcr90.dll"
-  File "${BIN}\Microsoft.VC90.CRT\Microsoft.VC90.CRT.manifest"
-
-SectionEnd
-
-
-
-
-Section "TAP Virtual Ethernet Adapter" SecTAP
-
-  SetOverwrite on
-
-  # Generate TAP driver install script dynamically
-  FileOpen $R0 "$INSTDIR\bin\addtap.bat" w
-  FileWrite $R0 "rem Add a new TAP virtual ethernet adapter$\r$\n"
-  FileWrite $R0 '"$INSTDIR\bin\tapinstall.exe" install "$INSTDIR\driver\OemWin2k.inf" ${TAP}$\r$\n'
-  FileWrite $R0 "pause$\r$\n"
-  FileClose $R0
-
-  # Generate TAP driver removal script dynamically
-  FileOpen $R0 "$INSTDIR\bin\deltapall.bat" w
-  FileWrite $R0 "echo WARNING: this script will delete ALL TAP virtual adapters (use the device manager to delete adapters one at a time)$\r$\n"
-  FileWrite $R0 "pause$\r$\n"
-  FileWrite $R0 '"$INSTDIR\bin\tapinstall.exe" remove ${TAP}$\r$\n'
-  FileWrite $R0 "pause$\r$\n"
-  FileClose $R0
-
-  ; Check if we are running on a 64 bit system.
-  System::Call "kernel32::GetCurrentProcess() i .s"
-  System::Call "kernel32::IsWow64Process(i s, *i .r0)"
-  IntCmp $0 0 tap-32bit
-
-; tap-64bit:
-
-  DetailPrint "We are running on a 64-bit system."
-
-  SetOutPath "$INSTDIR\bin"
-
-  File "${GEN}\amd64\tapinstall.exe"
-
-  SetOutPath "$INSTDIR\driver"
-
-  File "${GEN}\amd64\OemWin2k.inf"
-  File "${GEN}\amd64\${TAPDRV}"
-
-  # Don't try to install TAP driver signature if it does not exist.
-  File /nonfatal "${GEN}\amd64\${PRODUCT_TAP_COMPONENT_ID}.cat"
-
-goto tapend
-
-tap-32bit:
-
-  DetailPrint "We are running on a 32-bit system."
-
-  SetOutPath "$INSTDIR\bin"
-  File "${GEN}\i386\tapinstall.exe"
-
-  SetOutPath "$INSTDIR\driver"
-  File "${GEN}\i386\OemWin2k.inf"
-  File "${GEN}\i386\${TAPDRV}"
-
-  # Don't try to install TAP driver signature if it does not exist.
-  File /nonfatal "${GEN}\i386\${PRODUCT_TAP_COMPONENT_ID}.cat"
-
-  tapend:
-
-SectionEnd
-
-Section "Add ${PRODUCT_NAME} to PATH" SecAddPath
-
-  ; remove previously set path (if any)
-  Push "$INSTDIR\bin"
-  Call RemoveFromPath
-
-  ; append our bin directory to end of current user path
-  Push "$INSTDIR\bin"
-  Call AddToPath
-
-SectionEnd
-
-Section "Add Shortcuts to Start Menu" SecAddShortcuts
-
-  ; Required to handle shortcuts properly on Vista/7
-  SetShellVarContext all
-  SetOverwrite on
-  CreateDirectory "$SMPROGRAMS\${PRODUCT_NAME}"
-  CreateDirectory "$SMPROGRAMS\${PRODUCT_NAME}\Documentation"
-  WriteINIStr "$SMPROGRAMS\${PRODUCT_NAME}\Documentation\${PRODUCT_NAME} Windows Notes.url" "InternetShortcut" "URL" "http://openvpn.net/INSTALL-win32.html"
-  WriteINIStr "$SMPROGRAMS\${PRODUCT_NAME}\Documentation\${PRODUCT_NAME} Manual Page.url" "InternetShortcut" "URL" "http://openvpn.net/man.html"
-  WriteINIStr "$SMPROGRAMS\${PRODUCT_NAME}\Documentation\${PRODUCT_NAME} HOWTO.url" "InternetShortcut" "URL" "http://openvpn.net/howto.html"
-  WriteINIStr "$SMPROGRAMS\${PRODUCT_NAME}\Documentation\${PRODUCT_NAME} Web Site.url" "InternetShortcut" "URL" "http://openvpn.net/"
-  CreateShortCut "$SMPROGRAMS\${PRODUCT_NAME}\Uninstall ${PRODUCT_NAME}.lnk" "$INSTDIR\Uninstall.exe"
-
-SectionEnd
-
-;--------------------
-;Post-install section
-
-Section -post
-
-  SetOverwrite on
-
-  ; delete old tapinstall.exe
-  ;Delete "$INSTDIR\bin\tapinstall.exe"
-
-  ; Store README, license, icon
-  SetOverwrite on
-  SetOutPath $INSTDIR
-  File "..\INSTALL-win32.txt"
-  File "..\COPYRIGHT.GPL"
-  File "..\images\${PRODUCT_ICON}"
-
-  ; store sample config files
-  !ifdef SAMPCONF_DIR
-    SetOverwrite on
-    SetOutPath "$INSTDIR\config"
-  !ifdef SAMPCONF_CONF
-    File "${GEN}\conf\${SAMPCONF_CONF}"
-  !endif
-  !ifdef SAMPCONF_CONF2
-    File "${GEN}\conf\${SAMPCONF_CONF2}"
-  !endif
-  !ifdef SAMPCONF_P12
-    File "${GEN}\conf\${SAMPCONF_P12}"
-  !endif
-  !ifdef SAMPCONF_TA
-    File "${GEN}\conf\${SAMPCONF_TA}"
-  !endif
-  !ifdef SAMPCONF_CA
-    File "${GEN}\conf\${SAMPCONF_CA}"
-  !endif
-  !ifdef SAMPCONF_CRT
-    File "${GEN}\conf\${SAMPCONF_CRT}"
-  !endif
-  !ifdef SAMPCONF_KEY
-    File "${GEN}\conf\${SAMPCONF_KEY}"
-  !endif
-  !ifdef SAMPCONF_DH
-    File "${GEN}\conf\${SAMPCONF_DH}"
-  !endif
-  !endif
-
-  ; Try to extract files if present
-  !ifdef EXTRACT_FILES
-    Push "$INSTDIR"
-    Call MultiFileExtract
-    Pop $R0
-    IntCmp $R0 0 +3 +1 +1
-    DetailPrint "MultiFileExtract Failed status=$R0"
-    goto +2
-    DetailPrint "MultiFileExtract Succeeded"
-  !endif
-
-  ;
-  ; install/upgrade TAP driver if selected, using tapinstall.exe
-  ;
-  SectionGetFlags ${SecTAP} $R0
-  IntOp $R0 $R0 & ${SF_SELECTED}
-  IntCmp $R0 ${SF_SELECTED} "" notap notap
-    ; TAP install/update was selected.
-    ; Should we install or update?
-    ; If tapinstall error occurred, $5 will
-    ; be nonzero.
-    IntOp $5 0 & 0
-    nsExec::ExecToStack '"$INSTDIR\bin\tapinstall.exe" hwids ${TAP}'
-    Pop $R0 # return value/error/timeout
-    IntOp $5 $5 | $R0
-    DetailPrint "tapinstall hwids returned: $R0"
-
-    ; If tapinstall output string contains "${TAP}" we assume
-    ; that TAP device has been previously installed,
-    ; therefore we will update, not install.
-    Push "${TAP}"
-    Call StrStr
-    Pop $R0
-
-    IntCmp $5 0 "" tapinstall_check_error tapinstall_check_error
-    IntCmp $R0 -1 tapinstall
-
- ;tapupdate:
-    DetailPrint "TAP UPDATE"
-    nsExec::ExecToLog '"$INSTDIR\bin\tapinstall.exe" update "$INSTDIR\driver\OemWin2k.inf" ${TAP}'
-    Pop $R0 # return value/error/timeout
-    Call CheckReboot
-    IntOp $5 $5 | $R0
-    DetailPrint "tapinstall update returned: $R0"
-    Goto tapinstall_check_error
-
- tapinstall:
-    DetailPrint "TAP REMOVE OLD TAP"
-
-    nsExec::ExecToLog '"$INSTDIR\bin\tapinstall.exe" remove TAP0801'
-    Pop $R0 # return value/error/timeout
-    DetailPrint "tapinstall remove TAP0801 returned: $R0"
-
-    DetailPrint "TAP INSTALL (${TAP})"
-    nsExec::ExecToLog '"$INSTDIR\bin\tapinstall.exe" install "$INSTDIR\driver\OemWin2k.inf" ${TAP}'
-    Pop $R0 # return value/error/timeout
-    Call CheckReboot
-    IntOp $5 $5 | $R0
-    DetailPrint "tapinstall install returned: $R0"
-
- tapinstall_check_error:
-    DetailPrint "tapinstall cumulative status: $5"
-    IntCmp $5 0 notap
-    MessageBox MB_OK "An error occurred installing the TAP device driver."
-
- notap:
-
-  ; Store install folder in registry
-  WriteRegStr HKLM SOFTWARE\${PRODUCT_NAME} "" $INSTDIR
-
-  ; install as a service if requested
-  SectionGetFlags ${SecService} $R0
-  IntOp $R0 $R0 & ${SF_SELECTED}
-  IntCmp $R0 ${SF_SELECTED} "" noserv noserv
-
-    ; set registry parameters for openvpnserv
-    !insertmacro WriteRegStringIfUndef HKLM "SOFTWARE\${PRODUCT_NAME}" "config_dir"  "${SERV_CONFIG_DIR}"
-    !insertmacro WriteRegStringIfUndef HKLM "SOFTWARE\${PRODUCT_NAME}" "config_ext"  "${SERV_CONFIG_EXT}"
-    !insertmacro WriteRegStringIfUndef HKLM "SOFTWARE\${PRODUCT_NAME}" "exe_path"    "${SERV_EXE_PATH}"
-    !insertmacro WriteRegStringIfUndef HKLM "SOFTWARE\${PRODUCT_NAME}" "log_dir"     "${SERV_LOG_DIR}"
-    !insertmacro WriteRegStringIfUndef HKLM "SOFTWARE\${PRODUCT_NAME}" "priority"    "${SERV_PRIORITY}"
-    !insertmacro WriteRegStringIfUndef HKLM "SOFTWARE\${PRODUCT_NAME}" "log_append"  "${SERV_LOG_APPEND}"
-
-    ; install openvpnserv as a service (to be started manually from service control manager)
-    DetailPrint "Service INSTALL"
-    nsExec::ExecToLog '"$INSTDIR\bin\${PRODUCT_UNIX_NAME}serv.exe" -install'
-    Pop $R0 # return value/error/timeout
-
- noserv:
-
-  ; Create file association if requested
- fileass:
-  SectionGetFlags ${SecFileAssociation} $R0
-  IntOp $R0 $R0 & ${SF_SELECTED}
-  IntCmp $R0 ${SF_SELECTED} "" noass noass
-    WriteRegStr HKCR ".${SERV_CONFIG_EXT}" "" "${PRODUCT_NAME}File"
-    WriteRegStr HKCR "${PRODUCT_NAME}File" "" "${PRODUCT_NAME} Config File"
-    WriteRegStr HKCR "${PRODUCT_NAME}File\shell" "" "open"
-    WriteRegStr HKCR "${PRODUCT_NAME}File\DefaultIcon" "" "$INSTDIR\${PRODUCT_ICON},0"
-    WriteRegStr HKCR "${PRODUCT_NAME}File\shell\open\command" "" 'notepad.exe "%1"'
-    WriteRegStr HKCR "${PRODUCT_NAME}File\shell\run" "" "Start ${PRODUCT_NAME} on this config file"
-    WriteRegStr HKCR "${PRODUCT_NAME}File\shell\run\command" "" '"$INSTDIR\bin\${PRODUCT_UNIX_NAME}.exe" --pause-exit --config "%1"'
-
- ; Create start menu folders
- noass:
-  CreateDirectory "$SMPROGRAMS\${PRODUCT_NAME}\Utilities"
-  CreateDirectory "$SMPROGRAMS\${PRODUCT_NAME}\Shortcuts"
-
-  ; Create start menu and desktop shortcuts to OpenVPN GUI
-  !ifdef USE_GUI
-      CreateShortCut "$SMPROGRAMS\${PRODUCT_NAME}\${PRODUCT_NAME} GUI.lnk" "$INSTDIR\bin\${OPENVPN_GUI}" ""
-      CreateShortcut "$DESKTOP\${PRODUCT_NAME} GUI.lnk" "$INSTDIR\bin\${OPENVPN_GUI}"
-  !endif
-
- ; Create start menu shortcuts to addtap.bat and deltapall.bat
- tryaddtap:
-    IfFileExists "$INSTDIR\bin\addtap.bat" "" trydeltap
-      CreateShortCut "$SMPROGRAMS\${PRODUCT_NAME}\Utilities\Add a new TAP virtual ethernet adapter.lnk" "$INSTDIR\bin\addtap.bat" ""
-
- trydeltap:
-    IfFileExists "$INSTDIR\bin\deltapall.bat" "" config_shortcut
-      CreateShortCut "$SMPROGRAMS\${PRODUCT_NAME}\Utilities\Delete ALL TAP virtual ethernet adapters.lnk" "$INSTDIR\bin\deltapall.bat" ""
-
- ; Create start menu shortcuts for config and log directories
- config_shortcut:
-    IfFileExists "$INSTDIR\config" "" log_shortcut
-      CreateShortCut "$SMPROGRAMS\${PRODUCT_NAME}\Shortcuts\${PRODUCT_NAME} configuration file directory.lnk" "$INSTDIR\config" ""
-
- log_shortcut:
-    IfFileExists "$INSTDIR\log" "" samp_shortcut
-      CreateShortCut "$SMPROGRAMS\${PRODUCT_NAME}\Shortcuts\${PRODUCT_NAME} log file directory.lnk" "$INSTDIR\log" ""
-
- samp_shortcut:
-    IfFileExists "$INSTDIR\sample-config" "" genkey_shortcut
-      CreateShortCut "$SMPROGRAMS\${PRODUCT_NAME}\Shortcuts\${PRODUCT_NAME} Sample Configuration Files.lnk" "$INSTDIR\sample-config" ""
-
- genkey_shortcut:
-    IfFileExists "$INSTDIR\bin\${PRODUCT_UNIX_NAME}.exe" "" noshortcuts
-      IfFileExists "$INSTDIR\config" "" noshortcuts
-        CreateShortCut "$SMPROGRAMS\${PRODUCT_NAME}\Utilities\Generate a static ${PRODUCT_NAME} key.lnk" "$INSTDIR\bin\${PRODUCT_UNIX_NAME}.exe" '--pause-exit --verb 3 --genkey --secret "$INSTDIR\config\key.txt"' "$INSTDIR\${PRODUCT_ICON}" 0
-
- noshortcuts:
-  ; Create uninstaller
-  WriteUninstaller "$INSTDIR\Uninstall.exe"
-
-  ; Show up in Add/Remove programs
-  WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}" "DisplayName" "${PRODUCT_NAME} ${VERSION}"
-  WriteRegExpandStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}" "UninstallString" "$INSTDIR\Uninstall.exe"
-  WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}" "DisplayIcon" "$INSTDIR\${PRODUCT_ICON}"
-  WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}" "DisplayVersion" "${VERSION}"
-
-  ; Advise a reboot
-  ;Messagebox MB_OK "IMPORTANT: Rebooting the system is advised in order to finalize TAP driver installation/upgrade (this is an informational message only, pressing OK will not reboot)."
-
-SectionEnd
-
-;--------------------------------
-;Descriptions
-
-!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
-  !insertmacro MUI_DESCRIPTION_TEXT ${SecOpenVPNUserSpace} $(DESC_SecOpenVPNUserSpace)
-  !ifdef USE_GUI
-    !insertmacro MUI_DESCRIPTION_TEXT ${SecOpenVPNGUI} $(DESC_SecOpenVPNGUI)
-  !endif
-  !insertmacro MUI_DESCRIPTION_TEXT ${SecOpenVPNEasyRSA} $(DESC_SecOpenVPNEasyRSA)
-  !insertmacro MUI_DESCRIPTION_TEXT ${SecTAP} $(DESC_SecTAP)
-  !insertmacro MUI_DESCRIPTION_TEXT ${SecOpenSSLUtilities} $(DESC_SecOpenSSLUtilities)
-  !insertmacro MUI_DESCRIPTION_TEXT ${SecOpenSSLDLLs} $(DESC_SecOpenSSLDLLs)
-  !insertmacro MUI_DESCRIPTION_TEXT ${SecPKCS11DLLs} $(DESC_SecPKCS11DLLs)
-  !insertmacro MUI_DESCRIPTION_TEXT ${SecLZO2DLLs} $(DESC_SecLZO2DLLs)
-  !insertmacro MUI_DESCRIPTION_TEXT ${SecMSVCR90DLL} $(DESC_SecMSVCR90DLL)
-  !insertmacro MUI_DESCRIPTION_TEXT ${SecAddPath} $(DESC_SecAddPath)
-  !insertmacro MUI_DESCRIPTION_TEXT ${SecAddShortcuts} $(DESC_SecAddShortcuts)
-
-  !insertmacro MUI_DESCRIPTION_TEXT ${SecService} $(DESC_SecService)
-  !insertmacro MUI_DESCRIPTION_TEXT ${SecFileAssociation} $(DESC_SecFileAssociation)
-!insertmacro MUI_FUNCTION_DESCRIPTION_END
-
-;--------------------------------
-;Uninstaller Section
-
-Function un.onInit
-  ClearErrors
-  UserInfo::GetName
-  IfErrors ok
-  Pop $R0
-  UserInfo::GetAccountType
-  Pop $R1
-  StrCmp $R1 "Admin" ok
-    Messagebox MB_OK "Administrator privileges required to uninstall ${PRODUCT_NAME} [$R0/$R1]"
-    Abort
-  ok:
-FunctionEnd
-
-Section "Uninstall"
-
-  ; Required to handle shortcuts properly on Vista/7
-  SetShellVarContext all
-
-  ; Stop OpenVPN if currently running
-
-  DetailPrint "Service REMOVE"
-  nsExec::ExecToLog '"$INSTDIR\bin\${PRODUCT_UNIX_NAME}serv.exe" -remove'
-  Pop $R0 # return value/error/timeout
-
-  Sleep 3000
-
-  DetailPrint "TAP REMOVE"
-  nsExec::ExecToLog '"$INSTDIR\bin\tapinstall.exe" remove ${TAP}'
-  Pop $R0 # return value/error/timeout
-  DetailPrint "tapinstall remove returned: $R0"
-
-  Push "$INSTDIR\bin"
-  Call un.RemoveFromPath
-
-  RMDir /r $SMPROGRAMS\${PRODUCT_NAME}
-
-  ; delete sample config files
-  !ifdef SAMPCONF_DIR
-  !ifdef SAMPCONF_CONF
-    Delete "$INSTDIR\config\${SAMPCONF_CONF}"
-  !endif
-  !ifdef SAMPCONF_CONF2
-    Delete "$INSTDIR\config\${SAMPCONF_CONF2}"
-  !endif
-  !ifdef SAMPCONF_P12
-    Delete "$INSTDIR\config\${SAMPCONF_P12}"
-  !endif
-  !ifdef SAMPCONF_TA
-    Delete "$INSTDIR\config\${SAMPCONF_TA}"
-  !endif
-  !ifdef SAMPCONF_CA
-    Delete "$INSTDIR\config\${SAMPCONF_CA}"
-  !endif
-  !ifdef SAMPCONF_CRT
-    Delete "$INSTDIR\config\${SAMPCONF_CRT}"
-  !endif
-  !ifdef SAMPCONF_KEY
-    Delete "$INSTDIR\config\${SAMPCONF_KEY}"
-  !endif
-  !ifdef SAMPCONF_DH
-    Delete "$INSTDIR\config\${SAMPCONF_DH}"
-  !endif
-  !endif
-
-  !ifdef USE_GUI
-    Delete "$INSTDIR\bin\${OPENVPN_GUI}"
-    Delete "$DESKTOP\${PRODUCT_NAME} GUI.lnk"
-  !endif
-
-  # Files installed by openvpn-2.2-beta5 and earlier
-  Delete "$INSTDIR\easy-rsa\openssl.cnf.sample"
-  Delete "$INSTDIR\license"
-  Delete "$INSTDIR\bin\libssl32.dll"
-
-  Delete "$INSTDIR\bin\${PRODUCT_UNIX_NAME}.exe"
-  Delete "$INSTDIR\bin\${PRODUCT_UNIX_NAME}serv.exe"
-  Delete "$INSTDIR\bin\libeay32.dll"
-  Delete "$INSTDIR\bin\ssleay32.dll"
-  Delete "$INSTDIR\bin\libpkcs11-helper-1.dll"
-  Delete "$INSTDIR\bin\lzo2.dll"
-  Delete "$INSTDIR\bin\msvcr90.dll"
-  Delete "$INSTDIR\bin\Microsoft.VC90.CRT.manifest"
-  Delete "$INSTDIR\bin\tapinstall.exe"
-  Delete "$INSTDIR\bin\addtap.bat"
-  Delete "$INSTDIR\bin\deltapall.bat"
-
-  Delete "$INSTDIR\config\README.txt"
-  Delete "$INSTDIR\config\sample.${SERV_CONFIG_EXT}.txt"
-
-  Delete "$INSTDIR\log\README.txt"
-
-  Delete "$INSTDIR\driver\OemWin2k.inf"
-  Delete "$INSTDIR\driver\${PRODUCT_TAP_COMPONENT_ID}.cat"
-  Delete "$INSTDIR\driver\${TAPDRV}"
-
-  Delete "$INSTDIR\bin\openssl.exe"
-
-  Delete "$INSTDIR\INSTALL-win32.txt"
-  Delete "$INSTDIR\${PRODUCT_ICON}"
-  Delete "$INSTDIR\COPYRIGHT.GPL"
-  Delete "$INSTDIR\Uninstall.exe"
-
-  Delete "$INSTDIR\easy-rsa\openssl.cnf"
-  Delete "$INSTDIR\easy-rsa\vars.bat.sample"
-  Delete "$INSTDIR\easy-rsa\init-config.bat"
-  Delete "$INSTDIR\easy-rsa\README.txt"
-  Delete "$INSTDIR\easy-rsa\build-ca.bat"
-  Delete "$INSTDIR\easy-rsa\build-dh.bat"
-  Delete "$INSTDIR\easy-rsa\build-key-server.bat"
-  Delete "$INSTDIR\easy-rsa\build-key.bat"
-  Delete "$INSTDIR\easy-rsa\build-key-pkcs12.bat"
-  Delete "$INSTDIR\easy-rsa\clean-all.bat"
-  Delete "$INSTDIR\easy-rsa\index.txt.start"
-  Delete "$INSTDIR\easy-rsa\revoke-key.bat"
-  Delete "$INSTDIR\easy-rsa\revoke-full.bat"
-  Delete "$INSTDIR\easy-rsa\serial.start"
-
-  Delete "$INSTDIR\sample-config\*.${PRODUCT_FILE_EXT}"
-
-  RMDir "$INSTDIR\bin"
-  RMDir "$INSTDIR\config"
-  RMDir "$INSTDIR\driver"
-  RMDir "$INSTDIR\easy-rsa"
-  RMDir "$INSTDIR\sample-config"
-  RMDir /r "$INSTDIR\log"
-  RMDir "$INSTDIR"
-
-  !insertmacro DelRegKeyIfUnchanged HKCR ".${SERV_CONFIG_EXT}" "${PRODUCT_NAME}File"
-  DeleteRegKey HKCR "${PRODUCT_NAME}File"
-  DeleteRegKey HKLM SOFTWARE\${PRODUCT_NAME}
-  DeleteRegKey HKCU "Software\${PRODUCT_NAME}"
-  DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}"
-
-SectionEnd
win/setpath.nsi deleted +0 -231
deleted file mode 100755
index a9626c3..0000000
@@ -1,231 +0,0 @@
-; Modify the user's PATH variable.
-;
-; Modified by JY to have both a RemoveFromPath
-; and an un.RemoveFromPath which are basically
-; copies of each other.  Why does NSIS demand
-; this nonsense?
-;
-; Modified Feb 14, 2005 by Mathias Sundman:
-;   Added code to remove the semicolon at the end of the path
-;   when uninstalling.
-;
-;   Added code to make sure we don't insert an extra semicolon
-;   before our path if there already exist one at the end of
-;   the original path.
-;
-;   Removed duplicated "un. and install" functions and made
-;   macros to duplicate the code instead.
-
-; example usage
-;
-;Section "Add to path"
-;  Push $INSTDIR
-;  Call AddToPath
-;SectionEnd
-;
-;# ...
-;
-;Section "uninstall"
-;  # ...
-;  Push $INSTDIR
-;  Call un.RemoveFromPath
-;  # ...
-;SectionEnd
-
-!verbose 3
-!include "WinMessages.NSH"
-!verbose 4
-
-;====================================================
-; AddToPath - Adds the given dir to the search path.
-;        Input - head of the stack
-;        Note - Win9x systems requires reboot
-;====================================================
-Function AddToPath
-  Exch $0
-  Push $1
-  Push $2
-
-  Call IsNT
-  Pop $1
-  StrCmp $1 1 AddToPath_NT
-    ; Not on NT
-    StrCpy $1 $WINDIR 2
-    FileOpen $1 "$1\autoexec.bat" a
-    FileSeek $1 0 END
-    GetFullPathName /SHORT $0 $0
-    FileWrite $1 "$\r$\nSET PATH=%PATH%;$0$\r$\n"
-    FileClose $1
-    Goto AddToPath_done
-
-  AddToPath_NT:
-    ReadRegStr $1 HKCU "Environment" "PATH"
-    StrCpy $2 $1 1 -1 # copy last char
-    StrCmp $2 ";" 0 +2 # if last char == ;
-      StrCpy $1 $1 -1 # remove last char
-
-    StrCmp $1 "" AddToPath_NTdoIt
-      StrCpy $0 "$1;$0"
-      Goto AddToPath_NTdoIt
-    AddToPath_NTdoIt:
-      WriteRegExpandStr HKCU "Environment" "PATH" $0
-      SendMessage ${HWND_BROADCAST} ${WM_WININICHANGE} 0 "STR:Environment" /TIMEOUT=5000
-
-  AddToPath_done:
-    Pop $2
-    Pop $1
-    Pop $0
-FunctionEnd
-
-;====================================================
-; RemoveFromPath - Remove a given dir from the path
-;     Input: head of the stack
-;====================================================
-!macro RemoveFromPath un
-Function ${un}RemoveFromPath
-  Exch $0
-  Push $1
-  Push $2
-  Push $3
-  Push $4
-  Push $5
-
-  Call ${un}IsNT
-  Pop $1
-  StrCmp $1 1 RemoveFromPath_NT
-    ; Not on NT
-    StrCpy $1 $WINDIR 2
-    FileOpen $1 "$1\autoexec.bat" r
-    GetTempFileName $4
-    FileOpen $2 $4 w
-    GetFullPathName /SHORT $0 $0
-    StrCpy $0 "SET PATH=%PATH%;$0"
-    SetRebootFlag true
-    Goto RemoveFromPath_dosLoop
-
-    RemoveFromPath_dosLoop:
-      FileRead $1 $3
-      StrCmp $3 "$0$\r$\n" RemoveFromPath_dosLoop
-      StrCmp $3 "$0$\n" RemoveFromPath_dosLoop
-      StrCmp $3 "$0" RemoveFromPath_dosLoop
-      StrCmp $3 "" RemoveFromPath_dosLoopEnd
-      FileWrite $2 $3
-      Goto RemoveFromPath_dosLoop
-
-    RemoveFromPath_dosLoopEnd:
-      FileClose $2
-      FileClose $1
-      StrCpy $1 $WINDIR 2
-      Delete "$1\autoexec.bat"
-      CopyFiles /SILENT $4 "$1\autoexec.bat"
-      Delete $4
-      Goto RemoveFromPath_done
-
-  RemoveFromPath_NT:
-    StrLen $2 $0
-    ReadRegStr $1 HKCU "Environment" "PATH"
-    Push $1
-    Push $0
-    Call ${un}StrStr ; Find $0 in $1
-    Pop $0 ; pos of our dir
-    IntCmp $0 -1 RemoveFromPath_done
-      ; else, it is in path
-      StrCpy $3 $1 $0 ; $3 now has the part of the path before our dir
-      IntOp $2 $2 + $0 ; $2 now contains the pos after our dir in the path (';')
-      IntOp $2 $2 + 1 ; $2 now containts the pos after our dir and the semicolon.
-      StrLen $0 $1
-      StrCpy $1 $1 $0 $2
-      StrCpy $3 "$3$1"
-
-      StrCpy $5 $3 1 -1 # copy last char
-      StrCmp $5 ";" 0 +2 # if last char == ;
-        StrCpy $3 $3 -1 # remove last char
-
-      WriteRegExpandStr HKCU "Environment" "PATH" $3
-      SendMessage ${HWND_BROADCAST} ${WM_WININICHANGE} 0 "STR:Environment" /TIMEOUT=5000
-
-  RemoveFromPath_done:
-    Pop $5
-    Pop $4
-    Pop $3
-    Pop $2
-    Pop $1
-    Pop $0
-FunctionEnd
-!macroend
-!insertmacro RemoveFromPath ""
-!insertmacro RemoveFromPath "un."
-
-
-;====================================================
-; StrStr - Finds a given string in another given string.
-;               Returns -1 if not found and the pos if found.
-;          Input: head of the stack - string to find
-;                      second in the stack - string to find in
-;          Output: head of the stack
-;====================================================
-!macro StrStr un
-Function ${un}StrStr
-  Push $0
-  Exch
-  Pop $0 ; $0 now have the string to find
-  Push $1
-  Exch 2
-  Pop $1 ; $1 now have the string to find in
-  Exch
-  Push $2
-  Push $3
-  Push $4
-  Push $5
-
-  StrCpy $2 -1
-  StrLen $3 $0
-  StrLen $4 $1
-  IntOp $4 $4 - $3
-
-  StrStr_loop:
-    IntOp $2 $2 + 1
-    IntCmp $2 $4 0 0 StrStrReturn_notFound
-    StrCpy $5 $1 $3 $2
-    StrCmp $5 $0 StrStr_done StrStr_loop
-
-  StrStrReturn_notFound:
-    StrCpy $2 -1
-
-  StrStr_done:
-    Pop $5
-    Pop $4
-    Pop $3
-    Exch $2
-    Exch 2
-    Pop $0
-    Pop $1
-FunctionEnd
-!macroend
-!insertmacro StrStr ""
-!insertmacro StrStr "un."
-
-;====================================================
-; IsNT - Returns 1 if the current system is NT, 0
-;        otherwise.
-;     Output: head of the stack
-;====================================================
-!macro IsNT un
-Function ${un}IsNT
-  Push $0
-  ReadRegStr $0 HKLM "SOFTWARE\Microsoft\Windows NT\CurrentVersion" CurrentVersion
-  StrCmp $0 "" 0 IsNT_yes
-  ; we are not NT.
-  Pop $0
-  Push 0
-  Return
-
-  IsNT_yes:
-    ; NT!!!
-    Pop $0
-    Push 1
-FunctionEnd
-!macroend
-!insertmacro IsNT ""
-!insertmacro IsNT "un."
-
win/settings.in deleted +0 -100
deleted file mode 100644
index 79033dd..0000000
@@ -1,100 +0,0 @@
-# Version numbers, settings, and dependencies
-# for Windows OpenVPN installer.
-#
-# Note that some variables are parsed by wb.py from version.m4 and are not
-# stored in this file. This is done to allow using the old and new Windows build
-# systems side-by-side
-
-# Features to include. DO NOT comment these out, use 1 to enable and 0 to
-# disable.
-!define ENABLE_PASSWORD_SAVE 1
-
-# ENABLE_CLIENT_SERVER enables the point-to-multipoint support. Normally you
-# want to have this enabled.
-!define ENABLE_CLIENT_SERVER 1
-
-# ENABLE_CLIENT_ONLY removes server-side point-to-multipoint features. This
-# depends on ENABLE_CLIENT_SERVER being set to 1.
-!define ENABLE_CLIENT_ONLY 0
-
-!define ENABLE_MANAGEMENT 1
-!define ENABLE_HTTP_PROXY 1
-!define ENABLE_SOCKS 1
-!define ENABLE_FRAGMENT 1
-!define ENABLE_DEBUG 1
-
-# Branding
-!define PRODUCT_NAME      "OpenVPN"
-!define PRODUCT_UNIX_NAME "openvpn"
-!define PRODUCT_FILE_EXT  "ovpn"
-
-# Include the OpenVPN GUI exe in the installer. Comment out USE_GUI to disable.
-!define USE_GUI
-!define OPENVPN_GUI_DIR "../openvpn-gui"
-!define OPENVPN_GUI     "openvpn-gui-1.0.3.exe"
-
-# Use either PolarSSL or OpenSSL. Only one may be active at a time
-!define USE_POLARSSL 0
-!define USE_OPENSSL 1
-
-# The same as above, but for library inclusion (must be defined/undefined due to build system)
-;!define INCLUDE_POLARSSL
-!define INCLUDE_OPENSSL
-
-# Uncomment to use the PKCS#11 helper library
-!define USE_PKCS11 0
-;!define INCLUDE_PKCS11
-
-# Prebuilt libraries.  DMALLOC is optional.
-!define OPENSSL_DIR      "../openssl"
-!define POLARSSL_DIR     "../polarssl"
-!define LZO_DIR                  "../lzo"
-!define PKCS11_HELPER_DIR "../pkcs11-helper"
-
-# write output files here
-!define DIST   "dist"
-
-# tapinstall.exe (a.k.a. devcon.exe) source code. Not needed if DRVBINSRC is
-# defined (or if using pre-built mode).
-!define TISRC  "../tapinstall"
-
-# TAP adapter icon -- visible=0x81 or hidden=0x89
-!define PRODUCT_TAP_CHARACTERISTICS     0x81
-
-# TAP adapter metadata. Version information in ../version.m4.
-!define PRODUCT_TAP_RELDATE    "04/19/2010"
-!define PRODUCT_TAP_DEVICE_DESCRIPTION    "TAP-Win32 Adapter V9"
-!define PRODUCT_TAP_PROVIDER    "TAP-Win32 Provider V9"
-
-# 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"
-
-# Directory with prebuilt TAP drivers and tapinstall.exes
-!define TAP_PREBUILT "../tap-prebuilt"
-
-; DEBUGGING -- set to something like "-DBG2"
-!define OUTFILE_LABEL ""
-
-; DEBUGGING -- set to something like "DEBUG2"
-!define TITLE_LABEL ""
win/show.py deleted +0 -9
deleted file mode 100644
index ac56e98..0000000
@@ -1,9 +0,0 @@
-from wb import get_config
-from js import JSON
-
-def main():
-    print JSON().encode(get_config())
-
-# if we are run directly, and not loaded as a module
-if __name__ == "__main__":
-    main()
win/sign.py deleted +0 -23
deleted file mode 100644
index a80bf98..0000000
@@ -1,23 +0,0 @@
-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, tap_dir):
-    from signtool import SignTool
-    st = SignTool(conf, tap_dir)
-    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:
-        if len(sys.argv) >= 3:
-            tap_dir = home_fn(sys.argv[2])
-        else:
-            tap_dir = None
-        main(config, sys.argv[1], tap_dir)
-    else:
-        print "usage: sign <x64|x86|all> [tap-dir]"
-        sys.exit(2)
win/tap_span.py deleted +0 -129
deleted file mode 100644
index 749f6f3..0000000
@@ -1,129 +0,0 @@
-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 == 'devcon.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()
win/wb.py deleted +0 -323
deleted file mode 100644
index 39eadec..0000000
@@ -1,322 +0,0 @@
-# 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 get_build_params():
-    kv = {}
-    parse_build_params(kv,mod_fn('settings.in'))
-
-    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 cd_service_win32():
-    os.chdir(os.path.join(os.path.dirname(__file__), '../service-win32'))
-
-def system(cmd):
-    print "RUN:", cmd
-    os.system(cmd)
-
-def run_in_vs_shell(cmd):
-    """Make sure environment variables are setup before running command"""
-    os.environ['PATH'] += ";%s\\VC" % (os.path.normpath(config['MSVC']),)
-    system('cmd /c "vcvarsall.bat x86 && %s"' % (cmd,))
-
-def parse_version_m4(kv, version_m4):
-    '''Parse define lines in 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()
-
-            # If we encounter PRODUCT_TAP_WIN32_MIN_MAJOR or
-            # PRODUCT_TAP_WIN32_MIN_MAJOR then we need to generate extra
-            # variables, PRODUCT_TAP_MAJOR_VER and PRODUCT_TAP_MINOR_VER with
-            # the same contents. This is necessary because tap-win32/tapdrv.c
-            # build depends on those.
-            if g[0] == 'PRODUCT_TAP_WIN32_MIN_MAJOR':
-                kv['PRODUCT_TAP_MAJOR_VER'] = g[1]
-            elif g[0] == 'PRODUCT_TAP_WIN32_MIN_MINOR':
-                kv['PRODUCT_TAP_MINOR_VER'] = g[1]
-
-            # Add the variable to build configuration
-            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 parse_build_params(kv, settings_in):
-    r = re.compile(r'^!define\s+(ENABLE_\w+)\s+(\w+)')
-
-    f = open(settings_in)
-
-    for line in f:
-        line = line.rstrip()
-
-        # Check if this is a #define line starts with ENABLE_
-        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 build_config_h(kv):
-    """Generate static win/config.h to config.h to mimic autotools behavior"""
-    preprocess(kv,
-               in_fn=mod_fn('config.h.in'),
-               out_fn=home_fn('config.h'),
-               quote_begin='@',
-               quote_end='@',
-               head_comment='/* %s */\n\n' % autogen)
-
-def build_configure_h(kv, configure_h_out, head_comment):
-    """Generate a configure.h dynamically"""
-    fout = open(configure_h_out, 'w')
-
-    # These two variables are required to view build parameters during runtime
-    configure_defines='#define CONFIGURE_DEFINES \"'
-    configure_call='#define CONFIGURE_CALL \" config_all.py \"'
-
-    # Initialize the list of enabled features
-    features = ''
-
-    # Write the header
-    fout.write(head_comment)
-
-    dict = get_build_params()
-
-    for key, value in dict.iteritems():
-        # Add enabled features
-       features = features + "#define " + key + " " + value + "\n"
-
-       # Add each enabled feature to CONFIGURE_DEFINES list
-        configure_defines = configure_defines + " " + key + "=" + value + ","
-
-    configure_defines = configure_defines + "\"" + "\n"
-
-    fout.write(features)
-    fout.write(configure_defines)
-    fout.write(configure_call)
-
-
-    fout.close()
-
-def build_version_m4_vars(version_m4_vars_out, head_comment):
-    """Generate a temporary file containing variables from version.m4 in
-win/settings.in format. This done to allow importing them in win/openvpn.nsi"""
-
-    fout = open(version_m4_vars_out, 'w')
-    fout.write(head_comment)
-
-    kv = {}
-    parse_version_m4(kv, home_fn('version.m4'))
-
-    for key, value in kv.iteritems():
-         line = "!define " + key + "\t" + "\"" + value + "\"" + "\n"
-         fout.write(line)
-
-    fout.close()
-
-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):
-    """Parse ../Makefile.am to obtain a list of .h and .c files"""
-    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):
-    """Generate HEADER and OBJS entries dynamically from ../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 rename(src, dest):
-    print "RENAME %s %s" % (src, dest)
-    shutil.move(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()
--

1.7.3.4

------------------------------------------------------------------------------
Virtualization & Cloud Management Using Capacity Planning Cloud computing makes use of virtualization - but cloud computing also focuses on allowing computing to be delivered as a service.
http://www.accelacomm.com/jaw/sfnl/114/51521223/
_______________________________________________
Openvpn-devel mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel

#18 lore raw

Re: [Openvpn-devel] [PATCH 09/52] cleanup: memcmp.c: remove unused source

In reply to Samuli Seppänen

Not exactly.
This file is needed for VERY old libc implementations. I don't think these exists anymore in supported configurations. If we find memcmp() is missing, we add it properly to compat.

2012/3/6 Samuli Seppänen <[email protected]...>:

Quoted 89 lines
Quoted 61 lines

---
 configure.ac |    3 ---
 memcmp.c     |   43 -------------------------------------------

 2 files changed, 0 insertions(+), 46 deletions(-)

 delete mode 100644 memcmp.c

configure.ac +0 -0
index 25dcc37..1c4d66c 100644
@@ -564,9 +564,6 @@ else
 

 fi

configure.ac +0 -3
-dnl Required library functions
-AC_FUNC_MEMCMP
-

 dnl
 dnl Check for res_init
 dnl

memcmp.c deleted +0 -33
deleted file mode 100644
index d921aac..0000000
@@ -1,43 +0,0 @@
-/*
- *  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. <[email protected]...>
- *
- *  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"
-
-#include "memdbg.h"
-
-int
-memcmp (const void *s1, const void *s2, size_t n)
-{
-  unsigned const char *p1 = s1, *p2 = s2;
-  int d;

memcmp.c line 43

Quoted 10 lines
memcmp.c deleted +0 -10
-
-  if (n)
-    while (n-- > 0)
-      {
-     d = *p1++ - *p2++;
-     if (d != 0)
-       return d;
-      }
-  return 0;
-}

My C-fu is fairly low, but this still seems to make sense as there's no memcmp.h. The memcmp function calls in other source files seem to use memcmp function stored elsewhere (gcc[1], libc[2], etc.).

ACK.

--
Samuli Seppänen
Community Manager
OpenVPN Technologies, Inc

irc freenode net: mattock

[1] <http://justin.harmonize.fm/index.php/2009/05/exploring-memcmp>
[2]
<http://www.slac.stanford.edu/comp/unix/package/rtems/doc/html/libc/libc.info.memcmp.html>

#8 lore raw

Re: [Openvpn-devel] [PATCH 04/52] cleanup: remove C++ warnings

In reply to Samuli Seppänen

2012/3/6 Samuli Seppänen <[email protected]...>:

Quoted 3 lines

Although this commenting style has been valid in C since C99 (year 2000), the actual C99 implementations seem to be incomplete[2]. So, just to be on the safe side, I'll give this one an ACK.

As long as we need to support old machines, we need to support C89. There is much work to be done to cleanup warnings gcc produces using -pendatic -Wall -Wextra.
But cleaning these will improve the ability to find issues.

Alon.

#30 lore raw

Re: [Openvpn-devel] [PATCH 16/52] build: we need the sample.ovpn in future

In reply to Samuli Seppänen

2012/3/6 Samuli Seppänen <[email protected]...>:

Quoted 2 lines

Just wondering... why not move sample.ovpn to "sample-config-files" directory?

Because I did not want to change the sample-config-files... This was windows specific so I left it windows specific.

If you want reorder of example, I will be happy to do any other way.

Alon.

#19 lore raw

Re: [Openvpn-devel] [PATCH 09/52] cleanup: memcmp.c: remove unused source

In reply to Alon Bar-Lev

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Quoted 3 lines · Alon Bar-Lev

Not exactly. This file is needed for VERY old libc implementations. I don't think these exists anymore in supported configurations. If we find memcmp() is missing, we add it properly to compat.

Agreed, and I also ACKed this one in the first round. This is basically dead code in the vast majority of platforms. Bear in mind that OpenVPN was released about a decade ago, "a few" things have changed since then ;-)

This patch goes in.

kind regards,

David Sommerseth

Quoted 6 lines

2012/3/6 Samuli Seppänen <[email protected]...>:

Quoted 5 lines
Quoted 5 lines

configure.ac | 3 --- memcmp.c | 43
------------------------------------------- 2 files changed, 0 insertions(+), 46 deletions(-) delete mode 100644 memcmp.c

[..snip..]

Quoted 12 lines
Quoted 12 lines

My C-fu is fairly low, but this still seems to make sense as there's no memcmp.h. The memcmp function calls in other source files seem to use memcmp function stored elsewhere (gcc[1], libc[2], etc.).

ACK.

-- Samuli Seppänen Community Manager OpenVPN Technologies, Inc

irc freenode net: mattock

Quoted 8 lines
Quoted 5 lines

[1] <http://justin.harmonize.fm/index.php/2009/05/exploring-memcmp>
[2]
<http://www.slac.stanford.edu/comp/unix/package/rtems/doc/html/libc/libc.info.memcmp.html>

------------------------------------------------------------------------------

Keep Your Developer Skills Current with LearnDevNow!

Quoted 8 lines

The most comprehensive online learning library for Microsoft developers is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3, Metro Style Apps, more. Free future releases when you subscribe now! http://p.sf.net/sfu/learndevnow-d2d
_______________________________________________ Openvpn-devel mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk9WC1sACgkQDC186MBRfrpwggCfahRiNIZZrCssyxWqOgCJPi+c r0gAoJeO5E5MqyggxsCPNSDXPy9SC6eU
=Em9/
-----END PGP SIGNATURE-----

#47 lore raw

Re: [Openvpn-devel] [PATCH 27/52] build: autoconf: remove OPENVPN_ADD_LIBS useless macro

In reply to Alon Bar-Lev

Looks fairly straightforward: the OPENVPN_ADD_LIBS(LIB) macro[1] from "acinclude.m4" is being phased out, e.g.

OPENVPN_ADD_LIBS(-ldmalloc)

becomes

LIBS="${LIBS} -ldmalloc"

I don't think the macro does anything _that_ special it would be worth saving.

ACK.

Signature · 13 lines
Samuli Seppänen
Community Manager
OpenVPN Technologies, Inc

irc freenode net: mattock


[1]

dnl OPENVPN_ADD_LIBS(LIB)
AC_DEFUN([OPENVPN_ADD_LIBS], [
  LIBS="$1 $LIBS"
])
Quoted 117 lines
---
 configure.ac         |   26 ++++++++++----------------
 m4/ax_openvpn_lib.m4 |    4 ----
 2 files changed, 10 insertions(+), 20 deletions(-)
 delete mode 100644 m4/ax_openvpn_lib.m4
configure.ac +10 -16
index 07b2e1a..81bf933 100644
@@ -352,13 +352,7 @@ case "$host" in
 		AC_DEFINE_UNQUOTED([TARGET_PREFIX], ["W"], [Target prefix])
 		CPPFLAGS="${CPPFLAGS} -DWIN32_LEAN_AND_MEAN -DWINVER=0x0501"
 		WIN32=yes
-		OPENVPN_ADD_LIBS(-lgdi32)
-		OPENVPN_ADD_LIBS(-lws2_32)
-		OPENVPN_ADD_LIBS(-lwininet)
-		OPENVPN_ADD_LIBS(-lcrypt32)
-		OPENVPN_ADD_LIBS(-liphlpapi)
-		OPENVPN_ADD_LIBS(-lwinmm)
-		OPENVPN_ADD_LIBS(-lshell32)
+		LIBS="${LIBS} -lgdi32 -lws2_32 -lwininet -lcrypt32 -liphlpapi -lwinmm -lshell32"
 		;;
 	*-*-dragonfly*)
 		AC_DEFINE([TARGET_DRAGONFLY], [1], [Are we running on DragonFlyBSD?])
@@ -640,7 +634,7 @@ case "${with_mem_check}" in
 				[dmalloc],
 				[malloc],
 				[
-					OPENVPN_ADD_LIBS(-ldmalloc)
+					LIBS="${LIBS} -ldmalloc"
 					AC_DEFINE(
 						[DMALLOC],
 						[1],
@@ -682,7 +676,7 @@ if test "${WIN32}" != "yes" -a "${enable_plugins}" = "yes"; then
 				[dl],
 				[dlopen],
 				[
-					OPENVPN_ADD_LIBS(-ldl)
+					LIBS="${LIBS} -ldl"
 					AC_DEFINE(USE_LIBDL, 1, [Use libdl for dynamic library loading])
 				],
 				[AC_MSG_RESULT([libdl library not found.])]
@@ -721,7 +715,7 @@ if test "${enable_lzo}" = "yes" && test "${enable_lzo_stub}" = "no"; then
 	if test $havelzolib = 1 ; then break ; fi
 	AC_CHECK_LIB($i, lzo1x_1_15_compress,
           [
-	    OPENVPN_ADD_LIBS(-l$i)
+	    LIBS="${LIBS} -l$i"
 	    AC_DEFINE(USE_LZO, 1, [Use LZO compression library])
 	    AC_DEFINE_UNQUOTED(LZO_VERSION_NUM, "$LZO_H", [LZO version number])
 	    havelzolib=1
@@ -752,7 +746,7 @@ if test "${enable_pkcs11}" = "yes"; then
 	[AC_CHECK_LIB(pkcs11-helper, pkcs11h_initialize,
 	    [
 		   AC_DEFINE(USE_PKCS11, 1, [Enable PKCS11 capability])
-		   OPENVPN_ADD_LIBS(-lpkcs11-helper)
+		   LIBS="${LIBS} -lpkcs11-helper"
 	    ],
 	    [AC_MSG_RESULT([pkcs11-helper library not found.])]
 	)],
@@ -773,7 +767,7 @@ if test "${enable_crypto}" = "yes"; then
           AC_CHECK_LIB($lib, EVP_CIPHER_CTX_init,
                 [
             		cryptofound=1
-            		OPENVPN_ADD_LIBS(-l$lib)
+			LIBS="${LIBS} -l$lib"
     	        ]
           )
        done
@@ -807,7 +801,7 @@ if test "${enable_crypto}" = "yes"; then
         AC_CHECK_HEADER(polarssl/aes.h,
             [AC_CHECK_LIB(polarssl, aes_crypt_cbc,
                 [
-                    OPENVPN_ADD_LIBS(-lpolarssl)
+		    LIBS="${LIBS} -lpolarssl"
                     AC_DEFINE(USE_CRYPTO, 1, [Use crypto library])
                     AC_DEFINE(USE_POLARSSL, 1, [Use PolarSSL library])
                 ],
@@ -831,7 +825,7 @@ if test "${enable_crypto}" = "yes"; then
 	     AC_CHECK_LIB($lib, SSL_CTX_new,
 		   [
 			   sslfound=1
-			   OPENVPN_ADD_LIBS(-l$lib)
+			   LIBS="${LIBS} -l$lib"
 		   ]
 	     )
          done
@@ -845,7 +839,7 @@ if test "${enable_crypto}" = "yes"; then
          AC_CHECK_HEADER(polarssl/ssl.h,
               [AC_CHECK_LIB(polarssl, ssl_init,
               [
-                  OPENVPN_ADD_LIBS(-lpolarssl)
+		  LIBS="${LIBS} -lpolarssl"
                   AC_DEFINE(USE_SSL, 1, [Use SSL library])
                   AC_DEFINE(USE_POLARSSL, 1, [Use PolarSSL library])
               ],
@@ -867,7 +861,7 @@ if test "${enable_selinux}" = "yes"; then
 			[selinux],
 			[setcon],
 			[
-				OPENVPN_ADD_LIBS(-lselinux)
+				LIBS="${LIBS} -lselinux"
 				AC_DEFINE(HAVE_SETCON, 1, [SELinux support])
 			],
 			[AC_MSG_RESULT([SELinux library not found.])]
m4/ax_openvpn_lib.m4 deleted +0 -4
deleted file mode 100644
index bcfe1ab..0000000
@@ -1,4 +0,0 @@
-dnl OPENVPN_ADD_LIBS(LIB)
-AC_DEFUN([OPENVPN_ADD_LIBS], [
-  LIBS="$1 $LIBS"
-])
#49 lore raw

Re: [Openvpn-devel] [PATCH 28/52] build: remove awk and non-standard autoconf output processing

In reply to Alon Bar-Lev

This looks ok. If I understood it correctly, earlier the Makefile called configure_h.awk to parse config.h to generate configure.h. This configure.h file contained only two defines:

#define CONFIGURE_DEFINES " ENABLE_CLIENT_SERVER ENABLE_DEBUG ENABLE_EUREPHIA ..." #define CONFIGURE_CALL " $ ./configure "

This patch removes configure_h.awk and thus phases out configure.h. After this change CONFIGURE_DEFINES is generated using this method:

CONFIGURE_DEFINES="set | grep '^enable_.*=' ; set | grep '^with_.*='"

This should be safe if running "set" does not produce output that would match the regexps without being related to the OpenVPN builds. Given that the regexps are very strictly defined, that doesn't sound likely.

I give this one an ACK. Please NACK if you disagree :).

Signature · 5 lines
Samuli Seppänen
Community Manager
OpenVPN Technologies, Inc

irc freenode net: mattock
Quoted 170 lines

Replace with simpler environment solution.

---
 Makefile.am       |   12 ++----------
 configure.ac      |    3 +++
 configure_h.awk   |   39 ---------------------------------------
 configure_log.awk |   33 ---------------------------------
 options.c         |    4 ----
 5 files changed, 5 insertions(+), 86 deletions(-)
 delete mode 100644 configure_h.awk
 delete mode 100644 configure_log.awk
Makefile.am +2 -10
index 6c0b2b4..a8ff457 100644
@@ -36,7 +36,7 @@ MAINTAINERCLEANFILES = \
 	$(srcdir)/depcomp $(srcdir)/aclocal.m4 \
 	$(srcdir)/config.guess $(srcdir)/config.sub \
 	$(srcdir)/openvpn.spec
-CLEANFILES = openvpn.8.html configure.h
+CLEANFILES = openvpn.8.html
 
 EXTRA_DIST = \
 	sample-config-files \
@@ -57,8 +57,7 @@ dist_doc_DATA = \
 
 dist_noinst_SCRIPTS = \
 	$(TESTS) \
-	t_cltsrv-down.sh \
-	configure_h.awk configure_log.awk
+	t_cltsrv-down.sh
 
 dist_doc_DATA = \
 	COPYRIGHT.GPL \
@@ -156,13 +155,6 @@ openvpn_SOURCES = \
 	win32.h win32.c \
 	cryptoapi.h cryptoapi.c
 
-nodist_openvpn_SOURCES = configure.h
-options.$(OBJEXT): configure.h
-
-configure.h: Makefile
-	awk -f $(srcdir)/configure_h.awk config.h > $@
-	awk -f $(srcdir)/configure_log.awk config.log >> $@
-
 if WIN32
 dist_noinst_DATA += openvpn.8
 nodist_html_DATA = openvpn.8.html
configure.ac +3 -0
index 81bf933..0b70325 100644
@@ -913,6 +913,9 @@ if test "${enable_strict}" = "yes"; then
 	CFLAGS="${CFLAGS} -Wall -Wno-unused-parameter -Wno-unused-function"
 fi
 
+CONFIGURE_DEFINES="`set | grep '^enable_.*=' ; set | grep '^with_.*='`"
+AC_DEFINE_UNQUOTED([CONFIGURE_DEFINES], ["`echo ${CONFIGURE_DEFINES}`"], [Configuration settings])
+
 TAP_WIN_COMPONENT_ID="PRODUCT_TAP_WIN_COMPONENT_ID"
 TAP_WIN_MIN_MAJOR="PRODUCT_TAP_WIN_MIN_MAJOR"
 TAP_WIN_MIN_MINOR="PRODUCT_TAP_WIN_MIN_MINOR"
configure_h.awk deleted +0 -39
deleted file mode 100644
index 672e745..0000000
@@ -1,39 +0,0 @@
-#
-#  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) 2010  David Sommerseth <[email protected]...>
-#
-#  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
-#
-#
-#  This script will build up a line which can be included into a C program.
-#  The line will contain all interesting #define statements from f.ex. ./config.h
-#
-
-BEGIN {
-	printf ("#define CONFIGURE_DEFINES \"")
-}
-
-/^#define (ENABLE|DISABLE|DEPRECATED|USE)_/ {
-	printf (" %s", $2)
-}
-
-END {
-	printf ("\"\n")
-}
configure_log.awk deleted +0 -33
deleted file mode 100644
index 099e5c4..0000000
@@ -1,33 +0,0 @@
-#
-#  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) 2010  David Sommerseth <[email protected]...>
-#
-#  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
-#
-#
-#  This script will build up a line which can be included into a C program.
-#  The line will only contain the first entry of the ./configure line from
-#  ./config.log.
-#
-
-/\$ (.*)\/configure/ {
-	printf ("#define CONFIGURE_CALL \"%s\"\n", $0)
-	exit 0
-}
options.c +0 -4
index b0ae7fd..d7f848e 100644
@@ -49,7 +49,6 @@
 #include "helper.h"
 #include "manage.h"
 #include "forward.h"
-#include "configure.h"
 #include <ctype.h>
 
 #include "memdbg.h"
@@ -3403,9 +3402,6 @@ usage_version (void)
   msg (M_INFO|M_NOPREFIX, "Originally developed by James Yonan");
   msg (M_INFO|M_NOPREFIX, "Copyright (C) 2002-2010 OpenVPN Technologies, Inc. <[email protected]...>");
 #ifndef ENABLE_SMALL
-#ifdef CONFIGURE_CALL
-  msg (M_INFO|M_NOPREFIX, "\n%s\n", CONFIGURE_CALL);
-#endif
 #ifdef CONFIGURE_DEFINES
   msg (M_INFO|M_NOPREFIX, "Compile time defines: %s", CONFIGURE_DEFINES);
 #endif
#55 lore raw

Re: [Openvpn-devel] [PATCH 31/52] build: autoconf: commands as environment

In reply to Alon Bar-Lev

So, this patch replaces (removes?) the "--with-<executable>-path" configure options with environment variables, right? For example, if one has "ifconfig" in a non-standard place, he can set the IFCONFIG environment variable and the build will find it. Did I understand this correctly?

I don't know autotools well enough to give this one an ACK at this point. That said, the patch does clean up configure.ac a lot, and cleanups are always nice :).

Signature · 5 lines
Samuli Seppänen
Community Manager
OpenVPN Technologies, Inc

irc freenode net: mattock
Quoted 110 lines
---
 configure.ac |   66 ++++++++++++++++++++++++---------------------------------
 1 files changed, 28 insertions(+), 38 deletions(-)
configure.ac +28 -38
index 6b5cf71..ed98464 100644
@@ -267,37 +267,6 @@ AC_ARG_WITH(
 )
 
 AC_ARG_WITH(
-	[ifconfig-path],
-	[AS_HELP_STRING([--with-ifconfig-path=PATH], [Path to ifconfig tool])],
-	[IFCONFIG="$withval"],
-	[AC_PATH_PROG([IFCONFIG], [ifconfig], [ifconfig], [$PATH:/usr/local/sbin:/usr/sbin:/sbin])]
-)
-AC_DEFINE_UNQUOTED([IFCONFIG_PATH], ["$IFCONFIG"], [Path to ifconfig tool])
-
-AC_ARG_WITH(
-	[iproute-path],
-	[AS_HELP_STRING([--with-iproute-path=PATH], [Path to iproute tool])],
-	[IPROUTE="$withval"],
-	[AC_PATH_PROG([IPROUTE], [ip], [ip], [$PATH:/usr/local/sbin:/usr/sbin:/sbin])]
-)
-AC_DEFINE_UNQUOTED([IPROUTE_PATH], ["$IPROUTE"], [Path to iproute tool])
-
-AC_ARG_WITH([route-path],
-   [AS_HELP_STRING([--with-route-path=PATH], [Path to route tool])],
-   [ROUTE="$withval"],
-   [AC_PATH_PROG([ROUTE], [route], [route], [$PATH:/usr/local/sbin:/usr/sbin:/sbin])]
-)
-AC_DEFINE_UNQUOTED([ROUTE_PATH], ["$ROUTE"], [Path to route tool])
-
-AC_ARG_WITH(
-	[netstat-path],
-	[AS_HELP_STRING([--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],
 	[AS_HELP_STRING([--with-mem-check=TYPE], [build with debug memory checking, TYPE=dmalloc|valgrind|ssl])],
 	[
@@ -370,6 +339,20 @@ AC_PROG_INSTALL
 AC_PROG_LN_S
 AC_PROG_MAKE_SET
 
+AC_ARG_VAR([IFCONFIG], [full path to ipconfig utility])
+AC_ARG_VAR([ROUTE], [full path to route utility])
+AC_ARG_VAR([IPROUTE], [full path to ip utility])
+AC_ARG_VAR([NETSTAT], [path to netstat utility]) # tests
+AC_ARG_VAR([MAN2HTML], [path to man2html utility])
+AC_PATH_PROGS([IFCONFIG], [ifconfig],, [$PATH:/usr/local/sbin:/usr/sbin:/sbin])
+AC_PATH_PROGS([ROUTE], [route],, [$PATH:/usr/local/sbin:/usr/sbin:/sbin])
+AC_PATH_PROGS([IPROUTE], [ip],, [$PATH:/usr/local/sbin:/usr/sbin:/sbin])
+AC_CHECK_PROGS([NETSTAT], [netstat], [netstat], [$PATH:/usr/local/sbin:/usr/sbin:/sbin:/etc]) # tests
+AC_CHECK_PROGS([MAN2HTML], [man2html])
+AC_DEFINE_UNQUOTED([IFCONFIG_PATH], ["$IFCONFIG"], [Path to ifconfig tool])
+AC_DEFINE_UNQUOTED([IPROUTE_PATH], ["$IPROUTE"], [Path to iproute tool])
+AC_DEFINE_UNQUOTED([ROUTE_PATH], ["$ROUTE"], [Path to route tool])
+
 #
 # Libtool
 #
@@ -386,12 +369,6 @@ ifdef(
 	]
 )
 
-if test "${WIN32}" = "yes"; then
-	AC_ARG_VAR([MAN2HTML], [man2html utility])
-	AC_CHECK_PROGS([MAN2HTML], [man2html])
-	test -z "${MAN2HTML}" && AC_MSG_ERROR([man2html is required for win32])
-fi
-
 AC_C_CONST
 AC_C_INLINE
 AC_C_VOLATILE
@@ -920,7 +897,16 @@ test "${enable_pf}" = "yes" && AC_DEFINE([ENABLE_PF], [1], [Enable internal pack
 test "${enable_strict_options}" = "yes" && AC_DEFINE([ENABLE_STRICT_OPTIONS_CHECK], [1], [Enable strict options check between peers])
 test "${enable_password_save}" = "yes" && AC_DEFINE([ENABLE_PASSWORD_SAVE], [1], [Allow --askpass and --auth-user-pass passwords to be read from a file])
 test "${enable_systemd}" = "yes" && AC_DEFINE([ENABLE_SYSTEMD], [1], [Enable systemd support])
-test "${enable_iproute2}" = "yes" && AC_DEFINE([ENABLE_IPROUTE], [1], [enable iproute2 support])
+
+if test "${enable_iproute2}" = "yes"; then
+	test -z "${IPROUTE}" && AC_MSG_ERROR([ip utility is required but missing])
+	AC_DEFINE([ENABLE_IPROUTE], [1], [enable iproute2 support])
+else
+	if test "${WIN32}" != "yes"; then
+		test -z "${ROUTE}" && AC_MSG_ERROR([route utility is required but missing])
+		test -z "${IFCONFIG}" && AC_MSG_ERROR([ifconfig utility is required but missing])
+	fi
+fi
 
 if test "${enable_pedantic}" = "yes"; then
 	enable_strict="yes"
@@ -930,6 +916,10 @@ if test "${enable_strict}" = "yes"; then
 	CFLAGS="${CFLAGS} -Wall -Wno-unused-parameter -Wno-unused-function"
 fi
 
+if test "${WIN32}" = "yes"; then
+	test -z "${MAN2HTML}" && AC_MSG_ERROR([man2html is required for win32])
+fi
+
 CONFIGURE_DEFINES="`set | grep '^enable_.*=' ; set | grep '^with_.*='`"
 AC_DEFINE_UNQUOTED([CONFIGURE_DEFINES], ["`echo ${CONFIGURE_DEFINES}`"], [Configuration settings])
 
#59 lore raw

Re: [Openvpn-devel] [PATCH 33/52] build: properly detect and use socket libs

In reply to Alon Bar-Lev

Did some digging regarding AC_SEARCH_LIBS and AC_CHECK_LIB. Somebody with more autotools knowledge might want to read this one:

<http://www.flameeyes.eu/autotools-mythbuster/autoconf/finding.html>

So, the question is: why AC_CHECK_LIB rather than AC_SEARCH_LIBS in this particular case? Apparently both have their uses.

Signature · 5 lines
Samuli Seppänen
Community Manager
OpenVPN Technologies, Inc

irc freenode net: mattock
Quoted 63 lines
---
 configure.ac            |   27 +++++++++++++++++----------
 src/openvpn/Makefile.am |    1 +
 2 files changed, 18 insertions(+), 10 deletions(-)
configure.ac +17 -10
index a0dc462..c540f82 100644
@@ -442,16 +442,6 @@ if test "${WIN32}" != "yes"; then
 		[[${SOCKET_INCLUDES}]]
 	)
 
-	AC_CHECK_DECLS(
-		[SO_MARK],
-		,
-		,
-		[[${SOCKET_INCLUDES}]]
-	)
-
-	AC_SEARCH_LIBS([socket], [socket])
-	AC_SEARCH_LIBS([inet_ntoa], [nsl])
-	AC_SEARCH_LIBS([gethostbyname], [resolv nsl])
 	AC_FUNC_FORK
 fi
 
@@ -613,6 +603,23 @@ AC_CHECK_LIB(
 )
 AC_SUBST([DL_LIBS])
 
+AC_CHECK_LIB(
+	[nsl],
+	[inet_ntoa],
+	[SOCKETS_LIBS="${SOCKETS_LIBS} -lnsl"]
+)
+AC_CHECK_LIB(
+	[socket],
+	[socket],
+	[SOCKETS_LIBS="${SOCKETS_LIBS} -lsocket"]
+)
+AC_CHECK_LIB(
+	[resolv],
+	[gethostbyname],
+	[SOCKETS_LIBS="${SOCKETS_LIBS} -lresolv"]
+)
+AC_SUBST([SOCKETS_LIBS])
+
 case "${with_mem_check}" in
 	valgrind)
 		AC_CHECK_HEADER(
src/openvpn/Makefile.am +1 -0
index c7626c8..86abd09 100644
@@ -96,6 +96,7 @@ openvpn_SOURCES = \
 	win32.h win32.c \
 	cryptoapi.h cryptoapi.c
 openvpn_LDADD = \
+	$(SOCKETS_LIBS) \
 	$(OPTIONAL_DL_LIBS)
 if WIN32
 openvpn_SOURCES += openvpn_win32_resources.rc
#63 lore raw

Re: [Openvpn-devel] [PATCH 35/52] build: proper selinux detection and usage

In reply to Alon Bar-Lev

Looks like a cleaner implementation than the earlier one. I take it AC_CHECK_HEADER is not anymore needed to detect selinux.h, but why exactly?

Besides that I give this one an ACK.

Signature · 5 lines
Samuli Seppänen
Community Manager
OpenVPN Technologies, Inc

irc freenode net: mattock
Quoted 175 lines
---
 configure.ac            |   35 +++++++++++++++--------------------
 src/openvpn/Makefile.am |    1 +
 src/openvpn/init.c      |    4 ++--
 src/openvpn/options.c   |    6 +++---
 src/openvpn/options.h   |    2 +-
 src/openvpn/syshead.h   |    2 +-
 6 files changed, 23 insertions(+), 27 deletions(-)
configure.ac +15 -20
index 98615c6..2388f17 100644
@@ -215,7 +215,7 @@ AC_ARG_ENABLE(
 
 AC_ARG_ENABLE(
 	[selinux],
-	[AS_HELP_STRING([--disable-selinux], [disable SELinux support])],
+	[AS_HELP_STRING([--enable-selinux], [enable SELinux support])],
 	,
 	[enable_selinux="no"]
 )
@@ -619,6 +619,13 @@ AC_CHECK_LIB(
 )
 AC_SUBST([SOCKETS_LIBS])
 
+AC_CHECK_LIB(
+	[selinux],
+	[setcon],
+	[SELINUX_LIBS="-lselinux"]
+)
+AC_SUBST([SELINUX_LIBS])
+
 case "${with_mem_check}" in
 	valgrind)
 		AC_CHECK_HEADER(
@@ -826,25 +833,6 @@ if test "${enable_crypto}" = "yes"; then
    fi
 fi
 
-dnl
-dnl check for SELinux library and headers
-dnl
-if test "${enable_selinux}" = "yes"; then
-	AC_CHECK_HEADER(
-		[selinux/selinux.h],
-		[AC_CHECK_LIB(
-			[selinux],
-			[setcon],
-			[
-				LIBS="${LIBS} -lselinux"
-				AC_DEFINE(HAVE_SETCON, 1, [SELinux support])
-			],
-			[AC_MSG_RESULT([SELinux library not found.])]
-		)],
-		[AC_MSG_ERROR([SELinux headers not found.])]
-	)
-fi
-
 if test -n "${SP_PLATFORM_WINDOWS}"; then
 	AC_DEFINE_UNQUOTED([PATH_SEPARATOR], ['\\\\'], [Path separator]) #"
 	AC_DEFINE_UNQUOTED([PATH_SEPARATOR_STR], ["\\\\"], [Path separator]) #"
@@ -896,6 +884,12 @@ else
 	fi
 fi
 
+if test "${enable_selinux}" = "yes"; then
+	test -z "${SELINUX_LIBS}" && AC_MSG_ERROR([libselinux required but missing])
+	OPTIONAL_SELINUX_LIBS="${SELINUX_LIBS}"
+	AC_DEFINE([ENABLE_SELINUX], [1], [SELinux support])
+fi
+
 if test "${enable_pedantic}" = "yes"; then
 	enable_strict="yes"
 	CFLAGS="${CFLAGS} -ansi -pedantic"
@@ -922,6 +916,7 @@ AC_SUBST([TAP_WIN_MIN_MAJOR])
 AC_SUBST([TAP_WIN_MIN_MINOR])
 
 AC_SUBST([OPTIONAL_DL_LIBS])
+AC_SUBST([OPTIONAL_SELINUX_LIBS])
 
 AM_CONDITIONAL([WIN32], [test "${WIN32}" = "yes"])
 
src/openvpn/Makefile.am +1 -0
index 86abd09..a3f8b3a 100644
@@ -97,6 +97,7 @@ openvpn_SOURCES = \
 	cryptoapi.h cryptoapi.c
 openvpn_LDADD = \
 	$(SOCKETS_LIBS) \
+	$(OPTIONAL_SELINUX_LIBS) \
 	$(OPTIONAL_DL_LIBS)
 if WIN32
 openvpn_SOURCES += openvpn_win32_resources.rc
src/openvpn/init.c +2 -2
index b8f57b2..0c995ff 100644
@@ -1038,7 +1038,7 @@ do_uid_gid_chroot (struct context *c, bool no_delay)
 	mstats_open(c->options.memstats_fn);
 #endif
 
-#ifdef HAVE_SETCON
+#ifdef ENABLE_SELINUX
       /* Apply a SELinux context in order to restrict what OpenVPN can do
        * to _only_ what it is supposed to do after initialization is complete
        * (basically just network I/O operations). Doing it after chroot
@@ -2465,7 +2465,7 @@ do_option_warnings (struct context *c)
     msg (M_WARN, "WARNING: --ping should normally be used with --ping-restart or --ping-exit");
 
   if (o->username || o->groupname || o->chroot_dir
-#ifdef HAVE_SETCON
+#ifdef ENABLE_SELINUX
       || o->selinux_context
 #endif
       )
src/openvpn/options.c +3 -3
index d7f848e..4e95b83 100644
@@ -316,7 +316,7 @@ static const char usage_message[] =
   "--user user     : Set UID to user after initialization.\n"
   "--group group   : Set GID to group after initialization.\n"
   "--chroot dir    : Chroot to this directory after initialization.\n"
-#ifdef HAVE_SETCON
+#ifdef ENABLE_SELINUX
   "--setcon context: Apply this SELinux context after initialization.\n"
 #endif
   "--cd dir        : Change to this directory before initialization.\n"
@@ -1477,7 +1477,7 @@ show_settings (const struct options *o)
   SHOW_STR (groupname);
   SHOW_STR (chroot_dir);
   SHOW_STR (cd_dir);
-#ifdef HAVE_SETCON
+#ifdef ENABLE_SELINUX
   SHOW_STR (selinux_context);
 #endif
   SHOW_STR (writepid);
@@ -4525,7 +4525,7 @@ add_option (struct options *options,
 	}
       options->cd_dir = p[1];
     }
-#ifdef HAVE_SETCON
+#ifdef ENABLE_SELINUX
   else if (streq (p[0], "setcon") && p[1])
     {
       VERIFY_PERMISSION (OPT_P_GENERAL);
src/openvpn/options.h +1 -1
index 6af4b3a..57b88b7 100644
@@ -310,7 +310,7 @@ struct options
   const char *groupname;
   const char *chroot_dir;
   const char *cd_dir;
-#ifdef HAVE_SETCON
+#ifdef ENABLE_SELINUX
   char *selinux_context;
 #endif
   const char *writepid;
src/openvpn/syshead.h +1 -1
index 1ad81d8..cac4757 100644
@@ -176,7 +176,7 @@
 #include <sys/epoll.h>
 #endif
 
-#ifdef HAVE_SETCON
+#ifdef ENABLE_SELINUX
 #include <selinux/selinux.h>
 #endif
 
#73 lore raw

Re: [Openvpn-devel] [PATCH 36/52] build: distribute pkg.m4

In reply to Alon Bar-Lev

If we need pkg-config, then we also want this one:

"Macros to locate and utilise pkg-config"

ACK.

Signature · 5 lines
Samuli Seppänen
Community Manager
OpenVPN Technologies, Inc

irc freenode net: mattock
Quoted 173 lines

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

---
 m4/pkg.m4 |  159 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 159 insertions(+), 0 deletions(-)
 create mode 100644 m4/pkg.m4
m4/pkg.m4 new file +159 -0
new file mode 100644
index 0000000..9a71878
@@ -0,0 +1,159 @@
+# pkg.m4 - Macros to locate and utilise pkg-config.            -*- Autoconf -*-
+# serial 1 (pkg-config-0.24)
+# 
+# Copyright © 2004 Scott James Remnant <[email protected]...>.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# 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; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+#
+# As a special exception to the GNU General Public License, if you
+# distribute this file as part of a program that contains a
+# configuration script generated by Autoconf, you may include it under
+# the same distribution terms that you use for the rest of that program.
+
+# PKG_PROG_PKG_CONFIG([MIN-VERSION])
+# ----------------------------------
+AC_DEFUN([PKG_PROG_PKG_CONFIG],
+[m4_pattern_forbid([^_?PKG_[A-Z_]+$])
+m4_pattern_allow([^PKG_CONFIG(_(PATH|LIBDIR|SYSROOT_DIR|ALLOW_SYSTEM_(CFLAGS|LIBS)))?$])
+m4_pattern_allow([^PKG_CONFIG_(DISABLE_UNINSTALLED|TOP_BUILD_DIR|DEBUG_SPEW)$])
+AC_ARG_VAR([PKG_CONFIG], [path to pkg-config utility])
+AC_ARG_VAR([PKG_CONFIG_PATH], [directories to add to pkg-config's search path])
+AC_ARG_VAR([PKG_CONFIG_LIBDIR], [path overriding pkg-config's built-in search path])
+
+if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then
+	AC_PATH_TOOL([PKG_CONFIG], [pkg-config])
+fi
+if test -n "$PKG_CONFIG"; then
+	_pkg_min_version=m4_default([$1], [0.9.0])
+	AC_MSG_CHECKING([pkg-config is at least version $_pkg_min_version])
+	if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then
+		AC_MSG_RESULT([yes])
+	else
+		AC_MSG_RESULT([no])
+		PKG_CONFIG=""
+	fi
+fi[]dnl
+])# PKG_PROG_PKG_CONFIG
+
+# PKG_CHECK_EXISTS(MODULES, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
+#
+# Check to see whether a particular set of modules exists.  Similar
+# to PKG_CHECK_MODULES(), but does not set variables or print errors.
+#
+# Please remember that m4 expands AC_REQUIRE([PKG_PROG_PKG_CONFIG])
+# only at the first occurence in configure.ac, so if the first place
+# it's called might be skipped (such as if it is within an "if", you
+# have to call PKG_CHECK_EXISTS manually
+# --------------------------------------------------------------
+AC_DEFUN([PKG_CHECK_EXISTS],
+[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
+if test -n "$PKG_CONFIG" && \
+    AC_RUN_LOG([$PKG_CONFIG --exists --print-errors "$1"]); then
+  m4_default([$2], [:])
+m4_ifvaln([$3], [else
+  $3])dnl
+fi])
+
+# _PKG_CONFIG([VARIABLE], [COMMAND], [MODULES])
+# ---------------------------------------------
+m4_define([_PKG_CONFIG],
+[if test -n "$$1"; then
+    pkg_cv_[]$1="$$1"
+ elif test -n "$PKG_CONFIG"; then
+    PKG_CHECK_EXISTS([$3],
+                     [pkg_cv_[]$1=`$PKG_CONFIG --[]$2 "$3" 2>/dev/null`
+		      test "x$?" != "x0" && pkg_failed=yes ],
+		     [pkg_failed=yes])
+ else
+    pkg_failed=untried
+fi[]dnl
+])# _PKG_CONFIG
+
+# _PKG_SHORT_ERRORS_SUPPORTED
+# -----------------------------
+AC_DEFUN([_PKG_SHORT_ERRORS_SUPPORTED],
+[AC_REQUIRE([PKG_PROG_PKG_CONFIG])
+if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
+        _pkg_short_errors_supported=yes
+else
+        _pkg_short_errors_supported=no
+fi[]dnl
+])# _PKG_SHORT_ERRORS_SUPPORTED
+
+
+# PKG_CHECK_MODULES(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND],
+# [ACTION-IF-NOT-FOUND])
+#
+#
+# Note that if there is a possibility the first call to
+# PKG_CHECK_MODULES might not happen, you should be sure to include an
+# explicit call to PKG_PROG_PKG_CONFIG in your configure.ac
+#
+#
+# --------------------------------------------------------------
+AC_DEFUN([PKG_CHECK_MODULES],
+[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
+AC_ARG_VAR([$1][_CFLAGS], [C compiler flags for $1, overriding pkg-config])dnl
+AC_ARG_VAR([$1][_LIBS], [linker flags for $1, overriding pkg-config])dnl
+
+pkg_failed=no
+AC_MSG_CHECKING([for $1])
+
+_PKG_CONFIG([$1][_CFLAGS], [cflags], [$2])
+_PKG_CONFIG([$1][_LIBS], [libs], [$2])
+
+m4_define([_PKG_TEXT], [Alternatively, you may set the environment variables $1[]_CFLAGS
+and $1[]_LIBS to avoid the need to call pkg-config.
+See the pkg-config man page for more details.])
+
+if test $pkg_failed = yes; then
+   	AC_MSG_RESULT([no])
+        _PKG_SHORT_ERRORS_SUPPORTED
+        if test $_pkg_short_errors_supported = yes; then
+	        $1[]_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "$2" 2>&1`
+        else 
+	        $1[]_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "$2" 2>&1`
+        fi
+	# Put the nasty error message in config.log where it belongs
+	echo "$$1[]_PKG_ERRORS" >&AS_MESSAGE_LOG_FD
+
+	m4_default([$4], [AC_MSG_ERROR(
+[Package requirements ($2) were not met:
+
+$$1_PKG_ERRORS
+
+Consider adjusting the PKG_CONFIG_PATH environment variable if you
+installed software in a non-standard prefix.
+
+_PKG_TEXT])[]dnl
+        ])
+elif test $pkg_failed = untried; then
+     	AC_MSG_RESULT([no])
+	m4_default([$4], [AC_MSG_FAILURE(
+[The pkg-config script could not be found or is too old.  Make sure it
+is in your PATH or set the PKG_CONFIG environment variable to the full
+path to pkg-config.
+
+_PKG_TEXT
+
+To get pkg-config, see <http://pkg-config.freedesktop.org/>.])[]dnl
+        ])
+else
+	$1[]_CFLAGS=$pkg_cv_[]$1[]_CFLAGS
+	$1[]_LIBS=$pkg_cv_[]$1[]_LIBS
+        AC_MSG_RESULT([yes])
+	$3
+fi[]dnl
+])# PKG_CHECK_MODULES
#75 lore raw

Re: [Openvpn-devel] [PATCH 37/52] build: proper pkcs11-helper detection and usage

In reply to Alon Bar-Lev

These changes follow the same style as earlier patches, e.g. the selinux patch. Pkg-config is now being used to detect pkcs11-helper afaics. Also, pkcs11-helper now disabled by default, which I think makes sense.

I don't see why this shouldn't be included, so it's an ACK.

Signature · 5 lines
Samuli Seppänen
Community Manager
OpenVPN Technologies, Inc

irc freenode net: mattock
Quoted 174 lines
---
 configure.ac               |   49 ++++++++++++++++---------------------------
 distro/rpm/openvpn.spec.in |    5 ++-
 src/openvpn/Makefile.am    |    4 +++
 src/openvpn/ssl.c          |    2 +-
 src/openvpn/syshead.h      |    7 ------
 5 files changed, 26 insertions(+), 41 deletions(-)
configure.ac +18 -31
index 2388f17..baa66b2 100644
@@ -111,9 +111,9 @@ AC_ARG_ENABLE(
 
 AC_ARG_ENABLE(
 	[pkcs11],
-	[AS_HELP_STRING([--disable-pkcs11], [disable pkcs11 support])],
+	[AS_HELP_STRING([--enable-pkcs11], [enable pkcs11 support])],
 	,
-	[enable_pkcs11="yes"]
+	[enable_pkcs11="no"]
 )
 
 AC_ARG_ENABLE(
@@ -254,19 +254,6 @@ AC_ARG_WITH(
 )
 
 AC_ARG_WITH(
-	[pkcs11-helper-headers],
-	[AS_HELP_STRING([--with-pkcs11-helper-headers=DIR], [pkcs11-helper Include files location])],
-	[PKCS11_HELPER_HDR_DIR="$withval"]
-	[CPPFLAGS="$CPPFLAGS -I$withval"] 
-)
-
-AC_ARG_WITH(
-	[pkcs11-helper-lib],
-	[AS_HELP_STRING([--with-pkcs11-helper-lib=DIR], [pkcs11-helper Library location])],
-	[LDFLAGS="$LDFLAGS -L$withval"] 
-)
-
-AC_ARG_WITH(
 	[mem-check],
 	[AS_HELP_STRING([--with-mem-check=TYPE], [build with debug memory checking, TYPE=dmalloc|valgrind|ssl])],
 	[
@@ -719,22 +706,12 @@ if test "${enable_lzo_stub}" = "yes"; then
 	AC_DEFINE([LZO_STUB], [1], [Enable LZO stub capability])
 fi
 
-dnl
-dnl enable pkcs11 capability
-dnl
-if test "${enable_pkcs11}" = "yes"; then
-   AC_CHECKING([for pkcs11-helper Library and Header files])
-   AC_CHECK_HEADER(pkcs11-helper-1.0/pkcs11h-core.h,
-	[AC_CHECK_LIB(pkcs11-helper, pkcs11h_initialize,
-	    [
-		   AC_DEFINE(USE_PKCS11, 1, [Enable PKCS11 capability])
-		   LIBS="${LIBS} -lpkcs11-helper"
-	    ],
-	    [AC_MSG_RESULT([pkcs11-helper library not found.])]
-	)],
-	[AC_MSG_RESULT([pkcs11-helper headers not found.])]
-   )
-fi
+PKG_CHECK_MODULES(
+	[PKCS11_HELPER],
+	[libpkcs11-helper-1 >= 1.02],
+	[have_pkcs11_helper="yes"],
+	[]
+)
 
 dnl
 dnl check for SSL-crypto library
@@ -890,6 +867,14 @@ if test "${enable_selinux}" = "yes"; then
 	AC_DEFINE([ENABLE_SELINUX], [1], [SELinux support])
 fi
 
+if test "${enable_pkcs11}" = "yes"; then
+	test "${have_pkcs11_helper}" != "yes" && AC_MSG_ERROR([PKCS11 enabled but libpkcs11-helper is missing])
+	test "${enable_ssl}" != "yes" && AC_MSG_ERROR([PKCS11 can be enabled only if SSL is enabled])
+	OPTIONAL_PKCS11_HELPER_CFLAGS="${PKCS11_HELPER_CFLAGS}"
+	OPTIONAL_PKCS11_HELPER_LIBS="${PKCS11_HELPER_LIBS}"
+	AC_DEFINE([ENABLE_PKCS11], [1], [Enable PKCS11])
+fi
+
 if test "${enable_pedantic}" = "yes"; then
 	enable_strict="yes"
 	CFLAGS="${CFLAGS} -ansi -pedantic"
@@ -917,6 +902,8 @@ AC_SUBST([TAP_WIN_MIN_MINOR])
 
 AC_SUBST([OPTIONAL_DL_LIBS])
 AC_SUBST([OPTIONAL_SELINUX_LIBS])
+AC_SUBST([OPTIONAL_PKCS11_HELPER_CFLAGS])
+AC_SUBST([OPTIONAL_PKCS11_HELPER_LIBS])
 
 AM_CONDITIONAL([WIN32], [test "${WIN32}" = "yes"])
 
distro/rpm/openvpn.spec.in +3 -2
index 455f739..8db5172 100644
@@ -52,8 +52,8 @@ Requires:      openssl       >= 0.9.6
 %{!?without_pam:BuildRequires: pam-devel}
 %{!?without_pam:Requires:      pam}
 
-%{!?with_pkcs11:BuildRequires: pkcs11-helper-devel}
-%{!?with_pkcs11:Requires:      pkcs11-helper}
+%{?with_pkcs11:BuildRequires: pkcs11-helper-devel}
+%{?with_pkcs11:Requires:      pkcs11-helper}
 
 #
 # Description
@@ -111,6 +111,7 @@ Development support for OpenVPN.
 	--docdir="%{_docdir}/%{name}-%{version}" \
 	%{?with_password_save:--enable-password-save} \
 	%{?without_lzo:--disable-lzo} \
+	%{?with_pkcs11:--enable-pkcs11} \
 	%{?with_kerberos:--with-ssl-headers=/usr/kerberos/include}
 %__make
 
src/openvpn/Makefile.am +4 -0
index a3f8b3a..fd92225 100644
@@ -16,6 +16,9 @@ MAINTAINERCLEANFILES = \
 
 INCLUDES = -I$(top_srcdir)/include
 
+AM_CFLAGS = \
+	$(OPTIONAL_PKCS11_HELPER_CFLAGS)
+
 sbin_PROGRAMS = openvpn
 
 openvpn_SOURCES = \
@@ -97,6 +100,7 @@ openvpn_SOURCES = \
 	cryptoapi.h cryptoapi.c
 openvpn_LDADD = \
 	$(SOCKETS_LIBS) \
+	$(OPTIONAL_PKCS11_HELPER_LIBS) \
 	$(OPTIONAL_SELINUX_LIBS) \
 	$(OPTIONAL_DL_LIBS)
 if WIN32
src/openvpn/ssl.c +1 -1
index c26756e..e260718 100644
@@ -264,7 +264,7 @@ ssl_purge_auth (const bool auth_user_pass_only)
 {
   if (!auth_user_pass_only)
     {
-#ifdef USE_PKCS11
+#ifdef ENABLE_PKCS11
       pkcs11_logout ();
 #endif
       purge_user_pass (&passbuf, true);
src/openvpn/syshead.h +0 -7
index cac4757..53b7580 100644
@@ -590,13 +590,6 @@ socket_defined (const socket_descriptor_t sd)
 #endif
 
 /*
- * Do we have PKCS11 capability?
- */
-#if defined(USE_PKCS11) && defined(USE_CRYPTO) && defined(USE_SSL)
-#define ENABLE_PKCS11
-#endif
-
-/*
  * Do we have CryptoAPI capability?
  */
 #if defined(WIN32) && defined(USE_CRYPTO) && defined(USE_SSL) && defined(USE_OPENSSL)
#77 lore raw

Re: [Openvpn-devel] [PATCH 38/52] build: properly process lzo-stub

In reply to Alon Bar-Lev

Much of this patch is about renaming LZO_STUB as the more descriptive ENABLE_LZO_STUB, and making thing clearer is always good. Also, the LZO_STUB-related logic is moved out of syshead.h to configure.ac.

Somebody with more autotools knowledge might want to review this just in case. If nobody speaks up, I say ACK this.

Signature · 5 lines
Samuli Seppänen
Community Manager
OpenVPN Technologies, Inc

irc freenode net: mattock
Quoted 266 lines
---
 configure.ac          |   12 +++++++-----
 src/openvpn/lzo.c     |   20 ++++++++++----------
 src/openvpn/lzo.h     |   20 ++++++++++----------
 src/openvpn/ssl.c     |    2 +-
 src/openvpn/syshead.h |   12 ------------
 5 files changed, 28 insertions(+), 38 deletions(-)
configure.ac +7 -5
index baa66b2..da41554 100644
@@ -701,11 +701,6 @@ if test "${enable_lzo}" = "yes" && test "${enable_lzo_stub}" = "no"; then
    fi
 fi
 
-dnl enable multi-client mode
-if test "${enable_lzo_stub}" = "yes"; then
-       AC_DEFINE([LZO_STUB], [1], [Enable LZO stub capability])
-fi
-
 PKG_CHECK_MODULES(
        [PKCS11_HELPER],
        [libpkcs11-helper-1 >= 1.02],
@@ -867,6 +862,13 @@ if test "${enable_selinux}" = "yes"; then
        AC_DEFINE([ENABLE_SELINUX], [1], [SELinux support])
 fi
 
+if test "${enable_lzo_stub}" = "yes"; then
+       test "${enable_lzo}" = "yes" && AC_MSG_ERROR([Cannot have both lzo stub and lzo enabled])
+       AC_DEFINE([ENABLE_LZO_STUB], [1], [Enable LZO stub capability])
+       AC_DEFINE([USE_LZO], [1], [Enable LZO compression library])
+       AC_DEFINE([LZO_VERSION_NUM], ["STUB"], [LZO version number])
+fi
+
 if test "${enable_pkcs11}" = "yes"; then
        test "${have_pkcs11_helper}" != "yes" && AC_MSG_ERROR([PKCS11 enabled but libpkcs11-helper is missing])
        test "${enable_ssl}" != "yes" && AC_MSG_ERROR([PKCS11 can be enabled only if SSL is enabled])
src/openvpn/lzo.c +10 -10
index 7e50fc9..ca06f71 100644
@@ -36,7 +36,7 @@
 
 #include "memdbg.h"
 
-#ifndef LZO_STUB
+#ifndef ENABLE_LZO_STUB
 /**
  * Perform adaptive compression housekeeping.
  *
@@ -91,7 +91,7 @@ lzo_adaptive_compress_data (struct lzo_adaptive_compress *ac, int n_total, int n
   ac->n_comp += n_comp;
 }
 
-#endif /* LZO_STUB */
+#endif /* ENABLE_LZO_STUB */
 
 void lzo_adjust_frame_parameters (struct frame *frame)
 {
@@ -109,7 +109,7 @@ lzo_compress_init (struct lzo_compress_workspace *lzowork, unsigned int flags)
   CLEAR (*lzowork);
 
   lzowork->flags = flags;
-#ifndef LZO_STUB
+#ifndef ENABLE_LZO_STUB
   lzowork->wmem_size = LZO_WORKSPACE;
 
   if (lzo_init () != LZO_E_OK)
@@ -129,7 +129,7 @@ lzo_compress_uninit (struct lzo_compress_workspace *lzowork)
   if (lzowork)
     {
       ASSERT (lzowork->defined);
-#ifndef LZO_STUB
+#ifndef ENABLE_LZO_STUB
       lzo_free (lzowork->wmem);
       lzowork->wmem = NULL;
 #endif
@@ -140,7 +140,7 @@ lzo_compress_uninit (struct lzo_compress_workspace *lzowork)
 static inline bool
 lzo_compression_enabled (struct lzo_compress_workspace *lzowork)
 {
-#ifndef LZO_STUB
+#ifndef ENABLE_LZO_STUB
   if ((lzowork->flags & (LZO_SELECTED|LZO_ON)) == (LZO_SELECTED|LZO_ON))
     {
       if (lzowork->flags & LZO_ADAPTIVE)
@@ -157,7 +157,7 @@ lzo_compress (struct buffer *buf, struct buffer work,
              struct lzo_compress_workspace *lzowork,
              const struct frame* frame)
 {
-#ifndef LZO_STUB
+#ifndef ENABLE_LZO_STUB
   lzo_uint zlen = 0;
   int err;
   bool compressed = false;
@@ -168,7 +168,7 @@ lzo_compress (struct buffer *buf, struct buffer work,
   if (buf->len <= 0)
     return;
 
-#ifndef LZO_STUB
+#ifndef ENABLE_LZO_STUB
   /*
    * In order to attempt compression, length must be at least COMPRESS_THRESHOLD,
    * and our adaptive level must give the OK.
@@ -226,7 +226,7 @@ lzo_decompress (struct buffer *buf, struct buffer work,
                struct lzo_compress_workspace *lzowork,
                const struct frame* frame)
 {
-#ifndef LZO_STUB
+#ifndef ENABLE_LZO_STUB
   lzo_uint zlen = EXPANDED_SIZE (frame);
   int err;
 #endif
@@ -244,7 +244,7 @@ lzo_decompress (struct buffer *buf, struct buffer work,
 
   if (c == YES_COMPRESS)       /* packet was compressed */
     {
-#ifndef LZO_STUB
+#ifndef ENABLE_LZO_STUB
       ASSERT (buf_safe (&work, zlen));
       err = LZO_DECOMPRESS (BPTR (buf), BLEN (buf), BPTR (&work), &zlen,
                            lzowork->wmem);
@@ -291,7 +291,7 @@ void lzo_print_stats (const struct lzo_compress_workspace *lzo_compwork, struct
 {
   ASSERT (lzo_compwork->defined);
 
-#ifndef LZO_STUB
+#ifndef ENABLE_LZO_STUB
   status_printf (so, "pre-compress bytes," counter_format, lzo_compwork->pre_compress);
   status_printf (so, "post-compress bytes," counter_format, lzo_compwork->post_compress);
   status_printf (so, "pre-decompress bytes," counter_format, lzo_compwork->pre_decompress);
src/openvpn/lzo.h +10 -10
index 5fb2a15..da4bd88 100644
@@ -39,7 +39,7 @@
  * @{
  */
 
-#ifndef LZO_STUB
+#ifndef ENABLE_LZO_STUB
 #ifdef LZO_HEADER_DIR
 #include "lzo/lzoutil.h"
 #include "lzo/lzo1x.h"
@@ -68,7 +68,7 @@
 
 /**************************************************************************/
 /** @name LZO library interface defines *//** @{ *//***********************/
-#ifndef LZO_STUB
+#ifndef ENABLE_LZO_STUB
 #define LZO_COMPRESS    lzo1x_1_15_compress
                                 /**< LZO library compression function.
                                  *
@@ -90,7 +90,7 @@
                                  *   verify the integrity of incoming
                                  *   packets, you might want to consider
                                  *   using the non-safe version. */
-#endif /* LZO_STUB */
+#endif /* ENABLE_LZO_STUB */
 /** @} name LZO library interface *//**************************************/
 
 
@@ -98,10 +98,10 @@
 /** @name Miscellaneous compression defines *//** @{ *//*******************/
 #define LZO_EXTRA_BUFFER(len) ((len)/8 + 128 + 3)
                                 /**< LZO 2.0 worst-case size expansion. */
-#ifndef LZO_STUB
+#ifndef ENABLE_LZO_STUB
 #define COMPRESS_THRESHOLD 100  /**< Minimum packet size to attempt
                                  *   compression. */
-#endif /* LZO_STUB */
+#endif /* ENABLE_LZO_STUB */
 /** @} name Miscellaneous compression defines *//**************************/
 
 
@@ -119,7 +119,7 @@
 
 /**************************************************************************/
 /** @name Adaptive compression defines *//** @{ *//************************/
-#ifndef LZO_STUB
+#ifndef ENABLE_LZO_STUB
 #define AC_SAMP_SEC    2        /**< Number of seconds in a sample period. */
 #define AC_MIN_BYTES   1000     /**< Minimum number of bytes a sample
                                  *   period must contain for it to be
@@ -129,10 +129,10 @@
                                  *   turned off. */
 #define AC_OFF_SEC     60       /**< Seconds to wait after compression has
                                  *   been turned off before retesting. */
-#endif /* LZO_STUB */
+#endif /* ENABLE_LZO_STUB */
 /** @} name Adaptive compression defines *//*******************************/
 
-#ifndef LZO_STUB
+#ifndef ENABLE_LZO_STUB
 
 /**
  * Adaptive compression state.
@@ -144,7 +144,7 @@ struct lzo_adaptive_compress {
   int n_comp;
 };
 
-#endif /* LZO_STUB */
+#endif /* ENABLE_LZO_STUB */
 
 
 /**
@@ -161,7 +161,7 @@ struct lzo_compress_workspace
 {
   bool defined;
   unsigned int flags;
-#ifndef LZO_STUB
+#ifndef ENABLE_LZO_STUB
   lzo_voidp wmem;
   int wmem_size;
   struct lzo_adaptive_compress ac;
src/openvpn/ssl.c +1 -1
index e260718..ba06ff7 100644
@@ -1652,7 +1652,7 @@ push_peer_info(struct buffer *buf, struct tls_session *session)
       }
 
       /* push LZO status */
-#ifdef LZO_STUB
+#ifdef ENABLE_LZO_STUB
       buf_printf (&out, "IV_LZO_STUB=1\n");
 #endif
 
src/openvpn/syshead.h +0 -13
index 53b7580..bfdf148 100644
@@ -700,18 +700,6 @@ socket_defined (const socket_descriptor_t sd)
 #define ENABLE_CLIENT_NAT
 
 /*
- * Support LZO as a stub in client? (LZO lib not included, but we
- * we still support LZO protocol changes that allow us to
- * communicate with an LZO-enabled server)
- */
-#ifdef LZO_STUB
-#undef USE_LZO
-#undef LZO_VERSION_NUM
-#define USE_LZO 1
-#define LZO_VERSION_NUM "STUB"
-#endif
-
-/*
  * Enable --memstats option
  */
 #ifdef TARGET_LINUX
--

1.7.3.4

------------------------------------------------------------------------------
Virtualization & Cloud Management Using Capacity Planning Cloud computing makes use of virtualization - but cloud computing also focuses on allowing computing to be delivered as a service.
http://www.accelacomm.com/jaw/sfnl/114/51521223/
_______________________________________________
Openvpn-devel mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel

#81 lore raw

Re: [Openvpn-devel] [PATCH 41/52] build: autoconf: update defaults for options

In reply to Alon Bar-Lev

I'd rather not RTFM... could somebody explain to me what the funky "@<:@default=no@:>@" thing exactly does? Does it just add the default "enabled/disabled" value to the help strings?

If so it's an ACK.

Signature · 5 lines
Samuli Seppänen
Community Manager
OpenVPN Technologies, Inc

irc freenode net: mattock
Quoted 246 lines
---
 configure.ac |   56 ++++++++++++++++++++++++++++----------------------------
 1 files changed, 28 insertions(+), 28 deletions(-)
configure.ac +28 -29
index 57d294d..9ffcc68 100644
@@ -41,195 +41,195 @@ AC_USE_SYSTEM_EXTENSIONS
 
 AC_ARG_ENABLE(
        [lzo],
-       [AS_HELP_STRING([--enable-lzo], [enable LZO compression support])],
+       [AS_HELP_STRING([--enable-lzo], [enable LZO compression support @<:@default=no@:>@])],
        ,
        [enable_lzo="no"]
 )
 
 AC_ARG_ENABLE(
        [lzo-stub],
-       [AS_HELP_STRING([--enable-lzo-stub], [don't compile LZO compression support but still allow limited interoperability with LZO-enabled peers])],
+       [AS_HELP_STRING([--enable-lzo-stub], [don't compile LZO compression support but still allow limited interoperability with LZO-enabled peers @<:@default=no@:>@])],
        ,
        [enable_lzo_stub="no"]
 )
 
 AC_ARG_ENABLE(
        [crypto],
-       [AS_HELP_STRING([--disable-crypto], [disable crypto support])],
+       [AS_HELP_STRING([--disable-crypto], [disable crypto support @<:@default=yes@:>@])],
        ,
        [enable_crypto="yes"]
 )
 
 AC_ARG_ENABLE(
        [ssl],
-       [AS_HELP_STRING([--disable-ssl], [disable SSL support for TLS-based key exchange])],
+       [AS_HELP_STRING([--disable-ssl], [disable SSL support for TLS-based key exchange @<:@default=yes@:>@])],
        ,
        [enable_ssl="yes"]
 )
 
 AC_ARG_ENABLE(
        [x509-alt-username],
-       [AS_HELP_STRING([--enable-x509-alt-username], [enable the --x509-username-field feature])],
+       [AS_HELP_STRING([--enable-x509-alt-username], [enable the --x509-username-field feature @<:@default=no@:>@])],
        ,
        [enable_x509_alt_username="no"]
 )
 
 AC_ARG_ENABLE(
        [multi],
-       [AS_HELP_STRING([--disable-multi], [disable client/server support (--mode server + client mode)])],
+       [AS_HELP_STRING([--disable-multi], [disable client/server support (--mode server + client mode) @<:@default=yes@:>@])],
        ,
        [enable_multi="yes"]
 )
 
 AC_ARG_ENABLE(
        [server],
-       [AS_HELP_STRING([--disable-server], [disable server support only (but retain client support)])],
+       [AS_HELP_STRING([--disable-server], [disable server support only (but retain client support) @<:@default=yes@:>@])],
        ,
        [enable_server="yes"]
 )
 
 AC_ARG_ENABLE(
        [plugins],
-       [AS_HELP_STRING([--disable-plugins], [disable plug-in support])],
+       [AS_HELP_STRING([--disable-plugins], [disable plug-in support @<:@default=yes@:>@])],
        ,
        [enable_plugins="yes"]
 )
 
 AC_ARG_ENABLE(
        [eurephia],
-       [AS_HELP_STRING([--disable-eurephia], [disable support for the eurephia plug-in])],
+       [AS_HELP_STRING([--disable-eurephia], [disable support for the eurephia plug-in @<:@default=yes@:>@])],
        ,
        [enable_eurephia="yes"]
 )
 
 AC_ARG_ENABLE(
        [management],
-       [AS_HELP_STRING([--disable-management], [disable management server support])],
+       [AS_HELP_STRING([--disable-management], [disable management server support @<:@default=yes@:>@])],
        ,
        [enable_management="yes"]
 )
 
 AC_ARG_ENABLE(
        [pkcs11],
-       [AS_HELP_STRING([--enable-pkcs11], [enable pkcs11 support])],
+       [AS_HELP_STRING([--enable-pkcs11], [enable pkcs11 support @<:@default=no@:>@])],
        ,
        [enable_pkcs11="no"]
 )
 
 AC_ARG_ENABLE(
        [socks],
-       [AS_HELP_STRING([--disable-socks], [disable Socks support])],
+       [AS_HELP_STRING([--disable-socks], [disable Socks support @<:@default=yes@:>@])],
        ,
        [enable_socks="yes"]
 )
 
 AC_ARG_ENABLE(
        [http-proxy],
-       [AS_HELP_STRING([--disable-http-proxy], [disable HTTP proxy support])],
+       [AS_HELP_STRING([--disable-http-proxy], [disable HTTP proxy support @<:@default=yes@:>@])],
        ,
        [enable_http_proxy="yes"]
 )
 
 AC_ARG_ENABLE(
        [fragment],
-       [AS_HELP_STRING([--disable-fragment], [disable internal fragmentation support (--fragment)])],
+       [AS_HELP_STRING([--disable-fragment], [disable internal fragmentation support (--fragment) @<:@default=yes@:>@])],
        ,
        [enable_fragment="yes"]
 )
 
 AC_ARG_ENABLE(
        [multihome],
-       [AS_HELP_STRING([--disable-multihome], [disable multi-homed UDP server support (--multihome)])],
+       [AS_HELP_STRING([--disable-multihome], [disable multi-homed UDP server support (--multihome) @<:@default=yes@:>@])],
        ,
        [enable_multihome="yes"]
 )
 
 AC_ARG_ENABLE(
        [port-share],
-       [AS_HELP_STRING([--disable-port-share], [disable TCP server port-share support (--port-share)])],
+       [AS_HELP_STRING([--disable-port-share], [disable TCP server port-share support (--port-share) @<:@default=yes@:>@])],
        ,
        [enable_port_share="yes"]
 )
 
 AC_ARG_ENABLE(
        [debug],
-       [AS_HELP_STRING([--disable-debug], [disable debugging support (disable gremlin and verb 7+ messages)])],
+       [AS_HELP_STRING([--disable-debug], [disable debugging support (disable gremlin and verb 7+ messages) @<:@default=yes@:>@])],
        ,
        [enable_debug="yes"]
 )
 
 AC_ARG_ENABLE(
        [small],
-       [AS_HELP_STRING([--enable-small], [enable smaller executable size (disable OCC, usage message, and verb 4 parm list)])],
+       [AS_HELP_STRING([--enable-small], [enable smaller executable size (disable OCC, usage message, and verb 4 parm list) @<:@default=yes@:>@])],
        ,
        [enable_small="no"]
 )
 
 AC_ARG_ENABLE(
        [password-save],
-       [AS_HELP_STRING([--enable-password-save], [allow --askpass and --auth-user-pass passwords to be read from a file])],
+       [AS_HELP_STRING([--enable-password-save], [allow --askpass and --auth-user-pass passwords to be read from a file @<:@default=yes@:>@])],
        [enable_password_save="no"]
 )
 
 AC_ARG_ENABLE(
        [iproute2],
-       [AS_HELP_STRING([--enable-iproute2], [enable support for iproute2])],
+       [AS_HELP_STRING([--enable-iproute2], [enable support for iproute2 @<:@default=no@:>@])],
        ,
        [enable_iproute2="no"]
 )
 
 AC_ARG_ENABLE(
        [def-auth],
-       [AS_HELP_STRING([--disable-def-auth], [disable deferred authentication])],
+       [AS_HELP_STRING([--disable-def-auth], [disable deferred authentication @<:@default=yes@:>@])],
        ,
        [enable_def_auth="yes"]
 )
 
 AC_ARG_ENABLE(
        [pf],
-       [AS_HELP_STRING([--disable-pf], [disable internal packet filter])],
+       [AS_HELP_STRING([--disable-pf], [disable internal packet filter @<:@default=yes@:>@])],
        ,
        [enable_pf="yes"]
 )
 
 AC_ARG_ENABLE(
        [strict],
-       [AS_HELP_STRING([--enable-strict], [enable strict compiler warnings (debugging option)])],
+       [AS_HELP_STRING([--enable-strict], [enable strict compiler warnings (debugging option) @<:@default=no@:>@])],
        ,
        [enable_strict="no"]
 )
 
 AC_ARG_ENABLE(
        [pedantic],
-       [AS_HELP_STRING([--enable-pedantic], [enable pedantic compiler warnings, will not generate a working executable (debugging option)])],
+       [AS_HELP_STRING([--enable-pedantic], [enable pedantic compiler warnings, will not generate a working executable (debugging option) @<:@default=no@:>@])],
        ,
        [enable_pedantic="no"]
 )
 
 AC_ARG_ENABLE(
        [strict-options],
-       [AS_HELP_STRING([--enable-strict-options], [enable strict options check between peers (debugging option)])],
+       [AS_HELP_STRING([--enable-strict-options], [enable strict options check between peers (debugging option) @<:@default=no@:>@])],
        ,
        [enable_strict_options="no"]
 )
 
 AC_ARG_ENABLE(
        [selinux],
-       [AS_HELP_STRING([--enable-selinux], [enable SELinux support])],
+       [AS_HELP_STRING([--enable-selinux], [enable SELinux support @<:@default=no@:>@])],
        ,
        [enable_selinux="no"]
 )
 
 AC_ARG_ENABLE(
        [systemd],
-       [AS_HELP_STRING([--enable-systemd], [enable systemd suppport])],
+       [AS_HELP_STRING([--enable-systemd], [enable systemd suppport @<:@default=no@:>@])],
        ,
        [enable_systemd="no"]
 )
 
 AC_ARG_WITH(
        [mem-check],
-       [AS_HELP_STRING([--with-mem-check=TYPE], [build with debug memory checking, TYPE=dmalloc|valgrind|ssl])],
+       [AS_HELP_STRING([--with-mem-check=TYPE], [build with debug memory checking, TYPE=no|dmalloc|valgrind|ssl @<:@default=no@:>@])],
        [
                case "${withval}" in
                        dmalloc|valgrind|ssl|no) ;;
--

1.7.3.4

------------------------------------------------------------------------------
Virtualization & Cloud Management Using Capacity Planning Cloud computing makes use of virtualization - but cloud computing also focuses on allowing computing to be delivered as a service.
http://www.accelacomm.com/jaw/sfnl/114/51521223/
_______________________________________________
Openvpn-devel mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel

#84 lore raw

Re: [Openvpn-devel] [PATCH 42/52] build: win-msvc: msbuild format

In reply to Alon Bar-Lev

A huge patch :). So, this basically adds the new MSVC build system, which we want, at least for now. All the changes to existing files are fairly trivial.

I didn't go through all of this, but I suggest we give this one an ACK and fix any issues later on. I've tested this buildsystem and it worked fine on Windows 2008r2.

Signature · 5 lines
Samuli Seppänen
Community Manager
OpenVPN Technologies, Inc

irc freenode net: mattock
Quoted 1,909 lines
---
 .gitignore                                    |   11 +-
 Makefile.am                                   |   10 +-
 build/Makefile.am                             |    2 +
 build/msvc/Makefile.am                        |   15 +
 build/msvc/msvc-generate/Makefile.am          |   18 +
 build/msvc/msvc-generate/Makefile.mak         |   13 +
 build/msvc/msvc-generate/msvc-generate.js     |  118 ++++
 build/msvc/msvc-generate/msvc-generate.vcproj |   74 +++
 config-msvc-version.h.in                      |   10 +
 config-msvc.h                                 |  122 ++++
 configure.ac                                  |    5 +-
 msvc-build.bat                                |   34 ++
 msvc-dev.bat                                  |    9 +
 msvc-env.bat                                  |   29 +
 openvpn.sln                                   |   45 ++
 src/openvpn/Makefile.am                       |    3 +
 src/openvpn/compat.h                          |    2 -
 src/openvpn/crypto_backend.h                  |    2 -
 src/openvpn/openvpn.vcproj                    |  769 +++++++++++++++++++++++++
 src/openvpn/openvpn_win32_resources.rc        |    2 +-
 src/openvpn/syshead.h                         |   14 +-
 src/openvpn/tun.c                             |    2 +-
 src/openvpn/win32.c                           |    2 +-
 src/openvpnserv/Makefile.am                   |    3 +
 src/openvpnserv/openvpnserv.c                 |   16 +-
 src/openvpnserv/openvpnserv.vcproj            |  209 +++++++
 src/openvpnserv/openvpnserv_resources.rc      |    2 +-
 src/openvpnserv/service.c                     |    5 +
 src/openvpnserv/service.h                     |    2 -
 29 files changed, 1527 insertions(+), 21 deletions(-)
 create mode 100644 build/msvc/Makefile.am
 create mode 100644 build/msvc/msvc-generate/Makefile.am
 create mode 100755 build/msvc/msvc-generate/Makefile.mak
 create mode 100644 build/msvc/msvc-generate/msvc-generate.js
 create mode 100644 build/msvc/msvc-generate/msvc-generate.vcproj
 create mode 100644 config-msvc-version.h.in
 create mode 100644 config-msvc.h
 create mode 100644 msvc-build.bat
 create mode 100644 msvc-dev.bat
 create mode 100644 msvc-env.bat
 create mode 100644 openvpn.sln
 create mode 100644 src/openvpn/openvpn.vcproj
 create mode 100644 src/openvpnserv/openvpnserv.vcproj
.gitignore +10 -1
index 156b2c2..e7232cf 100644
@@ -2,12 +2,18 @@
 *.dll
 *.exe
 *.exe.*
-*.mak
 *.obj
 *.pyc
 *.so
 *~
 *.idb
+*.suo
+*.ncb
+*.vcproj.*
+*.log
+Release
+Debug
+Win32-Output
 .deps
 Makefile
 Makefile.in
@@ -33,6 +39,9 @@ m4/ltsugar.m4
 m4/ltversion.m4
 m4/lt~obsolete.m4
 
+msvc-env-local.bat
+config-msvc-local.h
+config-msvc-version.h
 doc/openvpn.8.html
 distro/rpm/openvpn.spec
 tests/t_client.sh
Makefile.am +9 -1
index ebc2252..5293518 100644
@@ -54,10 +54,18 @@ dist_noinst_DATA = \
        .gitignore \
        PORTS \
        README.IPv6 TODO.IPv6 \
-       README.polarssl
+       README.polarssl \
+       openvpn.sln \
+       msvc-env.bat \
+       msvc-dev.bat \
+       msvc-build.bat
 
 if WIN32
 dist_doc_DATA += INSTALL-win32.txt
 else
 dist_noinst_DATA += INSTALL-win32.txt
 endif
+
+dist_noinst_HEADERS = \
+       config-msvc.h \
+       config-msvc-version.h.in
build/Makefile.am +2 -0
index a993b20..b53ff52 100644
@@ -13,3 +13,5 @@ MAINTAINERCLEANFILES = \
 
 EXTRA_DIST = \
        ltrc.inc
+
+SUBDIRS = msvc
build/msvc/Makefile.am new file +15 -0
new file mode 100644
index 0000000..7dc3def
@@ -0,0 +1,15 @@
+#
+#  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. <[email protected]...>
+#  Copyright (C) 2006-2012 Alon Bar-Lev <[email protected]...>
+#
+
+MAINTAINERCLEANFILES = \
+       $(srcdir)/Makefile.in
+
+SUBDIRS = msvc-generate
build/msvc/msvc-generate/Makefile.am new file +18 -0
new file mode 100644
index 0000000..035ae22
@@ -0,0 +1,18 @@
+#
+#  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. <[email protected]...>
+#  Copyright (C) 2006-2012 Alon Bar-Lev <[email protected]...>
+#
+
+MAINTAINERCLEANFILES = \
+       $(srcdir)/Makefile.in
+
+dist_noinst_DATA = \
+       msvc-generate.vcproj \
+       Makefile.mak \
+       msvc-generate.js
build/msvc/msvc-generate/Makefile.mak new file +13 -0
new file mode 100755
index 0000000..72415f1
@@ -0,0 +1,13 @@
+# Copyright (C) 2008-2012 Alon Bar-Lev <[email protected]...>
+
+CONFIG=$(SOURCEBASE)/version.m4
+INPUT=$(SOURCEBASE)/config-msvc-version.h.in
+OUTPUT=$(SOURCEBASE)/config-msvc-version.h
+
+all:   $(OUTPUT)
+
+$(OUTPUT): $(INPUT) $(CONFIG)
+       cscript //nologo msvc-generate.js --config="$(CONFIG)" --input="$(INPUT)" --output="$(OUTPUT)"
+
+clean:
+       -del "$(OUTPUT)"
build/msvc/msvc-generate/msvc-generate.js new file +118 -0
new file mode 100644
index 0000000..d9564cf
@@ -0,0 +1,118 @@
+/*
+ * msvc-generate.js  - string transformation
+ *
+ * Copyright (C) 2008-2012 Alon Bar-Lev <[email protected]...>
+ *
+ * BSD License
+ * ============
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ *     o Redistributions of source code must retain the above copyright notice,
+ *       this list of conditions and the following disclaimer.
+ *     o Redistributions in binary form must reproduce the above copyright
+ *       notice, this list of conditions and the following disclaimer in the
+ *       documentation and/or other materials provided with the distribution.
+ *     o Neither the name of the Alon Bar-Lev nor the names of its
+ *       contributors may be used to endorse or promote products derived from
+ *       this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+var ForReading = 1;
+var fso = new ActiveXObject("Scripting.FileSystemObject");
+var input = "nul";
+var output = "nul";
+var files = new Array();
+var env = new Array();
+
+function initialize() {
+       for (var i=0;i<WScript.Arguments.length;i++) {
+               var arg = WScript.Arguments(i);
+               if (arg.match(/^--input=(.*)$/)) {
+                       input=RegExp.$1;
+               }
+               else if (arg.match(/^--output=(.*)$/)) {
+                       output=RegExp.$1;
+               }
+               else if (arg.match(/^--config=(.*)$/)) {
+                       files.push(RegExp.$1);
+               }
+               else if (arg.match(/^--var=([^=]*)=(.*)$/)) {
+                       env[RegExp.$1] = RegExp.$2;
+               }
+       }
+}
+
+function process_config(vars, file) {
+       try {
+               var fin = fso.OpenTextFile(file, ForReading);
+
+               while (!fin.AtEndOfStream) {
+                       var content = fin.ReadLine();
+                       if (content.match(/^[ \t]*define\(\[(.*)\],[ \t]*\[(.*)\]\)[ \t]*/)) {
+                               vars[RegExp.$1] = RegExp.$2;
+                       }
+               }
+       }
+       catch(e) {
+               throw new Error(1, "Cannot process '" + file + "'.");
+       }
+}
+
+function process_file(vars, input, output) {
+       var fin = fso.OpenTextFile(input, ForReading);
+       var fout = fso.CreateTextFile(output);
+       var content = fin.ReadAll();
+
+       for (var i in vars) {
+               content = content.replace(new RegExp("@"+i+"@", "g"), vars[i]);
+       }
+
+       fout.Write(content);
+}
+
+function build_vars() {
+       var vars = new Array();
+       for (var f in files) {
+               process_config(vars, files[f]);
+       }
+       for (var e in env) {
+               vars[e] = env[e];
+       }
+       return vars;
+}
+
+function main() {
+       try {
+               initialize();
+
+               var vars = build_vars();
+
+               process_file(
+                       vars,
+                       input,
+                       output
+               );
+
+               WScript.Quit(0);
+       }
+       catch(e) {
+               WScript.Echo("ERROR: when procssing " + output + ": " + e.description);
+               WScript.Quit(1);
+       }
+}
+
+main();
build/msvc/msvc-generate/msvc-generate.vcproj new file +74 -0
new file mode 100644
index 0000000..3b7dc18
@@ -0,0 +1,74 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+       ProjectType="Visual C++"
+       Version="9.00"
+       Name="msvc-generate"
+       ProjectGUID="{8598C2C8-34C4-47A1-99B0-7C295A890615}"
+       RootNamespace="msvc-generate"
+       Keyword="MakeFileProj"
+       TargetFrameworkVersion="196613"
+       >
+       <Platforms>
+               <Platform
+                       Name="Win32"
+               />
+       </Platforms>
+       <ToolFiles>
+       </ToolFiles>
+       <Configurations>
+               <Configuration
+                       Name="Debug|Win32"
+                       OutputDirectory="$(ConfigurationName)"
+                       IntermediateDirectory="$(ConfigurationName)"
+                       ConfigurationType="0"
+                       >
+                       <Tool
+                               Name="VCNMakeTool"
+                               BuildCommandLine="nmake -f Makefile.mak all"
+                               ReBuildCommandLine="nmake -f Makefile.mak clean all"
+                               CleanCommandLine="nmake -f Makefile.mak clean"
+                               Output="config-msvc-version.h"
+                               PreprocessorDefinitions="WIN32;_DEBUG"
+                               IncludeSearchPath=""
+                               ForcedIncludes=""
+                               AssemblySearchPath=""
+                               ForcedUsingAssemblies=""
+                               CompileAsManaged=""
+                       />
+               </Configuration>
+               <Configuration
+                       Name="Release|Win32"
+                       OutputDirectory="$(ConfigurationName)"
+                       IntermediateDirectory="$(ConfigurationName)"
+                       ConfigurationType="0"
+                       >
+                       <Tool
+                               Name="VCNMakeTool"
+                               BuildCommandLine="nmake -f Makefile.mak all"
+                               ReBuildCommandLine="nmake -f Makefile.mak clean all"
+                               CleanCommandLine="nmake -f Makefile.mak clean"
+                               Output="config-msvc-version.h"
+                               PreprocessorDefinitions="WIN32;NDEBUG"
+                               IncludeSearchPath=""
+                               ForcedIncludes=""
+                               AssemblySearchPath=""
+                               ForcedUsingAssemblies=""
+                               CompileAsManaged=""
+                       />
+               </Configuration>
+       </Configurations>
+       <References>
+       </References>
+       <Files>
+               <File
+                       RelativePath=".\Makefile.mak"
+                       >
+               </File>
+               <File
+                       RelativePath=".\msc-generate.js"
+                       >
+               </File>
+       </Files>
+       <Globals>
+       </Globals>
+</VisualStudioProject>
config-msvc-version.h.in new file +10 -0
new file mode 100644
index 0000000..4bc89e7
@@ -0,0 +1,10 @@
+#define PACKAGE_NAME "@PRODUCT_NAME@"
+#define PACKAGE_STRING "@PRODUCT_NAME@ @PRODUCT_VERSION@"
+#define PACKAGE_TARNAME "@PRODUCT_TARNAME@"
+#define PACKAGE "@PRODUCT_TARNAME@"
+#define PACKAGE_VERSION "@PRODUCT_VERSION@"
+#define PRODUCT_BUGREPORT "@PRODUCT_BUGREPORT@"
+#define OPENVPN_VERSION_RESOURCE @PRODUCT_VERSION_RESOURCE@
+#define TAP_WIN_COMPONENT_ID "@PRODUCT_TAP_WIN_COMPONENT_ID@"
+#define TAP_WIN_MIN_MAJOR @PRODUCT_TAP_WIN_MIN_MAJOR@
+#define TAP_WIN_MIN_MINOR @PRODUCT_TAP_WIN_MIN_MINOR@
config-msvc.h new file +122 -0
new file mode 100644
index 0000000..577371f
@@ -0,0 +1,122 @@
+#include <config-msvc-version.h>
+
+#define CONFIGURE_DEFINES "N/A"
+
+#define ENABLE_DEF_AUTH 1
+#define ENABLE_PF 1
+#define ENABLE_CLIENT_SERVER 1
+#define ENABLE_CRYPTO 1
+#define ENABLE_CRYPTO_OPENSSL 1
+#define ENABLE_DEBUG 1
+#define ENABLE_EUREPHIA 1
+#define ENABLE_FRAGMENT 1
+#define ENABLE_HTTP_PROXY 1
+#define ENABLE_LZO 1
+#define ENABLE_MANAGEMENT 1
+#define ENABLE_MULTIHOME 1
+#define ENABLE_PKCS11 1
+#define ENABLE_PLUGIN 1
+#define ENABLE_PORT_SHARE 1
+#define ENABLE_SOCKS 1
+#define ENABLE_SSL 1
+
+#define HAVE_ERRNO_H 1
+#define HAVE_FCNTL_H 1
+#define HAVE_CTYPE_H 1
+#define HAVE_STDARG_H 1
+#define HAVE_STDIO_H 1
+#define HAVE_STDLIB_H 1
+#define HAVE_STRDUP 1
+#define HAVE_STRERROR 1
+#define HAVE_STRINGS_H 1
+#define HAVE_STRING_H 1
+#define HAVE_SYSTEM 1
+#define HAVE_TIME 1
+#define HAVE_TIME_H 1
+#define HAVE_UNLINK 1
+#define HAVE_VSNPRINTF 1
+#define HAVE_WINDOWS_H 1
+#define HAVE_WINSOCK2_H 1
+#define HAVE_WS2TCPIP_H 1
+#define HAVE_IO_H 1
+#define HAVE_DIRECT_H 1
+#define HAVE_SYS_TYPES_H 1
+#define HAVE_SYS_STAT_H 1
+#define HAVE_LZO_LZO1X_H 1
+#define HAVE_LZO_LZOUTIL_H 1
+
+#define HAVE_ACCESS 1
+#define HAVE_CHDIR 1
+#define HAVE_CHSIZE 1
+#define HAVE_CPP_VARARG_MACRO_ISO 1
+#define HAVE_CTIME 1
+#define HAVE_EVP_CIPHER_CTX_SET_KEY_LENGTH 1
+#define HAVE_GETTIMEOFDAY 1
+#define HAVE_IN_PKTINFO 1
+#define HAVE_MEMSET 1
+#define HAVE_PUTENV 1
+#define HAVE_STAT 1
+
+#define HAVE_SOCKET 1
+#define HAVE_RECV 1
+#define HAVE_RECVFROM 1
+#define HAVE_SEND 1
+#define HAVE_SENDTO 1
+#define HAVE_LISTEN 1
+#define HAVE_ACCEPT 1
+#define HAVE_CONNECT 1
+#define HAVE_BIND 1
+#define HAVE_SELECT 1
+#define HAVE_GETHOSTBYNAME 1
+#define HAVE_INET_NTOA 1
+#define HAVE_SETSOCKOPT 1
+#define HAVE_GETSOCKOPT 1
+#define HAVE_GETSOCKNAME 1
+#define HAVE_POLL 1
+
+#define HAVE_OPENSSL_ENGINE 1
+
+#ifndef __cplusplus
+#define inline __inline
+#endif
+
+#define EMPTY_ARRAY_SIZE 0
+#define TARGET_WIN32 1
+#define TARGET_ALIAS "Windows-MSVC"
+
+#define HAVE_DECL_SO_MARK 0
+
+#define strncasecmp strnicmp
+#define strcasecmp _stricmp
+#define snprintf _snprintf
+#define strtoull strtoul
+
+#define in_addr_t uint32_t
+#define ssize_t SSIZE_T
+
+#define S_IRUSR 0
+#define S_IWUSR 0
+#define R_OK 4
+#define W_OK 2
+#define X_OK 1
+#define F_OK 0
+
+#define SIGHUP    1
+#define SIGINT    2
+#define SIGUSR1   10
+#define SIGUSR2   12
+#define SIGTERM   15
+
+typedef unsigned __int64       uint64_t;
+typedef unsigned __int32       uint32_t;
+typedef unsigned __int16       uint16_t;
+typedef unsigned __int8                uint8_t;
+typedef __int64                int64_t;
+typedef __int32                int32_t;
+typedef __int16                int16_t;
+typedef __int8         int8_t;
+
+#ifdef HAVE_CONFIG_MSVC_LOCAL_H
+#include <config-msvc-local.h>
+#endif
+
configure.ac +4 -1
index 9ffcc68..f5663eb 100644
@@ -282,7 +282,8 @@ case "$host" in
        *-mingw*)
                AC_DEFINE([TARGET_WIN32], [1], [Are we running WIN32?])
                AC_DEFINE_UNQUOTED([TARGET_PREFIX], ["W"], [Target prefix])
-               CPPFLAGS="${CPPFLAGS} -DWIN32_LEAN_AND_MEAN -DWINVER=0x0501"
+               CPPFLAGS="${CPPFLAGS} -DWIN32_LEAN_AND_MEAN"
+               CPPFLAGS="${CPPFLAGS} -DNTDDI_VERSION=NTDDI_WINXP -D_WIN32_WINNT=_WIN32_WINNT_WINXP"
                WIN32=yes
                ;;
        *-*-dragonfly*)
@@ -906,6 +907,8 @@ AM_CONDITIONAL([WIN32], [test "${WIN32}" = "yes"])
 AC_CONFIG_FILES([
        Makefile
        build/Makefile
+       build/msvc/Makefile
+       build/msvc/msvc-generate/Makefile
        distro/Makefile
        distro/rpm/Makefile
        distro/rpm/openvpn.spec
msvc-build.bat new file +34 -0
new file mode 100644
index 0000000..02a396c
@@ -0,0 +1,34 @@
+@echo off
+
+rem Copyright (C) 2008-2012 Alon Bar-Lev <[email protected]...>
+
+call msvc-env.bat
+
+@rem this stupid command needed for SetEnv.cmd to operate
+setlocal ENABLEDELAYEDEXPANSION
+
+set PLATFORMS=Win32
+set CONFIGURATIONS=Release
+
+call "%VCHOME%\bin\vcvars32.bat"
+
+for %%p in (%PLATFORMS%) do (
+       for %%c in (%CONFIGURATIONS%) do (
+               rmdir /q /s %SOURCEBASE%\%%p\%%c > nul 2>&1
+
+               vcbuild /errfile:error.log /showenv %SOLUTION% /rebuild /platform:%%p "%%c|%%p"
+               for %%f in (error.log) do if %%~zf GTR 0 goto error
+       )
+)
+
+exit /b 0
+goto end
+
+:error
+if "%1" NEQ "batch" pause
+exit /b 1
+goto end
+
+:end
+
+endlocal
msvc-dev.bat new file +9 -0
new file mode 100644
index 0000000..671a56d
@@ -0,0 +1,9 @@
+@echo off
+
+setlocal
+cd %0\..
+call msvc-env.bat
+
+start "" "%VSHOME%\Common7\IDE\devenv.exe" %SOLUTION%
+
+endlocal
msvc-env.bat new file +29 -0
new file mode 100644
index 0000000..ef9c7bb
@@ -0,0 +1,29 @@
+@echo off
+
+cd %0\..
+
+rem Put your own settings at msvc-env-local.bat
+if exist msvc-env-local.bat call msvc-env-local.bat
+
+if "%ProgramFiles(x86)%"=="" set ProgramFiles(x86)=%ProgramFiles%
+if "%VS90COMNTOOLS%"=="" set VS90COMNTOOLS=%ProgramFiles(x86)%\Microsoft Visual Studio 9.0\Common7\Tools\
+if "%VSHOME%"=="" set VSHOME=%VS90COMNTOOLS%..\..
+if "%VCHOME%"=="" set VCHOME=%VSHOME%\VC
+
+set SOURCEBASE=%cd%
+set SOLUTION=openvpn.sln
+set CPPFLAGS=%CPPFLAGS%;_CRT_SECURE_NO_WARNINGS;WIN32_LEAN_AND_MEAN;_CRT_NONSTDC_NO_WARNINGS;_CRT_SECURE_NO_WARNINGS
+set CPPFLAGS=%CPPFLAGS%;NTDDI_VERSION=NTDDI_WINXP;_WIN32_WINNT=_WIN32_WINNT_WINXP
+set CPPFLAGS=%CPPFLAGS%;_USE_32BIT_TIME_T
+set CPPFLAGS=%CPPFLAGS%;%EXTRA_CPPFLAGS%
+
+if exist config-msvc-local.h set CPPFLAGS="%CPPFLAGS%;HAVE_CONFIG_MSVC_LOCAL_H"
+
+if "%OPENVPN_DEPROOT%" == "" set OPENVPN_DEPROOT=c:\Temp\openvpn-deps
+if "%OPENSSL_HOME%" == "" set OPENSSL_HOME=%OPENVPN_DEPROOT%
+if "%LZO_HOME%" == "" set LZO_HOME=%OPENVPN_DEPROOT%
+if "%PKCS11H_HOME%" == "" set PKCS11H_HOME=%OPENVPN_DEPROOT%
+
+if not exist "%OPENSSL_HOME%" echo WARNING: openssl '%OPENSSL_HOME%' does not exist
+if not exist "%LZO_HOME%" echo WARNING: lzo '%LZO_HOME%' does not exist
+if not exist "%PKCS11H_HOME%" echo WARNING: pkcs11-helper '%PKCS11H_HOME%' does not exist
openvpn.sln new file +45 -0
new file mode 100644
index 0000000..cbd2093
@@ -0,0 +1,45 @@
+
+Microsoft Visual Studio Solution File, Format Version 10.00
+# Visual Studio 2008
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "openvpnserv", "src\openvpnserv\openvpnserv.vcproj", "{9C91EE0B-817D-420A-A1E6-15A5A9D98BAD}"
+       ProjectSection(ProjectDependencies) = postProject
+               {8598C2C8-34C4-47A1-99B0-7C295A890615} = {8598C2C8-34C4-47A1-99B0-7C295A890615}
+       EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "openvpn", "src\openvpn\openvpn.vcproj", "{29DF226E-4D4E-440F-ADAF-5829CFD4CA94}"
+       ProjectSection(ProjectDependencies) = postProject
+               {8598C2C8-34C4-47A1-99B0-7C295A890615} = {8598C2C8-34C4-47A1-99B0-7C295A890615}
+       EndProjectSection
+EndProject
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "misc", "misc", "{1AA03DE8-3F08-45B9-B4ED-D7769A445DF3}"
+       ProjectSection(SolutionItems) = preProject
+               config-msvc-version.h.in = config-msvc-version.h.in
+               config-msvc.h = config-msvc.h
+               version.m4 = version.m4
+       EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "msvc-generate", "build\msvc\msvc-generate\msvc-generate.vcproj", "{8598C2C8-34C4-47A1-99B0-7C295A890615}"
+EndProject
+Global
+       GlobalSection(SolutionConfigurationPlatforms) = preSolution
+               Debug|Win32 = Debug|Win32
+               Release|Win32 = Release|Win32
+       EndGlobalSection
+       GlobalSection(ProjectConfigurationPlatforms) = postSolution
+               {9C91EE0B-817D-420A-A1E6-15A5A9D98BAD}.Debug|Win32.ActiveCfg = Debug|Win32
+               {9C91EE0B-817D-420A-A1E6-15A5A9D98BAD}.Debug|Win32.Build.0 = Debug|Win32
+               {9C91EE0B-817D-420A-A1E6-15A5A9D98BAD}.Release|Win32.ActiveCfg = Release|Win32
+               {9C91EE0B-817D-420A-A1E6-15A5A9D98BAD}.Release|Win32.Build.0 = Release|Win32
+               {29DF226E-4D4E-440F-ADAF-5829CFD4CA94}.Debug|Win32.ActiveCfg = Debug|Win32
+               {29DF226E-4D4E-440F-ADAF-5829CFD4CA94}.Debug|Win32.Build.0 = Debug|Win32
+               {29DF226E-4D4E-440F-ADAF-5829CFD4CA94}.Release|Win32.ActiveCfg = Release|Win32
+               {29DF226E-4D4E-440F-ADAF-5829CFD4CA94}.Release|Win32.Build.0 = Release|Win32
+               {8598C2C8-34C4-47A1-99B0-7C295A890615}.Debug|Win32.ActiveCfg = Debug|Win32
+               {8598C2C8-34C4-47A1-99B0-7C295A890615}.Debug|Win32.Build.0 = Debug|Win32
+               {8598C2C8-34C4-47A1-99B0-7C295A890615}.Release|Win32.ActiveCfg = Release|Win32
+               {8598C2C8-34C4-47A1-99B0-7C295A890615}.Release|Win32.Build.0 = Release|Win32
+       EndGlobalSection
+       GlobalSection(SolutionProperties) = preSolution
+               HideSolutionNode = FALSE
+       EndGlobalSection
+EndGlobal
src/openvpn/Makefile.am +3 -0
index e9b3b07..3d8c0a9 100644
@@ -14,6 +14,9 @@ include $(top_srcdir)/build/ltrc.inc
 MAINTAINERCLEANFILES = \
        $(srcdir)/Makefile.in
 
+EXTRA_DIST = \
+       openvpn.vcproj
+
 INCLUDES = -I$(top_srcdir)/include
 
 AM_CFLAGS = \
src/openvpn/compat.h +0 -2
index b380f0b..7af9fe2 100644
@@ -25,8 +25,6 @@
 #ifndef COMPAT_H
 #define COMPAT_H
 
-#include "config.h"
-
 #if defined(HAVE_BASENAME) || defined(HAVE_DIRNAME)
 #include <libgen.h>
 #endif
src/openvpn/crypto_backend.h +0 -2
index 57f2ac4..1eac611 100644
@@ -30,8 +30,6 @@
 #ifndef CRYPTO_BACKEND_H_
 #define CRYPTO_BACKEND_H_
 
-#include "config.h"
-
 #ifdef ENABLE_CRYPTO_OPENSSL
 #include "crypto_openssl.h"
 #endif
src/openvpn/openvpn.vcproj new file +769 -0
new file mode 100644
index 0000000..8a3f4b0
@@ -0,0 +1,769 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+       ProjectType="Visual C++"
+       Version="9.00"
+       Name="openvpn"
+       ProjectGUID="{29DF226E-4D4E-440F-ADAF-5829CFD4CA94}"
+       RootNamespace="openvpn"
+       Keyword="Win32Proj"
+       TargetFrameworkVersion="196613"
+       >
+       <Platforms>
+               <Platform
+                       Name="Win32"
+               />
+       </Platforms>
+       <ToolFiles>
+       </ToolFiles>
+       <Configurations>
+               <Configuration
+                       Name="Debug|Win32"
+                       OutputDirectory="$(SolutionDir)$(PlatformName)-Output\$(ConfigurationName)"
+                       IntermediateDirectory="$(ConfigurationName)"
+                       ConfigurationType="1"
+                       CharacterSet="2"
+                       >
+                       <Tool
+                               Name="VCPreBuildEventTool"
+                       />
+                       <Tool
+                               Name="VCCustomBuildTool"
+                       />
+                       <Tool
+                               Name="VCXMLDataGeneratorTool"
+                       />
+                       <Tool
+                               Name="VCWebServiceProxyGeneratorTool"
+                       />
+                       <Tool
+                               Name="VCMIDLTool"
+                       />
+                       <Tool
+                               Name="VCCLCompilerTool"
+                               Optimization="0"
+                               AdditionalIncludeDirectories="$(SOURCEBASE);$(SOURCEBASE)/include;$(OPENSSL_HOME)/include;$(LZO_HOME)/include;$(PKCS11H_HOME)/include"
+                               PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;$(CPPFLAGS)"
+                               MinimalRebuild="true"
+                               BasicRuntimeChecks="3"
+                               RuntimeLibrary="3"
+                               UsePrecompiledHeader="0"
+                               WarningLevel="3"
+                               DebugInformationFormat="4"
+                       />
+                       <Tool
+                               Name="VCManagedResourceCompilerTool"
+                       />
+                       <Tool
+                               Name="VCResourceCompilerTool"
+                               AdditionalIncludeDirectories="$(SOURCEBASE)"
+                       />
+                       <Tool
+                               Name="VCPreLinkEventTool"
+                       />
+                       <Tool
+                               Name="VCLinkerTool"
+                               AdditionalDependencies="libeay32.lib ssleay32.lib lzo2.lib pkcs11-helper.dll.lib gdi32.lib ws2_32.lib wininet.lib crypt32.lib iphlpapi.lib winmm.lib shell32.lib"
+                               LinkIncremental="2"
+                               AdditionalLibraryDirectories="$(OPENSSL_HOME)/lib;$(LZO_HOME)/lib;$(PKCS11H_HOME)/lib"
+                               GenerateDebugInformation="true"
+                               SubSystem="1"
+                               TargetMachine="1"
+                       />
+                       <Tool
+                               Name="VCALinkTool"
+                       />
+                       <Tool
+                               Name="VCManifestTool"
+                       />
+                       <Tool
+                               Name="VCXDCMakeTool"
+                       />
+                       <Tool
+                               Name="VCBscMakeTool"
+                       />
+                       <Tool
+                               Name="VCFxCopTool"
+                       />
+                       <Tool
+                               Name="VCAppVerifierTool"
+                       />
+                       <Tool
+                               Name="VCPostBuildEventTool"
+                       />
+               </Configuration>
+               <Configuration
+                       Name="Release|Win32"
+                       OutputDirectory="$(SolutionDir)$(PlatformName)-Output\$(ConfigurationName)"
+                       IntermediateDirectory="$(ConfigurationName)"
+                       ConfigurationType="1"
+                       CharacterSet="2"
+                       WholeProgramOptimization="1"
+                       >
+                       <Tool
+                               Name="VCPreBuildEventTool"
+                       />
+                       <Tool
+                               Name="VCCustomBuildTool"
+                       />
+                       <Tool
+                               Name="VCXMLDataGeneratorTool"
+                       />
+                       <Tool
+                               Name="VCWebServiceProxyGeneratorTool"
+                       />
+                       <Tool
+                               Name="VCMIDLTool"
+                       />
+                       <Tool
+                               Name="VCCLCompilerTool"
+                               Optimization="2"
+                               EnableIntrinsicFunctions="true"
+                               AdditionalIncludeDirectories="$(SOURCEBASE);$(SOURCEBASE)/include;$(OPENSSL_HOME)/include;$(LZO_HOME)/include;$(PKCS11H_HOME)/include"
+                               PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;$(CPPFLAGS)"
+                               RuntimeLibrary="2"
+                               EnableFunctionLevelLinking="true"
+                               UsePrecompiledHeader="0"
+                               WarningLevel="3"
+                               DebugInformationFormat="3"
+                       />
+                       <Tool
+                               Name="VCManagedResourceCompilerTool"
+                       />
+                       <Tool
+                               Name="VCResourceCompilerTool"
+                               AdditionalIncludeDirectories="$(SOURCEBASE)"
+                       />
+                       <Tool
+                               Name="VCPreLinkEventTool"
+                       />
+                       <Tool
+                               Name="VCLinkerTool"
+                               AdditionalDependencies="libeay32.lib ssleay32.lib lzo2.lib pkcs11-helper.dll.lib gdi32.lib ws2_32.lib wininet.lib crypt32.lib iphlpapi.lib winmm.lib shell32.lib"
+                               LinkIncremental="1"
+                               AdditionalLibraryDirectories="$(OPENSSL_HOME)/lib;$(LZO_HOME)/lib;$(PKCS11H_HOME)/lib"
+                               GenerateDebugInformation="true"
+                               SubSystem="1"
+                               OptimizeReferences="2"
+                               EnableCOMDATFolding="2"
+                               TargetMachine="1"
+                       />
+                       <Tool
+                               Name="VCALinkTool"
+                       />
+                       <Tool
+                               Name="VCManifestTool"
+                       />
+                       <Tool
+                               Name="VCXDCMakeTool"
+                       />
+                       <Tool
+                               Name="VCBscMakeTool"
+                       />
+                       <Tool
+                               Name="VCFxCopTool"
+                       />
+                       <Tool
+                               Name="VCAppVerifierTool"
+                       />
+                       <Tool
+                               Name="VCPostBuildEventTool"
+                       />
+               </Configuration>
+       </Configurations>
+       <References>
+       </References>
+       <Files>
+               <Filter
+                       Name="Source Files"
+                       Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
+                       UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
+                       >
+                       <File
+                               RelativePath=".\base64.c"
+                               >
+                       </File>
+                       <File
+                               RelativePath=".\buffer.c"
+                               >
+                       </File>
+                       <File
+                               RelativePath=".\clinat.c"
+                               >
+                       </File>
+                       <File
+                               RelativePath=".\compat.c"
+                               >
+                       </File>
+                       <File
+                               RelativePath=".\crypto.c"
+                               >
+                       </File>
+                       <File
+                               RelativePath=".\crypto_openssl.c"
+                               >
+                       </File>
+                       <File
+                               RelativePath=".\cryptoapi.c"
+                               >
+                       </File>
+                       <File
+                               RelativePath=".\dhcp.c"
+                               >
+                       </File>
+                       <File
+                               RelativePath=".\error.c"
+                               >
+                       </File>
+                       <File
+                               RelativePath=".\event.c"
+                               >
+                       </File>
+                       <File
+                               RelativePath=".\fdmisc.c"
+                               >
+                       </File>
+                       <File
+                               RelativePath=".\forward.c"
+                               >
+                       </File>
+                       <File
+                               RelativePath=".\fragment.c"
+                               >
+                       </File>
+                       <File
+                               RelativePath=".\gremlin.c"
+                               >
+                       </File>
+                       <File
+                               RelativePath=".\helper.c"
+                               >
+                       </File>
+                       <File
+                               RelativePath=".\httpdigest.c"
+                               >
+                       </File>
+                       <File
+                               RelativePath=".\init.c"
+                               >
+                       </File>
+                       <File
+                               RelativePath=".\interval.c"
+                               >
+                       </File>
+                       <File
+                               RelativePath=".\list.c"
+                               >
+                       </File>
+                       <File
+                               RelativePath=".\lladdr.c"
+                               >
+                       </File>
+                       <File
+                               RelativePath=".\lzo.c"
+                               >
+                       </File>
+                       <File
+                               RelativePath=".\manage.c"
+                               >
+                       </File>
+                       <File
+                               RelativePath=".\mbuf.c"
+                               >
+                       </File>
+                       <File
+                               RelativePath=".\misc.c"
+                               >
+                       </File>
+                       <File
+                               RelativePath=".\mroute.c"
+                               >
+                       </File>
+                       <File
+                               RelativePath=".\mss.c"
+                               >
+                       </File>
+                       <File
+                               RelativePath=".\mstats.c"
+                               >
+                       </File>
+                       <File
+                               RelativePath=".\mtcp.c"
+                               >
+                       </File>
+                       <File
+                               RelativePath=".\mtu.c"
+                               >
+                       </File>
+                       <File
+                               RelativePath=".\mudp.c"
+                               >
+                       </File>
+                       <File
+                               RelativePath=".\multi.c"
+                               >
+                       </File>
+                       <File
+                               RelativePath=".\ntlm.c"
+                               >
+                       </File>
+                       <File
+                               RelativePath=".\occ.c"
+                               >
+                       </File>
+                       <File
+                               RelativePath=".\openvpn.c"
+                               >
+                       </File>
+                       <File
+                               RelativePath=".\options.c"
+                               >
+                       </File>
+                       <File
+                               RelativePath=".\otime.c"
+                               >
+                       </File>
+                       <File
+                               RelativePath=".\packet_id.c"
+                               >
+                       </File>
+                       <File
+                               RelativePath=".\perf.c"
+                               >
+                       </File>
+                       <File
+                               RelativePath=".\pf.c"
+                               >
+                       </File>
+                       <File
+                               RelativePath=".\ping.c"
+                               >
+                       </File>
+                       <File
+                               RelativePath=".\pkcs11.c"
+                               >
+                       </File>
+                       <File
+                               RelativePath=".\pkcs11_openssl.c"
+                               >
+                       </File>
+                       <File
+                               RelativePath=".\plugin.c"
+                               >
+                       </File>
+                       <File
+                               RelativePath=".\pool.c"
+                               >
+                       </File>
+                       <File
+                               RelativePath=".\proto.c"
+                               >
+                       </File>
+                       <File
+                               RelativePath=".\proxy.c"
+                               >
+                       </File>
+                       <File
+                               RelativePath=".\ps.c"
+                               >
+                       </File>
+                       <File
+                               RelativePath=".\push.c"
+                               >
+                       </File>
+                       <File
+                               RelativePath=".\reliable.c"
+                               >
+                       </File>
+                       <File
+                               RelativePath=".\route.c"
+                               >
+                       </File>
+                       <File
+                               RelativePath=".\schedule.c"
+                               >
+                       </File>
+                       <File
+                               RelativePath=".\session_id.c"
+                               >
+                       </File>
+                       <File
+                               RelativePath=".\shaper.c"
+                               >
+                       </File>
+                       <File
+                               RelativePath=".\sig.c"
+                               >
+                       </File>
+                       <File
+                               RelativePath=".\socket.c"
+                               >
+                       </File>
+                       <File
+                               RelativePath=".\socks.c"
+                               >
+                       </File>
+                       <File
+                               RelativePath=".\ssl.c"
+                               >
+                       </File>
+                       <File
+                               RelativePath=".\ssl_openssl.c"
+                               >
+                       </File>
+                       <File
+                               RelativePath=".\ssl_verify.c"
+                               >
+                       </File>
+                       <File
+                               RelativePath=".\ssl_verify_openssl.c"
+                               >
+                       </File>
+                       <File
+                               RelativePath=".\status.c"
+                               >
+                       </File>
+                       <File
+                               RelativePath=".\tun.c"
+                               >
+                       </File>
+                       <File
+                               RelativePath=".\win32.c"
+                               >
+                       </File>
+               </Filter>
+               <Filter
+                       Name="Header Files"
+                       Filter="h;hpp;hxx;hm;inl;inc;xsd"
+                       UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
+                       >
+                       <File
+                               RelativePath=".\base64.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath=".\basic.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath=".\buffer.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath=".\circ_list.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath=".\clinat.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath=".\common.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath=".\compat.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath=".\crypto.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath=".\crypto_backend.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath=".\crypto_openssl.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath=".\cryptoapi.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath=".\dhcp.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath=".\errlevel.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath=".\error.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath=".\event.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath=".\fdmisc.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath=".\forward-inline.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath=".\forward.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath=".\fragment.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath=".\gremlin.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath=".\helper.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath=".\httpdigest.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath=".\init.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath=".\integer.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath=".\interval.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath=".\list.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath=".\lladdr.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath=".\lzo.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath=".\manage.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath=".\mbuf.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath=".\memdbg.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath=".\misc.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath=".\mroute.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath=".\mss.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath=".\mstats.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath=".\mtcp.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath=".\mtu.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath=".\mudp.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath=".\multi.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath=".\ntlm.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath=".\occ-inline.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath=".\occ.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath=".\openvpn.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath=".\options.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath=".\otime.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath=".\packet_id.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath=".\perf.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath=".\pf-inline.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath=".\pf.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath=".\ping-inline.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath=".\ping.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath=".\pkcs11.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath=".\pkcs11_backend.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath=".\plugin.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath=".\pool.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath=".\proto.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath=".\proxy.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath=".\ps.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath=".\push.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath=".\pushlist.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath=".\reliable.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath=".\route.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath=".\schedule.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath=".\session_id.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath=".\shaper.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath=".\sig.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath=".\socket.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath=".\socks.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath=".\ssl.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath=".\ssl_backend.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath=".\ssl_common.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath=".\ssl_openssl.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath=".\ssl_verify.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath=".\ssl_verify_backend.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath=".\ssl_verify_openssl.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath=".\status.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath=".\syshead.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath=".\tun.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath=".\win32.h"
+                               >
+                       </File>
+               </Filter>
+               <Filter
+                       Name="Resource Files"
+                       Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
+                       UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
+                       >
+                       <File
+                               RelativePath=".\openvpn_win32_resources.rc"
+                               >
+                       </File>
+               </Filter>
+       </Files>
+       <Globals>
+       </Globals>
+</VisualStudioProject>
src/openvpn/openvpn_win32_resources.rc +1 -1
index e91bfa1..c385baa 100644
@@ -1,7 +1,7 @@
 #ifdef HAVE_CONFIG_H
 #include <config.h>
 #else
-#include <config-msc-version.h>
+#include <config-msvc-version.h>
 #endif
 #include <winresrc.h>
 
src/openvpn/syshead.h +12 -2
index b82f9e4..bca842c 100644
@@ -28,11 +28,13 @@
 /*
  * Only include if not during configure
  */
-#ifndef PACKAGE_NAME
+#ifdef HAVE_CONFIG_H
 #include "config.h"
-#include "compat.h"
+#elif defined(_MSC_VER)
+#include "config-msvc.h"
 #endif
 
+#include "compat.h"
 
 /* branch prediction hints */
 #if defined(__GNUC__)
@@ -102,6 +104,14 @@
 #include <fcntl.h>
 #endif
 
+#ifdef HAVE_DIRECT_H
+#include <direct.h>
+#endif
+
+#ifdef HAVE_IO_H
+#include <io.h>
+#endif
+
 #ifdef HAVE_SYS_FILE_H
 #include <sys/file.h>
 #endif
src/openvpn/tun.c +1 -1
index 7b74ebd..9df7126 100644
@@ -3624,7 +3624,7 @@ get_adapter_index_method_1 (const char *guid)
   ULONG index = ~0;
   DWORD status;
   wchar_t wbuf[256];
-  snwprintf (wbuf, SIZE (wbuf), L"\\DEVICE\\TCPIP_%S", guid);
+  _snwprintf (wbuf, SIZE (wbuf), L"\\DEVICE\\TCPIP_%S", guid);
   wbuf [SIZE(wbuf) - 1] = 0;
   if ((status = GetAdapterIndex (wbuf, &index)) != NO_ERROR)
     index = ~0;
src/openvpn/win32.c +1 -1
index acf5ebc..7639bad 100644
@@ -611,7 +611,7 @@ window_title_generate (const char *title)
   struct buffer out = alloc_buf_gc (256, &gc);
   if (!title)
     title = "";
-  buf_printf (&out, "[%s] " PACKAGE_NAME " " VERSION " F4:EXIT F1:USR1 F2:USR2 F3:HUP", title);
+  buf_printf (&out, "[%s] " PACKAGE_NAME " " PACKAGE_VERSION " F4:EXIT F1:USR1 F2:USR2 F3:HUP", title);
   SetConsoleTitle (BSTR (&out));
   gc_free (&gc);
 }
src/openvpnserv/Makefile.am +3 -0
index 58005c0..8584b06 100644
@@ -13,6 +13,9 @@ include $(top_srcdir)/build/ltrc.inc
 
 MAINTAINERCLEANFILES = $(srcdir)/Makefile.in
 
+EXTRA_DIST = \
+       openvpnserv.vcproj
+
 if WIN32
 sbin_PROGRAMS = openvpnserv
 endif
src/openvpnserv/openvpnserv.c +10 -6
index 0993064..a9a9441 100755
@@ -33,7 +33,11 @@
  * This code is designed to be built with the mingw compiler.
  */
 
+#ifdef HAVE_CONFIG_H
 #include "config.h"
+#elif defined(_MSC_VER)
+#include "config-msvc.h"
+#endif
 #include <windows.h>
 #include <stdlib.h>
 #include <stdio.h>
@@ -196,7 +200,7 @@ match (const WIN32_FIND_DATA *find, const char *ext)
   if (i < 1)
     return false;
 
-  return find->cFileName[i] == '.' && !strcasecmp (find->cFileName + i + 1, ext);
+  return find->cFileName[i] == '.' && !_stricmp (find->cFileName + i + 1, ext);
 }
 
 /*
@@ -331,15 +335,15 @@ VOID ServiceStart (DWORD dwArgc, LPTSTR *lpszArgv)
 
   /* set process priority */
   priority = NORMAL_PRIORITY_CLASS;
-  if (!strcasecmp (priority_string, "IDLE_PRIORITY_CLASS"))
+  if (!_stricmp (priority_string, "IDLE_PRIORITY_CLASS"))
     priority = IDLE_PRIORITY_CLASS;
-  else if (!strcasecmp (priority_string, "BELOW_NORMAL_PRIORITY_CLASS"))
+  else if (!_stricmp (priority_string, "BELOW_NORMAL_PRIORITY_CLASS"))
     priority = BELOW_NORMAL_PRIORITY_CLASS;
-  else if (!strcasecmp (priority_string, "NORMAL_PRIORITY_CLASS"))
+  else if (!_stricmp (priority_string, "NORMAL_PRIORITY_CLASS"))
     priority = NORMAL_PRIORITY_CLASS;
-  else if (!strcasecmp (priority_string, "ABOVE_NORMAL_PRIORITY_CLASS"))
+  else if (!_stricmp (priority_string, "ABOVE_NORMAL_PRIORITY_CLASS"))
     priority = ABOVE_NORMAL_PRIORITY_CLASS;
-  else if (!strcasecmp (priority_string, "HIGH_PRIORITY_CLASS"))
+  else if (!_stricmp (priority_string, "HIGH_PRIORITY_CLASS"))
     priority = HIGH_PRIORITY_CLASS;
   else
     {
src/openvpnserv/openvpnserv.vcproj new file +209 -0
new file mode 100644
index 0000000..4c55561
@@ -0,0 +1,209 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+       ProjectType="Visual C++"
+       Version="9.00"
+       Name="openvpnserv"
+       ProjectGUID="{9C91EE0B-817D-420A-A1E6-15A5A9D98BAD}"
+       RootNamespace="openvpnserv"
+       Keyword="Win32Proj"
+       TargetFrameworkVersion="196613"
+       >
+       <Platforms>
+               <Platform
+                       Name="Win32"
+               />
+       </Platforms>
+       <ToolFiles>
+       </ToolFiles>
+       <Configurations>
+               <Configuration
+                       Name="Debug|Win32"
+                       OutputDirectory="$(SolutionDir)$(PlatformName)-Output\$(ConfigurationName)"
+                       IntermediateDirectory="$(ConfigurationName)"
+                       ConfigurationType="1"
+                       CharacterSet="2"
+                       >
+                       <Tool
+                               Name="VCPreBuildEventTool"
+                       />
+                       <Tool
+                               Name="VCCustomBuildTool"
+                       />
+                       <Tool
+                               Name="VCXMLDataGeneratorTool"
+                       />
+                       <Tool
+                               Name="VCWebServiceProxyGeneratorTool"
+                       />
+                       <Tool
+                               Name="VCMIDLTool"
+                       />
+                       <Tool
+                               Name="VCCLCompilerTool"
+                               Optimization="0"
+                               AdditionalIncludeDirectories="$(SOURCEBASE)"
+                               PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;$(CPPFLAGS)"
+                               MinimalRebuild="true"
+                               BasicRuntimeChecks="3"
+                               RuntimeLibrary="3"
+                               UsePrecompiledHeader="0"
+                               WarningLevel="3"
+                               DebugInformationFormat="4"
+                       />
+                       <Tool
+                               Name="VCManagedResourceCompilerTool"
+                       />
+                       <Tool
+                               Name="VCResourceCompilerTool"
+                               AdditionalIncludeDirectories="$(SOURCEBASE)"
+                       />
+                       <Tool
+                               Name="VCPreLinkEventTool"
+                       />
+                       <Tool
+                               Name="VCLinkerTool"
+                               LinkIncremental="2"
+                               GenerateDebugInformation="true"
+                               SubSystem="1"
+                               TargetMachine="1"
+                       />
+                       <Tool
+                               Name="VCALinkTool"
+                       />
+                       <Tool
+                               Name="VCManifestTool"
+                       />
+                       <Tool
+                               Name="VCXDCMakeTool"
+                       />
+                       <Tool
+                               Name="VCBscMakeTool"
+                       />
+                       <Tool
+                               Name="VCFxCopTool"
+                       />
+                       <Tool
+                               Name="VCAppVerifierTool"
+                       />
+                       <Tool
+                               Name="VCPostBuildEventTool"
+                       />
+               </Configuration>
+               <Configuration
+                       Name="Release|Win32"
+                       OutputDirectory="$(SolutionDir)$(PlatformName)-Output\$(ConfigurationName)"
+                       IntermediateDirectory="$(ConfigurationName)"
+                       ConfigurationType="1"
+                       CharacterSet="2"
+                       WholeProgramOptimization="1"
+                       >
+                       <Tool
+                               Name="VCPreBuildEventTool"
+                       />
+                       <Tool
+                               Name="VCCustomBuildTool"
+                       />
+                       <Tool
+                               Name="VCXMLDataGeneratorTool"
+                       />
+                       <Tool
+                               Name="VCWebServiceProxyGeneratorTool"
+                       />
+                       <Tool
+                               Name="VCMIDLTool"
+                       />
+                       <Tool
+                               Name="VCCLCompilerTool"
+                               Optimization="2"
+                               EnableIntrinsicFunctions="true"
+                               AdditionalIncludeDirectories="$(SOURCEBASE)"
+                               PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;$(CPPFLAGS)"
+                               RuntimeLibrary="2"
+                               EnableFunctionLevelLinking="true"
+                               UsePrecompiledHeader="0"
+                               WarningLevel="3"
+                               DebugInformationFormat="3"
+                       />
+                       <Tool
+                               Name="VCManagedResourceCompilerTool"
+                       />
+                       <Tool
+                               Name="VCResourceCompilerTool"
+                               AdditionalIncludeDirectories="$(SOURCEBASE)"
+                       />
+                       <Tool
+                               Name="VCPreLinkEventTool"
+                       />
+                       <Tool
+                               Name="VCLinkerTool"
+                               LinkIncremental="1"
+                               GenerateDebugInformation="true"
+                               SubSystem="1"
+                               OptimizeReferences="2"
+                               EnableCOMDATFolding="2"
+                               TargetMachine="1"
+                       />
+                       <Tool
+                               Name="VCALinkTool"
+                       />
+                       <Tool
+                               Name="VCManifestTool"
+                       />
+                       <Tool
+                               Name="VCXDCMakeTool"
+                       />
+                       <Tool
+                               Name="VCBscMakeTool"
+                       />
+                       <Tool
+                               Name="VCFxCopTool"
+                       />
+                       <Tool
+                               Name="VCAppVerifierTool"
+                       />
+                       <Tool
+                               Name="VCPostBuildEventTool"
+                       />
+               </Configuration>
+       </Configurations>
+       <References>
+       </References>
+       <Files>
+               <Filter
+                       Name="Source Files"
+                       Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
+                       UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
+                       >
+                       <File
+                               RelativePath=".\openvpnserv.c"
+                               >
+                       </File>
+                       <File
+                               RelativePath=".\service.c"
+                               >
+                       </File>
+               </Filter>
+               <Filter
+                       Name="Header Files"
+                       Filter="h;hpp;hxx;hm;inl;inc;xsd"
+                       UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
+                       >
+                       <File
+                               RelativePath=".\service.h"
+                               >
+                       </File>
+               </Filter>
+               <Filter
+                       Name="Resource Files"
+                       Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
+                       UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
+                       >
+                       <File
+                               RelativePath=".\openvpnserv_resources.rc"
+                               >
+                       </File>
+               </Filter>
+       </Files>
+       <Globals>
+       </Globals>
+</VisualStudioProject>
src/openvpnserv/openvpnserv_resources.rc +1 -1
index b87f4a3..c5a7bf6 100644
@@ -1,7 +1,7 @@
 #ifdef HAVE_CONFIG_H
 #include <config.h>
 #else
-#include <config-msc-version.h>
+#include <config-msvc-version.h>
 #endif
 #include <winresrc.h>
 
src/openvpnserv/service.c +5 -0
index 91b5821..d7562b3 100644
@@ -23,6 +23,11 @@ FUNCTIONS:
 
 ---------------------------------------------------------------------------*/
 
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#elif defined(_MSC_VER)
+#include "config-msvc.h"
+#endif
 #include <windows.h>
 #include <stdio.h>
 #include <stdlib.h>
src/openvpnserv/service.h +0 -3
index cf41ed7..e89a89f 100644
@@ -57,8 +57,6 @@ Copyright (C) 1993 - 2000.  Microsoft Corporation.  All rights reserved.
 extern "C" {
 #endif
 
-#include "config.h"
-
 //////////////////////////////////////////////////////////////////////////////
 //// todo: change to desired strings
 ////
--

1.7.3.4

------------------------------------------------------------------------------
Virtualization & Cloud Management Using Capacity Planning Cloud computing makes use of virtualization - but cloud computing also focuses on allowing computing to be delivered as a service.
http://www.accelacomm.com/jaw/sfnl/114/51521223/
_______________________________________________
Openvpn-devel mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel

#87 lore raw

Re: [Openvpn-devel] [PATCH 44/52] build: split out compat

In reply to Alon Bar-Lev

The commit message makes sense to me, so it's a feature-ACK. Somebody else might want to look at the code itself.

Signature · 5 lines
Samuli Seppänen
Community Manager
OpenVPN Technologies, Inc

irc freenode net: mattock
Quoted 820 lines

compat should not use any of the main project headers or conventions, it should be a standalone library that provides missing library functions.

---
 configure.ac                 |    3 +-
 openvpn.sln                  |    7 ++
 src/Makefile.am              |    2 +-
 src/compat/Makefile.am       |   23 ++++++
 src/compat/compat-basename.c |   50 ++++++++++++
 src/compat/compat-dirname.c  |  119 +++++++++++++++++++++++++++
 src/compat/compat.h          |   36 ++++++++
 src/compat/compat.vcproj     |  181 ++++++++++++++++++++++++++++++++++++++++++
 src/openvpn/Makefile.am      |    6 +-
 src/openvpn/compat.c         |  135 -------------------------------
 src/openvpn/compat.h         |   40 ---------
 src/openvpn/openvpn.vcproj   |   12 +---
 src/openvpn/syshead.h        |    4 +
 13 files changed, 429 insertions(+), 189 deletions(-)
 create mode 100644 src/compat/Makefile.am
 create mode 100644 src/compat/compat-basename.c
 create mode 100644 src/compat/compat-dirname.c
 create mode 100644 src/compat/compat.h
 create mode 100644 src/compat/compat.vcproj
 delete mode 100644 src/openvpn/compat.c
 delete mode 100644 src/openvpn/compat.h
configure.ac +2 -1
index f5663eb..ff3df28 100644
@@ -365,7 +365,7 @@ AC_CHECK_HEADERS([ \
 AC_CHECK_HEADERS([ \
        sys/time.h sys/un.h sys/ioctl.h sys/stat.h \
        sys/mman.h sys/file.h \
-       unistd.h signal.h  \
+       unistd.h signal.h libgen.h \
        syslog.h pwd.h grp.h \
        net/if_tun.h net/tun/if_tun.h stropts.h \
        sys/sockio.h \
@@ -914,6 +914,7 @@ AC_CONFIG_FILES([
        distro/rpm/openvpn.spec
        include/Makefile
        src/Makefile
+       src/compat/Makefile
        src/openvpn/Makefile
        src/openvpnserv/Makefile
        tests/Makefile
openvpn.sln +7 -0
index cbd2093..be35d16 100644
@@ -8,6 +8,7 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "openvpnserv", "src\openvpns
 EndProject
 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "openvpn", "src\openvpn\openvpn.vcproj", "{29DF226E-4D4E-440F-ADAF-5829CFD4CA94}"
        ProjectSection(ProjectDependencies) = postProject
+               {4B2E2719-E661-45D7-9203-F6F456B22F19} = {4B2E2719-E661-45D7-9203-F6F456B22F19}
                {8598C2C8-34C4-47A1-99B0-7C295A890615} = {8598C2C8-34C4-47A1-99B0-7C295A890615}
        EndProjectSection
 EndProject
@@ -20,6 +21,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "misc", "misc", "{1AA03DE8-3
 EndProject
 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "msvc-generate", "build\msvc\msvc-generate\msvc-generate.vcproj", "{8598C2C8-34C4-47A1-99B0-7C295A890615}"
 EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "compat", "src\compat\compat.vcproj", "{4B2E2719-E661-45D7-9203-F6F456B22F19}"
+EndProject
 Global
        GlobalSection(SolutionConfigurationPlatforms) = preSolution
                Debug|Win32 = Debug|Win32
@@ -38,6 +41,10 @@ Global
                {8598C2C8-34C4-47A1-99B0-7C295A890615}.Debug|Win32.Build.0 = Debug|Win32
                {8598C2C8-34C4-47A1-99B0-7C295A890615}.Release|Win32.ActiveCfg = Release|Win32
                {8598C2C8-34C4-47A1-99B0-7C295A890615}.Release|Win32.Build.0 = Release|Win32
+               {4B2E2719-E661-45D7-9203-F6F456B22F19}.Debug|Win32.ActiveCfg = Debug|Win32
+               {4B2E2719-E661-45D7-9203-F6F456B22F19}.Debug|Win32.Build.0 = Debug|Win32
+               {4B2E2719-E661-45D7-9203-F6F456B22F19}.Release|Win32.ActiveCfg = Release|Win32
+               {4B2E2719-E661-45D7-9203-F6F456B22F19}.Release|Win32.Build.0 = Release|Win32
        EndGlobalSection
        GlobalSection(SolutionProperties) = preSolution
                HideSolutionNode = FALSE
src/Makefile.am +1 -1
index f2481c2..b894977 100644
@@ -15,4 +15,4 @@ MAINTAINERCLEANFILES = \
 EXTRA_DIST = \
        plugins
 
-SUBDIRS = openvpn openvpnserv
+SUBDIRS = compat openvpn openvpnserv
src/compat/Makefile.am new file +23 -0
new file mode 100644
index 0000000..e33e5e7
@@ -0,0 +1,23 @@
+#
+#  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. <[email protected]...>
+#  Copyright (C) 2006-2012 Alon Bar-Lev <[email protected]...>
+#
+
+MAINTAINERCLEANFILES = \
+       $(srcdir)/Makefile.in
+
+EXTRA_DIST = \
+       compat.vcproj
+
+noinst_LTLIBRARIES = libcompat.la
+
+libcompat_la_SOURCES = \
+       compat.h \
+       compat-dirname.c \
+       compat-basename.c
src/compat/compat-basename.c new file +50 -0
new file mode 100644
index 0000000..a057691
@@ -0,0 +1,50 @@
+/*
+ *  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) 2011 - David Sommerseth <[email protected]...>
+ *
+ *  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
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#elif defined(_MSC_VER)
+#include "config-msvc.h"
+#endif
+
+#ifndef HAVE_BASENAME
+
+#include "compat.h"
+#include <string.h>
+
+/* Modified version based on glibc-2.14.1 by Roland McGrath <[email protected]...>
+ * This version is extended to handle both / and \ in path names
+ */
+char *
+basename (char *filename)
+{
+  char *p = strrchr (filename, '/');
+  if (!p) {
+    /* If NULL, check for \ instead ... might be Windows a path */
+    p = strrchr (filename, '\\');
+  }
+  return p ? p + 1 : (char *) filename;
+}
+
+#endif /* HAVE_BASENAME */
src/compat/compat-dirname.c new file +119 -0
new file mode 100644
index 0000000..8878595
@@ -0,0 +1,119 @@
+/*
+ *  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) 2011 - David Sommerseth <[email protected]...>
+ *
+ *  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
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#elif defined(_MSC_VER)
+#include "config-msvc.h"
+#endif
+
+
+#ifndef HAVE_DIRNAME
+
+#include "compat.h"
+#include <string.h>
+
+/* Unoptimised version of glibc memrchr().
+ * This is considered fast enough, as only this compat
+ * version of dirname() depends on it.
+ */
+static const char *
+__memrchr(const char *str, int c, size_t n)
+{
+  const char *end = str;
+
+  end += n - 1; /* Go to the end of the string */
+  while (end >= str) {
+    if(c == *end)
+      return end;
+    else
+      end--;
+  }
+  return NULL;
+}
+
+/* Modified version based on glibc-2.14.1 by Ulrich Drepper <[email protected]...>
+ * This version is extended to handle both / and \ in path names.
+ */
+char *
+dirname (char *path)
+{
+  static const char dot[] = ".";
+  char *last_slash;
+  char separator = '/';
+
+  /* Find last '/'.  */
+  last_slash = path != NULL ? strrchr (path, '/') : NULL;
+  /* If NULL, check for \ instead ... might be Windows a path */
+  if (!last_slash) {
+    last_slash = path != NULL ? strrchr (path, '\\') : NULL;
+    separator = last_slash ? '\\' : '/';  /* Change the separator if \ was found */
+  }
+
+  if (last_slash != NULL && last_slash != path && last_slash[1] == '\0') {
+      /* Determine whether all remaining characters are slashes.  */
+      char *runp;
+
+      for (runp = last_slash; runp != path; --runp)
+       if (runp[-1] != separator)
+         break;
+
+      /* The '/' is the last character, we have to look further.  */
+      if (runp != path)
+       last_slash = (char *) __memrchr (path, separator, runp - path);
+    }
+
+  if (last_slash != NULL) {
+      /* Determine whether all remaining characters are slashes.  */
+      char *runp;
+
+      for (runp = last_slash; runp != path; --runp)
+       if (runp[-1] != separator)
+         break;
+
+      /* Terminate the path.  */
+      if (runp == path) {
+         /* The last slash is the first character in the string.  We have to
+            return "/".  As a special case we have to return "//" if there
+            are exactly two slashes at the beginning of the string.  See
+            XBD 4.10 Path Name Resolution for more information.  */
+         if (last_slash == path + 1)
+           ++last_slash;
+         else
+           last_slash = path + 1;
+       }
+      else
+       last_slash = runp;
+
+      last_slash[0] = '\0';
+  } else
+    /* This assignment is ill-designed but the XPG specs require to
+       return a string containing "." in any case no directory part is
+       found and so a static and constant string is required.  */
+    path = (char *) dot;
+
+  return path;
+}
+
+#endif /* HAVE_DIRNAME */
src/compat/compat.h new file +36 -0
new file mode 100644
index 0000000..57754da
@@ -0,0 +1,36 @@
+/*
+ *  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) 2011 - David Sommerseth <[email protected]...>
+ *
+ *  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
+ */
+
+#ifndef COMPAT_H
+#define COMPAT_H
+
+#ifndef HAVE_DIRNAME
+char * dirname(char *str);
+#endif /* HAVE_DIRNAME */
+
+#ifndef HAVE_BASENAME
+char * basename(char *str);
+#endif /* HAVE_BASENAME */
+
+#endif /* COMPAT_H */
src/compat/compat.vcproj new file +181 -0
new file mode 100644
index 0000000..1ece749
@@ -0,0 +1,181 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+       ProjectType="Visual C++"
+       Version="9.00"
+       Name="compat"
+       ProjectGUID="{4B2E2719-E661-45D7-9203-F6F456B22F19}"
+       RootNamespace="compat"
+       Keyword="Win32Proj"
+       TargetFrameworkVersion="196613"
+       >
+       <Platforms>
+               <Platform
+                       Name="Win32"
+               />
+       </Platforms>
+       <ToolFiles>
+       </ToolFiles>
+       <Configurations>
+               <Configuration
+                       Name="Debug|Win32"
+                       OutputDirectory="$(SolutionDir)$(PlatformName)-Output\$(ConfigurationName)"
+                       IntermediateDirectory="$(ConfigurationName)"
+                       ConfigurationType="4"
+                       CharacterSet="2"
+                       >
+                       <Tool
+                               Name="VCPreBuildEventTool"
+                       />
+                       <Tool
+                               Name="VCCustomBuildTool"
+                       />
+                       <Tool
+                               Name="VCXMLDataGeneratorTool"
+                       />
+                       <Tool
+                               Name="VCWebServiceProxyGeneratorTool"
+                       />
+                       <Tool
+                               Name="VCMIDLTool"
+                       />
+                       <Tool
+                               Name="VCCLCompilerTool"
+                               Optimization="0"
+                               AdditionalIncludeDirectories="$(SOURCEBASE);$(SOURCEBASE)/include;$(OPENSSL_HOME)/include;$(LZO_HOME)/include;$(PKCS11H_HOME)/include"
+                               PreprocessorDefinitions="WIN32;_DEBUG;_LIB;$(CPPFLAGS)"
+                               MinimalRebuild="true"
+                               BasicRuntimeChecks="3"
+                               RuntimeLibrary="3"
+                               UsePrecompiledHeader="0"
+                               WarningLevel="3"
+                               DebugInformationFormat="4"
+                       />
+                       <Tool
+                               Name="VCManagedResourceCompilerTool"
+                       />
+                       <Tool
+                               Name="VCResourceCompilerTool"
+                       />
+                       <Tool
+                               Name="VCPreLinkEventTool"
+                       />
+                       <Tool
+                               Name="VCLibrarianTool"
+                       />
+                       <Tool
+                               Name="VCALinkTool"
+                       />
+                       <Tool
+                               Name="VCXDCMakeTool"
+                       />
+                       <Tool
+                               Name="VCBscMakeTool"
+                       />
+                       <Tool
+                               Name="VCFxCopTool"
+                       />
+                       <Tool
+                               Name="VCPostBuildEventTool"
+                       />
+               </Configuration>
+               <Configuration
+                       Name="Release|Win32"
+                       OutputDirectory="$(SolutionDir)$(PlatformName)-Output\$(ConfigurationName)"
+                       IntermediateDirectory="$(ConfigurationName)"
+                       ConfigurationType="4"
+                       CharacterSet="2"
+                       WholeProgramOptimization="1"
+                       >
+                       <Tool
+                               Name="VCPreBuildEventTool"
+                       />
+                       <Tool
+                               Name="VCCustomBuildTool"
+                       />
+                       <Tool
+                               Name="VCXMLDataGeneratorTool"
+                       />
+                       <Tool
+                               Name="VCWebServiceProxyGeneratorTool"
+                       />
+                       <Tool
+                               Name="VCMIDLTool"
+                       />
+                       <Tool
+                               Name="VCCLCompilerTool"
+                               Optimization="2"
+                               EnableIntrinsicFunctions="true"
+                               AdditionalIncludeDirectories="$(SOURCEBASE);$(SOURCEBASE)/include;$(OPENSSL_HOME)/include;$(LZO_HOME)/include;$(PKCS11H_HOME)/include"
+                               PreprocessorDefinitions="WIN32;NDEBUG;_LIB;$(CPPFLAGS)"
+                               RuntimeLibrary="2"
+                               EnableFunctionLevelLinking="true"
+                               UsePrecompiledHeader="0"
+                               WarningLevel="3"
+                               DebugInformationFormat="3"
+                       />
+                       <Tool
+                               Name="VCManagedResourceCompilerTool"
+                       />
+                       <Tool
+                               Name="VCResourceCompilerTool"
+                       />
+                       <Tool
+                               Name="VCPreLinkEventTool"
+                       />
+                       <Tool
+                               Name="VCLibrarianTool"
+                       />
+                       <Tool
+                               Name="VCALinkTool"
+                       />
+                       <Tool
+                               Name="VCXDCMakeTool"
+                       />
+                       <Tool
+                               Name="VCBscMakeTool"
+                       />
+                       <Tool
+                               Name="VCFxCopTool"
+                       />
+                       <Tool
+                               Name="VCPostBuildEventTool"
+                       />
+               </Configuration>
+       </Configurations>
+       <References>
+       </References>
+       <Files>
+               <Filter
+                       Name="Source Files"
+                       Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
+                       UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
+                       >
+                       <File
+                               RelativePath=".\compat-basename.c"
+                               >
+                       </File>
+                       <File
+                               RelativePath=".\compat-dirname.c"
+                               >
+                       </File>
+               </Filter>
+               <Filter
+                       Name="Header Files"
+                       Filter="h;hpp;hxx;hm;inl;inc;xsd"
+                       UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
+                       >
+                       <File
+                               RelativePath=".\compat.h"
+                               >
+                       </File>
+               </Filter>
+               <Filter
+                       Name="Resource Files"
+                       Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
+                       UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
+                       >
+               </Filter>
+       </Files>
+       <Globals>
+       </Globals>
+</VisualStudioProject>
src/openvpn/Makefile.am +4 -2
index 3d8c0a9..e170380 100644
@@ -17,7 +17,9 @@ MAINTAINERCLEANFILES = \
 EXTRA_DIST = \
        openvpn.vcproj
 
-INCLUDES = -I$(top_srcdir)/include
+INCLUDES = \
+       -I$(top_srcdir)/include \
+       -I$(top_srcdir)/src/compat
 
 AM_CFLAGS = \
        $(OPTIONAL_CRYPTO_CFLAGS) \
@@ -33,7 +35,6 @@ openvpn_SOURCES = \
        circ_list.h \
        clinat.c clinat.h \
        common.h \
-       compat.h compat.c \
        crypto.c crypto.h crypto_backend.h \
        crypto_openssl.c crypto_openssl.h \
        crypto_polarssl.c crypto_polarssl.h \
@@ -104,6 +105,7 @@ openvpn_SOURCES = \
        win32.h win32.c \
        cryptoapi.h cryptoapi.c
 openvpn_LDADD = \
+       $(top_builddir)/src/compat/libcompat.la \
        $(SOCKETS_LIBS) \
        $(OPTIONAL_LZO_LIBS) \
        $(OPTIONAL_PKCS11_HELPER_LIBS) \
src/openvpn/compat.c deleted +0 -135
deleted file mode 100644
index f2fa265..0000000
@@ -1,135 +0,0 @@
-/*
- *  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) 2011 - David Sommerseth <[email protected]...>
- *
- *  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
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#elif defined(_MSC_VER)
-#include "config-msvc.h"
-#endif
-
-#include "syshead.h"
-#include "compat.h"
-#include <string.h>
-
-
-#ifndef HAVE_DIRNAME
-/* Unoptimised version of glibc memrchr().
- * This is considered fast enough, as only this compat
- * version of dirname() depends on it.
- */
-static const char *
-__memrchr(const char *str, int c, size_t n)
-{
-  const char *end = str;
-
-  end += n - 1; /* Go to the end of the string */
-  while (end >= str) {
-    if(c == *end)
-      return end;
-    else
-      end--;
-  }
-  return NULL;
-}
-
-/* Modified version based on glibc-2.14.1 by Ulrich Drepper <[email protected]...>
- * This version is extended to handle both / and \ in path names.
- */
-char *
-dirname (char *path)
-{
-  static const char dot[] = ".";
-  char *last_slash;
-  char separator = '/';
-
-  /* Find last '/'.  */
-  last_slash = path != NULL ? strrchr (path, '/') : NULL;
-  /* If NULL, check for \ instead ... might be Windows a path */
-  if (!last_slash) {
-    last_slash = path != NULL ? strrchr (path, '\\') : NULL;
-    separator = last_slash ? '\\' : '/';  /* Change the separator if \ was found */
-  }
-
-  if (last_slash != NULL && last_slash != path && last_slash[1] == '\0') {
-      /* Determine whether all remaining characters are slashes.  */
-      char *runp;
-
-      for (runp = last_slash; runp != path; --runp)
-       if (runp[-1] != separator)
-         break;
-
-      /* The '/' is the last character, we have to look further.  */
-      if (runp != path)
-       last_slash = (char *) __memrchr (path, separator, runp - path);
-    }
-
-  if (last_slash != NULL) {
-      /* Determine whether all remaining characters are slashes.  */
-      char *runp;
-
-      for (runp = last_slash; runp != path; --runp)
-       if (runp[-1] != separator)
-         break;
-
-      /* Terminate the path.  */
-      if (runp == path) {
-         /* The last slash is the first character in the string.  We have to
-            return "/".  As a special case we have to return "//" if there
-            are exactly two slashes at the beginning of the string.  See
-            XBD 4.10 Path Name Resolution for more information.  */
-         if (last_slash == path + 1)
-           ++last_slash;
-         else
-           last_slash = path + 1;
-       }
-      else
-       last_slash = runp;
-
-      last_slash[0] = '\0';
-  } else
-    /* This assignment is ill-designed but the XPG specs require to
-       return a string containing "." in any case no directory part is
-       found and so a static and constant string is required.  */
-    path = (char *) dot;
-
-  return path;
-}
-#endif /* HAVE_DIRNAME */
-
-
-#ifndef HAVE_BASENAME
-/* Modified version based on glibc-2.14.1 by Roland McGrath <[email protected]...>
- * This version is extended to handle both / and \ in path names
- */
-char *
-basename (char *filename)
-{
-  char *p = strrchr (filename, '/');
-  if (!p) {
-    /* If NULL, check for \ instead ... might be Windows a path */
-    p = strrchr (filename, '\\');
-  }
-  return p ? p + 1 : (char *) filename;
-}
-#endif /* HAVE_BASENAME */
src/openvpn/compat.h deleted +0 -40
deleted file mode 100644
index 7af9fe2..0000000
@@ -1,40 +0,0 @@
-/*
- *  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) 2011 - David Sommerseth <[email protected]...>
- *
- *  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
- */
-
-#ifndef COMPAT_H
-#define COMPAT_H
-
-#if defined(HAVE_BASENAME) || defined(HAVE_DIRNAME)
-#include <libgen.h>
-#endif
-
-#ifndef HAVE_DIRNAME
-char * dirname(char *str);
-#endif /* HAVE_DIRNAME */
-
-#ifndef HAVE_BASENAME
-char * basename(char *str);
-#endif /* HAVE_BASENAME */
-
-#endif /* COMPAT_H */
src/openvpn/openvpn.vcproj +2 -10
index 8a3f4b0..45c0a77 100644
@@ -41,7 +41,7 @@
                        <Tool
                                Name="VCCLCompilerTool"
                                Optimization="0"
-                               AdditionalIncludeDirectories="$(SOURCEBASE);$(SOURCEBASE)/include;$(OPENSSL_HOME)/include;$(LZO_HOME)/include;$(PKCS11H_HOME)/include"
+                               AdditionalIncludeDirectories="$(SOURCEBASE);$(SOURCEBASE)/src/compat;$(SOURCEBASE)/include;$(OPENSSL_HOME)/include;$(LZO_HOME)/include;$(PKCS11H_HOME)/include"
                                PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;$(CPPFLAGS)"
                                MinimalRebuild="true"
                                BasicRuntimeChecks="3"
@@ -118,7 +118,7 @@
                                Name="VCCLCompilerTool"
                                Optimization="2"
                                EnableIntrinsicFunctions="true"
-                               AdditionalIncludeDirectories="$(SOURCEBASE);$(SOURCEBASE)/include;$(OPENSSL_HOME)/include;$(LZO_HOME)/include;$(PKCS11H_HOME)/include"
+                               AdditionalIncludeDirectories="$(SOURCEBASE);$(SOURCEBASE)/src/compat;$(SOURCEBASE)/include;$(OPENSSL_HOME)/include;$(LZO_HOME)/include;$(PKCS11H_HOME)/include"
                                PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;$(CPPFLAGS)"
                                RuntimeLibrary="2"
                                EnableFunctionLevelLinking="true"
@@ -191,10 +191,6 @@
                                >
                        </File>
                        <File
-                               RelativePath=".\compat.c"
-                               >
-                       </File>
-                       <File
                                RelativePath=".\crypto.c"
                                >
                        </File>
@@ -461,10 +457,6 @@
                                >
                        </File>
                        <File
-                               RelativePath=".\compat.h"
-                               >
-                       </File>
-                       <File
                                RelativePath=".\crypto.h"
                                >
                        </File>
src/openvpn/syshead.h +4 -1
index f9636f7..e8da88c 100644
@@ -181,6 +181,10 @@
 #include <selinux/selinux.h>
 #endif
 
+#if defined(HAVE_LIBGEN_H)
+#include <libgen.h>
+#endif
+
 #ifdef TARGET_SOLARIS
 #ifdef HAVE_STRINGS_H
 #include <strings.h>
--

1.7.3.4

------------------------------------------------------------------------------
Virtualization & Cloud Management Using Capacity Planning Cloud computing makes use of virtualization - but cloud computing also focuses on allowing computing to be delivered as a service.
http://www.accelacomm.com/jaw/sfnl/114/51521223/
_______________________________________________
Openvpn-devel mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel

#90 lore raw

Re: [Openvpn-devel] [PATCH 46/52] build: move daemon() emulation into compat

In reply to Alon Bar-Lev

Which platforms need daemon() emulation? Only Windows?

I think it makes sense to isolate OS compatibility functions to files under src/compat. Better than having them in misc.c. Also, I can't see any obvious issues with the patch, code-vise.

ACK.

Signature · 5 lines
Samuli Seppänen
Community Manager
OpenVPN Technologies, Inc

irc freenode net: mattock
Quoted 228 lines
---
 src/compat/Makefile.am     |    3 +-
 src/compat/compat-daemon.c |  100 ++++++++++++++++++++++++++++++++++++++++++++
 src/compat/compat.h        |    4 ++
 src/compat/compat.vcproj   |    4 ++
 src/openvpn/init.c         |    2 +-
 src/openvpn/misc.c         |   32 --------------
 src/openvpn/misc.h         |    4 --
 7 files changed, 111 insertions(+), 38 deletions(-)
 create mode 100644 src/compat/compat-daemon.c
src/compat/Makefile.am +2 -1
index 5e9db5f..c8a92ce 100644
@@ -21,4 +21,5 @@ libcompat_la_SOURCES = \
 	compat.h \
 	compat-dirname.c \
 	compat-basename.c \
-	compat-gettimeofday.c
+	compat-gettimeofday.c \
+	compat-daemon.c
src/compat/compat-daemon.c new file +100 -0
new file mode 100644
index 0000000..dde96a2
@@ -0,0 +1,100 @@
+/*
+ *  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) 2011 - David Sommerseth <[email protected]...>
+ *
+ *  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
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#elif defined(_MSC_VER)
+#include "config-msvc.h"
+#endif
+
+#ifndef HAVE_DAEMON
+
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+
+#ifdef HAVE_STDLIB_H
+#include <stdlib.h>
+#endif
+
+#ifdef HAVE_SYS_TYPES_H
+#include <sys/types.h>
+#endif
+
+#ifdef HAVE_SYS_STAT_H
+#include <sys/stat.h>
+#endif
+
+#ifdef HAVE_FCNTL_H
+#include <fcntl.h>
+#endif
+
+#ifdef HAVE_ERRNO_H
+#include <errno.h>
+#endif
+
+int
+daemon(int nochdir, int noclose)
+{
+#if defined(HAVE_FORK) && defined(HAVE_SETSID)
+	switch (fork()) {
+		case -1:
+			return (-1);
+		case 0:
+		break;
+		default:
+			exit(0);
+	}
+
+	if (setsid() == -1)
+		return (-1);
+
+	if (!nochdir)
+		chdir("/");
+
+	if (!noclose) {
+#if defined(HAVE_DUP) && defined(HAVE_DUP2)
+		int fd;
+		if ((fd = open ("/dev/null", O_RDWR, 0)) != -1) {
+			dup2 (fd, 0);
+			dup2 (fd, 1);
+			dup2 (fd, 2);
+			if (fd > 2) {
+				close (fd);
+			}
+		}
+#endif
+	}
+
+	return 0;
+#else
+	(void)nochdir;
+	(void)noclose;
+	errno = EFAULT;
+	return -1;
+#endif
+}
+
+#endif
+
src/compat/compat.h +4 -0
index 3f9ac31..e9d51b8 100644
@@ -46,4 +46,8 @@ char * basename(char *str);
 int gettimeofday (struct timeval *tv, void *tz);
 #endif
 
+#ifndef HAVE_DAEMON
+int daemon(int nochdir, int noclose);
+#endif
+
 #endif /* COMPAT_H */
src/compat/compat.vcproj +4 -0
index 235163c..efdecb4 100644
@@ -162,6 +162,10 @@
 				RelativePath=".\compat-gettimeofday.c"
 				>
 			</File>
+			<File
+				RelativePath=".\compat-daemon.c"
+				>
+			</File>
 		</Filter>
 		<Filter
 			Name="Header Files"
src/openvpn/init.c +1 -1
index e7edb05..bba3cf8 100644
@@ -993,7 +993,7 @@ possibly_become_daemon (const struct options *options, const bool first_time)
     {
       ASSERT (!options->inetd);
       if (daemon (options->cd_dir != NULL, options->log) < 0)
-	msg (M_ERR, "daemon() failed");
+	msg (M_ERR, "daemon() failed or unsupported");
       restore_signal_state ();
       if (options->log)
 	set_std_files_to_null (true);
src/openvpn/misc.c +0 -32
index 898a183..07beaf0 100644
@@ -301,38 +301,6 @@ do_mlockall(bool print_msg)
 #endif
 }
 
-#ifndef HAVE_DAEMON
-
-int
-daemon(int nochdir, int noclose)
-{
-#if defined(HAVE_FORK) && defined(HAVE_SETSID)
-  switch (fork())
-    {
-    case -1:
-      return (-1);
-    case 0:
-      break;
-    default:
-      openvpn_exit (OPENVPN_EXIT_STATUS_GOOD); /* exit point */
-    }
-
-  if (setsid() == -1)
-    return (-1);
-
-  if (!nochdir)
-    openvpn_chdir ("/");
-
-  if (!noclose)
-    set_std_files_to_null (false);
-#else
-  msg (M_FATAL, "Sorry but I can't become a daemon because this operating system doesn't appear to support either the daemon() or fork() system calls");
-#endif
-  return (0);
-}
-
-#endif
-
 /*
  * Set standard file descriptors to /dev/null
  */
src/openvpn/misc.h +0 -4
index 9fa8106..9bb2fa2 100644
@@ -115,10 +115,6 @@ unsigned int openvpn_getpid (void);
 
 void do_mlockall (bool print_msg); /* Disable paging */
 
-#ifndef HAVE_DAEMON
-int daemon (int nochdir, int noclose);
-#endif
-
 /* check file protections */
 void warn_if_group_others_accessible(const char* filename);
 
#93 lore raw

Re: [Openvpn-devel] [PATCH 47/52] build: move inet_ntop(), inet_pton() emulation into compat

In reply to Alon Bar-Lev

Windows has this functionality, but not under the same function names as UNIX. So thse two are just wrappers around the Windows-specific functionality. In any case, I think it makes sense to move inet_pton and inet_ntop under src/compat. The actual code changes seem fairly trivial.

ACK.

Signature · 11 lines
Samuli Seppänen
Community Manager
OpenVPN Technologies, Inc

irc freenode net: mattock


PS. These links should cover the basic idea, in case somebody is interested:

<http://us.generation-nt.com/inet-pton-windows-convert-address-presentation-format-network-format-help-37036482.html>
<http://pubs.opengroup.org/onlinepubs/009604599/functions/inet_ntop.html>
Quoted 363 lines

---
configure.ac I recall many issues with inet_ntop and inet_pton.

                |    2 +-
 src/compat/Makefile.am        |    4 ++-
 src/compat/compat-inet_ntop.c |   76 +++++++++++++++++++++++++++++++++++++++
 src/compat/compat-inet_pton.c |   79 +++++++++++++++++++++++++++++++++++++++++
 src/compat/compat.h           |   17 ++++++++-
 src/compat/compat.vcproj      |    8 ++++
 src/openvpn/socket.c          |   55 ----------------------------
 src/openvpn/win32.h           |    6 ---
 8 files changed, 183 insertions(+), 64 deletions(-)
 create mode 100644 src/compat/compat-inet_ntop.c
 create mode 100644 src/compat/compat-inet_pton.c
configure.ac +1 -1
index dc138ba..d53a74a 100644
@@ -522,7 +522,7 @@ AC_CHECK_FUNCS([ \
        chsize ftruncate execve getpeereid umask basename dirname access \
        epoll_create \
 ])
-AC_CHECK_FUNCS([sendmsg recvmsg])
+AC_CHECK_FUNCS([sendmsg recvmsg inet_ntop inet_pton])
 AC_CHECK_FUNCS(
        [res_init],
        ,
src/compat/Makefile.am +3 -1
index c8a92ce..91b7f40 100644
@@ -22,4 +22,6 @@ libcompat_la_SOURCES = \
        compat-dirname.c \
        compat-basename.c \
        compat-gettimeofday.c \
-       compat-daemon.c
+       compat-daemon.c \
+       compat-inet_ntop.c \
+       compat-inet_pton.c
src/compat/compat-inet_ntop.c new file +76 -0
new file mode 100644
index 0000000..0d52142
@@ -0,0 +1,76 @@
+/*
+ *  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) 2011 - David Sommerseth <[email protected]...>
+ *
+ *  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
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#elif defined(_MSC_VER)
+#include "config-msvc.h"
+#endif
+
+#ifndef HAVE_INET_NTOP
+
+#include "compat.h"
+
+#ifdef WIN32
+
+#include <windows.h>
+
+/*
+ * inet_ntop() and inet_pton() wrap-implementations using
+ * WSAAddressToString() and WSAStringToAddress() functions
+ *
+ * this is needed as long as we support running OpenVPN on WinXP
+ */
+
+const char *
+inet_ntop(int af, const void *src, char *dst, socklen_t size)
+{
+  struct sockaddr_storage ss;
+  unsigned long s = size;
+
+  ZeroMemory(&ss, sizeof(ss));
+  ss.ss_family = af;
+
+  switch(af) {
+    case AF_INET:
+      ((struct sockaddr_in *)&ss)->sin_addr = *(struct in_addr *)src;
+      break;
+    case AF_INET6:
+      ((struct sockaddr_in6 *)&ss)->sin6_addr = *(struct in6_addr *)src;
+      break;
+    default:
+      return NULL;
+  }
+  /* cannot direclty use &size because of strict aliasing rules */
+  return (WSAAddressToString((struct sockaddr *)&ss, sizeof(ss), NULL, dst, &s) == 0)?
+          dst : NULL;
+}
+
+#else
+
+#error no emulation for inet_ntop
+
+#endif
+
+#endif
src/compat/compat-inet_pton.c new file +79 -0
new file mode 100644
index 0000000..cdc8d4b
@@ -0,0 +1,79 @@
+/*
+ *  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) 2011 - David Sommerseth <[email protected]...>
+ *
+ *  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
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#elif defined(_MSC_VER)
+#include "config-msvc.h"
+#endif
+
+#ifndef HAVE_INET_PTON
+
+#include "compat.h"
+
+#ifdef WIN32
+
+#include <windows.h>
+#include <string.h>
+
+/*
+ * inet_ntop() and inet_pton() wrap-implementations using
+ * WSAAddressToString() and WSAStringToAddress() functions
+ *
+ * this is needed as long as we support running OpenVPN on WinXP
+ */
+
+
+int
+inet_pton(int af, const char *src, void *dst)
+{
+  struct sockaddr_storage ss;
+  int size = sizeof(ss);
+  char src_copy[INET6_ADDRSTRLEN+1];
+
+  ZeroMemory(&ss, sizeof(ss));
+  /* stupid non-const API */
+  strncpy (src_copy, src, INET6_ADDRSTRLEN+1);
+  src_copy[INET6_ADDRSTRLEN] = 0;
+
+  if (WSAStringToAddress(src_copy, af, NULL, (struct sockaddr *)&ss, &size) == 0) {
+    switch(af) {
+      case AF_INET:
+       *(struct in_addr *)dst = ((struct sockaddr_in *)&ss)->sin_addr;
+       return 1;
+      case AF_INET6:
+       *(struct in6_addr *)dst = ((struct sockaddr_in6 *)&ss)->sin6_addr;
+       return 1;
+    }
+  }
+  return 0;
+}
+
+#else
+
+#error no emulation for inet_ntop
+
+#endif
+
+#endif
src/compat/compat.h +16 -1
index e9d51b8..021573e 100644
@@ -26,14 +26,21 @@
 #define COMPAT_H
 
 #ifdef HAVE_WINSOCK2_H
-/* timeval */
 #include <winsock2.h>
 #endif
 
+#ifdef HAVE_WS2TCPIP_H
+#include <ws2tcpip.h>
+#endif
+
 #ifdef HAVE_SYS_TIME_H
 #include <sys/time.h>
 #endif
 
+#ifdef HAVE_SYS_SOCKET_H
+#include <sys/socket.h>
+#endif
+
 #ifndef HAVE_DIRNAME
 char * dirname(char *str);
 #endif /* HAVE_DIRNAME */
@@ -50,4 +57,12 @@ int gettimeofday (struct timeval *tv, void *tz);
 int daemon(int nochdir, int noclose);
 #endif
 
+#ifndef HAVE_INET_NTOP
+const char * inet_ntop(int af, const void *src, char *dst, socklen_t size);
+#endif
+
+#ifndef HAVE_INET_PTON
+int inet_pton(int af, const char *src, void *dst);
+#endif
+
 #endif /* COMPAT_H */
src/compat/compat.vcproj +8 -0
index efdecb4..43fc0c2 100644
@@ -163,6 +163,14 @@
                                >
                        </File>
                        <File
+                               RelativePath=".\compat-inet_ntop.c"
+                               >
+                       </File>
+                       <File
+                               RelativePath=".\compat-inet_pton.c"
+                               >
+                       </File>
+                       <File
                                RelativePath=".\compat-daemon.c"
                                >
                        </File>
src/openvpn/socket.c +0 -55
index e1526ff..608213b 100644
@@ -3086,61 +3086,6 @@ link_socket_write_udp_posix_sendmsg (struct link_socket *sock,
 
 #ifdef WIN32
 
-/*
- * inet_ntop() and inet_pton() wrap-implementations using
- * WSAAddressToString() and WSAStringToAddress() functions
- *
- * this is needed as long as we support running OpenVPN on WinXP
- */
-
-const char *
-openvpn_inet_ntop(int af, const void *src, char *dst, socklen_t size)
-{
-  struct sockaddr_storage ss;
-  unsigned long s = size;
-
-  CLEAR(ss);
-  ss.ss_family = af;
-
-  switch(af) {
-    case AF_INET:
-      ((struct sockaddr_in *)&ss)->sin_addr = *(struct in_addr *)src;
-      break;
-    case AF_INET6:
-      ((struct sockaddr_in6 *)&ss)->sin6_addr = *(struct in6_addr *)src;
-      break;
-    default:
-      ASSERT (0);
-  }
-  /* cannot direclty use &size because of strict aliasing rules */
-  return (WSAAddressToString((struct sockaddr *)&ss, sizeof(ss), NULL, dst, &s) == 0)?
-          dst : NULL;
-}
-
-int
-openvpn_inet_pton(int af, const char *src, void *dst)
-{
-  struct sockaddr_storage ss;
-  int size = sizeof(ss);
-  char src_copy[INET6_ADDRSTRLEN+1];
-
-  CLEAR(ss);
-  /* stupid non-const API */
-  strncpynt(src_copy, src, INET6_ADDRSTRLEN+1);
-
-  if (WSAStringToAddress(src_copy, af, NULL, (struct sockaddr *)&ss, &size) == 0) {
-    switch(af) {
-      case AF_INET:
-       *(struct in_addr *)dst = ((struct sockaddr_in *)&ss)->sin_addr;
-       return 1;
-      case AF_INET6:
-       *(struct in6_addr *)dst = ((struct sockaddr_in6 *)&ss)->sin6_addr;
-       return 1;
-    }
-  }
-  return 0;
-}
-
 int
 socket_recv_queue (struct link_socket *sock, int maxsize)
 {
src/openvpn/win32.h +0 -7
index 09f897a..d87e987 100644
@@ -266,12 +266,6 @@ char *get_win_sys_path (void);
 /* call self in a subprocess */
 void fork_to_self (const char *cmdline);
 
-const char *openvpn_inet_ntop(int af, const void *src,
-                              char *dst, socklen_t size);
-int openvpn_inet_pton(int af, const char *src, void *dst);
-#define inet_ntop(af,src,dst,size) openvpn_inet_ntop(af,src,dst,size)
-#define inet_pton(af,src,dst)      openvpn_inet_pton(af,src,dst)
-
 /* Find temporary directory */
 const char *win_get_tempdir();
 
--

1.7.3.4

------------------------------------------------------------------------------
Virtualization & Cloud Management Using Capacity Planning Cloud computing makes use of virtualization - but cloud computing also focuses on allowing computing to be delivered as a service.
http://www.accelacomm.com/jaw/sfnl/114/51521223/
_______________________________________________
Openvpn-devel mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel

#97 lore raw

Re: [Openvpn-devel] [PATCH 48/52] cleanup: move console related function into its own module

In reply to Alon Bar-Lev

Currently many files (42) include misc.h, which is a lot. Also, misc.c is among the biggest files in the codebase[1], so splitting it into smaller files with good names and well-defined functionality makes sense:

"Oh, this include console.h, it must be using some console-related functions"

Feature-vise I give this one an ACK. Somebody else might want to look at the actual changes.

Signature · 9 lines
Samuli Seppänen
Community Manager
OpenVPN Technologies, Inc

irc freenode net: mattock

[1] For you own amusement, you can try something like this:

for i in `ls *.c`;do echo -n $i": ";cat $i|wc --lines;done|less
Quoted 653 lines
---
 src/openvpn/Makefile.am    |    1 +
 src/openvpn/console.c      |  238 ++++++++++++++++++++++++++++++++++++++++++++
 src/openvpn/console.h      |   33 ++++++
 src/openvpn/misc.c         |  125 +-----------------------
 src/openvpn/misc.h         |    3 +-
 src/openvpn/openvpn.vcproj |    8 ++
 src/openvpn/pkcs11.c       |    1 +
 src/openvpn/win32.c        |   87 +----------------
 src/openvpn/win32.h        |    5 +-
 9 files changed, 286 insertions(+), 215 deletions(-)
 create mode 100644 src/openvpn/console.c
 create mode 100644 src/openvpn/console.h
src/openvpn/Makefile.am +1 -0
index e170380..333eebc 100644
@@ -58,6 +58,7 @@ openvpn_SOURCES = \
        mbuf.c mbuf.h \
        memdbg.h \
        misc.c misc.h \
+       console.c console.h \
        mroute.c mroute.h \
        mss.c mss.h \
        mstats.c mstats.h \
src/openvpn/console.c new file +238 -0
new file mode 100644
index 0000000..2464e7e
@@ -0,0 +1,238 @@
+/*
+ *  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. <[email protected]...>
+ *
+ *  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
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#elif defined(_MSC_VER)
+#include "config-msvc.h"
+#endif
+
+#include "syshead.h"
+#include "console.h"
+#include "error.h"
+#include "buffer.h"
+#include "misc.h"
+
+#ifdef WIN32
+
+#include "win32.h"
+
+/*
+ * Get input from console.
+ *
+ * Return false on input error, or if service
+ * exit event is signaled.
+ */
+
+static bool
+get_console_input_win32 (const char *prompt, const bool echo, char *input, const int capacity)
+{
+  HANDLE in = INVALID_HANDLE_VALUE;
+  HANDLE err = INVALID_HANDLE_VALUE;
+  DWORD len = 0;
+
+  ASSERT (prompt);
+  ASSERT (input);
+  ASSERT (capacity > 0);
+
+  input[0] = '\0';
+
+  in = GetStdHandle (STD_INPUT_HANDLE);
+  err = get_orig_stderr ();
+
+  if (in != INVALID_HANDLE_VALUE
+      && err != INVALID_HANDLE_VALUE
+      && !win32_service_interrupt (&win32_signal)
+      && WriteFile (err, prompt, strlen (prompt), &len, NULL))
+    {
+      bool is_console = (GetFileType (in) == FILE_TYPE_CHAR);
+      DWORD flags_save = 0;
+      int status = 0;
+      WCHAR *winput;
+
+      if (is_console)
+       {
+         if (GetConsoleMode (in, &flags_save))
+           {
+             DWORD flags = ENABLE_LINE_INPUT | ENABLE_PROCESSED_INPUT;
+             if (echo)
+               flags |= ENABLE_ECHO_INPUT;
+             SetConsoleMode (in, flags);
+           }
+         else
+           is_console = 0;
+       }
+
+      if (is_console)
+        {
+          winput = malloc (capacity * sizeof (WCHAR));
+          if (winput == NULL)
+            return false;
+
+          status = ReadConsoleW (in, winput, capacity, &len, NULL);
+          WideCharToMultiByte (CP_UTF8, 0, winput, len, input, capacity, NULL, NULL);
+          free (winput);
+        }
+      else
+        status = ReadFile (in, input, capacity, &len, NULL);
+
+      string_null_terminate (input, (int)len, capacity);
+      chomp (input);
+
+      if (!echo)
+       WriteFile (err, "\r\n", 2, &len, NULL);
+      if (is_console)
+       SetConsoleMode (in, flags_save);
+      if (status && !win32_service_interrupt (&win32_signal))
+       return true;
+    }
+
+  return false;
+}
+
+#endif
+
+#ifdef HAVE_GETPASS
+
+static FILE *
+open_tty (const bool write)
+{
+  FILE *ret;
+  ret = fopen ("/dev/tty", write ? "w" : "r");
+  if (!ret)
+    ret = write ? stderr : stdin;
+  return ret;
+}
+
+static void
+close_tty (FILE *fp)
+{
+  if (fp != stderr && fp != stdin)
+    fclose (fp);
+}
+
+#endif
+
+#ifdef ENABLE_SYSTEMD
+
+/*
+ * is systemd running
+ */
+
+static bool
+check_systemd_running ()
+{
+  struct stat a, b;
+
+  /* We simply test whether the systemd cgroup hierarchy is
+   * mounted */
+
+  return (lstat("/sys/fs/cgroup", &a) == 0)
+         && (lstat("/sys/fs/cgroup/systemd", &b) == 0)
+         && (a.st_dev != b.st_dev);
+
+}
+
+static bool
+get_console_input_systemd (const char *prompt, const bool echo, char *input, const int capacity)
+{
+  int std_out;
+  bool ret = false;
+  struct argv argv;
+
+  argv_init (&argv);
+  argv_printf (&argv, "/bin/systemd-ask-password");
+  argv_printf_cat (&argv, "%s", prompt);
+
+  if ((std_out = openvpn_popen (&argv, NULL)) < 0) {
+         return false;
+  }
+  CLEAR (*input);
+  if (read (std_out, input, capacity) != 0)
+    {
+       chomp (input);
+       ret = true;
+    }
+  close (std_out);
+
+  argv_reset (&argv);
+
+  return ret;
+}
+
+
+#endif
+
+/*
+ * Get input from console
+ */
+bool
+get_console_input (const char *prompt, const bool echo, char *input, const int capacity)
+{
+  bool ret = false;
+  ASSERT (prompt);
+  ASSERT (input);
+  ASSERT (capacity > 0);
+  input[0] = '\0';
+
+#ifdef ENABLE_SYSTEMD
+  if (check_systemd_running ())
+    return get_console_input_systemd (prompt, echo, input, capacity);
+#endif
+
+#if defined(WIN32)
+  return get_console_input_win32 (prompt, echo, input, capacity);
+#elif defined(HAVE_GETPASS)
+  if (echo)
+    {
+      FILE *fp;
+
+      fp = open_tty (true);
+      fprintf (fp, "%s", prompt);
+      fflush (fp);
+      close_tty (fp);
+
+      fp = open_tty (false);
+      if (fgets (input, capacity, fp) != NULL)
+       {
+         chomp (input);
+         ret = true;
+       }
+      close_tty (fp);
+    }
+  else
+    {
+      char *gp = getpass (prompt);
+      if (gp)
+       {
+         strncpynt (input, gp, capacity);
+         memset (gp, 0, strlen (gp));
+         ret = true;
+       }
+    }
+#else
+  msg (M_FATAL, "Sorry, but I can't get console input on this OS");
+#endif
+  return ret;
+}
src/openvpn/console.h new file +33 -0
new file mode 100644
index 0000000..268f3fe
@@ -0,0 +1,33 @@
+/*
+ *  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. <[email protected]...>
+ *
+ *  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
+ */
+
+#ifndef CONSOLE_H
+#define CONSOLE_H
+
+#include "basic.h"
+
+bool
+get_console_input (const char *prompt, const bool echo, char *input, const int capacity);
+
+#endif
src/openvpn/misc.c +1 -124
index 07beaf0..2571194 100644
@@ -41,6 +41,7 @@
 #include "manage.h"
 #include "crypto.h"
 #include "route.h"
+#include "console.h"
 #include "win32.h"
 
 #include "memdbg.h"
@@ -1373,130 +1374,6 @@ absolute_pathname (const char *pathname)
     return false;
 }
 
-#ifdef HAVE_GETPASS
-
-static FILE *
-open_tty (const bool write)
-{
-  FILE *ret;
-  ret = fopen ("/dev/tty", write ? "w" : "r");
-  if (!ret)
-    ret = write ? stderr : stdin;
-  return ret;
-}
-
-static void
-close_tty (FILE *fp)
-{
-  if (fp != stderr && fp != stdin)
-    fclose (fp);
-}
-
-#endif
-
-/*
- * is systemd running
- */
-
-#if defined(TARGET_LINUX) && defined(ENABLE_SYSTEMD)
-bool
-check_systemd_running ()
-{
-  struct stat a, b;
-
-  /* We simply test whether the systemd cgroup hierarchy is
-   * mounted */
-
-  return (lstat("/sys/fs/cgroup", &a) == 0)
-         && (lstat("/sys/fs/cgroup/systemd", &b) == 0)
-         && (a.st_dev != b.st_dev);
-
-}
-
-bool
-get_console_input_systemd (const char *prompt, const bool echo, char *input, const int capacity)
-{
-  int std_out;
-  char cmd[256];
-  bool ret = false;
-  struct argv argv;
-
-  argv_init (&argv);
-  argv_printf (&argv, "/bin/systemd-ask-password");
-  argv_printf_cat (&argv, "%s", prompt);
-
-  if ((std_out = openvpn_popen (&argv, NULL)) < 0) {
-         return false;
-  }
-  CLEAR (*input);
-  if (read (std_out, input, capacity) != 0)
-    {
-       chomp (input);
-       ret = true;
-    }
-  close (std_out);
-
-  argv_reset (&argv);
-
-  return ret;
-}
-
-
-#endif
-
-/*
- * Get input from console
- */
-bool
-get_console_input (const char *prompt, const bool echo, char *input, const int capacity)
-{
-  bool ret = false;
-  ASSERT (prompt);
-  ASSERT (input);
-  ASSERT (capacity > 0);
-  input[0] = '\0';
-
-#if defined(TARGET_LINUX) && defined(ENABLE_SYSTEMD)
-  if (check_systemd_running ())
-    return get_console_input_systemd (prompt, echo, input, capacity);
-#endif
-
-#if defined(WIN32)
-  return get_console_input_win32 (prompt, echo, input, capacity);
-#elif defined(HAVE_GETPASS)
-  if (echo)
-    {
-      FILE *fp;
-
-      fp = open_tty (true);
-      fprintf (fp, "%s", prompt);
-      fflush (fp);
-      close_tty (fp);
-
-      fp = open_tty (false);
-      if (fgets (input, capacity, fp) != NULL)
-       {
-         chomp (input);
-         ret = true;
-       }
-      close_tty (fp);
-    }
-  else
-    {
-      char *gp = getpass (prompt);
-      if (gp)
-       {
-         strncpynt (input, gp, capacity);
-         memset (gp, 0, strlen (gp));
-         ret = true;
-       }
-    }
-#else
-  msg (M_FATAL, "Sorry, but I can't get console input on this OS");
-#endif
-  return ret;
-}
-
 /*
  * Get and store a username/password
  */
src/openvpn/misc.h +1 -2
index 9bb2fa2..12a8f71 100644
@@ -128,6 +128,7 @@ bool system_executed (int stat);
 const char *system_error_message (int, struct gc_arena *gc);
 
 /* wrapper around the execve() call */
+int openvpn_popen (const struct argv *a,  const struct env_set *es);
 int openvpn_execve (const struct argv *a, const struct env_set *es, const unsigned int flags);
 bool openvpn_execve_check (const struct argv *a, const struct env_set *es, const unsigned int flags, const char *error_message);
 bool openvpn_execve_allowed (const unsigned int flags);
@@ -322,8 +323,6 @@ struct auth_challenge_info {};
 struct static_challenge_info {};
 #endif
 
-bool get_console_input (const char *prompt, const bool echo, char *input, const int capacity);
-
 /*
  * Flags for get_user_pass and management_query_user_pass
  */
src/openvpn/openvpn.vcproj +8 -0
index 45c0a77..6c19621 100644
@@ -191,6 +191,10 @@
                                >
                        </File>
                        <File
+                               RelativePath=".\console.c"
+                               >
+                       </File>
+                       <File
                                RelativePath=".\crypto.c"
                                >
                        </File>
@@ -457,6 +461,10 @@
                                >
                        </File>
                        <File
+                               RelativePath=".\console.h"
+                               >
+                       </File>
+                       <File
                                RelativePath=".\crypto.h"
                                >
                        </File>
src/openvpn/pkcs11.c +1 -0
index 2189208..fd609d4 100644
@@ -40,6 +40,7 @@
 #include "pkcs11.h"
 #include "misc.h"
 #include "otime.h"
+#include "console.h"
 #include "pkcs11_backend.h"
 
 static
src/openvpn/win32.c +1 -86
index d7bf514..e94343b 100644
@@ -514,7 +514,7 @@ win32_signal_close (struct win32_signal *ws)
 /*
  * Return true if interrupt occurs in service mode.
  */
-static bool
+bool
 win32_service_interrupt (struct win32_signal *ws)
 {
   if (ws->mode == WSO_MODE_SERVICE)
@@ -740,91 +740,6 @@ netcmd_semaphore_release (void)
 }
 
 /*
- * Get input from console.
- *
- * Return false on input error, or if service
- * exit event is signaled.
- */
-
-bool
-get_console_input_win32 (const char *prompt, const bool echo, char *input, const int capacity)
-{
-  HANDLE in = INVALID_HANDLE_VALUE;
-  HANDLE err = INVALID_HANDLE_VALUE;
-  DWORD len = 0;
-
-  ASSERT (prompt);
-  ASSERT (input);
-  ASSERT (capacity > 0);
-
-  input[0] = '\0';
-
-  in = GetStdHandle (STD_INPUT_HANDLE);
-  err = get_orig_stderr ();
-
-  if (in != INVALID_HANDLE_VALUE
-      && err != INVALID_HANDLE_VALUE
-      && !win32_service_interrupt (&win32_signal)
-      && WriteFile (err, prompt, strlen (prompt), &len, NULL))
-    {
-      bool is_console = (GetFileType (in) == FILE_TYPE_CHAR);
-      DWORD flags_save = 0;
-      int status = 0;
-      WCHAR *winput;
-
-      if (is_console)
-       {
-         if (GetConsoleMode (in, &flags_save))
-           {
-             DWORD flags = ENABLE_LINE_INPUT | ENABLE_PROCESSED_INPUT;
-             if (echo)
-               flags |= ENABLE_ECHO_INPUT;
-             SetConsoleMode (in, flags);
-           }
-         else
-           is_console = 0;
-       }
-
-      if (is_console)
-        {
-          winput = malloc (capacity * sizeof (WCHAR));
-          if (winput == NULL)
-            return false;
-
-          status = ReadConsoleW (in, winput, capacity, &len, NULL);
-          WideCharToMultiByte (CP_UTF8, 0, winput, len, input, capacity, NULL, NULL);
-          free (winput);
-        }
-      else
-        status = ReadFile (in, input, capacity, &len, NULL);
-
-      string_null_terminate (input, (int)len, capacity);
-      chomp (input);
-
-      if (!echo)
-       WriteFile (err, "\r\n", 2, &len, NULL);
-      if (is_console)
-       SetConsoleMode (in, flags_save);
-      if (status && !win32_service_interrupt (&win32_signal))
-       return true;
-    }
-
-  return false;
-}
-
-/* get password from console */
-
-char *
-getpass (const char *prompt)
-{
-  static char line[256];
-  if (get_console_input_win32 (prompt, false, line, sizeof (line)))
-    return line;
-  else
-    return NULL;
-}
-
-/*
  * Return true if filename is safe to be used on Windows,
  * by avoiding the following reserved names:
  *
src/openvpn/win32.h +2 -4
index d87e987..cc18f02 100644
@@ -166,6 +166,8 @@ int win32_signal_get (struct win32_signal *ws);
 
 void win32_pause (struct win32_signal *ws);
 
+bool win32_service_interrupt (struct win32_signal *ws);
+
 /*
  * Set the text on the window title bar
  */
@@ -246,9 +248,6 @@ void netcmd_semaphore_close (void);
 void netcmd_semaphore_lock (void);
 void netcmd_semaphore_release (void);
 
-bool get_console_input_win32 (const char *prompt, const bool echo, char *input, const int capacity);
-char *getpass (const char *prompt);
-
 /* Set Win32 security attributes structure to allow all access */
 bool init_security_attributes_allow_all (struct security_attributes *obj);
 
--

1.7.3.4

------------------------------------------------------------------------------
Virtualization & Cloud Management Using Capacity Planning Cloud computing makes use of virtualization - but cloud computing also focuses on allowing computing to be delivered as a service.
http://www.accelacomm.com/jaw/sfnl/114/51521223/
_______________________________________________
Openvpn-devel mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel

#100 lore raw

Re: [Openvpn-devel] [PATCH 49/52] build: move wrappers into platform module

In reply to Alon Bar-Lev

This probably makes sense, lots of good refactorings. That said, I'd like to know how you selected what goes to platform.c?

Signature · 5 lines
Samuli Seppänen
Community Manager
OpenVPN Technologies, Inc

irc freenode net: mattock
Quoted 1,669 lines

+ Some fixups within the platform.c functions.
- need to check environment set on Windows.

---
 src/openvpn/Makefile.am    |    1 +
 src/openvpn/buffer.c       |    2 +-
 src/openvpn/crypto.c       |    6 +-
 src/openvpn/error.c        |    2 +-
 src/openvpn/init.c         |   18 +-
 src/openvpn/manage.c       |   16 +-
 src/openvpn/misc.c         |  295 ++----------------------------------
 src/openvpn/misc.h         |  106 +-------------
 src/openvpn/mstats.c       |    2 +-
 src/openvpn/multi.c        |    2 +-
 src/openvpn/openvpn.h      |    4 +-
 src/openvpn/openvpn.vcproj |    8 +
 src/openvpn/options.c      |   14 +-
 src/openvpn/packet_id.c    |    2 +-
 src/openvpn/pf.c           |    6 +-
 src/openvpn/platform.c     |  369 ++++++++++++++++++++++++++++++++++++++++++++
 src/openvpn/platform.h     |  142 +++++++++++++++++
 src/openvpn/ps.c           |    2 +-
 src/openvpn/ssl_openssl.c  |    2 +-
 src/openvpn/ssl_verify.c   |    8 +-
 src/openvpn/status.c       |    6 +-
 src/openvpn/tun.c          |   12 +-
 src/openvpn/win32.c        |   27 ----
 23 files changed, 584 insertions(+), 468 deletions(-)
 create mode 100644 src/openvpn/platform.c
 create mode 100644 src/openvpn/platform.h
src/openvpn/Makefile.am +1 -0
index 333eebc..6ba12b8 100644
@@ -58,6 +58,7 @@ openvpn_SOURCES = \
        mbuf.c mbuf.h \
        memdbg.h \
        misc.c misc.h \
+       platform.c platform.h \
        console.c console.h \
        mroute.c mroute.h \
        mss.c mss.h \
src/openvpn/buffer.c +1 -1
index ad30223..5eee3ee 100644
@@ -1080,7 +1080,7 @@ buffer_list_advance (struct buffer_list *ol, int n)
 struct buffer_list *
 buffer_list_file (const char *fn, int max_line_len)
 {
-  FILE *fp = openvpn_fopen (fn, "r");
+  FILE *fp = platform_fopen (fn, "r");
   struct buffer_list *bl = NULL;
 
   if (fp)
src/openvpn/crypto.c +3 -3
index 2e2e5d7..f811966 100644
@@ -868,7 +868,7 @@ read_key_file (struct key2 *key2, const char *file, const unsigned int flags)
 #endif
     {
       in = alloc_buf_gc (2048, &gc);
-      fd = openvpn_open (file, O_RDONLY, 0);
+      fd = platform_open (file, O_RDONLY, 0);
       if (fd == -1)
        msg (M_ERR, "Cannot open file key file '%s'", file);
       size = read (fd, in.data, in.capacity);
@@ -1029,7 +1029,7 @@ read_passphrase_hash (const char *passphrase_file,
     const int min_passphrase_size = 8;
     uint8_t buf[64];
     int total_size = 0;
-    int fd = openvpn_open (passphrase_file, O_RDONLY, 0);
+    int fd = platform_open (passphrase_file, O_RDONLY, 0);
 
     if (fd == -1)
       msg (M_ERR, "Cannot open passphrase file: '%s'", passphrase_file);
@@ -1079,7 +1079,7 @@ write_key_file (const int nkeys, const char *filename)
   const int bytes_per_line = 16;
 
   /* open key file */
-  fd = openvpn_open (filename, O_CREAT | O_TRUNC | O_WRONLY, S_IRUSR | S_IWUSR);
+  fd = platform_open (filename, O_CREAT | O_TRUNC | O_WRONLY, S_IRUSR | S_IWUSR);
 
   if (fd == -1)
     msg (M_ERR, "Cannot open shared secret file '%s' for write", filename);
src/openvpn/error.c +1 -1
index 1f2dd86..d6ad639 100644
@@ -640,7 +640,7 @@ x_check_status (int status,
                 my_errno);
 
          if (x_cs_err_delay_ms)
-           sleep_milliseconds (x_cs_err_delay_ms);
+           platform_sleep_milliseconds (x_cs_err_delay_ms);
        }
       gc_free (&gc);
     }
src/openvpn/init.c +9 -9
index bba3cf8..bc7718e 100644
@@ -935,7 +935,7 @@ do_genkey (const struct options * options)
               "shared secret output file (--secret)");
 
       if (options->mlock)      /* should we disable paging? */
-       do_mlockall (true);
+       platform_mlockall (true);
 
       nbits_written = write_key_file (2, options->shared_secret_file);
 
@@ -1022,7 +1022,7 @@ do_uid_gid_chroot (struct context *c, bool no_delay)
       if (c->options.chroot_dir)
        {
          if (no_delay)
-           do_chroot (c->options.chroot_dir);
+           platform_chroot (c->options.chroot_dir);
          else
            msg (M_INFO, "NOTE: chroot %s", why_not);
        }
@@ -1030,8 +1030,8 @@ do_uid_gid_chroot (struct context *c, bool no_delay)
       /* set user and/or group that we want to setuid/setgid to */
       if (no_delay)
        {
-         set_group (&c0->group_state);
-         set_user (&c0->user_state);
+         platform_group_set (&c0->platform_state_group);
+         platform_user_set (&c0->platform_state_user);
          c0->uid_gid_set = true;
        }
       else if (c0->uid_gid_specified)
@@ -2780,8 +2780,8 @@ do_init_first_time (struct context *c)
 
       /* get user and/or group that we want to setuid/setgid to */
       c0->uid_gid_specified =
-       get_group (c->options.groupname, &c0->group_state) |
-       get_user (c->options.username, &c0->user_state);
+       platform_group_get (c->options.groupname, &c0->platform_state_group) |
+       platform_user_get (c->options.username, &c0->platform_state_user);
 
       /* get --writepid file descriptor */
       get_pid_file (c->options.writepid, &c0->pid_state);
@@ -2791,13 +2791,13 @@ do_init_first_time (struct context *c)
 
       /* should we disable paging? */
       if (c->options.mlock && c->did_we_daemonize)
-       do_mlockall (true);     /* call again in case we daemonized */
+       platform_mlockall (true);       /* call again in case we daemonized */
 
       /* save process ID in a file */
       write_pid (&c0->pid_state);
 
       /* should we change scheduling priority? */
-      set_nice (c->options.nice);
+      platform_nice (c->options.nice);
     }
 }
 
@@ -3342,7 +3342,7 @@ init_instance (struct context *c, const struct env_set *env, const unsigned int
 
   /* should we disable paging? */
   if (c->first_time && options->mlock)
-    do_mlockall (true);
+    platform_mlockall (true);
 
 #if P2MP
   /* get passwords if undefined */
src/openvpn/manage.c +8 -8
index 85c9aca..1dddd41 100644
@@ -1146,7 +1146,7 @@ man_dispatch_command (struct management *man, struct status_output *so, const ch
     }
   else if (streq (p[0], "pid"))
     {
-      msg (M_CLIENT, "SUCCESS: pid=%d", openvpn_getpid ());
+      msg (M_CLIENT, "SUCCESS: pid=%d", platform_getpid ());
     }
 #ifdef MANAGEMENT_DEF_AUTH
   else if (streq (p[0], "nclients"))
@@ -1429,7 +1429,7 @@ man_record_peer_info (struct management *man)
            {
              const in_addr_t a = ntohl (addr.sin_addr.s_addr);
              const int p = ntohs (addr.sin_port);
-             FILE *fp = openvpn_fopen (man->settings.write_peer_info_file, "w");
+             FILE *fp = platform_fopen (man->settings.write_peer_info_file, "w");
              if (fp)
                {
                  fprintf (fp, "%s\n%d\n", print_in_addr_t (a, 0, &gc), p);
@@ -2013,17 +2013,17 @@ man_settings_init (struct man_settings *ms,
        */
       if (client_user)
        {
-         struct user_state s;
-         get_user (client_user, &s);
-         ms->client_uid = user_state_uid (&s);
+         struct platform_state_user s;
+         platform_user_get (client_user, &s);
+         ms->client_uid = platform_state_user_uid (&s);
          msg (D_MANAGEMENT, "MANAGEMENT: client_uid=%d", ms->client_uid);
          ASSERT (ms->client_uid >= 0);
        }
       if (client_group)
        {
-         struct group_state s;
-         get_group (client_group, &s);
-         ms->client_gid = group_state_gid (&s);
+         struct platform_state_group s;
+         platform_group_get (client_group, &s);
+         ms->client_gid = platform_state_group_gid (&s);
          msg (D_MANAGEMENT, "MANAGEMENT: client_gid=%d", ms->client_gid);
          ASSERT (ms->client_gid >= 0);
        }
src/openvpn/misc.c +11 -284
index 2571194..2ded9bf 100644
@@ -56,122 +56,6 @@ int script_security = SSEC_BUILT_IN; /* GLOBAL */
 /* contains SM_x value defined in misc.h */
 int script_method = SM_EXECVE; /* GLOBAL */
 
-/* Redefine the top level directory of the filesystem
-   to restrict access to files for security */
-void
-do_chroot (const char *path)
-{
-  if (path)
-    {
-#ifdef HAVE_CHROOT
-      const char *top = "/";
-      if (chroot (path))
-       msg (M_ERR, "chroot to '%s' failed", path);
-      if (openvpn_chdir (top))
-       msg (M_ERR, "cd to '%s' failed", top);
-      msg (M_INFO, "chroot to '%s' and cd to '%s' succeeded", path, top);
-#else
-      msg (M_FATAL, "Sorry but I can't chroot to '%s' because this operating system doesn't appear to support the chroot() system call", path);
-#endif
-    }
-}
-
-/* Get/Set UID of process */
-
-bool
-get_user (const char *username, struct user_state *state)
-{
-  bool ret = false;
-  CLEAR (*state);
-  if (username)
-    {
-#if defined(HAVE_GETPWNAM) && defined(HAVE_SETUID)
-      state->pw = getpwnam (username);
-      if (!state->pw)
-       msg (M_ERR, "failed to find UID for user %s", username);
-      state->username = username;
-      ret = true;
-#else
-      msg (M_FATAL, "cannot get UID for user %s -- platform lacks getpwname() or setuid() system calls", username);
-#endif
-    }
-  return ret;
-}
-
-void
-set_user (const struct user_state *state)
-{
-#if defined(HAVE_GETPWNAM) && defined(HAVE_SETUID)
-  if (state->username && state->pw)
-    {
-      if (setuid (state->pw->pw_uid))
-       msg (M_ERR, "setuid('%s') failed", state->username);
-      msg (M_INFO, "UID set to %s", state->username);
-    }
-#endif
-}
-
-/* Get/Set GID of process */
-
-bool
-get_group (const char *groupname, struct group_state *state)
-{
-  bool ret = false;
-  CLEAR (*state);
-  if (groupname)
-    {
-#if defined(HAVE_GETGRNAM) && defined(HAVE_SETGID)
-      state->gr = getgrnam (groupname);
-      if (!state->gr)
-       msg (M_ERR, "failed to find GID for group %s", groupname);
-      state->groupname = groupname;
-      ret = true;
-#else
-      msg (M_FATAL, "cannot get GID for group %s -- platform lacks getgrnam() or setgid() system calls", groupname);
-#endif
-    }
-  return ret;
-}
-
-void
-set_group (const struct group_state *state)
-{
-#if defined(HAVE_GETGRNAM) && defined(HAVE_SETGID)
-  if (state->groupname && state->gr)
-    {
-      if (setgid (state->gr->gr_gid))
-       msg (M_ERR, "setgid('%s') failed", state->groupname);
-      msg (M_INFO, "GID set to %s", state->groupname);
-#ifdef HAVE_SETGROUPS
-      {
-        gid_t gr_list[1];
-       gr_list[0] = state->gr->gr_gid;
-       if (setgroups (1, gr_list))
-         msg (M_ERR, "setgroups('%s') failed", state->groupname);
-      }
-#endif
-    }
-#endif
-}
-
-/* Change process priority */
-void
-set_nice (int niceval)
-{
-  if (niceval)
-    {
-#ifdef HAVE_NICE
-      errno = 0;
-      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
-      msg (M_WARN, "WARNING: nice %d failed (function not implemented)", niceval);
-#endif
-    }
-}
-
 /*
  * Pass tunnel endpoint and MTU parms to a user-supplied script.
  * Used to execute the up/down script/plugins.
@@ -253,7 +137,7 @@ get_pid_file (const char* filename, struct pid_state *state)
   CLEAR (*state);
   if (filename)
     {
-      state->fp = openvpn_fopen (filename, "w");
+      state->fp = platform_fopen (filename, "w");
       if (!state->fp)
        msg (M_ERR, "Open error on pid file %s", filename);
       state->filename = filename;
@@ -266,42 +150,13 @@ write_pid (const struct pid_state *state)
 {
   if (state->filename && state->fp)
     {
-      unsigned int pid = openvpn_getpid ();
+      unsigned int pid = platform_getpid ();
       fprintf(state->fp, "%u\n", pid);
       if (fclose (state->fp))
        msg (M_ERR, "Close error on pid file %s", state->filename);
     }
 }
 
-/* Get current PID */
-unsigned int
-openvpn_getpid ()
-{
-#ifdef WIN32
-  return (unsigned int) GetCurrentProcessId ();
-#else
-#ifdef HAVE_GETPID
-  return (unsigned int) getpid ();
-#else
-  return 0;
-#endif
-#endif
-}
-
-/* Disable paging */
-void
-do_mlockall(bool print_msg)
-{
-#ifdef HAVE_MLOCKALL
-  if (mlockall (MCL_CURRENT | MCL_FUTURE))
-    msg (M_WARN | M_ERRNO, "WARNING: mlockall call failed");
-  else if (print_msg)
-    msg (M_INFO, "mlockall call succeeded");
-#else
-  msg (M_WARN, "WARNING: mlockall call failed (function not implemented)");
-#endif
-}
-
 /*
  * Set standard file descriptors to /dev/null
  */
@@ -325,27 +180,6 @@ set_std_files_to_null (bool stdin_only)
 }
 
 /*
- * Wrapper for chdir library function
- */
-int
-openvpn_chdir (const char* dir)
-{
-#ifdef HAVE_CHDIR
-#ifdef WIN32
-  int res;
-  struct gc_arena gc = gc_new ();
-  res = _wchdir (wide_string (dir, &gc));
-  gc_free (&gc);
-  return res;
-#else
-  return chdir (dir);
-#endif
-#else
-  return -1;
-#endif
-}
-
-/*
  *  dup inetd/xinetd socket descriptor and save
  */
 
@@ -391,32 +225,6 @@ warn_if_group_others_accessible (const char* filename)
 }
 
 /*
- * convert system() return into a success/failure value
- */
-bool
-system_ok (int stat)
-{
-#ifdef WIN32
-  return stat == 0;
-#else
-  return stat != -1 && WIFEXITED (stat) && WEXITSTATUS (stat) == 0;
-#endif
-}
-
-/*
- * did system() call execute the given command?
- */
-bool
-system_executed (int stat)
-{
-#ifdef WIN32
-  return stat != -1;
-#else
-  return stat != -1 && WEXITSTATUS (stat) != 127;
-#endif
-}
-
-/*
  * Print an error message based on the status code returned by system().
  */
 const char *
@@ -456,7 +264,7 @@ openvpn_execve_check (const struct argv *a, const struct env_set *es, const unsi
   const int stat = openvpn_execve (a, es, flags);
   int ret = false;
 
-  if (system_ok (stat))
+  if (platform_system_ok (stat))
     ret = true;
   else
     {
@@ -554,7 +362,6 @@ openvpn_system (const char *command, const struct env_set *es, unsigned int flag
 {
 #ifdef HAVE_SYSTEM
   int ret;
-  struct gc_arena gc;
 
   perf_push (PERF_SCRIPT);
 
@@ -573,13 +380,7 @@ openvpn_system (const char *command, const struct env_set *es, unsigned int flag
   /*
    * execute the command
    */
-#ifdef WIN32
-  gc = gc_new ();
-  ret = _wsystem (wide_string (command, &gc));
-  gc_free (&gc);
-#else
-  ret = system (command);
-#endif
+  ret = platform_system(command);
 
   /* debugging */
   dmsg (D_SCRIPT, "SYSTEM return=%u", ret);
@@ -599,19 +400,6 @@ openvpn_system (const char *command, const struct env_set *es, unsigned int flag
 #endif
 }
 
-int
-openvpn_access (const char *path, int mode)
-{
-#ifdef WIN32
-  struct gc_arena gc = gc_new ();
-  int ret = _waccess (wide_string (path, &gc), mode);
-  gc_free (&gc);
-  return ret;
-#else
-  return access (path, mode);
-#endif
-}
-
 /*
  * Run execve() inside a fork(), duping stdout.  Designed to replicate the semantics of popen() but
  * in a safer way that doesn't require the invocation of a shell or the risks
@@ -981,7 +769,7 @@ env_set_remove_from_environment (const struct env_set *es)
 
 static struct env_item *global_env = NULL; /* GLOBAL */
 
-static void
+void
 manage_env (char *str)
 {
   remove_env_item (str, true, &global_env);
@@ -1078,27 +866,11 @@ setenv_str_ex (struct env_set *es,
     }
   else
     {
-#if defined(WIN32)
+      char *str = construct_name_value (name_tmp, val_tmp, NULL);
+      if (platform_putenv(str))
       {
-        if (!SetEnvironmentVariableW (wide_string (name_tmp, &gc),
-                                      wide_string (val_tmp, &gc)))
-         msg (M_WARN | M_ERRNO, "SetEnvironmentVariable failed, name='%s', value='%s'",
-              name_tmp,
-              val_tmp ? val_tmp : "NULL");
+        msg (M_WARN | M_ERRNO, "putenv('%s') failed", str);
       }
-#elif defined(HAVE_PUTENV)
-      {
-       char *str = construct_name_value (name_tmp, val_tmp, NULL);
-       int status;
-
-       status = putenv (str);
-       /*msg (M_INFO, "PUTENV '%s'", str);*/
-       if (!status)
-         manage_env (str);
-       if (status)
-         msg (M_WARN | M_ERRNO, "putenv('%s') failed", str);
-      }
-#endif
     }
 
   gc_free (&gc);
@@ -1162,35 +934,6 @@ count_netmask_bits(const char *dotted_quad)
   return ((int)result);
 }
 
-/*
- * Go to sleep for n milliseconds.
- */
-void
-sleep_milliseconds (unsigned int n)
-{
-#ifdef WIN32
-  Sleep (n);
-#else
-  struct timeval tv;
-  tv.tv_sec = n / 1000;
-  tv.tv_usec = (n % 1000) * 1000;
-  select (0, NULL, NULL, NULL, &tv);
-#endif
-}
-
-/*
- * Go to sleep indefinitely.
- */
-void
-sleep_until_signal (void)
-{
-#ifdef WIN32
-  ASSERT (0);
-#else
-  select (0, NULL, NULL, NULL, NULL);
-#endif
-}
-
 /* return true if filename can be opened for read */
 bool
 test_file (const char *filename)
@@ -1198,7 +941,7 @@ test_file (const char *filename)
   bool ret = false;
   if (filename)
     {
-      FILE *fp = openvpn_fopen (filename, "r");
+      FILE *fp = platform_fopen (filename, "r");
       if (fp)
        {
          fclose (fp);
@@ -1246,7 +989,7 @@ create_temp_file (const char *directory, const char *prefix, struct gc_arena *gc
 
       /* Atomically create the file.  Errors out if the file already
          exists.  */
-      fd = openvpn_open (retfname, O_CREAT | O_EXCL | O_WRONLY, S_IRUSR | S_IWUSR);
+      fd = platform_open (retfname, O_CREAT | O_EXCL | O_WRONLY, S_IRUSR | S_IWUSR);
       if (fd != -1)
         {
           close (fd);
@@ -1342,22 +1085,6 @@ gen_path (const char *directory, const char *filename, struct gc_arena *gc)
     return NULL;
 }
 
-/* delete a file, return true if succeeded */
-bool
-delete_file (const char *filename)
-{
-#if defined(WIN32)
-  struct gc_arena gc = gc_new ();
-  BOOL ret = DeleteFileW (wide_string (filename, &gc));
-  gc_free (&gc);
-  return (ret != 0);
-#elif defined(HAVE_UNLINK)
-  return (unlink (filename) == 0);
-#else
-  return false;
-#endif
-}
-
 bool
 absolute_pathname (const char *pathname)
 {
@@ -1524,7 +1251,7 @@ get_user_pass_cr (struct user_pass *up,
 
          warn_if_group_others_accessible (auth_file);
 
-         fp = openvpn_fopen (auth_file, "r");
+         fp = platform_fopen (auth_file, "r");
          if (!fp)
            msg (M_ERR, "Error opening '%s' auth file: %s", prefix, auth_file);
 
src/openvpn/misc.h +1 -105
index 12a8f71..d4c8e33 100644
@@ -29,6 +29,7 @@
 #include "common.h"
 #include "integer.h"
 #include "buffer.h"
+#include "platform.h"
 
 /* socket descriptor passed by inetd/xinetd server to us */
 #define INETD_SOCKET_DESCRIPTOR 0
@@ -58,37 +59,6 @@ struct env_set {
   struct env_item *list;
 };
 
-/* Get/Set UID of process */
-
-struct user_state {
-#if defined(HAVE_GETPWNAM) && defined(HAVE_SETUID)
-  const char *username;
-  struct passwd *pw;
-#else
-  int dummy;
-#endif
-};
-
-bool get_user (const char *username, struct user_state *state);
-void set_user (const struct user_state *state);
-
-/* Get/Set GID of process */
-
-struct group_state {
-#if defined(HAVE_GETGRNAM) && defined(HAVE_SETGID)
-  const char *groupname;
-  struct group *gr;
-#else
-  int dummy;
-#endif
-};
-
-bool get_group (const char *groupname, struct group_state *state);
-void set_group (const struct group_state *state);
-
-void set_nice (int niceval);
-void do_chroot (const char *path);
-
 void run_up_down (const char *command,
                  const struct plugin_list *plugins,
                  int plugin_type,
@@ -111,9 +81,6 @@ struct pid_state {
 
 void get_pid_file (const char* filename, struct pid_state *state);
 void write_pid (const struct pid_state *state);
-unsigned int openvpn_getpid (void);
-
-void do_mlockall (bool print_msg); /* Disable paging */
 
 /* check file protections */
 void warn_if_group_others_accessible(const char* filename);
@@ -122,9 +89,6 @@ void warn_if_group_others_accessible(const char* filename);
 #define S_SCRIPT (1<<0)
 #define S_FATAL  (1<<1)
 
-/* interpret the status code returned by system()/execve() */
-bool system_ok(int);
-bool system_executed (int stat);
 const char *system_error_message (int, struct gc_arena *gc);
 
 /* wrapper around the execve() call */
@@ -133,7 +97,6 @@ int openvpn_execve (const struct argv *a, const struct env_set *es, const unsign
 bool openvpn_execve_check (const struct argv *a, const struct env_set *es, const unsigned int flags, const char *error_message);
 bool openvpn_execve_allowed (const unsigned int flags);
 int openvpn_system (const char *command, const struct env_set *es, unsigned int flags);
-int openvpn_access (const char *path, int mode);
 
 static inline bool
 openvpn_run_script (const struct argv *a, const struct env_set *es, const unsigned int flags, const char *hook)
@@ -144,37 +107,6 @@ openvpn_run_script (const struct argv *a, const struct env_set *es, const unsign
   return openvpn_execve_check(a, es, flags | S_SCRIPT, msg);
 }
 
-#ifdef WIN32
-FILE * openvpn_fopen (const char *path, const char *mode);
-#else
-static inline FILE *
-openvpn_fopen (const char *path, const char *mode)
-{
-  return fopen (path, mode);
-}
-#endif
-
-#ifdef WIN32
-int openvpn_open (const char *path, int flags, int mode);
-#else
-static inline int
-openvpn_open (const char *path, int flags, mode_t mode)
-{
-  return open (path, flags, mode);
-}
-#endif
-
-#ifdef WIN32
-typedef struct _stat openvpn_stat_t;
-int openvpn_stat (const char *path, openvpn_stat_t *buf);
-#else
-typedef struct stat openvpn_stat_t;
-static inline int
-openvpn_stat (const char *path, openvpn_stat_t *buf)
-{
-  return stat (path, buf);
-}
-#endif
 
 #ifdef HAVE_STRERROR
 /* a thread-safe version of strerror */
@@ -184,9 +116,6 @@ const char* strerror_ts (int errnum, struct gc_arena *gc);
 /* Set standard file descriptors to /dev/null */
 void set_std_files_to_null (bool stdin_only);
 
-/* Wrapper for chdir library function */
-int openvpn_chdir (const char* dir);
-
 /* dup inetd/xinetd socket descriptor and save */
 extern int inetd_socket_descriptor;
 void save_inetd_socket_descriptor (void);
@@ -242,12 +171,6 @@ const char **make_extended_arg_array (char **p, struct gc_arena *gc);
 int count_netmask_bits(const char *);
 unsigned int count_bits(unsigned int );
 
-/* go to sleep for n milliseconds */
-void sleep_milliseconds (unsigned int n);
-
-/* go to sleep indefinitely */
-void sleep_until_signal (void);
-
 /* an analogue to the random() function, but use OpenSSL functions if available */
 #ifdef ENABLE_CRYPTO
 long int get_random(void);
@@ -264,9 +187,6 @@ const char *create_temp_file (const char *directory, const char *prefix, struct
 /* put a directory and filename together */
 const char *gen_path (const char *directory, const char *filename, struct gc_arena *gc);
 
-/* delete a file, return true if succeeded */
-bool delete_file (const char *filename);
-
 /* return true if pathname is absolute */
 bool absolute_pathname (const char *pathname);
 
@@ -448,28 +368,4 @@ void argv_printf_cat (struct argv *a, const char *format, ...)
 #endif
   ;
 
-/*
- * Extract UID or GID
- */
-
-static inline int
-user_state_uid (const struct user_state *s)
-{
-#if defined(HAVE_GETPWNAM) && defined(HAVE_SETUID)
-  if (s->pw)
-    return s->pw->pw_uid;
-#endif
-  return -1;
-}
-
-static inline int
-group_state_gid (const struct group_state *s)
-{
-#if defined(HAVE_GETGRNAM) && defined(HAVE_SETGID)
-  if (s->gr)
-    return s->gr->gr_gid;
-#endif
-  return -1;
-}
-
 #endif
src/openvpn/mstats.c +1 -1
index b4b864b..3be493c 100644
@@ -114,7 +114,7 @@ mstats_close(void)
       mmap_stats->state = MSTATS_EXPIRED;
       if (munmap((void *)mmap_stats, sizeof(struct mmap_stats)))
        msg (M_WARN | M_ERRNO, "mstats_close: munmap error");
-      delete_file(mmap_fn);
+      platform_unlink(mmap_fn);
       mmap_stats = NULL;
     }
 }
src/openvpn/multi.c +1 -1
index e79c6f1..9876b80 100644
@@ -1452,7 +1452,7 @@ multi_client_connect_post (struct multi_context *m,
                             option_types_found,
                             mi->context.c2.es);
 
-      if (!delete_file (dc_file))
+      if (!platform_unlink (dc_file))
        msg (D_MULTI_ERRORS, "MULTI: problem deleting temporary file: %s",
             dc_file);
 
src/openvpn/openvpn.h +2 -2
index b314885..0732d0f 100644
@@ -143,8 +143,8 @@ struct context_0
   /* workspace for --user/--group */
   bool uid_gid_specified;
   bool uid_gid_set;
-  struct user_state user_state;
-  struct group_state group_state;
+  struct platform_state_user platform_state_user;
+  struct platform_state_group platform_state_group;
 };
 
 
src/openvpn/openvpn.vcproj +8 -0
index 6c19621..4680e52 100644
@@ -347,6 +347,10 @@
                                >
                        </File>
                        <File
+                               RelativePath=".\platform.c"
+                               >
+                       </File>
+                       <File
                                RelativePath=".\plugin.c"
                                >
                        </File>
@@ -649,6 +653,10 @@
                                >
                        </File>
                        <File
+                               RelativePath=".\platform.h"
+                               >
+                       </File>
+                       <File
                                RelativePath=".\plugin.h"
                                >
                        </File>
src/openvpn/options.c +7 -7
index 258b060..bd83843 100644
@@ -920,7 +920,7 @@ setenv_settings (struct env_set *es, const struct options *o)
   setenv_int (es, "daemon", o->daemon);
   setenv_int (es, "daemon_log_redirect", o->log);
   setenv_unsigned (es, "daemon_start_time", time(NULL));
-  setenv_int (es, "daemon_pid", openvpn_getpid());
+  setenv_int (es, "daemon_pid", platform_getpid());
 
 #ifdef ENABLE_CONNECTION
   if (o->connection_list)
@@ -2640,18 +2640,18 @@ check_file_access(const int type, const char *file, const int mode, const char *
       char *fullpath = strdup(file);  /* POSIX dirname() implementaion may modify its arguments */
       char *dirpath = dirname(fullpath);
 
-      if (openvpn_access (dirpath, mode|X_OK) != 0)
+      if (platform_access (dirpath, mode|X_OK) != 0)
           errcode = errno;
       free(fullpath);
     }
 
   /* Is the file itself accessible? */
-  if (!errcode && (type & CHKACC_FILE) && (openvpn_access (file, mode) != 0) )
+  if (!errcode && (type & CHKACC_FILE) && (platform_access (file, mode) != 0) )
       errcode = errno;
 
   /* If the file exists and is accessible, is it writable? */
-  if (!errcode && (type & CHKACC_FILEXSTWR) && (openvpn_access (file, F_OK) == 0) )
-    if (openvpn_access (file, W_OK) != 0)
+  if (!errcode && (type & CHKACC_FILEXSTWR) && (platform_access (file, F_OK) == 0) )
+    if (platform_access (file, W_OK) != 0)
       errcode = errno;
 
   /* Scream if an error is found */
@@ -3755,7 +3755,7 @@ read_config_file (struct options *options,
       if (streq (file, "stdin"))
        fp = stdin;
       else
-       fp = openvpn_fopen (file, "r");
+       fp = platform_fopen (file, "r");
       if (fp)
        {
          line_num = 0;
@@ -4528,7 +4528,7 @@ add_option (struct options *options,
   else if (streq (p[0], "cd") && p[1])
     {
       VERIFY_PERMISSION (OPT_P_GENERAL);
-      if (openvpn_chdir (p[1]))
+      if (platform_chdir (p[1]))
        {
          msg (M_ERR, "cd to '%s' failed", p[1]);
          goto err;
src/openvpn/packet_id.c +1 -1
index 186f074..0102129 100644
@@ -368,7 +368,7 @@ packet_id_persist_load (struct packet_id_persist *p, const char *filename)
   if (!packet_id_persist_enabled (p))
     {
       /* open packet-id persist file for both read and write */
-      p->fd = openvpn_open (filename,
+      p->fd = platform_open (filename,
                             O_CREAT | O_RDWR | O_BINARY,
                             S_IRUSR | S_IWUSR);
       if (p->fd == -1)
src/openvpn/pf.c +3 -3
index 729792e..7ed1e70 100644
@@ -504,8 +504,8 @@ pf_check_reload (struct context *c)
       && c->c2.pf.filename
       && event_timeout_trigger (&c->c2.pf.reload, &c->c2.timeval, ETT_DEFAULT))
     {
-      openvpn_stat_t s;
-      if (!openvpn_stat (c->c2.pf.filename, &s))
+      platform_stat_t s;
+      if (!platform_stat (c->c2.pf.filename, &s))
        {
          if (s.st_mtime > c->c2.pf.file_last_mod)
            {
@@ -605,7 +605,7 @@ pf_destroy_context (struct pf_context *pfc)
 #ifdef PLUGIN_PF
   if (pfc->filename)
     {
-      delete_file (pfc->filename);
+      platform_unlink (pfc->filename);
       free (pfc->filename);
     }
 #endif
src/openvpn/platform.c new file +369 -0
new file mode 100644
index 0000000..c79f680
@@ -0,0 +1,369 @@
+/*
+ *  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. <[email protected]...>
+ *
+ *  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
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#elif defined(_MSC_VER)
+#include "config-msvc.h"
+#endif
+
+#include "syshead.h"
+
+#include "buffer.h"
+#include "error.h"
+#include "win32.h"
+
+#include "memdbg.h"
+
+#include "platform.h"
+
+/* Redefine the top level directory of the filesystem
+   to restrict access to files for security */
+void
+platform_chroot (const char *path)
+{
+  if (path)
+    {
+#ifdef HAVE_CHROOT
+      const char *top = "/";
+      if (chroot (path))
+       msg (M_ERR, "chroot to '%s' failed", path);
+      if (platform_chdir (top))
+       msg (M_ERR, "cd to '%s' failed", top);
+      msg (M_INFO, "chroot to '%s' and cd to '%s' succeeded", path, top);
+#else
+      msg (M_FATAL, "Sorry but I can't chroot to '%s' because this operating system doesn't appear to support the chroot() system call", path);
+#endif
+    }
+}
+
+/* Get/Set UID of process */
+
+bool
+platform_user_get (const char *username, struct platform_state_user *state)
+{
+  bool ret = false;
+  CLEAR (*state);
+  if (username)
+    {
+#if defined(HAVE_GETPWNAM) && defined(HAVE_SETUID)
+      state->pw = getpwnam (username);
+      if (!state->pw)
+       msg (M_ERR, "failed to find UID for user %s", username);
+      state->username = username;
+      ret = true;
+#else
+      msg (M_FATAL, "cannot get UID for user %s -- platform lacks getpwname() or setuid() system calls", username);
+#endif
+    }
+  return ret;
+}
+
+void
+platform_user_set (const struct platform_state_user *state)
+{
+#if defined(HAVE_GETPWNAM) && defined(HAVE_SETUID)
+  if (state->username && state->pw)
+    {
+      if (setuid (state->pw->pw_uid))
+       msg (M_ERR, "setuid('%s') failed", state->username);
+      msg (M_INFO, "UID set to %s", state->username);
+    }
+#endif
+}
+
+/* Get/Set GID of process */
+
+bool
+platform_group_get (const char *groupname, struct platform_state_group *state)
+{
+  bool ret = false;
+  CLEAR (*state);
+  if (groupname)
+    {
+#if defined(HAVE_GETGRNAM) && defined(HAVE_SETGID)
+      state->gr = getgrnam (groupname);
+      if (!state->gr)
+       msg (M_ERR, "failed to find GID for group %s", groupname);
+      state->groupname = groupname;
+      ret = true;
+#else
+      msg (M_FATAL, "cannot get GID for group %s -- platform lacks getgrnam() or setgid() system calls", groupname);
+#endif
+    }
+  return ret;
+}
+
+void
+platform_group_set (const struct platform_state_group *state)
+{
+#if defined(HAVE_GETGRNAM) && defined(HAVE_SETGID)
+  if (state->groupname && state->gr)
+    {
+      if (setgid (state->gr->gr_gid))
+       msg (M_ERR, "setgid('%s') failed", state->groupname);
+      msg (M_INFO, "GID set to %s", state->groupname);
+#ifdef HAVE_SETGROUPS
+      {
+        gid_t gr_list[1];
+       gr_list[0] = state->gr->gr_gid;
+       if (setgroups (1, gr_list))
+         msg (M_ERR, "setgroups('%s') failed", state->groupname);
+      }
+#endif
+    }
+#endif
+}
+
+/* Change process priority */
+void
+platform_nice (int niceval)
+{
+  if (niceval)
+    {
+#ifdef HAVE_NICE
+      errno = 0;
+      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
+      msg (M_WARN, "WARNING: nice %d failed (function not implemented)", niceval);
+#endif
+    }
+}
+
+/* Get current PID */
+unsigned int
+platform_getpid ()
+{
+#ifdef WIN32
+  return (unsigned int) GetCurrentProcessId ();
+#else
+#ifdef HAVE_GETPID
+  return (unsigned int) getpid ();
+#else
+  return 0;
+#endif
+#endif
+}
+
+/* Disable paging */
+void
+platform_mlockall(bool print_msg)
+{
+#ifdef HAVE_MLOCKALL
+  if (mlockall (MCL_CURRENT | MCL_FUTURE))
+    msg (M_WARN | M_ERRNO, "WARNING: mlockall call failed");
+  else if (print_msg)
+    msg (M_INFO, "mlockall call succeeded");
+#else
+  msg (M_WARN, "WARNING: mlockall call failed (function not implemented)");
+#endif
+}
+
+/*
+ * Wrapper for chdir library function
+ */
+int
+platform_chdir (const char* dir)
+{
+#ifdef HAVE_CHDIR
+#ifdef WIN32
+  int res;
+  struct gc_arena gc = gc_new ();
+  res = _wchdir (wide_string (dir, &gc));
+  gc_free (&gc);
+  return res;
+#else
+  return chdir (dir);
+#endif
+#else
+  return -1;
+#endif
+}
+
+/*
+ * convert system() return into a success/failure value
+ */
+bool
+platform_system_ok (int stat)
+{
+#ifdef WIN32
+  return stat == 0;
+#else
+  return stat != -1 && WIFEXITED (stat) && WEXITSTATUS (stat) == 0;
+#endif
+}
+
+/*
+ * did system() call execute the given command?
+ */
+bool
+platform_system_executed (int stat)
+{
+#ifdef WIN32
+  return stat != -1;
+#else
+  return stat != -1 && WEXITSTATUS (stat) != 127;
+#endif
+}
+
+int
+platform_access (const char *path, int mode)
+{
+#ifdef WIN32
+  struct gc_arena gc = gc_new ();
+  int ret = _waccess (wide_string (path, &gc), mode & ~X_OK);
+  gc_free (&gc);
+  return ret;
+#else
+  return access (path, mode);
+#endif
+}
+
+/*
+ * Go to sleep for n milliseconds.
+ */
+void
+platform_sleep_milliseconds (unsigned int n)
+{
+#ifdef WIN32
+  Sleep (n);
+#else
+  struct timeval tv;
+  tv.tv_sec = n / 1000;
+  tv.tv_usec = (n % 1000) * 1000;
+  select (0, NULL, NULL, NULL, &tv);
+#endif
+}
+
+/*
+ * Go to sleep indefinitely.
+ */
+void
+platform_sleep_until_signal (void)
+{
+#ifdef WIN32
+  ASSERT (0);
+#else
+  select (0, NULL, NULL, NULL, NULL);
+#endif
+}
+
+/* delete a file, return true if succeeded */
+bool
+platform_unlink (const char *filename)
+{
+#if defined(WIN32)
+  struct gc_arena gc = gc_new ();
+  BOOL ret = DeleteFileW (wide_string (filename, &gc));
+  gc_free (&gc);
+  return (ret != 0);
+#elif defined(HAVE_UNLINK)
+  return (unlink (filename) == 0);
+#else
+  return false;
+#endif
+}
+
+int platform_system(const char *command) {
+  int ret;
+#ifdef WIN32
+  struct gc_arena gc = gc_new ();
+  ret = _wsystem (wide_string (command, &gc));
+  gc_free (&gc);
+#else
+  ret = system (command);
+#endif
+  return ret;
+}
+
+int platform_putenv(char *string)
+{
+  int status;
+#if defined(WIN32)
+  struct gc_arena gc = gc_new ();
+  char *s = string_alloc(string, &gc);
+  char *value = strchr(s, '=');
+  if (value!=NULL)
+    {
+      *value = '\0';
+      value++;
+      if (*value == '\0')
+        value = NULL;
+    }
+
+  status = SetEnvironmentVariableW (wide_string (s, &gc),
+      wide_string (value, &gc)) ? 1: 0;
+  gc_free (&gc);
+#elif defined(HAVE_PUTENV)
+  void manage_env (char *str); /* TODO: Resolve properly */
+  status = putenv (string);
+  if (!status)
+    manage_env (string);
+#endif
+
+  return status;
+}
+
+FILE *
+platform_fopen (const char *path, const char *mode)
+{
+#ifdef WIN32
+  struct gc_arena gc = gc_new ();
+  FILE *f = _wfopen (wide_string (path, &gc), wide_string (mode, &gc));
+  gc_free (&gc);
+  return f;
+#else
+  return fopen(path, mode);
+#endif
+}
+
+int
+platform_open (const char *path, int flags, int mode)
+{
+#ifdef WIN32
+  struct gc_arena gc = gc_new ();
+  int fd = _wopen (wide_string (path, &gc), flags, mode);
+  gc_free (&gc);
+  return fd;
+#else
+  return open(path, flags, mode);
+#endif
+}
+
+int
+platform_stat (const char *path, platform_stat_t *buf)
+{
+#ifdef WIN32
+  struct gc_arena gc = gc_new ();
+  int res = _wstat (wide_string (path, &gc), buf);
+  gc_free (&gc);
+  return res;
+#else
+  return stat(path, buf);
+#endif
+}
+
src/openvpn/platform.h new file +142 -0
new file mode 100644
index 0000000..7bd2067
@@ -0,0 +1,142 @@
+/*
+ *  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. <[email protected]...>
+ *
+ *  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
+ */
+
+#ifndef PLATFORM_H
+#define PLATFORM_H
+
+#ifdef HAVE_SYS_TYPES_H
+#include <sys/types.h>
+#endif
+
+#ifdef HAVE_SYS_STAT_H
+#include <sys/stat.h>
+#endif
+
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+
+#ifdef HAVE_PWD_H
+#include <pwd.h>
+#endif
+
+#ifdef HAVE_GRP_H
+#include <grp.h>
+#endif
+
+#ifdef HAVE_STDIO_H
+#include <stdio.h>
+#endif
+
+#include "basic.h"
+
+/* Get/Set UID of process */
+
+struct platform_state_user {
+#if defined(HAVE_GETPWNAM) && defined(HAVE_SETUID)
+  const char *username;
+  struct passwd *pw;
+#else
+  int dummy;
+#endif
+};
+
+/* Get/Set GID of process */
+
+struct platform_state_group {
+#if defined(HAVE_GETGRNAM) && defined(HAVE_SETGID)
+  const char *groupname;
+  struct group *gr;
+#else
+  int dummy;
+#endif
+};
+
+bool platform_user_get (const char *username, struct platform_state_user *state);
+void platform_user_set (const struct platform_state_user *state);
+
+bool platform_group_get (const char *groupname, struct platform_state_group *state);
+void platform_group_set (const struct platform_state_group *state);
+
+/*
+ * Extract UID or GID
+ */
+
+static inline int
+platform_state_user_uid (const struct platform_state_user *s)
+{
+#if defined(HAVE_GETPWNAM) && defined(HAVE_SETUID)
+  if (s->pw)
+    return s->pw->pw_uid;
+#endif
+  return -1;
+}
+
+static inline int
+platform_state_group_gid (const struct platform_state_group *s)
+{
+#if defined(HAVE_GETGRNAM) && defined(HAVE_SETGID)
+  if (s->gr)
+    return s->gr->gr_gid;
+#endif
+  return -1;
+}
+
+void platform_chroot (const char *path);
+
+void platform_nice (int niceval);
+
+unsigned int platform_getpid (void);
+
+void platform_mlockall (bool print_msg); /* Disable paging */
+
+int platform_chdir (const char* dir);
+
+/* interpret the status code returned by system()/execve() */
+bool platform_system_ok (int stat);
+bool platform_system_executed (int stat);
+int platform_system(const char *command);
+
+int platform_access (const char *path, int mode);
+
+void platform_sleep_milliseconds (unsigned int n);
+
+void platform_sleep_until_signal (void);
+
+/* delete a file, return true if succeeded */
+bool platform_unlink (const char *filename);
+
+int platform_putenv (char *string);
+
+FILE *platform_fopen (const char *path, const char *mode);
+int platform_open (const char *path, int flags, int mode);
+
+#ifdef WIN32
+typedef struct _stat platform_stat_t;
+#else
+typedef struct stat platform_stat_t;
+#endif
+int platform_stat (const char *path, platform_stat_t *buf);
+
+#endif
src/openvpn/ps.c +1 -1
index a4e50e8..5d056ee 100644
@@ -337,7 +337,7 @@ journal_add (const char *journal_dir, struct proxy_connection *pc, struct proxy_
       check_malloc_return (jfn);
       openvpn_snprintf (jfn, fnlen, "%s/%s", journal_dir, t);
       dmsg (D_PS_PROXY_DEBUG, "PORT SHARE PROXY: client origin %s -> %s", jfn, f);
-      fd = openvpn_open (jfn, O_CREAT | O_TRUNC | O_WRONLY, S_IRUSR | S_IWUSR | S_IRGRP);
+      fd = platform_open (jfn, O_CREAT | O_TRUNC | O_WRONLY, S_IRUSR | S_IWUSR | S_IRGRP);
       if (fd != -1)
        {
          write(fd, f, strlen(f));
src/openvpn/ssl_openssl.c +1 -1
index 6a60cb5..d712c66 100644
@@ -280,7 +280,7 @@ tls_ctx_load_pkcs12(struct tls_root_ctx *ctx, const char *pkcs12_file,
 #endif
     {
       /* Load the PKCS #12 file */
-      if (!(fp = openvpn_fopen(pkcs12_file, "rb")))
+      if (!(fp = platform_fopen(pkcs12_file, "rb")))
        msg(M_SSLERR, "Error opening file %s", pkcs12_file);
       p12 = d2i_PKCS12_fp(fp, NULL);
       fclose(fp);
src/openvpn/ssl_verify.c +4 -4
index 51457f8..e837e39 100644
@@ -517,7 +517,7 @@ verify_cert_call_command(const char *verify_command, struct env_set *es,
   if (verify_export_cert)
     {
        if (tmp_file)
-          delete_file(tmp_file);
+          platform_unlink(tmp_file);
     }
 
   gc_free(&gc);
@@ -551,7 +551,7 @@ verify_check_crl_dir(const char *crl_dir, openvpn_x509_cert_t *cert)
       x509_free_serial(serial);
       return FAILURE;
     }
-  fd = openvpn_open (fn, O_RDONLY, 0);
+  fd = platform_open (fn, O_RDONLY, 0);
   if (fd >= 0)
     {
       msg (D_HANDSHAKE, "VERIFY CRL: certificate serial number %s is revoked", serial);
@@ -735,7 +735,7 @@ key_state_rm_auth_control_file (struct key_state *ks)
 {
   if (ks && ks->auth_control_file)
     {
-      delete_file (ks->auth_control_file);
+      platform_unlink (ks->auth_control_file);
       free (ks->auth_control_file);
       ks->auth_control_file = NULL;
     }
@@ -987,7 +987,7 @@ verify_user_pass_script (struct tls_session *session, const struct user_pass *up
 
  done:
   if (tmp_file && strlen (tmp_file) > 0)
-    delete_file (tmp_file);
+    platform_unlink (tmp_file);
 
   argv_reset (&argv);
   gc_free (&gc);
src/openvpn/status.c +3 -3
index 0be5e4c..5f9ab9e 100644
@@ -78,17 +78,17 @@ status_open (const char *filename,
           switch (so->flags)
             {
             case STATUS_OUTPUT_WRITE:
-              so->fd = openvpn_open (filename,
+              so->fd = platform_open (filename,
                                      O_CREAT | O_TRUNC | O_WRONLY,
                                      S_IRUSR | S_IWUSR);
               break;
             case STATUS_OUTPUT_READ:
-              so->fd = openvpn_open (filename,
+              so->fd = platform_open (filename,
                                      O_RDONLY,
                                      S_IRUSR | S_IWUSR);
               break;
             case STATUS_OUTPUT_READ|STATUS_OUTPUT_WRITE:
-              so->fd = openvpn_open (filename,
+              so->fd = platform_open (filename,
                                      O_CREAT | O_RDWR,
                                      S_IRUSR | S_IWUSR);
               break;
src/openvpn/tun.c +6 -6
index abc6a99..e6a7bc8 100644
@@ -1545,22 +1545,22 @@ tuncfg (const char *dev, const char *dev_type, const char *dev_node, int persist
     msg (M_ERR, "Cannot ioctl TUNSETPERSIST(%d) %s", persist_mode, dev);
   if (username != NULL)
     {
-      struct user_state user_state;
+      struct platform_state_user platform_state_user;
 
-      if (!get_user (username, &user_state))
+      if (!platform_user_get (username, &platform_state_user))
         msg (M_ERR, "Cannot get user entry for %s", username);
       else
-        if (ioctl (tt->fd, TUNSETOWNER, user_state.pw->pw_uid) < 0)
+        if (ioctl (tt->fd, TUNSETOWNER, platform_state_user.pw->pw_uid) < 0)
           msg (M_ERR, "Cannot ioctl TUNSETOWNER(%s) %s", username, dev);
     }
   if (groupname != NULL)
     {
-      struct group_state group_state;
+      struct platform_state_group platform_state_group;
 
-      if (!get_group (groupname, &group_state))
+      if (!platform_group_get (groupname, &platform_state_group))
         msg (M_ERR, "Cannot get group entry for %s", groupname);
       else
-        if (ioctl (tt->fd, TUNSETGROUP, group_state.gr->gr_gid) < 0)
+        if (ioctl (tt->fd, TUNSETGROUP, platform_state_group.gr->gr_gid) < 0)
           msg (M_ERR, "Cannot ioctl TUNSETOWNER(%s) %s", groupname, dev);
     }
   close_tun (tt);
src/openvpn/win32.c +0 -28
index e94343b..e8e69dc 100644
@@ -976,33 +976,6 @@ wide_string (const char* utf8, struct gc_arena *gc)
   return ucs16;
 }
 
-FILE *
-openvpn_fopen (const char *path, const char *mode)
-{
-  struct gc_arena gc = gc_new ();
-  FILE *f = _wfopen (wide_string (path, &gc), wide_string (mode, &gc));
-  gc_free (&gc);
-  return f;
-}
-
-int
-openvpn_open (const char *path, int flags, int mode)
-{
-  struct gc_arena gc = gc_new ();
-  int fd = _wopen (wide_string (path, &gc), flags, mode);
-  gc_free (&gc);
-  return fd;
-}
-
-int
-openvpn_stat (const char *path, openvpn_stat_t *buf)
-{
-  struct gc_arena gc = gc_new ();
-  int res = _wstat (wide_string (path, &gc), buf);
-  gc_free (&gc);
-  return res;
-}
-
 /*
  * call ourself in another process
  */
--

1.7.3.4

------------------------------------------------------------------------------
Virtualization & Cloud Management Using Capacity Planning Cloud computing makes use of virtualization - but cloud computing also focuses on allowing computing to be delivered as a service.
http://www.accelacomm.com/jaw/sfnl/114/51521223/
_______________________________________________
Openvpn-devel mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel

#105 lore raw

Re: [Openvpn-devel] [PATCH 50/52] build: windows: install version.sh to allow installer read version

In reply to Alon Bar-Lev

Is this meant to allow using these variables[1] in the NSIS script(s)?

Signature · 12 lines
Samuli Seppänen
Community Manager
OpenVPN Technologies, Inc

irc freenode net: mattock

[1]

OPENVPN_PACKAGE_NAME="@PACKAGE_NAME@"
OPENVPN_PACKAGE_TARNAME="@PACKAGE_TARNAME@"
OPENVPN_PACKAGE_VERSION="@PACKAGE_VERSION@"
OPENVPN_PACKAGE_HOST="@host@"
Quoted 56 lines
---
 .gitignore    |    1 +
 Makefile.am   |    5 +++++
 configure.ac  |    1 +
 version.sh.in |    4 ++++
 4 files changed, 11 insertions(+), 0 deletions(-)
 create mode 100644 version.sh.in
.gitignore +1 -0
index e7232cf..2f72ed8 100644
@@ -39,6 +39,7 @@ m4/ltsugar.m4
 m4/ltversion.m4
 m4/lt~obsolete.m4
 
+version.sh
 msvc-env-local.bat
 config-msvc-local.h
 config-msvc-version.h
Makefile.am +5 -0
index 5293518..68aa0a8 100644
@@ -69,3 +69,8 @@ endif
 dist_noinst_HEADERS = \
 	config-msvc.h \
 	config-msvc-version.h.in
+
+if WIN32
+rootdir=$(prefix)
+root_DATA = version.sh
+endif
configure.ac +1 -0
index d53a74a..0f2a62e 100644
@@ -904,6 +904,7 @@ AC_SUBST([OPTIONAL_PKCS11_HELPER_LIBS])
 AM_CONDITIONAL([WIN32], [test "${WIN32}" = "yes"])
 
 AC_CONFIG_FILES([
+	version.sh
 	Makefile
 	build/Makefile
 	build/msvc/Makefile
version.sh.in new file +4 -0
new file mode 100644
index 0000000..2af5a36
@@ -0,0 +1,4 @@
+OPENVPN_PACKAGE_NAME="@PACKAGE_NAME@"
+OPENVPN_PACKAGE_TARNAME="@PACKAGE_TARNAME@"
+OPENVPN_PACKAGE_VERSION="@PACKAGE_VERSION@"
+OPENVPN_PACKAGE_HOST="@host@"
#109 lore raw

Re: [Openvpn-devel] [PATCH 51/52] build: distribute samples in windows

In reply to Alon Bar-Lev

So, this essentially makes sure client.conf and server.conf are included in Windows (installers) as client.ovpn and server.ovpn?

If so, ACK.

Signature · 5 lines
Samuli Seppänen
Community Manager
OpenVPN Technologies, Inc

irc freenode net: mattock
Quoted 42 lines
---
 configure.ac       |    3 +++
 sample/Makefile.am |   14 ++++++++++++++
 2 files changed, 17 insertions(+), 0 deletions(-)
configure.ac +3 -0
index 0f2a62e..2b095a3 100644
@@ -903,6 +903,9 @@ AC_SUBST([OPTIONAL_PKCS11_HELPER_LIBS])
 
 AM_CONDITIONAL([WIN32], [test "${WIN32}" = "yes"])
 
+sampledir="\$(docdir)/sample"
+AC_SUBST([sampledir])
+
 AC_CONFIG_FILES([
 	version.sh
 	Makefile
sample/Makefile.am +14 -0
index 5df8d9c..8e35bfc 100644
@@ -17,3 +17,17 @@ EXTRA_DIST = \
 	sample-windows \
 	sample-keys \
 	sample-scripts
+
+if WIN32
+sample_DATA = \
+	client.ovpn \
+	server.ovpn \
+	sample-windows/sample.ovpn
+
+client.ovpn: sample-config-files/client.conf
+	-rm -f client.ovpn
+	cp "$(srcdir)/sample-config-files/client.conf" client.ovpn
+server.ovpn: sample-config-files/server.conf
+	-rm -f server.ovpn
+	cp "$(srcdir)/sample-config-files/server.conf" server.ovpn
+endif
#111 lore raw

Re: [Openvpn-devel] [PATCH 52/52] build: use tap-windows.h as external dependency

In reply to Alon Bar-Lev

If I understood this correctly, include/tap-windows.h gets removed, and will then be included using the same mechanism that's used to include LZO headers, OpenSSL headers, etc. I think this makes sense now that the TAP-driver is a separate subproject.

ACK.

Signature · 5 lines
Samuli Seppänen
Community Manager
OpenVPN Technologies, Inc

irc freenode net: mattock
Quoted 182 lines

tap-windows.h is provided by the tap project

---
 configure.ac               |   12 ++++++++
 include/Makefile.am        |    2 -
 include/tap-windows.h      |   68 --------------------------------------------
 msvc-env.bat               |    2 +
 src/openvpn/Makefile.am    |    1 +
 src/openvpn/openvpn.vcproj |    4 +-
 6 files changed, 17 insertions(+), 72 deletions(-)
 delete mode 100644 include/tap-windows.h
configure.ac +12 -0
index 2b095a3..c6cabee 100644
@@ -666,6 +666,18 @@ PKG_CHECK_MODULES(
        )]
 )
 
+AC_ARG_VAR([TAP_WINDOWS_CFLAGS], [C compiler flags for TAP-Windows])
+if test "${WIN32}" = "yes"; then
+       old_CFLAGS="${CFLAGS}"
+       CFLAGS="${CFLAGS} ${TAP_WINDOWS_CFLAGS}"
+       AC_CHECK_HEADERS(
+               [tap-windows.h],
+               ,
+               [AC_MSG_ERROR([tap-windows.h is required but missing])]
+       )
+       CFLAGS="${old_CFLAGS}"
+fi
+
 if test "${have_openssl_crypto}" = "yes"; then
        saved_CFLAGS="${CFLAGS}"
        saved_LIBS="${LIBS}"
include/Makefile.am +0 -2
index 36eeb6c..13dee61 100644
@@ -12,6 +12,4 @@
 MAINTAINERCLEANFILES = \
        $(srcdir)/Makefile.in
 
-dist_noinst_HEADERS = tap-windows.h
-
 include_HEADERS = openvpn-plugin.h
include/tap-windows.h deleted +0 -68
deleted file mode 100644
index 243a4a2..0000000
@@ -1,68 +0,0 @@
-/*
- *  TAP-Windows -- A kernel driver to provide virtual tap
- *                 device functionality on Windows.
- *
- *  This code was inspired by the CIPE-Win32 driver by Damion K. Wilson.
- *
- *  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
- *  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
- */
-#ifndef __TAP_WIN_H
-#define __TAP_WIN_H
-
-//=============
-// TAP IOCTLs
-//=============
-
-#define TAP_WIN_CONTROL_CODE(request,method) \
-  CTL_CODE (FILE_DEVICE_UNKNOWN, request, method, FILE_ANY_ACCESS)
-
-// Present in 8.1
-
-#define TAP_WIN_IOCTL_GET_MAC               TAP_WIN_CONTROL_CODE (1, METHOD_BUFFERED)
-#define TAP_WIN_IOCTL_GET_VERSION           TAP_WIN_CONTROL_CODE (2, METHOD_BUFFERED)
-#define TAP_WIN_IOCTL_GET_MTU               TAP_WIN_CONTROL_CODE (3, METHOD_BUFFERED)
-#define TAP_WIN_IOCTL_GET_INFO              TAP_WIN_CONTROL_CODE (4, METHOD_BUFFERED)
-#define TAP_WIN_IOCTL_CONFIG_POINT_TO_POINT TAP_WIN_CONTROL_CODE (5, METHOD_BUFFERED)
-#define TAP_WIN_IOCTL_SET_MEDIA_STATUS      TAP_WIN_CONTROL_CODE (6, METHOD_BUFFERED)
-#define TAP_WIN_IOCTL_CONFIG_DHCP_MASQ      TAP_WIN_CONTROL_CODE (7, METHOD_BUFFERED)
-#define TAP_WIN_IOCTL_GET_LOG_LINE          TAP_WIN_CONTROL_CODE (8, METHOD_BUFFERED)
-#define TAP_WIN_IOCTL_CONFIG_DHCP_SET_OPT   TAP_WIN_CONTROL_CODE (9, METHOD_BUFFERED)
-
-// Added in 8.2
-
-/* obsoletes TAP_WIN_IOCTL_CONFIG_POINT_TO_POINT */
-#define TAP_WIN_IOCTL_CONFIG_TUN            TAP_WIN_CONTROL_CODE (10, METHOD_BUFFERED)
-
-//=================
-// Registry keys
-//=================
-
-#define ADAPTER_KEY "SYSTEM\\CurrentControlSet\\Control\\Class\\{4D36E972-E325-11CE-BFC1-08002BE10318}"
-
-#define NETWORK_CONNECTIONS_KEY "SYSTEM\\CurrentControlSet\\Control\\Network\\{4D36E972-E325-11CE-BFC1-08002BE10318}"
-
-//======================
-// Filesystem prefixes
-//======================
-
-#define USERMODEDEVICEDIR "\\\\.\\Global\\"
-#define SYSDEVICEDIR      "\\Device\\"
-#define USERDEVICEDIR     "\\DosDevices\\Global\\"
-#define TAP_WIN_SUFFIX    ".tap"
-
-#endif
msvc-env.bat +2 -0
index ef9c7bb..e37757b 100644
@@ -23,7 +23,9 @@ if "%OPENVPN_DEPROOT%" == "" set OPENVPN_DEPROOT=c:\Temp\openvpn-deps
 if "%OPENSSL_HOME%" == "" set OPENSSL_HOME=%OPENVPN_DEPROOT%
 if "%LZO_HOME%" == "" set LZO_HOME=%OPENVPN_DEPROOT%
 if "%PKCS11H_HOME%" == "" set PKCS11H_HOME=%OPENVPN_DEPROOT%
+if "%TAP_WINDOWS_HOME%" == "" set TAP_WINDOWS_HOME=%OPENVPN_DEPROOT%
 
 if not exist "%OPENSSL_HOME%" echo WARNING: openssl '%OPENSSL_HOME%' does not exist
 if not exist "%LZO_HOME%" echo WARNING: lzo '%LZO_HOME%' does not exist
 if not exist "%PKCS11H_HOME%" echo WARNING: pkcs11-helper '%PKCS11H_HOME%' does not exist
+if not exist "%TAP_WINDOWS_HOME%" echo WARNING: tap-windows '%TAP_WINDOWS_HOME%' does not exist
src/openvpn/Makefile.am +1 -0
index 6ba12b8..1410021 100644
@@ -22,6 +22,7 @@ INCLUDES = \
        -I$(top_srcdir)/src/compat
 
 AM_CFLAGS = \
+       $(TAP_WINDOWS_CFLAGS) \
        $(OPTIONAL_CRYPTO_CFLAGS) \
        $(OPTIONAL_LZO_CFLAGS) \
        $(OPTIONAL_PKCS11_HELPER_CFLAGS)
src/openvpn/openvpn.vcproj +2 -3
index 4680e52..c1aa8a0 100644
@@ -41,7 +41,7 @@
                        <Tool
                                Name="VCCLCompilerTool"
                                Optimization="0"
-                               AdditionalIncludeDirectories="$(SOURCEBASE);$(SOURCEBASE)/src/compat;$(SOURCEBASE)/include;$(OPENSSL_HOME)/include;$(LZO_HOME)/include;$(PKCS11H_HOME)/include"
+                               AdditionalIncludeDirectories="$(SOURCEBASE);$(SOURCEBASE)/src/compat;$(SOURCEBASE)/include;$(TAP_WINDOWS_HOME)/include;$(OPENSSL_HOME)/include;$(LZO_HOME)/include;$(PKCS11H_HOME)/include"
                                PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;$(CPPFLAGS)"
                                MinimalRebuild="true"
                                BasicRuntimeChecks="3"
@@ -118,7 +118,7 @@
                                Name="VCCLCompilerTool"
                                Optimization="2"
                                EnableIntrinsicFunctions="true"
-                               AdditionalIncludeDirectories="$(SOURCEBASE);$(SOURCEBASE)/src/compat;$(SOURCEBASE)/include;$(OPENSSL_HOME)/include;$(LZO_HOME)/include;$(PKCS11H_HOME)/include"
+                               AdditionalIncludeDirectories="$(SOURCEBASE);$(SOURCEBASE)/src/compat;$(SOURCEBASE)/include;$(TAP_WINDOWS_HOME)/include;$(OPENSSL_HOME)/include;$(LZO_HOME)/include;$(PKCS11H_HOME)/include"
                                PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;$(CPPFLAGS)"
                                RuntimeLibrary="2"
                                EnableFunctionLevelLinking="true"
--

1.7.3.4

------------------------------------------------------------------------------
Virtualization & Cloud Management Using Capacity Planning Cloud computing makes use of virtualization - but cloud computing also focuses on allowing computing to be delivered as a service.
http://www.accelacomm.com/jaw/sfnl/114/51521223/
_______________________________________________
Openvpn-devel mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel

#106 lore raw

Re: [Openvpn-devel] [PATCH 50/52] build: windows: install version.sh to allow installer read version

In reply to Samuli Seppänen

Not exactly.
It is used[1] by the packaging script... just sourced to get some environment variables.

[1] https://github.com/alonbl/openvpn-build/blob/master/windows-nsis/build#L55

2012/3/8 Samuli Seppänen <[email protected]...>:

Quoted 75 lines

Is this meant to allow using these variables[1] in the NSIS script(s)?

--
Samuli Seppänen
Community Manager
OpenVPN Technologies, Inc

irc freenode net: mattock

[1]

OPENVPN_PACKAGE_NAME="@PACKAGE_NAME@"
OPENVPN_PACKAGE_TARNAME="@PACKAGE_TARNAME@"
OPENVPN_PACKAGE_VERSION="@PACKAGE_VERSION@"
OPENVPN_PACKAGE_HOST="@host@"

Quoted 56 lines

---
 .gitignore    |    1 +
 Makefile.am   |    5 +++++
 configure.ac  |    1 +
 version.sh.in |    4 ++++

 4 files changed, 11 insertions(+), 0 deletions(-)

 create mode 100644 version.sh.in

.gitignore +0 -0
index e7232cf..2f72ed8 100644
@@ -39,6 +39,7 @@ m4/ltsugar.m4

 m4/ltversion.m4
 m4/lt~obsolete.m4

+version.sh
 msvc-env-local.bat
 config-msvc-local.h
 config-msvc-version.h

Makefile.am +0 -0
index 5293518..68aa0a8 100644
@@ -69,3 +69,8 @@ endif
  dist_noinst_HEADERS = \
       config-msvc.h \

      config-msvc-version.h.in

Makefile.am +5 -0
+
+if WIN32
+rootdir=$(prefix)
+root_DATA = version.sh
+endif
configure.ac +0 -0
index d53a74a..0f2a62e 100644
@@ -904,6 +904,7 @@ AC_SUBST([OPTIONAL_PKCS11_HELPER_LIBS])
  AM_CONDITIONAL([WIN32], [test "${WIN32}" = "yes"])
 

 AC_CONFIG_FILES([
+     version.sh
      Makefile
      build/Makefile
      build/msvc/Makefile

version.sh.in new file +4 -0
new file mode 100644
index 0000000..2af5a36
@@ -0,0 +1,4 @@
+OPENVPN_PACKAGE_NAME="@PACKAGE_NAME@"
+OPENVPN_PACKAGE_TARNAME="@PACKAGE_TARNAME@"
+OPENVPN_PACKAGE_VERSION="@PACKAGE_VERSION@"
+OPENVPN_PACKAGE_HOST="@host@"
#91 lore raw

Re: [Openvpn-devel] [PATCH 46/52] build: move daemon() emulation into compat

In reply to Samuli Seppänen

daemon is gnu specific:
---
CONFORMING TO
Not in POSIX.1-2001. A similar function appears on the BSDs.
The daemon() function
first appeared in 4.4BSD.
---

Solaris, uclibc and other does not have it.

2012/3/8 Samuli Seppänen <[email protected]...>:

Quoted 246 lines

Which platforms need daemon() emulation? Only Windows?

I think it makes sense to isolate OS compatibility functions to files under src/compat. Better than having them in misc.c. Also, I can't see any obvious issues with the patch, code-vise.

ACK.

--
Samuli Seppänen
Community Manager
OpenVPN Technologies, Inc

irc freenode net: mattock

Quoted 228 lines

---
 src/compat/Makefile.am     |    3 +-
 src/compat/compat-daemon.c |  100 ++++++++++++++++++++++++++++++++++++++++++++ src/compat/compat.h        |    4 ++
 src/compat/compat.vcproj   |    4 ++

 src/openvpn/init.c         |    2 +-
 src/openvpn/misc.c         |   32 --------------
 src/openvpn/misc.h         |    4 --
 7 files changed, 111 insertions(+), 38 deletions(-)

 create mode 100644 src/compat/compat-daemon.c

src/compat/Makefile.am +2 -1
index 5e9db5f..c8a92ce 100644
@@ -21,4 +21,5 @@ libcompat_la_SOURCES = \
       compat.h \
       compat-dirname.c \
       compat-basename.c \
-     compat-gettimeofday.c
+     compat-gettimeofday.c \
+     compat-daemon.c
src/compat/compat-daemon.c new file +100 -0
new file mode 100644
index 0000000..dde96a2
@@ -0,0 +1,100 @@
+/*
+ *  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) 2011 - David Sommerseth <[email protected]...>
+ *
+ *  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
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#elif defined(_MSC_VER)
+#include "config-msvc.h"
+#endif
+
+#ifndef HAVE_DAEMON
+
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+
+#ifdef HAVE_STDLIB_H
+#include <stdlib.h>
+#endif
+
+#ifdef HAVE_SYS_TYPES_H
+#include <sys/types.h>
+#endif
+
+#ifdef HAVE_SYS_STAT_H
+#include <sys/stat.h>
+#endif
+
+#ifdef HAVE_FCNTL_H
+#include <fcntl.h>
+#endif
+
+#ifdef HAVE_ERRNO_H
+#include <errno.h>
+#endif
+
+int
+daemon(int nochdir, int noclose)
+{
+#if defined(HAVE_FORK) && defined(HAVE_SETSID)
+     switch (fork()) {
+             case -1:
+                     return (-1);
+             case 0:
+             break;
+             default:
+                     exit(0);
+     }
+
+     if (setsid() == -1)
+             return (-1);
+
+     if (!nochdir)
+             chdir("/");
+
+     if (!noclose) {
+#if defined(HAVE_DUP) && defined(HAVE_DUP2)
+             int fd;
+             if ((fd = open ("/dev/null", O_RDWR, 0)) != -1) {
+                     dup2 (fd, 0);
+                     dup2 (fd, 1);
+                     dup2 (fd, 2);
+                     if (fd > 2) {
+                             close (fd);
+                     }
+             }
+#endif
+     }
+
+     return 0;
+#else
+     (void)nochdir;
+     (void)noclose;
+     errno = EFAULT;
+     return -1;
+#endif
+}
+
+#endif
+
src/compat/compat.h +4 -0
index 3f9ac31..e9d51b8 100644
@@ -46,4 +46,8 @@ char * basename(char *str);
  int gettimeofday (struct timeval *tv, void *tz);
  #endif
 
+#ifndef HAVE_DAEMON
+int daemon(int nochdir, int noclose);
+#endif
+
  #endif /* COMPAT_H */
src/compat/compat.vcproj +0 -0
index 235163c..efdecb4 100644
@@ -162,6 +162,10 @@

                              RelativePath=".\compat-gettimeofday.c" >
                      </File>
+                     <File
+                             RelativePath=".\compat-daemon.c"
+                             >
+                     </File>
              </Filter>
              <Filter
                      Name="Header Files"

src/openvpn/init.c +1 -1
index e7edb05..bba3cf8 100644
@@ -993,7 +993,7 @@ possibly_become_daemon (const struct options *options, const bool first_time)
      {
        ASSERT (!options->inetd);
        if (daemon (options->cd_dir != NULL, options->log) < 0)
-     msg (M_ERR, "daemon() failed");
+     msg (M_ERR, "daemon() failed or unsupported");
        restore_signal_state ();
        if (options->log)
       set_std_files_to_null (true);
src/openvpn/misc.c +0 -32
index 898a183..07beaf0 100644
@@ -301,38 +301,6 @@ do_mlockall(bool print_msg)
  #endif
  }
 
-#ifndef HAVE_DAEMON
-
-int
-daemon(int nochdir, int noclose)
-{
-#if defined(HAVE_FORK) && defined(HAVE_SETSID)
-  switch (fork())
-    {
-    case -1:
-      return (-1);
-    case 0:
-      break;
-    default:
-      openvpn_exit (OPENVPN_EXIT_STATUS_GOOD); /* exit point */
-    }
-
-  if (setsid() == -1)
-    return (-1);
-
-  if (!nochdir)
-    openvpn_chdir ("/");
-
-  if (!noclose)
-    set_std_files_to_null (false);
-#else
-  msg (M_FATAL, "Sorry but I can't become a daemon because this operating system doesn't appear to support either the daemon() or fork() system calls");
-#endif
-  return (0);
-}
-
-#endif
-
  /*
   * Set standard file descriptors to /dev/null
   */
src/openvpn/misc.h +0 -0
index 9fa8106..9bb2fa2 100644
@@ -115,10 +115,6 @@ unsigned int openvpn_getpid (void);
 

 void do_mlockall (bool print_msg); /* Disable paging */

src/openvpn/misc.h +0 -4
-#ifndef HAVE_DAEMON
-int daemon (int nochdir, int noclose);
-#endif
-

 /* check file protections */
 void warn_if_group_others_accessible(const char* filename);

#101 lore raw

Re: [Openvpn-devel] [PATCH 49/52] build: move wrappers into platform module

In reply to Samuli Seppänen

Well, at first I wanted to split it into its own libplatform distinct from libcompat.

libcompat - emulation of missing library functions, drop-in replacement. libplatform - extensions to library functions, such as unicode or security additions.

But then I've seen that there is too much openvpn specific logic, especially in log messages. So I left what I would have placed in libplatform in platform.c for now.

After this round we should consider if we want to progress in this.

One missing part is the exec wrappers which needs some work before moving to platform.

Alon.

2012/3/8 Samuli Seppänen <[email protected]...>:

Quoted 1,682 lines

This probably makes sense, lots of good refactorings. That said, I'd like to know how you selected what goes to platform.c?

--
Samuli Seppänen
Community Manager
OpenVPN Technologies, Inc

irc freenode net: mattock

Quoted 1,669 lines

+ Some fixups within the platform.c functions.
- need to check environment set on Windows.

---
 src/openvpn/Makefile.am    |    1 +
 src/openvpn/buffer.c       |    2 +-
 src/openvpn/crypto.c       |    6 +-
 src/openvpn/error.c        |    2 +-
 src/openvpn/init.c         |   18 +-
 src/openvpn/manage.c       |   16 +-
 src/openvpn/misc.c         |  295 ++---------------------------------- src/openvpn/misc.h         |  106 +------------- src/openvpn/mstats.c       |    2 +-
 src/openvpn/multi.c        |    2 +-
 src/openvpn/openvpn.h      |    4 +-
 src/openvpn/openvpn.vcproj |    8 +
 src/openvpn/options.c      |   14 +-
 src/openvpn/packet_id.c    |    2 +-
 src/openvpn/pf.c           |    6 +-
 src/openvpn/platform.c     |  369 ++++++++++++++++++++++++++++++++++++++++++++ src/openvpn/platform.h     |  142 +++++++++++++++++ src/openvpn/ps.c           |    2 +-
 src/openvpn/ssl_openssl.c  |    2 +-
 src/openvpn/ssl_verify.c   |    8 +-
 src/openvpn/status.c       |    6 +-
 src/openvpn/tun.c          |   12 +-
 src/openvpn/win32.c        |   27 ----

 23 files changed, 584 insertions(+), 468 deletions(-)

 create mode 100644 src/openvpn/platform.c
 create mode 100644 src/openvpn/platform.h

src/openvpn/Makefile.am +1 -0
index 333eebc..6ba12b8 100644
@@ -58,6 +58,7 @@ openvpn_SOURCES = \
         mbuf.c mbuf.h \
         memdbg.h \
         misc.c misc.h \
+       platform.c platform.h \
         console.c console.h \
         mroute.c mroute.h \
         mss.c mss.h \
src/openvpn/buffer.c +0 -0
index ad30223..5eee3ee 100644
@@ -1080,7 +1080,7 @@ buffer_list_advance (struct buffer_list *ol, int n)

 struct buffer_list *
 buffer_list_file (const char *fn, int max_line_len) {
-  FILE *fp = openvpn_fopen (fn, "r");
+  FILE *fp = platform_fopen (fn, "r"); struct buffer_list *bl = NULL;

   if (fp)

src/openvpn/crypto.c +3 -3
index 2e2e5d7..f811966 100644
@@ -868,7 +868,7 @@ read_key_file (struct key2 *key2, const char *file, const unsigned int flags)
  #endif
      {
        in = alloc_buf_gc (2048, &gc);
-      fd = openvpn_open (file, O_RDONLY, 0);
+      fd = platform_open (file, O_RDONLY, 0);
        if (fd == -1)
         msg (M_ERR, "Cannot open file key file '%s'", file);
        size = read (fd, in.data, in.capacity);
@@ -1029,7 +1029,7 @@ read_passphrase_hash (const char *passphrase_file,
      const int min_passphrase_size = 8;
      uint8_t buf[64];
      int total_size = 0;
-    int fd = openvpn_open (passphrase_file, O_RDONLY, 0);
+    int fd = platform_open (passphrase_file, O_RDONLY, 0);
 
      if (fd == -1)
        msg (M_ERR, "Cannot open passphrase file: '%s'", passphrase_file);
@@ -1079,7 +1079,7 @@ write_key_file (const int nkeys, const char *filename)
    const int bytes_per_line = 16;
 
    /* open key file */
-  fd = openvpn_open (filename, O_CREAT | O_TRUNC | O_WRONLY, S_IRUSR | S_IWUSR);
+  fd = platform_open (filename, O_CREAT | O_TRUNC | O_WRONLY, S_IRUSR | S_IWUSR);
 
    if (fd == -1)
      msg (M_ERR, "Cannot open shared secret file '%s' for write", filename);
src/openvpn/error.c +1 -1
index 1f2dd86..d6ad639 100644
@@ -640,7 +640,7 @@ x_check_status (int status,
                  my_errno);
 
           if (x_cs_err_delay_ms)
-           sleep_milliseconds (x_cs_err_delay_ms);
+           platform_sleep_milliseconds (x_cs_err_delay_ms);
         }
        gc_free (&gc);
      }
src/openvpn/init.c +0 -0
index bba3cf8..bc7718e 100644
@@ -935,7 +935,7 @@ do_genkey (const struct options * options)
                "shared secret output file (--secret)");
 

       if (options->mlock)      /* should we disable paging? */
-       do_mlockall (true);
+       platform_mlockall (true);

       nbits_written = write_key_file (2, options->shared_secret_file);

src/openvpn/init.c +1 -1
@@ -1022,7 +1022,7 @@ do_uid_gid_chroot (struct context *c, bool no_delay)
        if (c->options.chroot_dir)
         {
           if (no_delay)
-           do_chroot (c->options.chroot_dir);
+           platform_chroot (c->options.chroot_dir);

          else
            msg (M_INFO, "NOTE: chroot %s", why_not); }

src/openvpn/init.c +2 -2
@@ -1030,8 +1030,8 @@ do_uid_gid_chroot (struct context *c, bool no_delay)
        /* set user and/or group that we want to setuid/setgid to */
        if (no_delay)
         {
-         set_group (&c0->group_state);
-         set_user (&c0->user_state);
+         platform_group_set (&c0->platform_state_group);
+         platform_user_set (&c0->platform_state_user);
           c0->uid_gid_set = true;
         }
        else if (c0->uid_gid_specified)
@@ -2780,8 +2780,8 @@ do_init_first_time (struct context *c)
 
        /* get user and/or group that we want to setuid/setgid to */

       c0->uid_gid_specified =
-       get_group (c->options.groupname, &c0->group_state) |
-       get_user (c->options.username, &c0->user_state);
+       platform_group_get (c->options.groupname, &c0->platform_state_group) |
+       platform_user_get (c->options.username, &c0->platform_state_user);

       /* get --writepid file descriptor */ get_pid_file (c->options.writepid, &c0->pid_state);

src/openvpn/init.c +3 -3
@@ -2791,13 +2791,13 @@ do_init_first_time (struct context *c)
 
        /* should we disable paging? */
        if (c->options.mlock && c->did_we_daemonize)
-       do_mlockall (true);     /* call again in case we daemonized */
+       platform_mlockall (true);       /* call again in case we daemonized */
 
        /* save process ID in a file */
        write_pid (&c0->pid_state);
 
        /* should we change scheduling priority? */
-      set_nice (c->options.nice);
+      platform_nice (c->options.nice);
      }
  }
 
@@ -3342,7 +3342,7 @@ init_instance (struct context *c, const struct env_set *env, const unsigned int
 
    /* should we disable paging? */
    if (c->first_time && options->mlock)
-    do_mlockall (true);
+    platform_mlockall (true);
 
  #if P2MP
    /* get passwords if undefined */
src/openvpn/manage.c +8 -8
index 85c9aca..1dddd41 100644
@@ -1146,7 +1146,7 @@ man_dispatch_command (struct management *man, struct status_output *so, const ch
      }
    else if (streq (p[0], "pid"))
      {
-      msg (M_CLIENT, "SUCCESS: pid=%d", openvpn_getpid ());
+      msg (M_CLIENT, "SUCCESS: pid=%d", platform_getpid ());
      }
  #ifdef MANAGEMENT_DEF_AUTH
    else if (streq (p[0], "nclients"))
@@ -1429,7 +1429,7 @@ man_record_peer_info (struct management *man)
             {
               const in_addr_t a = ntohl (addr.sin_addr.s_addr);
               const int p = ntohs (addr.sin_port);
-             FILE *fp = openvpn_fopen (man->settings.write_peer_info_file, "w");
+             FILE *fp = platform_fopen (man->settings.write_peer_info_file, "w");
               if (fp)
                 {
                   fprintf (fp, "%s\n%d\n", print_in_addr_t (a, 0, &gc), p);
@@ -2013,17 +2013,17 @@ man_settings_init (struct man_settings *ms,
         */
        if (client_user)
         {
-         struct user_state s;
-         get_user (client_user, &s);
-         ms->client_uid = user_state_uid (&s);
+         struct platform_state_user s;
+         platform_user_get (client_user, &s);
+         ms->client_uid = platform_state_user_uid (&s);
           msg (D_MANAGEMENT, "MANAGEMENT: client_uid=%d", ms->client_uid);
           ASSERT (ms->client_uid >= 0);
         }
        if (client_group)
         {
-         struct group_state s;
-         get_group (client_group, &s);
-         ms->client_gid = group_state_gid (&s);
+         struct platform_state_group s;
+         platform_group_get (client_group, &s);
+         ms->client_gid = platform_state_group_gid (&s);
           msg (D_MANAGEMENT, "MANAGEMENT: client_gid=%d", ms->client_gid);
           ASSERT (ms->client_gid >= 0);
         }
src/openvpn/misc.c +0 -0
index 2571194..2ded9bf 100644
@@ -56,122 +56,6 @@ int script_security = SSEC_BUILT_IN; /* GLOBAL */
  /* contains SM_x value defined in misc.h */

 int script_method = SM_EXECVE; /* GLOBAL */

src/openvpn/misc.c +0 -116
-/* Redefine the top level directory of the filesystem
-   to restrict access to files for security */
-void
-do_chroot (const char *path)
-{
-  if (path)
-    {
-#ifdef HAVE_CHROOT
-      const char *top = "/";
-      if (chroot (path))
-       msg (M_ERR, "chroot to '%s' failed", path);
-      if (openvpn_chdir (top))
-       msg (M_ERR, "cd to '%s' failed", top);
-      msg (M_INFO, "chroot to '%s' and cd to '%s' succeeded", path, top);
-#else
-      msg (M_FATAL, "Sorry but I can't chroot to '%s' because this operating system doesn't appear to support the chroot() system call", path);
-#endif
-    }
-}
-
-/* Get/Set UID of process */
-
-bool
-get_user (const char *username, struct user_state *state)
-{
-  bool ret = false;
-  CLEAR (*state);
-  if (username)
-    {
-#if defined(HAVE_GETPWNAM) && defined(HAVE_SETUID)
-      state->pw = getpwnam (username);
-      if (!state->pw)
-       msg (M_ERR, "failed to find UID for user %s", username);
-      state->username = username;
-      ret = true;
-#else
-      msg (M_FATAL, "cannot get UID for user %s -- platform lacks getpwname() or setuid() system calls", username);
-#endif
-    }
-  return ret;
-}
-
-void
-set_user (const struct user_state *state)
-{
-#if defined(HAVE_GETPWNAM) && defined(HAVE_SETUID)
-  if (state->username && state->pw)
-    {
-      if (setuid (state->pw->pw_uid))
-       msg (M_ERR, "setuid('%s') failed", state->username);
-      msg (M_INFO, "UID set to %s", state->username);
-    }
-#endif
-}
-
-/* Get/Set GID of process */
-
-bool
-get_group (const char *groupname, struct group_state *state)
-{
-  bool ret = false;
-  CLEAR (*state);
-  if (groupname)
-    {
-#if defined(HAVE_GETGRNAM) && defined(HAVE_SETGID)
-      state->gr = getgrnam (groupname);
-      if (!state->gr)
-       msg (M_ERR, "failed to find GID for group %s", groupname);
-      state->groupname = groupname;
-      ret = true;
-#else
-      msg (M_FATAL, "cannot get GID for group %s -- platform lacks getgrnam() or setgid() system calls", groupname);
-#endif
-    }
-  return ret;
-}
-
-void
-set_group (const struct group_state *state)
-{
-#if defined(HAVE_GETGRNAM) && defined(HAVE_SETGID)
-  if (state->groupname && state->gr)
-    {
-      if (setgid (state->gr->gr_gid))
-       msg (M_ERR, "setgid('%s') failed", state->groupname);
-      msg (M_INFO, "GID set to %s", state->groupname);
-#ifdef HAVE_SETGROUPS
-      {
-        gid_t gr_list[1];
-       gr_list[0] = state->gr->gr_gid;
-       if (setgroups (1, gr_list))
-         msg (M_ERR, "setgroups('%s') failed", state->groupname);
-      }
-#endif
-    }
-#endif
-}
-
-/* Change process priority */
-void
-set_nice (int niceval)
-{
-  if (niceval)
-    {
-#ifdef HAVE_NICE
-      errno = 0;
-      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
-      msg (M_WARN, "WARNING: nice %d failed (function not implemented)", niceval);
-#endif
-    }
-}
-

 /*
  * Pass tunnel endpoint and MTU parms to a user-supplied script.
  * Used to execute the up/down script/plugins.

src/openvpn/misc.c +2 -78
@@ -253,7 +137,7 @@ get_pid_file (const char* filename, struct pid_state *state)
    CLEAR (*state);
    if (filename)
      {
-      state->fp = openvpn_fopen (filename, "w");
+      state->fp = platform_fopen (filename, "w");
        if (!state->fp)
         msg (M_ERR, "Open error on pid file %s", filename);
        state->filename = filename;
@@ -266,42 +150,13 @@ write_pid (const struct pid_state *state)
  {
    if (state->filename && state->fp)
      {
-      unsigned int pid = openvpn_getpid ();
+      unsigned int pid = platform_getpid ();
        fprintf(state->fp, "%u\n", pid);
        if (fclose (state->fp))
         msg (M_ERR, "Close error on pid file %s", state->filename);
      }
  }
 
-/* Get current PID */
-unsigned int
-openvpn_getpid ()
-{
-#ifdef WIN32
-  return (unsigned int) GetCurrentProcessId ();
-#else
-#ifdef HAVE_GETPID
-  return (unsigned int) getpid ();
-#else
-  return 0;
-#endif
-#endif
-}
-
-/* Disable paging */
-void
-do_mlockall(bool print_msg)
-{
-#ifdef HAVE_MLOCKALL
-  if (mlockall (MCL_CURRENT | MCL_FUTURE))
-    msg (M_WARN | M_ERRNO, "WARNING: mlockall call failed");
-  else if (print_msg)
-    msg (M_INFO, "mlockall call succeeded");
-#else
-  msg (M_WARN, "WARNING: mlockall call failed (function not implemented)");
-#endif
-}
-
  /*
   * Set standard file descriptors to /dev/null
   */
@@ -325,27 +180,6 @@ set_std_files_to_null (bool stdin_only)
  }
 
  /*
- * Wrapper for chdir library function
- */
-int
-openvpn_chdir (const char* dir)
-{
-#ifdef HAVE_CHDIR
-#ifdef WIN32
-  int res;
-  struct gc_arena gc = gc_new ();
-  res = _wchdir (wide_string (dir, &gc));
-  gc_free (&gc);
-  return res;
-#else
-  return chdir (dir);
-#endif
-#else
-  return -1;
-#endif
-}
-
-/*
   *  dup inetd/xinetd socket descriptor and save
   */
 
@@ -391,32 +225,6 @@ warn_if_group_others_accessible (const char* filename)
  }
 
  /*
- * convert system() return into a success/failure value
- */
-bool
-system_ok (int stat)
-{
-#ifdef WIN32
-  return stat == 0;
-#else
-  return stat != -1 && WIFEXITED (stat) && WEXITSTATUS (stat) == 0;
-#endif
-}
-
-/*
- * did system() call execute the given command?
- */
-bool
-system_executed (int stat)
-{
-#ifdef WIN32
-  return stat != -1;
-#else
-  return stat != -1 && WEXITSTATUS (stat) != 127;
-#endif
-}
-
-/*
   * Print an error message based on the status code returned by system().
   */

 const char *

src/openvpn/misc.c +1 -1
@@ -456,7 +264,7 @@ openvpn_execve_check (const struct argv *a, const struct env_set *es, const unsi
    const int stat = openvpn_execve (a, es, flags);
    int ret = false;
 
-  if (system_ok (stat))
+  if (platform_system_ok (stat))
      ret = true;

   else
     {

src/openvpn/misc.c +1 -21
@@ -554,7 +362,6 @@ openvpn_system (const char *command, const struct env_set *es, unsigned int flag
  {
  #ifdef HAVE_SYSTEM
    int ret;
-  struct gc_arena gc;
 
    perf_push (PERF_SCRIPT);
 
@@ -573,13 +380,7 @@ openvpn_system (const char *command, const struct env_set *es, unsigned int flag
    /*
     * execute the command
     */
-#ifdef WIN32
-  gc = gc_new ();
-  ret = _wsystem (wide_string (command, &gc));
-  gc_free (&gc);
-#else
-  ret = system (command);
-#endif
+  ret = platform_system(command);
 
    /* debugging */
    dmsg (D_SCRIPT, "SYSTEM return=%u", ret);
@@ -599,19 +400,6 @@ openvpn_system (const char *command, const struct env_set *es, unsigned int flag
  #endif
  }
 
-int
-openvpn_access (const char *path, int mode)
-{
-#ifdef WIN32
-  struct gc_arena gc = gc_new ();
-  int ret = _waccess (wide_string (path, &gc), mode);
-  gc_free (&gc);
-  return ret;
-#else
-  return access (path, mode);
-#endif
-}
-
  /*
   * Run execve() inside a fork(), duping stdout.  Designed to replicate the semantics of popen() but
   * in a safer way that doesn't require the invocation of a shell or the risks
@@ -981,7 +769,7 @@ env_set_remove_from_environment (const struct env_set *es)
 

 static struct env_item *global_env = NULL; /* GLOBAL */

src/openvpn/misc.c +1 -1
-static void
+void

 manage_env (char *str)
 {
   remove_env_item (str, true, &global_env);

src/openvpn/misc.c +0 -0
@@ -1078,27 +866,11 @@ setenv_str_ex (struct env_set *es,
      }

   else
     {
-#if defined(WIN32)
+      char *str = construct_name_value (name_tmp, val_tmp, NULL);
+      if (platform_putenv(str))
       {
-        if (!SetEnvironmentVariableW (wide_string (name_tmp, &gc),
-                                      wide_string (val_tmp, &gc)))
-         msg (M_WARN | M_ERRNO, "SetEnvironmentVariable failed, name='%s', value='%s'",
-              name_tmp,
-              val_tmp ? val_tmp : "NULL");
+        msg (M_WARN | M_ERRNO, "putenv('%s') failed", str);
       }

src/openvpn/misc.c +0 -13
-#elif defined(HAVE_PUTENV)
-      {
-       char *str = construct_name_value (name_tmp, val_tmp, NULL);
-       int status;
-
-       status = putenv (str);
-       /*msg (M_INFO, "PUTENV '%s'", str);*/
-       if (!status)
-         manage_env (str);
-       if (status)
-         msg (M_WARN | M_ERRNO, "putenv('%s') failed", str);
-      }
-#endif

     }

   gc_free (&gc);

src/openvpn/misc.c +0 -29
@@ -1162,35 +934,6 @@ count_netmask_bits(const char *dotted_quad)
    return ((int)result);
  }
 
-/*
- * Go to sleep for n milliseconds.
- */
-void
-sleep_milliseconds (unsigned int n)
-{
-#ifdef WIN32
-  Sleep (n);
-#else
-  struct timeval tv;
-  tv.tv_sec = n / 1000;
-  tv.tv_usec = (n % 1000) * 1000;
-  select (0, NULL, NULL, NULL, &tv);
-#endif
-}
-
-/*
- * Go to sleep indefinitely.
- */
-void
-sleep_until_signal (void)
-{
-#ifdef WIN32
-  ASSERT (0);
-#else
-  select (0, NULL, NULL, NULL, NULL);
-#endif
-}
-
  /* return true if filename can be opened for read */

 bool
 test_file (const char *filename)

src/openvpn/misc.c +1 -1
@@ -1198,7 +941,7 @@ test_file (const char *filename)
    bool ret = false;
    if (filename)
      {
-      FILE *fp = openvpn_fopen (filename, "r");
+      FILE *fp = platform_fopen (filename, "r");
        if (fp)
         {
           fclose (fp);
@@ -1246,7 +989,7 @@ create_temp_file (const char *directory, const char *prefix, struct gc_arena *gc
 
        /* Atomically create the file.  Errors out if the file already

          exists.  */
-      fd = openvpn_open (retfname, O_CREAT | O_EXCL | O_WRONLY, S_IRUSR | S_IWUSR);
+      fd = platform_open (retfname, O_CREAT | O_EXCL | O_WRONLY, S_IRUSR | S_IWUSR); if (fd != -1)
         {
           close (fd);

src/openvpn/misc.c +0 -16
@@ -1342,22 +1085,6 @@ gen_path (const char *directory, const char *filename, struct gc_arena *gc)
      return NULL;
  }
 
-/* delete a file, return true if succeeded */
-bool
-delete_file (const char *filename)
-{
-#if defined(WIN32)
-  struct gc_arena gc = gc_new ();
-  BOOL ret = DeleteFileW (wide_string (filename, &gc));
-  gc_free (&gc);
-  return (ret != 0);
-#elif defined(HAVE_UNLINK)
-  return (unlink (filename) == 0);
-#else
-  return false;
-#endif
-}
-

 bool
 absolute_pathname (const char *pathname)
 {

src/openvpn/misc.c +1 -1
@@ -1524,7 +1251,7 @@ get_user_pass_cr (struct user_pass *up,
 
           warn_if_group_others_accessible (auth_file);
 
-         fp = openvpn_fopen (auth_file, "r");
+         fp = platform_fopen (auth_file, "r");
           if (!fp)
             msg (M_ERR, "Error opening '%s' auth file: %s", prefix, auth_file);
 
src/openvpn/misc.h +1 -38
index 12a8f71..d4c8e33 100644
@@ -29,6 +29,7 @@
  #include "common.h"
  #include "integer.h"
  #include "buffer.h"
+#include "platform.h"
 
  /* socket descriptor passed by inetd/xinetd server to us */
  #define INETD_SOCKET_DESCRIPTOR 0
@@ -58,37 +59,6 @@ struct env_set {
    struct env_item *list;
  };
 
-/* Get/Set UID of process */
-
-struct user_state {
-#if defined(HAVE_GETPWNAM) && defined(HAVE_SETUID)
-  const char *username;
-  struct passwd *pw;
-#else
-  int dummy;
-#endif
-};
-
-bool get_user (const char *username, struct user_state *state);
-void set_user (const struct user_state *state);
-
-/* Get/Set GID of process */
-
-struct group_state {
-#if defined(HAVE_GETGRNAM) && defined(HAVE_SETGID)
-  const char *groupname;
-  struct group *gr;
-#else
-  int dummy;
-#endif
-};
-
-bool get_group (const char *groupname, struct group_state *state);
-void set_group (const struct group_state *state);
-
-void set_nice (int niceval);
-void do_chroot (const char *path);
-
  void run_up_down (const char *command,
                   const struct plugin_list *plugins,
                   int plugin_type,
@@ -111,9 +81,6 @@ struct pid_state {
 
  void get_pid_file (const char* filename, struct pid_state *state);
  void write_pid (const struct pid_state *state);
-unsigned int openvpn_getpid (void);
-
-void do_mlockall (bool print_msg); /* Disable paging */
 
  /* check file protections */
  void warn_if_group_others_accessible(const char* filename);
@@ -122,9 +89,6 @@ void warn_if_group_others_accessible(const char* filename);
  #define S_SCRIPT (1<<0)
  #define S_FATAL  (1<<1)
 
-/* interpret the status code returned by system()/execve() */
-bool system_ok(int);
-bool system_executed (int stat);
  const char *system_error_message (int, struct gc_arena *gc);
 
  /* wrapper around the execve() call */
@@ -133,7 +97,6 @@ int openvpn_execve (const struct argv *a, const struct env_set *es, const unsign
  bool openvpn_execve_check (const struct argv *a, const struct env_set *es, const unsigned int flags, const char *error_message);
  bool openvpn_execve_allowed (const unsigned int flags);
  int openvpn_system (const char *command, const struct env_set *es, unsigned int flags);
-int openvpn_access (const char *path, int mode);
 

 static inline bool
 openvpn_run_script (const struct argv *a, const struct env_set *es, const unsigned int flags, const char *hook)

src/openvpn/misc.h +0 -67
@@ -144,37 +107,6 @@ openvpn_run_script (const struct argv *a, const struct env_set *es, const unsign
    return openvpn_execve_check(a, es, flags | S_SCRIPT, msg);
  }
 
-#ifdef WIN32
-FILE * openvpn_fopen (const char *path, const char *mode);
-#else
-static inline FILE *
-openvpn_fopen (const char *path, const char *mode)
-{
-  return fopen (path, mode);
-}
-#endif
-
-#ifdef WIN32
-int openvpn_open (const char *path, int flags, int mode);
-#else
-static inline int
-openvpn_open (const char *path, int flags, mode_t mode)
-{
-  return open (path, flags, mode);
-}
-#endif
-
-#ifdef WIN32
-typedef struct _stat openvpn_stat_t;
-int openvpn_stat (const char *path, openvpn_stat_t *buf);
-#else
-typedef struct stat openvpn_stat_t;
-static inline int
-openvpn_stat (const char *path, openvpn_stat_t *buf)
-{
-  return stat (path, buf);
-}
-#endif
 
  #ifdef HAVE_STRERROR
  /* a thread-safe version of strerror */
@@ -184,9 +116,6 @@ const char* strerror_ts (int errnum, struct gc_arena *gc);
  /* Set standard file descriptors to /dev/null */
  void set_std_files_to_null (bool stdin_only);
 
-/* Wrapper for chdir library function */
-int openvpn_chdir (const char* dir);
-
  /* dup inetd/xinetd socket descriptor and save */
  extern int inetd_socket_descriptor;
  void save_inetd_socket_descriptor (void);
@@ -242,12 +171,6 @@ const char **make_extended_arg_array (char **p, struct gc_arena *gc);
  int count_netmask_bits(const char *);
  unsigned int count_bits(unsigned int );
 
-/* go to sleep for n milliseconds */
-void sleep_milliseconds (unsigned int n);
-
-/* go to sleep indefinitely */
-void sleep_until_signal (void);
-
  /* an analogue to the random() function, but use OpenSSL functions if available */
  #ifdef ENABLE_CRYPTO
  long int get_random(void);
@@ -264,9 +187,6 @@ const char *create_temp_file (const char *directory, const char *prefix, struct
  /* put a directory and filename together */
  const char *gen_path (const char *directory, const char *filename, struct gc_arena *gc);
 
-/* delete a file, return true if succeeded */
-bool delete_file (const char *filename);
-
  /* return true if pathname is absolute */
  bool absolute_pathname (const char *pathname);
 
@@ -448,28 +368,4 @@ void argv_printf_cat (struct argv *a, const char *format, ...)
  #endif
    ;
 
-/*
- * Extract UID or GID
- */
-
-static inline int
-user_state_uid (const struct user_state *s)
-{
-#if defined(HAVE_GETPWNAM) && defined(HAVE_SETUID)
-  if (s->pw)
-    return s->pw->pw_uid;
-#endif
-  return -1;
-}
-
-static inline int
-group_state_gid (const struct group_state *s)
-{
-#if defined(HAVE_GETGRNAM) && defined(HAVE_SETGID)
-  if (s->gr)
-    return s->gr->gr_gid;
-#endif
-  return -1;
-}
-
  #endif
src/openvpn/mstats.c +1 -1
index b4b864b..3be493c 100644
@@ -114,7 +114,7 @@ mstats_close(void)
        mmap_stats->state = MSTATS_EXPIRED;
        if (munmap((void *)mmap_stats, sizeof(struct mmap_stats)))
         msg (M_WARN | M_ERRNO, "mstats_close: munmap error");
-      delete_file(mmap_fn);
+      platform_unlink(mmap_fn);
        mmap_stats = NULL;
      }
  }
src/openvpn/multi.c +1 -1
index e79c6f1..9876b80 100644
@@ -1452,7 +1452,7 @@ multi_client_connect_post (struct multi_context *m,
                              option_types_found,
                              mi->context.c2.es);
 
-      if (!delete_file (dc_file))
+      if (!platform_unlink (dc_file))
         msg (D_MULTI_ERRORS, "MULTI: problem deleting temporary file: %s",
              dc_file);
 
src/openvpn/openvpn.h +2 -2
index b314885..0732d0f 100644
@@ -143,8 +143,8 @@ struct context_0
    /* workspace for --user/--group */
    bool uid_gid_specified;
    bool uid_gid_set;
-  struct user_state user_state;
-  struct group_state group_state;
+  struct platform_state_user platform_state_user;
+  struct platform_state_group platform_state_group;
  };
 
 
src/openvpn/openvpn.vcproj +0 -0
index 6c19621..4680e52 100644
@@ -347,6 +347,10 @@

                                >
                        </File>
                        <File
+                               RelativePath=".\platform.c"
+                               >
+                       </File>
+                       <File RelativePath=".\plugin.c" >
                        </File>

src/openvpn/openvpn.vcproj +0 -0
@@ -649,6 +653,10 @@

                                >
                        </File>
                        <File
+                               RelativePath=".\platform.h"
+                               >
+                       </File>
+                       <File RelativePath=".\plugin.h" >
                        </File>

src/openvpn/options.c +1 -1
index 258b060..bd83843 100644
@@ -920,7 +920,7 @@ setenv_settings (struct env_set *es, const struct options *o)
    setenv_int (es, "daemon", o->daemon);
    setenv_int (es, "daemon_log_redirect", o->log);
    setenv_unsigned (es, "daemon_start_time", time(NULL));
-  setenv_int (es, "daemon_pid", openvpn_getpid());
+  setenv_int (es, "daemon_pid", platform_getpid());
 
  #ifdef ENABLE_CONNECTION
    if (o->connection_list)
@@ -2640,18 +2640,18 @@ check_file_access(const int type, const char *file, const int mode, const char *

       char *fullpath = strdup(file);  /* POSIX dirname() implementaion may modify its arguments */ char *dirpath = dirname(fullpath);

-      if (openvpn_access (dirpath, mode|X_OK) != 0)
+      if (platform_access (dirpath, mode|X_OK) != 0) errcode = errno;
       free(fullpath);
     }

   /* Is the file itself accessible? */
-  if (!errcode && (type & CHKACC_FILE) && (openvpn_access (file, mode) != 0) )
+  if (!errcode && (type & CHKACC_FILE) && (platform_access (file, mode) != 0) ) errcode = errno;

   /* If the file exists and is accessible, is it writable? */
-  if (!errcode && (type & CHKACC_FILEXSTWR) && (openvpn_access (file, F_OK) == 0) )
-    if (openvpn_access (file, W_OK) != 0)
+  if (!errcode && (type & CHKACC_FILEXSTWR) && (platform_access (file, F_OK) == 0) )
+    if (platform_access (file, W_OK) != 0)
       errcode = errno;

   /* Scream if an error is found */

src/openvpn/options.c +0 -0
@@ -3755,7 +3755,7 @@ read_config_file (struct options *options,
        if (streq (file, "stdin"))
         fp = stdin;

       else
-       fp = openvpn_fopen (file, "r");
+       fp = platform_fopen (file, "r");
       if (fp)
        {
          line_num = 0;

src/openvpn/options.c +1 -1
@@ -4528,7 +4528,7 @@ add_option (struct options *options,
    else if (streq (p[0], "cd") && p[1])
      {
        VERIFY_PERMISSION (OPT_P_GENERAL);
-      if (openvpn_chdir (p[1]))
+      if (platform_chdir (p[1]))
         {
           msg (M_ERR, "cd to '%s' failed", p[1]);
           goto err;
src/openvpn/packet_id.c +1 -1
index 186f074..0102129 100644
@@ -368,7 +368,7 @@ packet_id_persist_load (struct packet_id_persist *p, const char *filename)
    if (!packet_id_persist_enabled (p))
      {
        /* open packet-id persist file for both read and write */
-      p->fd = openvpn_open (filename,
+      p->fd = platform_open (filename,
                              O_CREAT | O_RDWR | O_BINARY,
                              S_IRUSR | S_IWUSR);
        if (p->fd == -1)
src/openvpn/pf.c +0 -0
index 729792e..7ed1e70 100644
@@ -504,8 +504,8 @@ pf_check_reload (struct context *c)

       && c->c2.pf.filename
       && event_timeout_trigger (&c->c2.pf.reload, &c->c2.timeval, ETT_DEFAULT)) {
-      openvpn_stat_t s;
-      if (!openvpn_stat (c->c2.pf.filename, &s))
+      platform_stat_t s;
+      if (!platform_stat (c->c2.pf.filename, &s))
        {
          if (s.st_mtime > c->c2.pf.file_last_mod)
            {

src/openvpn/pf.c +1 -1
@@ -605,7 +605,7 @@ pf_destroy_context (struct pf_context *pfc)
  #ifdef PLUGIN_PF
    if (pfc->filename)
      {
-      delete_file (pfc->filename);
+      platform_unlink (pfc->filename);
        free (pfc->filename);
      }
  #endif
src/openvpn/platform.c new file +369 -0
new file mode 100644
index 0000000..c79f680
@@ -0,0 +1,369 @@
+/*
+ *  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. <[email protected]...>
+ *
+ *  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
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#elif defined(_MSC_VER)
+#include "config-msvc.h"
+#endif
+
+#include "syshead.h"
+
+#include "buffer.h"
+#include "error.h"
+#include "win32.h"
+
+#include "memdbg.h"
+
+#include "platform.h"
+
+/* Redefine the top level directory of the filesystem
+   to restrict access to files for security */
+void
+platform_chroot (const char *path)
+{
+  if (path)
+    {
+#ifdef HAVE_CHROOT
+      const char *top = "/";
+      if (chroot (path))
+       msg (M_ERR, "chroot to '%s' failed", path);
+      if (platform_chdir (top))
+       msg (M_ERR, "cd to '%s' failed", top);
+      msg (M_INFO, "chroot to '%s' and cd to '%s' succeeded", path, top);
+#else
+      msg (M_FATAL, "Sorry but I can't chroot to '%s' because this operating system doesn't appear to support the chroot() system call", path);
+#endif
+    }
+}
+
+/* Get/Set UID of process */
+
+bool
+platform_user_get (const char *username, struct platform_state_user *state)
+{
+  bool ret = false;
+  CLEAR (*state);
+  if (username)
+    {
+#if defined(HAVE_GETPWNAM) && defined(HAVE_SETUID)
+      state->pw = getpwnam (username);
+      if (!state->pw)
+       msg (M_ERR, "failed to find UID for user %s", username);
+      state->username = username;
+      ret = true;
+#else
+      msg (M_FATAL, "cannot get UID for user %s -- platform lacks getpwname() or setuid() system calls", username);
+#endif
+    }
+  return ret;
+}
+
+void
+platform_user_set (const struct platform_state_user *state)
+{
+#if defined(HAVE_GETPWNAM) && defined(HAVE_SETUID)
+  if (state->username && state->pw)
+    {
+      if (setuid (state->pw->pw_uid))
+       msg (M_ERR, "setuid('%s') failed", state->username);
+      msg (M_INFO, "UID set to %s", state->username);
+    }
+#endif
+}
+
+/* Get/Set GID of process */
+
+bool
+platform_group_get (const char *groupname, struct platform_state_group *state)
+{
+  bool ret = false;
+  CLEAR (*state);
+  if (groupname)
+    {
+#if defined(HAVE_GETGRNAM) && defined(HAVE_SETGID)
+      state->gr = getgrnam (groupname);
+      if (!state->gr)
+       msg (M_ERR, "failed to find GID for group %s", groupname);
+      state->groupname = groupname;
+      ret = true;
+#else
+      msg (M_FATAL, "cannot get GID for group %s -- platform lacks getgrnam() or setgid() system calls", groupname);
+#endif
+    }
+  return ret;
+}
+
+void
+platform_group_set (const struct platform_state_group *state)
+{
+#if defined(HAVE_GETGRNAM) && defined(HAVE_SETGID)
+  if (state->groupname && state->gr)
+    {
+      if (setgid (state->gr->gr_gid))
+       msg (M_ERR, "setgid('%s') failed", state->groupname);
+      msg (M_INFO, "GID set to %s", state->groupname);
+#ifdef HAVE_SETGROUPS
+      {
+        gid_t gr_list[1];
+       gr_list[0] = state->gr->gr_gid;
+       if (setgroups (1, gr_list))
+         msg (M_ERR, "setgroups('%s') failed", state->groupname);
+      }
+#endif
+    }
+#endif
+}
+
+/* Change process priority */
+void
+platform_nice (int niceval)
+{
+  if (niceval)
+    {
+#ifdef HAVE_NICE
+      errno = 0;
+      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
+      msg (M_WARN, "WARNING: nice %d failed (function not implemented)", niceval);
+#endif
+    }
+}
+
+/* Get current PID */
+unsigned int
+platform_getpid ()
+{
+#ifdef WIN32
+  return (unsigned int) GetCurrentProcessId ();
+#else
+#ifdef HAVE_GETPID
+  return (unsigned int) getpid ();
+#else
+  return 0;
+#endif
+#endif
+}
+
+/* Disable paging */
+void
+platform_mlockall(bool print_msg)
+{
+#ifdef HAVE_MLOCKALL
+  if (mlockall (MCL_CURRENT | MCL_FUTURE))
+    msg (M_WARN | M_ERRNO, "WARNING: mlockall call failed");
+  else if (print_msg)
+    msg (M_INFO, "mlockall call succeeded");
+#else
+  msg (M_WARN, "WARNING: mlockall call failed (function not implemented)");
+#endif
+}
+
+/*
+ * Wrapper for chdir library function
+ */
+int
+platform_chdir (const char* dir)
+{
+#ifdef HAVE_CHDIR
+#ifdef WIN32
+  int res;
+  struct gc_arena gc = gc_new ();
+  res = _wchdir (wide_string (dir, &gc));
+  gc_free (&gc);
+  return res;
+#else
+  return chdir (dir);
+#endif
+#else
+  return -1;
+#endif
+}
+
+/*
+ * convert system() return into a success/failure value
+ */
+bool
+platform_system_ok (int stat)
+{
+#ifdef WIN32
+  return stat == 0;
+#else
+  return stat != -1 && WIFEXITED (stat) && WEXITSTATUS (stat) == 0;
+#endif
+}
+
+/*
+ * did system() call execute the given command?
+ */
+bool
+platform_system_executed (int stat)
+{
+#ifdef WIN32
+  return stat != -1;
+#else
+  return stat != -1 && WEXITSTATUS (stat) != 127;
+#endif
+}
+
+int
+platform_access (const char *path, int mode)
+{
+#ifdef WIN32
+  struct gc_arena gc = gc_new ();
+  int ret = _waccess (wide_string (path, &gc), mode & ~X_OK);
+  gc_free (&gc);
+  return ret;
+#else
+  return access (path, mode);
+#endif
+}
+
+/*
+ * Go to sleep for n milliseconds.
+ */
+void
+platform_sleep_milliseconds (unsigned int n)
+{
+#ifdef WIN32
+  Sleep (n);
+#else
+  struct timeval tv;
+  tv.tv_sec = n / 1000;
+  tv.tv_usec = (n % 1000) * 1000;
+  select (0, NULL, NULL, NULL, &tv);
+#endif
+}
+
+/*
+ * Go to sleep indefinitely.
+ */
+void
+platform_sleep_until_signal (void)
+{
+#ifdef WIN32
+  ASSERT (0);
+#else
+  select (0, NULL, NULL, NULL, NULL);
+#endif
+}
+
+/* delete a file, return true if succeeded */
+bool
+platform_unlink (const char *filename)
+{
+#if defined(WIN32)
+  struct gc_arena gc = gc_new ();
+  BOOL ret = DeleteFileW (wide_string (filename, &gc));
+  gc_free (&gc);
+  return (ret != 0);
+#elif defined(HAVE_UNLINK)
+  return (unlink (filename) == 0);
+#else
+  return false;
+#endif
+}
+
+int platform_system(const char *command) {
+  int ret;
+#ifdef WIN32
+  struct gc_arena gc = gc_new ();
+  ret = _wsystem (wide_string (command, &gc));
+  gc_free (&gc);
+#else
+  ret = system (command);
+#endif
+  return ret;
+}
+
+int platform_putenv(char *string)
+{
+  int status;
+#if defined(WIN32)
+  struct gc_arena gc = gc_new ();
+  char *s = string_alloc(string, &gc);
+  char *value = strchr(s, '=');
+  if (value!=NULL)
+    {
+      *value = '\0';
+      value++;
+      if (*value == '\0')
+        value = NULL;
+    }
+
+  status = SetEnvironmentVariableW (wide_string (s, &gc),
+      wide_string (value, &gc)) ? 1: 0;
+  gc_free (&gc);
+#elif defined(HAVE_PUTENV)
+  void manage_env (char *str); /* TODO: Resolve properly */
+  status = putenv (string);
+  if (!status)
+    manage_env (string);
+#endif
+
+  return status;
+}
+
+FILE *
+platform_fopen (const char *path, const char *mode)
+{
+#ifdef WIN32
+  struct gc_arena gc = gc_new ();
+  FILE *f = _wfopen (wide_string (path, &gc), wide_string (mode, &gc));
+  gc_free (&gc);
+  return f;
+#else
+  return fopen(path, mode);
+#endif
+}
+
+int
+platform_open (const char *path, int flags, int mode)
+{
+#ifdef WIN32
+  struct gc_arena gc = gc_new ();
+  int fd = _wopen (wide_string (path, &gc), flags, mode);
+  gc_free (&gc);
+  return fd;
+#else
+  return open(path, flags, mode);
+#endif
+}
+
+int
+platform_stat (const char *path, platform_stat_t *buf)
+{
+#ifdef WIN32
+  struct gc_arena gc = gc_new ();
+  int res = _wstat (wide_string (path, &gc), buf);
+  gc_free (&gc);
+  return res;
+#else
+  return stat(path, buf);
+#endif
+}
+
src/openvpn/platform.h new file +142 -0
new file mode 100644
index 0000000..7bd2067
@@ -0,0 +1,142 @@
+/*
+ *  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. <[email protected]...>
+ *
+ *  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
+ */
+
+#ifndef PLATFORM_H
+#define PLATFORM_H
+
+#ifdef HAVE_SYS_TYPES_H
+#include <sys/types.h>
+#endif
+
+#ifdef HAVE_SYS_STAT_H
+#include <sys/stat.h>
+#endif
+
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+
+#ifdef HAVE_PWD_H
+#include <pwd.h>
+#endif
+
+#ifdef HAVE_GRP_H
+#include <grp.h>
+#endif
+
+#ifdef HAVE_STDIO_H
+#include <stdio.h>
+#endif
+
+#include "basic.h"
+
+/* Get/Set UID of process */
+
+struct platform_state_user {
+#if defined(HAVE_GETPWNAM) && defined(HAVE_SETUID)
+  const char *username;
+  struct passwd *pw;
+#else
+  int dummy;
+#endif
+};
+
+/* Get/Set GID of process */
+
+struct platform_state_group {
+#if defined(HAVE_GETGRNAM) && defined(HAVE_SETGID)
+  const char *groupname;
+  struct group *gr;
+#else
+  int dummy;
+#endif
+};
+
+bool platform_user_get (const char *username, struct platform_state_user *state);
+void platform_user_set (const struct platform_state_user *state);
+
+bool platform_group_get (const char *groupname, struct platform_state_group *state);
+void platform_group_set (const struct platform_state_group *state);
+
+/*
+ * Extract UID or GID
+ */
+
+static inline int
+platform_state_user_uid (const struct platform_state_user *s)
+{
+#if defined(HAVE_GETPWNAM) && defined(HAVE_SETUID)
+  if (s->pw)
+    return s->pw->pw_uid;
+#endif
+  return -1;
+}
+
+static inline int
+platform_state_group_gid (const struct platform_state_group *s)
+{
+#if defined(HAVE_GETGRNAM) && defined(HAVE_SETGID)
+  if (s->gr)
+    return s->gr->gr_gid;
+#endif
+  return -1;
+}
+
+void platform_chroot (const char *path);
+
+void platform_nice (int niceval);
+
+unsigned int platform_getpid (void);
+
+void platform_mlockall (bool print_msg); /* Disable paging */
+
+int platform_chdir (const char* dir);
+
+/* interpret the status code returned by system()/execve() */
+bool platform_system_ok (int stat);
+bool platform_system_executed (int stat);
+int platform_system(const char *command);
+
+int platform_access (const char *path, int mode);
+
+void platform_sleep_milliseconds (unsigned int n);
+
+void platform_sleep_until_signal (void);
+
+/* delete a file, return true if succeeded */
+bool platform_unlink (const char *filename);
+
+int platform_putenv (char *string);
+
+FILE *platform_fopen (const char *path, const char *mode);
+int platform_open (const char *path, int flags, int mode);
+
+#ifdef WIN32
+typedef struct _stat platform_stat_t;
+#else
+typedef struct stat platform_stat_t;
+#endif
+int platform_stat (const char *path, platform_stat_t *buf);
+
+#endif
src/openvpn/ps.c +1 -1
index a4e50e8..5d056ee 100644
@@ -337,7 +337,7 @@ journal_add (const char *journal_dir, struct proxy_connection *pc, struct proxy_
        check_malloc_return (jfn);
        openvpn_snprintf (jfn, fnlen, "%s/%s", journal_dir, t);
        dmsg (D_PS_PROXY_DEBUG, "PORT SHARE PROXY: client origin %s -> %s", jfn, f);
-      fd = openvpn_open (jfn, O_CREAT | O_TRUNC | O_WRONLY, S_IRUSR | S_IWUSR | S_IRGRP);
+      fd = platform_open (jfn, O_CREAT | O_TRUNC | O_WRONLY, S_IRUSR | S_IWUSR | S_IRGRP);
        if (fd != -1)
         {
           write(fd, f, strlen(f));
src/openvpn/ssl_openssl.c +1 -1
index 6a60cb5..d712c66 100644
@@ -280,7 +280,7 @@ tls_ctx_load_pkcs12(struct tls_root_ctx *ctx, const char *pkcs12_file,
  #endif
      {
        /* Load the PKCS #12 file */
-      if (!(fp = openvpn_fopen(pkcs12_file, "rb")))
+      if (!(fp = platform_fopen(pkcs12_file, "rb")))
         msg(M_SSLERR, "Error opening file %s", pkcs12_file);
        p12 = d2i_PKCS12_fp(fp, NULL);
        fclose(fp);
src/openvpn/ssl_verify.c +3 -3
index 51457f8..e837e39 100644
@@ -517,7 +517,7 @@ verify_cert_call_command(const char *verify_command, struct env_set *es,
    if (verify_export_cert)
      {
         if (tmp_file)
-          delete_file(tmp_file);
+          platform_unlink(tmp_file);
      }
 
    gc_free(&gc);
@@ -551,7 +551,7 @@ verify_check_crl_dir(const char *crl_dir, openvpn_x509_cert_t *cert)
        x509_free_serial(serial);
        return FAILURE;
      }
-  fd = openvpn_open (fn, O_RDONLY, 0);
+  fd = platform_open (fn, O_RDONLY, 0);
    if (fd >= 0)
      {
        msg (D_HANDSHAKE, "VERIFY CRL: certificate serial number %s is revoked", serial);
@@ -735,7 +735,7 @@ key_state_rm_auth_control_file (struct key_state *ks)
  {
    if (ks && ks->auth_control_file)
      {
-      delete_file (ks->auth_control_file);
+      platform_unlink (ks->auth_control_file);
        free (ks->auth_control_file);
        ks->auth_control_file = NULL;
      }
@@ -987,7 +987,7 @@ verify_user_pass_script (struct tls_session *session, const struct user_pass *up
 

  done:
   if (tmp_file && strlen (tmp_file) > 0)
-    delete_file (tmp_file);
+    platform_unlink (tmp_file);

   argv_reset (&argv);
   gc_free (&gc);

src/openvpn/status.c +0 -0
index 0be5e4c..5f9ab9e 100644
@@ -78,17 +78,17 @@ status_open (const char *filename,
            switch (so->flags)
              {

             case STATUS_OUTPUT_WRITE:
-              so->fd = openvpn_open (filename,
+              so->fd = platform_open (filename,
                                      O_CREAT | O_TRUNC | O_WRONLY, S_IRUSR | S_IWUSR); break;
             case STATUS_OUTPUT_READ:
-              so->fd = openvpn_open (filename,
+              so->fd = platform_open (filename, O_RDONLY,
                                      S_IRUSR | S_IWUSR); break;
             case STATUS_OUTPUT_READ|STATUS_OUTPUT_WRITE:
-              so->fd = openvpn_open (filename,
+              so->fd = platform_open (filename,
                                      O_CREAT | O_RDWR, S_IRUSR | S_IWUSR); break;

src/openvpn/tun.c +2 -2
index abc6a99..e6a7bc8 100644
@@ -1545,22 +1545,22 @@ tuncfg (const char *dev, const char *dev_type, const char *dev_node, int persist
      msg (M_ERR, "Cannot ioctl TUNSETPERSIST(%d) %s", persist_mode, dev);
    if (username != NULL)
      {
-      struct user_state user_state;
+      struct platform_state_user platform_state_user;
 
-      if (!get_user (username, &user_state))
+      if (!platform_user_get (username, &platform_state_user))
          msg (M_ERR, "Cannot get user entry for %s", username);

       else
-        if (ioctl (tt->fd, TUNSETOWNER, user_state.pw->pw_uid) < 0)
+        if (ioctl (tt->fd, TUNSETOWNER, platform_state_user.pw->pw_uid) < 0) msg (M_ERR, "Cannot ioctl TUNSETOWNER(%s) %s", username, dev); }
   if (groupname != NULL)
     {
-      struct group_state group_state;
+      struct platform_state_group platform_state_group;

-      if (!get_group (groupname, &group_state))
+      if (!platform_group_get (groupname, &platform_state_group)) msg (M_ERR, "Cannot get group entry for %s", groupname); else
-        if (ioctl (tt->fd, TUNSETGROUP, group_state.gr->gr_gid) < 0)
+        if (ioctl (tt->fd, TUNSETGROUP, platform_state_group.gr->gr_gid) < 0) msg (M_ERR, "Cannot ioctl TUNSETOWNER(%s) %s", groupname, dev); }
   close_tun (tt);

src/openvpn/win32.c +0 -28
index e94343b..e8e69dc 100644
@@ -976,33 +976,6 @@ wide_string (const char* utf8, struct gc_arena *gc)
    return ucs16;
  }
 
-FILE *
-openvpn_fopen (const char *path, const char *mode)
-{
-  struct gc_arena gc = gc_new ();
-  FILE *f = _wfopen (wide_string (path, &gc), wide_string (mode, &gc));
-  gc_free (&gc);
-  return f;
-}
-
-int
-openvpn_open (const char *path, int flags, int mode)
-{
-  struct gc_arena gc = gc_new ();
-  int fd = _wopen (wide_string (path, &gc), flags, mode);
-  gc_free (&gc);
-  return fd;
-}
-
-int
-openvpn_stat (const char *path, openvpn_stat_t *buf)
-{
-  struct gc_arena gc = gc_new ();
-  int res = _wstat (wide_string (path, &gc), buf);
-  gc_free (&gc);
-  return res;
-}
-
  /*
   * call ourself in another process
   */
--

1.7.3.4

------------------------------------------------------------------------------
Virtualization & Cloud Management Using Capacity Planning Cloud computing makes use of virtualization - but cloud computing also focuses on allowing computing to be delivered as a service.
http://www.accelacomm.com/jaw/sfnl/114/51521223/
_______________________________________________
Openvpn-devel mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel

#94 lore raw

Re: [Openvpn-devel] [PATCH 47/52] build: move inet_ntop(), inet_pton() emulation into compat

In reply to Samuli Seppänen

Not exactly... windows has this in Vista and above.
As long as we need to support XP we need to implement replacement functionality.

2012/3/8 Samuli Seppänen <[email protected]...>:

Quoted 384 lines

Windows has this functionality, but not under the same function names as UNIX. So thse two are just wrappers around the Windows-specific functionality. In any case, I think it makes sense to move inet_pton and inet_ntop under src/compat. The actual code changes seem fairly trivial.

ACK.

--
Samuli Seppänen
Community Manager
OpenVPN Technologies, Inc

irc freenode net: mattock

PS. These links should cover the basic idea, in case somebody is interested:

<http://us.generation-nt.com/inet-pton-windows-convert-address-presentation-format-network-format-help-37036482.html>
<http://pubs.opengroup.org/onlinepubs/009604599/functions/inet_ntop.html>

Quoted 363 lines

---
 configure.ac  I recall many issues with inet_ntop and inet_pton.

                |    2 +-
 src/compat/Makefile.am        |    4 ++- src/compat/compat-inet_ntop.c |   76 +++++++++++++++++++++++++++++++++++++++ src/compat/compat-inet_pton.c |   79 +++++++++++++++++++++++++++++++++++++++++ src/compat/compat.h           |   17 ++++++++- src/compat/compat.vcproj      |    8 ++++
 src/openvpn/socket.c          |   55 ---------------------------- src/openvpn/win32.h           |    6 ---

 8 files changed, 183 insertions(+), 64 deletions(-)

 create mode 100644 src/compat/compat-inet_ntop.c
 create mode 100644 src/compat/compat-inet_pton.c

configure.ac +1 -1
index dc138ba..d53a74a 100644
@@ -522,7 +522,7 @@ AC_CHECK_FUNCS([ \
         chsize ftruncate execve getpeereid umask basename dirname access \
         epoll_create \
  ])
-AC_CHECK_FUNCS([sendmsg recvmsg])
+AC_CHECK_FUNCS([sendmsg recvmsg inet_ntop inet_pton])

 AC_CHECK_FUNCS(
        [res_init],
        ,

src/compat/Makefile.am +3 -1
index c8a92ce..91b7f40 100644
@@ -22,4 +22,6 @@ libcompat_la_SOURCES = \
         compat-dirname.c \
         compat-basename.c \
         compat-gettimeofday.c \
-       compat-daemon.c
+       compat-daemon.c \
+       compat-inet_ntop.c \
+       compat-inet_pton.c
src/compat/compat-inet_ntop.c new file +76 -0
new file mode 100644
index 0000000..0d52142
@@ -0,0 +1,76 @@
+/*
+ *  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) 2011 - David Sommerseth <[email protected]...>
+ *
+ *  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
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#elif defined(_MSC_VER)
+#include "config-msvc.h"
+#endif
+
+#ifndef HAVE_INET_NTOP
+
+#include "compat.h"
+
+#ifdef WIN32
+
+#include <windows.h>
+
+/*
+ * inet_ntop() and inet_pton() wrap-implementations using
+ * WSAAddressToString() and WSAStringToAddress() functions
+ *
+ * this is needed as long as we support running OpenVPN on WinXP
+ */
+
+const char *
+inet_ntop(int af, const void *src, char *dst, socklen_t size)
+{
+  struct sockaddr_storage ss;
+  unsigned long s = size;
+
+  ZeroMemory(&ss, sizeof(ss));
+  ss.ss_family = af;
+
+  switch(af) {
+    case AF_INET:
+      ((struct sockaddr_in *)&ss)->sin_addr = *(struct in_addr *)src;
+      break;
+    case AF_INET6:
+      ((struct sockaddr_in6 *)&ss)->sin6_addr = *(struct in6_addr *)src;
+      break;
+    default:
+      return NULL;
+  }
+  /* cannot direclty use &size because of strict aliasing rules */
+  return (WSAAddressToString((struct sockaddr *)&ss, sizeof(ss), NULL, dst, &s) == 0)?
+          dst : NULL;
+}
+
+#else
+
+#error no emulation for inet_ntop
+
+#endif
+
+#endif
src/compat/compat-inet_pton.c new file +79 -0
new file mode 100644
index 0000000..cdc8d4b
@@ -0,0 +1,79 @@
+/*
+ *  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) 2011 - David Sommerseth <[email protected]...>
+ *
+ *  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
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#elif defined(_MSC_VER)
+#include "config-msvc.h"
+#endif
+
+#ifndef HAVE_INET_PTON
+
+#include "compat.h"
+
+#ifdef WIN32
+
+#include <windows.h>
+#include <string.h>
+
+/*
+ * inet_ntop() and inet_pton() wrap-implementations using
+ * WSAAddressToString() and WSAStringToAddress() functions
+ *
+ * this is needed as long as we support running OpenVPN on WinXP
+ */
+
+
+int
+inet_pton(int af, const char *src, void *dst)
+{
+  struct sockaddr_storage ss;
+  int size = sizeof(ss);
+  char src_copy[INET6_ADDRSTRLEN+1];
+
+  ZeroMemory(&ss, sizeof(ss));
+  /* stupid non-const API */
+  strncpy (src_copy, src, INET6_ADDRSTRLEN+1);
+  src_copy[INET6_ADDRSTRLEN] = 0;
+
+  if (WSAStringToAddress(src_copy, af, NULL, (struct sockaddr *)&ss, &size) == 0) {
+    switch(af) {
+      case AF_INET:
+       *(struct in_addr *)dst = ((struct sockaddr_in *)&ss)->sin_addr;
+       return 1;
+      case AF_INET6:
+       *(struct in6_addr *)dst = ((struct sockaddr_in6 *)&ss)->sin6_addr;
+       return 1;
+    }
+  }
+  return 0;
+}
+
+#else
+
+#error no emulation for inet_ntop
+
+#endif
+
+#endif
src/compat/compat.h +16 -1
index e9d51b8..021573e 100644
@@ -26,14 +26,21 @@
  #define COMPAT_H
 
  #ifdef HAVE_WINSOCK2_H
-/* timeval */
  #include <winsock2.h>
  #endif
 
+#ifdef HAVE_WS2TCPIP_H
+#include <ws2tcpip.h>
+#endif
+
  #ifdef HAVE_SYS_TIME_H
  #include <sys/time.h>
  #endif
 
+#ifdef HAVE_SYS_SOCKET_H
+#include <sys/socket.h>
+#endif
+
  #ifndef HAVE_DIRNAME
  char * dirname(char *str);
  #endif /* HAVE_DIRNAME */
@@ -50,4 +57,12 @@ int gettimeofday (struct timeval *tv, void *tz);
  int daemon(int nochdir, int noclose);
  #endif
 
+#ifndef HAVE_INET_NTOP
+const char * inet_ntop(int af, const void *src, char *dst, socklen_t size);
+#endif
+
+#ifndef HAVE_INET_PTON
+int inet_pton(int af, const char *src, void *dst);
+#endif
+
  #endif /* COMPAT_H */
src/compat/compat.vcproj +0 -0
index efdecb4..43fc0c2 100644
@@ -163,6 +163,14 @@

                                >
                        </File>
                        <File
+                               RelativePath=".\compat-inet_ntop.c"
+                               >
+                       </File>
+                       <File
+                               RelativePath=".\compat-inet_pton.c"
+                               >
+                       </File>
+                       <File RelativePath=".\compat-daemon.c" >
                        </File>

src/openvpn/socket.c +0 -55
index e1526ff..608213b 100644
@@ -3086,61 +3086,6 @@ link_socket_write_udp_posix_sendmsg (struct link_socket *sock,
 
  #ifdef WIN32
 
-/*
- * inet_ntop() and inet_pton() wrap-implementations using
- * WSAAddressToString() and WSAStringToAddress() functions
- *
- * this is needed as long as we support running OpenVPN on WinXP
- */
-
-const char *
-openvpn_inet_ntop(int af, const void *src, char *dst, socklen_t size)
-{
-  struct sockaddr_storage ss;
-  unsigned long s = size;
-
-  CLEAR(ss);
-  ss.ss_family = af;
-
-  switch(af) {
-    case AF_INET:
-      ((struct sockaddr_in *)&ss)->sin_addr = *(struct in_addr *)src;
-      break;
-    case AF_INET6:
-      ((struct sockaddr_in6 *)&ss)->sin6_addr = *(struct in6_addr *)src;
-      break;
-    default:
-      ASSERT (0);
-  }
-  /* cannot direclty use &size because of strict aliasing rules */
-  return (WSAAddressToString((struct sockaddr *)&ss, sizeof(ss), NULL, dst, &s) == 0)?
-          dst : NULL;
-}
-
-int
-openvpn_inet_pton(int af, const char *src, void *dst)
-{
-  struct sockaddr_storage ss;
-  int size = sizeof(ss);
-  char src_copy[INET6_ADDRSTRLEN+1];
-
-  CLEAR(ss);
-  /* stupid non-const API */
-  strncpynt(src_copy, src, INET6_ADDRSTRLEN+1);
-
-  if (WSAStringToAddress(src_copy, af, NULL, (struct sockaddr *)&ss, &size) == 0) {
-    switch(af) {
-      case AF_INET:
-       *(struct in_addr *)dst = ((struct sockaddr_in *)&ss)->sin_addr;
-       return 1;
-      case AF_INET6:
-       *(struct in6_addr *)dst = ((struct sockaddr_in6 *)&ss)->sin6_addr;
-       return 1;
-    }
-  }
-  return 0;
-}
-

 int
 socket_recv_queue (struct link_socket *sock, int maxsize) {

src/openvpn/win32.h +0 -7
index 09f897a..d87e987 100644
@@ -266,12 +266,6 @@ char *get_win_sys_path (void);
  /* call self in a subprocess */
  void fork_to_self (const char *cmdline);
 
-const char *openvpn_inet_ntop(int af, const void *src,
-                              char *dst, socklen_t size);
-int openvpn_inet_pton(int af, const char *src, void *dst);
-#define inet_ntop(af,src,dst,size) openvpn_inet_ntop(af,src,dst,size)
-#define inet_pton(af,src,dst)      openvpn_inet_pton(af,src,dst)
-
  /* Find temporary directory */
  const char *win_get_tempdir();
 
--

1.7.3.4

------------------------------------------------------------------------------
Virtualization & Cloud Management Using Capacity Planning Cloud computing makes use of virtualization - but cloud computing also focuses on allowing computing to be delivered as a service.
http://www.accelacomm.com/jaw/sfnl/114/51521223/
_______________________________________________
Openvpn-devel mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel

#82 lore raw

Re: [Openvpn-devel] [PATCH 41/52] build: autoconf: update defaults for options

In reply to Samuli Seppänen

Yes. You cannot put '[' or ']' in m4.

2012/3/8 Samuli Seppänen <[email protected]...>:

Quoted 262 lines

I'd rather not RTFM... could somebody explain to me what the funky "@<:@default=no@:>@" thing exactly does? Does it just add the default "enabled/disabled" value to the help strings?

If so it's an ACK.

--
Samuli Seppänen
Community Manager
OpenVPN Technologies, Inc

irc freenode net: mattock

Quoted 246 lines

---
 configure.ac |   56 ++++++++++++++++++++++++++++----------------------------

 1 files changed, 28 insertions(+), 28 deletions(-)
configure.ac +0 -0
index 57d294d..9ffcc68 100644
@@ -41,195 +41,195 @@ AC_USE_SYSTEM_EXTENSIONS
 

 AC_ARG_ENABLE(
        [lzo],
-       [AS_HELP_STRING([--enable-lzo], [enable LZO compression support])],
+       [AS_HELP_STRING([--enable-lzo], [enable LZO compression support @<:@default=no@:>@])], ,
        [enable_lzo="no"]
 )

 AC_ARG_ENABLE(
        [lzo-stub],
-       [AS_HELP_STRING([--enable-lzo-stub], [don't compile LZO compression support but still allow limited interoperability with LZO-enabled peers])],
+       [AS_HELP_STRING([--enable-lzo-stub], [don't compile LZO compression support but still allow limited interoperability with LZO-enabled peers @<:@default=no@:>@])], ,
        [enable_lzo_stub="no"]
 )

 AC_ARG_ENABLE(
        [crypto],
-       [AS_HELP_STRING([--disable-crypto], [disable crypto support])],
+       [AS_HELP_STRING([--disable-crypto], [disable crypto support @<:@default=yes@:>@])], ,
        [enable_crypto="yes"]
 )

 AC_ARG_ENABLE(
        [ssl],
-       [AS_HELP_STRING([--disable-ssl], [disable SSL support for TLS-based key exchange])],
+       [AS_HELP_STRING([--disable-ssl], [disable SSL support for TLS-based key exchange @<:@default=yes@:>@])], ,
        [enable_ssl="yes"]
 )

 AC_ARG_ENABLE(
        [x509-alt-username],
-       [AS_HELP_STRING([--enable-x509-alt-username], [enable the --x509-username-field feature])],
+       [AS_HELP_STRING([--enable-x509-alt-username], [enable the --x509-username-field feature @<:@default=no@:>@])], ,
        [enable_x509_alt_username="no"]
 )

 AC_ARG_ENABLE(
        [multi],
-       [AS_HELP_STRING([--disable-multi], [disable client/server support (--mode server + client mode)])],
+       [AS_HELP_STRING([--disable-multi], [disable client/server support (--mode server + client mode) @<:@default=yes@:>@])], ,
        [enable_multi="yes"]
 )

 AC_ARG_ENABLE(
        [server],
-       [AS_HELP_STRING([--disable-server], [disable server support only (but retain client support)])],
+       [AS_HELP_STRING([--disable-server], [disable server support only (but retain client support) @<:@default=yes@:>@])], ,
        [enable_server="yes"]
 )

 AC_ARG_ENABLE(
        [plugins],
-       [AS_HELP_STRING([--disable-plugins], [disable plug-in support])],
+       [AS_HELP_STRING([--disable-plugins], [disable plug-in support @<:@default=yes@:>@])], ,
        [enable_plugins="yes"]
 )

 AC_ARG_ENABLE(
        [eurephia],
-       [AS_HELP_STRING([--disable-eurephia], [disable support for the eurephia plug-in])],
+       [AS_HELP_STRING([--disable-eurephia], [disable support for the eurephia plug-in @<:@default=yes@:>@])], ,
        [enable_eurephia="yes"]
 )

 AC_ARG_ENABLE(
        [management],
-       [AS_HELP_STRING([--disable-management], [disable management server support])],
+       [AS_HELP_STRING([--disable-management], [disable management server support @<:@default=yes@:>@])], ,
        [enable_management="yes"]
 )

 AC_ARG_ENABLE(
        [pkcs11],
-       [AS_HELP_STRING([--enable-pkcs11], [enable pkcs11 support])],
+       [AS_HELP_STRING([--enable-pkcs11], [enable pkcs11 support @<:@default=no@:>@])], ,
        [enable_pkcs11="no"]
 )

 AC_ARG_ENABLE(
        [socks],
-       [AS_HELP_STRING([--disable-socks], [disable Socks support])],
+       [AS_HELP_STRING([--disable-socks], [disable Socks support @<:@default=yes@:>@])], ,
        [enable_socks="yes"]
 )

 AC_ARG_ENABLE(
        [http-proxy],
-       [AS_HELP_STRING([--disable-http-proxy], [disable HTTP proxy support])],
+       [AS_HELP_STRING([--disable-http-proxy], [disable HTTP proxy support @<:@default=yes@:>@])], ,
        [enable_http_proxy="yes"]
 )

 AC_ARG_ENABLE(
        [fragment],
-       [AS_HELP_STRING([--disable-fragment], [disable internal fragmentation support (--fragment)])],
+       [AS_HELP_STRING([--disable-fragment], [disable internal fragmentation support (--fragment) @<:@default=yes@:>@])], ,
        [enable_fragment="yes"]
 )

 AC_ARG_ENABLE(
        [multihome],
-       [AS_HELP_STRING([--disable-multihome], [disable multi-homed UDP server support (--multihome)])],
+       [AS_HELP_STRING([--disable-multihome], [disable multi-homed UDP server support (--multihome) @<:@default=yes@:>@])], ,
        [enable_multihome="yes"]
 )

 AC_ARG_ENABLE(
        [port-share],
-       [AS_HELP_STRING([--disable-port-share], [disable TCP server port-share support (--port-share)])],
+       [AS_HELP_STRING([--disable-port-share], [disable TCP server port-share support (--port-share) @<:@default=yes@:>@])], ,
        [enable_port_share="yes"]
 )

 AC_ARG_ENABLE(
        [debug],
-       [AS_HELP_STRING([--disable-debug], [disable debugging support (disable gremlin and verb 7+ messages)])],
+       [AS_HELP_STRING([--disable-debug], [disable debugging support (disable gremlin and verb 7+ messages) @<:@default=yes@:>@])], ,
        [enable_debug="yes"]
 )

 AC_ARG_ENABLE(
        [small],
-       [AS_HELP_STRING([--enable-small], [enable smaller executable size (disable OCC, usage message, and verb 4 parm list)])],
+       [AS_HELP_STRING([--enable-small], [enable smaller executable size (disable OCC, usage message, and verb 4 parm list) @<:@default=yes@:>@])], ,
        [enable_small="no"]
 )

 AC_ARG_ENABLE(
        [password-save],
-       [AS_HELP_STRING([--enable-password-save], [allow --askpass and --auth-user-pass passwords to be read from a file])],
+       [AS_HELP_STRING([--enable-password-save], [allow --askpass and --auth-user-pass passwords to be read from a file @<:@default=yes@:>@])], [enable_password_save="no"]
 )

 AC_ARG_ENABLE(
        [iproute2],
-       [AS_HELP_STRING([--enable-iproute2], [enable support for iproute2])],
+       [AS_HELP_STRING([--enable-iproute2], [enable support for iproute2 @<:@default=no@:>@])], ,
        [enable_iproute2="no"]
 )

 AC_ARG_ENABLE(
        [def-auth],
-       [AS_HELP_STRING([--disable-def-auth], [disable deferred authentication])],
+       [AS_HELP_STRING([--disable-def-auth], [disable deferred authentication @<:@default=yes@:>@])], ,
        [enable_def_auth="yes"]
 )

 AC_ARG_ENABLE(
        [pf],
-       [AS_HELP_STRING([--disable-pf], [disable internal packet filter])],
+       [AS_HELP_STRING([--disable-pf], [disable internal packet filter @<:@default=yes@:>@])], ,
        [enable_pf="yes"]
 )

 AC_ARG_ENABLE(
        [strict],
-       [AS_HELP_STRING([--enable-strict], [enable strict compiler warnings (debugging option)])],
+       [AS_HELP_STRING([--enable-strict], [enable strict compiler warnings (debugging option) @<:@default=no@:>@])], ,
        [enable_strict="no"]
 )

 AC_ARG_ENABLE(
        [pedantic],
-       [AS_HELP_STRING([--enable-pedantic], [enable pedantic compiler warnings, will not generate a working executable (debugging option)])],
+       [AS_HELP_STRING([--enable-pedantic], [enable pedantic compiler warnings, will not generate a working executable (debugging option) @<:@default=no@:>@])], ,
        [enable_pedantic="no"]
 )

 AC_ARG_ENABLE(
        [strict-options],
-       [AS_HELP_STRING([--enable-strict-options], [enable strict options check between peers (debugging option)])],
+       [AS_HELP_STRING([--enable-strict-options], [enable strict options check between peers (debugging option) @<:@default=no@:>@])], ,
        [enable_strict_options="no"]
 )

 AC_ARG_ENABLE(
        [selinux],
-       [AS_HELP_STRING([--enable-selinux], [enable SELinux support])],
+       [AS_HELP_STRING([--enable-selinux], [enable SELinux support @<:@default=no@:>@])], ,
        [enable_selinux="no"]
 )

 AC_ARG_ENABLE(
        [systemd],
-       [AS_HELP_STRING([--enable-systemd], [enable systemd suppport])],
+       [AS_HELP_STRING([--enable-systemd], [enable systemd suppport @<:@default=no@:>@])], ,
        [enable_systemd="no"]
 )

 AC_ARG_WITH(
        [mem-check],
-       [AS_HELP_STRING([--with-mem-check=TYPE], [build with debug memory checking, TYPE=dmalloc|valgrind|ssl])],
+       [AS_HELP_STRING([--with-mem-check=TYPE], [build with debug memory checking, TYPE=no|dmalloc|valgrind|ssl @<:@default=no@:>@])], [
                case "${withval}" in
                        dmalloc|valgrind|ssl|no) ;;
--
1.7.3.4

------------------------------------------------------------------------------
Virtualization & Cloud Management Using Capacity Planning Cloud computing makes use of virtualization - but cloud computing also focuses on allowing computing to be delivered as a service.
http://www.accelacomm.com/jaw/sfnl/114/51521223/
_______________________________________________
Openvpn-devel mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel

#64 lore raw

Re: [Openvpn-devel] [PATCH 35/52] build: proper selinux detection and usage

In reply to Samuli Seppänen

I wrote this in the introduction of the patch set.

There are two approaches to detecting dependencies:

1. Detect all compile time dependences- you detect headers and libraries, this is probably the safest way to go, but makes the code very complex.

2. Detect library only - you assume that if library is present, the functionality exists, this is what important... no need to check for header, most probably this exists as well. This makes the code simpler, in the risk of compile failure if header is missing.

In all project I wrote build for (opensc, uswsusp, ntfs3g, ecryptfs) we took the 2nd approach, and it is fine.

Alon.

2012/3/8 Samuli Seppänen <[email protected]...>:

Quoted 187 lines

Looks like a cleaner implementation than the earlier one. I take it AC_CHECK_HEADER is not anymore needed to detect selinux.h, but why exactly?

Besides that I give this one an ACK.

--
Samuli Seppänen
Community Manager
OpenVPN Technologies, Inc

irc freenode net: mattock

Quoted 175 lines

---
 configure.ac            |   35 +++++++++++++++-------------------- src/openvpn/Makefile.am |    1 +
 src/openvpn/init.c      |    4 ++--

 src/openvpn/options.c   |    6 +++---
 src/openvpn/options.h   |    2 +-
 src/openvpn/syshead.h   |    2 +-
 6 files changed, 23 insertions(+), 27 deletions(-)
configure.ac +0 -0
index 98615c6..2388f17 100644
@@ -215,7 +215,7 @@ AC_ARG_ENABLE(
 

 AC_ARG_ENABLE(
      [selinux],
-     [AS_HELP_STRING([--disable-selinux], [disable SELinux support])],
+     [AS_HELP_STRING([--enable-selinux], [enable SELinux support])], ,
      [enable_selinux="no"]
 )

configure.ac +7 -0
@@ -619,6 +619,13 @@ AC_CHECK_LIB(
  )
  AC_SUBST([SOCKETS_LIBS])
 
+AC_CHECK_LIB(
+     [selinux],
+     [setcon],
+     [SELINUX_LIBS="-lselinux"]
+)
+AC_SUBST([SELINUX_LIBS])
+

 case "${with_mem_check}" in
      valgrind)
              AC_CHECK_HEADER(

configure.ac +0 -0
@@ -826,25 +833,6 @@ if test "${enable_crypto}" = "yes"; then

    fi
 fi

configure.ac +0 -19
-dnl
-dnl check for SELinux library and headers
-dnl
-if test "${enable_selinux}" = "yes"; then
-     AC_CHECK_HEADER(
-             [selinux/selinux.h],
-             [AC_CHECK_LIB(
-                     [selinux],
-                     [setcon],
-                     [
-                             LIBS="${LIBS} -lselinux"
-                             AC_DEFINE(HAVE_SETCON, 1, [SELinux support])
-                     ],
-                     [AC_MSG_RESULT([SELinux library not found.])]
-             )],
-             [AC_MSG_ERROR([SELinux headers not found.])]
-     )
-fi
-

 if test -n "${SP_PLATFORM_WINDOWS}"; then AC_DEFINE_UNQUOTED([PATH_SEPARATOR], ['\\\\'], [Path separator]) #" AC_DEFINE_UNQUOTED([PATH_SEPARATOR_STR], ["\\\\"], [Path separator]) #"

configure.ac +0 -0
@@ -896,6 +884,12 @@ else

      fi
 fi

configure.ac +6 -0
+if test "${enable_selinux}" = "yes"; then
+     test -z "${SELINUX_LIBS}" && AC_MSG_ERROR([libselinux required but missing])
+     OPTIONAL_SELINUX_LIBS="${SELINUX_LIBS}"
+     AC_DEFINE([ENABLE_SELINUX], [1], [SELinux support])
+fi
+

 if test "${enable_pedantic}" = "yes"; then
      enable_strict="yes"
      CFLAGS="${CFLAGS} -ansi -pedantic"

configure.ac +1 -0
@@ -922,6 +916,7 @@ AC_SUBST([TAP_WIN_MIN_MAJOR])
  AC_SUBST([TAP_WIN_MIN_MINOR])
 
  AC_SUBST([OPTIONAL_DL_LIBS])
+AC_SUBST([OPTIONAL_SELINUX_LIBS])
 
  AM_CONDITIONAL([WIN32], [test "${WIN32}" = "yes"])
 
src/openvpn/Makefile.am +0 -0
index 86abd09..a3f8b3a 100644
@@ -97,6 +97,7 @@ openvpn_SOURCES = \

      cryptoapi.h cryptoapi.c
 openvpn_LDADD = \
      $(SOCKETS_LIBS) \
+     $(OPTIONAL_SELINUX_LIBS) \
      $(OPTIONAL_DL_LIBS)
 if WIN32
 openvpn_SOURCES += openvpn_win32_resources.rc

src/openvpn/init.c +1 -1
index b8f57b2..0c995ff 100644
@@ -1038,7 +1038,7 @@ do_uid_gid_chroot (struct context *c, bool no_delay)
       mstats_open(c->options.memstats_fn);
  #endif
 
-#ifdef HAVE_SETCON
+#ifdef ENABLE_SELINUX
        /* Apply a SELinux context in order to restrict what OpenVPN can do
         * to _only_ what it is supposed to do after initialization is complete
         * (basically just network I/O operations). Doing it after chroot
@@ -2465,7 +2465,7 @@ do_option_warnings (struct context *c)
      msg (M_WARN, "WARNING: --ping should normally be used with --ping-restart or --ping-exit");
 

   if (o->username || o->groupname || o->chroot_dir

src/openvpn/init.c +1 -1
-#ifdef HAVE_SETCON
+#ifdef ENABLE_SELINUX

       || o->selinux_context
 #endif
       )

src/openvpn/options.c +0 -0
index d7f848e..4e95b83 100644
@@ -316,7 +316,7 @@ static const char usage_message[] =

   "--user user     : Set UID to user after initialization.\n" "--group group   : Set GID to group after initialization.\n" "--chroot dir    : Chroot to this directory after initialization.\n"

src/openvpn/options.c +1 -1
-#ifdef HAVE_SETCON
+#ifdef ENABLE_SELINUX

   "--setcon context: Apply this SELinux context after initialization.\n" #endif
   "--cd dir        : Change to this directory before initialization.\n"

src/openvpn/options.c +2 -2
@@ -1477,7 +1477,7 @@ show_settings (const struct options *o)
    SHOW_STR (groupname);
    SHOW_STR (chroot_dir);
    SHOW_STR (cd_dir);
-#ifdef HAVE_SETCON
+#ifdef ENABLE_SELINUX
    SHOW_STR (selinux_context);
  #endif
    SHOW_STR (writepid);
@@ -4525,7 +4525,7 @@ add_option (struct options *options,
       }
        options->cd_dir = p[1];
      }
-#ifdef HAVE_SETCON
+#ifdef ENABLE_SELINUX
    else if (streq (p[0], "setcon") && p[1])
      {
        VERIFY_PERMISSION (OPT_P_GENERAL);
src/openvpn/options.h +1 -1
index 6af4b3a..57b88b7 100644
@@ -310,7 +310,7 @@ struct options
    const char *groupname;
    const char *chroot_dir;
    const char *cd_dir;
-#ifdef HAVE_SETCON
+#ifdef ENABLE_SELINUX
    char *selinux_context;
  #endif
    const char *writepid;
src/openvpn/syshead.h +1 -1
index 1ad81d8..cac4757 100644
@@ -176,7 +176,7 @@
  #include <sys/epoll.h>
  #endif
 
-#ifdef HAVE_SETCON
+#ifdef ENABLE_SELINUX
  #include <selinux/selinux.h>
  #endif
 
#56 lore raw

Re: [Openvpn-devel] [PATCH 31/52] build: autoconf: commands as environment

In reply to Samuli Seppänen

Just like CPP, CC, CXX, LD, AR, PKG_CONFIG Programs are expected to be in environment.
The autoconf detection get/set these in environment too.

2012/3/8 Samuli Seppänen <[email protected]...>:

Quoted 123 lines

So, this patch replaces (removes?) the "--with-<executable>-path" configure options with environment variables, right?  For example, if one has "ifconfig" in a non-standard place, he can set the IFCONFIG environment variable and the build will find it. Did I understand this correctly?

I don't know autotools well enough to give this one an ACK at this point. That said, the patch does clean up configure.ac a lot, and cleanups are always nice :).

--
Samuli Seppänen
Community Manager
OpenVPN Technologies, Inc

irc freenode net: mattock

Quoted 110 lines

---
 configure.ac |   66 ++++++++++++++++++++++++---------------------------------

 1 files changed, 28 insertions(+), 38 deletions(-)
configure.ac +0 -0
index 6b5cf71..ed98464 100644
@@ -267,37 +267,6 @@ AC_ARG_WITH(
  )
 

 AC_ARG_WITH(
-     [ifconfig-path],
-     [AS_HELP_STRING([--with-ifconfig-path=PATH], [Path to ifconfig tool])],
-     [IFCONFIG="$withval"],
-     [AC_PATH_PROG([IFCONFIG], [ifconfig], [ifconfig], [$PATH:/usr/local/sbin:/usr/sbin:/sbin])]

configure.ac +0 -27
-)
-AC_DEFINE_UNQUOTED([IFCONFIG_PATH], ["$IFCONFIG"], [Path to ifconfig tool])
-
-AC_ARG_WITH(
-     [iproute-path],
-     [AS_HELP_STRING([--with-iproute-path=PATH], [Path to iproute tool])],
-     [IPROUTE="$withval"],
-     [AC_PATH_PROG([IPROUTE], [ip], [ip], [$PATH:/usr/local/sbin:/usr/sbin:/sbin])]
-)
-AC_DEFINE_UNQUOTED([IPROUTE_PATH], ["$IPROUTE"], [Path to iproute tool])
-
-AC_ARG_WITH([route-path],
-   [AS_HELP_STRING([--with-route-path=PATH], [Path to route tool])],
-   [ROUTE="$withval"],
-   [AC_PATH_PROG([ROUTE], [route], [route], [$PATH:/usr/local/sbin:/usr/sbin:/sbin])]
-)
-AC_DEFINE_UNQUOTED([ROUTE_PATH], ["$ROUTE"], [Path to route tool])
-
-AC_ARG_WITH(
-     [netstat-path],
-     [AS_HELP_STRING([--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],
      [AS_HELP_STRING([--with-mem-check=TYPE], [build with debug memory checking, TYPE=dmalloc|valgrind|ssl])], [

configure.ac +0 -0
@@ -370,6 +339,20 @@ AC_PROG_INSTALL

 AC_PROG_LN_S
 AC_PROG_MAKE_SET

configure.ac +14 -0
+AC_ARG_VAR([IFCONFIG], [full path to ipconfig utility])
+AC_ARG_VAR([ROUTE], [full path to route utility])
+AC_ARG_VAR([IPROUTE], [full path to ip utility])
+AC_ARG_VAR([NETSTAT], [path to netstat utility]) # tests
+AC_ARG_VAR([MAN2HTML], [path to man2html utility])
+AC_PATH_PROGS([IFCONFIG], [ifconfig],, [$PATH:/usr/local/sbin:/usr/sbin:/sbin])
+AC_PATH_PROGS([ROUTE], [route],, [$PATH:/usr/local/sbin:/usr/sbin:/sbin])
+AC_PATH_PROGS([IPROUTE], [ip],, [$PATH:/usr/local/sbin:/usr/sbin:/sbin])
+AC_CHECK_PROGS([NETSTAT], [netstat], [netstat], [$PATH:/usr/local/sbin:/usr/sbin:/sbin:/etc]) # tests
+AC_CHECK_PROGS([MAN2HTML], [man2html])
+AC_DEFINE_UNQUOTED([IFCONFIG_PATH], ["$IFCONFIG"], [Path to ifconfig tool])
+AC_DEFINE_UNQUOTED([IPROUTE_PATH], ["$IPROUTE"], [Path to iproute tool])
+AC_DEFINE_UNQUOTED([ROUTE_PATH], ["$ROUTE"], [Path to route tool])
+

 #
 # Libtool
 #

configure.ac +0 -0
@@ -386,12 +369,6 @@ ifdef(

      ]
 )

configure.ac +0 -6
-if test "${WIN32}" = "yes"; then
-     AC_ARG_VAR([MAN2HTML], [man2html utility])
-     AC_CHECK_PROGS([MAN2HTML], [man2html])
-     test -z "${MAN2HTML}" && AC_MSG_ERROR([man2html is required for win32])
-fi
-

 AC_C_CONST
 AC_C_INLINE
 AC_C_VOLATILE

configure.ac +10 -1
@@ -920,7 +897,16 @@ test "${enable_pf}" = "yes" && AC_DEFINE([ENABLE_PF], [1], [Enable internal pack
  test "${enable_strict_options}" = "yes" && AC_DEFINE([ENABLE_STRICT_OPTIONS_CHECK], [1], [Enable strict options check between peers])
  test "${enable_password_save}" = "yes" && AC_DEFINE([ENABLE_PASSWORD_SAVE], [1], [Allow --askpass and --auth-user-pass passwords to be read from a file])
  test "${enable_systemd}" = "yes" && AC_DEFINE([ENABLE_SYSTEMD], [1], [Enable systemd support])
-test "${enable_iproute2}" = "yes" && AC_DEFINE([ENABLE_IPROUTE], [1], [enable iproute2 support])
+
+if test "${enable_iproute2}" = "yes"; then
+     test -z "${IPROUTE}" && AC_MSG_ERROR([ip utility is required but missing])
+     AC_DEFINE([ENABLE_IPROUTE], [1], [enable iproute2 support])
+else
+     if test "${WIN32}" != "yes"; then
+             test -z "${ROUTE}" && AC_MSG_ERROR([route utility is required but missing])
+             test -z "${IFCONFIG}" && AC_MSG_ERROR([ifconfig utility is required but missing])
+     fi
+fi
 

 if test "${enable_pedantic}" = "yes"; then
      enable_strict="yes"

configure.ac +0 -0
@@ -930,6 +916,10 @@ if test "${enable_strict}" = "yes"; then

      CFLAGS="${CFLAGS} -Wall -Wno-unused-parameter -Wno-unused-function" fi

configure.ac +4 -0
+if test "${WIN32}" = "yes"; then
+     test -z "${MAN2HTML}" && AC_MSG_ERROR([man2html is required for win32])
+fi
+

 CONFIGURE_DEFINES="set | grep '^enable_.*=' ; set | grep '^with_.*='" AC_DEFINE_UNQUOTED([CONFIGURE_DEFINES], ["echo ${CONFIGURE_DEFINES}"], [Configuration settings])

#60 lore raw

Re: [Openvpn-devel] [PATCH 33/52] build: properly detect and use socket libs

In reply to Samuli Seppänen

Although I work with flameeyes closely in some of these issues...

I disagree with his opinion here as generic approach.

He is write as in most cases people just adds libraries as they go in the configure process...
So you check for dl, then rt, then resolv, then selinux etc... building your LIBS.
The result is one long LIBS which is common to all executables.

I take another approach and detect dependencies as atoms.

Yes... if one day dl will be merged into libc we fail in this case, but then we can fix <something>.

For now this is working perfectly.

Alon.

2012/3/8 Samuli Seppänen <[email protected]...>:

Quoted 80 lines

Did some digging regarding AC_SEARCH_LIBS and AC_CHECK_LIB. Somebody with more autotools knowledge might want to read this one:

<http://www.flameeyes.eu/autotools-mythbuster/autoconf/finding.html>

So, the question is: why AC_CHECK_LIB rather than AC_SEARCH_LIBS in this particular case? Apparently both have their uses.

--
Samuli Seppänen
Community Manager
OpenVPN Technologies, Inc

irc freenode net: mattock

Quoted 63 lines

---
 configure.ac            |   27 +++++++++++++++++---------- src/openvpn/Makefile.am |    1 +

 2 files changed, 18 insertions(+), 10 deletions(-)
configure.ac +0 -0
index a0dc462..c540f82 100644
@@ -442,16 +442,6 @@ if test "${WIN32}" != "yes"; then

              [[${SOCKET_INCLUDES}]]
      )

-     AC_CHECK_DECLS(
-             [SO_MARK],
-             ,
-             ,
-             [[${SOCKET_INCLUDES}]]
-     )
-
-     AC_SEARCH_LIBS([socket], [socket])
-     AC_SEARCH_LIBS([inet_ntoa], [nsl])
-     AC_SEARCH_LIBS([gethostbyname], [resolv nsl]) AC_FUNC_FORK
 fi

configure.ac +17 -0
@@ -613,6 +603,23 @@ AC_CHECK_LIB(
  )
  AC_SUBST([DL_LIBS])
 
+AC_CHECK_LIB(
+     [nsl],
+     [inet_ntoa],
+     [SOCKETS_LIBS="${SOCKETS_LIBS} -lnsl"]
+)
+AC_CHECK_LIB(
+     [socket],
+     [socket],
+     [SOCKETS_LIBS="${SOCKETS_LIBS} -lsocket"]
+)
+AC_CHECK_LIB(
+     [resolv],
+     [gethostbyname],
+     [SOCKETS_LIBS="${SOCKETS_LIBS} -lresolv"]
+)
+AC_SUBST([SOCKETS_LIBS])
+

 case "${with_mem_check}" in
      valgrind)
              AC_CHECK_HEADER(

src/openvpn/Makefile.am +0 -0
index c7626c8..86abd09 100644
@@ -96,6 +96,7 @@ openvpn_SOURCES = \
       win32.h win32.c \

      cryptoapi.h cryptoapi.c
 openvpn_LDADD = \
+     $(SOCKETS_LIBS) \
      $(OPTIONAL_DL_LIBS)
 if WIN32
 openvpn_SOURCES += openvpn_win32_resources.rc

#107 lore raw

Re: [Openvpn-devel] [PATCH 50/52] build: windows: install version.sh to allow installer read version

In reply to Alon Bar-Lev

Ok. ACK.

Signature · 5 lines
Samuli Seppänen
Community Manager
OpenVPN Technologies, Inc

irc freenode net: mattock
Quoted 81 lines

Not exactly.
It is used[1] by the packaging script... just sourced to get some environment variables.

[1] https://github.com/alonbl/openvpn-build/blob/master/windows-nsis/build#L55

2012/3/8 Samuli Seppänen <[email protected]...>:

Quoted 74 lines

Is this meant to allow using these variables[1] in the NSIS script(s)?

--
Samuli Seppänen
Community Manager
OpenVPN Technologies, Inc

irc freenode net: mattock

[1]

OPENVPN_PACKAGE_NAME="@PACKAGE_NAME@"
OPENVPN_PACKAGE_TARNAME="@PACKAGE_TARNAME@"
OPENVPN_PACKAGE_VERSION="@PACKAGE_VERSION@"
OPENVPN_PACKAGE_HOST="@host@"

Quoted 56 lines
---
 .gitignore    |    1 +
 Makefile.am   |    5 +++++
 configure.ac  |    1 +
 version.sh.in |    4 ++++
 4 files changed, 11 insertions(+), 0 deletions(-)
 create mode 100644 version.sh.in
.gitignore +1 -0
index e7232cf..2f72ed8 100644
@@ -39,6 +39,7 @@ m4/ltsugar.m4
 m4/ltversion.m4
 m4/lt~obsolete.m4
 
+version.sh
 msvc-env-local.bat
 config-msvc-local.h
 config-msvc-version.h
Makefile.am +5 -0
index 5293518..68aa0a8 100644
@@ -69,3 +69,8 @@ endif
 dist_noinst_HEADERS = \
      config-msvc.h \
      config-msvc-version.h.in
+
+if WIN32
+rootdir=$(prefix)
+root_DATA = version.sh
+endif
configure.ac +1 -0
index d53a74a..0f2a62e 100644
@@ -904,6 +904,7 @@ AC_SUBST([OPTIONAL_PKCS11_HELPER_LIBS])
 AM_CONDITIONAL([WIN32], [test "${WIN32}" = "yes"])
 
 AC_CONFIG_FILES([
+     version.sh
      Makefile
      build/Makefile
      build/msvc/Makefile
version.sh.in new file +4 -0
new file mode 100644
index 0000000..2af5a36
@@ -0,0 +1,4 @@
+OPENVPN_PACKAGE_NAME="@PACKAGE_NAME@"
+OPENVPN_PACKAGE_TARNAME="@PACKAGE_TARNAME@"
+OPENVPN_PACKAGE_VERSION="@PACKAGE_VERSION@"
+OPENVPN_PACKAGE_HOST="@host@"
#95 lore raw

Re: [Openvpn-devel] [PATCH 47/52] build: move inet_ntop(), inet_pton() emulation into compat

In reply to Alon Bar-Lev

Ok. We need this for at least 2 years when XP has EOL and I think compat is the right place. ACK just as earlier :).

Signature · 5 lines
Samuli Seppänen
Community Manager
OpenVPN Technologies, Inc

irc freenode net: mattock
Quoted 387 lines

Not exactly... windows has this in Vista and above.
As long as we need to support XP we need to implement replacement functionality.

2012/3/8 Samuli Seppänen <[email protected]...>:

Quoted 383 lines

Windows has this functionality, but not under the same function names as UNIX. So thse two are just wrappers around the Windows-specific functionality. In any case, I think it makes sense to move inet_pton and inet_ntop under src/compat. The actual code changes seem fairly trivial.

ACK.

--
Samuli Seppänen
Community Manager
OpenVPN Technologies, Inc

irc freenode net: mattock

PS. These links should cover the basic idea, in case somebody is interested:

<http://us.generation-nt.com/inet-pton-windows-convert-address-presentation-format-network-format-help-37036482.html>
<http://pubs.opengroup.org/onlinepubs/009604599/functions/inet_ntop.html>

Quoted 363 lines

---
configure.ac I recall many issues with inet_ntop and inet_pton.

                |    2 +-
 src/compat/Makefile.am        |    4 ++-
 src/compat/compat-inet_ntop.c |   76 +++++++++++++++++++++++++++++++++++++++
 src/compat/compat-inet_pton.c |   79 +++++++++++++++++++++++++++++++++++++++++
 src/compat/compat.h           |   17 ++++++++-
 src/compat/compat.vcproj      |    8 ++++
 src/openvpn/socket.c          |   55 ----------------------------
 src/openvpn/win32.h           |    6 ---
 8 files changed, 183 insertions(+), 64 deletions(-)
 create mode 100644 src/compat/compat-inet_ntop.c
 create mode 100644 src/compat/compat-inet_pton.c
configure.ac +1 -1
index dc138ba..d53a74a 100644
@@ -522,7 +522,7 @@ AC_CHECK_FUNCS([ \
        chsize ftruncate execve getpeereid umask basename dirname access \
        epoll_create \
 ])
-AC_CHECK_FUNCS([sendmsg recvmsg])
+AC_CHECK_FUNCS([sendmsg recvmsg inet_ntop inet_pton])
 AC_CHECK_FUNCS(
        [res_init],
        ,
src/compat/Makefile.am +3 -1
index c8a92ce..91b7f40 100644
@@ -22,4 +22,6 @@ libcompat_la_SOURCES = \
        compat-dirname.c \
        compat-basename.c \
        compat-gettimeofday.c \
-       compat-daemon.c
+       compat-daemon.c \
+       compat-inet_ntop.c \
+       compat-inet_pton.c
src/compat/compat-inet_ntop.c new file +76 -0
new file mode 100644
index 0000000..0d52142
@@ -0,0 +1,76 @@
+/*
+ *  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) 2011 - David Sommerseth <[email protected]...>
+ *
+ *  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
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#elif defined(_MSC_VER)
+#include "config-msvc.h"
+#endif
+
+#ifndef HAVE_INET_NTOP
+
+#include "compat.h"
+
+#ifdef WIN32
+
+#include <windows.h>
+
+/*
+ * inet_ntop() and inet_pton() wrap-implementations using
+ * WSAAddressToString() and WSAStringToAddress() functions
+ *
+ * this is needed as long as we support running OpenVPN on WinXP
+ */
+
+const char *
+inet_ntop(int af, const void *src, char *dst, socklen_t size)
+{
+  struct sockaddr_storage ss;
+  unsigned long s = size;
+
+  ZeroMemory(&ss, sizeof(ss));
+  ss.ss_family = af;
+
+  switch(af) {
+    case AF_INET:
+      ((struct sockaddr_in *)&ss)->sin_addr = *(struct in_addr *)src;
+      break;
+    case AF_INET6:
+      ((struct sockaddr_in6 *)&ss)->sin6_addr = *(struct in6_addr *)src;
+      break;
+    default:
+      return NULL;
+  }
+  /* cannot direclty use &size because of strict aliasing rules */
+  return (WSAAddressToString((struct sockaddr *)&ss, sizeof(ss), NULL, dst, &s) == 0)?
+          dst : NULL;
+}
+
+#else
+
+#error no emulation for inet_ntop
+
+#endif
+
+#endif
src/compat/compat-inet_pton.c new file +79 -0
new file mode 100644
index 0000000..cdc8d4b
@@ -0,0 +1,79 @@
+/*
+ *  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) 2011 - David Sommerseth <[email protected]...>
+ *
+ *  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
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#elif defined(_MSC_VER)
+#include "config-msvc.h"
+#endif
+
+#ifndef HAVE_INET_PTON
+
+#include "compat.h"
+
+#ifdef WIN32
+
+#include <windows.h>
+#include <string.h>
+
+/*
+ * inet_ntop() and inet_pton() wrap-implementations using
+ * WSAAddressToString() and WSAStringToAddress() functions
+ *
+ * this is needed as long as we support running OpenVPN on WinXP
+ */
+
+
+int
+inet_pton(int af, const char *src, void *dst)
+{
+  struct sockaddr_storage ss;
+  int size = sizeof(ss);
+  char src_copy[INET6_ADDRSTRLEN+1];
+
+  ZeroMemory(&ss, sizeof(ss));
+  /* stupid non-const API */
+  strncpy (src_copy, src, INET6_ADDRSTRLEN+1);
+  src_copy[INET6_ADDRSTRLEN] = 0;
+
+  if (WSAStringToAddress(src_copy, af, NULL, (struct sockaddr *)&ss, &size) == 0) {
+    switch(af) {
+      case AF_INET:
+       *(struct in_addr *)dst = ((struct sockaddr_in *)&ss)->sin_addr;
+       return 1;
+      case AF_INET6:
+       *(struct in6_addr *)dst = ((struct sockaddr_in6 *)&ss)->sin6_addr;
+       return 1;
+    }
+  }
+  return 0;
+}
+
+#else
+
+#error no emulation for inet_ntop
+
+#endif
+
+#endif
src/compat/compat.h +16 -1
index e9d51b8..021573e 100644
@@ -26,14 +26,21 @@
 #define COMPAT_H
 
 #ifdef HAVE_WINSOCK2_H
-/* timeval */
 #include <winsock2.h>
 #endif
 
+#ifdef HAVE_WS2TCPIP_H
+#include <ws2tcpip.h>
+#endif
+
 #ifdef HAVE_SYS_TIME_H
 #include <sys/time.h>
 #endif
 
+#ifdef HAVE_SYS_SOCKET_H
+#include <sys/socket.h>
+#endif
+
 #ifndef HAVE_DIRNAME
 char * dirname(char *str);
 #endif /* HAVE_DIRNAME */
@@ -50,4 +57,12 @@ int gettimeofday (struct timeval *tv, void *tz);
 int daemon(int nochdir, int noclose);
 #endif
 
+#ifndef HAVE_INET_NTOP
+const char * inet_ntop(int af, const void *src, char *dst, socklen_t size);
+#endif
+
+#ifndef HAVE_INET_PTON
+int inet_pton(int af, const char *src, void *dst);
+#endif
+
 #endif /* COMPAT_H */
src/compat/compat.vcproj +8 -0
index efdecb4..43fc0c2 100644
@@ -163,6 +163,14 @@
                                >
                        </File>
                        <File
+                               RelativePath=".\compat-inet_ntop.c"
+                               >
+                       </File>
+                       <File
+                               RelativePath=".\compat-inet_pton.c"
+                               >
+                       </File>
+                       <File
                                RelativePath=".\compat-daemon.c"
                                >
                        </File>
src/openvpn/socket.c +0 -55
index e1526ff..608213b 100644
@@ -3086,61 +3086,6 @@ link_socket_write_udp_posix_sendmsg (struct link_socket *sock,
 
 #ifdef WIN32
 
-/*
- * inet_ntop() and inet_pton() wrap-implementations using
- * WSAAddressToString() and WSAStringToAddress() functions
- *
- * this is needed as long as we support running OpenVPN on WinXP
- */
-
-const char *
-openvpn_inet_ntop(int af, const void *src, char *dst, socklen_t size)
-{
-  struct sockaddr_storage ss;
-  unsigned long s = size;
-
-  CLEAR(ss);
-  ss.ss_family = af;
-
-  switch(af) {
-    case AF_INET:
-      ((struct sockaddr_in *)&ss)->sin_addr = *(struct in_addr *)src;
-      break;
-    case AF_INET6:
-      ((struct sockaddr_in6 *)&ss)->sin6_addr = *(struct in6_addr *)src;
-      break;
-    default:
-      ASSERT (0);
-  }
-  /* cannot direclty use &size because of strict aliasing rules */
-  return (WSAAddressToString((struct sockaddr *)&ss, sizeof(ss), NULL, dst, &s) == 0)?
-          dst : NULL;
-}
-
-int
-openvpn_inet_pton(int af, const char *src, void *dst)
-{
-  struct sockaddr_storage ss;
-  int size = sizeof(ss);
-  char src_copy[INET6_ADDRSTRLEN+1];
-
-  CLEAR(ss);
-  /* stupid non-const API */
-  strncpynt(src_copy, src, INET6_ADDRSTRLEN+1);
-
-  if (WSAStringToAddress(src_copy, af, NULL, (struct sockaddr *)&ss, &size) == 0) {
-    switch(af) {
-      case AF_INET:
-       *(struct in_addr *)dst = ((struct sockaddr_in *)&ss)->sin_addr;
-       return 1;
-      case AF_INET6:
-       *(struct in6_addr *)dst = ((struct sockaddr_in6 *)&ss)->sin6_addr;
-       return 1;
-    }
-  }
-  return 0;
-}
-
 int
 socket_recv_queue (struct link_socket *sock, int maxsize)
 {
src/openvpn/win32.h +0 -7
index 09f897a..d87e987 100644
@@ -266,12 +266,6 @@ char *get_win_sys_path (void);
 /* call self in a subprocess */
 void fork_to_self (const char *cmdline);
 
-const char *openvpn_inet_ntop(int af, const void *src,
-                              char *dst, socklen_t size);
-int openvpn_inet_pton(int af, const char *src, void *dst);
-#define inet_ntop(af,src,dst,size) openvpn_inet_ntop(af,src,dst,size)
-#define inet_pton(af,src,dst)      openvpn_inet_pton(af,src,dst)
-
 /* Find temporary directory */
 const char *win_get_tempdir();
 
--

1.7.3.4

------------------------------------------------------------------------------
Virtualization & Cloud Management Using Capacity Planning Cloud computing makes use of virtualization - but cloud computing also focuses on allowing computing to be delivered as a service.
http://www.accelacomm.com/jaw/sfnl/114/51521223/
_______________________________________________
Openvpn-devel mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel