You could go suid, chmod 4111, but that is ALL to dangerous.
Well you cannot execute a script on either FreeBSD or Linux that has the SUID bit set ..
OK, you still end up with an SUID program, but what about putting the real Perl script in a directory that users cannot read, then calling it with this wrapper:
/* wrapper.c */
#define REAL_PATH "/usr/local/bin/secret/secret.pl"
main(ac, av)
char **av;
{
execv(REAL_PATH, av);
}
Compile it: cc -o secret wrapper.c
Put the real script in the unreadable directory:
# mkdir /usr/local/bin/secret
# cp secret.pl /usr/local/bin/secret/
# chmod -R 0711 /usr/local/bin/secret/
Make the wrapper you just compiled SUID root:
# chown root:root secret
# chmod 4711 secret
A unprivileged user should be able to execute the "secret" program, but not read the real Perl code.. so how dangerous would it be to have this suid program around? Maybe in the Perl script you could make sure no arguments are passed in as a first level precaution.. ? I know, it's a Bad Thing.
You could also just compile the perl script into an executable with perlcc - I don't believe you can see the source code.
|