Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 20 Dec 2009 12:10:55 -0800
From:      Doug Barton <dougb@FreeBSD.org>
To:        Hajimu UMEMOTO <ume@FreeBSD.org>
Cc:        svn-src-head@FreeBSD.org, svn-src-all@FreeBSD.org, src-committers@FreeBSD.org, freebsd-rc@FreeBSD.org
Subject:   Re: svn commit: r200743 - in head/usr.sbin: . service
Message-ID:  <4B2E84CF.2060902@FreeBSD.org>
In-Reply-To: <ygeaaxec7oz.wl%ume@mahoroba.org>
References:  <200912200134.nBK1YCAA048942@svn.freebsd.org>	<yged42ackpc.wl%ume@mahoroba.org>	<4B2DBB51.9060002@FreeBSD.org>	<ygebphuceaw.wl%ume@mahoroba.org>	<4B2DD2A1.8060907@FreeBSD.org> <ygeaaxec7oz.wl%ume@mahoroba.org>

next in thread | previous in thread | raw e-mail | index | archive | help
This is a multi-part message in MIME format.
--------------060103070006030401020109
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit

Hajimu UMEMOTO wrote:
> Yup, I often do restart the services installed from ports, too.
> I meant that I don't want that the values of user environment are
> inherited to the services which is started from the user environment.

And I meant that I see the ability to start services AND inherit the
user environment as a feature, however the people have spoken! :)

I agree to making the change you suggested, but I would like to
quibble over the format. Isn't the attached patch equivalent, and
simpler? What is the value of setting HOME and PATH in the environment
if we're just going to use 'env -i HOME PATH' anyway?

Doug

-- 

	Improve the effectiveness of your Internet presence with
	a domain name makeover!    http://SupersetSolutions.com/


--------------060103070006030401020109
Content-Type: text/plain;
 name="service-env.diff"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="service-env.diff"

Index: service.8
===================================================================
--- service.8	(revision 200757)
+++ service.8	(working copy)
@@ -24,7 +24,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd December 19, 2009
+.Dd December 20, 2009
 .Dt service 8
 .Os
 .Sh NAME
@@ -44,7 +44,10 @@
 .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 @@
 .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
Index: service.sh
===================================================================
--- service.sh	(revision 200757)
+++ service.sh	(working copy)
@@ -106,11 +106,11 @@
 	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
 

--------------060103070006030401020109--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?4B2E84CF.2060902>