From 4ffb4653b5cec9b28c39992d8192900da7756146 Mon Sep 17 00:00:00 2001 From: ian Date: Wed, 31 May 2000 01:57:25 +0000 Subject: [PATCH] Make debugging redirect work. --- ipif/udptunnel | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/ipif/udptunnel b/ipif/udptunnel index 5b64b2b..b76a9da 100755 --- a/ipif/udptunnel +++ b/ipif/udptunnel @@ -170,8 +170,6 @@ sub arg_value ($$) { return shift @ARGV; } -$|=1; - @lcmd= (); @encryption= (); $masq= 0; @@ -276,7 +274,6 @@ if (@ARGV) { if ($rapcmd) { pipe(RAPREAD,RCMDREADSUB) or fail("pipe"); - select(RCMDREADSUB); $|=1; select(STDOUT); } pipe(RCMDWRITESUB,DUMPKEYS) or fail("pipe"); defined($c_rcmd= fork) or fail("fork for remote"); @@ -295,30 +292,33 @@ if (@ARGV) { if ($rapcmd) { close RCMDREADSUB if $rapcmd; - $!=0; $_= ; $e="$!"; + $_= ''; + while (!m/\n/) { + $!=0; + defined($nread= sysread(RAPREAD,$_,1,length)) + or fail("read from remote command"); + if (!$nread) { + close DUMPKEYS; + close RAPREAD; + waitpid $c_rcmd,0 or fail("wait for remote command"); + quit($? ? "remote command failed (code $?)" : + "no details received from remote"); + } + } + chomp; + m/^([.0-9]+)\,(\d+)$/ or quit("invalid details from remote end: \`$_'"); + ($rar,$rpr) = ($1,$2); + $ra= conv_host_addr($rar); + $rp= conv_port_number($rpr); defined($c_catremdebug= fork) or fail("fork for cat remote debug"); if (!$c_catremdebug) { open(STDIN,"<&RAPREAD") or fail("redirect remote debug"); - close RAPREAD; close DUMPKEYS; close L; exec "cat"; fail("execute cat"); } close RAPREAD; - - if (!length) { - close DUMPKEYS; - waitpid $c_rcmd,0 or fail("wait for remote command"); - quit($? ? "remote command failed (code $?)" : - $e ? "read error from remote command: $e" : - "no details received from remote"); - } - chomp; - m/^([.0-9]+)\,(\d+)$/ or quit("invalid details from remote end: \`$_'"); - ($rar,$rpr) = ($1,$2); - $ra= conv_host_addr($rar); - $rp= conv_port_number($rpr); } } elsif ($dump) { open DUMPKEYS, ">&STDOUT" or fail("reopen stdout for key material"); -- 2.30.2