|
Added
Link Here
|
| 1 |
--- ddclient.in.orig 2023-10-25 19:22:47 UTC |
| 2 |
+++ ddclient.in |
| 3 |
@@ -20,6 +20,7 @@ use File::Path qw(make_path); |
| 4 |
use File::Temp; |
| 5 |
use Getopt::Long; |
| 6 |
use Sys::Hostname; |
| 7 |
+use POSIX 'setsid'; |
| 8 |
|
| 9 |
use version 0.77; our $VERSION = version->declare('3.11.1'); |
| 10 |
my $version = $VERSION->stringify(); |
| 11 |
@@ -39,9 +40,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@', '/usr/local/etc'); |
| 19 |
+my $cachedir = subst_var('@localstatedir@', '/var') . '/tmp'; |
| 20 |
+my $savedir = '/var/tmp'; |
| 21 |
if ($program =~ /test/i) { |
| 22 |
$etc = '.'; |
| 23 |
$cachedir = '.'; |
| 24 |
@@ -59,7 +60,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/local/sbin:/bin:"; |
| 30 |
|
| 31 |
our %globals; |
| 32 |
my ($result, %config, %cache); |
| 33 |
@@ -1131,6 +1132,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 |
@@ -1138,10 +1142,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 |
@@ -2164,17 +2167,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; |