NetBSD Problem Report #47371

From www@NetBSD.org  Thu Dec 27 17:35:14 2012
Return-Path: <www@NetBSD.org>
Received: from mail.netbsd.org (mail.netbsd.org [149.20.53.66])
	by www.NetBSD.org (Postfix) with ESMTP id 2FB4E63D82E
	for <gnats-bugs@gnats.NetBSD.org>; Thu, 27 Dec 2012 17:35:14 +0000 (UTC)
Message-Id: <20121227173512.EF68D63D82E@www.NetBSD.org>
Date: Thu, 27 Dec 2012 17:35:12 +0000 (UTC)
From: richard.palo@baou.fr
Reply-To: richard.palo@baou.fr
To: gnats-bugs@NetBSD.org
Subject: pkgsrc/pkgtools/rc.subr uses optional tools (whoami) [at least in solaris zones]
X-Send-Pr-Version: www-1.0

>Number:         47371
>Category:       pkg
>Synopsis:       pkgsrc/pkgtools/rc.subr uses optional tools (whoami) [at least in solaris zones]
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    pkg-manager
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Thu Dec 27 17:40:00 +0000 2012
>Last-Modified:  Fri Dec 28 19:30:09 +0000 2012
>Originator:     Richard PALO
>Release:        pkgsrc trunk
>Organization:
>Environment:
SunOS devzoneX 5.11 oi_151a7 i86pc i386 i86pc Solaris

>Description:
using pkgtools/rc.subr on a NG solaris (illumos) zone, I noticed the following:
richard@devzoneX:~/src/pkgsrc$ pfexec /etc/rc.d/pgsql status
/etc/rc.subr: line 525: /usr/bin/whoami: No such file or directory
pgsql is not running.

richard@devzoneX:~/src/pkgsrc$ pkg search whoami
INDEX      ACTION VALUE              PACKAGE
basename   file   usr/ucb/whoami     pkg:/compatibility/ucb@0.5.11-0.151.1.7
basename   file   usr/bin/whoami     pkg:/file/gnu-coreutils@8.5-0.151.1.7
basename   file   usr/gnu/bin/whoami pkg:/file/gnu-coreutils@8.5-0.151.1.7
richard@devzoneX:~/src/pkgsrc$ find /usr -name whoami
richard@devzoneX:~/src/pkgsrc$ find /opt/pkg -name whoami
/opt/pkg/gnu/bin/whoami
find: /opt/pkg/scgi_temp: Permission denied
richard@devzoneX:~/src/pkgsrc$ grep whoami sysutils/coreutils/PLIST
bin/gwhoami
gnu/bin/whoami
gnu/man/man1/whoami.1
man/man1/gwhoami.1

Indeed, rc.subr presumes that whoami is core installed, even makes some somewhat questionable presumptions here:

...
_RCCMD_whoami="/usr/bin/whoami"
...
case $_osname in
	SunOS)
		_RCCMD_chown="/bin/chown"
#		_RCCMD_ci="/usr/bin/ci"			# not in Solaris 9
#		_RCCMD_co="/usr/bin/co"			# not in Solaris 9
#		_RCCMD_systrace="/bin/systrace"		# not in Solaris 9
		_RCARG_psformat="-o pid,comm"
		_RCARG_ps="-ef"
		_RCARG_su=""
		if [ "$_osrelease" = "5.11" ]; then
			bsd_echo () {
				if [ "$1" = "-n" ]; then
					shift; echo "$@\c"
				else
					echo "$@"
				fi
			}
			_RCCMD_echo="bsd_echo"
		else
			_RCCMD_echo="/usr/ucb/echo"	# not in Solaris 11
			_RCCMD_whoami="/usr/ucb/whoami"	# not in Solaris 11
		fi
		;;


perhaps sysutils/coreutils can come to the rescue if the core system is missing some required utilities.
>How-To-Repeat:
install a minimal non-global zone in OpenIndiana

do not install in addition pkg:/compatibility/ucb nor pkg:/file/gnu-coreutils

execute /etc/rc.d/<daemon> status
where the script uses the rc.subr default "status" command.
>Fix:

>Audit-Trail:
From: David Holland <dholland-pbugs@netbsd.org>
To: gnats-bugs@netbsd.org
Cc: 
Subject: Re: pkg/47371: pkgsrc/pkgtools/rc.subr uses optional tools (whoami)
 [at least in solaris zones]
Date: Fri, 28 Dec 2012 19:29:35 +0000

 please send all PR traffic to gnats-bugs@...

    ------

 From: Richard PALO <richard.palo@baou.fr>
 To: pkgsrc-bugs@NetBSD.org
 Subject: Re: pkg/47371: pkgsrc/pkgtools/rc.subr uses optional tools (whoami)
 	[at least in solaris zones]
 Date: Fri, 28 Dec 2012 18:22:54 +0100

 Also problematic:  /usr/bin/su on solaris doesn't support '-m'
                      and /usr/bin/su - <user> -c '<cmd args>' does not
 execute if the user has /usr/bin/false for shell (like do all the
 daemons whose startup script is installed in /etc/rc.d)

 seems heimdal provides gnu 'su' which works in the above cases

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2007 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.