diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-12 03:50:42 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-12 03:50:42 +0000 |
commit | 78e9bb837c258ac0ec7712b3d612cc2f407e731e (patch) | |
tree | f515d16b6efd858a9aeb5b0ef5d6f90bf288283d /src/resolve/test-resolved-stream.c | |
parent | Adding debian version 255.5-1. (diff) | |
download | systemd-78e9bb837c258ac0ec7712b3d612cc2f407e731e.tar.xz systemd-78e9bb837c258ac0ec7712b3d612cc2f407e731e.zip |
Merging upstream version 256.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/resolve/test-resolved-stream.c')
-rw-r--r-- | src/resolve/test-resolved-stream.c | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/src/resolve/test-resolved-stream.c b/src/resolve/test-resolved-stream.c index 847de04..4f27eac 100644 --- a/src/resolve/test-resolved-stream.c +++ b/src/resolve/test-resolved-stream.c @@ -329,7 +329,7 @@ static void test_dns_stream(bool tls) { log_info("test-resolved-stream: Finished %s test", tls ? "TLS" : "TCP"); } -static void try_isolate_network(void) { +static int try_isolate_network(void) { _cleanup_close_ int socket_fd = -EBADF; int r; @@ -356,20 +356,25 @@ static void try_isolate_network(void) { _exit(EXIT_SUCCESS); } if (r == -EPROTO) /* EPROTO means nonzero exit code of child, i.e. the tests in the child failed */ - return; + return 0; assert_se(r > 0); /* Now that we know that the unshare() is safe, let's actually do it */ assert_se(unshare(CLONE_NEWUSER | CLONE_NEWNET) >= 0); - /* Bring up the loopback interfaceon the newly created network namespace */ + /* Bring up the loopback interface on the newly created network namespace */ struct ifreq req = { .ifr_ifindex = 1 }; assert_se((socket_fd = socket(AF_INET, SOCK_STREAM | SOCK_CLOEXEC, 0)) >= 0); assert_se(ioctl(socket_fd, SIOCGIFNAME, &req) >= 0); assert_se(ioctl(socket_fd, SIOCGIFFLAGS, &req) >= 0); assert_se(FLAGS_SET(req.ifr_flags, IFF_LOOPBACK)); req.ifr_flags |= IFF_UP; - assert_se(ioctl(socket_fd, SIOCSIFFLAGS, &req) >= 0); + /* Do not assert on this, fails in the Ubuntu 24.04 CI environment */ + r = RET_NERRNO(ioctl(socket_fd, SIOCSIFFLAGS, &req)); + if (r < 0) + return r; + + return 0; } int main(int argc, char **argv) { @@ -378,10 +383,14 @@ int main(int argc, char **argv) { .in.sin_port = htobe16(random_u64_range(UINT16_MAX - 1024) + 1024), .in.sin_addr.s_addr = htobe32(INADDR_LOOPBACK) }; + int r; test_setup_logging(LOG_DEBUG); - try_isolate_network(); + r = try_isolate_network(); + if (ERRNO_IS_NEG_PRIVILEGE(r)) + return log_tests_skipped("lacking privileges"); + assert_se(r >= 0); test_dns_stream(false); #if ENABLE_DNS_OVER_TLS |