Subject: Using sudo in SU_CMD
To: None <tech-pkg@netbsd.org>
From: Marc Baudoin <babafou@babafou.eu.org>
List: tech-pkg
Date: 09/19/2004 21:26:20
Hi,

The NetBSD Packages Collection manual indicates how to use sudo
in SU_CMD:

   11.29. Using 'sudo' with pkgsrc

   When installing packages as non-root user and using the
   just-in-time su(1) feature of pkgsrc, it can become annoying
   to type in the root password for each required package
   installed.  To avoid this, the sudo package can be used, which
   does password caching over a limited time.  To use it, install
   sudo (either as binary package or from security/sudo) and then
   put the following into your /etc/mk.conf:

   SU_CMD=/usr/pkg/bin/sudo /bin/sh -c

This works fine except when upgrading sudo where it fails
miserably because there's no sudo anymore.

I would suggest modifying it that way:

   .if exists(/usr/pkg/bin/sudo)
   SU_CMD=/usr/pkg/bin/sudo /bin/sh -c
   .endif

which does the right thing when sudo exists and reverts to the
default value (${ROOT_CMD}) when it doesn't.  I've just tested it
and it seems to work fine.