]> git.ipfire.org Git - thirdparty/openembedded/openembedded-core-contrib.git/blob
acda8f1ce9e4f795402e2a572c22f002e062873f
[thirdparty/openembedded/openembedded-core-contrib.git] /
1 From be187435911cde6cc3cef6982a508261074f1e56 Mon Sep 17 00:00:00 2001
2 From: Matt Jolly <Matt.Jolly@footclan.ninja>
3 Date: Thu, 2 Feb 2023 21:05:40 +1100
4 Subject: [PATCH] systemd: Add optional support for systemd `sd_notify`
5
6 This is a rebase of Dennis Lamm's <expeditioneer@gentoo.org>
7 patch based on Jakub Jelen's <jjelen@redhat.com> original patch
8
9 Upstream-Status: Submitted [https://github.com/openssh/openssh-portable/pull/375/commits/be187435911cde6cc3cef6982a508261074f1e56]
10
11 Signed-off-by: Xiangyu Chen <xiangyu.chen@windriver.com>
12 ---
13 configure.ac | 24 ++++++++++++++++++++++++
14 sshd.c | 13 +++++++++++++
15 2 files changed, 37 insertions(+)
16
17 diff --git a/configure.ac b/configure.ac
18 index 22fee70f..486c189f 100644
19 --- a/configure.ac
20 +++ b/configure.ac
21 @@ -4835,6 +4835,29 @@ AC_SUBST([GSSLIBS])
22 AC_SUBST([K5LIBS])
23 AC_SUBST([CHANNELLIBS])
24
25 +# Check whether user wants systemd support
26 +SYSTEMD_MSG="no"
27 +AC_ARG_WITH(systemd,
28 + [ --with-systemd Enable systemd support],
29 + [ if test "x$withval" != "xno" ; then
30 + AC_PATH_TOOL([PKGCONFIG], [pkg-config], [no])
31 + if test "$PKGCONFIG" != "no"; then
32 + AC_MSG_CHECKING([for libsystemd])
33 + if $PKGCONFIG --exists libsystemd; then
34 + SYSTEMD_CFLAGS=`$PKGCONFIG --cflags libsystemd`
35 + SYSTEMD_LIBS=`$PKGCONFIG --libs libsystemd`
36 + CPPFLAGS="$CPPFLAGS $SYSTEMD_CFLAGS"
37 + SSHDLIBS="$SSHDLIBS $SYSTEMD_LIBS"
38 + AC_MSG_RESULT([yes])
39 + AC_DEFINE(HAVE_SYSTEMD, 1, [Define if you want systemd support.])
40 + SYSTEMD_MSG="yes"
41 + else
42 + AC_MSG_RESULT([no])
43 + fi
44 + fi
45 + fi ]
46 +)
47 +
48 # Looking for programs, paths and files
49
50 PRIVSEP_PATH=/var/empty
51 @@ -5634,6 +5657,7 @@ echo " libldns support: $LDNS_MSG"
52 echo " Solaris process contract support: $SPC_MSG"
53 echo " Solaris project support: $SP_MSG"
54 echo " Solaris privilege support: $SPP_MSG"
55 +echo " systemd support: $SYSTEMD_MSG"
56 echo " IP address in \$DISPLAY hack: $DISPLAY_HACK_MSG"
57 echo " Translate v4 in v6 hack: $IPV4_IN6_HACK_MSG"
58 echo " BSD Auth support: $BSD_AUTH_MSG"
59 diff --git a/sshd.c b/sshd.c
60 index 6321936c..859d6a0b 100644
61 --- a/sshd.c
62 +++ b/sshd.c
63 @@ -88,6 +88,10 @@
64 #include <prot.h>
65 #endif
66
67 +#ifdef HAVE_SYSTEMD
68 +#include <systemd/sd-daemon.h>
69 +#endif
70 +
71 #include "xmalloc.h"
72 #include "ssh.h"
73 #include "ssh2.h"
74 @@ -310,6 +314,10 @@ static void
75 sighup_restart(void)
76 {
77 logit("Received SIGHUP; restarting.");
78 +#ifdef HAVE_SYSTEMD
79 + /* Signal systemd that we are reloading */
80 + sd_notify(0, "RELOADING=1");
81 +#endif
82 if (options.pid_file != NULL)
83 unlink(options.pid_file);
84 platform_pre_restart();
85 @@ -2086,6 +2094,11 @@ main(int ac, char **av)
86 }
87 }
88
89 +#ifdef HAVE_SYSTEMD
90 + /* Signal systemd that we are ready to accept connections */
91 + sd_notify(0, "READY=1");
92 +#endif
93 +
94 /* Accept a connection and return in a forked child */
95 server_accept_loop(&sock_in, &sock_out,
96 &newsock, config_s);
97 --
98 2.25.1
99