Skip to content
Snippets Groups Projects
Commit 6c4cd4a1 authored by Morris Jette's avatar Morris Jette
Browse files

Merge branch 'slurm-17.02'

parents 512e4610 c7e6d864
No related branches found
No related tags found
No related merge requests found
...@@ -42,6 +42,7 @@ ...@@ -42,6 +42,7 @@
#include <dirent.h> #include <dirent.h>
#include <fcntl.h> #include <fcntl.h>
#include <grp.h>
#include <pwd.h> #include <pwd.h>
#include <stdbool.h> #include <stdbool.h>
#include <stdio.h> #include <stdio.h>
...@@ -413,6 +414,11 @@ int main(int argc, char **argv) ...@@ -413,6 +414,11 @@ int main(int argc, char **argv)
/* become the user after the allocation has been requested. */ /* become the user after the allocation has been requested. */
if (opt.uid != (uid_t) -1) { if (opt.uid != (uid_t) -1) {
/* drop groups before changing uid per POSIX POS36-C */
if ((setgroups(0, NULL) < 0) && (errno != EPERM)) {
error("setgroups: %m");
exit(error_exit);
}
if (setuid(opt.uid) < 0) { if (setuid(opt.uid) < 0) {
error("setuid: %m"); error("setuid: %m");
exit(error_exit); exit(error_exit);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment