support OpenVPN 2.4/compiler issues?
fkooman opened this issue · 4 comments
Hi,
I'm trying to compile the plugin on CentOS 7 which currently has OpenVPN 2.4.2. I installed the openvpn-devel
package which includes /usr/include/openvpn-plugin.h
before attempting make
.
$ rpm -q openvpn gcc glibc
openvpn-2.4.2-2.el7.x86_64
gcc-4.8.5-11.el7.x86_64
glibc-2.17-157.el7_3.1.x86_64
Building:
$ make
gcc -std=c99 -Wall -Wextra -Wformat-security -fstack-protector-strong -D_FORTIFY_SOURCE=2 -fPIC -shared -I. -c auth_script.c
In file included from /usr/include/errno.h:28:0,
from auth_script.c:18:
/usr/include/features.h:330:4: warning: #warning _FORTIFY_SOURCE requires compiling with optimization (-O) [-Wcpp]
# warning _FORTIFY_SOURCE requires compiling with optimization (-O)
^
In file included from auth_script.c:19:0:
/usr/include/openvpn-plugin.h:271:53: error: unknown type name ‘size_t’
typedef void (*plugin_secure_memzero_t)(void *data, size_t len);
^
/usr/include/openvpn-plugin.h:294:5: error: unknown type name ‘plugin_secure_memzero_t’
plugin_secure_memzero_t plugin_secure_memzero;
^
auth_script.c: In function ‘handle_sigchld’:
auth_script.c:39:3: warning: implicit declaration of function ‘waitpid’ [-Wimplicit-function-declaration]
while(waitpid((pid_t)(-1), 0, WNOHANG) > 0) {}
^
auth_script.c:39:18: error: ‘pid_t’ undeclared (first use in this function)
while(waitpid((pid_t)(-1), 0, WNOHANG) > 0) {}
^
auth_script.c:39:18: note: each undeclared identifier is reported only once for each function it appears in
auth_script.c:39:33: error: ‘WNOHANG’ undeclared (first use in this function)
while(waitpid((pid_t)(-1), 0, WNOHANG) > 0) {}
^
auth_script.c: In function ‘deferred_handler’:
auth_script.c:50:20: error: storage size of ‘sa’ isn’t known
struct sigaction sa;
^
auth_script.c:51:3: warning: implicit declaration of function ‘strdup’ [-Wimplicit-function-declaration]
char *script_path = strdup(context->script_path);
^
auth_script.c:51:23: warning: initialization makes pointer from integer without a cast [enabled by default]
char *script_path = strdup(context->script_path);
^
auth_script.c:57:3: warning: implicit declaration of function ‘sigemptyset’ [-Wimplicit-function-declaration]
sigemptyset(&sa.sa_mask);
^
auth_script.c:58:17: error: ‘SA_RESTART’ undeclared (first use in this function)
sa.sa_flags = SA_RESTART | SA_NOCLDSTOP;
^
auth_script.c:58:30: error: ‘SA_NOCLDSTOP’ undeclared (first use in this function)
sa.sa_flags = SA_RESTART | SA_NOCLDSTOP;
^
auth_script.c:60:3: warning: implicit declaration of function ‘sigaction’ [-Wimplicit-function-declaration]
if (sigaction(SIGCHLD, &sa, 0) == -1) {
^
auth_script.c:50:20: warning: unused variable ‘sa’ [-Wunused-variable]
struct sigaction sa;
^
auth_script.c: In function ‘openvpn_plugin_open_v3’:
auth_script.c:175:26: warning: assignment makes pointer from integer without a cast [enabled by default]
context->script_path = strdup(arguments->argv[1]);
^
make: *** [plugin] Error 1
The "included" OpenVPN defer test plugin compiles without issues:
$ cp -r /usr/share/doc/openvpn-2.4.2/sample/sample-plugins/defer ~/
$ cd defer/
$ sh ./build simple
$ ls -l simple*
-rw-r--r--. 1 centos centos 9982 May 23 09:25 simple.c
-rw-r--r--. 1 centos centos 178 May 23 09:25 simple.def
-rw-rw-r--. 1 centos centos 26664 May 23 09:25 simple.o
-rwxrwxr-x. 1 centos centos 25400 May 23 09:25 simple.so
Hey,
Thanks for raising the issue, I hadn't checked it on CentOS at all. Just given it a quick poke and added what I think is missing to get it going.
Could you test the changes in https://github.com/fac/auth-script-openvpn/compare/centos7 please and see if that works for you? I'll look at getting them pulled into master if so.
Thanks!
Hi, I tested compiling it just now on CentOS 7 and Fedora 25. Both work! I didn't test actually using it, that will be next! Thanks so much!
@caius the branch commits fix the compilation issue on Ubuntu 17.04 as well - thanks!
PR is now merged, many thanks for your help 😄