From: Mike Yuan Date: Sat, 31 Aug 2024 15:16:47 +0000 (+0200) Subject: machine-dbus: use in_same_namespace() at one more place X-Git-Tag: v257-rc1~558^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c1bf6f148edd9a56087c894bb3bc63b71ac9a912;p=thirdparty%2Fsystemd.git machine-dbus: use in_same_namespace() at one more place --- diff --git a/src/machine/machine-dbus.c b/src/machine/machine-dbus.c index 366be8fbdeb..49ec710df0e 100644 --- a/src/machine/machine-dbus.c +++ b/src/machine/machine-dbus.c @@ -215,21 +215,13 @@ int bus_machine_method_get_addresses(sd_bus_message *message, void *userdata, sd case MACHINE_CONTAINER: { _cleanup_close_pair_ int pair[2] = EBADF_PAIR; - _cleanup_free_ char *us = NULL, *them = NULL; _cleanup_close_ int netns_fd = -EBADF; - const char *p; pid_t child; - r = readlink_malloc("/proc/self/ns/net", &us); + r = in_same_namespace(0, m->leader.pid, NAMESPACE_NET); if (r < 0) return r; - - p = procfs_file_alloca(m->leader.pid, "ns/net"); - r = readlink_malloc(p, &them); - if (r < 0) - return r; - - if (streq(us, them)) + if (r > 0) return sd_bus_error_setf(error, BUS_ERROR_NO_PRIVATE_NETWORKING, "Machine %s does not use private networking", m->name); r = pidref_namespace_open(&m->leader,