Tuesday, February 28, 2023

Re: [audio/umurmur] umurmurd "switching" to the last group found in group(5) file

On 2023/02/28 13:34:23 +0000, Raf Czlonka <rczlonka@gmail.com> wrote:
> Hello,
>
> This is what is being written to /var/log/daemon after fresh install of
> umurmur:
>
> Feb 26 13:38:06 foo uMurmurd[34340]: OpenSSL library initialized (version: LibreSSL 3.7.1)
> Feb 26 13:38:06 foo uMurmurd[34340]: Setting default channel 'Lobby'
> Feb 26 13:38:06 foo uMurmurd[34340]: Adding channel 'Lobby' parent 'Root'
> Feb 26 13:38:06 foo uMurmurd[34340]: Adding channel 'Silent' parent 'Root'
> Feb 26 13:38:06 foo uMurmurd[34340]: Adding channel 'Red team' parent 'Lobby'
> Feb 26 13:38:06 foo uMurmurd[34340]: Adding channel 'Blue team' parent 'Lobby'
> Feb 26 13:38:06 foo uMurmurd[34340]: Adding channel link 'Lobby' -> 'Red team'
> Feb 26 13:38:06 foo uMurmurd[34340]: Adding channel link 'Lobby' -> 'Blue team'
> Feb 26 13:38:06 foo uMurmurd[34340]: Switch to user '_umurmur' group '_umurmur'
> Feb 26 13:38:06 foo uMurmurd[34340]: uMurmur version 0.2.20 ('Bonkers') protocol version 1.2.4
> Feb 26 13:38:06 foo uMurmurd[34340]: Visit https://github.com/umurmur/umurmur
>
> After an upgrade to the latest snapshot and having installed gotd,
> I've noticed an odd and misleading information produced by umurmurd:
>
> Feb 27 12:14:45 foo uMurmurd[57309]: OpenSSL library initialized (version: LibreSSL 3.7.1)
> Feb 27 12:14:45 foo uMurmurd[57309]: Setting default channel 'Lobby'
> Feb 27 12:14:45 foo uMurmurd[57309]: Adding channel 'Lobby' parent 'Root'
> Feb 27 12:14:45 foo uMurmurd[57309]: Adding channel 'Silent' parent 'Root'
> Feb 27 12:14:45 foo uMurmurd[57309]: Adding channel 'Red team' parent 'Lobby'
> Feb 27 12:14:45 foo uMurmurd[57309]: Adding channel 'Blue team' parent 'Lobby'
> Feb 27 12:14:45 foo uMurmurd[57309]: Adding channel link 'Lobby' -> 'Red team'
> Feb 27 12:14:45 foo uMurmurd[57309]: Adding channel link 'Lobby' -> 'Blue team'
> Feb 27 12:14:45 foo uMurmurd[57309]: Switch to user '_umurmur' group '_gotd'
> Feb 27 12:14:45 foo uMurmurd[57309]: uMurmur version 0.2.20 ('Bonkers') protocol version 1.2.4
> Feb 27 12:14:46 foo uMurmurd[57309]: Visit https://github.com/umurmur/umurmur
>
> In case this isn't clear - this is the line in question:
>
> Feb 27 12:14:45 foo uMurmurd[57309]: Switch to user '_umurmur' group '_gotd'
>
> Why would umurmurd switch to group _gotd?
>
> Given that it was the last piece of software I installed or, rather,
> it was the last group added to the system, it must be related, no?
>
> $ tail -n 1 /etc/group
> _gotd:*:501:
>
> A quick test confirmed it - umurmurd says that it switches to a
> particular group and, as it happens, said group is simply the last
> entry found in group(5) file; I've added a 'git' user, with a
> corresponding group:
>
> $ tail -n 2 /etc/group
> _gotd:*:501:
> git:*:999:
>
> and sure enough:
>
> Feb 28 09:44:14 foo uMurmurd[42595]: OpenSSL library initialized (version: LibreSSL 3.7.1)
> Feb 28 09:44:14 foo uMurmurd[42595]: Setting default channel 'Lobby'
> Feb 28 09:44:15 foo uMurmurd[42595]: Adding channel 'Lobby' parent 'Root'
> Feb 28 09:44:15 foo uMurmurd[42595]: Adding channel 'Silent' parent 'Root'
> Feb 28 09:44:15 foo uMurmurd[42595]: Adding channel 'Red team' parent 'Lobby'
> Feb 28 09:44:15 foo uMurmurd[42595]: Adding channel 'Blue team' parent 'Lobby'
> Feb 28 09:44:15 foo uMurmurd[42595]: Adding channel link 'Lobby' -> 'Red team'
> Feb 28 09:44:15 foo uMurmurd[42595]: Adding channel link 'Lobby' -> 'Blue team'
> Feb 28 09:44:15 foo uMurmurd[42595]: Switch to user '_umurmur' group 'git'
> Feb 28 09:44:15 foo uMurmurd[42595]: uMurmur version 0.2.20 ('Bonkers') protocol version 1.2.4
> Feb 28 09:44:15 foo uMurmurd[42595]: Visit https://github.com/umurmur/umurmur
>
> What's odd, though, is that umurmur does *not* seem to be switching
> to that group - it only says it does:
>
> $ pgrep -G git -l
> $ echo $?
> 1
> $ pgrep -G _umurmur -l
> 42595 umurmurd
>
> So it looks like it is only _pretty printing_ that's broken.
>
> Cheers,
>
> Raf
>
> P.S. I'm not subscribed to this mailing list so please CC me if need be.

This is because they call getgrnam() to get group info, then call
initgroups() (which will call getgrouplist() and invalidate the data
pointed by the previous call to getgrnam()) and print it. luckily the
pointer returned by getgrnam() is only kept around for printing to the
logs.

Can you try again with this diff applied? it should fix the issue.
Alternatively commenting the `groupname = "_umurmur"` in the config
file should have a similar effect.

I'm not familiar with this daemon, when I start it i don't have any
logs in /var/logs/messages and if I manually run with -d I don't see
the "Switching to user" log :/


Index: Makefile
===================================================================
RCS file: /home/cvs/ports/audio/umurmur/Makefile,v
retrieving revision 1.31
diff -u -p -r1.31 Makefile
--- Makefile 8 Nov 2022 11:14:44 -0000 1.31
+++ Makefile 28 Feb 2023 13:45:45 -0000
@@ -3,7 +3,7 @@ COMMENT = minimalistic Mumble server
GH_ACCOUNT = umurmur
GH_PROJECT = umurmur
GH_TAGNAME = 0.2.20
-REVISION = 0
+REVISION = 1

CATEGORIES = audio

Index: patches/patch-src_main_c
===================================================================
RCS file: patches/patch-src_main_c
diff -N patches/patch-src_main_c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ patches/patch-src_main_c 28 Feb 2023 13:57:55 -0000
@@ -0,0 +1,13 @@
+Index: src/main.c
+--- src/main.c.orig
++++ src/main.c
+@@ -149,6 +149,9 @@ static void switch_user(void)
+ Log_fatal("Unknown group '%s'", groupname);
+
+ gid = grp->gr_gid;
++
++ /* initgroups() will invalidate this pointer */
++ grp = NULL;
+ }
+
+ if (initgroups(pwd->pw_name, gid))

No comments:

Post a Comment