Re: git: 918612d6fe2e - main - security/arti: Fix rc.d service using daemon, update URL

From: Rene Ladan <rene_at_freebsd.org>
Date: Mon, 26 Sep 2022 12:36:14 UTC
On Sun, Sep 25, 2022 at 04:22:00PM +0000, Carlo Strub wrote:
> The branch main has been updated by cs:
> 
> URL: https://cgit.FreeBSD.org/ports/commit/?id=918612d6fe2e312a1a57446d1c8f9c72df400e9e
> 
> commit 918612d6fe2e312a1a57446d1c8f9c72df400e9e
> Author:     Carlo Strub <cs@FreeBSD.org>
> AuthorDate: 2022-09-25 16:21:15 +0000
> Commit:     Carlo Strub <cs@FreeBSD.org>
> CommitDate: 2022-09-25 16:21:15 +0000
> 
>     security/arti: Fix rc.d service using daemon, update URL
> ---
>  GIDs                                               |  2 +-
>  UIDs                                               |  2 +-
>  security/arti/Makefile                             | 11 ++---
>  security/arti/files/arti.in                        | 51 ++++++++++++++--------
>  .../patch-crates_arti_src_arti-example-config.toml | 10 +++--
>  5 files changed, 48 insertions(+), 28 deletions(-)
> 
[...]

> diff --git a/security/arti/files/arti.in b/security/arti/files/arti.in
> index b7226c5ebe14..8cb8d4a48513 100644
> --- a/security/arti/files/arti.in
> +++ b/security/arti/files/arti.in
> @@ -1,37 +1,54 @@
[...]
>  #			by default.
> -# arti_user (str):      Arti daemon user. Default: %%USER%%
> -# arti_pidfile (str):   Arti pid file.  Default: /var/run/arti/arti.pid
> -
> +# arti_user (str):      Arti daemon user. Default: %%USERS%%
> +# arti_group (str):     Arti daemon group. Default: %%GROUPS%%
>  
[...]
> -command_args="-f -o $arti_logfile -P $arti_pidfile $arti proxy -c $arti_config"
> +: ${arti_user="%%USERS%%"}
> +: ${arti_group="%%GROUPS%%"}
> +
> +pidfiledir="/var/run/${name}"
> +pidfile="${pidfiledir}/${name}.pid"
> +logfiledir="/var/log/${name}"
> +logfile="${logfiledir}/${name}.log"
> +dbfiledir="/var/db/${name}"
> +command="/usr/sbin/daemon"
> +procname="%%PREFIX%%/bin/${name}"
> +
> +command_args="-f -o $logfile -p $pidfile $procname proxy --config $arti_config"
> +
> +start_precmd="${name}_prestart"
> +
> +arti_prestart()
> +{
> +	if [ ! -d ${pidfiledir} ]; then
> +		install -d -o ${arti_user} -g ${arti_group} ${pidfiledir}
> +	fi
> +	if [ ! -d ${logfiledir} ]; then
> +		install -d -o ${arti_user} -g ${arti_group} ${logfiledir}
> +	fi
> +	if [ ! -d ${dbfiledir} ]; then
> +		install -d -o ${arti_user} -g ${arti_group} ${dbfiledir}
> +	fi
> +}
>  
Somehow arti_prestart() fails to set the correct owner and group, causing
arti to not start as a service. Wouldn't it be easier to handle this in
pkg-plist instead?

diff --git a/security/arti/pkg-plist b/security/arti/pkg-plist
index 4b90f62f5..b70161d58 100644
--- a/security/arti/pkg-plist
+++ b/security/arti/pkg-plist
@@ -1,5 +1,7 @@
 bin/arti
 @sample %%ETCDIR%%/arti.toml.sample
+@owner %%USERS%%
+@group %%GROUPS%%
 @dir /var/db/arti
 @dir /var/log/arti
 @dir /var/run/arti

That also simplifies the rc.d script a bit by not having to declare the
*filedir, arti_user and arti_group variables.

Regards,
René