Summary: | net-irc/unrealircd-6.0.4.2 startup issues (with openrc) | ||
---|---|---|---|
Product: | Gentoo Linux | Reporter: | dullfire |
Component: | Current packages | Assignee: | Sam James <sam> |
Status: | UNCONFIRMED --- | ||
Severity: | normal | CC: | bss, sam |
Priority: | Normal | Keywords: | PATCH |
Version: | unspecified | ||
Hardware: | All | ||
OS: | Linux | ||
See Also: | https://bugs.gentoo.org/show_bug.cgi?id=905139 | ||
Whiteboard: | |||
Package list: | Runtime testing required: | --- | |
Attachments: |
new conf.d file for new pid location
new init.d file for new pidfile location and working checkconfig modified unrealircd-6.0.4.2.ebuild to utilize new pidfile and openrc files |
Description
dullfire
2023-01-10 12:48:22 UTC
(In reply to dullfire from comment #0) > Furthermore, the package is compiled with > '--with-controlfile="${EPREFIX}"/run/${PN}/unrealircd.ctl', however the > openrc startup scripts ensure that "${EPREFIX}"/run/${PN}" is only writable > by root (security measure since pidfile is also in that dir). Thus > unrealircd dies when it fails to create it's socket. I encountered this same problem. I found that removing start_pre() entirely fixed startup --- it seems that /run/unrealircd/ is created 755 unrealircd:unrealircd via unrealircd.tmpfiles (good) and openrc nevertheless creates /run/unrealircd/ircd.pid as root:root (also good). So it just works? This also appeared necessary as `checkconfig` calls `unrealircd configtest` and that apparently starts the listeners, so running checkconfig in start_pre() would actually start the server, and then the actual startup would fail because it couldn't bind to the port(s). I think I saw this behavior in 5.x's init script too, I just never looked into it until now. I'm working on a new ebuild to solve this; if it proves stable I'll share it here. I forgot to add that the configtest behavior is possibly an upstream bug, but I'm not confident of that just yet. Thanks Brian. If you could, let me know either way. I'm preoccupied with some other bits at the moment so much appreciated even just with the comment you've left. Sorry for not getting to it yet. (In reply to Brian S. Stephan from comment #1) > (In reply to dullfire from comment #0) > > Furthermore, the package is compiled with > > '--with-controlfile="${EPREFIX}"/run/${PN}/unrealircd.ctl', however the > > openrc startup scripts ensure that "${EPREFIX}"/run/${PN}" is only writable > > by root (security measure since pidfile is also in that dir). Thus > > unrealircd dies when it fails to create it's socket. > > I encountered this same problem. I found that removing start_pre() entirely > fixed startup --- it seems that /run/unrealircd/ is created 755 > unrealircd:unrealircd via unrealircd.tmpfiles (good) and openrc nevertheless > creates /run/unrealircd/ircd.pid as root:root (also good). So it just works? Isn't that behavior a violating of the security design? In this case non-root (namely unrealircd) can rm /run/unrealircd/ircd.pid (since it has write access to /run/unrealircd) and replace it with it's own. IMHO: in order to preserve the security features, the socket needs to be in a different directory. > > This also appeared necessary as `checkconfig` calls `unrealircd configtest` > and that apparently starts the listeners, so running checkconfig in > start_pre() would actually start the server, and then the actual startup > would fail because it couldn't bind to the port(s). I think I saw this > behavior in 5.x's init script too, I just never looked into it until now. > > I'm working on a new ebuild to solve this; if it proves stable I'll share it > here. I have worked around these issues by having the socket live in a different directory (for reasons explained above), and the checkconfig skip the test for SVCAME != unrealirc. I will also note: the design of the control socket seems to preclude multiple unrealircd servers in the same mount namespace. This is due to fact that the path is configure-time selectable, and the actual file name is hard coded I believe. I haven't really tested this out though. (In reply to dullfire from comment #4) > (In reply to Brian S. Stephan from comment #1) > > I encountered this same problem. I found that removing start_pre() entirely > > fixed startup --- it seems that /run/unrealircd/ is created 755 > > unrealircd:unrealircd via unrealircd.tmpfiles (good) and openrc nevertheless > > creates /run/unrealircd/ircd.pid as root:root (also good). So it just works? > > Isn't that behavior a violating of the security design? In this case > non-root (namely unrealircd) can rm /run/unrealircd/ircd.pid (since it has > write access to /run/unrealircd) and replace it with it's own. IMHO: in > order to preserve the security features, the socket needs to be in a > different directory. I hadn't thought about that but you are right; I think a drwxrwxr-t root:unrealircd /run/unrealircd/ would also work, though maybe your way is clearer. What's an idiomatic alternative location for the named socket? That's what was holding me up when I was hacking at my ebuild last night. I've found the issue with checkconfig's config test --- it looks like they moved the configtest argument to a wrapper script which the ebuild doesn't install + the su invocation is dropping the argument (which is old anyway). Looking at the wrapper script, this is the new config check: [ ${SVCNAME} = unrealircd ] && su -s /bin/sh ${command_user:=root} -c "${command} ${command_args%${UNREALIRCD_COMMAND_ARGS}} -c" With that resolved I have something that starts clean, pidfile vs. socket location aside for now. I also bumped my ebuild to 6.0.7 (which removes the need for the clang patch) and added a IUSE + RDEPEND to get geoip_classic built since that's the default. This is perhaps becoming something beyond this issue, but Sam, let me know how you'd like to see my changes (once we come up with something on pidfile vs. socket). Created attachment 859900 [details]
new conf.d file for new pid location
Created attachment 859901 [details]
new init.d file for new pidfile location and working checkconfig
Created attachment 859902 [details, diff]
modified unrealircd-6.0.4.2.ebuild to utilize new pidfile and openrc files
I've attached what is working for me; I believe it satisfies the security concerns in a clean manner by putting the pidfile directly in /run, as is done by other services. |