From patchwork Thu Apr 22 15:29:34 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [Openvpn-devel,v2,1/6] Avoid failing_test unused warning in example_test X-Patchwork-Submitter: Arne Schwabe X-Patchwork-Id: 1770 Message-Id: <20210422152939.2134046-1-arne@rfc2549.org> To: openvpn-devel@lists.sourceforge.net Date: Thu, 22 Apr 2021 17:29:34 +0200 From: Arne Schwabe List-Id: This warnings makes make check fail if Werror is exmaple on LLVM/Clang on macOS for me. Signed-off-by: Arne Schwabe Acked-by: Gert Doering Acked-by: Gert Doering --- tests/unit_tests/example_test/test.c | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/unit_tests/example_test/test.c b/tests/unit_tests/example_test/test.c index bc3fdc17c..ea31b884d 100644 --- a/tests/unit_tests/example_test/test.c +++ b/tests/unit_tests/example_test/test.c @@ -38,6 +38,7 @@ int_test_success(void **state) assert_int_equal(*answer, 42); } +__attribute__((unused)) static void failing_test(void **state) { From patchwork Thu Apr 22 15:29:35 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [Openvpn-devel,v2,2/6] Remove --disable-multihome option X-Patchwork-Submitter: Arne Schwabe X-Patchwork-Id: 1768 Message-Id: <20210422152939.2134046-2-arne@rfc2549.org> To: openvpn-devel@lists.sourceforge.net Date: Thu, 22 Apr 2021 17:29:35 +0200 From: Arne Schwabe List-Id: With this change we always build multihome support if the operating system supports it. Patch v2: Remove also from config-msvc.h Signed-off-by: Arne Schwabe --- config-msvc.h | 1 - configure.ac | 7 ------- src/openvpn/syshead.h | 2 +- 3 files changed, 1 insertion(+), 9 deletions(-) diff --git a/config-msvc.h b/config-msvc.h index 2d5e1a51c..3750f0799 100644 --- a/config-msvc.h +++ b/config-msvc.h @@ -10,7 +10,6 @@ #define ENABLE_LZO 1 #define ENABLE_LZ4 1 #define ENABLE_MANAGEMENT 1 -#define ENABLE_MULTIHOME 1 #define ENABLE_PKCS11 1 #define ENABLE_PLUGIN 1 #define ENABLE_PORT_SHARE 1 diff --git a/configure.ac b/configure.ac index 747325164..aaac65c3d 100644 --- a/configure.ac +++ b/configure.ac @@ -121,13 +121,6 @@ AC_ARG_ENABLE( [enable_fragment="yes"] ) -AC_ARG_ENABLE( - [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) @<:@default=yes@:>@])], diff --git a/src/openvpn/syshead.h b/src/openvpn/syshead.h index e7657b880..4650846fe 100644 --- a/src/openvpn/syshead.h +++ b/src/openvpn/syshead.h @@ -391,7 +391,7 @@ typedef int MIB_TCP_STATE; * Does this platform support linux-style IP_PKTINFO * or bsd-style IP_RECVDSTADDR ? */ -#if defined(ENABLE_MULTIHOME) && ((defined(HAVE_IN_PKTINFO) && defined(IP_PKTINFO)) || defined(IP_RECVDSTADDR)) && defined(HAVE_MSGHDR) && defined(HAVE_CMSGHDR) && defined(HAVE_IOVEC) && defined(CMSG_FIRSTHDR) && defined(CMSG_NXTHDR) && defined(HAVE_RECVMSG) && defined(HAVE_SENDMSG) +#if ((defined(HAVE_IN_PKTINFO) && defined(IP_PKTINFO)) || defined(IP_RECVDSTADDR)) && defined(HAVE_MSGHDR) && defined(HAVE_CMSGHDR) && defined(HAVE_IOVEC) && defined(CMSG_FIRSTHDR) && defined(CMSG_NXTHDR) && defined(HAVE_RECVMSG) && defined(HAVE_SENDMSG) #define ENABLE_IP_PKTINFO 1 #else #define ENABLE_IP_PKTINFO 0 From patchwork Thu Apr 22 15:29:36 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [Openvpn-devel,v2,3/6] Move direct.h header where it is used X-Patchwork-Submitter: Arne Schwabe X-Patchwork-Id: 1769 Message-Id: <20210422152939.2134046-3-arne@rfc2549.org> To: openvpn-devel@lists.sourceforge.net Date: Thu, 22 Apr 2021 17:29:36 +0200 From: Arne Schwabe List-Id: The direct.h header provides only a handful of functions [1] of which we only use _wchdir. Directly included the direct.h file where it is used and remove autoconf magic around it. [1] https://docs.microsoft.com/en-us/previous-versions/visualstudio/visual-studio-2012/as5kw0ze(v=vs.110)?redirectedfrom=MSDN Patch V2: also remove from config-msvc.h Signed-off-by: Arne Schwabe Acked-by: Gert Doering --- config-msvc.h | 1 - configure.ac | 2 +- src/openvpn/platform.c | 4 ++++ src/openvpn/syshead.h | 4 ---- 4 files changed, 5 insertions(+), 6 deletions(-) diff --git a/config-msvc.h b/config-msvc.h index 3750f0799..e73dd8c6f 100644 --- a/config-msvc.h +++ b/config-msvc.h @@ -29,7 +29,6 @@ #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 diff --git a/configure.ac b/configure.ac index aaac65c3d..a67bf2595 100644 --- a/configure.ac +++ b/configure.ac @@ -407,7 +407,7 @@ AX_TYPE_SOCKLEN_T AC_CHECK_SIZEOF([unsigned int]) AC_CHECK_SIZEOF([unsigned long]) AC_CHECK_HEADERS([ \ - fcntl.h io.h direct.h \ + fcntl.h io.h \ sys/types.h sys/socket.h \ unistd.h dlfcn.h \ netinet/in.h netinet/in_systm.h \ diff --git a/src/openvpn/platform.c b/src/openvpn/platform.c index 45ee54541..c63c1d994 100644 --- a/src/openvpn/platform.c +++ b/src/openvpn/platform.c @@ -39,6 +39,10 @@ #include "platform.h" +#if _WIN32 +#include +#endif + /* Redefine the top level directory of the filesystem * to restrict access to files for security */ void diff --git a/src/openvpn/syshead.h b/src/openvpn/syshead.h index 4650846fe..f29c63c73 100644 --- a/src/openvpn/syshead.h +++ b/src/openvpn/syshead.h @@ -100,10 +100,6 @@ #include #endif -#ifdef HAVE_DIRECT_H -#include -#endif - #ifdef HAVE_IO_H #include #endif From patchwork Thu Apr 22 15:29:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [Openvpn-devel,v2,4/6] Remove support for blocking connect() X-Patchwork-Submitter: Arne Schwabe X-Patchwork-Id: 1771 Message-Id: <20210422152939.2134046-4-arne@rfc2549.org> To: openvpn-devel@lists.sourceforge.net Date: Thu, 22 Apr 2021 17:29:37 +0200 From: Arne Schwabe List-Id: It is hard to imagine that we still have any supported OS that does not support non-blocking connect while still supporting non-blocking sockets in general. Patch V2: remove epoll.h removal that should have been in other patch. Signed-off-by: Arne Schwabe --- src/openvpn/socket.c | 8 -------- src/openvpn/syshead.h | 7 ------- 2 files changed, 15 deletions(-) diff --git a/src/openvpn/socket.c b/src/openvpn/socket.c index 8a6e42cc6..4e13c65e8 100644 --- a/src/openvpn/socket.c +++ b/src/openvpn/socket.c @@ -1459,7 +1459,6 @@ openvpn_connect(socket_descriptor_t sd, protect_fd_nonlocal(sd, remote); #endif -#ifdef CONNECT_NONBLOCK set_nonblock(sd); status = connect(sd, remote, af_addr_size(remote->sa_family)); if (status) @@ -1540,13 +1539,6 @@ openvpn_connect(socket_descriptor_t sd, } } } -#else /* ifdef CONNECT_NONBLOCK */ - status = connect(sd, remote, af_addr_size(remote->sa_family)); - if (status) - { - status = openvpn_errno(); - } -#endif /* ifdef CONNECT_NONBLOCK */ return status; } diff --git a/src/openvpn/syshead.h b/src/openvpn/syshead.h index f29c63c73..3f2e563b7 100644 --- a/src/openvpn/syshead.h +++ b/src/openvpn/syshead.h @@ -545,13 +545,6 @@ socket_defined(const socket_descriptor_t sd) #define EPOLL 0 #endif -/* - * Is non-blocking connect() supported? - */ -#if defined(SOL_SOCKET) && defined(SO_ERROR) && defined(EINPROGRESS) && defined(ETIMEDOUT) -#define CONNECT_NONBLOCK -#endif - /* * Compression support */ From patchwork Thu Apr 22 15:29:38 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [Openvpn-devel,v2,5/6] Replace OS_SPECIFIC_DIRSEP with PATH_SEPARATOR X-Patchwork-Submitter: Arne Schwabe X-Patchwork-Id: 1767 Message-Id: <20210422152939.2134046-5-arne@rfc2549.org> To: openvpn-devel@lists.sourceforge.net Date: Thu, 22 Apr 2021 17:29:38 +0200 From: Arne Schwabe List-Id: We have two define that do exactly the same. Also move the check from configure.ac to syshead.h since it is really only checking for Windows. Patch V2: Also remove from config-msvc.h Signed-off-by: Arne Schwabe Acked-by: Gert Doering --- config-msvc.h | 3 --- configure.ac | 8 -------- src/openvpn/platform.c | 2 +- src/openvpn/ssl_verify.c | 2 +- src/openvpn/syshead.h | 6 ++++-- 5 files changed, 6 insertions(+), 15 deletions(-) diff --git a/config-msvc.h b/config-msvc.h index e73dd8c6f..979232282 100644 --- a/config-msvc.h +++ b/config-msvc.h @@ -80,9 +80,6 @@ #define HAVE_EVP_CIPHER_CTX_RESET 1 #define HAVE_DIINSTALLDEVICE 1 -#define PATH_SEPARATOR '\\' -#define PATH_SEPARATOR_STR "\\" - #ifndef __cplusplus #define inline __inline #endif diff --git a/configure.ac b/configure.ac index a67bf2595..3b4d3cbc7 100644 --- a/configure.ac +++ b/configure.ac @@ -1133,14 +1133,6 @@ if test -n "${GIT}" -a -d "${srcdir}/.git"; then fi AC_MSG_RESULT([${GIT_CHECKOUT}]) -if test -n "${SP_PLATFORM_WINDOWS}"; then - AC_DEFINE_UNQUOTED([PATH_SEPARATOR], ['\\\\'], [Path separator]) #" - AC_DEFINE_UNQUOTED([PATH_SEPARATOR_STR], ["\\\\"], [Path separator]) #" -else - AC_DEFINE_UNQUOTED([PATH_SEPARATOR], ['/'], [Path separator]) - AC_DEFINE_UNQUOTED([PATH_SEPARATOR_STR], ["/"], [Path separator]) -fi - dnl enable --x509-username-field feature if requested if test "${enable_x509_alt_username}" = "yes"; then if test "${with_crypto_library}" = "mbedtls" ; then diff --git a/src/openvpn/platform.c b/src/openvpn/platform.c index c63c1d994..bf7b1aa0a 100644 --- a/src/openvpn/platform.c +++ b/src/openvpn/platform.c @@ -486,7 +486,7 @@ platform_gen_path(const char *directory, const char *filename, struct buffer out = alloc_buf_gc(outsize, gc); char dirsep[2]; - dirsep[0] = OS_SPECIFIC_DIRSEP; + dirsep[0] = PATH_SEPARATOR; dirsep[1] = '\0'; if (directory) diff --git a/src/openvpn/ssl_verify.c b/src/openvpn/ssl_verify.c index 7608155cd..14aaf2bf7 100644 --- a/src/openvpn/ssl_verify.c +++ b/src/openvpn/ssl_verify.c @@ -616,7 +616,7 @@ verify_check_crl_dir(const char *crl_dir, openvpn_x509_cert_t *cert, goto cleanup; } - if (!openvpn_snprintf(fn, sizeof(fn), "%s%c%s", crl_dir, OS_SPECIFIC_DIRSEP, serial)) + if (!openvpn_snprintf(fn, sizeof(fn), "%s%c%s", crl_dir, PATH_SEPARATOR, serial)) { msg(D_HANDSHAKE, "VERIFY CRL: filename overflow"); goto cleanup; diff --git a/src/openvpn/syshead.h b/src/openvpn/syshead.h index 3f2e563b7..bc628eac4 100644 --- a/src/openvpn/syshead.h +++ b/src/openvpn/syshead.h @@ -436,9 +436,11 @@ typedef unsigned short sa_family_t; * Directory separation char */ #ifdef _WIN32 -#define OS_SPECIFIC_DIRSEP '\\' +#define PATH_SEPARATOR '\\' +#define PATH_SEPARATOR_STR "\\" #else -#define OS_SPECIFIC_DIRSEP '/' +#define PATH_SEPARATOR '/' +#define PATH_SEPARATOR_STR "/" #endif /* From patchwork Thu Apr 22 15:29:39 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [Openvpn-devel,v2,6/6] Remove a number of platform specific checks in configure.ac X-Patchwork-Submitter: Arne Schwabe X-Patchwork-Id: 1766 Message-Id: <20210422152939.2134046-6-arne@rfc2549.org> To: openvpn-devel@lists.sourceforge.net Date: Thu, 22 Apr 2021 17:29:39 +0200 From: Arne Schwabe List-Id: - Remove windows XP/old mingw compat code in socket.c - Use _WIN32 instead checking for existence of windows.h, winsock2.h and ws2tcpip.h in autconf - Remove check for unlink. The last remaining use is a check inside a Unix socket. - Even Windows has umask, so remove the check for it - Move epoll.h inclusion to event.c Patch V2: Add epoll.h syshead.h that accidently was put into another patch Signed-off-by: Arne Schwabe Acked-by: Gert Doering --- configure.ac | 11 +++++------ src/compat/compat.h | 5 +---- src/openvpn/event.c | 4 ++++ src/openvpn/socket.c | 16 ---------------- src/openvpn/syshead.h | 16 ++-------------- 5 files changed, 12 insertions(+), 40 deletions(-) diff --git a/configure.ac b/configure.ac index 3b4d3cbc7..94897c863 100644 --- a/configure.ac +++ b/configure.ac @@ -412,7 +412,6 @@ AC_CHECK_HEADERS([ \ unistd.h dlfcn.h \ netinet/in.h netinet/in_systm.h \ netinet/tcp.h arpa/inet.h netdb.h \ - windows.h winsock2.h ws2tcpip.h \ versionhelpers.h \ ]) AC_CHECK_HEADERS([ \ @@ -438,13 +437,13 @@ SOCKET_INCLUDES=" #ifdef HAVE_NETINET_IN_H #include #endif -#ifdef HAVE_WINDOWS_H +#ifdef _WIN32 #include #endif -#ifdef HAVE_WINSOCK2_H +#ifdef _WIN32 #include #endif -#ifdef HAVE_WS2TCPIP_H +#ifdef _WIN32 #include #endif #ifdef HAVE_NETINET_IN_SYSTM_H @@ -623,8 +622,8 @@ AC_CHECK_FUNCS([ \ daemon chroot getpwnam setuid nice system getpid dup dup2 \ syslog openlog mlockall getrlimit getgrnam setgid \ setgroups flock readv writev time gettimeofday \ - setsid chdir getpeername unlink \ - chsize ftruncate execve getpeereid umask basename dirname access \ + setsid chdir getpeername \ + chsize ftruncate execve getpeereid basename dirname access \ epoll_create strsep \ ]) diff --git a/src/compat/compat.h b/src/compat/compat.h index 2bf48a5eb..026974a81 100644 --- a/src/compat/compat.h +++ b/src/compat/compat.h @@ -24,11 +24,8 @@ #ifndef COMPAT_H #define COMPAT_H -#ifdef HAVE_WINSOCK2_H +#ifdef _WIN32 #include -#endif - -#ifdef HAVE_WS2TCPIP_H #include #endif diff --git a/src/openvpn/event.c b/src/openvpn/event.c index 14a25155c..d766f8be8 100644 --- a/src/openvpn/event.c +++ b/src/openvpn/event.c @@ -35,6 +35,10 @@ #include "event.h" #include "fdmisc.h" +#if EPOLL +#include +#endif + #include "memdbg.h" /* diff --git a/src/openvpn/socket.c b/src/openvpn/socket.c index 4e13c65e8..01c65b3e0 100644 --- a/src/openvpn/socket.c +++ b/src/openvpn/socket.c @@ -1385,14 +1385,6 @@ socket_listen_accept(socket_descriptor_t sd, return new_sd; } -/* older mingw versions and WinXP do not have this define, - * but Vista and up support the functionality - just define it here - */ -#ifdef _WIN32 -#ifndef IPV6_V6ONLY -#define IPV6_V6ONLY 27 -#endif -#endif void socket_bind(socket_descriptor_t sd, struct addrinfo *local, @@ -3905,10 +3897,7 @@ socket_bind_unix(socket_descriptor_t sd, const char *prefix) { struct gc_arena gc = gc_new(); - -#ifdef HAVE_UMASK const mode_t orig_umask = umask(0); -#endif if (bind(sd, (struct sockaddr *) local, sizeof(struct sockaddr_un))) { @@ -3919,10 +3908,7 @@ socket_bind_unix(socket_descriptor_t sd, sockaddr_unix_name(local, "NULL")); } -#ifdef HAVE_UMASK umask(orig_umask); -#endif - gc_free(&gc); } @@ -3967,12 +3953,10 @@ void socket_delete_unix(const struct sockaddr_un *local) { const char *name = sockaddr_unix_name(local, NULL); -#ifdef HAVE_UNLINK if (name && strlen(name)) { unlink(name); } -#endif } bool diff --git a/src/openvpn/syshead.h b/src/openvpn/syshead.h index bc628eac4..a9680f72f 100644 --- a/src/openvpn/syshead.h +++ b/src/openvpn/syshead.h @@ -100,10 +100,6 @@ #include #endif -#ifdef HAVE_IO_H -#include -#endif - #ifdef HAVE_SYS_FILE_H #include #endif @@ -155,10 +151,6 @@ #include #endif -#ifdef HAVE_SYS_EPOLL_H -#include -#endif - #ifdef ENABLE_SELINUX #include #endif @@ -342,6 +334,8 @@ typedef int MIB_TCP_STATE; #include #include #include +#include + /* The following two headers are needed of PF_INET6 */ #include #include @@ -541,12 +535,6 @@ socket_defined(const socket_descriptor_t sd) #define EPOLL 0 #endif -/* Disable EPOLL */ -#if 0 -#undef EPOLL -#define EPOLL 0 -#endif - /* * Compression support */