rcolebaugh / rpms / openssh

Forked from rpms/openssh 2 years ago
Clone
f5835d
commit 0e22b79bfde45a7cf7a2e51a68ec11c4285f3b31
f5835d
Author: Jakub Jelen <jjelen@redhat.com>
f5835d
Date:   Mon Nov 21 15:04:06 2016 +0100
f5835d
f5835d
    systemd stuff
f5835d
f5835d
diff --git a/configure.ac b/configure.ac
f5835d
index 2ffc369..162ce92 100644
f5835d
--- a/configure.ac
f5835d
+++ b/configure.ac
f5835d
@@ -4265,6 +4265,30 @@ AC_ARG_WITH([kerberos5],
f5835d
 AC_SUBST([GSSLIBS])
f5835d
 AC_SUBST([K5LIBS])
f5835d
 
f5835d
+# Check whether user wants systemd support
f5835d
+SYSTEMD_MSG="no"
f5835d
+AC_ARG_WITH(systemd,
f5835d
+	[  --with-systemd          Enable systemd support],
f5835d
+	[ if test "x$withval" != "xno" ; then
f5835d
+		AC_PATH_TOOL([PKGCONFIG], [pkg-config], [no])
f5835d
+		if test "$PKGCONFIG" != "no"; then
f5835d
+			AC_MSG_CHECKING([for libsystemd])
f5835d
+			if $PKGCONFIG --exists libsystemd; then
f5835d
+				SYSTEMD_CFLAGS=`$PKGCONFIG --cflags libsystemd`
f5835d
+				SYSTEMD_LIBS=`$PKGCONFIG --libs libsystemd`
f5835d
+				CPPFLAGS="$CPPFLAGS $SYSTEMD_CFLAGS"
f5835d
+				SSHDLIBS="$SSHDLIBS $SYSTEMD_LIBS"
f5835d
+				AC_MSG_RESULT([yes])
f5835d
+				AC_DEFINE(HAVE_SYSTEMD, 1, [Define if you want systemd support.])
f5835d
+				SYSTEMD_MSG="yes"
f5835d
+			else
f5835d
+				AC_MSG_RESULT([no])
f5835d
+			fi
f5835d
+		fi
f5835d
+	fi ]
f5835d
+)
f5835d
+
f5835d
+
f5835d
 # Looking for programs, paths and files
f5835d
 
f5835d
 PRIVSEP_PATH=/var/empty
f5835d
@@ -5097,6 +5121,7 @@ echo "                   libedit support: $LIBEDIT_MSG"
f5835d
 echo "  Solaris process contract support: $SPC_MSG"
f5835d
 echo "           Solaris project support: $SP_MSG"
f5835d
 echo "         Solaris privilege support: $SPP_MSG"
f5835d
+echo "                   systemd support: $SYSTEMD_MSG"
f5835d
 echo "       IP address in \$DISPLAY hack: $DISPLAY_HACK_MSG"
f5835d
 echo "           Translate v4 in v6 hack: $IPV4_IN6_HACK_MSG"
f5835d
 echo "                  BSD Auth support: $BSD_AUTH_MSG"
f5835d
diff --git a/contrib/sshd.service b/contrib/sshd.service
f5835d
new file mode 100644
f5835d
index 0000000..e0d4923
f5835d
--- /dev/null
f5835d
+++ b/contrib/sshd.service
f5835d
@@ -0,0 +1,16 @@
f5835d
+[Unit]
f5835d
+Description=OpenSSH server daemon
f5835d
+Documentation=man:sshd(8) man:sshd_config(5)
f5835d
+After=network.target
f5835d
+
f5835d
+[Service]
f5835d
+Type=notify
f5835d
+ExecStart=/usr/sbin/sshd -D $OPTIONS
f5835d
+ExecReload=/bin/kill -HUP $MAINPID
f5835d
+KillMode=process
f5835d
+Restart=on-failure
f5835d
+RestartPreventExitStatus=255
f5835d
+
f5835d
+[Install]
f5835d
+WantedBy=multi-user.target
f5835d
+
f5835d
diff --git a/sshd.c b/sshd.c
f5835d
index 816611c..b8b9d13 100644
f5835d
--- a/sshd.c
f5835d
+++ b/sshd.c
f5835d
@@ -85,6 +85,10 @@
f5835d
 #include <prot.h>
f5835d
 #endif
f5835d
 
f5835d
+#ifdef HAVE_SYSTEMD
f5835d
+#include <systemd/sd-daemon.h>
f5835d
+#endif
f5835d
+
f5835d
 #include "xmalloc.h"
f5835d
 #include "ssh.h"
f5835d
 #include "ssh2.h"
f5835d
@@ -1888,6 +1892,11 @@ main(int ac, char **av)
f5835d
 			}
f5835d
 		}
f5835d
 
f5835d
+#ifdef HAVE_SYSTEMD
f5835d
+		/* Signal systemd that we are ready to accept connections */
f5835d
+		sd_notify(0, "READY=1");
f5835d
+#endif
f5835d
+
f5835d
 		/* Accept a connection and return in a forked child */
f5835d
 		server_accept_loop(&sock_in, &sock_out,
f5835d
 		    &newsock, config_s);