mirror of
https://github.com/eclipse/mosquitto.git
synced 2025-05-08 16:52:13 +08:00
Provide help for users trying to bind to privileged ports.
Closes #2098.
This commit is contained in:
parent
eead0d2943
commit
983dc14f2c
@ -754,6 +754,12 @@ static int net__socket_listen_tcp(struct mosquitto__listener *listener)
|
||||
#endif
|
||||
|
||||
if(bind(sock, rp->ai_addr, rp->ai_addrlen) == -1){
|
||||
#if defined(__linux__)
|
||||
if(errno == EACCES){
|
||||
log__printf(NULL, MOSQ_LOG_ERR, "If you are trying to bind to a privileged port (<1024), try using setcap and do not start the broker as root:");
|
||||
log__printf(NULL, MOSQ_LOG_ERR, " sudo setcap 'CAP_NET_BIND_SERVICE=+ep /usr/sbin/mosquitto'");
|
||||
}
|
||||
#endif
|
||||
net__print_error(MOSQ_LOG_ERR, "Error: %s");
|
||||
COMPAT_CLOSE(sock);
|
||||
freeaddrinfo(ainfo);
|
||||
|
Loading…
x
Reference in New Issue
Block a user