How to use the systemd directive "RestrictAddressFamilies" with "podman run"? #14311
-
Could the systemd directive RestrictAddressFamilies be used to lock down When I try RestrictAddressFamilies=AF_UNIX, Socket-activated sockets are excluded from the restrictions: Quote from the systemd.exec man page I did an experiment
Test 1: RestrictAddressFamilies=noneThe file patch1 contains --- test.service.orig 2022-05-21 14:24:48.355738661 +0200
+++ test.service 2022-05-21 14:27:26.112727012 +0200
@@ -13,10 +13,15 @@
Environment=PODMAN_SYSTEMD_UNIT=%n
Restart=on-failure
TimeoutStopSec=70
+RestrictAddressFamilies=none
ExecStartPre=/bin/rm -f %t/%n.ctr-id
ExecStart=/usr/bin/podman run \
--cidfile=%t/%n.ctr-id \
--cgroups=no-conmon \
+ --pull=never \
+ --log-driver=k8s-file \
+ --log-opt path=/tmp/test \
+ --network none \
--rm \
--sdnotify=conmon \
--replace \
Result: Test 2: RestrictAddressFamilies=AF_UNIXEdit the file test.service and replace
with
Result: Test 3: RestrictAddressFamilies=AF_UNIX AF_INET AF_INET6After also adding AF_INET AF_INET6 the service test.service started successfully. I'm not quite sure why the log says
Is it possible to get it working with fewer privileges than:
? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 9 replies
-
I can definitely say that I am somewhat surprised that restricting to AF_UNIX only does not work - @giuseppe The error seems to be coming out of crun - thoughts? @eriksjolund Does it work if you use runc instead? |
Beta Was this translation helpful? Give feedback.
-
For completeness, I want to add that customizing the generated units files is not supported. While we will do our best to resolve issues as they come in, we can only support that Podman generates. |
Beta Was this translation helpful? Give feedback.
I can definitely say that
RestrictAddressFamilies=none
will not work - we use Unix sockets internally to handle container attach.I am somewhat surprised that restricting to AF_UNIX only does not work - @giuseppe The error seems to be coming out of crun - thoughts?
@eriksjolund Does it work if you use runc instead?