aboutsummaryrefslogtreecommitdiff
path: root/dns/ddclient/files/patch-ddclient
blob: 45d08058741a4b9a986586808f482bd497e1da32 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
--- ddclient.orig	2018-05-23 10:25:05 UTC
+++ ddclient
@@ -25,6 +25,7 @@ use Getopt::Long;
 use Sys::Hostname;
 use IO::Socket;
 use Data::Validate::IP;
+use POSIX 'setsid';
 
 my $version  = "3.8.3";
 my $programd  = $0; 
@@ -33,9 +34,9 @@ my $program   = $programd;
 $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 = '';
 
@@ -43,7 +44,7 @@ use vars qw($file $lineno);
 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'};
@@ -792,6 +793,9 @@ if (opt('foreground') || opt('force')) {
     ;
 } elsif (opt('daemon')) {
     $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";
@@ -799,10 +803,9 @@ if (opt('foreground') || opt('force')) {
     } elsif ($pid) {
 	exit 0;
     }
+    setsid;
     $SIG{'CHLD'}   = 'DEFAULT';
-    open(STDOUT, ">/dev/null");
-    open(STDERR, ">/dev/null");
-    open(STDIN,  "</dev/null");
+    open(STDERR, "&STDOUT");
 }
 
 # write out the pid file if we're daemon'ized
@@ -1595,17 +1598,17 @@ sub pipecmd {
     ## execute the command.
     local *FD;
     if (! open(FD, $cmd)) {
-	printf STDERR "$program: cannot execute command %s.\n", $cmd;
+	warning("$program: cannot execute command %s.\n", $cmd);
 
     } elsif ($stdin && (! print FD "$stdin\n")) {
-	printf STDERR "$program: failed writting to %s.\n", $cmd;
+	warning("$program: failed writing to %s.\n", $cmd);
 	close(FD);
 
     } elsif (! close(FD)) {
-	printf STDERR "$program: failed closing %s.($@)\n", $cmd;
+	warning("$program: failed closing %s.($@)\n", $cmd);
 
     } elsif (opt('exec') && $?) {
-	printf STDERR "$program: failed %s. ($@)\n", $cmd;
+	warning("$program: failed %s. ($@)\n", $cmd);
 
     } else {
 	$ok = 1;
@@ -2034,6 +2037,7 @@ sub geturl {
 	    $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'),