build revolution
PATCH 38/52 build: properly process lzo-stub
In reply to Alon Bar-Lev--- 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
@@ -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
@@ -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
@@ -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
@@ -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 -12
@@ -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
Signature · 1 line
1.7.3.4
Re: [Openvpn-devel] [PATCH 38/52] build: properly process lzo-stub
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
Signed-off-by Alon Bar-Lev <[email protected]...>--- 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@@ -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@@ -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@@ -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@@ -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@@ -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
PATCH 39/52 build: proper lzo detection and usage
In reply to Alon Bar-Lev--- configure.ac | 101 ++++++++++++++++++++--------------------- distro/rpm/openvpn.spec.in | 2 +- doc/doxygen/doc_compression.h | 2 +- src/openvpn/Makefile.am | 2 + src/openvpn/forward.c | 4 +- src/openvpn/init.c | 14 +++--- src/openvpn/lzo.c | 4 +- src/openvpn/lzo.h | 13 +++-- src/openvpn/openvpn.h | 4 +- src/openvpn/options.c | 18 +++++--- src/openvpn/options.h | 2 +- src/openvpn/sig.c | 2 +- 12 files changed, 87 insertions(+), 81 deletions(-)
configure.ac +49 -52
@@ -41,9 +41,9 @@ AC_USE_SYSTEM_EXTENSIONS AC_ARG_ENABLE( [lzo], - [AS_HELP_STRING([--disable-lzo], [disable LZO compression support])], + [AS_HELP_STRING([--enable-lzo], [enable LZO compression support])], , - [enable_lzo="yes"] + [enable_lzo="no"] ) AC_ARG_ENABLE(
@@ -241,19 +241,6 @@ AC_ARG_WITH( ) AC_ARG_WITH( - [lzo-headers], - [AS_HELP_STRING([--with-lzo-headers=DIR], [LZO Include files location])], - [LZO_HDR_DIR="$withval"] - [CPPFLAGS="$CPPFLAGS -I$withval"] -) - -AC_ARG_WITH( - [lzo-lib], - [AS_HELP_STRING([--with-lzo-lib=DIR], [LZO 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])], [
@@ -664,41 +651,44 @@ case "${with_mem_check}" in ;; esac -dnl -dnl check for LZO library -dnl -if test "${enable_lzo}" = "yes" && test "${enable_lzo_stub}" = "no"; then - LZO_H="" - AC_CHECKING([for LZO Library and Header files]) - AC_CHECK_HEADER(lzo/lzo1x.h, - [ LZO_H="2" - lzolibs="lzo2 lzo" - AC_DEFINE(LZO_HEADER_DIR, 1, [Use lzo/ directory prefix for LZO header files (for LZO 2.0)]) - ], - [ AC_CHECK_HEADER(lzo1x.h, [ LZO_H="1" ; lzolibs=lzo ]) ] - ) - - if test -n "$LZO_H"; then - havelzolib=0 - for i in $lzolibs ; do - if test $havelzolib = 1 ; then break ; fi - AC_CHECK_LIB($i, lzo1x_1_15_compress, - [ - 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 - ] - ) - done - if test $havelzolib = 0 ; then - AC_MSG_ERROR([LZO headers were found but LZO library was not found]) - fi - else - AC_MSG_RESULT([LZO headers were not found]) - AC_MSG_RESULT([LZO library available from http://www.oberhumer.com/opensource/lzo/]) - AC_MSG_ERROR([Or try ./configure --disable-lzo OR ./configure --enable-lzo-stub]) - fi +AC_ARG_VAR([LZO_CFLAGS], [C compiler flags for lzo]) +AC_ARG_VAR([LZO_LIBS], [linker flags for lzo]) +have_lzo="yes" +if test -z "${LZO_LIBS}"; then + AC_CHECK_LIB( + [lzo2], + [lzo1x_1_15_compress], + [LZO_LIBS="-llzo2"], + [AC_CHECK_LIB( + [lzo], + [lzo1x_1_15_compress], + [LZO_LIBS="-llzo"], + [have_lzo="no"] + )] + ) +fi +if test "${have_lzo}" = "yes"; then + saved_CFLAGS="${CFLAGS}" + CFLAGS="${CFLAGS} ${LZO_CFLAGS}" + AC_CHECK_HEADERS( + [lzo/lzoutil.h], + , + [AC_CHECK_HEADERS( + [lzoutil.h], + , + [AC_MSG_ERROR([lzoutil.h is missing])] + )] + ) + AC_CHECK_HEADERS( + [lzo/lzo1x.h], + , + [AC_CHECK_HEADERS( + [lzo1x.h], + , + [AC_MSG_ERROR([lzo1x.h is missing])] + )] + ) + CFLAGS="${saved_CFLAGS}" fi PKG_CHECK_MODULES(
@@ -862,11 +852,16 @@ if test "${enable_selinux}" = "yes"; then AC_DEFINE([ENABLE_SELINUX], [1], [SELinux support]) fi +if test "${enable_lzo}" = "yes"; then + test "${have_lzo}" != "yes" && AC_MSG_ERROR([lzo enabled but missing]) + OPTIONAL_LZO_CFLAGS="${LZO_CFLAGS}" + OPTIONAL_LZO_LIBS="${LZO_LIBS}" + AC_DEFINE([ENABLE_LZO], [1], [Enable LZO compression library]) +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]) + AC_DEFINE([ENABLE_LZO], [1], [Enable LZO compression library]) fi if test "${enable_pkcs11}" = "yes"; then
@@ -904,6 +899,8 @@ AC_SUBST([TAP_WIN_MIN_MINOR]) AC_SUBST([OPTIONAL_DL_LIBS]) AC_SUBST([OPTIONAL_SELINUX_LIBS]) +AC_SUBST([OPTIONAL_LZO_CFLAGS]) +AC_SUBST([OPTIONAL_LZO_LIBS]) AC_SUBST([OPTIONAL_PKCS11_HELPER_CFLAGS]) AC_SUBST([OPTIONAL_PKCS11_HELPER_LIBS])
distro/rpm/openvpn.spec.in +1 -1
@@ -110,7 +110,7 @@ Development support for OpenVPN. --disable-dependency-tracking \ --docdir="%{_docdir}/%{name}-%{version}" \ %{?with_password_save:--enable-password-save} \ - %{?without_lzo:--disable-lzo} \ + %{!?without_lzo:--enable-lzo} \ %{?with_pkcs11:--enable-pkcs11} \ %{?with_kerberos:--with-ssl-headers=/usr/kerberos/include} %__make
doc/doxygen/doc_compression.h +1 -1
@@ -68,7 +68,7 @@* * @par Settings that control this module's activity * Whether or not the Data Channel Compression module is active depends on -* the compile-time \c USE_LZO preprocessor macro and the runtime flags +* the compile-time \c ENABLE_LZO preprocessor macro and the runtime flags * stored in \c lzo_compress_workspace.flags of the associated VPN tunnel. * The latter are initialized from \c options.lzo, which gets its value * from the process's configuration sources, such as its configuration
src/openvpn/Makefile.am +2 -0
@@ -17,6 +17,7 @@ MAINTAINERCLEANFILES = \ INCLUDES = -I$(top_srcdir)/include AM_CFLAGS = \ + $(OPTIONAL_LZO_CFLAGS) \ $(OPTIONAL_PKCS11_HELPER_CFLAGS) sbin_PROGRAMS = openvpn
@@ -100,6 +101,7 @@ openvpn_SOURCES = \ cryptoapi.h cryptoapi.c openvpn_LDADD = \ $(SOCKETS_LIBS) \ + $(OPTIONAL_LZO_LIBS) \ $(OPTIONAL_PKCS11_HELPER_LIBS) \ $(OPTIONAL_SELINUX_LIBS) \ $(OPTIONAL_DL_LIBS)
src/openvpn/forward.c +2 -2
@@ -438,7 +438,7 @@ encrypt_sign (struct context *c, bool comp_frag)if (comp_frag) { -#ifdef USE_LZO +#ifdef ENABLE_LZO /* Compress the packet. */ if (lzo_defined (&c->c2.lzo_compwork))lzo_compress (&c->c2.buf, b->lzo_compress_buf, &c->c2.lzo_compwork, &c->c2.frame);
@@ -840,7 +840,7 @@ process_incoming_link (struct context *c)fragment_incoming (c->c2.fragment, &c->c2.buf, &c->c2.frame_fragment);#endif -#ifdef USE_LZO +#ifdef ENABLE_LZO /* decompress the incoming packet */ if (lzo_defined (&c->c2.lzo_compwork))lzo_decompress (&c->c2.buf, c->c2.buffers->lzo_decompress_buf, &c->c2.lzo_compwork, &c->c2.frame);
src/openvpn/init.c +7 -7
@@ -1789,7 +1789,7 @@ do_deferred_options (struct context *c, const unsigned int found) }#endif -#ifdef USE_LZO +#ifdef ENABLE_LZO if (found &OPT_P_COMP ) {if (lzo_defined (&c->c2.lzo_compwork))
@@ -2370,7 +2370,7 @@ do_init_crypto (struct context *c, const unsigned int flags)static void do_init_frame (struct context *c) { -#ifdef USE_LZO +#ifdef ENABLE_LZO /* * Initialize LZO compression library. */
@@ -2393,7 +2393,7 @@ do_init_frame (struct context *c)lzo_adjust_frame_parameters (&c->c2.frame_fragment_omit);/* omit LZO frame delta from final frame_fragment */ #endif } -#endif /* USE_LZO */ +#endif /* ENABLE_LZO */ #ifdef ENABLE_SOCKS /*
@@ -2564,7 +2564,7 @@ init_context_buffers (const struct frame *frame) b->decrypt_buf =alloc_buf (BUF_SIZE (frame));#endif -#ifdef USE_LZO +#ifdef ENABLE_LZO b->lzo_compress_buf =alloc_buf (BUF_SIZE (frame)); b->lzo_decompress_buf =alloc_buf (BUF_SIZE (frame));#endif
@@ -2581,7 +2581,7 @@ free_context_buffers (struct context_buffers *b)free_buf (&b->read_tun_buf);free_buf (&b->aux_buf); -#ifdef USE_LZO +#ifdef ENABLE_LZO free_buf (&b->lzo_compress_buf);free_buf (&b->lzo_decompress_buf);#endif
@@ -3419,7 +3419,7 @@ init_instance (struct context *c, const struct env_set *env, const unsigned int goto sig; } -#ifdef USE_LZO +#ifdef ENABLE_LZO /* initialize LZO compression library. */ if ((options->lzo &LZO_SELECTED ) && (c->mode ==CM_P2P || child))lzo_compress_init (&c->c2.lzo_compwork, options->lzo);
@@ -3536,7 +3536,7 @@ close_instance (struct context *c)/* if xinetd/inetd mode, don't allow restart */ do_close_check_if_restart_permitted (c); -#ifdef USE_LZO +#ifdef ENABLE_LZO if (lzo_defined (&c->c2.lzo_compwork))lzo_compress_uninit (&c->c2.lzo_compwork);#endif
src/openvpn/lzo.c +2 -2
@@ -28,7 +28,7 @@#include "syshead.h" -#ifdef USE_LZO +#ifdef ENABLE_LZO #include "lzo.h" #include "error.h"
@@ -301,4 +301,4 @@ void lzo_print_stats (const struct lzo_compress_workspace *lzo_compwork, struct#else static void dummy (void ) {} -#endif /* USE_LZO */ +#endif /* ENABLE_LZO */
src/openvpn/lzo.h +8 -5
@@ -32,7 +32,7 @@*/ -#ifdef USE_LZO +#ifdef ENABLE_LZO /** * @addtogroup compression
@@ -40,11 +40,14 @@*/ #ifndef ENABLE_LZO_STUB -#ifdef LZO_HEADER_DIR +#if defined(HAVE_LZO_LZOUTIL_H )#include "lzo/lzoutil.h" -#include "lzo/lzo1x.h" -#else +#elif defined(HAVE_LZOUTIL_H )#include "lzoutil.h" +#endif +#if defined(HAVE_LZO_LZO1X_H ) +#include "lzo/lzo1x.h" +#elif defined(HAVE_LZO1X_H )#include "lzo1x.h" #endif #endif
@@ -340,5 +343,5 @@ lzo_defined (const struct lzo_compress_workspace *lzowork)/** @} addtogroup compression */ -#endif /* USE_LZO */ +#endif /* ENABLE_LZO */ #endif
src/openvpn/openvpn.h +2 -2
@@ -105,7 +105,7 @@ struct context_buffers#endif /* workspace buffers for LZO compression */ -#ifdef USE_LZO +#ifdef ENABLE_LZO struct buffer lzo_compress_buf;struct buffer lzo_decompress_buf;#endif
@@ -372,7 +372,7 @@ struct context_2#endif /* USE_CRYPTO */ -#ifdef USE_LZO +#ifdef ENABLE_LZO struct lzo_compress_workspace lzo_compwork;/**< Compression workspace used by the * \link compression Data Channel
src/openvpn/options.c +11 -7
@@ -75,8 +75,12 @@ const char title_string[] =#endif /* defined(USE_POLARSSL) */ #endif /* USE_SSL */ #endif /* USE_CRYPTO */ -#ifdef USE_LZO - " [LZO" LZO_VERSION_NUM "]" +#ifdef ENABLE_LZO +#ifdef ENABLE_LZO_STUB +" [LZO (STUB)]" +#else + " [LZO]" +#endif #endif #if EPOLL " [EPOLL]"
@@ -354,7 +358,7 @@ static const char usage_message[] =#ifdef ENABLE_DEBUG "--gremlin mask : Special stress testing mode (for debugging only).\n"#endif -#ifdef USE_LZO +#ifdef ENABLE_LZO "--comp-lzo : Use fast LZO compression -- may add up to 1 byte per\n" " packet for uncompressible data.\n" "--comp-noadapt : Don't use adaptive compression when --comp-lzo\n"
@@ -1512,7 +1516,7 @@ show_settings (const struct options *o)SHOW_BOOL (fast_io); -#ifdef USE_LZO +#ifdef ENABLE_LZO SHOW_INT (lzo);#endif
@@ -2954,7 +2958,7 @@ options_string (const struct options *o, tt =NULL ; } -#ifdef USE_LZO +#ifdef ENABLE_LZO if (o->lzo &LZO_SELECTED )buf_printf (&out,",comp-lzo" );#endif
@@ -6180,7 +6184,7 @@ add_option (struct options *options, options->passtos = true; }#endif -#ifdef USE_LZO +#ifdef ENABLE_LZO else if (streq (p[0], "comp-lzo")) {VERIFY_PERMISSION (OPT_P_COMP );
@@ -6206,7 +6210,7 @@ add_option (struct options *options,VERIFY_PERMISSION (OPT_P_COMP ); options->lzo &= ~LZO_ADAPTIVE ; } -#endif /* USE_LZO */ +#endif /* ENABLE_LZO */ #ifdef USE_CRYPTO else if (streq (p[0], "show-ciphers")) {
src/openvpn/options.h +1 -1
@@ -343,7 +343,7 @@ struct options/* optimize TUN/TAP/UDP writes */ bool fast_io; -#ifdef USE_LZO +#ifdef ENABLE_LZO /* LZO_x flags from lzo.h */ unsigned int lzo;#endif
src/openvpn/sig.c +1 -1
@@ -259,7 +259,7 @@ print_status (const struct context *c, struct status_output *so)status_printf (so,"TCP/UDP read bytes," counter_format, c->c2.link_read_bytes);status_printf (so,"TCP/UDP write bytes," counter_format, c->c2.link_write_bytes);status_printf (so,"Auth read bytes," counter_format, c->c2.link_read_bytes_auth); -#ifdef USE_LZO +#ifdef ENABLE_LZO if (lzo_defined (&c->c2.lzo_compwork))lzo_print_stats (&c->c2.lzo_compwork, so);#endif
Signature · 1 line
1.7.3.4
PATCH 40/52 build: proper crypto detection and usage
In reply to Alon Bar-Lev--- configure.ac | 227 ++++++++++++++++++------------------- distro/rpm/openvpn.spec.in | 6 +- doc/doxygen/doc_data_crypto.h | 2 +- include/openvpn-plugin.h | 31 ++++-- src/openvpn/Makefile.am | 2 + src/openvpn/crypto.c | 10 +- src/openvpn/crypto.h | 8 +- src/openvpn/crypto_backend.h | 4 +- src/openvpn/crypto_openssl.c | 26 +--- src/openvpn/crypto_polarssl.c | 4 +- src/openvpn/error.c | 8 +- src/openvpn/error.h | 2 +- src/openvpn/forward-inline.h | 6 +- src/openvpn/forward.c | 24 ++-- src/openvpn/init.c | 84 +++++++------- src/openvpn/manage.c | 4 +- src/openvpn/misc.c | 2 +- src/openvpn/misc.h | 6 +- src/openvpn/openvpn.h | 26 ++-- src/openvpn/options.c | 140 +++++++++++----------- src/openvpn/options.h | 14 +- src/openvpn/packet_id.c | 4 +- src/openvpn/packet_id.h | 4 +- src/openvpn/pkcs11_openssl.c | 2 +- src/openvpn/pkcs11_polarssl.c | 4 +- src/openvpn/plugin.c | 12 +- src/openvpn/plugin.h | 14 +- src/openvpn/reliable.c | 4 +- src/openvpn/reliable.h | 4 +- src/openvpn/session_id.c | 4 +- src/openvpn/session_id.h | 4 +- src/openvpn/ssl.c | 6 +- src/openvpn/ssl.h | 4 +- src/openvpn/ssl_backend.h | 10 +- src/openvpn/ssl_openssl.c | 8 +- src/openvpn/ssl_polarssl.c | 10 +- src/openvpn/ssl_verify.c | 22 ++-- src/openvpn/ssl_verify.h | 4 +- src/openvpn/ssl_verify_backend.h | 26 ++-- src/openvpn/ssl_verify_openssl.c | 10 +- src/openvpn/ssl_verify_openssl.h | 6 +- src/openvpn/ssl_verify_polarssl.c | 6 +- src/openvpn/ssl_verify_polarssl.h | 5 +- src/openvpn/syshead.h | 14 +- src/plugins/examples/log_v3.c | 4 +- 45 files changed, 412 insertions(+), 415 deletions(-)
configure.ac +112 -115
@@ -228,19 +228,6 @@ AC_ARG_ENABLE( ) AC_ARG_WITH( - [ssl-headers], - [AS_HELP_STRING([--with-ssl-headers=DIR], [Crypto/SSL Include files location])], - [CS_HDR_DIR="$withval"] - [CPPFLAGS="$CPPFLAGS -I$withval"] -) - -AC_ARG_WITH( - [ssl-lib], - [AS_HELP_STRING([--with-ssl-lib=DIR], [Crypto/SSL 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])], [
@@ -253,15 +240,15 @@ AC_ARG_WITH( ) AC_ARG_WITH( - [ssl-type], - [AS_HELP_STRING([--with-ssl-type=TYPE], [build with the given SSL library, TYPE = openssl or polarssl])], + [crypto-library], + [AS_HELP_STRING([--with-crypto-library=library], [build with the given crypto library, TYPE=openssl|polarssl @<:@default=openssl@:>@])], [ case "${withval}" in openssl|polarssl) ;; - *) AC_MSG_ERROR([bad value ${withval} for --with-ssl-type]) ;; + *) AC_MSG_ERROR([bad value ${withval} for --with-crypto-library]) ;; esac ], - [with_ssl_type="openssl"] + [with_crypto_library="openssl"] ) AC_DEFINE_UNQUOTED(TARGET_ALIAS, "${host}", [A string representing our host])
@@ -651,6 +638,76 @@ case "${with_mem_check}" in ;; esac +PKG_CHECK_MODULES( + [OPENSSL_CRYPTO], + [libcrypto >= 0.9.6], + [have_openssl_crypto="yes"], + [AC_CHECK_LIB( + [crypto], + [RSA_new], + [ + have_openssl_crypto="yes" + OPENSSL_CRYPTO_LIBS="-lcrypto" + ] + )] +) + +PKG_CHECK_MODULES( + [OPENSSL_SSL], + [libssl >= 0.9.6], + [have_openssl_ssl="yes"], + [AC_CHECK_LIB( + [ssl], + [SSL_CTX_new], + [ + have_openssl_ssl="yes" + OPENSSL_SSL_LIBS="-lssl" + ] + )] +) + +if test "${have_openssl_crypto}" = "yes"; then + saved_CFLAGS="${CFLAGS}" + saved_LIBS="${LIBS}" + CFLAGS="${CFLAGS} ${OPENSSL_CRYPTO_CFLAGS}" + LIBS="${LIBS} ${OPENSSL_CRYPTO_LIBS}" + AC_CHECK_FUNCS([EVP_CIPHER_CTX_set_key_length]) + have_openssl_engine="yes" + AC_CHECK_FUNCS( + [ \ + ENGINE_load_builtin_engines \ + ENGINE_register_all_complete \ + ENGINE_cleanup \ + ], + , + [have_openssl_engine="no"; break] + ) + + CFLAGS="${saved_CFLAGS}" + LIBS="${saved_LIBS}" +fi + +AC_ARG_VAR([POLARSSL_CFLAGS], [C compiler flags for polarssl]) +AC_ARG_VAR([POLARSSL_LIBS], [linker flags for polarssl]) +have_polarssl_ssl="yes" +have_polarssl_crypto="yes" +if test -z "${POLARSSL_LIBS}"; then + AC_CHECK_LIB( + [polarssl], + [ssl_init], + [POLARSSL_LIBS="-lpolarssl"], + [ + have_polarssl_ssl="no" + AC_CHECK_LIB( + [polarssl], + [aes_crypt_cbc], + , + [have_polarssl_crypto="no"] + ) + ] + ) +fi + AC_ARG_VAR([LZO_CFLAGS], [C compiler flags for lzo]) AC_ARG_VAR([LZO_LIBS], [linker flags for lzo]) have_lzo="yes"
@@ -698,103 +755,6 @@ PKG_CHECK_MODULES( [] ) -dnl -dnl check for SSL-crypto library -dnl -if test "${enable_crypto}" = "yes"; then - if test "${with_ssl_type}" = "openssl"; then - AC_CHECKING([for OpenSSL Crypto Library and Header files]) - AC_CHECK_HEADER(openssl/evp.h,, - [AC_MSG_ERROR([OpenSSL Crypto headers not found.])]) - - for lib in crypto eay32; do - AC_CHECK_LIB($lib, EVP_CIPHER_CTX_init, - [ - cryptofound=1 - LIBS="${LIBS} -l$lib" - ] - ) - done - test -n "$cryptofound" || AC_MSG_ERROR([OpenSSL Crypto library not found.]) - - AC_MSG_CHECKING([that OpenSSL Library is at least version 0.9.6]) - AC_EGREP_CPP(yes, - [ - #include <openssl/evp.h> - #if SSLEAY_VERSION_NUMBER >= 0x00906000L - yes - #endif - ], - [ - AC_MSG_RESULT([yes]) - AC_DEFINE(USE_CRYPTO, 1, [Use crypto library]) - AC_DEFINE(USE_OPENSSL, 1, [Use OpenSSL library]) - AC_CHECK_FUNCS(EVP_CIPHER_CTX_set_key_length) - - dnl check for OpenSSL crypto acceleration capability - AC_CHECK_HEADERS(openssl/engine.h) - AC_CHECK_FUNCS(ENGINE_load_builtin_engines) - AC_CHECK_FUNCS(ENGINE_register_all_complete) - AC_CHECK_FUNCS(ENGINE_cleanup) - ], - [AC_MSG_ERROR([OpenSSL crypto Library is too old.])] - ) - fi - if test "${with_ssl_type}" = "polarssl"; then - AC_CHECKING([for PolarSSL Crypto Library and Header files]) - AC_CHECK_HEADER(polarssl/aes.h, - [AC_CHECK_LIB(polarssl, aes_crypt_cbc, - [ - LIBS="${LIBS} -lpolarssl" - AC_DEFINE(USE_CRYPTO, 1, [Use crypto library]) - AC_DEFINE(USE_POLARSSL, 1, [Use PolarSSL library]) - ], - [AC_MSG_ERROR([PolarSSL Crypto library not found.])] - )], - [AC_MSG_ERROR([PolarSSL Crypto headers not found.])] - ) - fi - dnl - dnl check for OpenSSL-SSL library - dnl - - if test "${enable_ssl}" = "yes"; then - if test "${with_ssl_type}" = "openssl"; then - AC_CHECKING([for OpenSSL SSL Library and Header files]) - AC_CHECK_HEADER(openssl/ssl.h,, - [AC_MSG_ERROR([OpenSSL SSL headers not found.])] - ) - - for lib in ssl ssl32; do - AC_CHECK_LIB($lib, SSL_CTX_new, - [ - sslfound=1 - LIBS="${LIBS} -l$lib" - ] - ) - done - - test -n "${sslfound}" || AC_MSG_ERROR([OpenSSL SSL library not found.]) - - AC_DEFINE(USE_SSL, 1, [Use OpenSSL SSL library]) - fi - if test "${with_ssl_type}" = "polarssl"; then - AC_CHECKING([for PolarSSL SSL Library and Header files]) - AC_CHECK_HEADER(polarssl/ssl.h, - [AC_CHECK_LIB(polarssl, ssl_init, - [ - LIBS="${LIBS} -lpolarssl" - AC_DEFINE(USE_SSL, 1, [Use SSL library]) - AC_DEFINE(USE_POLARSSL, 1, [Use PolarSSL library]) - ], - [AC_MSG_ERROR([PolarSSL SSL library not found.])] - )], - [AC_MSG_ERROR([PolarSSL SSL headers not found.])] - ) - fi - fi -fi - if test -n "${SP_PLATFORM_WINDOWS}"; then AC_DEFINE_UNQUOTED([PATH_SEPARATOR], ['\\\\'], [Path separator]) #" AC_DEFINE_UNQUOTED([PATH_SEPARATOR_STR], ["\\\\"], [Path separator]) #"
@@ -805,7 +765,7 @@ fi dnl enable --x509-username-field feature if requested if test "${enable_x509_alt_username}" = "yes"; then - if test "${with_ssl_type}" = "polarssl" ; then + if test "${with_crypto_library}" = "polarssl" ; then AC_MSG_ERROR([PolarSSL does not support the --x509-username-field feature]) fi
@@ -829,6 +789,41 @@ test "${enable_strict_options}" = "yes" && AC_DEFINE([ENABLE_STRICT_OPTIONS_CHEC 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]) +case "${with_crypto_library}" in + openssl) + have_crypto_crypto="${have_openssl_crypto}" + have_crypto_ssl="${have_openssl_ssl}" + CRYPTO_CRYPTO_CFLAGS="${OPENSSL_CRYPTO_CFLAGS}" + CRYPTO_CRYPTO_LIBS="${OPENSSL_CRYPTO_LIBS}" + CRYPTO_SSL_CFLAGS="${OPENSSL_SSL_CFLAGS}" + CRYPTO_SSL_LIBS="${OPENSSL_SSL_LIBS}" + AC_DEFINE([ENABLE_CRYPTO_OPENSSL], [1], [Use OpenSSL library]) + test "${have_openssl_engine}" = "yes" && AC_DEFINE([HAVE_OPENSSL_ENGINE], [1], [Use crypto library]) + ;; + polarssl) + have_crypto_crypto="${have_polarssl_crypto}" + have_crypto_ssl="${have_polarssl_ssl}" + CRYPTO_CRYPTO_CFLAGS="${POLARSSL_CRYPTO_CFLAGS}" + CRYPTO_CRYPTO_LIBS="${POLARSSL_LIBS}" + AC_DEFINE([ENABLE_CRYPTO_POLARSSL], [1], [Use PolarSSL library]) + ;; +esac + +if test "${enable_ssl}" = "yes"; then + test "${enable_crypto}" != "yes" && AC_MSG_ERROR([crypto must be enabled for ssl]) + test "${have_crypto_ssl}" != "yes" && AC_MSG_ERROR([${with_ssl_library} ssl is required but missing]) + OPTIONAL_CRYPTO_CFLAGS="${OPTIONAL_CRYPTO_CFLAGS} ${CRYPTO_SSL_CFLAGS}" + OPTIONAL_CRYPTO_LIBS="${OPTIONAL_CRYPTO_LIBS} ${CRYPTO_SSL_LIBS}" + AC_DEFINE([ENABLE_SSL], [1], [Enable ssl library]) +fi + +if test "${enable_crypto}" = "yes"; then + test "${have_crypto_crypto}" != "yes" && AC_MSG_ERROR([${with_crypto_library} crytpo is required but missing]) + OPTIONAL_CRYPTO_CFLAGS="${OPTIONAL_CRYPTO_CFLAGS} ${CRYPTO_CRYPTO_CFLAGS}" + OPTIONAL_CRYPTO_LIBS="${OPTIONAL_CRYPTO_LIBS} ${CRYPTO_CRYPTO_LIBS}" + AC_DEFINE([ENABLE_CRYPTO], [1], [Enable crypto library]) +fi + if test "${enable_plugins}" = "yes"; then test "${WIN32}" != "yes" -a -z "${DL_LIBS}" && AC_MSG_ERROR([libdl is required for plugins]) OPTIONAL_DL_LIBS="${DL_LIBS}"
@@ -899,6 +894,8 @@ AC_SUBST([TAP_WIN_MIN_MINOR]) AC_SUBST([OPTIONAL_DL_LIBS]) AC_SUBST([OPTIONAL_SELINUX_LIBS]) +AC_SUBST([OPTIONAL_CRYPTO_CFLAGS]) +AC_SUBST([OPTIONAL_CRYPTO_LIBS]) AC_SUBST([OPTIONAL_LZO_CFLAGS]) AC_SUBST([OPTIONAL_LZO_LIBS]) AC_SUBST([OPTIONAL_PKCS11_HELPER_CFLAGS])
distro/rpm/openvpn.spec.in +1 -5
@@ -10,9 +10,6 @@ # # Allow passwords to be read from files # rpmbuild -tb [openvpn.x.tar.gz] --define 'with_password_save 1' -# -# Use this on RH9 and RHEL3 -# rpmbuild -tb [openvpn.x.tar.gz] --define 'with_kerberos 1' Summary: OpenVPN is a robust and highly flexible VPN daemon by James Yonan. Name: @PACKAGE@
@@ -111,8 +108,7 @@ Development support for OpenVPN. --docdir="%{_docdir}/%{name}-%{version}" \ %{?with_password_save:--enable-password-save} \ %{!?without_lzo:--enable-lzo} \ - %{?with_pkcs11:--enable-pkcs11} \ - %{?with_kerberos:--with-ssl-headers=/usr/kerberos/include} + %{?with_pkcs11:--enable-pkcs11} %__make # Build down-root plugin
doc/doxygen/doc_data_crypto.h +1 -1
@@ -60,7 +60,7 @@* * @par Settings that control this module's activity * Whether or not the Data Channel Crypto module is active depends on the -* compile-time \c USE_CRYPTO and \c USE_SSL preprocessor macros. How it +* compile-time \c ENABLE_CRYPTO and \c ENABLE_SSL preprocessor macros. How it * processes packets received from the \link data_control Data Channel * Control module\endlink at runtime depends on the associated \c * crypto_options structure. To perform cryptographic operations, the \c
include/openvpn-plugin.h +20 -11
@@ -24,16 +24,25 @@#ifndef OPENVPN_PLUGIN_H_ #define OPENVPN_PLUGIN_H_ -#ifdef USE_SSL -# if defined(SSL_VERIFY_OPENSSL_H_ ) || defined(SSL_VERIFY_POLARSSL_H_ ) -# define ENABLE_SSL_PLUGIN -# else -# warning "Neither OpenSSL or PoLarSSL headers included, disabling plugin's SSL support" -# endif -#endif /*USE_SSL*/ #define OPENVPN_PLUGIN_VERSION 3 +#ifdef ENABLE_SSL +#ifdef ENABLE_CRYPTO_POLARSSL +#include <polarssl/x509.h> +#ifndef __OPENVPN_X509_CERT_T_DECLARED +#define __OPENVPN_X509_CERT_T_DECLARED +typedef x509_cert openvpn_x509_cert_t ; +#endif +#else +#include <openssl/x509.h> +#ifndef __OPENVPN_X509_CERT_T_DECLARED +#define __OPENVPN_X509_CERT_T_DECLARED +typedef X509 openvpn_x509_cert_t ; +#endif +#endif +#endif +/* * Plug-in types. These types correspond to the set of script callbacks * supported by OpenVPN.
@@ -268,9 +277,9 @@ struct openvpn_plugin_args_open_return* *per_client_context : the per-client context pointer which was returned by * openvpn_plugin_client_constructor_v1, if defined. * -* current_cert_depth : Certificate depth of the certificate being passed over (only if compiled with USE_SSL defined) +* current_cert_depth : Certificate depth of the certificate being passed over (only if compiled with ENABLE_SSL defined) * -* *current_cert : X509 Certificate object received from the client (only if compiled with USE_SSL defined) +* *current_cert : X509 Certificate object received from the client (only if compiled with ENABLE_SSL defined) * */ struct openvpn_plugin_args_func_in
@@ -280,9 +289,9 @@ struct openvpn_plugin_args_func_inconst char **const envp;openvpn_plugin_handle_t handle;void *per_client_context; -#ifdef ENABLE_SSL_PLUGIN +#ifdef ENABLE_SSL int current_cert_depth; -x509_cert_t *current_cert; +openvpn_x509_cert_t *current_cert;#else int __current_cert_depth_disabled;/* Unused, for compatibility purposes only */ void *__current_cert_disabled;/* Unused, for compatibility purposes only */
src/openvpn/Makefile.am +2 -0
@@ -17,6 +17,7 @@ MAINTAINERCLEANFILES = \ INCLUDES = -I$(top_srcdir)/include AM_CFLAGS = \ + $(OPTIONAL_CRYPTO_CFLAGS) \ $(OPTIONAL_LZO_CFLAGS) \ $(OPTIONAL_PKCS11_HELPER_CFLAGS)
@@ -103,6 +104,7 @@ openvpn_LDADD = \ $(SOCKETS_LIBS) \ $(OPTIONAL_LZO_LIBS) \ $(OPTIONAL_PKCS11_HELPER_LIBS) \ + $(OPTIONAL_CRYPTO_LIBS) \ $(OPTIONAL_SELINUX_LIBS) \ $(OPTIONAL_DL_LIBS) if WIN32
src/openvpn/crypto.c +5 -5
@@ -25,7 +25,7 @@#include "syshead.h" -#ifdef USE_CRYPTO +#ifdef ENABLE_CRYPTO #include "crypto.h" #include "error.h"
@@ -712,7 +712,7 @@ test_crypto (const struct crypto_options *co, struct frame* frame)gc_free (&gc); } -#ifdef USE_SSL +#ifdef ENABLE_SSL void get_tls_handshake_key (const struct key_type *key_type,
@@ -1373,7 +1373,7 @@ get_random()return l; } -#ifndef USE_SSL +#ifndef ENABLE_SSL void init_ssl_lib (void )
@@ -1392,7 +1392,7 @@ free_ssl_lib (void) ERR_free_strings (); } -#endif /* USE_SSL */ +#endif /* ENABLE_SSL */ /* * md5 functions
@@ -1452,4 +1452,4 @@ md5_digest_equal (const struct md5_digest *d1, const struct md5_digest *d2) return memcmp(d1->digest, d2->digest, MD5_DIGEST_LENGTH) == 0; } -#endif /* USE_CRYPTO */ +#endif /* ENABLE_CRYPTO */
src/openvpn/crypto.h +4 -4
@@ -30,7 +30,7 @@#ifndef CRYPTO_H #define CRYPTO_H -#ifdef USE_CRYPTO +#ifdef ENABLE_CRYPTO #define ALLOW_NON_CBC_CIPHERS
@@ -347,7 +347,7 @@ void key2_print (const struct key2* k,const char * prefix0, const char* prefix1); -#ifdef USE_SSL +#ifdef ENABLE_SSL #define GHK_INLINE (1<<0) void get_tls_handshake_key (const struct key_type *key_type,
@@ -361,7 +361,7 @@ void get_tls_handshake_key (const struct key_type *key_type,void init_ssl_lib (void );void free_ssl_lib (void ); -#endif /* USE_SSL */ +#endif /* ENABLE_SSL */ /* * md5 functions
@@ -394,5 +394,5 @@ key_ctx_bi_defined(const struct key_ctx_bi* key) } -#endif /* USE_CRYPTO */ +#endif /* ENABLE_CRYPTO */ #endif /* CRYPTO_H */
src/openvpn/crypto_backend.h +2 -2
@@ -32,10 +32,10 @@#include "config.h" -#ifdef USE_OPENSSL +#ifdef ENABLE_CRYPTO_OPENSSL #include "crypto_openssl.h" #endif -#ifdef USE_POLARSSL +#ifdef ENABLE_CRYPTO_POLARSSL #include "crypto_polarssl.h" #endif #include "basic.h"
src/openvpn/crypto_openssl.c +7 -19
@@ -29,7 +29,7 @@#include "syshead.h" -#if defined(USE_CRYPTO ) && defined(USE_OPENSSL ) +#if defined(ENABLE_CRYPTO ) && defined(ENABLE_CRYPTO_OPENSSL )#include "basic.h" #include "buffer.h"
@@ -104,19 +104,7 @@ cipher_ok (const char* name)#define EVP_MD_name (e) OBJ_nid2sn(EVP_MD_type(e))#endif -/* -* -* OpenSSL engine support. Allows loading/unloading of engines. -* -*/ - -#if defined(HAVE_OPENSSL_ENGINE_H ) && defined(HAVE_ENGINE_LOAD_BUILTIN_ENGINES ) && defined(HAVE_ENGINE_REGISTER_ALL_COMPLETE ) && defined(HAVE_ENGINE_CLEANUP ) -#define CRYPTO_ENGINE 1 -#else -#define CRYPTO_ENGINE 0 -#endif - -#if CRYPTO_ENGINE +#if HAVE_OPENSSL_ENGINE #include <openssl/engine.h> static bool engine_initialized = false;/* GLOBAL */
@@ -173,12 +161,12 @@ setup_engine (const char *engine)return e; } -#endif /* CRYPTO_ENGINE */ +#endif /* HAVE_OPENSSL_ENGINE */ void crypto_init_lib_engine (const char *engine_name) { -#if CRYPTO_ENGINE +#if HAVE_OPENSSL_ENGINE if (!engine_initialized) {ASSERT (engine_name);
@@ -220,7 +208,7 @@ crypto_uninit_lib (void)fclose (fp);#endif -#if CRYPTO_ENGINE +#if HAVE_OPENSSL_ENGINE if (engine_initialized) {ENGINE_cleanup ();
@@ -335,7 +323,7 @@ show_available_digests ()void show_available_engines () { -#if CRYPTO_ENGINE /* Only defined for OpenSSL */ +#if HAVE_OPENSSL_ENGINE /* Only defined for OpenSSL */ ENGINE *e;printf ("OpenSSL Crypto Engines\n\n" );
@@ -741,4 +729,4 @@ hmac_ctx_final (HMAC_CTX *ctx, uint8_t *dst) HMAC_Final (ctx, dst, &in_hmac_len); } -#endif /* USE_CRYPTO && USE_OPENSSL */ +#endif /* ENABLE_CRYPTO && ENABLE_CRYPTO_OPENSSL */
src/openvpn/crypto_polarssl.c +2 -2
@@ -29,7 +29,7 @@#include "syshead.h" -#if defined(USE_CRYPTO ) && defined(USE_POLARSSL ) +#if defined(ENABLE_CRYPTO ) && defined(ENABLE_CRYPTO_POLARSSL )#include "errlevel.h" #include "basic.h"
@@ -557,4 +557,4 @@ hmac_ctx_final (md_context_t *ctx, uint8_t *dst) ASSERT(0 == md_hmac_finish(ctx, dst)); } -#endif /* USE_CRYPTO && USE_POLARSSL */ +#endif /* ENABLE_CRYPTO && ENABLE_CRYPTO_POLARSSL */
src/openvpn/error.c +4 -4
@@ -37,8 +37,8 @@#include "ps.h" #include "mstats.h" -#ifdef USE_CRYPTO -#ifdef USE_OPENSSL +#ifdef ENABLE_CRYPTO +#ifdef ENABLE_CRYPTO_OPENSSL #include <openssl/err.h> #endif #endif
@@ -246,8 +246,8 @@ void x_msg (const unsigned int flags, const char *format, ...)SWAP ; } -#ifdef USE_CRYPTO -#ifdef USE_OPENSSL +#ifdef ENABLE_CRYPTO +#ifdef ENABLE_CRYPTO_OPENSSL if (flags & M_SSL) { int nerrs = 0;
src/openvpn/error.h +1 -1
@@ -96,7 +96,7 @@ extern int x_msg_line_num;#define M_ERRNO (1<<8)/* show errno description */ #define M_ERRNO_SOCK (1<<9)/* show socket errno description */ -#ifdef USE_OPENSSL +#ifdef ENABLE_CRYPTO_OPENSSL # define M_SSL (1<<10)/* show SSL error */ #endif
src/openvpn/forward-inline.h +3 -3
@@ -35,7 +35,7 @@static inline void check_tls (struct context *c) { -#if defined(USE_CRYPTO ) && defined(USE_SSL ) +#if defined(ENABLE_CRYPTO ) && defined(ENABLE_SSL )void check_tls_dowork (struct context *c);if (c->c2.tls_multi)check_tls_dowork (c);
@@ -49,7 +49,7 @@ check_tls (struct context *c)static inline void check_tls_errors (struct context *c) { -#if defined(USE_CRYPTO ) && defined(USE_SSL ) +#if defined(ENABLE_CRYPTO ) && defined(ENABLE_SSL )void check_tls_errors_co (struct context *c);void check_tls_errors_nco (struct context *c);if (c->c2.tls_multi && c->c2.tls_exit_signal)
@@ -189,7 +189,7 @@ check_push_request (struct context *c)#endif -#ifdef USE_CRYPTO +#ifdef ENABLE_CRYPTO /* * Should we persist our anti-replay packet ID state to disk? */
src/openvpn/forward.c +12 -12
@@ -81,7 +81,7 @@ show_wait_status (struct context *c)* traffic on the control-channel. * */ -#if defined(USE_CRYPTO ) && defined(USE_SSL ) +#if defined(ENABLE_CRYPTO ) && defined(ENABLE_SSL )void check_tls_dowork (struct context *c) {
@@ -112,7 +112,7 @@ check_tls_dowork (struct context *c) }#endif -#if defined(USE_CRYPTO ) && defined(USE_SSL ) +#if defined(ENABLE_CRYPTO ) && defined(ENABLE_SSL )void check_tls_errors_co (struct context *c)
@@ -232,7 +232,7 @@ check_connection_established_dowork (struct context *c)bool send_control_channel_string (struct context *c,const char *str,int msglevel) { -#if defined(USE_CRYPTO ) && defined(USE_SSL ) +#if defined(ENABLE_CRYPTO ) && defined(ENABLE_SSL )if (c->c2.tls_multi) {struct gc_arena gc =gc_new ();bool stat;
@@ -449,8 +449,8 @@ encrypt_sign (struct context *c, bool comp_frag)#endif } -#ifdef USE_CRYPTO -#ifdef USE_SSL +#ifdef ENABLE_CRYPTO +#ifdef ENABLE_SSL /* * If TLS mode, get the key we will use to encrypt * the packet.
@@ -472,8 +472,8 @@ encrypt_sign (struct context *c, bool comp_frag)*/ link_socket_get_outgoing_addr (&c->c2.buf,get_link_socket_info (c), &c->c2.to_link_addr); -#ifdef USE_CRYPTO -#ifdef USE_SSL +#ifdef ENABLE_CRYPTO +#ifdef ENABLE_SSL /* * In TLS mode, prepend the appropriate one-byte opcode * to the packet which identifies it as a data channel
@@ -498,7 +498,7 @@ encrypt_sign (struct context *c, bool comp_frag)static void process_coarse_timers (struct context *c) { -#ifdef USE_CRYPTO +#ifdef ENABLE_CRYPTO /* flush current packet-id to file once per 60 seconds if --replay-persist was specified */ check_packet_id_persist_flush (c);
@@ -789,8 +789,8 @@ process_incoming_link (struct context *c)if (!link_socket_verify_incoming_addr (&c->c2.buf, lsi, &c->c2.from))link_socket_bad_incoming_addr (&c->c2.buf, lsi, &c->c2.from); -#ifdef USE_CRYPTO -#ifdef USE_SSL +#ifdef ENABLE_CRYPTO +#ifdef ENABLE_SSL if (c->c2.tls_multi) { /*
@@ -820,7 +820,7 @@ process_incoming_link (struct context *c)if (c->c2.context_auth !=CAS_SUCCEEDED ) c->c2.buf.len =0 ;#endif -#endif /* USE_SSL */ +#endif /* ENABLE_SSL */ /* authenticate and decrypt the incoming packet */ decrypt_status =openvpn_decrypt (&c->c2.buf, c->c2.buffers->decrypt_buf, &c->c2.crypto_options, &c->c2.frame);
@@ -833,7 +833,7 @@ process_incoming_link (struct context *c) goto done; } -#endif /* USE_CRYPTO */ +#endif /* ENABLE_CRYPTO */ #ifdef ENABLE_FRAGMENT if (c->c2.fragment)
src/openvpn/init.c +42 -42
284 lines not on this page · raw message
src/openvpn/manage.c +2 -2
@@ -699,7 +699,7 @@ man_query_need_str (struct management *man, const char *type, const char *actionstatic void man_forget_passwords (struct management *man) { -#if defined(USE_CRYPTO ) && defined(USE_SSL ) +#if defined(ENABLE_CRYPTO ) && defined(ENABLE_SSL )ssl_purge_auth (false);msg (M_CLIENT ,"SUCCESS: Passwords were forgotten" );#endif
@@ -1714,7 +1714,7 @@ man_reset_client_socket (struct management *man, const bool exiting) }if (!exiting) { -#if defined(USE_CRYPTO ) && defined(USE_SSL ) +#if defined(ENABLE_CRYPTO ) && defined(ENABLE_SSL )if (man->settings.flags &MF_FORGET_DISCONNECT )ssl_purge_auth (false);#endif
src/openvpn/misc.c +1 -1
@@ -1243,7 +1243,7 @@ test_file (const char *filename)return ret; } -#ifdef USE_CRYPTO +#ifdef ENABLE_CRYPTO /* create a temporary filename in directory */ const char *
src/openvpn/misc.h +3 -3
@@ -194,7 +194,7 @@ int openvpn_chdir (const char* dir);extern int inetd_socket_descriptor;void save_inetd_socket_descriptor (void ); -/* init random() function, only used as source for weak random numbers, when !USE_CRYPTO */ +/* init random() function, only used as source for weak random numbers, when !ENABLE_CRYPTO */ void init_random_seed (void );/* set/delete environmental variable */
@@ -252,7 +252,7 @@ void sleep_milliseconds (unsigned int n);void sleep_until_signal (void );/* an analogue to the random() function, but use OpenSSL functions if available */ -#ifdef USE_CRYPTO +#ifdef ENABLE_CRYPTO long int get_random (void );#else #define get_random random
@@ -273,7 +273,7 @@ bool delete_file (const char *filename);/* return true if pathname is absolute */ bool absolute_pathname (const char *pathname); -/* prepend a random prefix to hostname (need USE_CRYPTO) */ +/* prepend a random prefix to hostname (need ENABLE_CRYPTO) */ const char *hostname_randomize (const char *hostname,struct gc_arena *gc);/*
src/openvpn/openvpn.h +13 -13
@@ -55,24 +55,24 @@struct key_schedule { -#ifdef USE_CRYPTO +#ifdef ENABLE_CRYPTO /* which cipher, HMAC digest, and key sizes are we using? */ struct key_type key_type;/* pre-shared static key, read from a file */ struct key_ctx_bi static_key; -#ifdef USE_SSL +#ifdef ENABLE_SSL /* our global SSL context */ struct tls_root_ctx ssl_ctx;/* optional authentication HMAC key for TLS control channel */ struct key_ctx_bi tls_auth_key; -#endif /* USE_SSL */ -#else /* USE_CRYPTO */ +#endif /* ENABLE_SSL */ +#else /* ENABLE_CRYPTO */ int dummy; -#endif /* USE_CRYPTO */ +#endif /* ENABLE_CRYPTO */ };/*
@@ -99,7 +99,7 @@ struct context_buffersstruct buffer aux_buf;/* workspace buffers used by crypto routines */ -#ifdef USE_CRYPTO +#ifdef ENABLE_CRYPTO struct buffer encrypt_buf;struct buffer decrypt_buf;#endif
@@ -331,12 +331,12 @@ struct context_2int occ_mtu_load_n_tries;#endif -#ifdef USE_CRYPTO +#ifdef ENABLE_CRYPTO /* * TLS-mode crypto objects. */ -#ifdef USE_SSL +#ifdef ENABLE_SSL struct tls_multi *tls_multi;/**< TLS state structure for this VPN * tunnel. */
@@ -358,7 +358,7 @@ struct context_2/* throw this signal on TLS errors */ int tls_exit_signal; -#endif /* USE_SSL */ +#endif /* ENABLE_SSL */ struct crypto_options crypto_options;/**< Security parameters and crypto state
@@ -370,7 +370,7 @@ struct context_2struct packet_id packet_id;struct event_timeout packet_id_persist_interval; -#endif /* USE_CRYPTO */ +#endif /* ENABLE_CRYPTO */ #ifdef ENABLE_LZO struct lzo_compress_workspace lzo_compwork;
@@ -566,7 +566,7 @@ struct context* have been compiled in. */ -#if defined(USE_CRYPTO ) && defined(USE_SSL ) +#if defined(ENABLE_CRYPTO ) && defined(ENABLE_SSL )#define TLS_MODE (c) ((c)->c2.tls_multi != NULL)#define PROTO_DUMP_FLAGS (check_debug_level (D_LINK_RW_VERBOSE) ? (PD_SHOW_DATA|PD_VERBOSE) : 0)#define PROTO_DUMP (buf, gc) protocol_dump((buf), \
@@ -579,13 +579,13 @@ struct context#define PROTO_DUMP (buf, gc) format_hex (BPTR (buf), BLEN (buf), 80, gc)#endif -#ifdef USE_CRYPTO +#ifdef ENABLE_CRYPTO #define MD5SUM (buf, len, gc) md5sum((buf), (len), 0, (gc))#else #define MD5SUM (buf, len, gc) "[unavailable]"#endif -#ifdef USE_CRYPTO +#ifdef ENABLE_CRYPTO #define CIPHER_ENABLED (c) (c->c1.ks.key_type.cipher != NULL)#else #define CIPHER_ENABLED (c) (false)
src/openvpn/options.c +70 -70
450 lines not on this page · raw message
src/openvpn/options.h +7 -7
@@ -80,7 +80,7 @@ struct options_pre_pull };#endif -#if defined(USE_CRYPTO ) && !defined(USE_OPENSSL ) && !defined(USE_POLARSSL ) +#if defined(ENABLE_CRYPTO ) && !defined(ENABLE_CRYPTO_OPENSSL ) && !defined(ENABLE_CRYPTO_POLARSSL )# error "At least one of OpenSSL or PolarSSL needs to be defined."#endif
@@ -211,12 +211,12 @@ struct optionsbool persist_config;int persist_mode; -#ifdef USE_CRYPTO +#ifdef ENABLE_CRYPTO const char *key_pass_file;bool show_ciphers;bool show_digests;bool show_engines; -#ifdef USE_SSL +#ifdef ENABLE_SSL bool show_tls_ciphers;#endif bool genkey;
@@ -498,7 +498,7 @@ struct options#endif #endif -#ifdef USE_CRYPTO +#ifdef ENABLE_CRYPTO /* Cipher parms */ const char *shared_secret_file;#if ENABLE_INLINE_FILES
@@ -521,7 +521,7 @@ struct optionsbool use_iv;bool test_crypto; -#ifdef USE_SSL +#ifdef ENABLE_SSL /* TLS (control channel) parms */ bool tls_server;bool tls_client;
@@ -605,8 +605,8 @@ struct optionsbool tls_exit; -#endif /* USE_SSL */ -#endif /* USE_CRYPTO */ +#endif /* ENABLE_SSL */ +#endif /* ENABLE_CRYPTO */ #ifdef ENABLE_X509_TRACK const struct x509_track *x509_track;
src/openvpn/packet_id.c +2 -2
@@ -33,7 +33,7 @@#include "syshead.h" -#ifdef USE_CRYPTO +#ifdef ENABLE_CRYPTO #include "packet_id.h" #include "misc.h"
@@ -593,4 +593,4 @@ packet_id_interactive_test () }#endif -#endif /* USE_CRYPTO */ +#endif /* ENABLE_CRYPTO */
src/openvpn/packet_id.h +2 -2
@@ -28,7 +28,7 @@* attempts to replay them back later. */ -#ifdef USE_CRYPTO +#ifdef ENABLE_CRYPTO #ifndef PACKET_ID_H #define PACKET_ID_H
@@ -335,4 +335,4 @@ packet_id_reap_test (struct packet_id_rec *p) }#endif /* PACKET_ID_H */ -#endif /* USE_CRYPTO */ +#endif /* ENABLE_CRYPTO */
src/openvpn/pkcs11_openssl.c +1 -1
@@ -29,7 +29,7 @@#include "syshead.h" -#if defined(ENABLE_PKCS11 ) && defined(USE_OPENSSL ) +#if defined(ENABLE_PKCS11 ) && defined(ENABLE_CRYPTO_OPENSSL )#include "errlevel.h" #include "pkcs11_backend.h"
src/openvpn/pkcs11_polarssl.c +2 -2
@@ -29,7 +29,7 @@#include "syshead.h" -#if defined(ENABLE_PKCS11 ) && defined(USE_POLARSSL ) +#if defined(ENABLE_PKCS11 ) && defined(ENABLE_CRYPTO_POLARSSL )#include "errlevel.h" #include "pkcs11_backend.h"
@@ -117,4 +117,4 @@ cleanup: return ret; } -#endif /* defined(ENABLE_PKCS11) && defined(USE_POLARSSL) */ +#endif /* defined(ENABLE_PKCS11) && defined(ENABLE_CRYPTO_POLARSSL) */
src/openvpn/plugin.c +6 -6
@@ -351,9 +351,9 @@ plugin_call_item (const struct plugin *p,const struct argv *av, struct openvpn_plugin_string_list **retlist, const char **envp -#ifdef USE_SSL +#ifdef ENABLE_SSL , int certdepth, - x509_cert_t *current_cert + openvpn_x509_cert_t *current_cert #endif ) {
@@ -380,7 +380,7 @@ plugin_call_item (const struct plugin *p, (const char **const ) envp, p->plugin_handle, per_client_context, -#ifdef USE_SSL +#ifdef ENABLE_SSL (current_cert ? certdepth :-1 ), current_cert #else
@@ -590,9 +590,9 @@ plugin_call_ssl (const struct plugin_list *pl,const struct argv *av, struct plugin_return *pr, struct env_set *es -#ifdef USE_SSL +#ifdef ENABLE_SSL , int certdepth, - x509_cert_t *current_cert + openvpn_x509_cert_t *current_cert #endif ) {
@@ -620,7 +620,7 @@ plugin_call_ssl (const struct plugin_list *pl, av, pr ? &pr->list[i] :NULL , envp -#ifdef USE_SSL +#ifdef ENABLE_SSL ,certdepth, current_cert #endif
src/openvpn/plugin.h +7 -7
@@ -29,10 +29,10 @@#ifndef OPENVPN_PLUGIN_H #define OPENVPN_PLUGIN_H -#ifdef USE_OPENSSL +#ifdef ENABLE_CRYPTO_OPENSSL #include "ssl_verify_openssl.h" #endif -#ifdef USE_POLARSSL +#ifdef ENABLE_CRYPTO_POLARSSL #include "ssl_verify_polarssl.h" #endif #include "openvpn-plugin.h"
@@ -127,9 +127,9 @@ int plugin_call_ssl (const struct plugin_list *pl,const struct argv *av, struct plugin_return *pr, struct env_set *es -#ifdef USE_SSL +#ifdef ENABLE_SSL , int current_cert_depth, - x509_cert_t *current_cert + openvpn_x509_cert_t *current_cert #endif );
@@ -183,9 +183,9 @@ plugin_call_ssl (const struct plugin_list *pl,const struct argv *av, struct plugin_return *pr, struct env_set *es -#ifdef USE_SSL +#ifdef ENABLE_SSL , int current_cert_depth, - x509_cert_t *current_cert + openvpn_x509_cert_t *current_cert #endif ) {
@@ -202,7 +202,7 @@ plugin_call(const struct plugin_list *pl, struct env_set *es) {return plugin_call_ssl (pl, type, av, pr, es -#ifdef USE_SSL +#ifdef ENABLE_SSL ,-1 ,NULL #endif );
src/openvpn/reliable.c +2 -2
@@ -29,7 +29,7 @@#include "syshead.h" -#if defined(USE_CRYPTO ) && defined(USE_SSL ) +#if defined(ENABLE_CRYPTO ) && defined(ENABLE_SSL )#include "buffer.h" #include "error.h"
@@ -748,4 +748,4 @@ reliable_debug_print (const struct reliable *rel, char *desc)#else static void dummy (void ) {} -#endif /* USE_CRYPTO && USE_SSL*/ +#endif /* ENABLE_CRYPTO && ENABLE_SSL*/
src/openvpn/reliable.h +2 -2
@@ -29,7 +29,7 @@*/ -#if defined(USE_CRYPTO ) && defined(USE_SSL ) +#if defined(ENABLE_CRYPTO ) && defined(ENABLE_SSL )#ifndef RELIABLE_H #define RELIABLE_H
@@ -477,4 +477,4 @@ void reliable_ack_debug_print (const struct reliable_ack *ack, char *desc);#endif /* RELIABLE_H */ -#endif /* USE_CRYPTO && USE_SSL */ +#endif /* ENABLE_CRYPTO && ENABLE_SSL */
src/openvpn/session_id.c +2 -2
@@ -33,7 +33,7 @@#include "syshead.h" -#if defined(USE_CRYPTO ) && defined(USE_SSL ) +#if defined(ENABLE_CRYPTO ) && defined(ENABLE_SSL )#include "error.h" #include "common.h"
@@ -58,4 +58,4 @@ session_id_print (const struct session_id *sid, struct gc_arena *gc)#else static void dummy (void ) {} -#endif /* USE_CRYPTO && USE_SSL*/ +#endif /* ENABLE_CRYPTO && ENABLE_SSL*/
src/openvpn/session_id.h +2 -2
@@ -30,7 +30,7 @@* negotiated). */ -#if defined(USE_CRYPTO ) && defined(USE_SSL ) +#if defined(ENABLE_CRYPTO ) && defined(ENABLE_SSL )#ifndef SESSION_ID_H #define SESSION_ID_H
@@ -83,4 +83,4 @@ void session_id_random (struct session_id *sid);const char *session_id_print (const struct session_id *sid,struct gc_arena *gc);#endif /* SESSION_ID_H */ -#endif /* USE_CRYPTO && USE_SSL */ +#endif /* ENABLE_CRYPTO && ENABLE_SSL */
src/openvpn/ssl.c +3 -3
@@ -41,7 +41,7 @@#include "syshead.h" -#if defined(USE_CRYPTO ) && defined(USE_SSL ) +#if defined(ENABLE_CRYPTO ) && defined(ENABLE_SSL )#include "error.h" #include "common.h"
@@ -342,7 +342,7 @@ init_ssl (const struct options *options, struct tls_root_ctx *new_ctx)#ifdef MANAGMENT_EXTERNAL_KEY else if ((options->management_flags & MF_EXTERNAL_KEY) && options->cert_file) { -x509_cert_t *my_cert =NULL ; +openvpn_x509_cert_t *my_cert =NULL ;tls_ctx_load_cert_file (new_ctx, options->cert_file, options->cert_file_inline, &my_cert);tls_ctx_use_external_private_key (new_ctx, my_cert);
@@ -3370,4 +3370,4 @@ done:#else static void dummy (void ) {} -#endif /* USE_CRYPTO && USE_SSL*/ +#endif /* ENABLE_CRYPTO && ENABLE_SSL*/
src/openvpn/ssl.h +2 -2
@@ -30,7 +30,7 @@#ifndef OPENVPN_SSL_H #define OPENVPN_SSL_H -#if defined(USE_CRYPTO ) && defined(USE_SSL ) +#if defined(ENABLE_CRYPTO ) && defined(ENABLE_SSL )#include "basic.h" #include "common.h"
@@ -502,6 +502,6 @@ void show_tls_performance_stats(void);/*#define EXTRACT_X509_FIELD_TEST*/ void extract_x509_field_test (void ); -#endif /* USE_CRYPTO && USE_SSL */ +#endif /* ENABLE_CRYPTO && ENABLE_SSL */ #endif
src/openvpn/ssl_backend.h +5 -5
@@ -33,11 +33,11 @@#include "buffer.h" -#ifdef USE_OPENSSL +#ifdef ENABLE_CRYPTO_OPENSSL #include "ssl_openssl.h" #include "ssl_verify_openssl.h" #endif -#ifdef USE_POLARSSL +#ifdef ENABLE_CRYPTO_POLARSSL #include "ssl_polarssl.h" #include "ssl_verify_polarssl.h" #endif
@@ -193,7 +193,7 @@ void tls_ctx_load_cert_file (struct tls_root_ctx *ctx, const char *cert_file,#if ENABLE_INLINE_FILES const char *cert_file_inline,#endif -x509_cert_t **x509 +openvpn_x509_cert_t **x509 );/**
@@ -201,7 +201,7 @@ void tls_ctx_load_cert_file (struct tls_root_ctx *ctx, const char *cert_file,* * @param x509 certificate to free */ -void tls_ctx_free_cert_file (x509_cert_t *x509); +void tls_ctx_free_cert_file (openvpn_x509_cert_t *x509);/** * Load private key file into the given TLS context.
@@ -233,7 +233,7 @@ int tls_ctx_load_priv_file (struct tls_root_ctx *ctx, const char *priv_key_file* @return 1 if an error occurred, 0 if parsing was * successful. */ -int tls_ctx_use_external_private_key (struct tls_root_ctx *ctx,x509_cert_t *cert); +int tls_ctx_use_external_private_key (struct tls_root_ctx *ctx,openvpn_x509_cert_t *cert);#endif
src/openvpn/ssl_openssl.c +4 -4
@@ -29,7 +29,7 @@#include "syshead.h" -#if defined(USE_SSL ) && defined(USE_OPENSSL ) +#if defined(ENABLE_SSL ) && defined(ENABLE_CRYPTO_OPENSSL )#include "errlevel.h" #include "buffer.h"
@@ -1020,13 +1020,13 @@ key_state_write_plaintext (struct key_state_ssl *ks_ssl, struct buffer *buf)int ret =0 ;perf_push (PERF_BIO_WRITE_PLAINTEXT ); -#ifdef USE_OPENSSL +#ifdef ENABLE_CRYPTO_OPENSSL ASSERT (NULL != ks_ssl); ret =bio_write (ks_ssl->ssl_bio,BPTR (buf),BLEN (buf),"tls_write_plaintext" );bio_write_post (ret, buf); -#endif /* USE_OPENSSL */ +#endif /* ENABLE_CRYPTO_OPENSSL */ perf_pop ();return ret;
@@ -1187,4 +1187,4 @@ get_highest_preference_tls_cipher (char *buf, int size) SSL_CTX_free (ctx); } -#endif /* defined(USE_SSL) && defined(USE_OPENSSL) */ +#endif /* defined(ENABLE_SSL) && defined(ENABLE_CRYPTO_OPENSSL) */
src/openvpn/ssl_polarssl.c +5 -5
@@ -29,7 +29,7 @@#include "syshead.h" -#if defined(USE_SSL ) && defined(USE_POLARSSL ) +#if defined(ENABLE_SSL ) && defined(ENABLE_CRYPTO_POLARSSL )#include "errlevel.h" #include "ssl_backend.h"
@@ -243,7 +243,7 @@ tls_ctx_load_cert_file (struct tls_root_ctx *ctx, const char *cert_file,#if ENABLE_INLINE_FILES const char *cert_file_inline,#endif -x509_cert_t **x509 +openvpn_x509_cert_t **x509 ) {ASSERT (NULL != ctx);
@@ -270,7 +270,7 @@ tls_ctx_load_cert_file (struct tls_root_ctx *ctx, const char *cert_file, }void -tls_ctx_free_cert_file (x509_cert_t *x509) +tls_ctx_free_cert_file (openvpn_x509_cert_t *x509) {x509_free (x509); }
@@ -334,7 +334,7 @@ tls_ctx_load_priv_file (struct tls_root_ctx *ctx, const char *priv_key_file#ifdef MANAGMENT_EXTERNAL_KEY int -tls_ctx_use_external_private_key (struct tls_root_ctx *ctx,x509_cert_t *cert) +tls_ctx_use_external_private_key (struct tls_root_ctx *ctx,openvpn_x509_cert_t *cert) {msg (M_FATAL ,"Use of management external keys not yet supported for PolarSSL." );return false;
@@ -865,4 +865,4 @@ get_highest_preference_tls_cipher (char *buf, int size) strncpynt (buf, cipher_name, size); } -#endif /* defined(USE_SSL) && defined(USE_POLARSSL) */ +#endif /* defined(ENABLE_SSL) && defined(ENABLE_CRYPTO_POLARSSL) */
src/openvpn/ssl_verify.c +11 -11
@@ -29,14 +29,14 @@#include "syshead.h" -#if defined(USE_CRYPTO ) && defined(USE_SSL ) +#if defined(ENABLE_CRYPTO ) && defined(ENABLE_SSL )#include "misc.h" #include "manage.h" #include "ssl_verify.h" #include "ssl_verify_backend.h" -#ifdef USE_OPENSSL +#ifdef ENABLE_CRYPTO_OPENSSL #include "ssl_verify_openssl.h" #endif
@@ -296,7 +296,7 @@ print_nsCertType (int type)* @param subject the peer's extracted common name */ static result_t -verify_peer_cert (const struct tls_options *opt,x509_cert_t *peer_cert, +verify_peer_cert (const struct tls_options *opt,openvpn_x509_cert_t *peer_cert,const char *subject,const char *common_name) {/* verify certificate nsCertType */
@@ -315,7 +315,7 @@ verify_peer_cert(const struct tls_options *opt, x509_cert_t *peer_cert, } } -#if OPENSSL_VERSION_NUMBER >=0x00907000L ||USE_POLARSSL +#if OPENSSL_VERSION_NUMBER >=0x00907000L ||ENABLE_CRYPTO_POLARSSL /* verify certificate ku */ if (opt->remote_cert_ku[0 ] !=0 )
@@ -369,7 +369,7 @@ verify_peer_cert(const struct tls_options *opt, x509_cert_t *peer_cert,* environment for later verification by scripts and plugins. */ static void -verify_cert_set_env (struct env_set *es,x509_cert_t *peer_cert,int cert_depth, +verify_cert_set_env (struct env_set *es,openvpn_x509_cert_t *peer_cert,int cert_depth,const char *subject,const char *common_name #ifdef ENABLE_X509_TRACK , const struct x509_track *x509_track
@@ -425,7 +425,7 @@ verify_cert_set_env(struct env_set *es, x509_cert_t *peer_cert, int cert_depth,*/ static result_t verify_cert_call_plugin (const struct plugin_list *plugins,struct env_set *es, -int cert_depth,x509_cert_t *cert,char *subject) +int cert_depth,openvpn_x509_cert_t *cert,char *subject) {if (plugin_defined (plugins,OPENVPN_PLUGIN_TLS_VERIFY )) {
@@ -454,7 +454,7 @@ verify_cert_call_plugin(const struct plugin_list *plugins, struct env_set *es, }static const char * -verify_cert_export_cert (x509_cert_t *peercert,const char *tmp_dir,struct gc_arena *gc) +verify_cert_export_cert (openvpn_x509_cert_t *peercert,const char *tmp_dir,struct gc_arena *gc) {FILE *peercert_file;const char *peercert_filename="" ;
@@ -486,7 +486,7 @@ verify_cert_export_cert(x509_cert_t *peercert, const char *tmp_dir, struct gc_ar*/ static result_t verify_cert_call_command (const char *verify_command,struct env_set *es, -int cert_depth,x509_cert_t *cert,char *subject,const char *verify_export_cert) +int cert_depth,openvpn_x509_cert_t *cert,char *subject,const char *verify_export_cert) {const char *tmp_file =NULL ;int ret;
@@ -533,7 +533,7 @@ verify_cert_call_command(const char *verify_command, struct env_set *es,* check peer cert against CRL directory */ static result_t -verify_check_crl_dir (const char *crl_dir,x509_cert_t *cert) +verify_check_crl_dir (const char *crl_dir,openvpn_x509_cert_t *cert) {char fn[256 ];int fd;
@@ -560,7 +560,7 @@ verify_check_crl_dir(const char *crl_dir, x509_cert_t *cert) }result_t -verify_cert (struct tls_session *session,x509_cert_t *cert,int cert_depth) +verify_cert (struct tls_session *session,openvpn_x509_cert_t *cert,int cert_depth) {char *subject =NULL ;char common_name[TLS_USERNAME_LEN ] = {0 };
@@ -1215,4 +1215,4 @@ verify_final_auth_checks(struct tls_multi *multi, struct tls_session *session) gc_free (&gc); } } -#endif /* defined(USE_CRYPTO) && defined(USE_SSL) */ +#endif /* defined(ENABLE_CRYPTO) && defined(ENABLE_SSL) */
src/openvpn/ssl_verify.h +2 -2
@@ -36,10 +36,10 @@#include "ssl_common.h" /* Include OpenSSL-specific code */ -#ifdef USE_OPENSSL +#ifdef ENABLE_CRYPTO_OPENSSL #include "ssl_verify_openssl.h" #endif -#ifdef USE_POLARSSL +#ifdef ENABLE_CRYPTO_POLARSSL #include "ssl_verify_polarssl.h" #endif
src/openvpn/ssl_verify_backend.h +13 -13
@@ -55,7 +55,7 @@ typedef enum { SUCCESS=0, FAILURE=1 } result_t;* * @return \c SUCCESS if verification was successful, \c FAILURE on failure. */ -result_t verify_cert (struct tls_session *session,x509_cert_t *cert,int cert_depth); +result_t verify_cert (struct tls_session *session,openvpn_x509_cert_t *cert,int cert_depth);/* * Remember the given certificate hash, allowing the certificate chain to be
@@ -86,7 +86,7 @@ void cert_hash_remember (struct tls_session *session, const int cert_depth,* * @return a string containing the subject */ -char *x509_get_subject (x509_cert_t *cert); +char *x509_get_subject (openvpn_x509_cert_t *cert);/* * Free a subject string as returned by \c verify_get_subject()
@@ -103,7 +103,7 @@ void x509_free_subject (char *subject);* * @return a string containing the SHA1 hash of the certificate */ -unsigned char *x509_get_sha1_hash (x509_cert_t *cert); +unsigned char *x509_get_sha1_hash (openvpn_x509_cert_t *cert);/* * Free a hash as returned by \c verify_get_hash()
@@ -126,7 +126,7 @@ void x509_free_sha1_hash (unsigned char *hash);* @return \c FAILURE, \c or SUCCESS */ result_t x509_get_username (char *common_name,int cn_len, -char * x509_username_field,x509_cert_t *peer_cert); +char * x509_username_field,openvpn_x509_cert_t *peer_cert);/* * Return the certificate's serial number.
@@ -138,7 +138,7 @@ result_t x509_get_username (char *common_name, int cn_len,* * @return The certificate's serial number. */ -char *x509_get_serial (x509_cert_t *cert); +char *x509_get_serial (openvpn_x509_cert_t *cert);/* * Free a serial number string as returned by \c verify_get_serial()
@@ -156,7 +156,7 @@ void x509_free_serial (char *serial);* @param cert_depth Depth of the certificate * @param cert Certificate to set the environment for */ -void x509_setenv (struct env_set *es,int cert_depth,x509_cert_t *cert); +void x509_setenv (struct env_set *es,int cert_depth,openvpn_x509_cert_t *cert);#ifdef ENABLE_X509_TRACK
@@ -195,7 +195,7 @@ void x509_track_add (const struct x509_track **ll_head, const char *name,* @param cert Certificate to set the environment for */ void x509_setenv_track (const struct x509_track *xt,struct env_set *es, -const int depth,x509_cert_t *x509); +const int depth,openvpn_x509_cert_t *x509);#endif
@@ -210,9 +210,9 @@ void x509_setenv_track (const struct x509_track *xt, struct env_set *es,* the expected bit set. \c FAILURE if the certificate does * not have NS cert type verification or the wrong bit set. */ -result_t x509_verify_ns_cert_type (const x509_cert_t *cert,const int usage); +result_t x509_verify_ns_cert_type (const openvpn_x509_cert_t *cert,const int usage); -#if OPENSSL_VERSION_NUMBER >=0x00907000L ||USE_POLARSSL +#if OPENSSL_VERSION_NUMBER >=0x00907000L ||ENABLE_CRYPTO_POLARSSL /* * Verify X.509 key usage extension field.
@@ -224,7 +224,7 @@ result_t x509_verify_ns_cert_type(const x509_cert_t *cert, const int usage);* @return \c SUCCESS if one of the key usage values matches, \c FAILURE * if key usage is not enabled, or the values do not match. */ -result_t x509_verify_cert_ku (x509_cert_t *x509,const unsigned *const expected_ku, +result_t x509_verify_cert_ku (openvpn_x509_cert_t *x509,const unsigned *const expected_ku,int expected_len);/*
@@ -240,7 +240,7 @@ result_t x509_verify_cert_ku (x509_cert_t *x509, const unsigned * const expected* extended key usage fields, \c FAILURE if extended key * usage is not enabled, or the values do not match. */ -result_t x509_verify_cert_eku (x509_cert_t *x509,const char *const expected_oid); +result_t x509_verify_cert_eku (openvpn_x509_cert_t *x509,const char *const expected_oid);#endif
@@ -253,7 +253,7 @@ result_t x509_verify_cert_eku (x509_cert_t *x509, const char * const expected_oi* * */ -result_t x509_write_pem (FILE *peercert_file,x509_cert_t *peercert); +result_t x509_write_pem (FILE *peercert_file,openvpn_x509_cert_t *peercert);/* * Check the certificate against a CRL file.
@@ -266,7 +266,7 @@ result_t x509_write_pem(FILE *peercert_file, x509_cert_t *peercert);* certificate or does not contain an entry for it. * \c FAILURE otherwise. */ -result_t x509_verify_crl (const char *crl_file,x509_cert_t *cert, +result_t x509_verify_crl (const char *crl_file,openvpn_x509_cert_t *cert,const char *subject);#endif /* SSL_VERIFY_BACKEND_H_ */
src/openvpn/ssl_verify_openssl.c +5 -5
@@ -29,7 +29,7 @@#include "syshead.h" -#if defined(USE_SSL ) && defined(USE_OPENSSL ) +#if defined(ENABLE_SSL ) && defined(ENABLE_CRYPTO_OPENSSL )#include "ssl_verify.h" #include "ssl_verify_backend.h"
@@ -210,7 +210,7 @@ x509_get_username (char *common_name, int cn_len, }char * -x509_get_serial (x509_cert_t *cert) +x509_get_serial (openvpn_x509_cert_t *cert) {ASN1_INTEGER *asn1_i;BIGNUM *bignum;
@@ -401,7 +401,7 @@ x509_setenv_track (const struct x509_track *xt, struct env_set *es, const int de* X509_{cert_depth}_{name}={value} */ void -x509_setenv (struct env_set *es,int cert_depth,x509_cert_t *peer_cert) +x509_setenv (struct env_set *es,int cert_depth,openvpn_x509_cert_t *peer_cert) {int i, n;int fn_nid;
@@ -449,7 +449,7 @@ x509_setenv (struct env_set *es, int cert_depth, x509_cert_t *peer_cert) }result_t -x509_verify_ns_cert_type (const x509_cert_t *peer_cert,const int usage) +x509_verify_ns_cert_type (const openvpn_x509_cert_t *peer_cert,const int usage) {if (usage ==NS_CERT_CHECK_NONE )return SUCCESS ;
@@ -623,4 +623,4 @@ end: return retval; } -#endif /* defined(USE_SSL) && defined(USE_OPENSSL) */ +#endif /* defined(ENABLE_SSL) && defined(ENABLE_CRYPTO_OPENSSL) */
src/openvpn/ssl_verify_openssl.h +5 -1
@@ -32,7 +32,11 @@#define SSL_VERIFY_OPENSSL_H_ #include <openssl/x509.h> -typedef X509 x509_cert_t ; + +#ifndef __OPENVPN_X509_CERT_T_DECLARED +#define __OPENVPN_X509_CERT_T_DECLARED +typedef X509 openvpn_x509_cert_t ; +#endif /** @name Function for authenticating a new connection from a remote OpenVPN peer * @{ */
src/openvpn/ssl_verify_polarssl.c +3 -3
@@ -29,7 +29,7 @@#include "syshead.h" -#if defined(USE_SSL ) && defined(USE_POLARSSL ) +#if defined(ENABLE_SSL ) && defined(ENABLE_CRYPTO_POLARSSL )#include "ssl_verify.h" #include <polarssl/sha1.h>
@@ -189,7 +189,7 @@ x509_free_subject (char *subject)* X509_{cert_depth}_{name}={value} */ void -x509_setenv (struct env_set *es,int cert_depth,x509_cert_t *cert) +x509_setenv (struct env_set *es,int cert_depth,openvpn_x509_cert_t *cert) {int i;unsigned char c;
@@ -422,4 +422,4 @@ end: return retval; } -#endif /* #if defined(USE_SSL) && defined(USE_POLARSSL) */ +#endif /* #if defined(ENABLE_SSL) && defined(ENABLE_CRYPTO_POLARSSL) */
src/openvpn/ssl_verify_polarssl.h +4 -1
@@ -35,7 +35,10 @@#include "manage.h" #include <polarssl/x509.h> -typedef x509_cert x509_cert_t ; +#ifndef __OPENVPN_X509_CERT_T_DECLARED +#define __OPENVPN_X509_CERT_T_DECLARED +typedef x509_cert openvpn_x509_cert_t ; +#endif /** @name Function for authenticating a new connection from a remote OpenVPN peer * @{ */
src/openvpn/syshead.h +7 -7
@@ -481,7 +481,7 @@ socket_defined (const socket_descriptor_t sd)* Do we have point-to-multipoint capability? */ -#if defined(ENABLE_CLIENT_SERVER ) && defined(USE_CRYPTO ) && defined(USE_SSL ) && defined(HAVE_GETTIMEOFDAY ) +#if defined(ENABLE_CLIENT_SERVER ) && defined(ENABLE_CRYPTO ) && defined(ENABLE_SSL ) && defined(HAVE_GETTIMEOFDAY )#define P2MP 1#else #define P2MP 0
@@ -518,7 +518,7 @@ socket_defined (const socket_descriptor_t sd)/* * Enable external private key */ -#if defined(ENABLE_MANAGEMENT ) && defined(USE_SSL ) && !defined(USE_POLARSSL ) +#if defined(ENABLE_MANAGEMENT ) && defined(ENABLE_SSL ) && !defined(ENABLE_CRYPTO_POLARSSL )#define MANAGMENT_EXTERNAL_KEY #endif
@@ -567,7 +567,7 @@ socket_defined (const socket_descriptor_t sd)/* * Should we include NTLM proxy functionality */ -#if defined(USE_CRYPTO ) && defined(ENABLE_HTTP_PROXY ) +#if defined(ENABLE_CRYPTO ) && defined(ENABLE_HTTP_PROXY )#define NTLM 1#else #define NTLM 0
@@ -576,7 +576,7 @@ socket_defined (const socket_descriptor_t sd)/* * Should we include proxy digest auth functionality */ -#if defined(USE_CRYPTO ) && defined(ENABLE_HTTP_PROXY ) +#if defined(ENABLE_CRYPTO ) && defined(ENABLE_HTTP_PROXY )#define PROXY_DIGEST_AUTH 1#else #define PROXY_DIGEST_AUTH 0
@@ -592,14 +592,14 @@ socket_defined (const socket_descriptor_t sd)/* * Do we have CryptoAPI capability? */ -#if defined(WIN32 ) && defined(USE_CRYPTO ) && defined(USE_SSL ) && defined(USE_OPENSSL ) +#if defined(WIN32 ) && defined(ENABLE_CRYPTO ) && defined(ENABLE_SSL ) && defined(ENABLE_CRYPTO_OPENSSL )#define ENABLE_CRYPTOAPI #endif /* * Enable x509-track feature? */ -#if defined(USE_CRYPTO ) && defined(USE_SSL ) && defined (USE_OPENSSL ) +#if defined(ENABLE_CRYPTO ) && defined(ENABLE_SSL ) && defined (ENABLE_CRYPTO_OPENSSL )#define ENABLE_X509_TRACK #endif
@@ -690,7 +690,7 @@ socket_defined (const socket_descriptor_t sd)/* * Do we support pushing peer info? */ -#if defined(USE_CRYPTO ) && defined(USE_SSL ) +#if defined(ENABLE_CRYPTO ) && defined(ENABLE_SSL )#define ENABLE_PUSH_PEER_INFO #endif
src/plugins/examples/log_v3.c +1 -3
@@ -36,9 +36,7 @@#include <string.h> #include <stdlib.h> -#define USE_SSL -#define USE_OPENSSL -#include "ssl_verify_openssl.h" +#define ENABLE_SSL #include "openvpn-plugin.h"
Signature · 1 line
1.7.3.4
PATCH 41/52 build: autoconf: update defaults for options
In reply to Alon Bar-Lev--- configure.ac | 56 ++++++++++++++++++++++++++++---------------------------- 1 files changed, 28 insertions(+), 28 deletions(-)
configure.ac +28 -28
@@ -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) ;;
Signature · 1 line
1.7.3.4
Re: [Openvpn-devel] [PATCH 41/52] build: autoconf: update defaults for options
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
Signed-off-by Alon Bar-Lev <[email protected]...>--- configure.ac | 56 ++++++++++++++++++++++++++++---------------------------- 1 files changed, 28 insertions(+), 28 deletions(-)configure.ac +28
-29@@ -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
Re: [Openvpn-devel] [PATCH 41/52] build: autoconf: update defaults for options
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, Incirc freenode net: mattock
Quoted 246 lines
Signed-off-by Alon Bar-Lev <[email protected]...>---
configure.ac | 56 ++++++++++++++++++++++++++++----------------------------1 files changed, 28 insertions(+), 28 deletions(-)configure.ac +0
-0@@ -41,195 +41,195 @@ AC_USE_SYSTEM_EXTENSIONSAC_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
PATCH 42/52 build: win-msvc: msbuild format
In reply to Alon Bar-Lev--- .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
@@ -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
@@ -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
@@ -13,3 +13,5 @@ MAINTAINERCLEANFILES = \ EXTRA_DIST = \ ltrc.inc + +SUBDIRS = msvc
build/msvc/Makefile.am new file +15 -0
@@ -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
@@ -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
@@ -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
118 lines not on this page · raw message
build/msvc/msvc-generate/msvc-generate.vcproj new file +74 -0
74 lines not on this page · raw message
config-msvc-version.h.in new file +10 -0
@@ -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
122 lines not on this page · raw message
configure.ac +4 -1
@@ -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
@@ -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
@@ -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
@@ -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
45 lines not on this page · raw message
src/openvpn/Makefile.am +3 -0
@@ -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
@@ -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
@@ -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
769 lines not on this page · raw message
src/openvpn/openvpn_win32_resources.rc +1 -1
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
209 lines not on this page · raw message
src/openvpnserv/openvpnserv_resources.rc +1 -1
@@ -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
@@ -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 -2
@@ -57,8 +57,6 @@ Copyright (C) 1993 - 2000. Microsoft Corporation. All rights reserved.extern "C" {#endif -#include "config.h" -////////////////////////////////////////////////////////////////////////////// //// todo: change to desired strings ////
Signature · 1 line
1.7.3.4
Re: [Openvpn-devel] [PATCH 42/52] build: win-msvc: msbuild format
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
Signed-off-by Alon Bar-Lev <[email protected]...>--- .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@@ -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.shMakefile.am +9
-1@@ -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.inbuild/Makefile.am +2
-0@@ -13,3 +13,5 @@ MAINTAINERCLEANFILES = \ EXTRA_DIST = \ ltrc.inc + +SUBDIRS = msvcbuild/msvc/Makefile.am new file +15
-0@@ -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-generatebuild/msvc/msvc-generate/Makefile.am new file +18
-0@@ -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.jsbuild/msvc/msvc-generate/Makefile.mak new file +13
-0@@ -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@@ -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@@ -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@@ -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@@ -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@@ -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.specmsvc-build.bat new file +34
-0@@ -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 + +endlocalmsvc-dev.bat new file +9
-0@@ -0,0 +1,9 @@ +@echo off + +setlocal +cd %0\.. +call msvc-env.bat + +start "" "%VSHOME%\Common7\IDE\devenv.exe" %SOLUTION% + +endlocalmsvc-env.bat new file +29
-0@@ -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 existopenvpn.sln new file +45
-0@@ -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 +EndGlobalsrc/openvpn/Makefile.am +3
-0@@ -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@@ -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@@ -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@@ -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@@ -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@@ -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@@ -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@@ -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@@ -13,6 +13,9 @@ include $(top_srcdir)/build/ltrc.inc MAINTAINERCLEANFILES = $(srcdir)/Makefile.in +EXTRA_DIST = \ + openvpnserv.vcproj + if WIN32 sbin_PROGRAMS = openvpnserv endifsrc/openvpnserv/openvpnserv.c +10
-6@@ -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@@ -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@@ -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@@ -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@@ -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
PATCH 43/52 build: move out config.h include from syshead
In reply to Alon Bar-LevYet another step in reducing the syshead.h content.
Conditional compilation of sources needs to be based on a minimum program prefix (config.h only).
--- src/openvpn/base64.c | 6 ++++++ src/openvpn/buffer.c | 6 ++++++ src/openvpn/clinat.c | 6 ++++++ src/openvpn/compat.c | 6 ++++++ src/openvpn/crypto.c | 6 ++++++ src/openvpn/crypto_openssl.c | 6 ++++++ src/openvpn/crypto_polarssl.c | 6 ++++++ src/openvpn/cryptoapi.c | 6 ++++++ src/openvpn/dhcp.c | 6 ++++++ src/openvpn/error.c | 6 ++++++ src/openvpn/event.c | 6 ++++++ src/openvpn/fdmisc.c | 6 ++++++ src/openvpn/forward.c | 6 ++++++ src/openvpn/fragment.c | 6 ++++++ src/openvpn/gremlin.c | 6 ++++++ src/openvpn/helper.c | 6 ++++++ src/openvpn/httpdigest.c | 6 ++++++ src/openvpn/init.c | 6 ++++++ src/openvpn/interval.c | 6 ++++++ src/openvpn/list.c | 6 ++++++ src/openvpn/lladdr.c | 6 ++++++ src/openvpn/lzo.c | 6 ++++++ src/openvpn/manage.c | 6 ++++++ src/openvpn/mbuf.c | 6 ++++++ src/openvpn/misc.c | 6 ++++++ src/openvpn/mroute.c | 6 ++++++ src/openvpn/mss.c | 6 ++++++ src/openvpn/mstats.c | 6 ++++++ src/openvpn/mtcp.c | 6 ++++++ src/openvpn/mtu.c | 6 ++++++ src/openvpn/mudp.c | 6 ++++++ src/openvpn/multi.c | 6 ++++++ src/openvpn/ntlm.c | 6 ++++++ src/openvpn/occ.c | 6 ++++++ src/openvpn/openvpn.c | 6 ++++++ src/openvpn/options.c | 6 ++++++ src/openvpn/otime.c | 6 ++++++ src/openvpn/packet_id.c | 6 ++++++ src/openvpn/perf.c | 6 ++++++ src/openvpn/pf.c | 6 ++++++ src/openvpn/ping.c | 6 ++++++ src/openvpn/pkcs11.c | 6 ++++++ src/openvpn/pkcs11_openssl.c | 6 ++++++ src/openvpn/pkcs11_polarssl.c | 6 ++++++ src/openvpn/plugin.c | 6 ++++++ src/openvpn/pool.c | 6 ++++++ src/openvpn/proto.c | 6 ++++++ src/openvpn/proxy.c | 6 ++++++ src/openvpn/ps.c | 6 ++++++ src/openvpn/push.c | 6 ++++++ src/openvpn/reliable.c | 6 ++++++ src/openvpn/route.c | 6 ++++++ src/openvpn/schedule.c | 6 ++++++ src/openvpn/session_id.c | 6 ++++++ src/openvpn/shaper.c | 6 ++++++ src/openvpn/sig.c | 6 ++++++ src/openvpn/socket.c | 6 ++++++ src/openvpn/socks.c | 6 ++++++ src/openvpn/ssl.c | 6 ++++++ src/openvpn/ssl_openssl.c | 6 ++++++ src/openvpn/ssl_polarssl.c | 6 ++++++ src/openvpn/ssl_verify.c | 6 ++++++ src/openvpn/ssl_verify_openssl.c | 6 ++++++ src/openvpn/ssl_verify_polarssl.c | 6 ++++++ src/openvpn/status.c | 6 ++++++ src/openvpn/syshead.h | 9 --------- src/openvpn/tun.c | 6 ++++++ src/openvpn/win32.c | 7 +++++++ 68 files changed, 403 insertions(+), 9 deletions(-)
src/openvpn/base64.c +6 -0
@@ -31,6 +31,12 @@* SUCH DAMAGE. */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#elif defined(_MSC_VER) +#include "config-msvc.h" +#endif +#include "syshead.h" #if defined(ENABLE_HTTP_PROXY ) || defined(ENABLE_PKCS11 ) || defined(ENABLE_CLIENT_CR ) || defined(MANAGMENT_EXTERNAL_KEY )
src/openvpn/buffer.c +6 -0
@@ -22,6 +22,12 @@* 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 "common.h"
src/openvpn/clinat.c +6 -0
@@ -22,6 +22,12 @@* 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" #if defined(ENABLE_CLIENT_NAT )
src/openvpn/compat.c +6 -0
@@ -22,6 +22,12 @@* 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>
src/openvpn/crypto.c +6 -0
@@ -23,6 +23,12 @@* 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" #ifdef ENABLE_CRYPTO
src/openvpn/crypto_openssl.c +6 -0
@@ -27,6 +27,12 @@* @file Data Channel Cryptography OpenSSL-specific backend interface */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#elif defined(_MSC_VER) +#include "config-msvc.h" +#endif +#include "syshead.h" #if defined(ENABLE_CRYPTO ) && defined(ENABLE_CRYPTO_OPENSSL )
src/openvpn/crypto_polarssl.c +6 -0
@@ -27,6 +27,12 @@* @file Data Channel Cryptography PolarSSL-specific backend interface */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#elif defined(_MSC_VER) +#include "config-msvc.h" +#endif +#include "syshead.h" #if defined(ENABLE_CRYPTO ) && defined(ENABLE_CRYPTO_POLARSSL )
src/openvpn/cryptoapi.c +6 -0
@@ -28,6 +28,12 @@* THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#elif defined(_MSC_VER) +#include "config-msvc.h" +#endif +#include "syshead.h" #ifdef ENABLE_CRYPTOAPI
src/openvpn/dhcp.c +6 -0
@@ -22,6 +22,12 @@* 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 "dhcp.h"
src/openvpn/error.c +6 -0
@@ -22,6 +22,12 @@* 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 "error.h"
src/openvpn/event.c +6 -0
@@ -22,6 +22,12 @@* 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"
src/openvpn/fdmisc.c +6 -0
@@ -22,6 +22,12 @@* 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 "fdmisc.h"
src/openvpn/forward.c +6 -0
@@ -22,6 +22,12 @@* 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 "forward.h"
src/openvpn/fragment.c +6 -0
@@ -22,6 +22,12 @@* 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" #ifdef ENABLE_FRAGMENT
src/openvpn/gremlin.c +6 -0
@@ -27,6 +27,12 @@* network outages when the --gremlin option is used. */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#elif defined(_MSC_VER) +#include "config-msvc.h" +#endif +#include "syshead.h" #ifdef ENABLE_DEBUG
src/openvpn/helper.c +6 -0
@@ -22,6 +22,12 @@* 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 "forward.h"
src/openvpn/httpdigest.c +6 -0
@@ -22,6 +22,12 @@* 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" #if PROXY_DIGEST_AUTH
src/openvpn/init.c +6 -0
@@ -22,6 +22,12 @@* 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 "win32.h"
src/openvpn/interval.c +6 -0
@@ -22,6 +22,12 @@* 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 "interval.h"
src/openvpn/list.c +6 -0
@@ -22,6 +22,12 @@* 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" #if P2MP_SERVER
src/openvpn/lladdr.c +6 -0
@@ -2,6 +2,12 @@* Support routine for configuring link layer address */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#elif defined(_MSC_VER) +#include "config-msvc.h" +#endif +#include "syshead.h" #include "error.h" #include "misc.h"
src/openvpn/lzo.c +6 -0
@@ -26,6 +26,12 @@* @file Data Channel Compression module function definitions. */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#elif defined(_MSC_VER) +#include "config-msvc.h" +#endif +#include "syshead.h" #ifdef ENABLE_LZO
src/openvpn/manage.c +6 -0
@@ -22,6 +22,12 @@* 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" #ifdef ENABLE_MANAGEMENT
src/openvpn/mbuf.c +6 -0
@@ -22,6 +22,12 @@* 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" #if P2MP
src/openvpn/misc.c +6 -0
@@ -22,6 +22,12 @@* 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"
src/openvpn/mroute.c +6 -0
@@ -22,6 +22,12 @@* 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" #if P2MP_SERVER
src/openvpn/mss.c +6 -0
@@ -22,6 +22,12 @@* 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 "error.h" #include "mss.h"
src/openvpn/mstats.c +6 -0
@@ -26,6 +26,12 @@* Maintain usage stats in a memory-mapped file */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#elif defined(_MSC_VER) +#include "config-msvc.h" +#endif +#include "syshead.h" #if defined(ENABLE_MEMSTATS )
src/openvpn/mtcp.c +6 -0
@@ -22,6 +22,12 @@* 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" #if P2MP_SERVER
src/openvpn/mtu.c +6 -0
@@ -22,6 +22,12 @@* 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 "common.h"
src/openvpn/mudp.c +6 -0
@@ -22,6 +22,12 @@* 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" #if P2MP_SERVER
src/openvpn/multi.c +6 -0
@@ -22,6 +22,12 @@* 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" #if P2MP_SERVER
src/openvpn/ntlm.c +6 -0
@@ -21,6 +21,12 @@* 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" #if NTLM
src/openvpn/occ.c +6 -0
@@ -22,6 +22,12 @@* 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" #ifdef ENABLE_OCC
src/openvpn/openvpn.c +6 -0
@@ -22,6 +22,12 @@* 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 "init.h"
src/openvpn/options.c +6 -0
@@ -30,6 +30,12 @@* (Christof Meerwald, http://cmeerw.org) */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#elif defined(_MSC_VER) +#include "config-msvc.h" +#endif +#include "syshead.h" #include "buffer.h"
src/openvpn/otime.c +6 -0
@@ -22,6 +22,12 @@* 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 "otime.h"
src/openvpn/packet_id.c +6 -0
@@ -31,6 +31,12 @@* to IPSec. */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#elif defined(_MSC_VER) +#include "config-msvc.h" +#endif +#include "syshead.h" #ifdef ENABLE_CRYPTO
src/openvpn/perf.c +6 -0
@@ -22,6 +22,12 @@* 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 "perf.h"
src/openvpn/pf.c +6 -0
@@ -24,6 +24,12 @@/* packet filter functions */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#elif defined(_MSC_VER) +#include "config-msvc.h" +#endif +#include "syshead.h" #if defined(ENABLE_PF )
src/openvpn/ping.c +6 -0
@@ -22,6 +22,12 @@* 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 "ping.h"
src/openvpn/pkcs11.c +6 -0
@@ -22,6 +22,12 @@* 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" #if defined(ENABLE_PKCS11 )
src/openvpn/pkcs11_openssl.c +6 -0
@@ -27,6 +27,12 @@* @file PKCS #11 OpenSSL backend */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#elif defined(_MSC_VER) +#include "config-msvc.h" +#endif +#include "syshead.h" #if defined(ENABLE_PKCS11 ) && defined(ENABLE_CRYPTO_OPENSSL )
src/openvpn/pkcs11_polarssl.c +6 -0
@@ -27,6 +27,12 @@* @file PKCS #11 PolarSSL backend */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#elif defined(_MSC_VER) +#include "config-msvc.h" +#endif +#include "syshead.h" #if defined(ENABLE_PKCS11 ) && defined(ENABLE_CRYPTO_POLARSSL )
src/openvpn/plugin.c +6 -0
@@ -22,6 +22,12 @@* 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" #ifdef ENABLE_PLUGIN
src/openvpn/pool.c +6 -0
@@ -22,6 +22,12 @@* 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 "pool.h"
src/openvpn/proto.c +6 -0
@@ -22,6 +22,12 @@* 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 "proto.h"
src/openvpn/proxy.c +6 -0
@@ -22,6 +22,12 @@* 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 "common.h"
src/openvpn/ps.c +6 -0
@@ -22,6 +22,12 @@* 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" #if PORT_SHARE
src/openvpn/push.c +6 -0
@@ -22,6 +22,12 @@* 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 "push.h"
src/openvpn/reliable.c +6 -0
@@ -27,6 +27,12 @@* so that SSL/TLS can be run over UDP. */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#elif defined(_MSC_VER) +#include "config-msvc.h" +#endif +#include "syshead.h" #if defined(ENABLE_CRYPTO ) && defined(ENABLE_SSL )
src/openvpn/route.c +6 -0
@@ -26,6 +26,12 @@* Support routines for adding/deleting network routes. */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#elif defined(_MSC_VER) +#include "config-msvc.h" +#endif +#include "syshead.h" #include "common.h"
src/openvpn/schedule.c +6 -0
@@ -22,6 +22,12 @@* 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" #if P2MP_SERVER
src/openvpn/session_id.c +6 -0
@@ -31,6 +31,12 @@* it is called the key_id and is currently 2 bits long. */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#elif defined(_MSC_VER) +#include "config-msvc.h" +#endif +#include "syshead.h" #if defined(ENABLE_CRYPTO ) && defined(ENABLE_SSL )
src/openvpn/shaper.c +6 -0
@@ -22,6 +22,12 @@* 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 "shaper.h" #include "memdbg.h"
src/openvpn/sig.c +6 -0
@@ -22,6 +22,12 @@* 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"
src/openvpn/socket.c +6 -0
@@ -22,6 +22,12 @@* 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 "socket.h"
src/openvpn/socks.c +6 -0
@@ -30,6 +30,12 @@* (Pierre Bourdon <[email protected]...>) */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#elif defined(_MSC_VER) +#include "config-msvc.h" +#endif +#include "syshead.h" #ifdef ENABLE_SOCKS
src/openvpn/ssl.c +6 -0
@@ -39,6 +39,12 @@* over the same TCP/UDP port. */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#elif defined(_MSC_VER) +#include "config-msvc.h" +#endif +#include "syshead.h" #if defined(ENABLE_CRYPTO ) && defined(ENABLE_SSL )
src/openvpn/ssl_openssl.c +6 -0
@@ -27,6 +27,12 @@* @file Control Channel OpenSSL Backend */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#elif defined(_MSC_VER) +#include "config-msvc.h" +#endif +#include "syshead.h" #if defined(ENABLE_SSL ) && defined(ENABLE_CRYPTO_OPENSSL )
src/openvpn/ssl_polarssl.c +6 -0
@@ -27,6 +27,12 @@* @file Control Channel PolarSSL Backend */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#elif defined(_MSC_VER) +#include "config-msvc.h" +#endif +#include "syshead.h" #if defined(ENABLE_SSL ) && defined(ENABLE_CRYPTO_POLARSSL )
src/openvpn/ssl_verify.c +6 -0
@@ -27,6 +27,12 @@* @file Control Channel Verification Module */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#elif defined(_MSC_VER) +#include "config-msvc.h" +#endif +#include "syshead.h" #if defined(ENABLE_CRYPTO ) && defined(ENABLE_SSL )
src/openvpn/ssl_verify_openssl.c +6 -0
@@ -27,6 +27,12 @@* @file Control Channel Verification Module OpenSSL implementation */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#elif defined(_MSC_VER) +#include "config-msvc.h" +#endif +#include "syshead.h" #if defined(ENABLE_SSL ) && defined(ENABLE_CRYPTO_OPENSSL )
src/openvpn/ssl_verify_polarssl.c +6 -0
@@ -27,6 +27,12 @@* @file Control Channel Verification Module PolarSSL backend */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#elif defined(_MSC_VER) +#include "config-msvc.h" +#endif +#include "syshead.h" #if defined(ENABLE_SSL ) && defined(ENABLE_CRYPTO_POLARSSL )
src/openvpn/status.c +6 -0
@@ -22,6 +22,12 @@* 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 "status.h"
src/openvpn/syshead.h +0 -9
@@ -25,15 +25,6 @@#ifndef SYSHEAD_H #define SYSHEAD_H -/* -* Only include if not during configure -*/ -#ifdef HAVE_CONFIG_H -#include "config.h" -#elif defined(_MSC_VER) -#include "config-msvc.h" -#endif -#include "compat.h" /* branch prediction hints */
src/openvpn/tun.c +6 -0
@@ -30,6 +30,12 @@* from VTun by Maxim Krasnyansky <[email protected]...>. */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#elif defined(_MSC_VER) +#include "config-msvc.h" +#endif +#include "syshead.h" #include "tun.h"
src/openvpn/win32.c +7 -0
@@ -26,6 +26,13 @@* Win32-specific OpenVPN code, targetted at the mingw * development environment. */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#elif defined(_MSC_VER) +#include "config-msvc.h" +#endif +#include "syshead.h" #ifdef WIN32
Signature · 1 line
1.7.3.4
PATCH 44/52 build: split out compat
In reply to Alon Bar-Levcompat 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
@@ -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
@@ -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
@@ -15,4 +15,4 @@ MAINTAINERCLEANFILES = \ EXTRA_DIST = \ plugins -SUBDIRS = openvpn openvpnserv +SUBDIRS = compat openvpn openvpnserv
src/compat/Makefile.am new file +23 -0
@@ -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
50 lines not on this page · raw message
src/compat/compat-dirname.c new file +119 -0
119 lines not on this page · raw message
src/compat/compat.h new file +36 -0
@@ -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
181 lines not on this page · raw message
src/openvpn/Makefile.am +4 -2
@@ -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
135 lines not on this page · raw message
src/openvpn/compat.h deleted +0 -40
@@ -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
@@ -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 -0
@@ -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>
Signature · 1 line
1.7.3.4
Re: [Openvpn-devel] [PATCH 44/52] build: split out compat
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.
Signed-off-by Alon Bar-Lev <[email protected]...>--- 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.hconfigure.ac +2
-1@@ -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/Makefileopenvpn.sln +7
-0@@ -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 = FALSEsrc/Makefile.am +1
-1@@ -15,4 +15,4 @@ MAINTAINERCLEANFILES = \ EXTRA_DIST = \ plugins -SUBDIRS = openvpn openvpnserv +SUBDIRS = compat openvpn openvpnservsrc/compat/Makefile.am new file +23
-0@@ -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.csrc/compat/compat-basename.c new file +50
-0@@ -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@@ -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@@ -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@@ -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@@ -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@@ -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@@ -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@@ -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@@ -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
PATCH 45/52 build: move gettimeofday() emulation to compat
In reply to Alon Bar-LevRemove all references to gettimeofday() from main project.
SIDE EFFECT: mingw will use its own internal gettimeofday().
--- config-msvc.h | 1 - configure.ac | 1 - src/compat/Makefile.am | 3 +- src/compat/compat-gettimeofday.c | 131 ++++++++++++++++++++++++++++++++++++++ src/compat/compat.h | 13 ++++ src/compat/compat.vcproj | 4 + src/openvpn/forward.c | 8 +- src/openvpn/init.c | 4 +- src/openvpn/misc.c | 5 -- src/openvpn/openvpn.h | 2 +- src/openvpn/options.c | 8 +- src/openvpn/options.h | 4 +- src/openvpn/otime.c | 84 +----------------------- src/openvpn/otime.h | 17 ++---- src/openvpn/shaper.c | 4 +- src/openvpn/shaper.h | 4 +- src/openvpn/syshead.h | 18 +++++- 17 files changed, 192 insertions(+), 119 deletions(-) create mode 100644 src/compat/compat-gettimeofday.c
config-msvc.h +0 -1
@@ -51,7 +51,6 @@#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
configure.ac +0 -1
@@ -541,7 +541,6 @@ m4_define( [setsockopt getsockopt getsockname poll]dnl ) if test "${WIN32}" = "yes"; then - AC_DEFINE([HAVE_GETTIMEOFDAY], [1], [We fake gettimeofday for win32 at otime.c]) m4_foreach( [F], m4_split(SOCKET_FUNCS SOCKET_OPT_FUNCS),
src/compat/Makefile.am +2 -1
@@ -20,4 +20,5 @@ noinst_LTLIBRARIES = libcompat.la libcompat_la_SOURCES = \ compat.h \ compat-dirname.c \ - compat-basename.c + compat-basename.c \ + compat-gettimeofday.c
src/compat/compat-gettimeofday.c new file +131 -0
131 lines not on this page · raw message
src/compat/compat.h +13 -0
@@ -25,6 +25,15 @@#ifndef COMPAT_H #define COMPAT_H +#ifdef HAVE_WINSOCK2_H +/* timeval */ +#include <winsock2.h> +#endif + +#ifdef HAVE_SYS_TIME_H +#include <sys/time.h> +#endif +#ifndef HAVE_DIRNAME char *dirname (char *str);#endif /* HAVE_DIRNAME */
@@ -33,4 +42,8 @@ char * dirname(char *str);char *basename (char *str);#endif /* HAVE_BASENAME */ +#ifndef HAVE_GETTIMEOFDAY +int gettimeofday (struct timeval *tv,void *tz); +#endif +#endif /* COMPAT_H */
src/compat/compat.vcproj +4 -0
@@ -158,6 +158,10 @@ RelativePath=".\compat-dirname.c" > </File> + <File + RelativePath=".\compat-gettimeofday.c" + > + </File> </Filter> <Filter Name="Header Files"
src/openvpn/forward.c +4 -4
@@ -1094,7 +1094,7 @@ process_outgoing_link (struct context *c)* Let the traffic shaper know how many bytes * we wrote. */ -#ifdef HAVE_GETTIMEOFDAY +#ifdef ENABLE_FEATURE_SHAPER if (c->options.shaper)shaper_wrote_bytes (&c->c2.shaper,BLEN (&c->c2.to_link) +datagram_overhead (c->options.ce.proto));
@@ -1383,7 +1383,7 @@ io_wait_dowork (struct context *c, const unsigned int flags)* quota, don't send -- instead compute the delay we must wait * until it will be OK to send the packet. */ -#ifdef HAVE_GETTIMEOFDAY +#ifdef ENABLE_FEATURE_SHAPER int delay =0 ;/* set traffic shaping delay in microseconds */
@@ -1398,9 +1398,9 @@ io_wait_dowork (struct context *c, const unsigned int flags) {shaper_soonest_event (&c->c2.timeval, delay); } -#else /* HAVE_GETTIMEOFDAY */ +#else /* ENABLE_FEATURE_SHAPER */ socket |=EVENT_WRITE ; -#endif /* HAVE_GETTIMEOFDAY */ +#endif /* ENABLE_FEATURE_SHAPER */ }else {
src/openvpn/init.c +2 -2
@@ -1180,7 +1180,7 @@ do_init_timers (struct context *c, bool deferred)static void do_init_traffic_shaper (struct context *c) { -#ifdef HAVE_GETTIMEOFDAY +#ifdef ENABLE_FEATURE_SHAPER /* initialize traffic shaper (i.e. transmit bandwidth limiter) */ if (c->options.shaper) {
@@ -3056,7 +3056,7 @@ do_setup_fast_io (struct context *c)msg (M_INFO ,"NOTE: --fast-io is disabled since we are not using UDP" ); else { -#ifdef HAVE_GETTIMEOFDAY +#ifdef ENABLE_FEATURE_SHAPER if (c->options.shaper)msg (M_INFO ,"NOTE: --fast-io is disabled since we are using --shaper" );else
src/openvpn/misc.c +0 -5
@@ -720,7 +720,6 @@ openvpn_popen (const struct argv *a, const struct env_set *es)void init_random_seed (void ) { -#ifdef HAVE_GETTIMEOFDAY struct timeval tv;if (!gettimeofday (&tv,NULL ))
@@ -728,10 +727,6 @@ init_random_seed(void)const unsigned int seed = (unsigned int ) tv.tv_sec ^ tv.tv_usec;srandom (seed); } -#else /* HAVE_GETTIMEOFDAY */ -const time_t current =time (NULL ); -srandom ((unsigned int )current); -#endif /* HAVE_GETTIMEOFDAY */ }/* thread-safe strerror */
src/openvpn/openvpn.h +1 -1
@@ -269,7 +269,7 @@ struct context_2struct frame frame_fragment_omit;#endif -#ifdef HAVE_GETTIMEOFDAY +#ifdef ENABLE_FEATURE_SHAPER /* * Traffic shaper object. */
src/openvpn/options.c +4 -4
@@ -1455,7 +1455,7 @@ show_settings (const struct options *o)SHOW_INT (ifconfig_ipv6_netbits);SHOW_STR (ifconfig_ipv6_remote); -#ifdef HAVE_GETTIMEOFDAY +#ifdef ENABLE_FEATURE_SHAPER SHOW_INT (shaper);#endif #ifdef ENABLE_OCC
@@ -4833,7 +4833,7 @@ add_option (struct options *options, }else if (streq (p[0 ],"shaper" ) && p[1 ]) { -#ifdef HAVE_GETTIMEOFDAY +#ifdef ENABLE_FEATURE_SHAPER int shaper;VERIFY_PERMISSION (OPT_P_SHAPER );
@@ -4845,11 +4845,11 @@ add_option (struct options *options, goto err; } options->shaper = shaper; -#else /* HAVE_GETTIMEOFDAY */ +#else /* ENABLE_FEATURE_SHAPER */ VERIFY_PERMISSION (OPT_P_GENERAL );msg (msglevel,"--shaper requires the gettimeofday() function which is missing" ); goto err; -#endif /* HAVE_GETTIMEOFDAY */ +#endif /* ENABLE_FEATURE_SHAPER */ }else if (streq (p[0 ],"port" ) && p[1 ]) {
src/openvpn/options.h +2 -2
@@ -260,7 +260,7 @@ struct optionsconst char *ifconfig_ipv6_remote;bool ifconfig_noexec;bool ifconfig_nowarn; -#ifdef HAVE_GETTIMEOFDAY +#ifdef ENABLE_FEATURE_SHAPER int shaper;#endif
@@ -680,7 +680,7 @@ struct options#define ROUTE_OPTION_FLAGS (o) (0)#endif -#ifdef HAVE_GETTIMEOFDAY +#ifdef ENABLE_FEATURE_SHAPER #define SHAPER_DEFINED (opt) ((opt)->shaper)#else #define SHAPER_DEFINED (opt) (false)
src/openvpn/otime.c +3 -81
108 lines not on this page · raw message
src/openvpn/otime.h +5 -12
@@ -41,10 +41,6 @@ struct frequency_limit *frequency_limit_init (int max, int per);void frequency_limit_free (struct frequency_limit *f);bool frequency_limit_event_allowed (struct frequency_limit *f); -#ifdef WIN32 -int gettimeofday (struct timeval *tv,void *tz); -#endif -/* format a time_t as ascii, or use current time if 0 */ const char *time_string (time_t t,int usec,bool show_usec,struct gc_arena *gc);
@@ -57,7 +53,7 @@ extern time_t now; /* updated frequently to time(NULL) */void time_test (void ); -#if TIME_BACKTRACK_PROTECTION && defined(HAVE_GETTIMEOFDAY ) +#if TIME_BACKTRACK_PROTECTION void update_now (const time_t system_time);
@@ -89,12 +85,13 @@ update_time (void)#endif } -#else /* !(TIME_BACKTRACK_PROTECTION && defined(HAVE_GETTIMEOFDAY)) */ +#else /* !TIME_BACKTRACK_PROTECTION */ static inline void update_time (void ) { -#if defined(WIN32 ) && defined(HAVE_GETTIMEOFDAY ) +#if defined(WIN32 ) +/* on WIN32, gettimeofday is faster than time(NULL) */ struct timeval tv;if (!gettimeofday (&tv,NULL )) {
@@ -108,17 +105,13 @@ update_time (void) #endif } -#ifdef HAVE_GETTIMEOFDAY -static inline int openvpn_gettimeofday (struct timeval *tv,void *tz) {return gettimeofday (tv, tz); } -#endif - -#endif /* TIME_BACKTRACK_PROTECTION && defined(HAVE_GETTIMEOFDAY) */ +#endif /* TIME_BACKTRACK_PROTECTION */ static inline time_t openvpn_time (time_t *t)
src/openvpn/shaper.c +2 -2
@@ -32,7 +32,7 @@#include "shaper.h" #include "memdbg.h" -#ifdef HAVE_GETTIMEOFDAY +#ifdef ENABLE_FEATURE_SHAPER /* * We want to wake up in delay microseconds. If timeval is larger
@@ -98,4 +98,4 @@ shaper_msg (struct shaper *s)#else static void dummy (void ) {} -#endif /* HAVE_GETTIMEOFDAY */ +#endif /* ENABLE_FEATURE_SHAPER */
src/openvpn/shaper.h +2 -2
@@ -27,7 +27,7 @@/*#define SHAPER_DEBUG*/ -#ifdef HAVE_GETTIMEOFDAY +#ifdef ENABLE_FEATURE_SHAPER #include "basic.h" #include "integer.h"
@@ -173,6 +173,6 @@ shaper_change_pct (struct shaper *s, int pct) }#endif -#endif /* HAVE_GETTIMEOFDAY */ +#endif /* ENABLE_FEATURE_SHAPER */ #endif
src/openvpn/syshead.h +17 -1
@@ -383,6 +383,13 @@#endif /* +* Do we have nanoseconds gettimeofday? +*/ +#if defined(HAVE_GETTIMEOFDAY ) || defined(WIN32 ) +#define HAVE_GETTIMEOFDAY_NANOSECONDS 1 +#endif + +/* * Do we have the capability to report extended socket errors? */ #if defined(HAVE_LINUX_TYPES_H ) && defined(HAVE_LINUX_ERRQUEUE_H ) && defined(HAVE_SOCK_EXTENDED_ERR ) && defined(HAVE_MSGHDR ) && defined(HAVE_CMSGHDR ) && defined(CMSG_FIRSTHDR ) && defined(CMSG_NXTHDR ) && defined(IP_RECVERR ) && defined(MSG_ERRQUEUE ) && defined(SOL_IP ) && defined(HAVE_IOVEC )
@@ -486,7 +493,7 @@ socket_defined (const socket_descriptor_t sd)* Do we have point-to-multipoint capability? */ -#if defined(ENABLE_CLIENT_SERVER ) && defined(ENABLE_CRYPTO ) && defined(ENABLE_SSL ) && defined(HAVE_GETTIMEOFDAY ) +#if defined(ENABLE_CLIENT_SERVER ) && defined(ENABLE_CRYPTO ) && defined(ENABLE_SSL ) && defined(HAVE_GETTIMEOFDAY_NANOSECONDS )#define P2MP 1#else #define P2MP 0
@@ -667,7 +674,16 @@ socket_defined (const socket_descriptor_t sd)* Reduce sensitivity to system clock instability * and backtracks. */ +#if defined(HAVE_GETTIMEOFDAY_NANOSECONDS )#define TIME_BACKTRACK_PROTECTION 1 +#endif + +/* +* Enable traffic shaper. +*/ +#if defined(HAVE_GETTIMEOFDAY_NANOSECONDS ) +#define ENABLE_FEATURE_SHAPER 1 +#endif /* * Is non-blocking connect() supported?
Signature · 1 line
1.7.3.4
PATCH 46/52 build: move daemon() emulation into compat
In reply to Alon Bar-Lev--- 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
@@ -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
100 lines not on this page · raw message
src/compat/compat.h +4 -0
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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);
Signature · 1 line
1.7.3.4
Re: [Openvpn-devel] [PATCH 46/52] build: move daemon() emulation into compat
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
Signed-off-by Alon Bar-Lev <[email protected]...>--- 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.csrc/compat/Makefile.am +2
-1@@ -21,4 +21,5 @@ libcompat_la_SOURCES = \ compat.h \ compat-dirname.c \ compat-basename.c \ - compat-gettimeofday.c + compat-gettimeofday.c \ + compat-daemon.csrc/compat/compat-daemon.c new file +100
-0@@ -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@@ -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@@ -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@@ -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@@ -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@@ -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);
Re: [Openvpn-devel] [PATCH 46/52] build: move daemon() emulation into compat
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, Incirc freenode net: mattock
Quoted 228 lines
Signed-off-by Alon Bar-Lev <[email protected]...>---
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.csrc/compat/Makefile.am +2
-1@@ -21,4 +21,5 @@ libcompat_la_SOURCES = \ compat.h \ compat-dirname.c \ compat-basename.c \ - compat-gettimeofday.c + compat-gettimeofday.c \ + compat-daemon.csrc/compat/compat-daemon.c new file +100
-0@@ -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@@ -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@@ -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@@ -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@@ -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@@ -115,10 +115,6 @@ unsigned int openvpn_getpid (void);void
do_mlockall(boolprint_msg); /* Disable paging */src/openvpn/misc.h +0
-4-#ifndef HAVE_DAEMON -int daemon (int nochdir,int noclose); -#endif -/* check file protections */
voidwarn_if_group_others_accessible(const char* filename);
PATCH 47/52 build: move inet_ntop(), inet_pton() emulation into compat
In reply to Alon Bar-Lev--- configure.ac | 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
@@ -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
@@ -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
76 lines not on this page · raw message
src/compat/compat-inet_pton.c new file +79 -0
79 lines not on this page · raw message
src/compat/compat.h +16 -1
@@ -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
@@ -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
61 lines not on this page · raw message
src/openvpn/win32.h +0 -6
@@ -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 ();
Signature · 1 line
1.7.3.4
Re: [Openvpn-devel] [PATCH 47/52] build: move inet_ntop(), inet_pton() emulation into compat
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
Signed-off-by Alon Bar-Lev <[email protected]...>---
configure.ac I recall many issues withinet_ntopandinet_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.cconfigure.ac +1
-1@@ -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@@ -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.csrc/compat/compat-inet_ntop.c new file +76
-0@@ -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@@ -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@@ -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@@ -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@@ -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@@ -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
Re: [Openvpn-devel] [PATCH 47/52] build: move inet_ntop(), inet_pton() emulation into compat
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_ptonandinet_ntopunder src/compat. The actual code changes seem fairly trivial.ACK.
--
Samuli Seppänen
Community Manager
OpenVPN Technologies, Incirc 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
Signed-off-by Alon Bar-Lev <[email protected]...>---
configure.ac I recall many issues withinet_ntopandinet_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 100644src/compat/compat-inet_pton.cconfigure.ac +1
-1@@ -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@@ -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.csrc/compat/compat-inet_ntop.c new file +76
-0@@ -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@@ -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@@ -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@@ -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@@ -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 (structlink_socket*sock, int maxsize) {src/openvpn/win32.h +0
-7@@ -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
Re: [Openvpn-devel] [PATCH 47/52] build: move inet_ntop(), inet_pton() emulation into compat
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_ptonandinet_ntopunder src/compat. The actual code changes seem fairly trivial.ACK.
--
Samuli Seppänen
Community Manager
OpenVPN Technologies, Incirc 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
Signed-off-by Alon Bar-Lev <[email protected]...>---
configure.ac I recall many issues withinet_ntopandinet_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.cconfigure.ac +1
-1@@ -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@@ -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.csrc/compat/compat-inet_ntop.c new file +76
-0@@ -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@@ -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@@ -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@@ -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@@ -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@@ -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
PATCH 48/52 cleanup: move console related function into its own module
In reply to Alon Bar-Lev--- 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
@@ -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
238 lines not on this page · raw message
src/openvpn/console.h new file +33 -0
@@ -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
137 lines not on this page · raw message
src/openvpn/misc.h +1 -2
@@ -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
@@ -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
@@ -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
99 lines not on this page · raw message
src/openvpn/win32.h +2 -3
@@ -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);
Signature · 1 line
1.7.3.4
Re: [Openvpn-devel] [PATCH 48/52] cleanup: move console related function into its own module
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
Signed-off-by Alon Bar-Lev <[email protected]...>--- 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.hsrc/openvpn/Makefile.am +1
-0@@ -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@@ -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@@ -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@@ -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@@ -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@@ -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@@ -40,6 +40,7 @@#include "pkcs11.h" #include "misc.h" #include "otime.h" +#include "console.h" #include "pkcs11_backend.h" staticsrc/openvpn/win32.c +1
-86@@ -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@@ -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
Re: [Openvpn-devel] [PATCH 48/52] cleanup: move console related function into its own module
Hi,
Quoted 9 lines · Samuli Seppänen
Currently many files (42) include
misc.h, which is a lot. Also,misc.cis 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.
ACK on the actual changes.
I verified that the code only moves, and is not changed.
Three exceptions from "code only moves":
- getpass() disappears, because it's dead code anyway
- the declaration of cmd[256] from get_console_input_systemd() disappears, because it's unused
- a few 'static' declarations need to go away
but these are fine, so ACK.
gert
Signature · 4 lines
USENET is *not* the non-clickable part of WWW!
//www.muc.de/~gert/
Gert Doering - Munich, Germany [email protected]...
fax: +49-89-35655025 [email protected]...PATCH 49/52 build: move wrappers into platform module
In reply to Alon Bar-Lev+ 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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
399 lines not on this page · raw message
src/openvpn/misc.h +1 -105
164 lines not on this page · raw message
src/openvpn/mstats.c +1 -1
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
369 lines not on this page · raw message
src/openvpn/platform.h new file +142 -0
142 lines not on this page · raw message
src/openvpn/ps.c +1 -1
@@ -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
@@ -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
@@ -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
@@ -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
@@ -1545,22 +1545,22 @@ tuncfg (const char *dev, const char *dev_type, const char *dev_node, int persistmsg (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 -27
@@ -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 */
Signature · 1 line
1.7.3.4
Re: [Openvpn-devel] [PATCH 49/52] build: move wrappers into platform module
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.cfunctions.
- need to check environment set on Windows.Signed-off-by Alon Bar-Lev <[email protected]...>--- 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.hsrc/openvpn/Makefile.am +1
-0@@ -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@@ -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@@ -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@@ -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@@ -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@@ -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@@ -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 unsiconst 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@@ -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 unsignbool 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 unsignreturn 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@@ -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@@ -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@@ -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@@ -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@@ -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@@ -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@@ -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@@ -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@@ -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@@ -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@@ -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@@ -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@@ -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@@ -1545,22 +1545,22 @@ tuncfg (const char *dev, const char *dev_type, const char *dev_node, int persistmsg (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@@ -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