1
#! /bin/sh /usr/share/dpatch/dpatch-run
2
## 01UPSTREAM_autofs-5.0.4-fix-return-start-status-on-fail.patch
4
## DP: Upstream patch on top of 5.0.4.
7
autofs-5.0.4 - fix return start status on fail
9
From: Ian Kent <raven@themaw.net>
11
We're not returning the status to the parent when automount(8) is waiting
12
for the daemon to finish its startup.
16
daemon/automount.c | 27 +++++++++++++++++++++------
17
2 files changed, 22 insertions(+), 6 deletions(-)
20
diff --git a/CHANGELOG b/CHANGELOG
21
index fdde400..2cb35dc 100644
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.
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 */
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;
45
@@ -1046,6 +1046,7 @@ static void become_daemon(unsigned foreground, unsigned daemon_check)
48
char buf[MAX_ERR_BUF];
52
/* Don't BUSY any directories unnecessarily */
53
@@ -1072,10 +1073,9 @@ static void become_daemon(unsigned foreground, unsigned daemon_check)
58
close(start_pipefd[1]);
59
- r = read(start_pipefd[0], pst_stat, sizeof(*pst_stat));
61
+ res = read(start_pipefd[0], pst_stat, sizeof(*pst_stat));
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",
70
+ /* Return success if already running */
72
+ res = write(start_pipefd[1], pst_stat, sizeof(*pst_stat));
75
close(start_pipefd[1]);
81
@@ -1099,8 +1104,9 @@ static void become_daemon(unsigned foreground, unsigned daemon_check)
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]);
92
@@ -1991,6 +1997,7 @@ int main(int argc, char *argv[])
94
logerr("%s: can't create master map %s",
96
+ res = write(start_pipefd[1], pst_stat, sizeof(*pst_stat));
97
close(start_pipefd[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!",
104
+ res = write(start_pipefd[1], pst_stat, sizeof(*pst_stat));
105
close(start_pipefd[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!",
112
+ res = write(start_pipefd[1], pst_stat, sizeof(*pst_stat));
113
close(start_pipefd[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!",
120
+ res = write(start_pipefd[1], pst_stat, sizeof(*pst_stat));
121
close(start_pipefd[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!",
128
+ res = write(start_pipefd[1], pst_stat, sizeof(*pst_stat));
129
close(start_pipefd[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!",
135
master_kill(master_list);
136
+ res = write(start_pipefd[1], pst_stat, sizeof(*pst_stat));
137
close(start_pipefd[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]);
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]);
156
@@ -2092,6 +2106,7 @@ int main(int argc, char *argv[])
161
res = write(start_pipefd[1], pst_stat, sizeof(*pst_stat));
162
close(start_pipefd[1]);