bmh10 / rpms / openssh

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