Lines 1-21
Link Here
|
1 |
--- ./ddclient.orig 2009-01-27 20:14:02.000000000 +0100 |
1 |
--- ./ddclient.orig 2011-07-25 19:41:39.000000000 -0700 |
2 |
+++ ./ddclient 2010-08-17 20:13:00.000000000 +0200 |
2 |
+++ ./ddclient 2011-07-25 19:41:48.000000000 -0700 |
3 |
@@ -1,4 +1,3 @@ |
3 |
@@ -1,4 +1,3 @@ |
4 |
-#!/usr/bin/perl -w |
4 |
-#!/usr/bin/perl -w |
5 |
#!/usr/local/bin/perl -w |
5 |
#!/usr/local/bin/perl -w |
6 |
###################################################################### |
6 |
###################################################################### |
7 |
# $Id: ddclient 106 2008-12-04 18:05:23Z wimpunk $ |
7 |
# $Id: ddclient 130 2011-07-11 21:02:07Z wimpunk $ |
8 |
@@ -19,6 +18,7 @@ |
8 |
@@ -19,6 +18,7 @@ |
9 |
use Getopt::Long; |
9 |
use Getopt::Long; |
10 |
use Sys::Hostname; |
10 |
use Sys::Hostname; |
11 |
use IO::Socket; |
11 |
use IO::Socket; |
12 |
+use POSIX 'setsid'; |
12 |
+use POSIX 'setsid'; |
13 |
|
13 |
|
14 |
my $version = "3.8.0"; |
14 |
my ($VERSION) = q$Revision: 130 $ =~ /(\d+)/; |
15 |
my $programd = $0; |
15 |
|
16 |
@@ -625,6 +625,9 @@ |
16 |
@@ -668,6 +668,9 @@ |
17 |
$SIG{'KILL'} = sub { $caught_kill = 1; }; |
17 |
; |
18 |
if (opt('daemon') && !opt('force')) { |
18 |
} elsif (opt('daemon')) { |
19 |
$SIG{'CHLD'} = 'IGNORE'; |
19 |
$SIG{'CHLD'} = 'IGNORE'; |
20 |
+ chdir '/'; |
20 |
+ chdir '/'; |
21 |
+ open(STDIN, "</dev/null"); |
21 |
+ open(STDIN, "</dev/null"); |
Lines 23-57
Link Here
|
23 |
my $pid = fork; |
23 |
my $pid = fork; |
24 |
if ($pid < 0) { |
24 |
if ($pid < 0) { |
25 |
print STDERR "${program}: can not fork ($!)\n"; |
25 |
print STDERR "${program}: can not fork ($!)\n"; |
26 |
@@ -632,11 +635,10 @@ |
26 |
@@ -675,10 +678,9 @@ |
27 |
} elsif ($pid) { |
27 |
} elsif ($pid) { |
28 |
exit 0; |
28 |
exit 0; |
29 |
} |
29 |
} |
30 |
+ setsid; |
30 |
+ setsid; |
31 |
$SIG{'CHLD'} = 'DEFAULT'; |
31 |
$SIG{'CHLD'} = 'DEFAULT'; |
32 |
$opt{'syslog'} = 1; |
|
|
33 |
- open(STDOUT, ">/dev/null"); |
32 |
- open(STDOUT, ">/dev/null"); |
34 |
- open(STDERR, ">/dev/null"); |
33 |
- open(STDERR, ">/dev/null"); |
35 |
- open(STDIN, "</dev/null"); |
34 |
- open(STDIN, "</dev/null"); |
36 |
+ open(STDERR, "&STDOUT"); |
35 |
+ open(STDERR, "&STDOUT"); |
37 |
|
|
|
38 |
write_pid(); |
39 |
} |
36 |
} |
40 |
@@ -1404,17 +1406,17 @@ |
37 |
|
|
|
38 |
# write out the pid file if we're daemon'ized |
39 |
@@ -1463,17 +1465,17 @@ |
41 |
## execute the command. |
40 |
## execute the command. |
42 |
local *FD; |
41 |
local *FD; |
43 |
if (! open(FD, $cmd)) { |
42 |
if (! open(FD, $cmd)) { |
44 |
- printf STDERR "$program: cannot execute command %s.\n", $cmd; |
43 |
- printf STDERR "$program: cannot execute command %s.\n", $cmd; |
45 |
+ warning("$program: cannot execute command %s.\n", $cmd); |
44 |
+ warning("$program: cannot execute command %s.\n", $cmd); |
46 |
|
45 |
|
47 |
} elsif ($stdin && (! print FD "$stdin\n")) { |
46 |
} elsif ($stdin && (! print FD "$stdin\n")) { |
48 |
- printf STDERR "$program: failed writting to %s.\n", $cmd; |
47 |
- printf STDERR "$program: failed writting to %s.\n", $cmd; |
49 |
+ warning("$program: failed writing to %s.\n", $cmd); |
48 |
+ warning("$program: failed writing to %s.\n", $cmd); |
50 |
close(FD); |
49 |
close(FD); |
51 |
|
50 |
|
52 |
} elsif (! close(FD)) { |
51 |
} elsif (! close(FD)) { |
53 |
- printf STDERR "$program: failed closing %s.($@)\n", $cmd; |
52 |
- printf STDERR "$program: failed closing %s.($@)\n", $cmd; |
54 |
+ warning("$program: failed closing %s.($@)\n", $cmd); |
53 |
+ warning("$program: failed closing %s.($@)\n", $cmd); |
55 |
|
54 |
|
56 |
} elsif (opt('exec') && $?) { |
55 |
} elsif (opt('exec') && $?) { |
57 |
- printf STDERR "$program: failed %s. ($@)\n", $cmd; |
56 |
- printf STDERR "$program: failed %s. ($@)\n", $cmd; |