OpenVoiceOS / ovos-PHAL-plugin-system

Apache License 2.0
0 stars 2 forks source link

Not able to restart services handles by regular a user #27

Closed goldyfruit closed 2 months ago

goldyfruit commented 3 months ago

Because this plugin is running as root, it can't restart services handled by regular user such as ovos.service.

Jul 09 07:58:16 mark2 ovos_PHAL_admin[7621]: 2024-07-09 07:58:16.944 - PHAL_admin - ovos_bus_client.apis.gui:_pages2uri:376 - DEBUG - Resolved pages: ['file:///home/goldyfruit/.venvs/ovos/lib/python3.11/site-packages/ovos_PHAL_plugin_system/ui/Restart.qml']
Jul 09 07:58:16 mark2 ovos_PHAL_admin[7621]: 2024-07-09 07:58:16.950 - PHAL_admin - ovos_bus_client.apis.gui:_normalize_page_name:387 - WARNING - Deprecation version=0.1.0. Caller=ovos_PHAL_plugin_system:303. GUI resources should specify a resource name and not a file path.
Jul 09 07:58:16 mark2 ovos_PHAL_admin[7621]: 2024-07-09 07:58:16.954 - PHAL_admin - ovos_bus_client.apis.gui:show_pages:448 - DEBUG - Updating gui data: {'__from': 'ovos-PHAL-plugin-system'}
Jul 09 07:58:17 mark2 systemctl[8544]: Failed to connect to bus: No medium found

root user doesn't have access to user's socket because DBUS_SESSION_BUS_ADDRESS path will be different which prevents it to restart services.

Using restrart_service from ovos_utils when using a simple user works fine as describe here https://github.com/OpenVoiceOS/ovos-utils/issues/259#issuecomment-2217443157

builderjer commented 3 months ago

The docs say to run the ovos-admin-phal.service as a user

https://openvoiceos.github.io/ovos-technical-manual/PHAL/#admin-phal

With that, everything works as expected when running as a user, no config provided, and as an admin plugin, enabled in mycroft.conf

I am not sure why the docs say this, because I don't see how it would run as root then.

Also, is there a real reason to run this as root? Could a section in the docs be added on how to setup polkit for this?

goldyfruit commented 2 months ago

The documentation says to run this service as root user.

builderjer commented 2 months ago

to use AdminPHAL create a launcher /usr/libexec/mycroft-systemd-admin-phal

Says a user service. Maybe this is wrong