From owner-svn-src-head@FreeBSD.ORG Mon Dec 21 20:32:05 2009 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 13E671065676; Mon, 21 Dec 2009 20:32:05 +0000 (UTC) (envelope-from dougb@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id DD5918FC24; Mon, 21 Dec 2009 20:32:04 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id nBLKW4re040003; Mon, 21 Dec 2009 20:32:04 GMT (envelope-from dougb@svn.freebsd.org) Received: (from dougb@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id nBLKW4WV040000; Mon, 21 Dec 2009 20:32:04 GMT (envelope-from dougb@svn.freebsd.org) Message-Id: <200912212032.nBLKW4WV040000@svn.freebsd.org> From: Doug Barton Date: Mon, 21 Dec 2009 20:32:04 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r200809 - head/usr.sbin/service X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 21 Dec 2009 20:32:05 -0000 Author: dougb Date: Mon Dec 21 20:32:04 2009 New Revision: 200809 URL: http://svn.freebsd.org/changeset/base/200809 Log: By popular request, execute rc.d scripts in the same environment as they are at boot time. Original concept submitted by: ume Modified: head/usr.sbin/service/service.8 head/usr.sbin/service/service.sh Modified: head/usr.sbin/service/service.8 ============================================================================== --- head/usr.sbin/service/service.8 Mon Dec 21 20:18:01 2009 (r200808) +++ head/usr.sbin/service/service.8 Mon Dec 21 20:32:04 2009 (r200809) @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd December 19, 2009 +.Dd December 20, 2009 .Dt service 8 .Os .Sh NAME @@ -44,7 +44,10 @@ The .Nm command is an easy interface to the rc.d system. Its primary purpose is to start and stop services provided -by the rc.d scripts, however it can also be used to list +by the rc.d scripts. +When used for this purpose it will set the same restricted +environment that is in use at boot time (see below). +It can also be used to list the scripts using various criteria. .Pp The options are as follows: @@ -78,6 +81,20 @@ above, but list all of the files, not ju .It Fl v Be slightly more verbose .El +.Sh ENVIRONMENT +When used to run rc.d scripts the +.Nm +command sets +.Ev HOME +to +.Pa / +and +.Ev PATH +to +.Pa /sbin:/bin:/usr/sbin:/usr/bin +which is how they are set in +.Pa /etc/rc +at boot time. .Sh EXIT STATUS .Ex -std .Sh EXAMPLES Modified: head/usr.sbin/service/service.sh ============================================================================== --- head/usr.sbin/service/service.sh Mon Dec 21 20:18:01 2009 (r200808) +++ head/usr.sbin/service/service.sh Mon Dec 21 20:32:04 2009 (r200809) @@ -106,11 +106,11 @@ else exit 1 fi +cd / for dir in /etc/rc.d $local_startup; do if [ -x "$dir/$script" ]; then [ -n "$VERBOSE" ] && echo "$script is located in $dir" - $dir/$script $* - exit $? + exec env -i HOME=/ PATH=/sbin:/bin:/usr/sbin:/usr/bin $dir/$script $* fi done