From fe3f56ee4710f19c2758d5bc8b32746e07655fb9 Mon Sep 17 00:00:00 2001 From: nbk Date: Sat, 10 Dec 2005 17:07:07 +0000 Subject: [PATCH] Add the option -P to set the port number to use for connection. Based on a patch from Roy M. Divina --- scripts/radsqlrelay | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/scripts/radsqlrelay b/scripts/radsqlrelay index 6c1c2e4..75cc91a 100755 --- a/scripts/radsqlrelay +++ b/scripts/radsqlrelay @@ -52,7 +52,7 @@ sub got_signal() # c2ph says: typedef='s2 l2 i', sizeof=16 my $FLOCK_STRUCT = 's2l2i'; -sub setlock ($;$$) +sub setlock($;$$) { my ($fh, $start, $len) = @_; $start = 0 unless defined $start; @@ -67,13 +67,14 @@ sub setlock ($;$$) sub usage() { print STDERR < 'mysql', b => 'radius', + d => 'mysql', h => 'localhost', - u => 'radius', p => 'radius', + u => 'radius', ); -my $ret = getopts("d:b:fh:u:p:x1?", \%args); +my $ret = getopts("b:d:fh:P:p:u:x1?", \%args); if (!$ret or @ARGV != 1) { usage(); exit 1; @@ -149,14 +150,15 @@ if ($args{'?'}) { } my $data_source; -if ($args{d} eq 'mysql') { +if (lc($args{d}) eq 'mysql') { $data_source = "DBI:mysql:database=$args{b};host=$args{h}"; -} elsif ($args{d} eq 'pg') { +} elsif (lc($args{d}) eq 'pg') { $data_source = "DBI:Pg:dbname=$args{b};host=$args{h}"; } else { print STDERR "error: SQL driver not supported yet: $args{d}\n"; exit 1; } +$data_source .= ";port=$args{P}" if $args{'P'}; $SIG{INT} = \&got_signal; $SIG{TERM} = \&got_signal; -- 2.1.4