From owner-svn-src-head@freebsd.org Fri May 25 19:36:27 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 1E1CBEF2055; Fri, 25 May 2018 19:36:27 +0000 (UTC) (envelope-from feld@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id C57EC7094C; Fri, 25 May 2018 19:36:26 +0000 (UTC) (envelope-from feld@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 A20BE25390; Fri, 25 May 2018 19:36:26 +0000 (UTC) (envelope-from feld@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w4PJaQcl093394; Fri, 25 May 2018 19:36:26 GMT (envelope-from feld@FreeBSD.org) Received: (from feld@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w4PJaQIf093393; Fri, 25 May 2018 19:36:26 GMT (envelope-from feld@FreeBSD.org) Message-Id: <201805251936.w4PJaQIf093393@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: feld set sender to feld@FreeBSD.org using -f From: Mark Felder Date: Fri, 25 May 2018 19:36:26 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r334221 - head/etc X-SVN-Group: head X-SVN-Commit-Author: feld X-SVN-Commit-Paths: head/etc X-SVN-Commit-Revision: 334221 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 25 May 2018 19:36:27 -0000 Author: feld (ports committer) Date: Fri May 25 19:36:26 2018 New Revision: 334221 URL: https://svnweb.freebsd.org/changeset/base/334221 Log: rc.subr: Support loading environmental variables from a file The current support for setting environment via foo_env="" in rc.conf is not scalable and does not handle envs with spaces in the value. It seems a common pattern for some newer software is to skip configuration files altogether and rely on the env. This is well supported in systemd unit files and may be the inspiration for this trend. MFH: 1 week Differential Revision: https://reviews.freebsd.org/D14453 Modified: head/etc/rc.subr Modified: head/etc/rc.subr ============================================================================== --- head/etc/rc.subr Fri May 25 19:16:05 2018 (r334220) +++ head/etc/rc.subr Fri May 25 19:36:26 2018 (r334221) @@ -754,6 +754,8 @@ check_startmsgs() # # ${name}_env n Environment variables to run ${command} with. # +# ${name}_env_file n File to source variables to run ${command} with. +# # ${name}_fib n Routing table number to run ${command} with. # # ${name}_nice n Nice level to run ${command} at. @@ -954,7 +956,14 @@ run_rc_command() _group=\$${name}_group _groups=\$${name}_groups \ _fib=\$${name}_fib _env=\$${name}_env \ _prepend=\$${name}_prepend _login_class=\${${name}_login_class:-daemon} \ - _limits=\$${name}_limits _oomprotect=\$${name}_oomprotect + _limits=\$${name}_limits _oomprotect=\$${name}_oomprotect \ + _env_file=\$${name}_env_file + + if [ -n "$_env_file" ] && [ -r "${_env_file}" ]; then # load env from file + set -a + . $_env_file + set +a + fi if [ -n "$_user" ]; then # unset $_user if running as that user if [ "$_user" = "$(eval $IDCMD)" ]; then