From nobody Mon Aug 15 15:27:17 2022 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4M5ynt0wxCz4ZG9V; Mon, 15 Aug 2022 15:27:30 +0000 (UTC) (envelope-from oshogbo.vx@gmail.com) Received: from mail-vs1-f43.google.com (mail-vs1-f43.google.com [209.85.217.43]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "GTS CA 1D4" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4M5yns1nwTz3nbw; Mon, 15 Aug 2022 15:27:29 +0000 (UTC) (envelope-from oshogbo.vx@gmail.com) Received: by mail-vs1-f43.google.com with SMTP id 66so7470557vse.4; Mon, 15 Aug 2022 08:27:29 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc; bh=qmMxHElmiuLcfOxl/UsoX7/wiYpWCnzKL0l4dq6FrDQ=; b=JSwrR6RBKb9c/WoeHIJ3jh/+DZi4VvoCoKNx3NDsTxZtLSA27ZjK0KPuqbIwRbOQsJ eJq590TJ40nUcIUyxwx4IDlRNcLQYyvyg0zTX50vzTKfxia3eeNyIoWKht0yaUzeKWVx czZcHFYEI5YKcijac+UMkfwjL1Pj3w2/w2Lr8Pr8uflV7dKQcecon/+ZQtknflVBfZ1Z k/5tEp1E62gImhRQRmPCc2UAXQrQ/016+jJQ66Bi5mIS7hNMHPsi+02rDaIQ8UFhkouR 73PGnBOtTDVcslAhkSCrQIRmWbHKj8xBSWpE2ahBLA7p2ZhibRtEVrIXkPHLiWn88pYN 6NKA== X-Gm-Message-State: ACgBeo1aM4mAv7eSWKX7x9uwoQksvQRcBA32g1EaYtHYAhEO0np7Uhpe cydqCPd0fGBvUOtwFINcNeWm5mzMBTHDT8/TRbI5k9ty X-Google-Smtp-Source: AA6agR7Lj+HsCvPfPZnR5Cxq+Twbb31BmY4f66uiLlcCegRbKUFLWLXkMoE3rWOnTjYUWg4at6o+Cu5l9npWFeOQDEw= X-Received: by 2002:a05:6102:149c:b0:388:a8ab:5328 with SMTP id d28-20020a056102149c00b00388a8ab5328mr6209739vsv.78.1660577248409; Mon, 15 Aug 2022 08:27:28 -0700 (PDT) List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 References: <202208151442.27FEgjSd083060@gitrepo.freebsd.org> <01000182a2168e9f-0a342484-127b-42fc-819a-00ddbf5158db-000000@email.amazonses.com> In-Reply-To: <01000182a2168e9f-0a342484-127b-42fc-819a-00ddbf5158db-000000@email.amazonses.com> From: Mariusz Zaborski Date: Mon, 15 Aug 2022 17:27:17 +0200 Message-ID: Subject: Re: git: c9be47b34dd8 - main - rc: add ${name}_setup script support To: Colin Percival Cc: franco@opnsense.org, src-committers , "" , dev-commits-src-main@freebsd.org Content-Type: multipart/alternative; boundary="000000000000037d4705e64945bf" X-Rspamd-Queue-Id: 4M5yns1nwTz3nbw X-Spamd-Bar: - Authentication-Results: mx1.freebsd.org; dkim=none; dmarc=none; spf=pass (mx1.freebsd.org: domain of oshogbo.vx@gmail.com designates 209.85.217.43 as permitted sender) smtp.mailfrom=oshogbo.vx@gmail.com X-Spamd-Result: default: False [-1.94 / 15.00]; SUBJECT_HAS_CURRENCY(1.00)[]; NEURAL_HAM_MEDIUM(-1.00)[-0.997]; NEURAL_HAM_SHORT(-0.99)[-0.989]; NEURAL_HAM_LONG(-0.95)[-0.951]; FORGED_SENDER(0.30)[oshogbo@freebsd.org,oshogbovx@gmail.com]; R_SPF_ALLOW(-0.20)[+ip4:209.85.128.0/17:c]; MIME_GOOD(-0.10)[multipart/alternative,text/plain]; MIME_TRACE(0.00)[0:+,1:+,2:~]; MLMMJ_DEST(0.00)[dev-commits-src-all@freebsd.org,dev-commits-src-main@freebsd.org]; RWL_MAILSPIKE_POSSIBLE(0.00)[209.85.217.43:from]; TAGGED_FROM(0.00)[]; RCVD_IN_DNSWL_NONE(0.00)[209.85.217.43:from]; ASN(0.00)[asn:15169, ipnet:209.85.128.0/17, country:US]; R_DKIM_NA(0.00)[]; ARC_NA(0.00)[]; FROM_NEQ_ENVFROM(0.00)[oshogbo@freebsd.org,oshogbovx@gmail.com]; FROM_HAS_DN(0.00)[]; FREEMAIL_ENVFROM(0.00)[gmail.com]; TO_MATCH_ENVRCPT_SOME(0.00)[]; TO_DN_SOME(0.00)[]; DMARC_NA(0.00)[freebsd.org]; RCVD_TLS_LAST(0.00)[]; RCPT_COUNT_FIVE(0.00)[5]; RCVD_COUNT_TWO(0.00)[2] X-ThisMailContainsUnwantedMimeParts: N --000000000000037d4705e64945bf Content-Type: text/plain; charset="UTF-8" Thats a good point. cc the author On Mon, 15 Aug 2022 at 17:19, Colin Percival wrote: > Can we have rc.subr(8) updated to reflect this change? It's not at all > clear > to me how foo_setup is different from start_precmd. > > Colin Percival > > On 8/15/22 07:42, Mariusz Zaborski wrote: > > The branch main has been updated by oshogbo: > > > > URL: > https://cgit.FreeBSD.org/src/commit/?id=c9be47b34dd847da1d4ab0feee4a6100b2c5ea0d > > > > commit c9be47b34dd847da1d4ab0feee4a6100b2c5ea0d > > Author: Franco Fichtner > > AuthorDate: 2022-08-15 14:41:31 +0000 > > Commit: Mariusz Zaborski > > CommitDate: 2022-08-15 14:43:12 +0000 > > > > rc: add ${name}_setup script support > > > > Run a service-based setup script before running the start command. > > Useful for automatic configuration file generation. > > > > Reviewed by: https://reviews.freebsd.org/D36006 > > --- > > libexec/rc/rc.subr | 14 +++++++++++--- > > 1 file changed, 11 insertions(+), 3 deletions(-) > > > > diff --git a/libexec/rc/rc.subr b/libexec/rc/rc.subr > > index 612ee12883ec..9ae93dc391a2 100644 > > --- a/libexec/rc/rc.subr > > +++ b/libexec/rc/rc.subr > > @@ -804,6 +804,8 @@ startmsg() > > # > > # ${name}_prepend n Command added before ${command}. > > # > > +# ${name}_setup n Command executed before ${command}. > > +# > > # ${name}_login_class n Login class to use, else "daemon". > > # > > # ${name}_limits n limits(1) to apply to ${command}. > > @@ -993,8 +995,8 @@ 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 \ > > - _env_file=\$${name}_env_file > > + _limits=\$${name}_limits _oomprotect=\$${name}_oomprotect \ > > + _setup=\$${name}_setup _env_file=\$${name}_env_file > > > > if [ -n "$_env_file" ] && [ -r "${_env_file}" ]; then # load env > from file > > set -a > > @@ -1149,6 +1151,12 @@ $command $rc_flags $command_args" > > fi > > fi > > > > + if [ -n "$_setup" ]; then > > + if ! _run_rc_doit "$_setup"; then > > + warn "failed to setup ${name}" > > + fi > > + fi > > + > > # Prepend default limits > > _doit="$_cd limits -C $_login_class $_limits > $_doit" > > > > @@ -2187,7 +2195,7 @@ check_kern_features() > > # check_namevarlist var > > # Return "0" if ${name}_var is reserved in rc.subr. > > > > -_rc_namevarlist="program chroot chdir env flags fib nice user group > groups prepend" > > +_rc_namevarlist="program chroot chdir env flags fib nice user group > groups prepend setup" > > check_namevarlist() > > { > > local _v > > > > -- > Colin Percival > Security Officer Emeritus, FreeBSD | The power to serve > Founder, Tarsnap | www.tarsnap.com | Online backups for the truly paranoid > --000000000000037d4705e64945bf Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Thats a good point.
cc the author

On Mon, 15 Aug = 2022 at 17:19, Colin Percival <c= perciva@tarsnap.com> wrote:
Can we have rc.subr(8) updated to reflect this change?= =C2=A0 It's not at all clear
to me how foo_setup is different from start_precmd.

Colin Percival

On 8/15/22 07:42, Mariusz Zaborski wrote:
> The branch main has been updated by oshogbo:
>
> URL: https://= cgit.FreeBSD.org/src/commit/?id=3Dc9be47b34dd847da1d4ab0feee4a6100b2c5ea0d<= /a>
>
> commit c9be47b34dd847da1d4ab0feee4a6100b2c5ea0d
> Author:=C2=A0 =C2=A0 =C2=A0Franco Fichtner <
franco@opnsense.org>
> AuthorDate: 2022-08-15 14:41:31 +0000
> Commit:=C2=A0 =C2=A0 =C2=A0Mariusz Zaborski <oshogbo@FreeBSD.org>= ;
> CommitDate: 2022-08-15 14:43:12 +0000
>
>=C2=A0 =C2=A0 =C2=A0 rc: add ${name}_setup script support
>=C2=A0 =C2=A0 =C2=A0
>=C2=A0 =C2=A0 =C2=A0 Run a service-based setup script before running th= e start command.
>=C2=A0 =C2=A0 =C2=A0 Useful for automatic configuration file generation= .
>=C2=A0 =C2=A0 =C2=A0
>=C2=A0 =C2=A0 =C2=A0 Reviewed by:=C2=A0 =C2=A0 https://reviews= .freebsd.org/D36006
> ---
>=C2=A0 =C2=A0libexec/rc/rc.subr | 14 +++++++++++---
>=C2=A0 =C2=A01 file changed, 11 insertions(+), 3 deletions(-)
>
> diff --git a/libexec/rc/rc.subr b/libexec/rc/rc.subr
> index 612ee12883ec..9ae93dc391a2 100644
> --- a/libexec/rc/rc.subr
> +++ b/libexec/rc/rc.subr
> @@ -804,6 +804,8 @@ startmsg()
>=C2=A0 =C2=A0#
>=C2=A0 =C2=A0#=C2=A0 =C2=A0${name}_prepend n=C2=A0 =C2=A0 =C2=A0 =C2=A0= Command added before ${command}.
>=C2=A0 =C2=A0#
> +#=C2=A0 =C2=A0 ${name}_setup=C2=A0 =C2=A0n=C2=A0 =C2=A0 =C2=A0 =C2=A0= Command executed before ${command}.
> +#
>=C2=A0 =C2=A0#=C2=A0 =C2=A0${name}_login_class n=C2=A0 =C2=A0Login clas= s to use, else "daemon".
>=C2=A0 =C2=A0#
>=C2=A0 =C2=A0#=C2=A0 =C2=A0${name}_limits=C2=A0 n=C2=A0 =C2=A0 =C2=A0 = =C2=A0limits(1) to apply to ${command}.
> @@ -993,8 +995,8 @@ run_rc_command()
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0_group=3D\$${name}_group=C2=A0= =C2=A0 =C2=A0 _groups=3D\$${name}_groups \
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0_fib=3D\$${name}_fib=C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 _env=3D\$${name}_env \
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0_prepend=3D\$${name}_prepend= =C2=A0 _login_class=3D\${${name}_login_class:-daemon} \
> -=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0_limits=3D\$${name}_limits=C2=A0 = =C2=A0 _oomprotect=3D\$${name}_oomprotect \
> -=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0_env_file=3D\$${name}_env_file
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0_limits=3D\$${name}_limits=C2=A0 = =C2=A0 _oomprotect=3D\$${name}_oomprotect \
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0_setup=3D\$${name}_setup=C2=A0 =C2= =A0 =C2=A0 _env_file=3D\$${name}_env_file
>=C2=A0 =C2=A0
>=C2=A0 =C2=A0 =C2=A0 =C2=A0if [ -n "$_env_file" ] && = [ -r "${_env_file}" ]; then=C2=A0 =C2=A0# load env from file
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0set -a
> @@ -1149,6 +1151,12 @@ $command $rc_flags $command_args"
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0fi
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0fi
>=C2=A0 =C2=A0
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0if [ -n "$_setup" ]; then
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0if ! _run_rc_doit "$_setup"; t= hen
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0warn "f= ailed to setup ${name}"
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0fi
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0fi
> +
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0# Prep= end default limits
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0_doit=3D"$_cd limits -C $_login_class $_limits $_doit&quo= t;
>=C2=A0 =C2=A0
> @@ -2187,7 +2195,7 @@ check_kern_features()
>=C2=A0 =C2=A0# check_namevarlist var
>=C2=A0 =C2=A0#=C2=A0 =C2=A0Return "0" if ${name}_var is reser= ved in rc.subr.
>=C2=A0 =C2=A0
> -_rc_namevarlist=3D"program chroot chdir env flags fib nice user = group groups prepend"
> +_rc_namevarlist=3D"program chroot chdir env flags fib nice user = group groups prepend setup"
>=C2=A0 =C2=A0check_namevarlist()
>=C2=A0 =C2=A0{
>=C2=A0 =C2=A0 =C2=A0 =C2=A0local _v
>

--
Colin Percival
Security Officer Emeritus, FreeBSD | The power to serve
Founder, Tarsnap | www.tarsnap.com | Online backups for the truly paranoid=
--000000000000037d4705e64945bf--