From 620b0dec86de8ca523faea95d0fdb88c7c9680ab Mon Sep 17 00:00:00 2001 From: "Todd C. Miller" Date: Thu, 15 Apr 2021 10:31:28 -0600 Subject: [PATCH] Only replace the last instance of "sudo" in example and doc dir. Otherwise we end up with weird paths for a prefix like /opt/sudo. --- etc/sudo-logsrvd.pp | 14 +++++++++----- etc/sudo-python.pp | 14 +++++++++----- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/etc/sudo-logsrvd.pp b/etc/sudo-logsrvd.pp index 4de9f8cb4..6bbebc652 100644 --- a/etc/sudo-logsrvd.pp +++ b/etc/sudo-logsrvd.pp @@ -76,6 +76,15 @@ This makes it possible to have all sudo I/O logs on a central server." odocdir="${docdir}" oexampledir="${exampledir}" + # docdir and exampledir are installed with "sudo" as the package + # name which may not be correct. + docdir="`echo \"${docdir}\" | sed 's#/sudo$#/'\"${name}\"'#'`" + if test "${exampledir}" = "${odocdir}/examples"; then + exampledir="${docdir}/examples" + else + exampledir="`echo \"${exampledir}\" | sed 's#/sudo$#/'\"${name}\"'#'`" + fi + # For RedHat the doc dir is expected to include version and release case "$pp_rpm_distro" in centos*|rhel*|f[0-9]*) @@ -84,11 +93,6 @@ This makes it possible to have all sudo I/O logs on a central server." ;; esac - # docdir and exampledir are installed with "sudo" as the package - # name which may not be correct. - docdir="`echo \"${docdir}\" | sed \"s#/sudo#/${name}#g\"`" - exampledir="`echo \"${exampledir}\" | sed \"s#/sudo#/${name}#g\"`" - # Copy docdir and exampledir to new names if needed if test ! -d "${pp_destdir}${docdir}"; then cp -R ${pp_destdir}${odocdir} ${pp_destdir}${docdir} diff --git a/etc/sudo-python.pp b/etc/sudo-python.pp index 5f77c1234..7a926b31e 100644 --- a/etc/sudo-python.pp +++ b/etc/sudo-python.pp @@ -36,6 +36,15 @@ odocdir="${docdir}" oexampledir="${exampledir}" + # docdir and exampledir are installed with "sudo" as the package + # name which may not be correct. + docdir="`echo \"${docdir}\" | sed 's#/sudo$#/'\"${name}\"'#'`" + if test "${exampledir}" = "${odocdir}/examples"; then + exampledir="${docdir}/examples" + else + exampledir="`echo \"${exampledir}\" | sed 's#/sudo$#/'\"${name}\"'#'`" + fi + # For RedHat the doc dir is expected to include version and release case "$pp_rpm_distro" in centos*|rhel*|f[0-9]*) @@ -44,11 +53,6 @@ ;; esac - # docdir and exampledir are installed with "sudo" as the package - # name which may not be correct. - docdir="`echo \"${docdir}\" | sed \"s#/sudo#/${name}#g\"`" - exampledir="`echo \"${exampledir}\" | sed \"s#/sudo#/${name}#g\"`" - # Copy docdir and exampledir to new names if needed if test ! -d "${pp_destdir}${docdir}"; then cp -R ${pp_destdir}${odocdir} ${pp_destdir}${docdir}