diff --git a/ChangeLog.txt b/ChangeLog.txt index 86f3922f..9230ca5f 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -3,6 +3,7 @@ Broker: - Elevate log level to warning for situation when socket limit is hit. +- Remove requirement to use `user root` in snap package config files. 1.5.2 - 20180919 diff --git a/src/mosquitto.c b/src/mosquitto.c index 61acd95b..eb90260c 100644 --- a/src/mosquitto.c +++ b/src/mosquitto.c @@ -94,6 +94,12 @@ int drop_privileges(struct mosquitto__config *config, bool temporary) char err[256]; int rc; + const char *snap = getenv("SNAP_NAME"); + if(snap && !strcmp(snap, "mosquitto")){ + /* Don't attempt to drop privileges if running as a snap */ + return MOSQ_ERR_SUCCESS; + } + if(geteuid() == 0){ if(config->user && strcmp(config->user, "root")){ pwd = getpwnam(config->user);