I want to have a bash scripts run setuid as root, The bash
script('do_something') suppose to write to a file('/var/filename')
that has an root owner and -rw--r--r permission
So I've created a C-wrapper that calls the script with permissions
4755 and has an root owner.
I have no problem to run the C-program as root, but when I am trying
to execute it as regular user I get a Permission denied message.
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <unistd.h>
int main(){
if((pid = fork()) == -1)
return -1;
if(pid == 0){
char *args[2];
args[0] = "./do_something";
args[1] = "/var/filename";
args[2] = NULL;
setuid(0);
rc = execv(args[0], args);
exit(rc);
}
rc = wait(NULL);
Quote:
}
does anyone know what is wrong ?
how can i let a regular user run that script with superuser
permissions ?
Thanks for any information
Itzik