From fcaa62c77767e41cd9d49e84ecab08ebe8e5984f Mon Sep 17 00:00:00 2001 From: "Todd C. Miller" Date: Thu, 15 Jul 2010 22:18:27 -0400 Subject: [PATCH] Restore the dot removal in the os version reported by polypkg. Adapt mkpkg and sudo.pp to the change. --HG-- branch : 1.7 --- mkpkg | 34 ++++++++------------- pp | 6 ++-- sudo.pp | 95 +++++++++++++++++++++++++++------------------------------ 3 files changed, 60 insertions(+), 75 deletions(-) diff --git a/mkpkg b/mkpkg index 1b8352027..0a16694ac 100755 --- a/mkpkg +++ b/mkpkg @@ -12,6 +12,7 @@ IFS=" $nl" top_srcdir=`dirname $0` platform=`$top_srcdir/pp --probe` || exit 1 +osrelease=`echo "$platform" | sed -e 's/^[^0-9]*//' -e 's/-.*$//'` # Default paths prefix=/usr/local @@ -32,15 +33,11 @@ esac case "$platform" in centos*|rhel*) prefix=/usr - case "$platform" in - centos[0-4].*|rhel[0-4].*) - ;; - *) - # RHEL 5 and up build pies and have audit support - export CFLAGS="$F_PIE" LDFLAGS="-pie" - configure_opts="--with-linux-audit" - ;; - esac + if [ $osrelease -ge 50 ]; then + # RHEL 5 and up build pies and have audit support + export CFLAGS="$F_PIE" LDFLAGS="-pie" + configure_opts="--with-linux-audit" + fi # Note, must indent with tabs, not spaces due to IFS trickery configure_opts="$configure_opts --prefix=$prefix @@ -59,19 +56,14 @@ case "$platform" in ;; sles*) prefix=/usr - case "$platform" in - sles[0-9].*) - ;; - sles10.*) - # SLES 10 and higher build pies - export CFLAGS="$F_PIE" LDFLAGS="-pie" - ;; - *) - # SLES 11 and higher has SELinux too - export CFLAGS="$F_PIE" LDFLAGS="-pie" + if [ $osrelease -ge 10 ]; then + # SLES 10 and higher build pies + export CFLAGS="$F_PIE" LDFLAGS="-pie" + if [ $osrelease -ge 11 ]; then + # SLES 11 and higher has SELinux configure_opts="--with-selinux" - ;; - esac + fi + fi # SuSE doesn't have /usr/libexec case "$platform" in *64*) libexec=lib64;; diff --git a/pp b/pp index 223ddb6bd..ae43a5fe1 100755 --- a/pp +++ b/pp @@ -3762,7 +3762,6 @@ pp_deb_make_data() { done # If no copyright file is present add one. This is a debian requirement. - # XXX - include the LICENSE file instead? share_doc="/usr/share/doc/`pp_deb_cmp_full_name $cmp`" if [ ! -f "$data/$share_doc/copyright" ] then @@ -3957,8 +3956,7 @@ pp_backend_deb_probe() { ;; *) # Remove trailing revision number and any dots - #release=`echo $release | cut -dr -f1 | tr -d .` - release=`echo $release | cut -dr -f1` + release=`echo $release | cut -dr -f1 | tr -d .` ;; esac @@ -5036,7 +5034,7 @@ pp_rpm_detect_distro () { /^SuSE SLES-[0-9]/ { print "sles" substr($2,6); exit; } ' /etc/SuSE-release` fi - #pp_rpm_distro=`echo $pp_rpm_distro | tr -d .` + pp_rpm_distro=`echo $pp_rpm_distro | tr -d .` test -z "$pp_rpm_distro" && pp_warn "unknown distro" } diff --git a/sudo.pp b/sudo.pp index 17767073d..7df939e05 100644 --- a/sudo.pp +++ b/sudo.pp @@ -22,18 +22,13 @@ still allow people to get their work done." %set [rpm] # Add distro info to release + osrelease=`echo "$pp_rpm_distro" | sed -e 's/^[^0-9]*//' -e 's/-.*$//'` case "$pp_rpm_distro" in centos*|rhel*) - d=`echo "$pp_rpm_distro" | sed -e 's/^[^0-9]*//' -e 's/[^0-9].*$//'` - if test -n "$d"; then - pp_rpm_release="$pp_rpm_release.el$d" - fi + pp_rpm_release="$pp_rpm_release.el${osrelease%%[0-9]}" ;; sles*) - d=`echo "$pp_rpm_distro" | sed -e 's/^[^0-9]*//' -e 's/[^0-9].*$//'` - if test -n "$d"; then - pp_rpm_release="$pp_rpm_release.sles$d" - fi + pp_rpm_release="$pp_rpm_release.sles$osrelease" ;; esac @@ -72,53 +67,53 @@ still allow people to get their work done." # Choose the correct PAM file by distro, must be tab indented for "<<-" case "$pp_rpm_distro" in - centos[0-4].*|rhel[0-4].*) - mkdir -p ${pp_destdir}/etc/pam.d - cat > ${pp_destdir}/etc/pam.d/sudo <<-EOF - #%PAM-1.0 - auth required pam_stack.so service=system-auth - account required pam_stack.so service=system-auth - password required pam_stack.so service=system-auth - session required pam_limits.so - EOF - ;; centos*|rhel*) mkdir -p ${pp_destdir}/etc/pam.d - cat > ${pp_destdir}/etc/pam.d/sudo <<-EOF - #%PAM-1.0 - auth include system-auth - account include system-auth - password include system-auth - session optional pam_keyinit.so revoke - session required pam_limits.so - EOF - cat > ${pp_destdir}/etc/pam.d/sudo-i <<-EOF - #%PAM-1.0 - auth include sudo - account include sudo - password include sudo - session optional pam_keyinit.so force revoke - session required pam_limits.so - EOF - ;; - sles9.*) - mkdir -p ${pp_destdir}/etc/pam.d - cat > ${pp_destdir}/etc/pam.d/sudo <<-EOF - #%PAM-1.0 - auth required pam_unix2.so - session required pam_limits.so - EOF + if test $osrelease -lt 50; then + cat > ${pp_destdir}/etc/pam.d/sudo <<-EOF + #%PAM-1.0 + auth required pam_stack.so service=system-auth + account required pam_stack.so service=system-auth + password required pam_stack.so service=system-auth + session required pam_limits.so + EOF + else + cat > ${pp_destdir}/etc/pam.d/sudo <<-EOF + #%PAM-1.0 + auth include system-auth + account include system-auth + password include system-auth + session optional pam_keyinit.so revoke + session required pam_limits.so + EOF + cat > ${pp_destdir}/etc/pam.d/sudo-i <<-EOF + #%PAM-1.0 + auth include sudo + account include sudo + password include sudo + session optional pam_keyinit.so force revoke + session required pam_limits.so + EOF + fi ;; sles*) mkdir -p ${pp_destdir}/etc/pam.d - cat > ${pp_destdir}/etc/pam.d/sudo <<-EOF - #%PAM-1.0 - auth include common-auth - account include common-account - password include common-password - session include common-session - # session optional pam_xauth.so - EOF + if test $osrelease -lt 10; then + cat > ${pp_destdir}/etc/pam.d/sudo <<-EOF + #%PAM-1.0 + auth required pam_unix2.so + session required pam_limits.so + EOF + else + cat > ${pp_destdir}/etc/pam.d/sudo <<-EOF + #%PAM-1.0 + auth include common-auth + account include common-account + password include common-password + session include common-session + # session optional pam_xauth.so + EOF + fi ;; esac -- 2.40.0