Fixed minor issue in TAP driver DEBUG builds where
non-null-terminated unicode strings were being
printed incorrectly.
Version 2.1.1g
git-svn-id: http://svn.openvpn.net/projects/openvpn/branches/BETA21/openvpn@5577 e7ae566f-a301-0410-adde-c780ea21d3b5
| ... | ... |
@@ -15,9 +15,8 @@ QUICK START: |
| 15 | 15 |
Windows MinGW, using MSYS bash shell: |
| 16 | 16 |
./domake-win (see comments in the script for more info) |
| 17 | 17 |
|
| 18 |
- Windows MSVC using Visual Studio 2008 Command Prompt window: |
|
| 19 |
- python msvc\config.py |
|
| 20 |
- nmake /f msvc\msvc.mak |
|
| 18 |
+ Windows Visual Studio: |
|
| 19 |
+ python win\build_all.py |
|
| 21 | 20 |
|
| 22 | 21 |
************************************************************************* |
| 23 | 22 |
|
| ... | ... |
@@ -35,15 +35,15 @@ |
| 35 | 35 |
# tapinstall.exe source code. |
| 36 | 36 |
# Not needed if DRVBINSRC is defined |
| 37 | 37 |
# (or if using pre-built mode). |
| 38 |
-!define TISRC "../tapinstall" |
|
| 38 |
+!define TISRC "../tapinstall/5600" |
|
| 39 | 39 |
|
| 40 | 40 |
# TAP Adapter parameters. Note that PRODUCT_TAP_ID is |
| 41 | 41 |
# defined in version.m4. |
| 42 | 42 |
!define PRODUCT_TAP_DEVICE_DESCRIPTION "TAP-Win32 Adapter V9" |
| 43 | 43 |
!define PRODUCT_TAP_PROVIDER "TAP-Win32 Provider V9" |
| 44 | 44 |
!define PRODUCT_TAP_MAJOR_VER 9 |
| 45 |
-!define PRODUCT_TAP_MINOR_VER 6 |
|
| 46 |
-!define PRODUCT_TAP_RELDATE "06/22/2009" |
|
| 45 |
+!define PRODUCT_TAP_MINOR_VER 7 |
|
| 46 |
+!define PRODUCT_TAP_RELDATE "04/19/2010" |
|
| 47 | 47 |
|
| 48 | 48 |
# TAP adapter icon -- visible=0x81 or hidden=0x89 |
| 49 | 49 |
!define PRODUCT_TAP_CHARACTERISTICS 0x81 |
| ... | ... |
@@ -58,7 +58,7 @@ |
| 58 | 58 |
|
| 59 | 59 |
# Code Signing. |
| 60 | 60 |
# If undefined, don't sign any files. |
| 61 |
-!define SIGNTOOL "../signtool" |
|
| 61 |
+!define SIGNTOOL "../signtool.old" |
|
| 62 | 62 |
!define PRODUCT_SIGN_CN "openvpn" |
| 63 | 63 |
|
| 64 | 64 |
# -j parameter passed to make |
| ... | ... |
@@ -8,7 +8,7 @@ TARGETNAME=@@PRODUCT_TAP_ID@@ |
| 8 | 8 |
TARGETTYPE=DRIVER |
| 9 | 9 |
TARGETPATH=. |
| 10 | 10 |
TARGETLIBS=$(DDK_LIB_PATH)\ndis.lib $(DDK_LIB_PATH)\ntstrsafe.lib |
| 11 |
-INCLUDES=$(DDK_INCLUDE_PATH) |
|
| 11 |
+INCLUDES=$(DDK_INCLUDE_PATH) .. |
|
| 12 | 12 |
|
| 13 | 13 |
# The TAP version numbers here must be >= |
| 14 | 14 |
# TAP_WIN32_MIN_x values defined in |
| ... | ... |
@@ -53,7 +53,7 @@ MSC_OPTIMIZATION=/Od /Oi /Fc |
| 53 | 53 |
!ENDIF |
| 54 | 54 |
|
| 55 | 55 |
# Generate a linker map file just in case we need one for debugging |
| 56 |
-LINKER_FLAGS=$(LINKER_FLAGS) /MAP /MAPINFO:EXPORTS /MAPINFO:LINES |
|
| 56 |
+LINKER_FLAGS=$(LINKER_FLAGS) /INCREMENTAL:NO /MAP /MAPINFO:EXPORTS |
|
| 57 | 57 |
|
| 58 | 58 |
# Generate a browser information file for use in IDE development |
| 59 | 59 |
#BROWSER_INFO=1 |
| ... | ... |
@@ -28,15 +28,7 @@ |
| 28 | 28 |
// common to both. |
| 29 | 29 |
//=============================================== |
| 30 | 30 |
|
| 31 |
-#if defined(HAVE_CONFIG_H) |
|
| 32 |
-#include "config.h" |
|
| 33 |
-#else |
|
| 34 |
-#if defined(_MSC_VER) && !defined(TAP_DRIVER_MAJOR_VERSION) |
|
| 35 |
-#include "config-win32.h" |
|
| 36 |
-#else |
|
| 37 |
-#include "../config.h" |
|
| 38 |
-#endif |
|
| 39 |
-#endif |
|
| 31 |
+#include "autodefs.h" |
|
| 40 | 32 |
|
| 41 | 33 |
//============= |
| 42 | 34 |
// TAP IOCTLs |
| ... | ... |
@@ -2,7 +2,6 @@ |
| 2 | 2 |
#include <ntverp.h> |
| 3 | 3 |
|
| 4 | 4 |
/* get VERSION */ |
| 5 |
-#include "../config-win32.h" |
|
| 6 | 5 |
#include "common.h" |
| 7 | 6 |
|
| 8 | 7 |
/* VER_FILETYPE, VER_FILESUBTYPE, VER_FILEDESCRIPTION_STR |
| ... | ... |
@@ -36,7 +35,7 @@ |
| 36 | 36 |
#define VER_COMPANYNAME_STR "The OpenVPN Project" |
| 37 | 37 |
#define VER_FILEDESCRIPTION_STR "TAP-Win32 Virtual Network Driver" |
| 38 | 38 |
#define VER_ORIGINALFILENAME_STR TAP_COMPONENT_ID ".sys" |
| 39 |
-#define VER_LEGALCOPYRIGHT_YEARS "2003-2009" |
|
| 39 |
+#define VER_LEGALCOPYRIGHT_YEARS "2003-2010" |
|
| 40 | 40 |
#define VER_LEGALCOPYRIGHT_STR "OpenVPN Technologies, Inc." |
| 41 | 41 |
|
| 42 | 42 |
|
| ... | ... |
@@ -46,7 +45,7 @@ |
| 46 | 46 |
#define XSTR(s) STR(s) |
| 47 | 47 |
#define STR(s) #s |
| 48 | 48 |
|
| 49 |
-#define VSTRING VERSION " " XSTR(TAP_DRIVER_MAJOR_VERSION) "/" XSTR(TAP_DRIVER_MINOR_VERSION) |
|
| 49 |
+#define VSTRING PACKAGE_VERSION " " XSTR(TAP_DRIVER_MAJOR_VERSION) "/" XSTR(TAP_DRIVER_MINOR_VERSION) |
|
| 50 | 50 |
|
| 51 | 51 |
#ifdef DBG |
| 52 | 52 |
#define VER_PRODUCTVERSION_STR VSTRING " (DEBUG)" |
| ... | ... |
@@ -35,7 +35,7 @@ |
| 35 | 35 |
// TAP_IOCTL_CONFIG_TUN ioctl. |
| 36 | 36 |
//====================================================== |
| 37 | 37 |
|
| 38 |
-#include "../../autodefs/defs.h" |
|
| 38 |
+#include "common.h" |
|
| 39 | 39 |
#ifndef DDKVER_MAJOR |
| 40 | 40 |
#error DDKVER_MAJOR must be defined as the major number of the DDK Version |
| 41 | 41 |
#endif |
| ... | ... |
@@ -78,7 +78,6 @@ |
| 78 | 78 |
|
| 79 | 79 |
#include "lock.h" |
| 80 | 80 |
#include "constants.h" |
| 81 |
-#include "common.h" |
|
| 82 | 81 |
#include "proto.h" |
| 83 | 82 |
#include "error.h" |
| 84 | 83 |
#include "endian.h" |
| ... | ... |
@@ -209,7 +208,7 @@ DriverEntry (IN PDRIVER_OBJECT p_DriverObject, |
| 209 | 209 |
TAP_DRIVER_MINOR_VERSION, |
| 210 | 210 |
__DATE__, |
| 211 | 211 |
__TIME__)); |
| 212 |
- DEBUGP (("Registry Path: '%S'\n", p_RegistryPath->Buffer));
|
|
| 212 |
+ DEBUGP (("Registry Path: '%.*S'\n", p_RegistryPath->Length/2, p_RegistryPath->Buffer));
|
|
| 213 | 213 |
break; |
| 214 | 214 |
} |
| 215 | 215 |
|
| ... | ... |
@@ -414,7 +413,9 @@ NDIS_STATUS AdapterCreate |
| 414 | 414 |
{
|
| 415 | 415 |
if (parm->ParameterType == NdisParameterString) |
| 416 | 416 |
{
|
| 417 |
- DEBUGP (("[TAP] NdisReadConfiguration (MiniportName=%S)\n", parm->ParameterData.StringData.Buffer));
|
|
| 417 |
+ DEBUGP (("[TAP] NdisReadConfiguration (MiniportName=%.*S)\n",
|
|
| 418 |
+ parm->ParameterData.StringData.Length/2, |
|
| 419 |
+ parm->ParameterData.StringData.Buffer)); |
|
| 418 | 420 |
|
| 419 | 421 |
if (RtlUnicodeStringToAnsiString ( |
| 420 | 422 |
&l_Adapter->m_NameAnsi, |
| 7 | 7 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,31 @@ |
| 0 |
+#ifndef AUTODEFS_H |
|
| 1 |
+#define AUTODEFS_H |
|
| 2 |
+ |
|
| 3 |
+/* |
|
| 4 |
+ * Minimum TAP-Win32 version number expected by userspace |
|
| 5 |
+ * |
|
| 6 |
+ * The TAP-Win32 version number is defined in tap-win32/SOURCES |
|
| 7 |
+ */ |
|
| 8 |
+#define TAP_ID "@PRODUCT_TAP_ID@" |
|
| 9 |
+#define TAP_WIN32_MIN_MAJOR @PRODUCT_TAP_WIN32_MIN_MAJOR@ |
|
| 10 |
+#define TAP_WIN32_MIN_MINOR @PRODUCT_TAP_WIN32_MIN_MINOR@ |
|
| 11 |
+ |
|
| 12 |
+/* Friendly name for TAP driver */ |
|
| 13 |
+#define PRODUCT_TAP_DEVICE_DESCRIPTION "@PRODUCT_TAP_DEVICE_DESCRIPTION@" |
|
| 14 |
+ |
|
| 15 |
+/* Version number of DDK/WDK used to build TAP driver */ |
|
| 16 |
+#define DDKVER_MAJOR @DDKVER_MAJOR@ |
|
| 17 |
+ |
|
| 18 |
+/* Name of package */ |
|
| 19 |
+#define PACKAGE "@PRODUCT_UNIX_NAME@" |
|
| 20 |
+ |
|
| 21 |
+/* Define to the full name of this package. */ |
|
| 22 |
+#define PACKAGE_NAME "@PRODUCT_NAME@" |
|
| 23 |
+ |
|
| 24 |
+/* Define to the one symbol short name of this package. */ |
|
| 25 |
+#define PACKAGE_TARNAME "@PRODUCT_UNIX_NAME@" |
|
| 26 |
+ |
|
| 27 |
+/* Define to the version of this package. */ |
|
| 28 |
+#define PACKAGE_VERSION "@PRODUCT_VERSION@" |
|
| 29 |
+ |
|
| 30 |
+#endif |
| 0 | 31 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,15 @@ |
| 0 |
+import os |
|
| 1 |
+from wb import system, config, home_fn, cd_home |
|
| 2 |
+ |
|
| 3 |
+os.environ['PATH'] += ";%s\\VC" % (os.path.normpath(config['MSVC']),) |
|
| 4 |
+ |
|
| 5 |
+def build_vc(cmd): |
|
| 6 |
+ system('cmd /c "vcvarsall.bat x86 && %s"' % (cmd,))
|
|
| 7 |
+ |
|
| 8 |
+def main(): |
|
| 9 |
+ cd_home() |
|
| 10 |
+ build_vc("nmake /f %s" % (home_fn('msvc.mak'),))
|
|
| 11 |
+ |
|
| 12 |
+# if we are run directly, and not loaded as a module |
|
| 13 |
+if __name__ == "__main__": |
|
| 14 |
+ main() |
| 0 | 15 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,18 @@ |
| 0 |
+from config_all import main as config_all |
|
| 1 |
+from build import main as build_openvpn |
|
| 2 |
+from build_ddk import main as build_ddk |
|
| 3 |
+from sign import main as sign |
|
| 4 |
+from make_dist import main as make_dist |
|
| 5 |
+ |
|
| 6 |
+def main(config): |
|
| 7 |
+ config_all(config) |
|
| 8 |
+ build_openvpn() |
|
| 9 |
+ build_ddk(config, 'tap', 'all') |
|
| 10 |
+ build_ddk(config, 'tapinstall', 'all') |
|
| 11 |
+ sign(config, 'all') |
|
| 12 |
+ make_dist(config) |
|
| 13 |
+ |
|
| 14 |
+# if we are run directly, and not loaded as a module |
|
| 15 |
+if __name__ == "__main__": |
|
| 16 |
+ from wb import config |
|
| 17 |
+ main(config) |
| 0 | 18 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,50 @@ |
| 0 |
+import os |
|
| 1 |
+from wb import system, home_fn, choose_arch |
|
| 2 |
+ |
|
| 3 |
+def build_ddk(config, dir, x64): |
|
| 4 |
+ setenv_bat = os.path.realpath(os.path.join(config['DDK_PATH'], 'bin/setenv.bat')) |
|
| 5 |
+ ddk_major = int(config['DDKVER_MAJOR']) |
|
| 6 |
+ debug = 'PRODUCT_TAP_DEBUG' in config |
|
| 7 |
+ target = 'chk' if debug else 'fre' |
|
| 8 |
+ if x64: |
|
| 9 |
+ target += ' x64' |
|
| 10 |
+ else: |
|
| 11 |
+ target += ' x86' |
|
| 12 |
+ if ddk_major >= 7600: |
|
| 13 |
+ if x64: |
|
| 14 |
+ target += ' wlh' # vista |
|
| 15 |
+ else: |
|
| 16 |
+ target += ' wnet' # server 2003 |
|
| 17 |
+ else: |
|
| 18 |
+ if x64: |
|
| 19 |
+ target += ' wnet' # server 2003 |
|
| 20 |
+ else: |
|
| 21 |
+ target += ' w2k' # 2000 |
|
| 22 |
+ |
|
| 23 |
+ system('cmd /c "%s %s %s && cd %s && build -cef"' % (
|
|
| 24 |
+ setenv_bat, |
|
| 25 |
+ os.path.realpath(config['DDK_PATH']), |
|
| 26 |
+ target, |
|
| 27 |
+ dir |
|
| 28 |
+ )) |
|
| 29 |
+ |
|
| 30 |
+def main(config, proj, arch): |
|
| 31 |
+ if proj == 'tap': |
|
| 32 |
+ dir = home_fn('tap-win32')
|
|
| 33 |
+ elif proj == 'tapinstall': |
|
| 34 |
+ dir = home_fn('tapinstall')
|
|
| 35 |
+ else: |
|
| 36 |
+ raise ValueError("unknown project: %s" % (proj,))
|
|
| 37 |
+ |
|
| 38 |
+ for x64 in choose_arch(arch): |
|
| 39 |
+ build_ddk(config, dir, x64) |
|
| 40 |
+ |
|
| 41 |
+# if we are run directly, and not loaded as a module |
|
| 42 |
+if __name__ == "__main__": |
|
| 43 |
+ import sys |
|
| 44 |
+ from wb import config |
|
| 45 |
+ if len(sys.argv) >= 3: |
|
| 46 |
+ main(config, sys.argv[1], sys.argv[2]) |
|
| 47 |
+ else: |
|
| 48 |
+ print "usage: build <tap|tapinstall> <x64|x86|all>" |
|
| 49 |
+ sys.exit(2) |
| 0 | 50 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,17 @@ |
| 0 |
+from wb import preprocess, autogen, mod_fn, home_fn, build_autodefs, make_headers_objs, dict_def |
|
| 1 |
+ |
|
| 2 |
+def main(config): |
|
| 3 |
+ build_autodefs(config, mod_fn('autodefs.h.in'), home_fn('autodefs.h'))
|
|
| 4 |
+ ho = make_headers_objs(home_fn('Makefile.am'))
|
|
| 5 |
+ |
|
| 6 |
+ preprocess(dict_def(config, [('HEADERS_OBJS', ho)]),
|
|
| 7 |
+ in_fn=mod_fn('msvc.mak.in'),
|
|
| 8 |
+ out_fn=home_fn('msvc.mak'),
|
|
| 9 |
+ quote_begin='@', |
|
| 10 |
+ quote_end='@', |
|
| 11 |
+ head_comment='# %s\n\n' % autogen) |
|
| 12 |
+ |
|
| 13 |
+# if we are run directly, and not loaded as a module |
|
| 14 |
+if __name__ == "__main__": |
|
| 15 |
+ from wb import config |
|
| 16 |
+ main(config) |
| 0 | 17 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,13 @@ |
| 0 |
+from config import main as config_main |
|
| 1 |
+from config_tap import main as config_tap |
|
| 2 |
+from config_ti import main as config_ti |
|
| 3 |
+ |
|
| 4 |
+def main(config): |
|
| 5 |
+ config_main(config) |
|
| 6 |
+ config_tap(config) |
|
| 7 |
+ config_ti(config) |
|
| 8 |
+ |
|
| 9 |
+# if we are run directly, and not loaded as a module |
|
| 10 |
+if __name__ == "__main__": |
|
| 11 |
+ from wb import config |
|
| 12 |
+ main(config) |
| 0 | 13 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,35 @@ |
| 0 |
+import os |
|
| 1 |
+from wb import preprocess, home_fn, autogen, dict_def |
|
| 2 |
+ |
|
| 3 |
+def main(config): |
|
| 4 |
+ preprocess(config, |
|
| 5 |
+ in_fn=home_fn('tap-win32/SOURCES.in'),
|
|
| 6 |
+ out_fn=home_fn('tap-win32/SOURCES'),
|
|
| 7 |
+ quote_begin='@@', |
|
| 8 |
+ quote_end='@@', |
|
| 9 |
+ head_comment='# %s\n\n' % autogen) |
|
| 10 |
+ |
|
| 11 |
+ preprocess(config, |
|
| 12 |
+ in_fn=home_fn('tap-win32/i386/OemWin2k.inf.in'),
|
|
| 13 |
+ out_fn=home_fn('tap-win32/i386/OemWin2k.inf'),
|
|
| 14 |
+ quote_begin='@@', |
|
| 15 |
+ quote_end='@@', |
|
| 16 |
+ if_prefix='!', |
|
| 17 |
+ head_comment='; %s\n\n' % autogen) |
|
| 18 |
+ |
|
| 19 |
+ try: |
|
| 20 |
+ os.mkdir(home_fn('tap-win32/amd64'))
|
|
| 21 |
+ except: |
|
| 22 |
+ pass |
|
| 23 |
+ preprocess(dict_def(config, [('AMD64', '1')]),
|
|
| 24 |
+ in_fn=home_fn('tap-win32/i386/OemWin2k.inf.in'),
|
|
| 25 |
+ out_fn=home_fn('tap-win32/amd64/OemWin2k.inf'),
|
|
| 26 |
+ quote_begin='@@', |
|
| 27 |
+ quote_end='@@', |
|
| 28 |
+ if_prefix='!', |
|
| 29 |
+ head_comment='; %s\n\n' % autogen) |
|
| 30 |
+ |
|
| 31 |
+# if we are run directly, and not loaded as a module |
|
| 32 |
+if __name__ == "__main__": |
|
| 33 |
+ from wb import config |
|
| 34 |
+ main(config) |
| 0 | 35 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,18 @@ |
| 0 |
+import os, shutil |
|
| 1 |
+from wb import preprocess, home_fn, autogen |
|
| 2 |
+ |
|
| 3 |
+def main(config): |
|
| 4 |
+ src = os.path.join(home_fn(config['TISRC']), config['DDKVER_MAJOR']) |
|
| 5 |
+ dest = home_fn('tapinstall')
|
|
| 6 |
+ shutil.rmtree(dest, ignore_errors=True) |
|
| 7 |
+ shutil.copytree(src, dest) |
|
| 8 |
+ preprocess(config, |
|
| 9 |
+ in_fn=os.path.join(dest, 'sources.in'), |
|
| 10 |
+ out_fn=os.path.join(dest, 'sources'), |
|
| 11 |
+ if_prefix='!', |
|
| 12 |
+ head_comment='# %s\n\n' % autogen) |
|
| 13 |
+ |
|
| 14 |
+# if we are run directly, and not loaded as a module |
|
| 15 |
+if __name__ == "__main__": |
|
| 16 |
+ from wb import config |
|
| 17 |
+ main(config) |
| 0 | 10 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,54 @@ |
| 0 |
+import os |
|
| 1 |
+from wb import home_fn, rm_rf, mkdir, cp_a, cp |
|
| 2 |
+ |
|
| 3 |
+def main(config): |
|
| 4 |
+ dist = config['DIST'] |
|
| 5 |
+ assert dist |
|
| 6 |
+ dist = home_fn(dist) |
|
| 7 |
+ bin = os.path.join(dist, 'bin') |
|
| 8 |
+ i386 = os.path.join(dist, 'i386') |
|
| 9 |
+ amd64 = os.path.join(dist, 'amd64') |
|
| 10 |
+ |
|
| 11 |
+ # build dist and subdirectories |
|
| 12 |
+ rm_rf(dist) |
|
| 13 |
+ mkdir(dist) |
|
| 14 |
+ mkdir(bin) |
|
| 15 |
+ mkdir(i386) |
|
| 16 |
+ mkdir(amd64) |
|
| 17 |
+ |
|
| 18 |
+ # copy openvpn.exe and manifest |
|
| 19 |
+ cp(home_fn('openvpn.exe'), bin)
|
|
| 20 |
+ cp(home_fn('openvpn.exe.manifest'), bin)
|
|
| 21 |
+ |
|
| 22 |
+ # copy DLL dependencies |
|
| 23 |
+ cp(home_fn(config['LZO_DIR']+'/bin/lzo2.dll'), bin) |
|
| 24 |
+ cp(home_fn(config['OPENSSL_DIR']+'/bin/libeay32.dll'), bin) |
|
| 25 |
+ cp(home_fn(config['OPENSSL_DIR']+'/bin/ssleay32.dll'), bin) |
|
| 26 |
+ |
|
| 27 |
+ # copy MSVC CRT |
|
| 28 |
+ cp_a(home_fn(config['MSVC_CRT']), bin) |
|
| 29 |
+ |
|
| 30 |
+ # copy TAP drivers |
|
| 31 |
+ for dir_name, dest in (('amd64', amd64), ('i386', i386)):
|
|
| 32 |
+ dir = home_fn(os.path.join('tap-win32', dir_name))
|
|
| 33 |
+ for dirpath, dirnames, filenames in os.walk(dir): |
|
| 34 |
+ for f in filenames: |
|
| 35 |
+ root, ext = os.path.splitext(f) |
|
| 36 |
+ if ext in ('.inf', '.cat', '.sys'):
|
|
| 37 |
+ cp(os.path.join(dir, f), dest) |
|
| 38 |
+ break |
|
| 39 |
+ |
|
| 40 |
+ # copy tapinstall |
|
| 41 |
+ dest = {'amd64' : amd64, 'i386' : i386}
|
|
| 42 |
+ for dirpath, dirnames, filenames in os.walk(home_fn('tapinstall')):
|
|
| 43 |
+ for f in filenames: |
|
| 44 |
+ if f == 'tapinstall.exe': |
|
| 45 |
+ dir_name = os.path.basename(dirpath) |
|
| 46 |
+ src = os.path.join(dirpath, f) |
|
| 47 |
+ if dir_name in dest: |
|
| 48 |
+ cp(src, dest[dir_name]) |
|
| 49 |
+ |
|
| 50 |
+# if we are run directly, and not loaded as a module |
|
| 51 |
+if __name__ == "__main__": |
|
| 52 |
+ from wb import config |
|
| 53 |
+ main(config) |
| 0 | 54 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,52 @@ |
| 0 |
+# This makefile builds the user-mode component |
|
| 1 |
+# of OpenVPN for Windows in the Visual Studio 2008 environment. |
|
| 2 |
+ |
|
| 3 |
+# To build: |
|
| 4 |
+# python win\config.py |
|
| 5 |
+# nmake /f msvc.mak |
|
| 6 |
+ |
|
| 7 |
+# Each of the OPENSSL and LZO dirs should have 'lib' and 'include' |
|
| 8 |
+# directories under them. |
|
| 9 |
+ |
|
| 10 |
+OPENSSL = @OPENSSL_DIR@ |
|
| 11 |
+OPENSSL_DYNAMIC = libeay32.lib ssleay32.lib |
|
| 12 |
+ |
|
| 13 |
+LZO = @LZO_DIR@ |
|
| 14 |
+LZO_DYNAMIC = lzo2.lib |
|
| 15 |
+ |
|
| 16 |
+INCLUDE_DIRS = -I$(OPENSSL)/include -I$(LZO)/include |
|
| 17 |
+ |
|
| 18 |
+LIBS = $(OPENSSL_DYNAMIC) $(LZO_DYNAMIC) ws2_32.lib crypt32.lib iphlpapi.lib winmm.lib user32.lib gdi32.lib advapi32.lib wininet.lib |
|
| 19 |
+ |
|
| 20 |
+LIB_DIRS = -LIBPATH:$(OPENSSL)\lib -LIBPATH:$(LZO)\lib |
|
| 21 |
+ |
|
| 22 |
+EXE = openvpn.exe |
|
| 23 |
+ |
|
| 24 |
+CPP=cl.exe |
|
| 25 |
+CPP_ARG_COMMON=/nologo /W3 /O2 -DWIN32 -DWIN32_LEAN_AND_MEAN -D_CONSOLE -D_MBCS -D_CRT_SECURE_NO_DEPRECATE $(INCLUDE_DIRS) /FD /c |
|
| 26 |
+# release: |
|
| 27 |
+CPP_PROJ=$(CPP_ARG_COMMON) /MD -DNDEBUG |
|
| 28 |
+# debug: |
|
| 29 |
+#CPP_PROJ=$(CPP_ARG_COMMON) /MDd /Zi /Od -D_DEBUG |
|
| 30 |
+ |
|
| 31 |
+LINK32=link.exe |
|
| 32 |
+# release: |
|
| 33 |
+LINK32_FLAGS=/nologo /subsystem:console /incremental:no /out:"$(EXE)" |
|
| 34 |
+# debug: |
|
| 35 |
+#LINK32_FLAGS=/nologo /subsystem:console /incremental:no /debug /out:"$(EXE)" |
|
| 36 |
+ |
|
| 37 |
+# HEADERS and OBJS definitions, automatically generated |
|
| 38 |
+@HEADERS_OBJS@ |
|
| 39 |
+ |
|
| 40 |
+openvpn : $(OBJS) |
|
| 41 |
+ $(LINK32) @<< |
|
| 42 |
+ $(LINK32_FLAGS) $(LIB_DIRS) $(LIBS) $(OBJS) |
|
| 43 |
+<< |
|
| 44 |
+ |
|
| 45 |
+clean : |
|
| 46 |
+ del /Q $(OBJS) $(EXE) *.idb *.pdb |
|
| 47 |
+ |
|
| 48 |
+.c.obj:: |
|
| 49 |
+ $(CPP) @<< |
|
| 50 |
+ $(CPP_PROJ) $< |
|
| 51 |
+<< |
| 0 | 52 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,62 @@ |
| 0 |
+# Version numbers, settings, and dependencies |
|
| 1 |
+# for Windows OpenVPN installer. |
|
| 2 |
+ |
|
| 3 |
+# Branding |
|
| 4 |
+!define PRODUCT_NAME "OpenVPN" |
|
| 5 |
+!define PRODUCT_UNIX_NAME "openvpn" |
|
| 6 |
+!define PRODUCT_FILE_EXT "ovpn" |
|
| 7 |
+ |
|
| 8 |
+# Allow --askpass and --auth-user-pass passwords to be read from a file |
|
| 9 |
+;!define ENABLE_PASSWORD_SAVE |
|
| 10 |
+ |
|
| 11 |
+# Include the OpenVPN GUI exe in the installer. |
|
| 12 |
+# May be undefined. |
|
| 13 |
+!define OPENVPN_GUI_DIR "../openvpn-gui" |
|
| 14 |
+!define OPENVPN_GUI "openvpn-gui-1.0.3.exe" |
|
| 15 |
+ |
|
| 16 |
+# Prebuilt libraries. DMALLOC is optional. |
|
| 17 |
+!define OPENSSL_DIR "../openssl" |
|
| 18 |
+!define LZO_DIR "../lzo" |
|
| 19 |
+ |
|
| 20 |
+# write output files here |
|
| 21 |
+!define DIST "dist" |
|
| 22 |
+ |
|
| 23 |
+# tapinstall.exe source code. |
|
| 24 |
+# Not needed if DRVBINSRC is defined |
|
| 25 |
+# (or if using pre-built mode). |
|
| 26 |
+!define TISRC "../tapinstall" |
|
| 27 |
+ |
|
| 28 |
+# TAP Adapter parameters. Note that PRODUCT_TAP_ID is |
|
| 29 |
+# defined in version.m4. |
|
| 30 |
+!define PRODUCT_TAP_DEVICE_DESCRIPTION "TAP-Win32 Adapter V9" |
|
| 31 |
+!define PRODUCT_TAP_PROVIDER "TAP-Win32 Provider V9" |
|
| 32 |
+!define PRODUCT_TAP_MAJOR_VER 9 |
|
| 33 |
+!define PRODUCT_TAP_MINOR_VER 7 |
|
| 34 |
+!define PRODUCT_TAP_RELDATE "04/19/2010" |
|
| 35 |
+ |
|
| 36 |
+# TAP adapter icon -- visible=0x81 or hidden=0x89 |
|
| 37 |
+!define PRODUCT_TAP_CHARACTERISTICS 0x81 |
|
| 38 |
+ |
|
| 39 |
+# Build debugging version of TAP driver |
|
| 40 |
+;!define PRODUCT_TAP_DEBUG |
|
| 41 |
+ |
|
| 42 |
+# DDK path -- currently Windows 7 WDK |
|
| 43 |
+!define DDK_PATH "c:/winddk/7600.16385.1" |
|
| 44 |
+;!define DDK_PATH "c:/winddk/6001.18002" |
|
| 45 |
+ |
|
| 46 |
+# Visual studio path |
|
| 47 |
+!define MSVC "C:/Program Files/Microsoft Visual Studio 9.0" |
|
| 48 |
+ |
|
| 49 |
+# Visual studio C run-time library path |
|
| 50 |
+!define MSVC_CRT "../Microsoft.VC90.CRT" |
|
| 51 |
+ |
|
| 52 |
+# Code Signing. |
|
| 53 |
+# If undefined, don't sign any files. |
|
| 54 |
+!define SIGNTOOL "../signtool" |
|
| 55 |
+!define PRODUCT_SIGN_CN "openvpn" |
|
| 56 |
+ |
|
| 57 |
+; DEBUGGING -- set to something like "-DBG2" |
|
| 58 |
+!define OUTFILE_LABEL "" |
|
| 59 |
+ |
|
| 60 |
+; DEBUGGING -- set to something like "DEBUG2" |
|
| 61 |
+!define TITLE_LABEL "" |
| 0 | 10 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,19 @@ |
| 0 |
+import sys |
|
| 1 |
+from wb import config, choose_arch, home_fn |
|
| 2 |
+ |
|
| 3 |
+if 'SIGNTOOL' in config: |
|
| 4 |
+ sys.path.append(home_fn(config['SIGNTOOL'])) |
|
| 5 |
+ |
|
| 6 |
+def main(conf, arch): |
|
| 7 |
+ from signtool import SignTool |
|
| 8 |
+ st = SignTool(conf) |
|
| 9 |
+ for x64 in choose_arch(arch): |
|
| 10 |
+ st.sign_verify(x64=x64) |
|
| 11 |
+ |
|
| 12 |
+# if we are run directly, and not loaded as a module |
|
| 13 |
+if __name__ == "__main__": |
|
| 14 |
+ if len(sys.argv) >= 2: |
|
| 15 |
+ main(config, sys.argv[1]) |
|
| 16 |
+ else: |
|
| 17 |
+ print "usage: sign <x64|x86|all>" |
|
| 18 |
+ sys.exit(2) |
| 0 | 19 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,185 @@ |
| 0 |
+# Python module containing general build functions |
|
| 1 |
+# for OpenVPN on Windows |
|
| 2 |
+ |
|
| 3 |
+import os, re, shutil |
|
| 4 |
+ |
|
| 5 |
+autogen = "Automatically generated by OpenVPN Windows build system" |
|
| 6 |
+ |
|
| 7 |
+def get_config(): |
|
| 8 |
+ kv = {}
|
|
| 9 |
+ parse_version_m4(kv, home_fn('version.m4'))
|
|
| 10 |
+ parse_settings_in(kv, mod_fn('settings.in'))
|
|
| 11 |
+ |
|
| 12 |
+ # config fixups |
|
| 13 |
+ kv['DDKVER'] = os.path.basename(kv['DDK_PATH']) |
|
| 14 |
+ kv['DDKVER_MAJOR'] = re.match(r'^(\d+)\.', kv['DDKVER']).groups()[0] |
|
| 15 |
+ |
|
| 16 |
+ if 'VERSION_SUFFIX' in kv: |
|
| 17 |
+ kv['PRODUCT_VERSION'] += kv['VERSION_SUFFIX'] |
|
| 18 |
+ |
|
| 19 |
+ return kv |
|
| 20 |
+ |
|
| 21 |
+def mod_fn(fn, src=__file__, real=True): |
|
| 22 |
+ p = os.path.join(os.path.dirname(src), os.path.normpath(fn)) |
|
| 23 |
+ if real: |
|
| 24 |
+ p = os.path.realpath(p) |
|
| 25 |
+ return p |
|
| 26 |
+ |
|
| 27 |
+def home_fn(fn, real=True): |
|
| 28 |
+ return mod_fn(os.path.join('..', fn), real=real)
|
|
| 29 |
+ |
|
| 30 |
+def cd_home(): |
|
| 31 |
+ os.chdir(os.path.join(os.path.dirname(__file__), '..')) |
|
| 32 |
+ |
|
| 33 |
+def system(cmd): |
|
| 34 |
+ print "RUN:", cmd |
|
| 35 |
+ os.system(cmd) |
|
| 36 |
+ |
|
| 37 |
+def parse_version_m4(kv, version_m4): |
|
| 38 |
+ r = re.compile(r'^define\((\w+),\[(.*)\]\)$') |
|
| 39 |
+ f = open(version_m4) |
|
| 40 |
+ for line in f: |
|
| 41 |
+ line = line.rstrip() |
|
| 42 |
+ m = re.match(r, line) |
|
| 43 |
+ if m: |
|
| 44 |
+ g = m.groups() |
|
| 45 |
+ kv[g[0]] = g[1] |
|
| 46 |
+ f.close() |
|
| 47 |
+ |
|
| 48 |
+def parse_settings_in(kv, settings_in): |
|
| 49 |
+ r = re.compile(r'^!define\s+(\w+)(?:\s+"?(.*?)"?)?$') |
|
| 50 |
+ f = open(settings_in) |
|
| 51 |
+ for line in f: |
|
| 52 |
+ line = line.rstrip() |
|
| 53 |
+ m = re.match(r, line) |
|
| 54 |
+ if m: |
|
| 55 |
+ g = m.groups() |
|
| 56 |
+ kv[g[0]] = g[1] or '' |
|
| 57 |
+ f.close() |
|
| 58 |
+ |
|
| 59 |
+def dict_def(dict, newdefs): |
|
| 60 |
+ ret = dict.copy() |
|
| 61 |
+ ret.update(newdefs) |
|
| 62 |
+ return ret |
|
| 63 |
+ |
|
| 64 |
+def build_autodefs(kv, autodefs_in, autodefs_out): |
|
| 65 |
+ preprocess(kv, |
|
| 66 |
+ in_fn=autodefs_in, |
|
| 67 |
+ out_fn=autodefs_out, |
|
| 68 |
+ quote_begin='@', |
|
| 69 |
+ quote_end='@', |
|
| 70 |
+ head_comment='/* %s */\n\n' % autogen) |
|
| 71 |
+ |
|
| 72 |
+def preprocess(kv, in_fn, out_fn, quote_begin=None, quote_end=None, if_prefix=None, head_comment=None): |
|
| 73 |
+ def repfn(m): |
|
| 74 |
+ var, = m.groups() |
|
| 75 |
+ return kv.get(var, '') |
|
| 76 |
+ |
|
| 77 |
+ re_macro = re_ifdef = None |
|
| 78 |
+ |
|
| 79 |
+ if quote_begin and quote_end: |
|
| 80 |
+ re_macro = re.compile(r'%s(\w+)%s' % (re.escape(quote_begin), re.escape(quote_end))) |
|
| 81 |
+ |
|
| 82 |
+ if if_prefix: |
|
| 83 |
+ re_ifdef = re.compile(r'^\s*%sifdef\s+(\w+)\b' % (re.escape(if_prefix),)) |
|
| 84 |
+ re_else = re.compile(r'^\s*%selse\b' % (re.escape(if_prefix),)) |
|
| 85 |
+ re_endif = re.compile(r'^\s*%sendif\b' % (re.escape(if_prefix),)) |
|
| 86 |
+ |
|
| 87 |
+ if_stack = [] |
|
| 88 |
+ fin = open(in_fn) |
|
| 89 |
+ fout = open(out_fn, 'w') |
|
| 90 |
+ if head_comment: |
|
| 91 |
+ fout.write(head_comment) |
|
| 92 |
+ for line in fin: |
|
| 93 |
+ if re_ifdef: |
|
| 94 |
+ m = re.match(re_ifdef, line) |
|
| 95 |
+ if m: |
|
| 96 |
+ var, = m.groups() |
|
| 97 |
+ if_stack.append(int(var in kv)) |
|
| 98 |
+ continue |
|
| 99 |
+ elif re.match(re_else, line): |
|
| 100 |
+ if_stack[-1] ^= 1 |
|
| 101 |
+ continue |
|
| 102 |
+ elif re.match(re_endif, line): |
|
| 103 |
+ if_stack.pop() |
|
| 104 |
+ continue |
|
| 105 |
+ if not if_stack or min(if_stack): |
|
| 106 |
+ if re_macro: |
|
| 107 |
+ line = re.sub(re_macro, repfn, line) |
|
| 108 |
+ fout.write(line) |
|
| 109 |
+ assert not if_stack |
|
| 110 |
+ fin.close() |
|
| 111 |
+ fout.close() |
|
| 112 |
+ |
|
| 113 |
+def print_key_values(kv): |
|
| 114 |
+ for k, v in sorted(kv.items()): |
|
| 115 |
+ print "%s%s%s" % (k, ' '*(32-len(k)), repr(v)) |
|
| 116 |
+ |
|
| 117 |
+def get_sources(makefile_am): |
|
| 118 |
+ c = set() |
|
| 119 |
+ h = set() |
|
| 120 |
+ f = open(makefile_am) |
|
| 121 |
+ state = False |
|
| 122 |
+ for line in f: |
|
| 123 |
+ line = line.rstrip() |
|
| 124 |
+ if line == 'openvpn_SOURCES = \\': |
|
| 125 |
+ state = True |
|
| 126 |
+ elif not line: |
|
| 127 |
+ state = False |
|
| 128 |
+ elif state: |
|
| 129 |
+ for sf in line.split(): |
|
| 130 |
+ if sf.endswith('.c'):
|
|
| 131 |
+ c.add(sf[:-2]) |
|
| 132 |
+ elif sf.endswith('.h'):
|
|
| 133 |
+ h.add(sf[:-2]) |
|
| 134 |
+ elif sf == '\\': |
|
| 135 |
+ pass |
|
| 136 |
+ else: |
|
| 137 |
+ print >>sys.stderr, "Unrecognized filename:", sf |
|
| 138 |
+ f.close() |
|
| 139 |
+ return [ sorted(list(s)) for s in (c, h) ] |
|
| 140 |
+ |
|
| 141 |
+def output_mak_list(title, srclist, ext): |
|
| 142 |
+ ret = "%s =" % (title,) |
|
| 143 |
+ for x in srclist: |
|
| 144 |
+ ret += " \\\n\t%s.%s" % (x, ext) |
|
| 145 |
+ ret += '\n\n' |
|
| 146 |
+ return ret |
|
| 147 |
+ |
|
| 148 |
+def make_headers_objs(makefile_am): |
|
| 149 |
+ c, h = get_sources(makefile_am) |
|
| 150 |
+ ret = output_mak_list('HEADERS', h, 'h')
|
|
| 151 |
+ ret += output_mak_list('OBJS', c, 'obj')
|
|
| 152 |
+ return ret |
|
| 153 |
+ |
|
| 154 |
+def choose_arch(arch_name): |
|
| 155 |
+ if arch_name == 'x64': |
|
| 156 |
+ return (True,) |
|
| 157 |
+ elif arch_name == 'x86': |
|
| 158 |
+ return (False,) |
|
| 159 |
+ elif arch_name == 'all': |
|
| 160 |
+ return (True, False) |
|
| 161 |
+ else: |
|
| 162 |
+ raise ValueError("architecture ('%s') must be x86, x64, or all" % (arch_name,))
|
|
| 163 |
+ |
|
| 164 |
+def rm_rf(dir): |
|
| 165 |
+ print "REMOVE", dir |
|
| 166 |
+ shutil.rmtree(dir, ignore_errors=True) |
|
| 167 |
+ |
|
| 168 |
+def mkdir(dir): |
|
| 169 |
+ print "MKDIR", dir |
|
| 170 |
+ os.mkdir(dir) |
|
| 171 |
+ |
|
| 172 |
+def cp_a(src, dest, dest_is_dir=True): |
|
| 173 |
+ if dest_is_dir: |
|
| 174 |
+ dest = os.path.join(dest, os.path.basename(src)) |
|
| 175 |
+ print "COPY_DIR %s %s" % (src, dest) |
|
| 176 |
+ shutil.copytree(src, dest) |
|
| 177 |
+ |
|
| 178 |
+def cp(src, dest, dest_is_dir=True): |
|
| 179 |
+ if dest_is_dir: |
|
| 180 |
+ dest = os.path.join(dest, os.path.basename(src)) |
|
| 181 |
+ print "COPY %s %s" % (src, dest) |
|
| 182 |
+ shutil.copyfile(src, dest) |
|
| 183 |
+ |
|
| 184 |
+config = get_config() |