[prev in list] [next in list] [prev in thread] [next in thread]
List: freedesktop-dbus
Subject: How to fully install, configure and start D-Bus system in a child namespace?
From: Heng Zhou <hz19h () fsu ! edu>
Date: 2024-02-13 4:37:00
Message-ID: PH0P220MB05727F794CCBF9B07B5DC251994F2 () PH0P220MB0572 ! NAMP220 ! PROD ! OUTLOOK ! COM
[Download RAW message or body]
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.
[Attachment #3 (text/html)]
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} \
</style> </head>
<body dir="ltr">
<div class="elementToProof" style="font-family: Aptos, Aptos_EmbeddedFont, \
Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, \
0, 0);"> The environment is as follows:</div>
<div class="elementToProof" style="font-family: Aptos, Aptos_EmbeddedFont, \
Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, \
0, 0);"> <br>
</div>
<div class="elementToProof"><span style="font-family: Aptos, Aptos_EmbeddedFont, \
Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, \
0, 0);">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.</span></div> <div class="elementToProof"><span \
style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, \
Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);"><br> </span></div>
<div class="elementToProof"><span style="font-family: Aptos, Aptos_EmbeddedFont, \
Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, \
0, 0);">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:</span></div>
<div class="elementToProof"><span style="font-family: Aptos, Aptos_EmbeddedFont, \
Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, \
0, 0);"><br> </span></div>
<div class="elementToProof"><span style="font-family: Aptos, Aptos_EmbeddedFont, \
Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, \
0, 0);">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".</span></div> <div class="elementToProof"><span \
style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, \
Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);"><br> </span></div>
<div class="elementToProof"><span style="font-family: Aptos, Aptos_EmbeddedFont, \
Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, \
0, 0);">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.</span></div> <div class="elementToProof"><span style="font-family: Aptos, \
Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: \
12pt; color: rgb(0, 0, 0);"><br> </span></div>
<div class="elementToProof"><span style="font-family: Aptos, Aptos_EmbeddedFont, \
Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, \
0, 0);">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.</span></div> <div class="elementToProof"><span \
style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, \
Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);"><br> </span></div>
<div class="elementToProof"><span style="font-family: Aptos, Aptos_EmbeddedFont, \
Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, \
0, 0);">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".</span></div> <div class="elementToProof"><span style="font-family: \
Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; \
font-size: 12pt; color: rgb(0, 0, 0);"><br> </span></div>
<div class="elementToProof"><span style="font-family: Aptos, Aptos_EmbeddedFont, \
Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, \
0, 0);">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?</span></div> <div class="elementToProof"><span \
style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, \
Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);"><br> </span></div>
<div class="elementToProof"><span style="font-family: Aptos, Aptos_EmbeddedFont, \
Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, \
0, 0);">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:</span></div> <div \
class="elementToProof"><span style="font-family: Aptos, Aptos_EmbeddedFont, \
Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, \
0, 0);"><br> </span></div>
<div class="elementToProof"><span style="font-family: Aptos, Aptos_EmbeddedFont, \
Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, \
0, 0);">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?</span></div> <div class="elementToProof"><span \
style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, \
Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);"><br> </span></div>
<div class="elementToProof"><span style="font-family: Aptos, Aptos_EmbeddedFont, \
Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, \
0, 0);">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.</span></div> <div \
class="elementToProof"><span style="font-family: Aptos, Aptos_EmbeddedFont, \
Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, \
0, 0);"><br> </span></div>
<div class="elementToProof"><span style="font-family: Aptos, Aptos_EmbeddedFont, \
Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, \
0, 0);">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.</span></div> <div class="elementToProof"><br>
</div>
<div class="elementToProof"><span style="font-family: Aptos, Aptos_EmbeddedFont, \
Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, \
0, 0);"><br> </span></div>
<div class="elementToProof"><span style="font-family: Aptos, Aptos_EmbeddedFont, \
Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, \
0, 0);"><br> </span></div>
<div class="elementToProof"><span style="font-family: Aptos, Aptos_EmbeddedFont, \
Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, \
0, 0);"><br> </span></div>
<div class="elementToProof"><span style="font-family: Aptos, Aptos_EmbeddedFont, \
Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, \
0, 0);"><br> </span></div>
</body>
</html>
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic