2018-07-07 20:54:31 +02:00
|
|
|
--- ddclient.orig 2018-05-23 10:25:05 UTC
|
|
|
|
+++ ddclient
|
|
|
|
@@ -25,6 +25,7 @@ use Getopt::Long;
|
2010-08-17 21:22:56 +02:00
|
|
|
use Sys::Hostname;
|
|
|
|
use IO::Socket;
|
2018-07-07 20:54:31 +02:00
|
|
|
use Data::Validate::IP;
|
2010-08-17 21:22:56 +02:00
|
|
|
+use POSIX 'setsid';
|
|
|
|
|
2018-07-07 20:54:31 +02:00
|
|
|
my $version = "3.8.3";
|
|
|
|
my $programd = $0;
|
|
|
|
@@ -33,9 +34,9 @@ my $program = $programd;
|
2014-01-19 03:04:22 +01:00
|
|
|
$program =~ s/d$//;
|
|
|
|
my $now = time;
|
|
|
|
my $hostname = hostname();
|
|
|
|
-my $etc = ($program =~ /test/i) ? './' : '/etc/ddclient/';
|
|
|
|
-my $cachedir = ($program =~ /test/i) ? './' : '/var/cache/ddclient/';
|
|
|
|
-my $savedir = ($program =~ /test/i) ? 'URL/' : '/tmp/';
|
|
|
|
+my $etc = ($program =~ /test/i) ? './' : '%%ETCDIR%%/';
|
|
|
|
+my $cachedir = ($program =~ /test/i) ? './' : '/var/tmp/';
|
|
|
|
+my $savedir = ($program =~ /test/i) ? 'URL/' : '/var/tmp/';
|
|
|
|
my $msgs = '';
|
|
|
|
my $last_msgs = '';
|
|
|
|
|
2018-07-07 20:54:31 +02:00
|
|
|
@@ -43,7 +44,7 @@ use vars qw($file $lineno);
|
2014-01-19 03:04:22 +01:00
|
|
|
local $file = '';
|
|
|
|
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:";
|
|
|
|
|
|
|
|
sub T_ANY {'any'};
|
|
|
|
sub T_STRING {'string'};
|
2018-07-07 20:54:31 +02:00
|
|
|
@@ -792,6 +793,9 @@ if (opt('foreground') || opt('force')) {
|
2011-07-28 23:59:28 +02:00
|
|
|
;
|
|
|
|
} elsif (opt('daemon')) {
|
2010-08-17 21:22:56 +02:00
|
|
|
$SIG{'CHLD'} = 'IGNORE';
|
|
|
|
+ chdir '/';
|
|
|
|
+ open(STDIN, "</dev/null");
|
|
|
|
+ open(STDOUT, ">/dev/null");
|
|
|
|
my $pid = fork;
|
|
|
|
if ($pid < 0) {
|
|
|
|
print STDERR "${program}: can not fork ($!)\n";
|
2018-07-07 20:54:31 +02:00
|
|
|
@@ -799,10 +803,9 @@ if (opt('foreground') || opt('force')) {
|
2010-08-17 21:22:56 +02:00
|
|
|
} elsif ($pid) {
|
|
|
|
exit 0;
|
|
|
|
}
|
|
|
|
+ setsid;
|
|
|
|
$SIG{'CHLD'} = 'DEFAULT';
|
|
|
|
- open(STDOUT, ">/dev/null");
|
|
|
|
- open(STDERR, ">/dev/null");
|
|
|
|
- open(STDIN, "</dev/null");
|
|
|
|
+ open(STDERR, "&STDOUT");
|
|
|
|
}
|
2011-07-28 23:59:28 +02:00
|
|
|
|
|
|
|
# write out the pid file if we're daemon'ized
|
2018-07-07 20:54:31 +02:00
|
|
|
@@ -1595,17 +1598,17 @@ sub pipecmd {
|
2010-08-17 21:22:56 +02:00
|
|
|
## execute the command.
|
|
|
|
local *FD;
|
|
|
|
if (! open(FD, $cmd)) {
|
|
|
|
- printf STDERR "$program: cannot execute command %s.\n", $cmd;
|
2011-07-28 23:59:28 +02:00
|
|
|
+ warning("$program: cannot execute command %s.\n", $cmd);
|
2010-08-17 21:22:56 +02:00
|
|
|
|
|
|
|
} elsif ($stdin && (! print FD "$stdin\n")) {
|
|
|
|
- printf STDERR "$program: failed writting to %s.\n", $cmd;
|
2011-07-28 23:59:28 +02:00
|
|
|
+ warning("$program: failed writing to %s.\n", $cmd);
|
2010-08-17 21:22:56 +02:00
|
|
|
close(FD);
|
|
|
|
|
|
|
|
} elsif (! close(FD)) {
|
|
|
|
- printf STDERR "$program: failed closing %s.($@)\n", $cmd;
|
2011-07-28 23:59:28 +02:00
|
|
|
+ warning("$program: failed closing %s.($@)\n", $cmd);
|
2010-08-17 21:22:56 +02:00
|
|
|
|
|
|
|
} elsif (opt('exec') && $?) {
|
|
|
|
- printf STDERR "$program: failed %s. ($@)\n", $cmd;
|
|
|
|
+ warning("$program: failed %s. ($@)\n", $cmd);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
$ok = 1;
|
2018-07-07 20:54:31 +02:00
|
|
|
@@ -2034,6 +2037,7 @@ sub geturl {
|
2014-01-19 03:04:22 +01:00
|
|
|
$sd = IO::Socket::SSL->new(
|
|
|
|
PeerAddr => $peer,
|
|
|
|
PeerPort => $port,
|
|
|
|
+ SSL_ca_file => '%%LOCALBASE%%/share/certs/ca-root-nss.crt',
|
|
|
|
Proto => 'tcp',
|
|
|
|
MultiHomed => 1,
|
|
|
|
Timeout => opt('timeout'),
|