]> granicus.if.org Git - sudo/commitdiff
Make sudoersdir relative to PKG_INSTALL_ROOT for Solaris.
authorTodd C. Miller <Todd.Miller@courtesan.com>
Fri, 30 Mar 2012 16:27:12 +0000 (12:27 -0400)
committerTodd C. Miller <Todd.Miller@courtesan.com>
Fri, 30 Mar 2012 16:27:12 +0000 (12:27 -0400)
Make sure sudoers file is writable before trying to edit it.

--HG--
branch : 1.7

sudo.pp

diff --git a/sudo.pp b/sudo.pp
index fd67c78d42e3a6633076578a4d7456c1325ff74e..11a485f36c7e9f185c0e37aa7f11b15b6f48f8f7 100644 (file)
--- a/sudo.pp
+++ b/sudo.pp
@@ -74,14 +74,17 @@ still allow people to get their work done."
        # Note that the order must match that of sudoers.
        case "$pp_rpm_distro" in
        centos*|rhel*)
+               chmod u+w ${pp_destdir}${sudoersdir}/sudoers
                /bin/ed - ${pp_destdir}${sudoersdir}/sudoers <<-'EOF'
                /Locale settings/+1,s/^# //
                /Desktop path settings/+1,s/^# //
                w
                q
                EOF
+               chmod u-w ${pp_destdir}${sudoersdir}/sudoers
                ;;
        sles*)
+               chmod u+w ${pp_destdir}${sudoersdir}/sudoers
                /bin/ed - ${pp_destdir}${sudoersdir}/sudoers <<-'EOF'
                /Locale settings/+1,s/^# //
                /ConsoleKit session/+1,s/^# //
@@ -90,6 +93,7 @@ still allow people to get their work done."
                w
                q
                EOF
+               chmod u-w ${pp_destdir}${sudoersdir}/sudoers
                ;;
        esac
 
@@ -157,6 +161,7 @@ still allow people to get their work done."
 %if [deb]
        # Uncomment some Defaults and the %sudo rule in sudoers
        # Note that the order must match that of sudoers and be tab-indented.
+       chmod u+w ${pp_destdir}${sudoersdir}/sudoers
        /bin/ed - ${pp_destdir}${sudoersdir}/sudoers <<-'EOF'
        /Locale settings/+1,s/^# //
        /X11 resource/+1,s/^# //
@@ -164,6 +169,7 @@ still allow people to get their work done."
        w
        q
        EOF
+       chmod u-w ${pp_destdir}${sudoersdir}/sudoers
        mkdir -p ${pp_destdir}/etc/pam.d
        cat > ${pp_destdir}/etc/pam.d/sudo <<-EOF
        #%PAM-1.0
@@ -225,7 +231,11 @@ still allow people to get their work done."
 
 %post [!rpm,deb]
        # Don't overwrite an existing sudoers file
+%if [solaris]
+       sudoersdir=${PKG_INSTALL_ROOT}%{sudoersdir}
+%else
        sudoersdir=%{sudoersdir}
+%endif
        if test ! -r $sudoersdir/sudoers; then
                cp $sudoersdir/sudoers.dist $sudoersdir/sudoers
                chmod %{sudoers_mode} $sudoersdir/sudoers