Hi Andrew,
On Fri, 14 Aug 2026 17:46:42 +0200 Andrew Bower <[email protected]> wrote:
>
> I'm not a big fan of the code dupliction there, I'd rather an RETC
> variable were used to define the config directory, so the output could
> be defined only once, and/or a helper function like is_verbose()
> although also without duplicate user-service detection logic.
I agree that invoke-run could benefit from being polished and
rationalized, but I'll do that in a later stage: first I want to finish
missing/wip features (cgroups, user services, maybe socket activation),
then I'll consider invoke-run finished and I'll start working on
refining code
>
> I also just noticed this:
>
> if [ "$(id -u)" -ge 1000 ] && [ -d /home/"$(id -u -n)" ] ; then
>
> I don't think that's a sound way of detecting invocation for
> non-system service. To understand if the user is a system user
> requires parsing /etc/login.defs, UID_MIN may not be 1000. Is it
> enough to detect != 0?
In principle, yes, but practically this looks a slippery-slope that
may end in a can of worms:
* systemd-sysusers ignore SYS_UID_MIN/MAX (last time I checked, it used
'r' lines in sysusers.conf files)
* adduser can be forced to create a human user with a UID < UID_MIN
* UID_MIN/SYS_UID_MIN/MAX can be changed after the system is installed,
new limits are effective only for packages installed later
* redefining non-system services in runit requires changes in several
places (at least cpsv, update-service, trigger_sv,
runit-user-session)
we don't want to start a user session for a system user, I think;
apparently systemd uses uid >= 1000 but it starts a user session also
for root, but I don't think it starts one for system users (not sure
about this).
I think runit's current uid >=1000 is a semplification but a reasonable
one and I'm not sure it's feasible to change it.
> Secondly, the home directory could be anywhere.
I'm open to not hardcode home to /home/username in future, but I
see this as an enhancement, first let me complete the support for
user session with uid>=1000 and home=/home/username
Right now I'm going to quickly fix the issue reported and take note of
the rest for future development
Best,
Lorenzo
>
> How about something like this?
>
> RETC=/etc/runit
> IFS=: read -r RUSER pw uid gid gecos home shell <<EOF
> $(getent passwd "$(id -u)" 2>/dev/null)
> EOF
>
> if [ "${uid:-0}" -ne 0 ] && [ -d "$home" ]; then
> RETC="$home"/.runit
> else
> unset RUSER
> fi
> unset pw uid gid gecos home shell
>
> I think a various error cases get indirect detection here, so we can
> keep it readable.
>
> Then read "$RETC/verbose" to test verbosity. There may be other things
> that could benefit from this snippet.
>
>