<div dir="ltr">Would really like to see the contents of the .service file. Does it use any hardening options at all?<br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Jul 18, 2024 at 10:49 AM Thomas Köller <<a href="mailto:thomas@koeller.dyndns.org">thomas@koeller.dyndns.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi,<br>
<br>
I have a problem creating a namespace from a systemd service. The <br>
service (type oneshot) invokes a shell script containing these two lines:<br>
<br>
ip netns add vpnlink<br>
iw phy phy0 set netns name vpnlink<br>
<br>
Both commands succeed, meaning they do not return an error, and so the <br>
service start is successful. However, the newly created network <br>
namespace is apparently unusable. Invoking the script from a root shell <br>
outside of the systemd service successfully creates the namespace. The <br>
log below illustrates the problem:<br>
<br>
root@htpc:~/netsu# ip netns list<br>
root@htpc:~/netsu# ./netsu<br>
root@htpc:~/netsu# ip netns list<br>
vpnlink (id: 0)<br>
root@htpc:~/netsu# ip netns exec vpnlink ip link show<br>
1: lo: <LOOPBACK> mtu 65536 qdisc noop state DOWN mode DEFAULT group <br>
default qlen 1000<br>
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00<br>
4: wlan_usb: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN mode <br>
DEFAULT group default qlen 1000<br>
link/ether 00:0f:60:06:7f:3b brd ff:ff:ff:ff:ff:ff<br>
root@htpc:~/netsu# ip netns del vpnlink<br>
root@htpc:~/netsu# ip netns list<br>
root@htpc:~/netsu# systemctl restart network-setup.service<br>
root@htpc:~/netsu# systemctl status network-setup.service<br>
● network-setup.service<br>
Loaded: loaded (/etc/systemd/system/network-setup.service; <br>
enabled; preset: disabled)<br>
Drop-In: /usr/lib/systemd/system/service.d<br>
└─10-timeout-abort.conf<br>
Active: active (exited) since Thu 2024-07-18 09:34:55 CEST; 14s ago<br>
Process: 3320 ExecStart=/root/netsu/netsu (code=exited, <br>
status=0/SUCCESS)<br>
Main PID: 3320 (code=exited, status=0/SUCCESS)<br>
CPU: 29ms<br>
<br>
Jul 18 09:34:55 htpc systemd[1]: Starting network-setup.service...<br>
Jul 18 09:34:55 htpc systemd[1]: Finished network-setup.service.<br>
root@htpc:~/netsu# ip netns list<br>
Error: Peer netns reference is invalid.<br>
Error: Peer netns reference is invalid.<br>
vpnlink<br>
root@htpc:~/netsu# ip netns exec vpnlink ip link show<br>
setting the network namespace "vpnlink" failed: Invalid argument<br>
root@htpc:~/netsu# ip netns del vpnlink<br>
<br>
Am I missing something? Of course, the process running the root shell <br>
invoked from the command line is ultimately also a child of systemd, <br>
which is the system's init process.<br>
</blockquote></div><br clear="all"><br><span class="gmail_signature_prefix">-- </span><br><div dir="ltr" class="gmail_signature"><div dir="ltr">Mantas Mikulėnas</div></div>