From owner-freebsd-bugs@FreeBSD.ORG Thu Nov 17 14:50:15 2011 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id B419E106564A for ; Thu, 17 Nov 2011 14:50:15 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id 8E0E78FC1B for ; Thu, 17 Nov 2011 14:50:15 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.4/8.14.4) with ESMTP id pAHEoF30013203 for ; Thu, 17 Nov 2011 14:50:15 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.4/8.14.4/Submit) id pAHEoFVX013202; Thu, 17 Nov 2011 14:50:15 GMT (envelope-from gnats) Resent-Date: Thu, 17 Nov 2011 14:50:15 GMT Resent-Message-Id: <201111171450.pAHEoFVX013202@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Andre Albsmeier Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id C407A106564A for ; Thu, 17 Nov 2011 14:44:03 +0000 (UTC) (envelope-from Andre.Albsmeier@siemens.com) Received: from thoth.sbs.de (thoth.sbs.de [192.35.17.2]) by mx1.freebsd.org (Postfix) with ESMTP id 57CE08FC13 for ; Thu, 17 Nov 2011 14:44:02 +0000 (UTC) Received: from mail2.siemens.de (localhost [127.0.0.1]) by thoth.sbs.de (8.13.6/8.13.6) with ESMTP id pAHEU56M001526 for ; Thu, 17 Nov 2011 15:30:05 +0100 Received: from curry.mchp.siemens.de (curry.mchp.siemens.de [139.25.40.130]) by mail2.siemens.de (8.13.6/8.13.6) with ESMTP id pAHEU4eH022366 for ; Thu, 17 Nov 2011 15:30:04 +0100 Received: (from localhost) by curry.mchp.siemens.de (8.14.5/8.14.4) id pAHEU4cE009416 for FreeBSD-gnats-submit@freebsd.org; Thu, 17 Nov 2011 15:30:04 +0100 (CET) Message-Id: <201111171430.pAHEU4f1039739@curry.mchp.siemens.de> Date: Thu, 17 Nov 2011 15:30:04 +0100 (CET) From: Andre Albsmeier To: FreeBSD-gnats-submit@FreeBSD.org X-Send-Pr-Version: 3.113 Cc: Subject: conf/162642: .sh scripts in /usr/loca/etc/rc.d get executed, not sourced X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 17 Nov 2011 14:50:15 -0000 >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: