From a89ddb63fd16ba9597c29bca70274af59371d5d0 Mon Sep 17 00:00:00 2001 From: "Todd C. Miller" Date: Thu, 16 Apr 2020 15:32:07 -0600 Subject: [PATCH] Disable systemd support on Linux systems that don't use it. --- etc/sudo-logsrvd.pp | 38 ++++++++++++++++++++--------------- scripts/pp | 49 +++++++++++++++++++++++++++++++++++++++++---- 2 files changed, 67 insertions(+), 20 deletions(-) diff --git a/etc/sudo-logsrvd.pp b/etc/sudo-logsrvd.pp index ebc4dd990..ef7a29dc8 100644 --- a/etc/sudo-logsrvd.pp +++ b/etc/sudo-logsrvd.pp @@ -221,21 +221,27 @@ This makes it possible to have all sudo I/O logs on a central server." pidfile=${rundir}/sudo_logsrvd.pid %endif %if [rpm,deb] - pp_systemd_service_description="Sudo central log server" - pp_systemd_service_exec="${cmd}" - pp_systemd_service_exec_args="-n" - pp_systemd_service_dir=`pkg-config systemd --variable=systemdsystemunitdir 2>/dev/null` - if test X"$pp_systemd_service_dir" = X""; then - if test -d /lib/systemd/system; then - pp_systemd_service_dir=/lib/systemd/system - else - pp_systemd_service_dir=/usr/lib/systemd/system - fi + # Only include systemd support if we find systemctl on the build + # machine. This assumes that we are building on the same distro + # that the package will be installed on. + if command -v systemctl >/dev/null; then + for d in `pkg-config systemd --variable=systemdsystemunitdir 2>/dev/null` /lib/systemd/system /usr/lib/systemd/system; do + if test -d "$d"; then + break + fi + done + pp_systemd_service_description="Sudo central log server" + pp_systemd_service_dir="$d" + pp_systemd_service_exec="${cmd}" + pp_systemd_service_exec_args="-n" + pp_systemd_service_man="man:sudo_logsrvd(8) man:sudo_logsrvd.conf(5)" + pp_systemd_service_documentation="https://www.sudo.ws/man.html" + pp_systemd_service_after="syslog.target network.target auditd.service" + pp_systemd_service_killmode="process" + pp_systemd_service_type="exec" + pp_systemd_system_target="multi-user.target" + else + # No systemd support + pp_systemd_disabled=true fi - pp_systemd_service_man="man:sudo_logsrvd(8) man:sudo_logsrvd.conf(5)" - pp_systemd_service_documentation="https://www.sudo.ws/man.html" - pp_systemd_service_after="syslog.target network.target auditd.service" - pp_systemd_service_killmode="process" - pp_systemd_service_type="exec" - pp_systemd_system_target="multi-user.target" %endif diff --git a/scripts/pp b/scripts/pp index c42f93fb4..ccddbc10b 100755 --- a/scripts/pp +++ b/scripts/pp @@ -1,6 +1,6 @@ #!/bin/sh # Copyright 2020 One Identity LLC. ALL RIGHTS RESERVED -pp_revision="20200414" +pp_revision="20200416" # Copyright 2018 One Identity LLC. ALL RIGHTS RESERVED. # # Redistribution and use in source and binary forms, with or without @@ -8805,11 +8805,14 @@ pp_backend_bsd_function() { esac } pp_systemd_make_service_file() { - local svc f + if [ "${pp_systemd_disabled}:-false" = "true" ]; then + return + fi + svc="$1" - f="${pp_systemd_service_dir:-'/opt/quest/libexec/vas'}/$svc.service" + f="${pp_systemd_service_dir:-/opt/quest/libexec/vas}/$svc.service" pp_add_file_if_missing $f run 644 v || return 0 cat <<. >$pp_destdir$f @@ -8838,7 +8841,7 @@ pp_systemd_service_init_common () { cat <<. _pp_systemd_init () { - systemd_service_dir=${pp_systemd_service_dir:-'/opt/quest/libexec/vas'} + systemd_service_dir=${pp_systemd_service_dir:-/opt/quest/libexec/vas} systemd_target=${pp_systemd_system_target:-"multi-user.target"} systemd_target_wants="\${systemd_target}.wants" @@ -8881,6 +8884,25 @@ pp_systemd_service_init_common () { } pp_systemd_service_install_common () { + if [ "${pp_systemd_disabled}:-false" = "true" ]; then + cat<<'.' + + # systemd support disabled + _pp_systemd_init () { + return + } + + _pp_systemd_install () { + return + } + + _pp_systemd_enable () { + return + } +. + return + fi + pp_systemd_service_init_common cat<<'.' @@ -8949,6 +8971,25 @@ pp_systemd_service_install_common () { } pp_systemd_service_remove_common () { + if [ "${pp_systemd_disabled}:-false" = "true" ]; then + cat<<'.' + + # systemd support disabled + _pp_systemd_init () { + return + } + + _pp_systemd_disable () { + return + } + + _pp_systemd_remove () { + return + } +. + return + fi + pp_systemd_service_init_common cat<<'.'