Is using a wrapper to execute a script a good practice ?
In such case can the following set of wrapper / script be considered as safe:
wrapper.c
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <unistd.h>
#include <sys/types.h>
int main(void)
{
if (setuid(geteuid()) != 0)
{
fputs(strerror(errno), stderr);
return EXIT_FAILURE;
}
system("cat script | /bin/bash");
return EXIT_SUCCESS;
}
script
IFS=""
/bin/echo -n "[Whoami]: "
/usr/bin/whoami
/bin/echo -n "[ls /root]: "
/bin/ls /root
The script
file does not contain any shebang. Would it change anything if I'd have added one ?
In the Wrapper, could I have simply called the script as I'd execute any Linux script instead of cat'ing its content into a shell ?