aboutgitcodebugslistschat
diff options
context:
space:
mode:
-rw-r--r--README.md2
-rw-r--r--conf.c5
-rw-r--r--contrib/apparmor/abstractions/passt4
-rw-r--r--contrib/apparmor/abstractions/pasta4
-rw-r--r--contrib/selinux/passt.te4
-rw-r--r--passt.12
-rw-r--r--test/pasta_options/dns_host_follow13
7 files changed, 24 insertions, 10 deletions
diff --git a/README.md b/README.md
index 43caf49..2f865fc 100644
--- a/README.md
+++ b/README.md
@@ -291,7 +291,7 @@ speeding up local connections, and usually requiring NAT. _pasta_:
* ✅ all capabilities dropped, other than `CAP_NET_BIND_SERVICE` (if granted)
* ✅ with default options, user, mount, IPC, UTS, PID namespaces are detached
* ✅ no external dependencies (other than a standard C library)
-* ✅ restrictive seccomp profiles (34 syscalls allowed for _passt_, 43 for
+* ✅ restrictive seccomp profiles (35 syscalls allowed for _passt_, 43 for
_pasta_ on x86_64)
* ✅ examples of [AppArmor](/passt/tree/contrib/apparmor) and
[SELinux](/passt/tree/contrib/selinux) profiles available
diff --git a/conf.c b/conf.c
index 7a271ff..925b94d 100644
--- a/conf.c
+++ b/conf.c
@@ -322,7 +322,7 @@ out:
*
* Return: 0 on success, negative error code if the file can't be opened
*
- * #syscalls:pasta openat
+ * #syscalls openat
*/
static int conf_resolv_update(struct ctx *c)
{
@@ -413,9 +413,6 @@ void conf_resolv_watch(struct ctx *c)
char dir[PATH_MAX], *base;
int fd = -1, dir_fd, rc;
- if (c->mode != MODE_PASTA)
- return;
-
if (IN4_IS_ADDR_UNSPECIFIED(&c->ip4.dns_match))
c->ip4.dns_host_resolv = false;
if (IN6_IS_ADDR_UNSPECIFIED(&c->ip6.dns_match))
diff --git a/contrib/apparmor/abstractions/passt b/contrib/apparmor/abstractions/passt
index 0aeb19d..d4a65a0 100644
--- a/contrib/apparmor/abstractions/passt
+++ b/contrib/apparmor/abstractions/passt
@@ -17,6 +17,10 @@
include <abstractions/nameservice> # get_dns(), conf.c
+ # Host's resolv.conf in /run, read via a detached copy of its directory,
+ # with paths relative to /run: conf_resolv_watch(), conf_resolv_update()
+ /{NetworkManager,connman,netconfig,resolvconf,systemd/resolve}/resolv.conf r,
+
capability net_bind_service, # isolation.c, conf.c
capability setuid,
capability setgid,
diff --git a/contrib/apparmor/abstractions/pasta b/contrib/apparmor/abstractions/pasta
index 7ee892b..89fa427 100644
--- a/contrib/apparmor/abstractions/pasta
+++ b/contrib/apparmor/abstractions/pasta
@@ -29,10 +29,6 @@
@{run}/user/@{uid}/** rw, # pasta_open_ns()
- # Host's resolv.conf in /run, read via a detached copy of its directory,
- # with paths relative to /run: conf_resolv_watch(), conf_resolv_update()
- /{NetworkManager,connman,netconfig,resolvconf,systemd/resolve}/resolv.conf r,
-
@{PROC}/[0-9]*/ns/ r, # pasta_netns_quit_init(),
@{PROC}/[0-9]*/ns/net r, # pasta_wait_for_ns(),
@{PROC}/[0-9]*/ns/user r, # conf_pasta_ns()
diff --git a/contrib/selinux/passt.te b/contrib/selinux/passt.te
index e540473..f2628ec 100644
--- a/contrib/selinux/passt.te
+++ b/contrib/selinux/passt.te
@@ -131,6 +131,10 @@ corenet_tcp_sendrecv_all_ports(passt_t)
corenet_udp_sendrecv_all_ports(passt_t)
sysnet_read_config(passt_t)
+# Watch the directory holding resolv.conf for changes: conf_resolv_watch()
+files_watch_etc_dirs(passt_t)
+networkmanager_watch_pid_dirs(passt_t)
+systemd_resolved_watch_pid_dirs(passt_t)
allow passt_t node_t:icmp_socket { name_bind node_bind };
allow passt_t port_t:icmp_socket name_bind;
diff --git a/passt.1 b/passt.1
index c743889..bf7a95b 100644
--- a/passt.1
+++ b/passt.1
@@ -287,7 +287,7 @@ Configure the host nameserver which guest or namespace queries to the
\fB\-\-dns-forward\fR address will be redirected to. This option can
be specified zero to two times (once for IPv4, once for IPv6).
By default, the first nameserver from the host's
-\fI/etc/resolv.conf\fR. In pasta mode, on Linux 5.12 or later, this
+\fI/etc/resolv.conf\fR. On Linux 5.12 or later, this
default follows changes to that file: new DNS flows go to the first
nameserver listed for each IP version, while existing flows keep their
target until they expire.
diff --git a/test/pasta_options/dns_host_follow b/test/pasta_options/dns_host_follow
index d8cc232..fa8228f 100644
--- a/test/pasta_options/dns_host_follow
+++ b/test/pasta_options/dns_host_follow
@@ -30,5 +30,18 @@ passt echo "nameserver 2001:db8::1" > /etc/r && mv /etc/r /etc/resolv.conf
sleep 1
passt touch __DONE__ && wait
check grep -q "removed nameserver 192.0.2.2" __LOG_FILE__
+
+test Host nameserver follows changes to resolv.conf in passt mode
+set PASST_LOG __STATEDIR__/resolv_passt.log
+set PIDFILE __STATEDIR__/resolv_passt.pid
+passt echo "nameserver 192.0.2.1" > /etc/r && mv /etc/r /etc/resolv.conf
+passt ./passt -d -l __PASST_LOG__ -P __PIDFILE__ -s __STATEDIR__/resolv.sock --dns-forward 192.0.2.53
+passt echo "nameserver 192.0.2.2" > /etc/r && mv /etc/r /etc/resolv.conf
+sleep 1
+passt echo "nameserver 2001:db8::1" > /etc/r && mv /etc/r /etc/resolv.conf
+sleep 1
+passt kill $(cat __PIDFILE__)
passt umount /etc
passt exit
+check grep -q "new host nameserver 192.0.2.2" __PASST_LOG__
+check grep -q "removed nameserver 192.0.2.2" __PASST_LOG__