aboutgitcodebugslistschat
diff options
context:
space:
mode:
authorStefano Brivio <sbrivio@redhat.com>2024-07-24 23:05:23 +0200
committerStefano Brivio <sbrivio@redhat.com>2024-07-25 12:30:42 +0200
commit6ff702f3257bbaf2979f95bf4906285621206007 (patch)
tree924c80d4ccc5881747fcfdd90b55f700bbe673fa
parentf72d35a78d4436c662cfafbceb829144cd4011fd (diff)
downloadpasst-6ff702f3257bbaf2979f95bf4906285621206007.tar
passt-6ff702f3257bbaf2979f95bf4906285621206007.tar.gz
passt-6ff702f3257bbaf2979f95bf4906285621206007.tar.bz2
passt-6ff702f3257bbaf2979f95bf4906285621206007.tar.lz
passt-6ff702f3257bbaf2979f95bf4906285621206007.tar.xz
passt-6ff702f3257bbaf2979f95bf4906285621206007.tar.zst
passt-6ff702f3257bbaf2979f95bf4906285621206007.zip
tap: Exit if we fail to bind a UNIX domain socket with explicit path
In tap_sock_unix_open(), if we have a given path for the socket from configuration, we don't need to loop over possible paths, so we exit the loop on the first iteration, unconditionally. But if we failed to bind() the socket to that explicit path, we should exit, instead of continuing. Otherwise we'll pretend we're up and running, but nobody can contact us, and this might be mildly confusing for users. Link: https://bugzilla.redhat.com/show_bug.cgi?id=2299474 Signed-off-by: Stefano Brivio <sbrivio@redhat.com> Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
-rw-r--r--tap.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/tap.c b/tap.c
index 6930ad8..44bd444 100644
--- a/tap.c
+++ b/tap.c
@@ -1139,8 +1139,11 @@ int tap_sock_unix_open(char *sock_path)
close(ex);
unlink(path);
- if (!bind(fd, (const struct sockaddr *)&addr, sizeof(addr)) ||
- *sock_path)
+ ret = bind(fd, (const struct sockaddr *)&addr, sizeof(addr));
+ if (*sock_path && ret)
+ die_perror("Failed to bind UNIX domain socket");
+
+ if (!ret)
break;
}