From owner-svn-src-stable@freebsd.org Tue Nov 10 10:19:56 2020 Return-Path: Delivered-To: svn-src-stable@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 092C92EA45A; Tue, 10 Nov 2020 10:19:56 +0000 (UTC) (envelope-from 0mp@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CVkPl6xkTz3Qp3; Tue, 10 Nov 2020 10:19:55 +0000 (UTC) (envelope-from 0mp@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id E1557211D8; Tue, 10 Nov 2020 10:19:55 +0000 (UTC) (envelope-from 0mp@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AAAJt1h027451; Tue, 10 Nov 2020 10:19:55 GMT (envelope-from 0mp@FreeBSD.org) Received: (from 0mp@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AAAJtTF027449; Tue, 10 Nov 2020 10:19:55 GMT (envelope-from 0mp@FreeBSD.org) Message-Id: <202011101019.0AAAJtTF027449@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: 0mp set sender to 0mp@FreeBSD.org using -f From: Mateusz Piotrowski <0mp@FreeBSD.org> Date: Tue, 10 Nov 2020 10:19:55 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r367550 - in stable/12: libexec/rc share/man/man8 X-SVN-Group: stable-12 X-SVN-Commit-Author: 0mp X-SVN-Commit-Paths: in stable/12: libexec/rc share/man/man8 X-SVN-Commit-Revision: 367550 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 10 Nov 2020 10:19:56 -0000 Author: 0mp (doc,ports committer) Date: Tue Nov 10 10:19:55 2020 New Revision: 367550 URL: https://svnweb.freebsd.org/changeset/base/367550 Log: MFC r351863: 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) Requested by: koobs Modified: stable/12/libexec/rc/rc.subr stable/12/share/man/man8/rc.subr.8 Directory Properties: stable/12/ (props changed) Modified: stable/12/libexec/rc/rc.subr ============================================================================== --- stable/12/libexec/rc/rc.subr Tue Nov 10 10:17:11 2020 (r367549) +++ stable/12/libexec/rc/rc.subr Tue Nov 10 10:19:55 2020 (r367550) @@ -1024,6 +1024,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: stable/12/share/man/man8/rc.subr.8 ============================================================================== --- stable/12/share/man/man8/rc.subr.8 Tue Nov 10 10:17:11 2020 (r367549) +++ stable/12/share/man/man8/rc.subr.8 Tue Nov 10 10:19:55 2020 (r367550) @@ -556,9 +556,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