ZZamboni has asked for the wisdom of the Perl Monks concerning the following question:
#!/usr/bin/perl -w print "$0\n";normally works ok. However, if the script is set-uid (to any user) it prints something like "/dev/fd/3". This is under Solaris 2.7. The FindBin modules uses $0 as its starting point, so it doesn't work either.
I read somewhere that this is a trick used by some kernels to safely execute set-uid scripts: when a set-uid script is invoked, the kernel passes the script to the interpreter using a file descriptor instead of the file name directly, to avoid race conditions. If this is the case, my problem may be unsolvable, but I thought I would ask anyway.
I asked in comp.lang.perl.misc about this, and got two main suggestions, which I list with their drawbacks:
Thanks,
--Diego
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: How to determine the program path from a set-uid program
by plaid (Chaplain) on Mar 30, 2000 at 02:15 UTC | |
|
Re: How to determine the program path from a set-uid program
by mikfire (Deacon) on Mar 30, 2000 at 03:18 UTC | |
|
Re: How to determine the program path from a set-uid program
by btrott (Parson) on Mar 30, 2000 at 01:39 UTC | |
|
Re: How to determine the program path from a set-uid program
by turnstep (Parson) on Apr 01, 2000 at 07:17 UTC |