From owner-svn-src-stable-10@FreeBSD.ORG Sun Nov 2 22:41:56 2014 Return-Path: Delivered-To: svn-src-stable-10@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 2DA5D1CD; Sun, 2 Nov 2014 22:41:56 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 18EA3EA6; Sun, 2 Nov 2014 22:41:56 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id sA2Mftq6082175; Sun, 2 Nov 2014 22:41:55 GMT (envelope-from hrs@FreeBSD.org) Received: (from hrs@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id sA2MftVO082173; Sun, 2 Nov 2014 22:41:55 GMT (envelope-from hrs@FreeBSD.org) Message-Id: <201411022241.sA2MftVO082173@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: hrs set sender to hrs@FreeBSD.org using -f From: Hiroki Sato Date: Sun, 2 Nov 2014 22:41:55 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r273993 - in stable/10: etc share/man/man8 X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 02 Nov 2014 22:41:56 -0000 Author: hrs Date: Sun Nov 2 22:41:55 2014 New Revision: 273993 URL: https://svnweb.freebsd.org/changeset/base/273993 Log: MFC r272974,272976: Add ${name}_env and ${name}_prepend. ${name}_env is an argument list which will be passed to env(1). ${name}_prepend is simply prepended to the command line for $command. Modified: stable/10/etc/rc.subr stable/10/share/man/man8/rc.subr.8 Directory Properties: stable/10/ (props changed) Modified: stable/10/etc/rc.subr ============================================================================== --- stable/10/etc/rc.subr Sun Nov 2 21:58:31 2014 (r273992) +++ stable/10/etc/rc.subr Sun Nov 2 22:41:55 2014 (r273993) @@ -749,6 +749,8 @@ check_startmsgs() # NOTE: $flags from the parent environment # can be used to override this. # +# ${name}_env n Environment variables to run ${command} with. +# # ${name}_fib n Routing table number to run ${command} with. # # ${name}_nice n Nice level to run ${command} at. @@ -764,6 +766,8 @@ check_startmsgs() # to run the chrooted ${command} with. # Requires /usr to be mounted. # +# ${name}_prepend n Command added before ${command}. +# # ${rc_arg}_cmd n If set, use this as the method when invoked; # Otherwise, use default command (see below) # @@ -937,7 +941,8 @@ run_rc_command() eval _chdir=\$${name}_chdir _chroot=\$${name}_chroot \ _nice=\$${name}_nice _user=\$${name}_user \ _group=\$${name}_group _groups=\$${name}_groups \ - _fib=\$${name}_fib + _fib=\$${name}_fib _env=\$${name}_env \ + _prepend=\$${name}_prepend if [ -n "$_user" ]; then # unset $_user if running as that user if [ "$_user" = "$(eval $IDCMD)" ]; then @@ -1022,12 +1027,14 @@ run_rc_command() _doit="\ ${_nice:+nice -n $_nice }\ ${_fib:+setfib -F $_fib }\ +${_env:+env $_env }\ chroot ${_user:+-u $_user }${_group:+-g $_group }${_groups:+-G $_groups }\ $_chroot $command $rc_flags $command_args" else _doit="\ ${_chdir:+cd $_chdir && }\ ${_fib:+setfib -F $_fib }\ +${_env:+env $_env }\ $command $rc_flags $command_args" if [ -n "$_user" ]; then _doit="su -m $_user -c 'sh -c \"$_doit\"'" @@ -1038,6 +1045,9 @@ $command $rc_flags $command_args" fi _doit="nice -n $_nice $_doit" fi + if [ -n "$_prepend" ]; then + _doit="$_prepend $_doit" + fi fi # run the full command @@ -2040,7 +2050,7 @@ check_kern_features() # check_namevarlist var # Return "0" if ${name}_var is reserved in rc.subr. -_rc_namevarlist="program chroot chdir flags fib nice user group groups" +_rc_namevarlist="program chroot chdir env flags fib nice user group groups prepend" check_namevarlist() { local _v Modified: stable/10/share/man/man8/rc.subr.8 ============================================================================== --- stable/10/share/man/man8/rc.subr.8 Sun Nov 2 21:58:31 2014 (r273992) +++ stable/10/share/man/man8/rc.subr.8 Sun Nov 2 22:41:55 2014 (r273993) @@ -29,7 +29,7 @@ .\" .\" $FreeBSD$ .\" -.Dd September 23, 2012 +.Dd October 12, 2014 .Dt RC.SUBR 8 .Os .Sh NAME @@ -568,6 +568,22 @@ to before running Only supported after .Pa /usr is mounted. +.It Va ${name}_env +A list of environment variables to run +.Va command +with. +This will be passed as arguments to +.Xr env 1 +utility. +.It Va ${name}_fib +FIB +.Pa Routing Table +number to run +.Va command +with. +See +.Xr setfib 1 +for more details. .It Va ${name}_flags Arguments to call .Va command @@ -622,6 +638,14 @@ as. Comma separated list of supplementary groups to run the chrooted .Va command with. +.It Va ${name}_prepend +Commands to be prepended to +.Va command . +This is a generic version of +.Va ${name}_env , +.Va ${name}_fib , +or +.Va ${name}_nice . .It Ar argument Ns Va _cmd Shell commands which override the default method for .Ar argument .