Skip to content

Commit d2d4bdf

Browse files
fsatelerDimitriPapadopoulos
authored andcommitted
Notify tunnel up to systemd with sd_notify
Allows usage of Type=notify systemd service types. Fixes: #229
1 parent 3664889 commit d2d4bdf

3 files changed

Lines changed: 10 additions & 2 deletions

File tree

Makefile.am

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ openfortivpn_SOURCES = src/config.c src/config.h src/hdlc.c src/hdlc.h \
99
openfortivpn_CFLAGS = -Wall --pedantic -std=gnu99
1010
openfortivpn_CPPFLAGS = -DSYSCONFDIR=\"$(sysconfdir)\"
1111

12-
openfortivpn_CPPFLAGS += $(OPENSSL_CFLAGS)
13-
openfortivpn_LDADD = $(OPENSSL_LIBS)
12+
openfortivpn_CPPFLAGS += $(OPENSSL_CFLAGS) $(LIBSYSTEMD_CFLAGS)
13+
openfortivpn_LDADD = $(OPENSSL_LIBS) $(LIBSYSTEMD_LIBS)
1414

1515
DISTCHECK_CONFIGURE_FLAGS = CFLAGS=-Werror
1616

configure.ac

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ AM_SILENT_RULES([yes])
2121
PKG_CHECK_MODULES(OPENSSL, [libcrypto >= 0.9.8 libssl >= 0.9.8], [], [AC_MSG_ERROR([Cannot find OpenSSL 0.9.8 or higher.])])
2222
AC_CHECK_LIB([pthread], [pthread_create], [], [AC_MSG_ERROR([Cannot find libpthread.])])
2323
AC_CHECK_LIB([util], [forkpty], [], [AC_MSG_ERROR([Cannot find libutil.])])
24+
PKG_CHECK_MODULES(LIBSYSTEMD, [libsystemd], [AC_DEFINE(HAVE_SYSTEMD)], [ ])
2425

2526
# Checks for header files.
2627
AC_CHECK_HEADERS([arpa/inet.h assert.h ctype.h errno.h fcntl.h getopt.h ifaddrs.h limits.h mach/mach.h netdb.h net/if.h netinet/in.h netinet/tcp.h net/route.h pty.h semaphore.h signal.h stdarg.h stddef.h stdint.h stdio.h stdlib.h string.h strings.h sys/ioctl.h syslog.h sys/socket.h sys/stat.h sys/time.h sys/types.h sys/wait.h termios.h unistd.h util.h])

src/tunnel.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@
5050
#include <signal.h>
5151
#include <sys/wait.h>
5252
#include <assert.h>
53+
#if HAVE_SYSTEMD
54+
#include <systemd/sd-daemon.h>
55+
#endif
5356

5457
struct ofv_varr {
5558
unsigned cap; // current capacity
@@ -101,6 +104,10 @@ static int on_ppp_if_up(struct tunnel *tunnel)
101104

102105
log_info("Tunnel is up and running.\n");
103106

107+
#if HAVE_SYSTEMD
108+
sd_notify(0, "READY=1");
109+
#endif
110+
104111
return 0;
105112
}
106113

0 commit comments

Comments
 (0)