Changeset View
Changeset View
Standalone View
Standalone View
dns/ddclient/files/patch-ddclient
--- ./ddclient.orig 2011-07-25 19:41:39.000000000 -0700 | --- ddclient.orig 2015-05-30 21:37:38.000000000 +1200 | ||||
+++ ./ddclient 2011-07-25 19:41:48.000000000 -0700 | +++ ddclient 2017-02-08 11:00:23.812579000 +1300 | ||||
@@ -19,6 +18,7 @@ | @@ -25,6 +25,7 @@ | ||||
use Getopt::Long; | use Getopt::Long; | ||||
use Sys::Hostname; | use Sys::Hostname; | ||||
use IO::Socket; | use IO::Socket; | ||||
+use POSIX 'setsid'; | +use POSIX 'setsid'; | ||||
my ($VERSION) = q$Revision: 157 $ =~ /(\d+)/; | # my ($VERSION) = q$Revision: 184 $ =~ /(\d+)/; | ||||
@@ -29,9 +29,9 @@ | @@ -35,9 +36,9 @@ | ||||
$program =~ s/d$//; | $program =~ s/d$//; | ||||
my $now = time; | my $now = time; | ||||
my $hostname = hostname(); | my $hostname = hostname(); | ||||
-my $etc = ($program =~ /test/i) ? './' : '/etc/ddclient/'; | -my $etc = ($program =~ /test/i) ? './' : '/etc/ddclient/'; | ||||
-my $cachedir = ($program =~ /test/i) ? './' : '/var/cache/ddclient/'; | -my $cachedir = ($program =~ /test/i) ? './' : '/var/cache/ddclient/'; | ||||
-my $savedir = ($program =~ /test/i) ? 'URL/' : '/tmp/'; | -my $savedir = ($program =~ /test/i) ? 'URL/' : '/tmp/'; | ||||
+my $etc = ($program =~ /test/i) ? './' : '%%ETCDIR%%/'; | +my $etc = ($program =~ /test/i) ? './' : '%%ETCDIR%%/'; | ||||
+my $cachedir = ($program =~ /test/i) ? './' : '/var/tmp/'; | +my $cachedir = ($program =~ /test/i) ? './' : '/var/tmp/'; | ||||
+my $savedir = ($program =~ /test/i) ? 'URL/' : '/var/tmp/'; | +my $savedir = ($program =~ /test/i) ? 'URL/' : '/var/tmp/'; | ||||
my $msgs = ''; | my $msgs = ''; | ||||
my $last_msgs = ''; | my $last_msgs = ''; | ||||
@@ -39,7 +39,7 @@ | @@ -45,7 +46,7 @@ | ||||
local $file = ''; | local $file = ''; | ||||
local $lineno = ''; | local $lineno = ''; | ||||
-$ENV{'PATH'} = (exists($ENV{PATH}) ? "$ENV{PATH}:" : "") . "/sbin:/usr/sbin:/bin:/usr/bin:/etc:/usr/lib:"; | -$ENV{'PATH'} = (exists($ENV{PATH}) ? "$ENV{PATH}:" : "") . "/sbin:/usr/sbin:/bin:/usr/bin:/etc:/usr/lib:"; | ||||
+$ENV{'PATH'} = (exists($ENV{PATH}) ? "$ENV{PATH}:" : "") . "/sbin:/usr/sbin:/bin:"; | +$ENV{'PATH'} = (exists($ENV{PATH}) ? "$ENV{PATH}:" : "") . "/sbin:/usr/sbin:/bin:"; | ||||
sub T_ANY {'any'}; | sub T_ANY {'any'}; | ||||
sub T_STRING {'string'}; | sub T_STRING {'string'}; | ||||
@@ -678,6 +678,9 @@ | @@ -743,6 +744,9 @@ | ||||
; | ; | ||||
} elsif (opt('daemon')) { | } elsif (opt('daemon')) { | ||||
$SIG{'CHLD'} = 'IGNORE'; | $SIG{'CHLD'} = 'IGNORE'; | ||||
+ chdir '/'; | + chdir '/'; | ||||
+ open(STDIN, "</dev/null"); | + open(STDIN, "</dev/null"); | ||||
+ open(STDOUT, ">/dev/null"); | + open(STDOUT, ">/dev/null"); | ||||
my $pid = fork; | my $pid = fork; | ||||
if ($pid < 0) { | if ($pid < 0) { | ||||
print STDERR "${program}: can not fork ($!)\n"; | print STDERR "${program}: can not fork ($!)\n"; | ||||
@@ -685,10 +688,9 @@ | @@ -750,10 +754,9 @@ | ||||
} elsif ($pid) { | } elsif ($pid) { | ||||
exit 0; | exit 0; | ||||
} | } | ||||
+ setsid; | + setsid; | ||||
$SIG{'CHLD'} = 'DEFAULT'; | $SIG{'CHLD'} = 'DEFAULT'; | ||||
- open(STDOUT, ">/dev/null"); | - open(STDOUT, ">/dev/null"); | ||||
- open(STDERR, ">/dev/null"); | - open(STDERR, ">/dev/null"); | ||||
- open(STDIN, "</dev/null"); | - open(STDIN, "</dev/null"); | ||||
+ open(STDERR, "&STDOUT"); | + open(STDERR, "&STDOUT"); | ||||
} | } | ||||
# write out the pid file if we're daemon'ized | # write out the pid file if we're daemon'ized | ||||
@@ -1478,17 +1480,17 @@ | @@ -1544,17 +1547,17 @@ | ||||
## execute the command. | ## execute the command. | ||||
local *FD; | local *FD; | ||||
if (! open(FD, $cmd)) { | if (! open(FD, $cmd)) { | ||||
- printf STDERR "$program: cannot execute command %s.\n", $cmd; | - printf STDERR "$program: cannot execute command %s.\n", $cmd; | ||||
+ warning("$program: cannot execute command %s.\n", $cmd); | + warning("$program: cannot execute command %s.\n", $cmd); | ||||
} elsif ($stdin && (! print FD "$stdin\n")) { | } elsif ($stdin && (! print FD "$stdin\n")) { | ||||
- printf STDERR "$program: failed writting to %s.\n", $cmd; | - printf STDERR "$program: failed writting to %s.\n", $cmd; | ||||
+ warning("$program: failed writing to %s.\n", $cmd); | + warning("$program: failed writing to %s.\n", $cmd); | ||||
close(FD); | close(FD); | ||||
} elsif (! close(FD)) { | } elsif (! close(FD)) { | ||||
- printf STDERR "$program: failed closing %s.($@)\n", $cmd; | - printf STDERR "$program: failed closing %s.($@)\n", $cmd; | ||||
+ warning("$program: failed closing %s.($@)\n", $cmd); | + warning("$program: failed closing %s.($@)\n", $cmd); | ||||
} elsif (opt('exec') && $?) { | } elsif (opt('exec') && $?) { | ||||
- printf STDERR "$program: failed %s. ($@)\n", $cmd; | - printf STDERR "$program: failed %s. ($@)\n", $cmd; | ||||
+ warning("$program: failed %s. ($@)\n", $cmd); | + warning("$program: failed %s. ($@)\n", $cmd); | ||||
} else { | } else { | ||||
$ok = 1; | $ok = 1; | ||||
@@ -1878,6 +1880,7 @@ | @@ -1878,13 +1881,13 @@ | ||||
## load_json_support | |||||
###################################################################### | |||||
sub load_json_support { | |||||
- my $json_loaded = eval {require JSON::Any}; | |||||
+ my $json_loaded = eval {require JSON::PP}; | |||||
unless ($json_loaded) { | |||||
fatal(<<"EOM"); | |||||
-Error loading the Perl module JSON::Any needed for cloudflare update. | |||||
+Error loading the Perl module JSON::PP needed for cloudflare update. | |||||
EOM | |||||
} | |||||
- import JSON::Any; | |||||
+ import JSON::PP (qw/decode_json/); | |||||
} | |||||
###################################################################### | |||||
## geturl | |||||
@@ -1957,6 +1960,7 @@ | |||||
$sd = IO::Socket::SSL->new( | $sd = IO::Socket::SSL->new( | ||||
PeerAddr => $peer, | PeerAddr => $peer, | ||||
PeerPort => $port, | PeerPort => $port, | ||||
+ SSL_ca_file => '%%LOCALBASE%%/share/certs/ca-root-nss.crt', | + SSL_ca_file => '%%LOCALBASE%%/share/certs/ca-root-nss.crt', | ||||
Proto => 'tcp', | Proto => 'tcp', | ||||
MultiHomed => 1, | MultiHomed => 1, | ||||
Timeout => opt('timeout'), | Timeout => opt('timeout'), | ||||
@@ -4096,9 +4100,9 @@ | |||||
# Strip header | |||||
$reply =~ s/^.*?\n\n//s; | |||||
- my $response = JSON::Any->jsonToObj($reply); | |||||
- if ($response->{result} eq 'error') { | |||||
- failed ("%s", $response->{msg}); | |||||
+ my $response = eval {decode_json($reply)}; | |||||
+ if (!defined $response || !defined $response->{result}) { | |||||
+ failed ("invalid json or result."); | |||||
next; | |||||
} | |||||
@@ -4128,9 +4132,9 @@ | |||||
# Strip header | |||||
$reply =~ s/^.*?\n\n//s; | |||||
- $response = JSON::Any->jsonToObj($reply); | |||||
- if ($response->{result} eq 'error') { | |||||
- failed ("%s", $response->{msg}); | |||||
+ $response = eval {decode_json($reply)}; | |||||
+ if (!defined $response || !defined $response->{result}) { | |||||
+ failed ("invalid json or result."); | |||||
} else { | |||||
success ("%s -- Updated Successfully to %s", $domain, $ip); | |||||