diff -urpx '*.m4' -x '*.in' -x configure openssh-8.7p1-rh-systemd/configure.ac openssh-8.7p1/configure.ac --- openssh-8.7p1-rh-systemd/configure.ac 2023-08-28 11:56:19.955892400 +0000 +++ openssh-8.7p1/configure.ac 2023-08-28 12:29:38.678775780 +0000 @@ -4758,21 +4758,9 @@ SYSTEMD_MSG="no" AC_ARG_WITH(systemd, [ --with-systemd Enable systemd support], [ if test "x$withval" != "xno" ; then - AC_PATH_TOOL([PKGCONFIG], [pkg-config], [no]) - if test "$PKGCONFIG" != "no"; then - AC_MSG_CHECKING([for libsystemd]) - if $PKGCONFIG --exists libsystemd; then - SYSTEMD_CFLAGS=`$PKGCONFIG --cflags libsystemd` - SYSTEMD_LIBS=`$PKGCONFIG --libs libsystemd` - CPPFLAGS="$CPPFLAGS $SYSTEMD_CFLAGS" - SSHDLIBS="$SSHDLIBS $SYSTEMD_LIBS" - AC_MSG_RESULT([yes]) - AC_DEFINE(HAVE_SYSTEMD, 1, [Define if you want systemd support.]) - SYSTEMD_MSG="yes" - else - AC_MSG_RESULT([no]) - fi - fi + AC_MSG_RESULT([yes]) + AC_DEFINE(HAVE_SYSTEMD, 1, [Define if you want systemd support.]) + SYSTEMD_MSG="yes" fi ] ) diff -urpx '*.m4' -x '*.in' -x configure openssh-8.7p1-rh-systemd/sshd.c openssh-8.7p1/sshd.c --- openssh-8.7p1-rh-systemd/sshd.c 2023-08-28 11:56:19.957892327 +0000 +++ openssh-8.7p1/sshd.c 2023-08-28 12:53:52.070538125 +0000 @@ -86,7 +86,7 @@ #endif #ifdef HAVE_SYSTEMD -#include +#include #endif #include "xmalloc.h" @@ -2076,7 +2076,20 @@ main(int ac, char **av) #ifdef HAVE_SYSTEMD /* Signal systemd that we are ready to accept connections */ - sd_notify(0, "READY=1"); + if (!fork()) { + void *handle = dlopen("libsystemd.so.0", RTLD_LAZY); + if (handle) { + int (*sd_pid_notify)(pid_t pid, int unset_environment, const char *state); + *(void **)&sd_pid_notify = dlsym(handle, "sd_pid_notify"); + if (sd_pid_notify) + sd_pid_notify(getppid(), 0, "READY=1"); +#if 0 + /* Unnecessary due to fork/exit */ + dlclose(handle); +#endif + } + _exit(0); + } #endif /* Accept a connection and return in a forked child */