svn commit: r200743 - in head/usr.sbin: . service

Doug Barton dougb at FreeBSD.org
Sun Dec 20 20:10:52 UTC 2009


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/

-------------- next part --------------
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
 


More information about the freebsd-rc mailing list