~ubuntu-branches/ubuntu/raring/autofs5/raring

« back to all changes in this revision

Viewing changes to debian/patches/01UPSTREAM_autofs-5.0.4-fix-return-start-status-on-fail.dpatch

  • Committer: Bazaar Package Importer
  • Author(s): Jan Christoph Nordholz
  • Date: 2009-08-28 21:24:14 UTC
  • mfrom: (5.1.2 squeeze)
  • Revision ID: james.westby@ubuntu.com-20090828212414-z9xvmo5kdpm26vxv
Tags: 5.0.4-3
* Fix LSB initscript header to use keywords that
  insserv knows about. Closes: #541841.
* Bump Standards version to 3.8.3.
  * Add README.source.

* Upload sponsored by Petter Reinholdtsen.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#! /bin/sh /usr/share/dpatch/dpatch-run
 
2
## 01UPSTREAM_autofs-5.0.4-fix-return-start-status-on-fail.patch
 
3
##
 
4
## DP: Upstream patch on top of 5.0.4.
 
5
 
 
6
@DPATCH@
 
7
autofs-5.0.4 - fix return start status on fail
 
8
 
 
9
From: Ian Kent <raven@themaw.net>
 
10
 
 
11
We're not returning the status to the parent when automount(8) is waiting
 
12
for the daemon to finish its startup.
 
13
---
 
14
 
 
15
 CHANGELOG          |    1 +
 
16
 daemon/automount.c |   27 +++++++++++++++++++++------
 
17
 2 files changed, 22 insertions(+), 6 deletions(-)
 
18
 
 
19
 
 
20
diff --git a/CHANGELOG b/CHANGELOG
 
21
index fdde400..2cb35dc 100644
 
22
--- a/CHANGELOG
 
23
+++ b/CHANGELOG
 
24
@@ -27,6 +27,7 @@
 
25
 - add WITH_LIBTIRPC to -V status report.
 
26
 - add nfs mount protocol default configuration option.
 
27
 - fix bad token declaration in master map parser.
 
28
+- fix return start status on fail.
 
29
 
 
30
 4/11/2008 autofs-5.0.4
 
31
 -----------------------
 
32
diff --git a/daemon/automount.c b/daemon/automount.c
 
33
index 776c92c..80691fa 100644
 
34
--- a/daemon/automount.c
 
35
+++ b/daemon/automount.c
 
36
@@ -60,7 +60,7 @@ long global_negative_timeout = -1;
 
37
 int do_force_unlink = 0;               /* Forceably unlink mount tree at startup */
 
38
 
 
39
 static int start_pipefd[2];
 
40
-static int st_stat = 0;
 
41
+static int st_stat = 1;
 
42
 static int *pst_stat = &st_stat;
 
43
 static pthread_t state_mach_thid;
 
44
 
 
45
@@ -1046,6 +1046,7 @@ static void become_daemon(unsigned foreground, unsigned daemon_check)
 
