1
0
Fork 0
mirror of https://passt.top/passt synced 2025-07-27 19:58:00 +02:00

passt-repair: Don't use perror(), accept ECONNRESET as termination

If we use glibc's perror(), we need to allow dup() and fcntl() in our
seccomp profiles, which are a bit too much for this simple helper. On
top of that, we would probably need a wrapper to avoid allocation for
translated messages.

While at it: ECONNRESET is just a close() from passt, treat it like
EOF.

Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
This commit is contained in:
Stefano Brivio 2025-02-07 01:51:38 +01:00
commit a0b7f56b3a

View file

@ -95,7 +95,7 @@ int main(int argc, char **argv)
} }
if ((s = socket(AF_UNIX, SOCK_STREAM, 0)) < 0) { if ((s = socket(AF_UNIX, SOCK_STREAM, 0)) < 0) {
perror("Failed to create AF_UNIX socket"); fprintf(stderr, "Failed to create AF_UNIX socket: %i\n", errno);
_exit(1); _exit(1);
} }
@ -108,8 +108,12 @@ int main(int argc, char **argv)
loop: loop:
ret = recvmsg(s, &msg, 0); ret = recvmsg(s, &msg, 0);
if (ret < 0) { if (ret < 0) {
perror("Failed to receive message"); if (errno == ECONNRESET) {
_exit(1); ret = 0;
} else {
fprintf(stderr, "Failed to read message: %i\n", errno);
_exit(1);
}
} }
if (!ret) /* Done */ if (!ret) /* Done */