/usr/share/doc/libnet-imap-simple-perl/examples/preauth-pipe-server.pl is in libnet-imap-simple-perl 1.2204-1.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 | #!/usr/bin/perl
use strict;
use Net::Server;
use base 'Net::Server::PreFork';
use IPC::Open3;
use IO::Select;
my $port = shift;
my @cmd = @ARGV;
die "port cmd cmd cmd cmd cmd cmd cmd" unless $port and @cmd;
sub process_request {
my $this = shift;
my ($wtr, $rdr, $err);
my $pid = open3($wtr, $rdr, $err, @cmd);
$rdr->blocking(0);
STDIN->blocking(0);
my $select = IO::Select->new($rdr, \*STDIN);
TOP: while(1) {
if( my @handles = $select->can_read(1) ) {
for(@handles) {
my $at_least_one = 0;
while( my $line = $_->getline ) {
if( $_ == $rdr ) {
print STDOUT $line;
$this->log(1, "[IMAP] $line");
} else {
print $wtr $line;
$this->log(1, "[CLNT] $line");
}
$at_least_one ++;
}
last TOP unless $at_least_one;
}
}
}
$this->log(1, "[KILL] $pid must die");
kill -1, $pid;
kill -2, $pid;
waitpid $pid, 0;
return;
}
main->run(port=>$port, log_file=>"ppsc.log");
|