46
 {
 
47
        FILE *pidfp;
 
48
        char buf[MAX_ERR_BUF];
 
49
+       int res;
 
50
        pid_t pid;
 
51
 
 
52
        /* Don't BUSY any directories unnecessarily */
 
53
@@ -1072,10 +1073,9 @@ static void become_daemon(unsigned foreground, unsigned daemon_check)
 
54
        } else {
 
55
                pid = fork();
 
56
                if (pid > 0) {
 
57
-                       int r;
 
58
                        close(start_pipefd[1]);
 
59
-                       r = read(start_pipefd[0], pst_stat, sizeof(*pst_stat));
 
60
-                       if (r < 0)
 
61
+                       res = read(start_pipefd[0], pst_stat, sizeof(*pst_stat));
 
62
+                       if (res < 0)
 
63
                                exit(1);
 
64
                        exit(*pst_stat);
 
65
                } else if (pid < 0) {
 
66
@@ -1088,8 +1088,13 @@ static void become_daemon(unsigned foreground, unsigned daemon_check)
 
67
                if (daemon_check && !aquire_flag_file()) {
 
68
                        fprintf(stderr, "%s: program is already running.\n",
 
69
                                program);
 
70
+                       /* Return success if already running */
 
71
+                       st_stat = 0;
 
72
+                       res = write(start_pipefd[1], pst_stat, sizeof(*pst_stat));
 
73
+                       if (res < 0)
 
74
+                               exit(1);
 
75
                        close(start_pipefd[1]);
 
76
-                       exit(1);
 
77
+                       exit(*pst_stat);
 
78
                }
 
79
 
 
80
                /*
 
81
@@ -1099,8 +1104,9 @@ static void become_daemon(unsigned foreground, unsigned daemon_check)
 
82
                if (setsid() == -1) {
 
83
                        char *estr = strerror_r(errno, buf, MAX_ERR_BUF);
 
84
                        fprintf(stderr, "setsid: %s", estr);
 
85
+                       res = write(start_pipefd[1], pst_stat, sizeof(*pst_stat));
 
86
                        close(start_pipefd[1]);
 
87
-                       exit(1);
 
88
+                       exit(*pst_stat);
 
89
                }
 
90
                log_to_syslog();
 
91
        }
 
92
@@ -1991,6 +1997,7 @@ int main(int argc, char *argv[])
 
93
        if (!master_list) {
 
94
                logerr("%s: can't create master map %s",
 
95
                        program, argv[0]);
 
96
+               res = write(start_pipefd[1], pst_stat, sizeof(*pst_stat));
 
97
                close(start_pipefd[1]);
 
98
                release_flag_file();
 
99
                exit(1);
 
100
@@ -1999,6 +2006,7 @@ int main(int argc, char *argv[])
 
101
        if (pthread_attr_init(&th_attr)) {
 
102
                logerr("%s: failed to init thread attribute struct!",
 
103
                     program);
 
104
+               res = write(start_pipefd[1], pst_stat, sizeof(*pst_stat));
 
105
                close(start_pipefd[1]);
 
106
                release_flag_file();
 
107
                exit(1);
 
108
@@ -2007,6 +2015,7 @@ int main(int argc, char *argv[])
 
109
        if (pthread_attr_init(&th_attr_detached)) {
 
110
                logerr("%s: failed to init thread attribute struct!",
 
111
                     program);
 
112
+               res = write(start_pipefd[1], pst_stat, sizeof(*pst_stat));
 
113
                close(start_pipefd[1]);
 
114
                release_flag_file();
 
115
                exit(1);
 
116
@@ -2016,6 +2025,7 @@ int main(int argc, char *argv[])
 
117
                        &th_attr_detached, PTHREAD_CREATE_DETACHED)) {
 
118
                logerr("%s: failed to set detached thread attribute!",
 
119
                     program);
 
120
+               res = write(start_pipefd[1], pst_stat, sizeof(*pst_stat));
 
121
                close(start_pipefd[1]);
 
122
                release_flag_file();
 
123
                exit(1);
 
124
@@ -2026,6 +2036,7 @@ int main(int argc, char *argv[])
 
125
                        &th_attr_detached, PTHREAD_STACK_MIN*64)) {
 
126
                logerr("%s: failed to set stack size thread attribute!",
 
127
                       program);
 
128
+               res = write(start_pipefd[1], pst_stat, sizeof(*pst_stat));
 
129
                close(start_pipefd[1]);
 
130
                release_flag_file();
 
131
                exit(1);
 
132
@@ -2043,6 +2054,7 @@ int main(int argc, char *argv[])
 
133
                logerr("%s: failed to create thread data key for std env vars!",
 
134
                       program);
 
135
                master_kill(master_list);
 
136
+               res = write(start_pipefd[1], pst_stat, sizeof(*pst_stat));
 
137
                close(start_pipefd[1]);
 
138
                release_flag_file();
 
139
                exit(1);
 
140
@@ -2053,6 +2065,7 @@ int main(int argc, char *argv[])
 
141
        if (!alarm_start_handler()) {
 
142
                logerr("%s: failed to create alarm handler thread!", program);
 
143
                master_kill(master_list);
 
144
+               res = write(start_pipefd[1], pst_stat, sizeof(*pst_stat));
 
145
                close(start_pipefd[1]);
 
146
                release_flag_file();
 
147
                exit(1);
 
148
@@ -2061,6 +2074,7 @@ int main(int argc, char *argv[])
 
149
        if (!st_start_handler()) {
 
150
                logerr("%s: failed to create FSM handler thread!", program);
 
151
                master_kill(master_list);
 
152
+               res = write(start_pipefd[1], pst_stat, sizeof(*pst_stat));
 
153
                close(start_pipefd[1]);
 
154
                release_flag_file();
 
155
                exit(1);
 
156
@@ -2092,6 +2106,7 @@ int main(int argc, char *argv[])
 
157
         */
 
158
        do_force_unlink = 0;
 
159
 
 
160
+       st_stat = 0;
 
161
        res = write(start_pipefd[1], pst_stat, sizeof(*pst_stat));
 
162
        close(start_pipefd[1]);
 
163