Главная страница


ru.unix

 
 - RU.UNIX ----------------------------------------------------------------------
 From : Eugene Korovin                       2:5080/196.72  05 Apr 2001  20:49:02
 To : Stas Vlasov
 Subject : Userspace FTP proxy need
 -------------------------------------------------------------------------------- 
 
 
 03 Апр 01 11:27, Stas Vlasov -> Eugene B. Berdnikov:
  SV> Вот что у меня вышло:
 
  SV> #!/usr/bin/perl
 
  SV> use IO::Socket;
  SV> use POSIX;
 
  SV> $server_port = 58100;
 
  SV> $server = IO::Socket::INET->new(LocalPort => $server_port,
  SV>                                 Type      => SOCK_STREAM,
  SV>                                 Reuse     => 1,
  SV>                                 Listen    => 10 )
  SV>     or die "Couldn't be a tcp server on port $server_port :$@\n";
 
  SV> while ($client = $server->accept()) {
  SV>     if ($client < 0) {
  SV>        printf "Socket error!\n";
  SV>        next;
  SV>     }
  SV>     $addr = $client->peerhost();
  SV>     if (($addr =~ /^192\.168\.47\./) || ($addr =~ /127.0.0.1/)) {
  SV>       $pid = fork();
  SV>       if ($pid < 0) { printf "Can't fork!\n" };
  SV>       if ($pid == 0) {
  SV>         close STDIN;
  SV>         close STDOUT;
  SV>         close STDERR;
  SV>         dup2(STDIN, $client);
  SV>         dup2(STDOUT, $client);
 
             dup($client);
 
  SV>         if (!(STDIN == $client) && !(STDOUT == $client)
 
               && !(STDERR == $client)
 
  SV> ) {
  SV>           close $client;
 
               exit();
 
  SV>         }
 
              close $client;   // (ИМХО) он больше ненужен и можно (нужно?)
                               // закрыть
 
  SV>         exec ("./ftp-gw");
  SV>         exit();
  SV>       } else {
  SV>         close $client;
  SV>       }
  SV>     } else {
  SV>       close $client;
  SV>     }
  SV> }
  SV> close($server);
  SV> При этом, ftp-gw (настроенный, отдельно работает) сообщает
  SV> мне getpeername: Socket operation on non-socket
 
 Значит на stdin/stdout/stderr не сокет; если на консоль сообщает, то на stderr
 точно не сокет
 
 PS: Если не поможет, то ради эксперемента, попробуй после dup'ов с STDIN что
 нибудь почитать...
 
 ... WBR, Eugene [ Registered Linux user #194650; ICQ#61264242 ]
 --- GoldED+/LNX 1.1.4.7
  * Origin: Powered by SlackWare Linux - http://slackware.com (2:5080/196.72)
 
 

Вернуться к списку тем, сортированных по: возрастание даты  уменьшение даты  тема  автор 

 Тема:    Автор:    Дата:  
 Re: Userspace FTP proxy need   Stas Vlasov   03 Apr 2001 11:27:09 
 Userspace FTP proxy need   Eugene Korovin   05 Apr 2001 20:49:02 
 Re: Userspace FTP proxy need   Stas Vlasov   09 Apr 2001 15:17:23 
 Userspace FTP proxy need   Eugene Korovin   11 Apr 2001 22:38:42 
 Re: Userspace FTP proxy need   Valentin Nechayev   12 Apr 2001 14:06:33 
 Userspace FTP proxy need   Eugene Korovin   13 Apr 2001 23:26:58 
 Re: Userspace FTP proxy need   Valentin Nechayev   14 Apr 2001 23:24:47 
 Re: Userspace FTP proxy need   Stas Vlasov   12 Apr 2001 19:09:57 
Архивное /ru.unix/40043acc85f0.html, оценка 3 из 5, голосов 10
Яндекс.Метрика
Valid HTML 4.01 Transitional