diff --git a/Changelog b/Changelog index ed9fe44..5496364 100644 --- a/Changelog +++ b/Changelog @@ -19,6 +19,10 @@ cvs - added support for smc-barricade-7004vbr, see patch #1087989 - added support for sitecom-dc202, see patch #1060119 - fixed the error of stripping out '#' in the middle of password, bug #1465932 +- fixed a couple bugs in sample-etc_rc.d_init.d_ddclient and added some extra auto distro detection +- added the validation of values when reading the configuration value. +- this fixes a bug when trying to use periods/intervals in the daemon check times, bug #1209743 +- added timeout option to the IO::Socket call for timing out the initial connection, bug: #1085110 3.6.7 - modified sample-etc_rc.d_init.d_ddclient.lsb (bug #1231930) diff --git a/ddclient b/ddclient index 9d43731..720e752 100755 --- a/ddclient +++ b/ddclient @@ -239,13 +239,13 @@ my %builtinfw = ( 'skip' => 'WAN.IP.*?Address', }, 'netgear-dg834g' => { - 'name netgear-dg834g', + 'name' => 'netgear-dg834g', 'url' => '/setup.cgi?next_file=s_status.htm&todo=cfg_init', 'skip' => '', - } + }, 'netgear-wgt624' => { 'name' => 'Netgear WGT624', - 'url' => '/RST_st_dhcp.htm' + 'url' => '/RST_st_dhcp.htm', 'skip' => 'IP Address', }, 'sveasoft' => { @@ -877,7 +877,9 @@ sub _read_config { warning("program version mismatch; ignoring %s", $file); last; } - warning("whitespace follows the \\ at the end-of-line.\nIf you meant to have a line continuation, remove the trailing whitespace.") + if (/\\\s+$/) { + warning("whitespace follows the \\ at the end-of-line.\nIf you meant to have a line continuation, remove the trailing whitespace."); + } $content .= "$_\n" unless /^#/; # lines contain passwords are a special case, we don't want to @@ -906,12 +908,19 @@ sub _read_config { s/\s*,\s*/,/g; my @args = split; - ## verify that keywords are valid.. + ## verify that keywords are valid...and check the value foreach my $k (keys %locals) { if (!exists $variables{'merged'}{$k}) { - warning("unrecognized keyword '%s' (ignored)", $k); - delete $locals{$k}; - } + warning("unrecognized keyword '%s' (ignored)", $k); + delete $locals{$k}; + } else { + my $def = $variables{'merged'}{$k}; + my $value = check_value($locals{$k}, $def); + if (!defined($value)) { + warning("Invalid Value for keyword '%s' = '%s'", $k, $locals{$k}); + delete $locals{$k}; + } else { $locals{$k} = $value; } + } } if (exists($locals{'host'})) { $args[0] = @args ? "$args[0],$locals{host}" : "$locals{host}"; @@ -1679,11 +1688,23 @@ sub geturl { debug("skipped network connection"); verbose("SENDING:", $request); } elsif ($use_ssl) { - $sd = IO::Socket::SSL->new(PeerAddr => $peer, PeerPort => $port, Proto => 'tcp', MultiHomed => 1); - defined $sd or warning("cannot connect to $peer:$port socket: $@ " . IO::Socket::SSL::errstr()); + $sd = IO::Socket::SSL->new( + PeerAddr => $peer, + PeerPort => $port, + Proto => 'tcp', + MultiHomed => 1, + Timeout => opt('timeout'), + ); + defined $sd or warning("cannot connect to $peer:$port socket: $@ " . IO::Socket::SSL::errstr()); } else { - $sd = IO::Socket::INET->new(PeerAddr => $peer, PeerPort => $port, Proto => 'tcp', MultiHomed => 1); - defined $sd or warning("cannot connect to $peer:$port socket: $@"); + $sd = IO::Socket::INET->new( + PeerAddr => $peer, + PeerPort => $port, + Proto => 'tcp', + MultiHomed => 1, + Timeout => opt('timeout'), + ); + defined $sd or warning("cannot connect to $peer:$port socket: $@"); } if (defined $sd) { @@ -3104,3 +3125,8 @@ sub nic_sitelutions_update { ###################################################################### # vim: ai ts=4 sw=4 tw=78 : + + +__END__ + + diff --git a/sample-etc_rc.d_init.d_ddclient b/sample-etc_rc.d_init.d_ddclient index 0cc68d0..ab6faf6 100755 --- a/sample-etc_rc.d_init.d_ddclient +++ b/sample-etc_rc.d_init.d_ddclient @@ -1,6 +1,4 @@ -#!/bin/sh -# -# $Id$ +#!/bin/bash # # ddclient This shell script takes care of starting and stopping # ddclient. @@ -8,25 +6,61 @@ # chkconfig: 2345 65 35 # description: ddclient provides support for updating dynamic DNS services. -[ -f /etc/ddclient/ddclient.conf ] || exit 0 - -PATH=/usr/sbin:${PATH} -COLUMNS=9999 -export PATH COLUMNS - +CONF=/etc/ddclient/ddclient.conf program=ddclient + +[ -f $CONF ] || exit 0 + +system=unknown +if [ -f /etc/fedora-release ]; then + system=fedora +elif [ -f /etc/redhat-release ]; then + system=redhat +elif [ -f /etc/debian_version ]; then + system=debian +fi + +PID='' +if [ "$system" = "fedora" ] || [ "$system" = "redhat" ]; then + . /etc/init.d/functions + PID=`pidofproc $program` +else + PID=`ps -aef | grep "$program - sleep" | grep -v grep | awk '{print $2}'` +fi + +PATH=/usr/sbin:/usr/local/sbin:${PATH} +export PATH + # See how we were called. case "$1" in start) # Start daemon. + DELAY=`grep -v '^\s*#' $CONF | grep -i -m 1 "daemon" | awk -F '=' '{print $2}'` + if [ -z "$DELAY" ] ; then + DELAY="-daemon 300" + else + DELAY='' + fi echo -n "Starting ddclient: " - ddclient -daemon 300 + if [ "$system" = "fedora" ] || [ "$system" = "redhat" ]; then + daemon $program $DELAY + else + ddclient $DELAY + fi echo ;; stop) # Stop daemon. echo -n "Shutting down ddclient: " - kill `ps -aef | awk '/[ \/]perl.*ddclient/ { print $2}'` + if [ -n "$PID" ] ; then + if [ "$system" = "fedora" ] || [ "$system" = "redhat" ]; then + killproc $program + else + kill $PID + fi + else + echo "ddclient is not running" + fi echo ;; restart) @@ -34,15 +68,18 @@ case "$1" in $0 start ;; status) - pids=`ps -aef | awk '/[ \/]perl.*ddclient/ { print $2}'` - if test "$pids" - then - for p in $pids - do - echo "$program (pid $p) is running" - done - else - echo "$program is stopped" + if [ "$system" = "fedora" ] || [ "$system" = "redhat" ]; then + status $program + else + if test "$PID" + then + for p in $PID + do + echo "$program (pid $p) is running" + done + else + echo "$program is stopped" + fi fi ;; *)