conf/162642: .sh scripts in /usr/loca/etc/rc.d get executed,
not sourced
Andre Albsmeier
Andre.Albsmeier at siemens.com
Thu Nov 17 14:50:15 UTC 2011
>Number: 162642
>Category: conf
>Synopsis: .sh scripts in /usr/loca/etc/rc.d get executed, not sourced
>Confidential: no
>Severity: non-critical
>Priority: medium
>Responsible: freebsd-bugs
>State: open
>Quarter:
>Keywords:
>Date-Required:
>Class: sw-bug
>Submitter-Id: current-users
>Arrival-Date: Thu Nov 17 14:50:15 UTC 2011
>Closed-Date:
>Last-Modified:
>Originator: Andre Albsmeier
>Release: FreeBSD 7.4-STABLE i386
>Organization:
>Environment:
System: FreeBSD 7.4-STABLE Tue Nov 8 12:24:13 CET 2011
>Description:
man rc.subr says:
run_rc_script file argument
Start the script file with an argument of argument, and handle the
return value from the script.
Various shell variables are unset before file is started:
name, command, command_args, command_interpreter,
extra_commands, pidfile, rcvar, required_dirs,
required_files, required_vars, argument_cmd, argument_precmd.
argument_postcmd.
The startup behaviour of file depends upon the following checks:
1. If file ends in .sh, it is sourced into the current shell.
2. If file appears to be a backup or scratch file (e.g., with a
suffix of ~, #, .OLD, or .orig), ignore it.
3. If file is not executable, ignore it.
4. If the rc.conf(5) variable rc_fast_and_loose is empty, source
file in a sub shell, otherwise source file into the current
shell.
This is only true for .sh scripts sitting in /etc/rc.d
but not for other locations.
>How-To-Repeat:
put test.sh into /usr/local/etc/rc.d and it will get executed
in a subshell but not executed in the current shell.
>Fix:
--- rc.subr.ORI 2011-11-17 15:21:59.000000000 +0100
+++ rc.subr 2011-11-17 15:26:04.000000000 +0100
@@ -938,7 +938,7 @@
eval unset ${_arg}_cmd ${_arg}_precmd ${_arg}_postcmd
case "$_file" in
- /etc/rc.d/*.sh) # run in current shell
+ *.sh) # run in current shell
set $_arg; . $_file
;;
*[~#]|*.OLD|*.bak|*.orig|*,v) # scratch file; skip
>Release-Note:
>Audit-Trail:
>Unformatted:
More information about the freebsd-bugs
mailing list