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
|
#endif
|
||||||
|
|
||||||
if(bind(sock, rp->ai_addr, rp->ai_addrlen) == -1){
|
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");
|
net__print_error(MOSQ_LOG_ERR, "Error: %s");
|
||||||
COMPAT_CLOSE(sock);
|
COMPAT_CLOSE(sock);
|
||||||
freeaddrinfo(ainfo);
|
freeaddrinfo(ainfo);
|
||||||
|
Loading…
Reference in New Issue
Block a user