commit a9164839e6f091ff66b6684c65d55ed7f5a09ebb Author: Laslo Hunhold <d...@frign.de> AuthorDate: Sun Jan 17 13:19:45 2021 +0100 Commit: Laslo Hunhold <d...@frign.de> CommitDate: Sun Jan 17 13:19:45 2021 +0100
Also add a proper warning with a hint when bind() fails Signed-off-by: Laslo Hunhold <d...@frign.de> diff --git a/sock.c b/sock.c index 676f604..fd16547 100644 --- a/sock.c +++ b/sock.c @@ -1,5 +1,6 @@ /* See LICENSE file for copyright and license details. */ #include <arpa/inet.h> +#include <errno.h> #include <fcntl.h> #include <netdb.h> #include <netinet/in.h> @@ -73,7 +74,13 @@ sock_get_ips_arr(const char *host, const char* port, int *sockfd, freeaddrinfo(ai); if (!p) { /* we exhaustet the addrinfo-list and found no connection */ - warn("bind:"); + if (errno == EACCES) { + warn("You need to run as root or have " + "CAP_NET_BIND_SERVICE set to bind to " + "privileged ports"); + } else { + warn("bind:"); + } return 1; }