aboutsummaryrefslogtreecommitdiffstats
path: root/dns/ddclient/files/patch-ddclient
blob: 5a1c51e7aa7b88653cc2a6206049669931f77509 (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
--- ./ddclient.orig 2009-01-27 20:14:02.000000000 +0100
+++ ./ddclient  2010-08-17 20:13:00.000000000 +0200
@@ -1,4 +1,3 @@
-#!/usr/bin/perl -w
 #!/usr/local/bin/perl -w
 ######################################################################
 # $Id: ddclient 106 2008-12-04 18:05:23Z wimpunk $
@@ -19,6 +18,7 @@
 use Getopt::Long;
 use Sys::Hostname;
 use IO::Socket;
+use POSIX 'setsid';
 
 my $version  = "3.8.0";
 my $programd  = $0; 
@@ -625,6 +625,9 @@
 $SIG{'KILL'}   = sub { $caught_kill = 1; };
 if (opt('daemon') && !opt('force')) {
     $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";
@@ -632,11 +635,10 @@
     } elsif ($pid) {
    exit 0;
     }
+    setsid;
     $SIG{'CHLD'}   = 'DEFAULT';
     $opt{'syslog'} = 1;
-    open(STDOUT, ">/dev/null");
-    open(STDERR, ">/dev/null");
-    open(STDIN,  "</dev/null");
+    open(STDERR, "&STDOUT");
 
     write_pid();
 }
@@ -1404,17 +1406,17 @@
     ## 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;