Skip to content

Commit

Permalink
Notify tunnel up to systemd with sd_notify
Browse files Browse the repository at this point in the history
Allows usage of Type=notify systemd service types.

Fixes: #229
  • Loading branch information
fsateler authored and DimitriPapadopoulos committed Sep 12, 2018
1 parent 3664889 commit d2d4bdf
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ openfortivpn_SOURCES = src/config.c src/config.h src/hdlc.c src/hdlc.h \
openfortivpn_CFLAGS = -Wall --pedantic -std=gnu99
openfortivpn_CPPFLAGS = -DSYSCONFDIR=\"$(sysconfdir)\"

openfortivpn_CPPFLAGS += $(OPENSSL_CFLAGS)
openfortivpn_LDADD = $(OPENSSL_LIBS)
openfortivpn_CPPFLAGS += $(OPENSSL_CFLAGS) $(LIBSYSTEMD_CFLAGS)
openfortivpn_LDADD = $(OPENSSL_LIBS) $(LIBSYSTEMD_LIBS)

DISTCHECK_CONFIGURE_FLAGS = CFLAGS=-Werror

Expand Down
1 change: 1 addition & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ AM_SILENT_RULES([yes])
PKG_CHECK_MODULES(OPENSSL, [libcrypto >= 0.9.8 libssl >= 0.9.8], [], [AC_MSG_ERROR([Cannot find OpenSSL 0.9.8 or higher.])])
AC_CHECK_LIB([pthread], [pthread_create], [], [AC_MSG_ERROR([Cannot find libpthread.])])
AC_CHECK_LIB([util], [forkpty], [], [AC_MSG_ERROR([Cannot find libutil.])])
PKG_CHECK_MODULES(LIBSYSTEMD, [libsystemd], [AC_DEFINE(HAVE_SYSTEMD)], [ ])

# Checks for header files.
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])
Expand Down
7 changes: 7 additions & 0 deletions src/tunnel.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@
#include <signal.h>
#include <sys/wait.h>
#include <assert.h>
#if HAVE_SYSTEMD
#include <systemd/sd-daemon.h>
#endif

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

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

#if HAVE_SYSTEMD
sd_notify(0, "READY=1");
#endif

return 0;
}

Expand Down

0 comments on commit d2d4bdf

Please sign in to comment.