Subject: Re: pkgsrc bootstrap kit for Solaris 10?
To: None <>
From: Alan Barrett <>
List: tech-pkg
Date: 08/23/2006 08:55:05
On Tue, 22 Aug 2006, Malcolm Herbert wrote:
> On Thu, Aug 17, 2006 at 06:57:30PM +0200, Alan Barrett wrote:
> |  * Use SU_CMD=su -m root -c (where the "-m" insuead of "-" is intended
> |  to make su invoke your $SHELL insteasd of the shell mentioned in
> |  root's entry in /etc/passwd), or SU_CMD=sudo /usr/xpg4/bin/sh -c.
> I'm still having Issues getting pkgsrc to use /usr/xpg4/bin/sh
> consistently, with su or sudo even when run as root with SHELL set
> appropriately. Unfortunately I wasn't able to find a version of su which
> accepts the -m flag (/bin/su, /sbin/su nor /usr/bin/su)

Other people who use pkgsrc on Solaris don't seem to have the same
problems; perhaps they just do everything as root.

grep shows that pkgsrc uses several different shell variables,
SH=/usr/xpg4/bin/sh in mk.conf or pkgsrc/mk/platform/ will
probably help, because most of the others seem to have defaults that are
derived from ${SH}.

If all else fails, try creating a wrapper script something like this:

	export SHELL
	exec ${SHELL} "$@"

(or rewrite in csh syntax if root's shell is csh).

Then, in mk.conf, set SU_CMD like this:

	SU_CMD= su root /path/to/wrapper/script -c

(note no bare "-", and no "-m").  pkgsrc will do things like "su root
/path/to/wrapper/script -c 'command here'"; su will do things like
"/bin/sh /path/to/wrapper/script -c 'command here'" or "/bin/csh
/path/to/wrapper/script -c 'command here'"; and the wrapper script will
do things like "/usr/xpg4/bin/sh -c 'command here'".

> Is there any config-file magic to allow sudo to change the environment
> for a command run under it that ISN'T dependant on the calling
> environment (ie, NOT using the -s option on the command-line, which
> imports the calling SHELL)? That would solve my problems, I think ...

Do any of these work (or variations on these themes)?

SU_CMD= env SHELL=/usr/xpg4/bin/sh sudo /usr/xpg4/bin/sh -c
SU_CMD= sudo /path/to/wrapper/script -c
SU_CMD= sudo /bin/sh /path/to/wrapper/script -c

--apb (Alan Barrett)