mirror of
https://github.com/SuperBFG7/ympd
synced 2024-06-17 02:30:10 +00:00
Fix: memory leaks detected by valingrid
Fix: dont't change user/group if startup user is not root
This commit is contained in:
parent
c5cac48ac7
commit
c7a093ae1d
|
@ -194,6 +194,7 @@ static void mympd_parse_env(struct t_config *config, const char *envvar) {
|
||||||
mympd_inihandler(config, section, name, value);
|
mympd_inihandler(config, section, name, value);
|
||||||
}
|
}
|
||||||
value = NULL;
|
value = NULL;
|
||||||
|
free(var);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -319,7 +320,8 @@ int main(int argc, char **argv) {
|
||||||
}
|
}
|
||||||
|
|
||||||
//drop privileges
|
//drop privileges
|
||||||
if (config->user != NULL) {
|
if (getuid() == 0) {
|
||||||
|
if (config->user != NULL || strlen(config->user) != 0) {
|
||||||
printf("Droping privileges to %s\n", config->user);
|
printf("Droping privileges to %s\n", config->user);
|
||||||
struct passwd *pw;
|
struct passwd *pw;
|
||||||
if ((pw = getpwnam(config->user)) == NULL) {
|
if ((pw = getpwnam(config->user)) == NULL) {
|
||||||
|
@ -336,6 +338,7 @@ int main(int argc, char **argv) {
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (getuid() == 0) {
|
if (getuid() == 0) {
|
||||||
printf("myMPD should not be run with root privileges\n");
|
printf("myMPD should not be run with root privileges\n");
|
||||||
|
@ -423,5 +426,6 @@ int main(int argc, char **argv) {
|
||||||
tiny_queue_free(mpd_client_queue);
|
tiny_queue_free(mpd_client_queue);
|
||||||
tiny_queue_free(mympd_api_queue);
|
tiny_queue_free(mympd_api_queue);
|
||||||
mympd_free_config(config);
|
mympd_free_config(config);
|
||||||
|
free(configfile);
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user