siglo icon indicating copy to clipboard operation
siglo copied to clipboard

Subprocess and systemctl issues in Flatpak

Open Torbuntu opened this issue 3 years ago • 6 comments

Version: 0.9.0 Install: Flathub's flatpak OS: Fedora Mobile Remix

When selecting a device in siglo and the Keep paired toggle is active, Siglo throws an errors in the console:

Traceback (most recent call last):
  File "/app/share/siglo/siglo/window.py", line 209, in on_watches_listbox_row_activated
    subprocess.Popen(["systemctl", "--user", "start", "siglo"])
  File "/usr/lib/python3.8/subprocess.py", line 858, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "/usr/lib/python3.8/subprocess.py", line 1706, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'systemctl'

I'm thinking that this means flatpak can't make calls directly to systemcl.

I did quickly find this article: https://gabmus.org/posts/making-a-dbus-daemon/ which lays out how to setup a daemon in a flatpak using python. Hopefully something in there can be of use?

Let me know if I can help collect any other information.

Torbuntu avatar Sep 02 '21 00:09 Torbuntu

@jwillikers i just want to run systemctl in a subprocess. is this a quick fix to get it working on flatpak?

theironrobin avatar Sep 02 '21 00:09 theironrobin

@alexr4535 Not without subverting the sandbox by allowing arbitrary code execution on the host. There's an existing Flatpak issue, flatpak/flatpak#2787, regarding this kind of thing, but a solution for Systemd isn't available yet. I know GTK/GNOME exposes functions for running in the background, which should integrate nicely with Flatpak, like this comment mentions. I think there's way that GTK Flatpaks like GNOME Boxes, Geary, and NewsFlash accomplish this which integrates with the Background portal. I can look more into this when I get time.

jwillikers avatar Sep 02 '21 12:09 jwillikers

Thanks, I've added a warning to the readme that SMS notifications are broken currently in the flatpak version

theironrobin avatar Sep 02 '21 13:09 theironrobin

The graphical apps that I mentioned seem to run in the background by hiding their main window when it is closed instead of exiting the application. This combined with the background portal should be enough run continually in the background, granted this doesn't provide service management in case of a crash. A Systemd user unit could be provided to users to manually install / enable for running the Flatpak'd Siglo app as a Systemd service until this is possible in Flatpak itself.

jwillikers avatar Sep 03 '21 17:09 jwillikers

When selecting a device in siglo and the Keep paired toggle is active,

Thanks for mentioning this, I was at a dead end and hadn't realised that turning the toggle off fixed it.

WhyNotHugo avatar Nov 13 '21 16:11 WhyNotHugo

Siglo tries to run systemctl, but that's not installed its package/image. There's two potential fixes for this:

  • Check if systemctl is executable, and hide the button if it isn't. This'll hide it in the flatpak for now, or any other isolation where that binary is not present.
  • Use systemd's D-Bus API. This won't work with flatpak (due to https://github.com/flatpak/flatpak/issues/2787), but will work on firejail.

WhyNotHugo avatar Dec 13 '21 21:12 WhyNotHugo