Subject: bin/32004: command interpreter test in rc.subr doesn't accomodate chroots
To: None <gnats-admin@netbsd.org, netbsd-bugs@netbsd.org>
From: None <eravin@panix.com>
List: netbsd-bugs
Date: 11/05/2005 03:34:00
>Number:         32004
>Category:       bin
>Synopsis:       command interpreter test in rc.subr doesn't accomodate chroots
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    bin-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sat Nov 05 03:34:00 +0000 2005
>Originator:     Ed Ravin
>Release:        3.0
>Organization:
Pubilc Access Networks Corp
>Environment:
NetBSD polyhedra.nyc.access.net 3.0_BETA NetBSD 3.0_BETA (PANIX-XENU-NETSERVER)
#0: Tue Oct 18 21:47:34 EDT 2005  root@juggler.panix.com:/devel/netbsd/release-3.0-20051018/src/sys/arch/i386/compile/PANIX-XENU-NETSERVER i386

>Description:
when using an rc.d script to start an interpreter running in a chroot, rc.subr's "find_processes" function tries to read the first line of
the interpreted program, but looks for it by the pathname supplied in
without prepending the chroot directory.

>How-To-Repeat:
sample rc.d script below.  rc.subr tries to read the first line of /var/flow/bin/flowscan instead of /var/chroot/var/flow/bin/flowscan.

name="flowscan"
rcvar=$name
flowscan_chroot=/var/chroot
flowscan_user=flowerman
command="/var/flow/bin/flowscan"
command_interpreter="/usr/local/bin/perl5.6.1"


load_rc_config $name
run_rc_command "$1"

>Fix:
--- rc.subr     2005/11/05 03:15:16     1.1
+++ rc.subr     2005/11/05 02:59:56
@@ -178,7 +178,7 @@

        _pref=
        if [ $_interpreter != "." ]; then       # an interpreted script
-               read _interp < $_procname       # read interpreter name
+               read _interp < ${_chroot:-}/$_procname  # read interpreter name                 _interp=${_interp#\#!}          # strip #!
                set -- $_interp
                if [ $_interpreter != $1 ]; then