Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Notify tunnel up to systemd with sd_notify #370

Merged
merged 1 commit into from
Sep 12, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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