Added
Link Here
|
1 |
--- ddclient.in.orig 2022-05-16 00:12:34 UTC |
2 |
+++ ddclient.in |
3 |
@@ -29,6 +29,7 @@ use Getopt::Long; |
4 |
use IO::Socket::INET; |
5 |
use Socket qw(AF_INET AF_INET6 PF_INET PF_INET6); |
6 |
use Sys::Hostname; |
7 |
+use POSIX 'setsid'; |
8 |
|
9 |
use version 0.77; our $VERSION = version->declare('v3.10.0_2'); |
10 |
(my $version = $VERSION->stringify()) =~ s/^v//; |
11 |
@@ -48,9 +49,9 @@ sub subst_var { |
12 |
return $subst; |
13 |
} |
14 |
|
15 |
-my $etc = subst_var('@sysconfdir@', '/etc/ddclient'); |
16 |
-my $cachedir = subst_var('@localstatedir@', '/var') . '/cache/ddclient'; |
17 |
-my $savedir = '/tmp'; |
18 |
+my $etc = subst_var('@sysconfdir@', '%%ETCDIR%%'); |
19 |
+my $cachedir = subst_var('@localstatedir@', '/var') . '/tmp'; |
20 |
+my $savedir = '/var/tmp'; |
21 |
if ($program =~ /test/i) { |
22 |
$etc = '.'; |
23 |
$cachedir = '.'; |
24 |
@@ -68,7 +69,7 @@ use vars qw($file $lineno); |
25 |
local $file = ''; |
26 |
local $lineno = ''; |
27 |
|
28 |
-$ENV{'PATH'} = (exists($ENV{PATH}) ? "$ENV{PATH}:" : "") . "/sbin:/usr/sbin:/bin:/usr/bin:/etc:/usr/lib:"; |
29 |
+$ENV{'PATH'} = (exists($ENV{PATH}) ? "$ENV{PATH}:" : "") . "/sbin:/usr/sbin:/bin:"; |
30 |
|
31 |
our %globals; |
32 |
my ($result, %config, %cache); |
33 |
@@ -1022,6 +1023,9 @@ sub main { |
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 |
@@ -1029,10 +1033,9 @@ sub main { |
44 |
} elsif ($pid) { |
45 |
exit 0; |
46 |
} |
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 |
write_pid(); |
54 |
} |
55 |
|
56 |
@@ -2011,17 +2014,17 @@ sub pipecmd { |
57 |
## execute the command. |
58 |
local *FD; |
59 |
if (!open(FD, $cmd)) { |
60 |
- printf STDERR "%s: cannot execute command %s.\n", $program, $cmd; |
61 |
+ warning("$program: cannot execute command %s.\n", $cmd); |
62 |
|
63 |
} elsif ($stdin && (!print FD "$stdin\n")) { |
64 |
- printf STDERR "%s: failed writting to %s.\n", $program, $cmd; |
65 |
+ warning("$program: failed writing to %s.\n", $cmd); |
66 |
close(FD); |
67 |
|
68 |
} elsif (!close(FD)) { |
69 |
- printf STDERR "%s: failed closing %s.(%s)\n", $program, $cmd, $@; |
70 |
+ warning("$program: failed closing %s.($@)\n", $cmd); |
71 |
|
72 |
} elsif (opt('exec') && $?) { |
73 |
- printf STDERR "%s: failed %s. (%s)\n", $program, $cmd, $@; |
74 |
+ warning("$program: failed %s. ($@)\n", $cmd); |
75 |
|
76 |
} else { |
77 |
$ok = 1; |
78 |
@@ -2461,6 +2464,7 @@ sub fetch_via_socket_io { |
79 |
PeerPort => $port, |
80 |
Proto => 'tcp', |
81 |
MultiHomed => 1, |
82 |
+ SSL_ca_file => '%%LOCALBASE%%/share/certs/ca-root-nss.crt', |
83 |
Timeout => opt('timeout'), |
84 |
); |
85 |
my $socket_class = 'IO::Socket::INET'; |