SUID gotcha

SUID allows an executable to be run with the permissions of the owner of that executable file. However this does not work for bash scripts (*.sh)

A workaround implies writing a short C program that calls the bash script.

#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <unistd.h>

int main()
   setuid( 0 );
   system( "/tmp/suid_test_script" );

   return 0;

then compile

gcc -o <destination executable> <source code>