[prev in list] [next in list] [prev in thread] [next in thread] 

List:       freedesktop-dbus
Subject:    Re: How to fully install, configure and start D-Bus system in a child namespace?
From:       Heng Zhou <hz19h () fsu ! edu>
Date:       2024-02-15 13:56:05
Message-ID: PH0P220MB0572033B600E714C87189B05994D2 () PH0P220MB0572 ! NAMP220 ! PROD ! OUTLOOK ! COM
[Download RAW message or body]

I have solved these problems myself. Thanks.
________________________________
From: Heng Zhou <hz19h@fsu.edu>
Sent: Monday, February 12, 2024 11:37 PM
To: dbus@lists.freedesktop.org <dbus@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.


[Attachment #3 (text/html)]

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<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);"> I have solved these&nbsp;problems myself. Thanks.</div>
<div id="appendonsend"></div>
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" \
style="font-size:11pt" color="#000000"><b>From:</b> Heng Zhou \
&lt;hz19h@fsu.edu&gt;<br> <b>Sent:</b> Monday, February 12, 2024 11:37 PM<br>
<b>To:</b> dbus@lists.freedesktop.org &lt;dbus@lists.freedesktop.org&gt;<br>
<b>Subject:</b> How to fully install, configure and start D-Bus system in a child \
namespace?</font> <div>&nbsp;</div>
</div>
<style type="text/css" style="display:none">
<!--
p
	{margin-top:0;
	margin-bottom:0}
-->
</style>
<div dir="ltr">
<div class="x_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="x_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="x_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="x_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="x_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&nbsp;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="x_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="x_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&nbsp;container  to run the operation related to \
namespace creation and entering. The command to start the Singularity container is \
&quot;singularity shell --fakeroot --userns --writable-tmpfs --bind /run/user/$(id \
-u)/ gnome.sif&quot;.</span></div> <div class="x_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="x_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: &quot;/usr/bin/daemonize /bin/unshare
 -Urfp --mount-proc bash -c 'exec /lib/systemd/systemd --unit=basic.target'&quot;. \
The systemd will be the init process (PID=1) of the new namespace. From the results \
returned from &quot;lsns|grep systemd&quot;, I can find out the PID of \
systemd.</span></div> <div class="x_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="x_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 &quot;nsenter \
--preserve-credentials --user --mount --pid -t $SYSTEMD_PID&quot; to enter  the new \
namespace. I can enter the child namespace, but problems start.</span></div> <div \
class="x_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="x_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 &quot;/etc/init.d/dbus \
start&quot; and &quot;service dbus status&quot; 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 &quot;Failed to connect to bus: No such \
file or directory&quot;.</span></div> <div class="x_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="x_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)&nbsp;is &quot;/run/user/1084/bus&quot; 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="x_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="x_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="x_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="x_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&quot;/run/user/1084/bus&quot; 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="x_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="x_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&nbsp;D-Bus system in such a scenario so that  I can run &quot;startx&quot; or \
TigerVNC/TurboVNC in the new namespace? Preferably it's just a few \
commands.</span></div> <div class="x_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="x_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&nbsp;appreciate  it if you can help me \
with these questions.</span></div> <div class="x_elementToProof"><br>
</div>
<div class="x_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="x_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="x_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="x_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>
</body>
</html>



[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic