|
Lines 1-85
Link Here
|
| 1 |
--- ddclient.orig 2018-05-23 10:25:05 UTC |
1 |
--- ddclient.in.orig 2022-05-15 20:12:34.000000000 -0400 |
| 2 |
+++ ddclient |
2 |
+++ ddclient.in |
| 3 |
@@ -25,6 +25,7 @@ use Getopt::Long; |
3 |
@@ -29,6 +29,7 @@ |
|
|
4 |
use IO::Socket::INET; |
| 5 |
use Socket qw(AF_INET AF_INET6 PF_INET PF_INET6); |
| 4 |
use Sys::Hostname; |
6 |
use Sys::Hostname; |
| 5 |
use IO::Socket; |
|
|
| 6 |
use Data::Validate::IP; |
| 7 |
+use POSIX 'setsid'; |
7 |
+use POSIX 'setsid'; |
| 8 |
|
8 |
|
| 9 |
my $version = "3.8.3"; |
9 |
use version 0.77; our $VERSION = version->declare('v3.10.0_2'); |
| 10 |
my $programd = $0; |
10 |
(my $version = $VERSION->stringify()) =~ s/^v//; |
| 11 |
@@ -33,9 +34,9 @@ my $program = $programd; |
11 |
@@ -1022,6 +1023,9 @@ |
| 12 |
$program =~ s/d$//; |
12 |
; |
| 13 |
my $now = time; |
13 |
} elsif (opt('daemon')) { |
| 14 |
my $hostname = hostname(); |
14 |
$SIG{'CHLD'} = 'IGNORE'; |
| 15 |
-my $etc = ($program =~ /test/i) ? './' : '/etc/ddclient/'; |
15 |
+ chdir '/'; |
| 16 |
-my $cachedir = ($program =~ /test/i) ? './' : '/var/cache/ddclient/'; |
16 |
+ open(STDIN, "</dev/null"); |
| 17 |
-my $savedir = ($program =~ /test/i) ? 'URL/' : '/tmp/'; |
17 |
+ open(STDOUT, ">/dev/null"); |
| 18 |
+my $etc = ($program =~ /test/i) ? './' : '%%ETCDIR%%/'; |
18 |
my $pid = fork; |
| 19 |
+my $cachedir = ($program =~ /test/i) ? './' : '/var/tmp/'; |
19 |
if ($pid < 0) { |
| 20 |
+my $savedir = ($program =~ /test/i) ? 'URL/' : '/var/tmp/'; |
20 |
print STDERR "${program}: can not fork ($!)\n"; |
| 21 |
my $msgs = ''; |
21 |
@@ -1029,10 +1033,9 @@ |
| 22 |
my $last_msgs = ''; |
22 |
} elsif ($pid) { |
| 23 |
|
23 |
exit 0; |
| 24 |
@@ -43,7 +44,7 @@ use vars qw($file $lineno); |
24 |
} |
| 25 |
local $file = ''; |
25 |
+ setsid; |
| 26 |
local $lineno = ''; |
26 |
$SIG{'CHLD'} = 'DEFAULT'; |
| 27 |
|
27 |
- open(STDOUT, ">/dev/null"); |
| 28 |
-$ENV{'PATH'} = (exists($ENV{PATH}) ? "$ENV{PATH}:" : "") . "/sbin:/usr/sbin:/bin:/usr/bin:/etc:/usr/lib:"; |
28 |
- open(STDERR, ">/dev/null"); |
| 29 |
+$ENV{'PATH'} = (exists($ENV{PATH}) ? "$ENV{PATH}:" : "") . "/sbin:/usr/sbin:/bin:"; |
29 |
- open(STDIN, "</dev/null"); |
| 30 |
|
30 |
+ open(STDERR, "&STDOUT"); |
| 31 |
sub T_ANY {'any'}; |
31 |
write_pid(); |
| 32 |
sub T_STRING {'string'}; |
|
|
| 33 |
@@ -792,6 +793,9 @@ if (opt('foreground') || opt('force')) { |
| 34 |
; |
| 35 |
} elsif (opt('daemon')) { |
| 36 |
$SIG{'CHLD'} = 'IGNORE'; |
| 37 |
+ chdir '/'; |
| 38 |
+ open(STDIN, "</dev/null"); |
| 39 |
+ open(STDOUT, ">/dev/null"); |
| 40 |
my $pid = fork; |
| 41 |
if ($pid < 0) { |
| 42 |
print STDERR "${program}: can not fork ($!)\n"; |
| 43 |
@@ -799,10 +803,9 @@ if (opt('foreground') || opt('force')) { |
| 44 |
} elsif ($pid) { |
| 45 |
exit 0; |
| 46 |
} |
32 |
} |
| 47 |
+ setsid; |
|
|
| 48 |
$SIG{'CHLD'} = 'DEFAULT'; |
| 49 |
- open(STDOUT, ">/dev/null"); |
| 50 |
- open(STDERR, ">/dev/null"); |
| 51 |
- open(STDIN, "</dev/null"); |
| 52 |
+ open(STDERR, "&STDOUT"); |
| 53 |
} |
| 54 |
|
33 |
|
| 55 |
# write out the pid file if we're daemon'ized |
34 |
@@ -2011,17 +2014,17 @@ |
| 56 |
@@ -1595,17 +1598,17 @@ sub pipecmd { |
|
|
| 57 |
## execute the command. |
35 |
## execute the command. |
| 58 |
local *FD; |
36 |
local *FD; |
| 59 |
if (! open(FD, $cmd)) { |
37 |
if (!open(FD, $cmd)) { |
| 60 |
- printf STDERR "$program: cannot execute command %s.\n", $cmd; |
38 |
- printf STDERR "%s: cannot execute command %s.\n", $program, $cmd; |
| 61 |
+ warning("$program: cannot execute command %s.\n", $cmd); |
39 |
+ warning("%s: cannot execute command %s.\n", $program, $cmd); |
| 62 |
|
40 |
|
| 63 |
} elsif ($stdin && (! print FD "$stdin\n")) { |
41 |
} elsif ($stdin && (!print FD "$stdin\n")) { |
| 64 |
- printf STDERR "$program: failed writting to %s.\n", $cmd; |
42 |
- printf STDERR "%s: failed writting to %s.\n", $program, $cmd; |
| 65 |
+ warning("$program: failed writing to %s.\n", $cmd); |
43 |
+ warning("%s: failed writting to %s.\n", $program, $cmd); |
| 66 |
close(FD); |
44 |
close(FD); |
| 67 |
|
45 |
|
| 68 |
} elsif (! close(FD)) { |
46 |
} elsif (!close(FD)) { |
| 69 |
- printf STDERR "$program: failed closing %s.($@)\n", $cmd; |
47 |
- printf STDERR "%s: failed closing %s.(%s)\n", $program, $cmd, $@; |
| 70 |
+ warning("$program: failed closing %s.($@)\n", $cmd); |
48 |
+ warning("%s: failed closing %s.(%s)\n", $program, $cmd, $@); |
| 71 |
|
49 |
|
| 72 |
} elsif (opt('exec') && $?) { |
50 |
} elsif (opt('exec') && $?) { |
| 73 |
- printf STDERR "$program: failed %s. ($@)\n", $cmd; |
51 |
- printf STDERR "%s: failed %s. (%s)\n", $program, $cmd, $@; |
| 74 |
+ warning("$program: failed %s. ($@)\n", $cmd); |
52 |
+ warning("%s: failed %s. (%s)\n", $program, $cmd, $@); |
| 75 |
|
53 |
|
| 76 |
} else { |
54 |
} else { |
| 77 |
$ok = 1; |
55 |
$ok = 1; |
| 78 |
@@ -2034,6 +2037,7 @@ sub geturl { |
|
|
| 79 |
$sd = IO::Socket::SSL->new( |
| 80 |
PeerAddr => $peer, |
| 81 |
PeerPort => $port, |
| 82 |
+ SSL_ca_file => '%%LOCALBASE%%/share/certs/ca-root-nss.crt', |
| 83 |
Proto => 'tcp', |
| 84 |
MultiHomed => 1, |
| 85 |
Timeout => opt('timeout'), |