summaryrefslogtreecommitdiff
path: root/ipif/udptunnel
diff options
context:
space:
mode:
authorian <ian>2000-05-30 23:51:00 +0000
committerian <ian>2000-05-30 23:51:00 +0000
commit0f4b558c78aae6fda9f52287e1b53483e9435903 (patch)
treea7df1896274b4f42a186376a955ca06b1e0ed9ca /ipif/udptunnel
parent09966b4959fa31ea3f6746b6b6583907744484e1 (diff)
downloaduserv-utils-0f4b558c78aae6fda9f52287e1b53483e9435903.tar.gz
crypto debugging, and several bugfixes
Diffstat (limited to 'ipif/udptunnel')
-rwxr-xr-xipif/udptunnel22
1 files changed, 13 insertions, 9 deletions
diff --git a/ipif/udptunnel b/ipif/udptunnel
index 08b75a3..e52ee73 100755
--- a/ipif/udptunnel
+++ b/ipif/udptunnel
@@ -159,7 +159,7 @@ sub show_addr_port ($) {
return show_addr($s).','.show_port($s);
}
sub arg_value ($$) {
- my ($val,$opt);
+ my ($val,$opt) = @_;
$_= '-';
return $val if length $val;
@ARGV or quit("$opt needs value");
@@ -187,14 +187,17 @@ while ($ARGV[0] =~ m/^-/) {
$fcmd= arg_value($_,'-f');
} elsif (s/^-e//) {
$encrarg= arg_value($_,'-e');
- push @encrargs, "-e$encrarg";
- push @encryption, split m#/#, $encrarg;
+ push @remoteopts, "-e$encrarg";
+ @thisencryption= split m#/#, $encrarg;
+ $thisencryption[0] =~ s/^/\!/;
+ push @encryption, @thisencryption;
} elsif (s/^-m/-/) {
$masq= 1;
} elsif (s/^-d/-/) {
$dump= 1;
} elsif (s/^-Dcrypto$/-/) {
$xfwdopts.= 'K';
+ push @remoteopts, '-Dcrypto';
} else {
quit("unknown option \`$_'");
}
@@ -259,7 +262,7 @@ if (@ARGV) {
$rad= xform_remote(show_addr($rs),$ras);
$rpd= xform_remote(show_port($rs),$rps);
@rcmd= (@ARGV,
- @encrargs,
+ @remoteopts,
"$rad,$rpd",
$masq ? 'Wait,Wait' : $lapd,
"$rva,$lva,$mtu,$proto",
@@ -271,10 +274,10 @@ if (@ARGV) {
pipe(RAPREAD,RCMDREADSUB) or fail("pipe");
select(RCMDREADSUB); $|=1; select(STDOUT);
}
- pipe(DUMPKEYS,RCMDWRITESUB) or fail("pipe");
+ pipe(RCMDWRITESUB,DUMPKEYS) or fail("pipe");
defined($c_rcmd= fork) or fail("fork for remote");
if (!$c_rcmd) {
- open STDIN, ">&RCMDWRITESUB" or fail("reopen stdin for remote command");
+ open STDIN, "<&RCMDWRITESUB" or fail("reopen stdin for remote command");
open STDOUT, ">&RCMDREADSUB" or fail("reopen stdout for remote command")
if $rapcmd;
close RAPREAD if $rapcmd;
@@ -360,7 +363,7 @@ debug("forwarding command @fcmd.");
defined($c_fwd= fork) or fail("fork for udptunnel-forwarder");
if (!$c_fwd) {
- foreach $fd (qw(L DW UR)) {
+ foreach $fd (qw(L DW UR DUMPKEYS)) {
fcntl($fd, F_SETFD, 0) or fail("set no-close-on-exec $fd");
}
exec @fcmd; fail("cannot execute $fcmd[0]");
@@ -381,11 +384,12 @@ $estatus= 0;
while (keys %procs) {
($c= wait) >0 or
fail("wait failed (expecting ". join('; ',keys %procs). ")");
- warning("unexpected child reaped: pid $c, code $?"), next
+ $status= $?;
+ warning("unexpected child reaped: pid $c, code $status"), next
unless exists $procs{$c};
$str= $procs{$c};
delete $procs{$c};
- $? ? warning("subprocess $str failed with code $?")
+ $status ? warning("subprocess $str failed with code $status")
: debug("subprocess $str finished");
if ($c==$c_lcmd || $c==$c_fwd || $c==$c_rcmd) {
kill 15, grep (exists $procs{$_}, $c_fwd, $c_rcmd);