I have some bash scripts that I use with the user 'root' to manage iptable rules.
The problem is that I want these things at the same time:
- The script must be owned by root
- Permissions must be 700
- I want to have an executable binary that certain user can execute. This executable will run the mentioned script as root.
This used to work, and is still what I use in older distributions:
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <unistd.h>
int main()
{
setuid(0);
system("/root/iptables/my-iptables-script.sh");
return 0;
}
So I compile this and then use sudo chown root and sudo chmod 4777. This way the user can now execute the binary and run the script owned by root.
But now I installed Ubuntu 13.10 and when I run that binary I get "permission denied" for the script.
Is it possible that something changed in this respect since 12.04?
What can I do?