Answer the question
In order to leave comments, you need to log in
What is the correct way to exec bash with SUID SGID?
I want to set SUID to a binary that will exec in bash to have a shell under a different user, but the shell is launched with the rights of the launcher, not the owner. That is, there is no access, for example, to directories, files, etc. user 1000. The bash itself is executed, but when I try to read the file, it says
bash-4.3$ cat n
cat: n: Permission denied
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
int main () {
char *args [] = {"/bin/bash", (char *)NULL};
setuid((uid_t)1000);
setgid(1000);
execvp ("/bin/bash", args);
return 0;
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question