Skip to content

Comments

Use a separate D-Bus server#384

Merged
imobachgs merged 26 commits intomasterfrom
use-own-bus
Jan 11, 2023
Merged

Use a separate D-Bus server#384
imobachgs merged 26 commits intomasterfrom
use-own-bus

Conversation

@imobachgs
Copy link
Contributor

@imobachgs imobachgs commented Dec 30, 2022

Problem

D-Installer uses the D-Bus "system" service. When running as a container, the backend container shares its "system" bus, so the web UI can access the services.

However, this approach does not work with Iguana. In that scenario, the web UI needs to access the D-Installer system bus (which is shared as it was the "system" D-Bus) and the host system bus (which cannot be accessed at this point) at the same time.

Our first attempt was to attach D-Installer to the host D-Bus server, but that's not possible because we need to change the server's configuration (to set the permissions).

Solution

This PR changes D-Installer to use its own D-Bus server. It has two main advantages:

  • We do not need to change the system D-Bus configuration anymore.
  • We can use our own D-Bus server for internal communication and use the system service to access components like NetworkManager.

We have not tested this approach in Iguana yet.

Testing

  • Added a new unit test
  • Tested manually
  • Tested with Iguana (see this comment)

To do

  • (optional) Allow setting the D-Bus server using an environment variable and/or the configuration file
  • Improve the process handling through bin/d-installer
  • Make the address discoverable to avoid using a hardcoded value in the web UI
  • Extend the documentation describing the approach

@coveralls
Copy link

coveralls commented Dec 30, 2022

Coverage Status

Coverage: 76.337% (+0.1%) from 76.218% when pulling 144c60c on use-own-bus into 8a94c2c on master.

@imobachgs imobachgs self-assigned this Jan 2, 2023
@imobachgs imobachgs added the enhancement New feature or request label Jan 2, 2023

<standard_session_servicedirs />

<policy context="default">
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes the policy wide open, overriding the root restrictions below.

I think it is wrong: for a regular session bus it works out because the socket used is /run/user/$UID/bus, in a user-specific tmpdir, and the access rights of the directory are 0700, locking other users out.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I see. So I guess we should drop this whole section, right?

Copy link
Contributor Author

@imobachgs imobachgs Jan 3, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have updated the file and I wonder whether it makes sense to put it under /usr/share/dbus-1/. We can read that configuration just from the gem path. WDYT?

PS: if we still decide to keep the file under /usr/share/dbus-1, we should at least move it out of the system.d folder.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have moved that file to /usr/share/dbus-1/d-installer and the services to /usr/share/dbus-1/d-installer-services. I found out that other packages are doing the same:

/usr/share/dbus-1/accessibility-services
/usr/share/dbus-1/system-services

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@imobachgs
Copy link
Contributor Author

imobachgs commented Jan 3, 2023

I tried this PR and it works: I could interact with NetworkManager from D-Installer's UI. The list of Iguana volumes looks like this:

volumes:
    - dbus_run:/run/d-installer
    - /var/run/dbus/system_bus_socket:/var/run/dbus/system_bus_socket

However, I found a different problem with the storage layer. In my setup (I do not know whether it might be a problem in other Iguana-based scenarios), D-Installer cannot probe one of the file systems (I think it corresponds to the ramdisk it is a disk corresponding to an old installation):

Minor issues were detected:
* Probing file system with UUID 794acf8c-0b66-4931-8804-9dcd6ace0160 failed

Given that the YastProbe callbacks are not implemented, the storage probing fails. See https://github.com/yast/yast-storage-ng/blob/3d1cadddfa8072ad1f074f3f52774812097fe75d/src/lib/y2storage/callbacks/yast_probe.rb#L46-L51.

PS: I used a PXE-based approach so I will write a small "howto" (in a different PR).

@imobachgs
Copy link
Contributor Author

However, I found a different problem with the storage layer. In my setup (I do not know whether it might be a problem in other Iguana-based scenarios), D-Installer cannot probe one of the file systems (I think it corresponds to the ramdisk it is a disk corresponding to an old installation):

Trying to mount the /dev/sda2 (a Btrfs file system) results in the following message (from the container or the host):

mount: /mnt: /dev/sda2 already mounted or mount point busy.

However, mounting the DVD (/dev/sr0) works just fine.

@imobachgs imobachgs changed the title [WIP] Use a separate D-Bus server Use a separate D-Bus server Jan 10, 2023
@imobachgs imobachgs marked this pull request as ready for review January 10, 2023 12:16
pid = find_server
return unless pid

Process.kill("KILL", pid.to_i)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NP: note that usually preferred way for killing is something like SIGTERM wait 5 seconds and then SIGKILL if it does not help. Here you do not allow process to finish anything.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. Let's postpone this change a bit, anyway.

import cockpit from "../lib/cockpit";

const MANAGER_SERVICE = "org.opensuse.DInstaller.Manager";
const MANAGER_SERVICE = "org.opensuse.DInstaller";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm, now I am curious why previously it works when service const was wrong?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jreidinger
Copy link
Contributor

In general change looks good, just please document exception at #384 (comment)

@imobachgs imobachgs merged commit 4de1d34 into master Jan 11, 2023
@imobachgs imobachgs deleted the use-own-bus branch January 11, 2023 10:16
@imobachgs imobachgs mentioned this pull request Feb 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants