1
0
mirror of https://github.com/SuperBFG7/ympd synced 2025-01-29 10:24:53 +00:00

Fix: setgroups before setuid

This commit is contained in:
jcorporation 2018-08-28 00:45:14 +01:00
parent e99bd1f66e
commit ca4ff0e396
2 changed files with 6 additions and 1 deletions

View File

@ -56,4 +56,4 @@ install(FILES dist/htdocs/css/bootstrap.min.css DESTINATION share/${PROJECT_NAME
install(FILES dist/htdocs/css/mympd.min.css DESTINATION share/${PROJECT_NAME}/htdocs/css/)
install(DIRECTORY htdocs/assets DESTINATION share/${PROJECT_NAME}/htdocs)
install(DIRECTORY DESTINATION share/${PROJECT_NAME}/htdocs/pics)
install(DIRECTORY DESTINATION /var/lib/${PROJECT_NAME}/)
install(DIRECTORY DESTINATION /var/lib/${PROJECT_NAME}/)

View File

@ -28,6 +28,7 @@
#include <unistd.h>
#include <sys/time.h>
#include <pwd.h>
#include <grp.h>
#include "../dist/src/mongoose/mongoose.h"
#include "../dist/src/inih/ini.h"
@ -246,6 +247,10 @@ int main(int argc, char **argv) {
printf("Unknown user\n");
mg_mgr_free(&mgr);
return EXIT_FAILURE;
} else if (setgroups(0, NULL) != 0) {
printf("setgroups() failed\n");
mg_mgr_free(&mgr);
return EXIT_FAILURE;
} else if (setgid(pw->pw_gid) != 0) {
printf("setgid() failed\n");
mg_mgr_free(&mgr);