On 2022/12/30 21:04, Volker Schlecht wrote:
> While rabbitmq.rc always started the rabbitmq launch script as _rabbitmq, it
> contained a call to rabbitmqctl in rc_check(). rabbitmqctl always starts an
> instance of epmd if none is running, and since the first call to rc_check()
> is run by root, it always launches epmd as root.
> Besides having a server running with root privileges now, this leads to the
> problem that the first startup might fail because
> /var/rabbitmq/.erlang.cookie is now owned by root and not accessible by
> _rabbitmq anymore.
>
> What I'm proposing now is to use a pexp in rabbitmq.rc for rc_check().
>
> Given rabbitmq's giant invocation of erl25, the pattern I'm looking for
> might be a little flaky, but it's the best working idea I could come up with
> so far - better solutions are highly welcome, as is of course any other
> feedback.
> Index: pkg/rabbitmq.rc
> ===================================================================
> RCS file: /cvs/ports/net/rabbitmq/pkg/rabbitmq.rc,v
> retrieving revision 1.11
> diff -u -p -r1.11 rabbitmq.rc
> --- pkg/rabbitmq.rc 31 Jul 2022 16:28:15 -0000 1.11
> +++ pkg/rabbitmq.rc 30 Dec 2022 19:45:46 -0000
> @@ -5,19 +5,20 @@ daemon_user="_rabbitmq"
>
> . /etc/rc.d/rc.subr
>
> +pexp="s rabbit boot"
> rc_reload=NO
> rc_usercheck=NO
>
> rc_pre() {
> - install -d -o ${daemon_user} /var/run/rabbitmq
> + install -d -o ${daemon_user} /var/run/rabbitmq
...
> rc_stop() {
> - ${TRUEPREFIX}/bin/rabbitmqctl stop
> + ${TRUEPREFIX}/bin/rabbitmqctl stop
> }
please leave the tabs as they were
> }
>
> rc_check() {
> - ${TRUEPREFIX}/bin/rabbitmqctl status
> + pgrep -q -f "${pexp}"
if it needs to use pexp, better to use the default rc_check (which uses
pgrep -q -xf, so the pexp string will need to match the whole process
string).
how about this for rabbitmq.rc?
(btw, this part would have been more obvious sent as a separate diff
rather than stacked with an update)
Index: pkg/rabbitmq.rc
===================================================================
RCS file: /cvs/ports/net/rabbitmq/pkg/rabbitmq.rc,v
retrieving revision 1.11
diff -u -p -r1.11 rabbitmq.rc
--- pkg/rabbitmq.rc 31 Jul 2022 16:28:15 -0000 1.11
+++ pkg/rabbitmq.rc 14 Jan 2023 14:01:09 -0000
@@ -5,15 +5,12 @@ daemon_user="_rabbitmq"
. /etc/rc.d/rc.subr
+pexp="${TRUEPREFIX}/lib/erlang${MODERL_VERSION}/erts.*bin/beam.*-s rabbit
boot.*"
rc_reload=NO
rc_usercheck=NO
rc_pre() {
install -d -o ${daemon_user} /var/run/rabbitmq
-}
-
-rc_check() {
- ${TRUEPREFIX}/bin/rabbitmqctl status
}
rc_stop() {