Skip to content

"User services" in OpenRC #432

@NyaomiDEV

Description

@NyaomiDEV

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 a NOPASSWD rule for rc-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:

  • to write the init scripts in exactly the same way except that they will need to be declared as user services somewhere in the scripts themselves, maybe with a user_service (0 or 1, false or true) variable; and that variable, in turn, would conflict with the command_user one;
  • to have a separate folder to load init scripts from, namely ~/.config/init.d/, where there can be user services only;
  • to have a separate directory to effectively handle the OpenRC inner workings, like /run/user/<uid>/openrc that would more or less be of the same function and scope as the current /run/openrc directory;
  • to have commands like rc-service and rc-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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions