Index | Thread | Search

From:
Klemens Nanni <kn@openbsd.org>
Subject:
Re: net/ejabberd: fix usage ejabberdctl from root
To:
ports@openbsd.org
Date:
Sat, 30 Nov 2024 10:02:49 +0000

Download raw body.

Thread
28.11.2024 04:31, Kirill A. Korinsky пишет:
> Index: patches/patch-ejabberdctl_template
> ===================================================================
> RCS file: patches/patch-ejabberdctl_template
> diff -N patches/patch-ejabberdctl_template
> --- /dev/null	1 Jan 1970 00:00:00 -0000
> +++ patches/patch-ejabberdctl_template	28 Nov 2024 01:26:59 -0000
> @@ -0,0 +1,14 @@
> +OpenBSD su treats -c before username as class, and don't requires --

doesn't require

> +
> +Index: ejabberdctl.template
> +--- ejabberdctl.template.orig
> ++++ ejabberdctl.template
> +@@ -126,7 +126,7 @@ set_dist_client()
> + exec_cmd()
> + {
> +     case $EXEC_CMD in
> +-        as_install_user) su -s /bin/sh -c 'exec "$0" "$@"' "$INSTALLUSER" -- "$@" ;;
> ++        as_install_user) su -s /bin/sh "$INSTALLUSER" -c 'exec "$0" "$@"' "$@" ;;
> +         as_current_user) "$@" ;;

I don't understand why argv is passed twice, the one inside the -c string is enough, no?

Isn't $@ the whole command incl. argv[0] aka. $0?  If so, 'exec_cmd echo foo' would print
"echo foo" and not "foo" due to the 'exec $0'.

Can't this be what a couple of base scripts do in their unpriv() helper?

	su -s /bin/sh "$INSTALLUSER" -c "'$@'"

> +     esac
> + }
>