NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

misc/47251: rc.d script using _chdir silently crashes

>Number:         47251
>Category:       misc
>Synopsis:       rc.d script using _chdir silently crashes
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    misc-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon Nov 26 22:10:00 +0000 2012
>Originator:     Guillaume
>Release:        6.0
NetBSD andy 6.0 NetBSD 6.0 (GENERIC) i386
I could not get a home-written /etc/rc.d/name script to work for an application 
that uses ${name}_chdir shell variable.

I couldn't even see the string 'Starting ${name}' when playing the script.

It seemed that the -x file test returned 0 in my case.
1. create a little "service" :

echo '#!/bin/sh\n\n#Dummy server, waiting on port 8080\nnc -l -p 8080 2>&1 >> 
/tmp/test &\n' >> /root/test_br

2. create a (really minimalist) initscript


. /etc/rc.subr



load_rc_config $name
run_rc_command "$1"

3. cd to a directory different than /root

cd /tmp

4. launch initscript

/etc/rc.d/test_br onestart

=> silently KO
Modifying the -x execfile test was enough ; the following diff illustrates a 
solution :

--- rc.subr.orig        2012-11-26 22:09:41.000000000 +0100
+++ rc.subr     2012-11-26 22:42:01.000000000 +0100
@@ -603,7 +603,7 @@
                                exit 1
-                       if [ ! -x ${_chroot}${command} ]; then
+                       if [ ! -x ${_chroot}${command} -a ! -x 
${_chdir}${command} ]; then
                                return 0
(I'm everything but a shell expert, please don't blame ^^)

after applying this diff, you can test :

3bis. cd to a directory different than /root

cd /tmp

4bis. launch initscript

/etc/rc.d/test_br onestart

=> Starting test_br.

5. connect to the server and talk to it. Great.

Home | Main Index | Thread Index | Old Index