-
Notifications
You must be signed in to change notification settings - Fork 249
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
"User services" in OpenRC #432
Comments
Better solution While I agree, user services is something I am looking for, I have some notes: What I've done on my machine is to create a runtime for my user, and add all the services i want for my user into it (+default), and manually setting Then the only command I need to run is Suggestion The way I can see this working is if users had their own runtime (not completely sure about the path or naming conventions here, although Then, in scripts, we'd need to have access to the |
This still poses a security risk as you could omit
The idea of runlevels for users is not a bad one, though the best thing would be to prefix it in some way:
Correction, the variables to be exposed would be at least |
I haven't looked into the security concerns regarding OpenRC. I am a single-user on my desktop, so it hasn't been a concern for me. It would be better to run
I like it, I changed it on my system.
I just named it Maybe setting a list of environment variables to be inherited would be okay. Having XDG_* by default would sure be nice. Being able to You don't have |
I have posted a "working" example for how I update my CloudFlare DNS records on my scripts repository as a user. It seems to work well, except for the fact that I still need to use root to change runtimes. I have also tried to boot up my window manager through it, but I am struggling with running dbus manually, without I can't find a clean and proper way to pass around variables from a single node, down to the rest of the environment, though. It would be nice if it were possible to export the entire environment at once. |
@mazunki I just had some time to check your scripts folder, and unless I am mistaken you are not really solving the main issue: OpenRC is still running those services as system services and you still need root to manage them. Sadly I didn't come up with a better or more dynamic idea as of yet (also I think there'd be another problem -- how can we tell the exact moment when users log in and out to start and stop their services?) and I also resorted to system services with Hope this issue gets some traction. |
You are entirely correct. My "solution" involves initial escalation, although this is only a concern on multiuser scenarios. For my home usage I don't really mind, since I'm not giving pipewire, for instance, any escalation, meaning there's no threat of the apps posing a security risk. The only threat is me abusing OpenRC to take over my own computer. It's a compromise since there's no better solution yet. Also, not only that, I also need to hardcode a configuration file + init script for each user, with the appropriate |
Replying to myself: OpenRC's PAM integration. a PAM module can be indeed used to know when an user logs in and out of the system. By the way, for now Dinit in userspace works just fine on my Artix install, until user mode OpenRC gets some more attention. |
Yeah, this looks really interesting. For others, see https://github.com/chimera-linux/dinit-userservd too. |
For what it worths, i use this initscript:
Then, administrator usually only have to cd /etc/init.d; ln -s userd userd.username, add it to wanted runlevel, and this uid will have ~/.userd/start and shutdown called appropriately (those can be used to daisy chain a specific init-style program, like svscan) |
This is an issue for me, I have a service for syncthing, but it has to run as root (it literally gives you a warning for doing this, as it could be problematic) because openrc doesn't support a user runlevel.. pretty big issue imo. |
I launch dinit through emptty. Emptty closes dinit automatically when a login session is closed. ~/.config/emptty
When a login session starts, sway executes this command to make dinit aware of GUI environment it is in.
~/.config/dinit.d can contain user services. |
There's two distinct (but very similar) ideas being discussed here:
For the second approach, OpenRC would need to essential do something like:
And a few similar changes for the other paths. I did something rather similar to OpenBSD's rc about a decade ago and the result was a bit of a hack but worked. Being able to manage user services like this would be very convenient to manage services like pulseaudio, pipewire, xdg-portals, offlineimap, etc. |
Maybe, we should dinit instead of OpenRC for user services? |
Adding our support here for use-cases like rootless containerd (and friends). You can currently get them into a service by using |
I am in favour of this solution if it can be implemented good. Some extra thoughts
|
#723 was merged. |
It would be nice if users could have and handle their own services and runlevels.
Nowadays a lot of applications rely on services run as the current user (for example sound servers like PipeWire and PulseAudio are required to run multiple applications that play audio in a tradiitonal desktop configuration).
For comparison, Systemd provides users with a mechanism to have their services (units) run and supervised upon login. This is, in turn, used by many desktop environments and also daemons (PulseAudio, PipeWire, etc.)
Some other init systems, like Runit, have no concept of user services, but they can be easily "tricked" to effectively handle them (Example).
OpenRC does not have any concept of user services and it doesn't seem to be easily adaptable to handle them in a tricky way; the best an user can do is effectively modify some system services so that they are run under their user and group and then they can write a bunch of
sudo rc-service <service> start
lines on their.profile
so that the services actually get started and supervised. This works but it is tricky and it requires the user to set aNOPASSWD
rule forrc-service
on their sudoers file, which makes for a security problem.Hence, it is probably wiser to let OpenRC have a concept of user services, in a way or another; the proposed solution would be:
user_service
(0 or 1, false or true) variable; and that variable, in turn, would conflict with thecommand_user
one;~/.config/init.d/
, where there can be user services only;/run/user/<uid>/openrc
that would more or less be of the same function and scope as the current/run/openrc
directory;rc-service
andrc-update
understand if they are being run as root or as user, to check whether there is a 'user' instance of OpenRC running, and to handle that one instead if they are indeed run as user.I know this may be sloppy as a proposed solution, but I hope to find more people willing to discuss this further.
The text was updated successfully, but these errors were encountered: