in reply to perl 5.16 setuid
The clean way to execute perl code setuid is to compile a wrapper from six lines of C code. See Security Bugs in perlsec.
Update:
This is the code from perlsec:
#define REAL_PATH "/path/to/script" main(ac, av) char **av; { execv(REAL_PATH, av); }
It is K&R style, quick and dirty, but it works.
If you prefer modern code that compiles cleanly even with gcc -Wall -pedantic, and that reports an error when executing the script fails, try this:
#include <unistd.h> /* for execv() */ #include <stdio.h> /* for perror() */ #define REAL_PATH "/path/to/script" int main(int argc, char ** argv) { execv(REAL_PATH, argv); perror("Can't execute main script"); return 126; }
Note that the wrapper is setuid, not the script. The script inherits the setuid from the wrapper.
Alexander
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: perl 5.16 setuid
by Corion (Patriarch) on Oct 14, 2016 at 12:23 UTC | |
|
Re^2: perl 5.16 setuid
by Anonymous Monk on Apr 30, 2018 at 19:00 UTC | |
by Anonymous Monk on May 01, 2018 at 12:02 UTC |