mirror of
https://gitlab.com/openconnect/ocserv.git
synced 2026-10-13 18:12:03 +08:00
several updates to allow compilation on FreeBSD
This commit is contained in:
@@ -1,3 +1,8 @@
|
|||||||
|
* Version 0.1.2 (unreleased)
|
||||||
|
|
||||||
|
- Several updates to allow compilation in FreeBSD.
|
||||||
|
|
||||||
|
|
||||||
* Version 0.1.1 (released 2013-04-03)
|
* Version 0.1.1 (released 2013-04-03)
|
||||||
|
|
||||||
- MTU discovery was simplified.
|
- MTU discovery was simplified.
|
||||||
|
|||||||
+1
-1
@@ -18,7 +18,7 @@ ocserv_SOURCES = main.c main-auth.c worker-vpn.c worker-auth.c tlslib.c \
|
|||||||
config.c pam.c pam.h worker-resume.c worker.h main-resume.c main.h \
|
config.c pam.c pam.h worker-resume.c worker.h main-resume.c main.h \
|
||||||
main-user.c cookies-gdbm.c cookies-hash.c worker-misc.c setproctitle.h \
|
main-user.c cookies-gdbm.c cookies-hash.c worker-misc.c setproctitle.h \
|
||||||
setproctitle.c worker-privs.c plain.c plain.h common.h common.c \
|
setproctitle.c worker-privs.c plain.c plain.h common.h common.c \
|
||||||
sec-mod.c sec-mod.h script-list.h \
|
sec-mod.c sec-mod.h script-list.h die.c die.h \
|
||||||
$(CCAN_SOURCES)
|
$(CCAN_SOURCES)
|
||||||
|
|
||||||
ocserv_SOURCES += ocserv-args.def ocserv-args.c ocserv-args.h
|
ocserv_SOURCES += ocserv-args.def ocserv-args.c ocserv-args.h
|
||||||
|
|||||||
+2
-1
@@ -30,7 +30,6 @@
|
|||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include <gdbm.h>
|
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include "setproctitle.h"
|
#include "setproctitle.h"
|
||||||
#include <main.h>
|
#include <main.h>
|
||||||
@@ -38,6 +37,8 @@
|
|||||||
|
|
||||||
#ifdef HAVE_GDBM
|
#ifdef HAVE_GDBM
|
||||||
|
|
||||||
|
# include <gdbm.h>
|
||||||
|
|
||||||
/* Note that it receives allocated data and stores them. Do not
|
/* Note that it receives allocated data and stores them. Do not
|
||||||
* free the sc.
|
* free the sc.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -30,7 +30,6 @@
|
|||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include <gdbm.h>
|
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
|
||||||
#include <main.h>
|
#include <main.h>
|
||||||
|
|||||||
@@ -0,0 +1,30 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2013 Nikos Mavrogiannopoulos
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
|
*/
|
||||||
|
#include <config.h>
|
||||||
|
|
||||||
|
#include <unistd.h>
|
||||||
|
#ifdef __linux__
|
||||||
|
# include <sys/prctl.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
void kill_on_parent_kill(int sig)
|
||||||
|
{
|
||||||
|
#ifdef __linux__
|
||||||
|
prctl(PR_SET_PDEATHSIG, sig);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
#ifndef DIE_H
|
||||||
|
# define DIE_H
|
||||||
|
|
||||||
|
void kill_on_parent_kill(int sig);
|
||||||
|
|
||||||
|
#endif
|
||||||
+2
-2
@@ -35,7 +35,7 @@
|
|||||||
#include <gnutls/crypto.h>
|
#include <gnutls/crypto.h>
|
||||||
#include <tlslib.h>
|
#include <tlslib.h>
|
||||||
#include <sys/un.h>
|
#include <sys/un.h>
|
||||||
#include <sys/prctl.h>
|
#include "die.h"
|
||||||
#include <cloexec.h>
|
#include <cloexec.h>
|
||||||
#include "ipc.h"
|
#include "ipc.h"
|
||||||
#include "setproctitle.h"
|
#include "setproctitle.h"
|
||||||
@@ -397,7 +397,7 @@ const char *p;
|
|||||||
pid = fork();
|
pid = fork();
|
||||||
if (pid == 0) { /* child */
|
if (pid == 0) { /* child */
|
||||||
clear_lists(s);
|
clear_lists(s);
|
||||||
prctl(PR_SET_PDEATHSIG, SIGTERM);
|
kill_on_parent_kill(SIGTERM);
|
||||||
setproctitle(PACKAGE_NAME"-secmod");
|
setproctitle(PACKAGE_NAME"-secmod");
|
||||||
|
|
||||||
sec_mod_server(s->config, p);
|
sec_mod_server(s->config, p);
|
||||||
|
|||||||
@@ -134,10 +134,12 @@ add_utmp_entry(main_server_st *s, struct proc_st* proc)
|
|||||||
entry.ut_pid = proc->pid;
|
entry.ut_pid = proc->pid;
|
||||||
snprintf(entry.ut_line, sizeof(entry.ut_line), "%s", proc->lease->name);
|
snprintf(entry.ut_line, sizeof(entry.ut_line), "%s", proc->lease->name);
|
||||||
snprintf(entry.ut_user, sizeof(entry.ut_user), "%s", proc->username);
|
snprintf(entry.ut_user, sizeof(entry.ut_user), "%s", proc->username);
|
||||||
|
#ifdef __linux__
|
||||||
if (proc->remote_addr_len == sizeof(struct sockaddr_in))
|
if (proc->remote_addr_len == sizeof(struct sockaddr_in))
|
||||||
memcpy(entry.ut_addr_v6, SA_IN_P(&proc->remote_addr), sizeof(struct in_addr));
|
memcpy(entry.ut_addr_v6, SA_IN_P(&proc->remote_addr), sizeof(struct in_addr));
|
||||||
else
|
else
|
||||||
memcpy(entry.ut_addr_v6, SA_IN6_P(&proc->remote_addr), sizeof(struct in6_addr));
|
memcpy(entry.ut_addr_v6, SA_IN6_P(&proc->remote_addr), sizeof(struct in6_addr));
|
||||||
|
#endif
|
||||||
|
|
||||||
gettime(&tv);
|
gettime(&tv);
|
||||||
entry.ut_tv.tv_sec = tv.tv_sec;
|
entry.ut_tv.tv_sec = tv.tv_sec;
|
||||||
|
|||||||
+3
-3
@@ -32,13 +32,13 @@
|
|||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <sys/ioctl.h>
|
#include <sys/ioctl.h>
|
||||||
#include <sys/resource.h>
|
#include <sys/resource.h>
|
||||||
#include <sys/prctl.h>
|
|
||||||
#include <cloexec.h>
|
#include <cloexec.h>
|
||||||
#include <script-list.h>
|
#include <script-list.h>
|
||||||
|
|
||||||
#include <gnutls/x509.h>
|
#include <gnutls/x509.h>
|
||||||
#include <tlslib.h>
|
#include <tlslib.h>
|
||||||
#include "ipc.h"
|
#include "ipc.h"
|
||||||
|
#include "die.h"
|
||||||
#include "setproctitle.h"
|
#include "setproctitle.h"
|
||||||
#ifdef HAVE_LIBWRAP
|
#ifdef HAVE_LIBWRAP
|
||||||
# include <tcpd.h>
|
# include <tcpd.h>
|
||||||
@@ -122,7 +122,7 @@ int _listen_ports(struct cfg_st* config, struct addrinfo *res, struct listen_lis
|
|||||||
if (ptr->ai_socktype == SOCK_DGRAM) {
|
if (ptr->ai_socktype == SOCK_DGRAM) {
|
||||||
#if defined(IP_DONTFRAG)
|
#if defined(IP_DONTFRAG)
|
||||||
y = 1;
|
y = 1;
|
||||||
if (setsockopt(s, IPPROTO_IP, IP_DONTFRAG,
|
if (setsockopt(s, SOL_IP, IP_DONTFRAG,
|
||||||
(const void *) &y, sizeof(y)) < 0)
|
(const void *) &y, sizeof(y)) < 0)
|
||||||
perror("setsockopt(IP_DF) failed");
|
perror("setsockopt(IP_DF) failed");
|
||||||
#elif defined(IP_MTU_DISCOVER)
|
#elif defined(IP_MTU_DISCOVER)
|
||||||
@@ -801,7 +801,7 @@ int main(int argc, char** argv)
|
|||||||
erase_cookies(&s);
|
erase_cookies(&s);
|
||||||
|
|
||||||
setproctitle(PACKAGE_NAME"-worker");
|
setproctitle(PACKAGE_NAME"-worker");
|
||||||
prctl(PR_SET_PDEATHSIG, SIGTERM);
|
kill_on_parent_kill(SIGTERM);
|
||||||
|
|
||||||
ws.config = &config;
|
ws.config = &config;
|
||||||
ws.cmd_fd = cmd_fd[1];
|
ws.cmd_fd = cmd_fd[1];
|
||||||
|
|||||||
@@ -18,6 +18,7 @@
|
|||||||
|
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <syslog.h>
|
#include <syslog.h>
|
||||||
|
|
||||||
|
|||||||
@@ -19,6 +19,9 @@
|
|||||||
#include <config.h>
|
#include <config.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#if !defined(HAVE_SETPROCTITLE)
|
||||||
|
|
||||||
|
# if defined(__linux__)
|
||||||
# include <sys/prctl.h>
|
# include <sys/prctl.h>
|
||||||
|
|
||||||
/* This sets the proccess title as shown in top, but not in ps (*@#%@).
|
/* This sets the proccess title as shown in top, but not in ps (*@#%@).
|
||||||
@@ -38,3 +41,13 @@ void setproctitle (const char *fmt, ...)
|
|||||||
prctl (PR_SET_NAME, name);
|
prctl (PR_SET_NAME, name);
|
||||||
# endif
|
# endif
|
||||||
}
|
}
|
||||||
|
# else /* not linux */
|
||||||
|
|
||||||
|
void setproctitle (const char *fmt, ...)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
# endif /* __linux__ */
|
||||||
|
|
||||||
|
#endif /* HAVE_SETPROCTITLE */
|
||||||
|
|||||||
@@ -1,7 +1,18 @@
|
|||||||
#ifndef SETPROCTITLE_H
|
#ifndef SETPROCTITLE_H
|
||||||
# define SETPROCTITLE_H
|
# define SETPROCTITLE_H
|
||||||
|
|
||||||
|
# include <config.h>
|
||||||
|
|
||||||
|
# ifndef HAVE_SETPROCTILE
|
||||||
|
|
||||||
void __attribute__ ((format(printf, 1, 2)))
|
void __attribute__ ((format(printf, 1, 2)))
|
||||||
setproctitle(const char *fmt, ...);
|
setproctitle(const char *fmt, ...);
|
||||||
|
|
||||||
|
# else
|
||||||
|
|
||||||
|
# include <sys/types.h>
|
||||||
|
# include <unistd.h>
|
||||||
|
|
||||||
|
# endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -22,7 +22,6 @@
|
|||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <arpa/inet.h>
|
#include <arpa/inet.h>
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
#include <linux/if_tun.h>
|
|
||||||
#include <net/if.h>
|
#include <net/if.h>
|
||||||
#include <sys/ioctl.h>
|
#include <sys/ioctl.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
@@ -31,6 +30,12 @@
|
|||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <cloexec.h>
|
#include <cloexec.h>
|
||||||
|
|
||||||
|
#ifdef __linux__
|
||||||
|
# include <linux/if_tun.h>
|
||||||
|
#else
|
||||||
|
# include <net/if_tun.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <netdb.h>
|
#include <netdb.h>
|
||||||
|
|
||||||
#include <vpn.h>
|
#include <vpn.h>
|
||||||
@@ -347,6 +352,7 @@ int open_tun(main_server_st* s, struct lease_st** l)
|
|||||||
|
|
||||||
/* No need to free the lease after this point.
|
/* No need to free the lease after this point.
|
||||||
*/
|
*/
|
||||||
|
#ifdef __linux__
|
||||||
tunfd = open("/dev/net/tun", O_RDWR);
|
tunfd = open("/dev/net/tun", O_RDWR);
|
||||||
if (tunfd < 0) {
|
if (tunfd < 0) {
|
||||||
int e = errno;
|
int e = errno;
|
||||||
@@ -399,6 +405,17 @@ int open_tun(main_server_st* s, struct lease_st** l)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
# endif
|
# endif
|
||||||
|
#else /* freebsd */
|
||||||
|
tunfd = open("/dev/tun", O_RDWR);
|
||||||
|
if (tunfd < 0) {
|
||||||
|
int e = errno;
|
||||||
|
mslog(s, NULL, LOG_ERR, "Can't open /dev/tun: %s\n",
|
||||||
|
strerror(e));
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
set_cloexec_flag (tunfd, 1);
|
||||||
|
#endif
|
||||||
|
|
||||||
/* set IP/mask */
|
/* set IP/mask */
|
||||||
ret = set_network_info(s, lease);
|
ret = set_network_info(s, lease);
|
||||||
|
|||||||
@@ -10,6 +10,7 @@
|
|||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <net/if.h>
|
#include <net/if.h>
|
||||||
|
#include <netinet/in.h>
|
||||||
#include <minmax.h>
|
#include <minmax.h>
|
||||||
|
|
||||||
#define AC_PKT_DATA 0 /* Uncompressed data */
|
#define AC_PKT_DATA 0 /* Uncompressed data */
|
||||||
|
|||||||
Reference in New Issue
Block a user