[GH-ISSUE #5693] netbird-ui should be launched as a systemd --user unit on systemd systems, restarted on updates #10933

Open
opened 2026-08-05 01:27:45 -04:00 by saavagebueno · 0 comments
Owner

Originally created by @jbillingredhat on GitHub (Mar 25, 2026).
Original GitHub issue: https://github.com/netbirdio/netbird/issues/5693

The netbird-ui process running as a user process currently gets restarted by a RPM %post script that most likely won't even work on RPM-based systems like Fedora or RHEL. The end-user experience is when the netbird-ui package gets updated, their icon in their menu just disappears.

Describe the solution you'd like
Rather than have the RPM try to launch or restart the netbird-ui process, the package should include a systemd --user unit that starts the netbird-ui process in the user's session. It should look something like this:

$ cat /usr/lib/systemd/user/netbirdui.service 
[Unit]
Description=Netbird UI

[Service]
Type=simple
ExecStart=/usr/bin/netbird-ui

[Install]
WantedBy=graphical-session.target

Then, the netbird-ui executable could simply have a toggle to "always start this" by just running: systemctl --user enable netbirdui.service and it will be launched on login. Restarting the service can be done from root on RPM-based distros by running /usr/lib/systemd/systemd-update-helper mark-restart-user-units netbirdui.service. I'm sure debian-based distros (that use systemd) have an equivalent.

Then, in your RPM post script for netbird-ui, you can just have something like this:

postinstall scriptlet (using /bin/sh):

if [ $1 -eq 1 ] && [ -x "/usr/lib/systemd/systemd-update-helper" ]; then 
    # Initial installation 
    /usr/lib/systemd/systemd-update-helper install-user-units netbirdui.service || : 
fi

preuninstall scriptlet (using /bin/sh):

if [ $1 -eq 0 ] && [ -x "/usr/lib/systemd/systemd-update-helper" ]; then 
   # Package removal, not upgrade 
   /usr/lib/systemd/systemd-update-helper remove-user-units netbirdui.service || : 
fi

postuninstall scriptlet (using /bin/sh):

if [ $1 -ge 1 ] && [ -x "/usr/lib/systemd/systemd-update-helper" ]; then 
    # Package upgrade, not uninstall 
    /usr/lib/systemd/systemd-update-helper mark-restart-user-units netbirdui.service || : 
fi 

if [ $1 -ge 1 ] && [ -x "/usr/lib/systemd/systemd-update-helper" ]; then 
    # Package upgrade, not uninstall 
    /usr/lib/systemd/systemd-update-helper mark-reload-user-units netbirdui.service || : 
fi

In a netbird.spec file used to create the package on Fedora/RHEL, you'd be able to do this pretty simply using the systemd macros:

%post ui
%systemd_user_post netbirdui.service

%preun ui
%systemd_user_preun netbirdui.service

%postun ui
%systemd_user_postun_with_restart netbirdui.service
%systemd_user_postun_with_reload netbirdui.service
%systemd_user_postun netbirdui.service

If you'd rather do it directly, you can take a look at the upstream source for the systemd-update-helper in the systemd source.

Describe alternatives you've considered
If you do not want to use systemd user units for running the netbird-ui process, then I think the attempts to restart the process should be removed from the packages. Having the user running updates (root) try to su to any user and execute the process will leave it running in the context of the root user, and will result in it having the wrong selinux context, and won't inherit any environment from the user's session. Kill it if you prefer, but definitely remove any attempt for the root user to impersonate the user.

Additional context
I'm building my own netbird packages for Fedora that do the above and it works quite well.

Originally created by @jbillingredhat on GitHub (Mar 25, 2026). Original GitHub issue: https://github.com/netbirdio/netbird/issues/5693 The `netbird-ui` process running as a user process currently gets [restarted by a RPM %post script](https://github.com/netbirdio/netbird/blob/main/release_files/ui-post-install.sh) that most likely won't even work on RPM-based systems like Fedora or RHEL. The end-user experience is when the netbird-ui package gets updated, their icon in their menu just disappears. **Describe the solution you'd like** Rather than have the RPM try to launch or restart the netbird-ui process, the package should include a systemd --user unit that starts the netbird-ui process in the user's session. It should look something like this: ``` $ cat /usr/lib/systemd/user/netbirdui.service [Unit] Description=Netbird UI [Service] Type=simple ExecStart=/usr/bin/netbird-ui [Install] WantedBy=graphical-session.target ``` Then, the netbird-ui executable could simply have a toggle to "always start this" by just running: `systemctl --user enable netbirdui.service` and it will be launched on login. Restarting the service can be done from root on RPM-based distros by running ` /usr/lib/systemd/systemd-update-helper mark-restart-user-units netbirdui.service`. I'm sure debian-based distros (that use systemd) have an equivalent. Then, in your RPM post script for netbird-ui, you can just have something like this: postinstall scriptlet (using /bin/sh): ``` if [ $1 -eq 1 ] && [ -x "/usr/lib/systemd/systemd-update-helper" ]; then # Initial installation /usr/lib/systemd/systemd-update-helper install-user-units netbirdui.service || : fi ``` preuninstall scriptlet (using /bin/sh): ``` if [ $1 -eq 0 ] && [ -x "/usr/lib/systemd/systemd-update-helper" ]; then # Package removal, not upgrade /usr/lib/systemd/systemd-update-helper remove-user-units netbirdui.service || : fi ``` postuninstall scriptlet (using /bin/sh): ``` if [ $1 -ge 1 ] && [ -x "/usr/lib/systemd/systemd-update-helper" ]; then # Package upgrade, not uninstall /usr/lib/systemd/systemd-update-helper mark-restart-user-units netbirdui.service || : fi if [ $1 -ge 1 ] && [ -x "/usr/lib/systemd/systemd-update-helper" ]; then # Package upgrade, not uninstall /usr/lib/systemd/systemd-update-helper mark-reload-user-units netbirdui.service || : fi ``` In a netbird.spec file used to create the package on Fedora/RHEL, you'd be able to do this pretty simply using the systemd macros: ``` %post ui %systemd_user_post netbirdui.service %preun ui %systemd_user_preun netbirdui.service %postun ui %systemd_user_postun_with_restart netbirdui.service %systemd_user_postun_with_reload netbirdui.service %systemd_user_postun netbirdui.service ``` If you'd rather do it directly, you can take a look at the [upstream source for the systemd-update-helper in the systemd source](https://github.com/systemd/systemd/blob/main/src/rpm/systemd-update-helper.in). **Describe alternatives you've considered** If you do not want to use systemd user units for running the netbird-ui process, then I think the attempts to restart the process should be removed from the packages. Having the user running updates (root) try to su to any user and execute the process will leave it running in the context of the root user, and will result in it having the wrong selinux context, and won't inherit any environment from the user's session. Kill it if you prefer, but definitely remove any attempt for the root user to impersonate the user. **Additional context** I'm building my own netbird packages for Fedora that do the above and it works quite well.
saavagebueno added the feature-request label 2026-08-05 01:27:45 -04:00
Sign in to join this conversation.
No Label feature-request
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: DYNR/netbird#10933