Date: Thu, 5 Sep 2019 14:52:23 +0000 (UTC) From: Mateusz Piotrowski <0mp@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r351863 - in head: libexec/rc share/man/man8 Message-ID: <201909051452.x85EqNxW021813@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: 0mp (ports committer) Date: Thu Sep 5 14:52:22 2019 New Revision: 351863 URL: https://svnweb.freebsd.org/changeset/base/351863 Log: rc: Honor ${name}_env when a custom *_cmd is defined (e.g., start_cmd) A user may set ${name}_env variable in rc.conf(5) in order to set additional environment variables for a service command. Unfortunately, at the moment this variable is only honored when the command is specified via the command variable. Those additional environment variables coming from ${name}_env are never set if the service is started via the ${rc_arg}_cmd variable (for example start_cmd). PR: 239692 Reviewed by: bcr, jilles Approved by: src (jilles) Differential Revision: https://reviews.freebsd.org/D21228 Modified: head/libexec/rc/rc.subr head/share/man/man8/rc.subr.8 Modified: head/libexec/rc/rc.subr ============================================================================== --- head/libexec/rc/rc.subr Thu Sep 5 14:19:06 2019 (r351862) +++ head/libexec/rc/rc.subr Thu Sep 5 14:52:22 2019 (r351863) @@ -1036,6 +1036,9 @@ run_rc_command() _postcmd=\$${rc_arg}_postcmd if [ -n "$_cmd" ]; then + if [ -n "$_env" ]; then + eval "export -- $_env" + fi _run_rc_precmd || return 1 _run_rc_doit "$_cmd $rc_extra_args" || return 1 _run_rc_postcmd Modified: head/share/man/man8/rc.subr.8 ============================================================================== --- head/share/man/man8/rc.subr.8 Thu Sep 5 14:19:06 2019 (r351862) +++ head/share/man/man8/rc.subr.8 Thu Sep 5 14:52:22 2019 (r351863) @@ -29,7 +29,7 @@ .\" .\" $FreeBSD$ .\" -.Dd January 5, 2019 +.Dd September 5, 2019 .Dt RC.SUBR 8 .Os .Sh NAME @@ -559,9 +559,19 @@ is mounted. A list of environment variables to run .Va command with. -This will be passed as arguments to the +Those variables will be passed as arguments to the .Xr env 1 -utility. +utility unless +.Ar argument Ns Va _cmd +is defined. +In that case the contents of +.Va ${name}_env +will be exported via the +.Xr export 1 +builtin of +.Xr sh 1 , +which puts some limitations on the names of variables +(e.g., a variable name may not start with a digit). .It Va ${name}_env_file A file to source for environmental variables to run .Va command
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201909051452.x85EqNxW021813>