From nobody Tue Oct 5 11:13:44 2021 X-Original-To: erlang@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 D5DEA17E23F0 for ; Tue, 5 Oct 2021 11:13:44 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4HNw205c03z4qRP for ; Tue, 5 Oct 2021 11:13:44 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org (kenobi.freebsd.org [IPv6:2610:1c1:1:606c::50:1d]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id A07CD3A66 for ; Tue, 5 Oct 2021 11:13:44 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org ([127.0.1.5]) by kenobi.freebsd.org (8.15.2/8.15.2) with ESMTP id 195BDi5L008860 for ; Tue, 5 Oct 2021 11:13:44 GMT (envelope-from bugzilla-noreply@freebsd.org) Received: (from www@localhost) by kenobi.freebsd.org (8.15.2/8.15.2/Submit) id 195BDiEF008859 for erlang@FreeBSD.org; Tue, 5 Oct 2021 11:13:44 GMT (envelope-from bugzilla-noreply@freebsd.org) X-Authentication-Warning: kenobi.freebsd.org: www set sender to bugzilla-noreply@freebsd.org using -f From: bugzilla-noreply@freebsd.org To: erlang@FreeBSD.org Subject: [Bug 258488] net/rabbitmq: fix pidfile in rabbitmq rc.d script Date: Tue, 05 Oct 2021 11:13:44 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Ports & Packages X-Bugzilla-Component: Individual Port(s) X-Bugzilla-Version: Latest X-Bugzilla-Keywords: regression X-Bugzilla-Severity: Affects Many People X-Bugzilla-Who: dch@freebsd.org X-Bugzilla-Status: In Progress X-Bugzilla-Resolution: X-Bugzilla-Priority: --- X-Bugzilla-Assigned-To: erlang@FreeBSD.org X-Bugzilla-Flags: maintainer-feedback? maintainer-feedback? merge-quarterly? X-Bugzilla-Changed-Fields: bug_status Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: https://bugs.freebsd.org/bugzilla/ Auto-Submitted: auto-generated List-Id: Support of Erlang-related ports List-Archive: https://lists.freebsd.org/archives/freebsd-erlang List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-erlang@freebsd.org MIME-Version: 1.0 X-ThisMailContainsUnwantedMimeParts: N https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D258488 Dave Cottlehuber changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Open |In Progress --- Comment #2 from Dave Cottlehuber --- This gets messy fast! None of the options so far produce a good result. - RabbitMQ in general expects its pidfile to be the BEAM process - using daemon(8) sets the FreeBSD pidfile to the rabbitmq-server shell scr= ipt - rabbitmq-server docs are in fact incorrect, the pidfile is written even when `-detached` is set - we don't know what the pidfile is going to be inside RabbitMQ really - RabbitMQ *needs* to have a writable pidfile location as its Elixir helper scripts will wait for the file to appear (so truncation is not an option) According to https://www.rabbitmq.com/relocate.html RabbitMQ has its pidfile defined here: RABBITMQ_PID_FILE Which expands to (by default): /var/db/rabbitmq/mnesia/rabbit@${HOSTNAME}.pid Which is not at all FreeBSD hier(7) nor POLA, but is exactly where a RabbitMQ person would look for it, and where all the tools expect it to be. The rc.d script sets this pidfile variable, but RabbitMQ ignores it as env = vars are not passed through to su nor daemon. ``` # ps -dU rabbitmq PID STAT TIME COMMAND 47303 I 0:00.01 /bin/sh /usr/local/sbin/rabbitmq-server 71950 I 0:07.19 - /usr/local/lib/erlang24/erts-12.1.1/bin/beam.smp ... 41316 Ss 0:00.10 `-- erl_child_setup 65000 69 Is 0:00.00 `-- inet_gethost 4 15065 I 0:00.00 `-- inet_gethost 4 # cat /var/db/rabbitmq/mnesia/rabbit@wintermute.pid 71950 # cat /var/run/rabbitmq.pid 47303 # cat /var/run/rabbitmq-daemon.pid 43693 # pgrep -ilf daemon|grep rabb 43693 daemon: /usr/local/sbin/rabbitmq-server[47303] ``` wrt using daemon(8), I'm generally not in favour of this for network-facing systems; if the application crashes, we want to fix that, and not just restart and YOLO our way through whatever issue crops up. For example, if the app crashes on malicious input, then it may be possible to use this crash as a side channel to extract credentials. That said, if you have need of it, I'm ok with switching back, I just need to understand what's broken so I am sure we fix it this time. I can roll this into the 3.9.7 update I'm preparing just now, and backport that to quarterly. Does the rc.d script behave correctly for your needs? Do you need knowledge of /var/run/rabbitmq.pid outside of the rc.d script at all? I don't think daemon(8) helps here, it just makes more incorrect pidfiles. And the only sensible choice is the rabbitmq default, which would mean we have no $pidfile at all in the rc.d script. What should we do here? --=20 You are receiving this mail because: You are the assignee for the bug.=