~mdw
/
with-authinfo-kludge
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
with-authinfo-kludge: Make $CLIENTKID be defined.
[with-authinfo-kludge]
/
with-authinfo-kludge
diff --git
a/with-authinfo-kludge
b/with-authinfo-kludge
index
d98aa83
..
651cd8c
100755
(executable)
--- a/
with-authinfo-kludge
+++ b/
with-authinfo-kludge
@@
-23,8
+23,6
@@
## things to do
##
## things to do
##
-## split parsing and resolution of addresses
-## default port
## pidfiles
my $VERSION = "0.1.0~unfinished";
## pidfiles
my $VERSION = "0.1.0~unfinished";
@@
-75,7
+73,7
@@
my $SESSDIR = undef;
my %SERVMAP = ();
my %CLIENT_NOIP = ();
my %KIDMAP = ();
my %SERVMAP = ();
my %CLIENT_NOIP = ();
my %KIDMAP = ();
-my $CLIENTKID =
undef
;
+my $CLIENTKID =
-1
;
###--------------------------------------------------------------------------
### Utilities.
###--------------------------------------------------------------------------
### Utilities.
@@
-155,6
+153,13
@@
sub set_cloexec ($) {
sysfail "failed to set close-on-exec: $!";
}
sysfail "failed to set close-on-exec: $!";
}
+sub set_nonblock ($) {
+ my ($fh) = @_;
+ my $f = fcntl $fh, F_GETFL, 0 or sysfail "failed to get file flags: $!";
+ fcntl $fh, F_SETFL, $f | O_NONBLOCK or
+ sysfail "failed to set non-blockingness: $!";
+}
+
sub lockedp ($) {
my ($f) = @_;
my $l = new File::FcntlLock;
sub lockedp ($) {
my ($f) = @_;
my $l = new File::FcntlLock;
@@
-200,7
+205,7
@@
sub chew_cli_server_configs (\@) {
ARG: for (;;) {
last ARG unless @$args;
ARG: for (;;) {
last ARG unless @$args;
- my $arg = shift $args;
+ my $arg = shift
@
$args;
if ($arg eq "+") { last ARG; }
elsif ($arg =~ /^\+/) {
$server = substr $arg, 1;
if ($arg eq "+") { last ARG; }
elsif ($arg =~ /^\+/) {
$server = substr $arg, 1;
@@
-298,7
+303,7
@@
sub dump_configuration () {
for my $s (sort keys %S) {
inform "Server `$s' parameters...";
for my $s (sort keys %S) {
inform "Server `$s' parameters...";
- for my $p (sort keys
$S{$s
}) { inform_param $p, $S{$s}{$p}; }
+ for my $p (sort keys
%{$S{$s}
}) { inform_param $p, $S{$s}{$p}; }
}
}
}
}
@@
-592,6
+597,8
@@
sub fix_server_config ($) {
$s->{"_proxy_sockdir"} = undef;
$s->{"_proxy_server"} = defined $s->{"via"} ?
$s->{"sshbind"} : $s->{"remote"};
$s->{"_proxy_sockdir"} = undef;
$s->{"_proxy_server"} = defined $s->{"via"} ?
$s->{"sshbind"} : $s->{"remote"};
+ $s->{"_proxy_server"} =~ s/:119$//;
+ $s->{"_proxy_server"} =~ s/^\[(.*)\]$/$1/;
$s->{"_sshkid"} = undef;
$s->{"_ssh_master"} = undef;
}
$s->{"_sshkid"} = undef;
$s->{"_ssh_master"} = undef;
}
@@
-628,7
+635,7
@@
sub server_listen ($) {
for my $a (@{$s->{"_laddrs"}}) {
socket my $sk, PF_UNIX, SOCK_STREAM, 0
or sysfail "failed to make Unix-domain socket: $!";
for my $a (@{$s->{"_laddrs"}}) {
socket my $sk, PF_UNIX, SOCK_STREAM, 0
or sysfail "failed to make Unix-domain socket: $!";
- set_cloexec $sk;
+ set_cloexec $sk;
set_nonblock $sk;
my $sa = "$SESSDIR/noip-client/$a";
bind $sk, sockaddr_un $sa
or sysfail "failed to bind Unix-domain socket to `$sa': $!";
my $sa = "$SESSDIR/noip-client/$a";
bind $sk, sockaddr_un $sa
or sysfail "failed to bind Unix-domain socket to `$sa': $!";
@@
-766,15
+773,18
@@
sub run_client (@) {
sub accept_loop () {
my $rfd_in = "";
for my $fd (keys %SERVMAP) { vec($rfd_in, $fd, 1) = 1; }
sub accept_loop () {
my $rfd_in = "";
for my $fd (keys %SERVMAP) { vec($rfd_in, $fd, 1) = 1; }
- for (;;) {
+
SELECT:
for (;;) {
my ($n, $t) = select my $rfd_out = $rfd_in, undef, undef, undef;
my ($n, $t) = select my $rfd_out = $rfd_in, undef, undef, undef;
- $n >= 0 || $! == EINTR or sysfail "select failed: $!";
+ if ($n >= 0) { }
+ elsif ($! == EINTR) { next SELECT; }
+ else { sysfail "select failed: $!"; }
FD: for my $fd (keys %SERVMAP) {
FD: for my $fd (keys %SERVMAP) {
- next unless vec $rfd_out, $fd, 1;
+ next
FD
unless vec $rfd_out, $fd, 1;
my ($s, $a, $sk) = @{$SERVMAP{$fd}};
my $nsk;
unless (accept $nsk, $sk) {
my ($s, $a, $sk) = @{$SERVMAP{$fd}};
my $nsk;
unless (accept $nsk, $sk) {
- moan "failed to accept new connection: $!";
+ moan "failed to accept new connection: $!"
+ unless $! == EAGAIN || $! == EWOULDBLOCK;
next FD;
}
set_cloexec $nsk;
next FD;
}
set_cloexec $nsk;