How to fully install, configure and start D-Bus system in a child namespace?

Heng Zhou hz19h at fsu.edu
Thu Feb 15 13:56:05 UTC 2024


I have solved these problems myself. Thanks.
________________________________
From: Heng Zhou <hz19h at fsu.edu>
Sent: Monday, February 12, 2024 11:37 PM
To: dbus at lists.freedesktop.org <dbus at lists.freedesktop.org>
Subject: How to fully install, configure and start D-Bus system in a child namespace?

The environment is as follows:

First, I am in a Singularity container containing Ubuntu 22.04. Because Singularity container does not boot normally like a normal Ubuntu, the Ubuntu guest is not initialized by systemd.

In the container, I first created a new namespace in hope that I can have a systemd-initialized environment, then I will enter this new namespace to run some software like GNOME that requires a fully functioning Ubuntu. But I encountered many problems during the course, one of which is D-Bus system not working. So, I hope you could please lend me a hand. Details are as follows:

For the Singularity container, I set up fakeroot so that I have root privilege inside the container to run the operation related to namespace creation and entering. The command to start the Singularity container is "singularity shell --fakeroot --userns --writable-tmpfs --bind /run/user/$(id -u)/ gnome.sif".

In the container, I use this command to create a namespace: "/usr/bin/daemonize /bin/unshare -Urfp --mount-proc bash -c 'exec /lib/systemd/systemd --unit=basic.target'". The systemd will be the init process (PID=1) of the new namespace. From the results returned from "lsns|grep systemd", I can find out the PID of systemd.

Next I use command "nsenter --preserve-credentials --user --mount --pid -t $SYSTEMD_PID" to enter the new namespace. I can enter the child namespace, but problems start.

Problem 1), I can run "/etc/init.d/dbus start" and "service dbus status" to start and query D-Bus system in the Singularity container (the parent namespace). But when I run these commands in the new child namespace, I got error message "Failed to connect to bus: No such file or directory".

Problem 2), I'm guessing the file in Problem 1) is "/run/user/1084/bus" where 1084 is my UID on host (outside container). This directory is bound into the container, but not available in the new namespace. I don't understand why. Do you know how to bind this DBUS_SESSION_BUS_ADDRESS directory into the new child namespace?

So, because of Problem 2), D-Bus system is not available in the new namespace. X server depends on D-Bus system, so GNOME on Xorg does not work, and in turn higher-level software like VNC server does not work. As a result, can you please help me with the following two questions:

Question 1): How to bind the"/run/user/1084/bus" directory indicated by DBUS_SESSION_BUS_ADDRESS environment variable into the new namespace, if I don't have to manually create it?

Question 2): How to fully install, configure, and start D-Bus system in such a scenario so that I can run "startx" or TigerVNC/TurboVNC in the new namespace? Preferably it's just a few commands.

The above workflow works in WSL, so I hope to port it to Singularity container. I will greatly appreciate it if you can help me with these questions.





-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/dbus/attachments/20240215/42bf3cf1/attachment.htm>


More information about the dbus mailing list