Alexander (HH): Perl-Skript mit "fork" funktioniert nicht als CGI

Beitrag lesen

Doch, $ENV{'PATH'} gefällt dem Taint-Modus nicht. Der ist nämlich reichlich paranoid, und das mit Recht. Wer garantiert Dir denn, dass das Programm, das Du startest, auch überall absolute Pfade benutzt?

"-v" bitte. Wenn ich "/bin/foobar /tmp/tempfile" ausführe, wo kommt dann noch ein Pfad her, der mir Probleme machen könnte? Ich lerne ja gerne dazu, aber Dazu solltest Du Dein Wissen so vermitteln, dass man es als "Unwürdiger" ;-) versteht.

Um mal aus man 3 execvp zu zitieren:

The  functions  execlp() and execvp() will duplicate the actions of the shell in searching for an executable file  if  the  specified  filename does  not  contain  a slash (/) character.  The search path is the path specified in the environment by the PATH variable.   If  this  variable isn't specified, the default path ":/bin:/usr/bin" is used.

Wenn /bin/foobar irgendwo execvp() oder execlp() aufruft, und sei es nur, weil ein übermüdeter Coder für irgendeine über 10 Umwege eingelinkte Library gerade unlink() vergessen hatte und stattdessen fork() && execvp("rm","rm","-f",tmpfile,NULL) gehackt hat, wird die PATH-Environment-Variable durchsucht.

popen(3) geht GRUNDSÄTZLICH über die Shell, schlimmer noch, popen() überläßt auch das Parsen der Kommandozeile der Shell. Zitat:

The command argument is a pointer to a null-terminated string containing  a shell command line.  This command is passed to /bin/sh using the c flag; interpretation, if any, is performed by the shell.

Alexander