description="Give certain users (or groups) the ability to run some commands as root."
url="http://www.sudo.ws"

contributors="Pierre B"
packager="Tnut <tnut@nutyx.org>"

makedepends=(pam)

name=sudo
version=1.9.12p2

source=($url/sudo/dist/$name-$version.tar.gz)

build() {
cd $name-$version

sed -e '/^pre-install:/{N;s@;@ -a -r $(sudoersdir)/sudoers;@}' \
    -i plugins/sudoers/Makefile.in

./configure --prefix=/usr \
--libexecdir=/usr/lib \
--docdir=/usr/share/doc/sudo-$version \
--with-all-insults \
--with-env-editor \
--without-sendmail \
--with-passprompt="[sudo] password for %p: "

make
make DESTDIR=$PKG install

ln -sfv libsudo_util.so.0.0.0 $PKG/usr/lib/sudo/libsudo_util.so.0

mkdir -pv $PKG/etc/pam.d

cat > $PKG/etc/pam.d/sudo << "EOF" &&
# Begin /etc/pam.d/sudo

# include the default auth settings
auth      include     system-auth

# include the default account settings
account   include     system-account

# Set default environment variables for the service user
session   required    pam_env.so

# include system session defaults
session   include     system-session

# End /etc/pam.d/sudo
EOF
chmod 644 $PKG/etc/pam.d/sudo
echo "%wheel ALL=(ALL) ALL
%wheel ALL =(ALL) NOPASSWD: /usr/bin/flcards" >> $PKG/etc/sudoers

}
