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

« back to all changes in this revision

Viewing changes to debian/patches/01UPSTREAM_autofs-5.0.4-force-unlink-umount.dpatch

  • Committer: Bazaar Package Importer
  • Author(s): Jan Christoph Nordholz
  • Date: 2009-03-09 01:16:48 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20090309011648-gjynlid883f0s2c4
Tags: 5.0.4-1
* New upstream version (5.0.4 plus patchset as of 2009/03/09).
  * Closes: #518728.
  * Remove dpatch 14, applied upstream.
* New dpatch 14 to avoid using the relatively young SOCK_CLOEXEC
  feature.
* Only invoke 'make clean' on clean target so ./configure isn't
  purged.
* Fix a typo in the postinst regarding the ucf conffile handling.
* Add 'set -e' to package maintenance scripts.
* Drop unnecessary /var/run/autofs from package.

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-force-unlink-umount.dpatch
 
3
##
 
4
## DP: Upstream patch.
 
5
 
 
6
@DPATCH@
 
7
autofs-5.0.4 - force unlink umount at startup
 
8
 
 
9
From: Ian Kent <raven@themaw.net>
 
10
 
 
11
Version 5.0.3 autofs would unlink existing mounts at startup. This
 
12
functioned OK most of the time but caused processes whose working
 
13
directory was within unlinked automounted directories to not get a
 
14
correct pwd reported by the system.
 
15
 
 
16
There can be situations where the unlink umounting is desirable, such
 
17
as when the daemon is forceably killed and we want to get rid of any
 
18
existing mounts at startup. This change provides a way to force this
 
19
old behavior by passing the "--force" option to the daemon. This can
 
20
also be done by using the "forcestart" and "forcerestart" actions to
 
21
the init script.
 
22
 
 
23
Note that the old behavior will always be used if the kernel does not
 
24
include the iotcl re-implementation which provides the ability to
 
25
re-connect to existing mounts.
 
26
---
 
27
 
 
28
 CHANGELOG             |    2 ++
 
29
 daemon/automount.c    |   14 +++++++++++++-
 
30
 daemon/direct.c       |    2 +-
 
31
 daemon/indirect.c     |    2 +-
 
32
 include/automount.h   |    3 +++
 
33
 man/automount.8       |   13 +++++++++++++
 
34
 redhat/autofs.init.in |   10 +++++++++-
 
35
 samples/rc.autofs.in  |   10 +++++++++-
 
36
 8 files changed, 51 insertions(+), 5 deletions(-)
 
37
 
 
38
 
 
39
diff --git a/CHANGELOG b/CHANGELOG
 
40
index 7dee674..d4dd70b 100644
 
41
--- a/CHANGELOG
 
42
+++ b/CHANGELOG
 
43
@@ -12,6 +12,8 @@
 
44
 - fix hosts map use after free.
 
45
 - fix uri list locking (again).
 
46
 - check for stale SASL credentials upon connect fail.
 
47
+- add "forcestart" and "forcerestart" init script options to allow
 
48
+  use of 5.0.3 strartup behavior if required.
 
49
 
 
50
 4/11/2008 autofs-5.0.4
 
51
 -----------------------
 
52
diff --git a/daemon/automount.c b/daemon/automount.c
 
53
index f04273f..e20e7c9 100644
 
54
--- a/daemon/automount.c
 
55
+++ b/daemon/automount.c
 
56
@@ -57,6 +57,7 @@ static char *pid_file = NULL;         /* File in which to keep pid */
 
57
 unsigned int global_random_selection;  /* use random policy when selecting
 
58
                                         * which multi-mount host to mount */
 
59
 long global_negative_timeout = -1;
 
60
+int do_force_unlink = 0;               /* Forceably unlink mount tree at startup */
 
61
 
 
62
 static int start_pipefd[2];
 
63
 static int st_stat = 0;
 
64
@@ -1798,6 +1799,7 @@ int main(int argc, char *argv[])
 
65
                {"version", 0, 0, 'V'},
 
66
                {"set-log-priority", 1, 0, 'l'},
 
67
                {"dont-check-daemon", 0, 0, 'C'},
 
68
+               {"force", 0, 0, 'F'},
 
69
                {0, 0, 0, 0}
 
70
        };
 
71
 
 
72
@@ -1819,7 +1821,7 @@ int main(int argc, char *argv[])
 
73
        daemon_check = 1;
 
74
 
 
75
        opterr = 0;
 
76
-       while ((opt = getopt_long(argc, argv, "+hp:t:vdD:fVrO:l:n:C", long_options, NULL)) != EOF) {
 
77
+       while ((opt = getopt_long(argc, argv, "+hp:t:vdD:fVrO:l:n:CF", long_options, NULL)) != EOF) {
 
78
                switch (opt) {
 
79
                case 'h':
 
80
                        usage();
 
81
@@ -1892,6 +1894,10 @@ int main(int argc, char *argv[])
 
82
                        daemon_check = 0;
 
83
                        break;
 
84
 
 
85
+               case 'F':
 
86
+                       do_force_unlink = 1;
 
87
+                       break;
 
88
+
 
89
                case '?':
 
90
                case ':':
 
91
                        printf("%s: Ambiguous or unknown options\n", program);
 
92
@@ -2066,6 +2072,12 @@ int main(int argc, char *argv[])
 
93
                exit(3);
 
94
        }
 
95
 
 
96
+       /*
 
97
+        * Mmm ... reset force unlink umount so we don't also do this
 
98
+        * in future when we receive a HUP signal.
 
99
+        */
 
100
+       do_force_unlink = 0;
 
101
+
 
102
        res = write(start_pipefd[1], pst_stat, sizeof(*pst_stat));
 
103
        close(start_pipefd[1]);
 
104
 
 
105
diff --git a/daemon/direct.c b/daemon/direct.c
 
106
index d9dda3d..2d979f1 100644
 
107
--- a/daemon/direct.c
 
108
+++ b/daemon/direct.c
 
109
@@ -335,7 +335,7 @@ int do_mount_autofs_direct(struct autofs_point *ap, struct mnt_list *mnts, struc
 
110
        /* Calculate the timeouts */
 
111
        ap->exp_runfreq = (timeout + CHECK_RATIO - 1) / CHECK_RATIO;
 
112
 
 
113
-       if (ops->version) {
 
114
+       if (ops->version && !do_force_unlink) {
 
115
                ap->flags |= MOUNT_FLAG_REMOUNT;
 
116
                ret = try_remount(ap, me, t_direct);
 
117
                ap->flags &= ~MOUNT_FLAG_REMOUNT;
 
118
diff --git a/daemon/indirect.c b/daemon/indirect.c
 
119
index 0721707..2ccbc53 100644
 
120
--- a/daemon/indirect.c
 
121
+++ b/daemon/indirect.c
 
122
@@ -97,7 +97,7 @@ static int do_mount_autofs_indirect(struct autofs_point *ap, const char *root)
 
123
 
 
124
        ap->exp_runfreq = (timeout + CHECK_RATIO - 1) / CHECK_RATIO;
 
125
 
 
126
-       if (ops->version) {
 
127
+       if (ops->version && !do_force_unlink) {
 
128
                ap->flags |= MOUNT_FLAG_REMOUNT;
 
129
                ret = try_remount(ap, NULL, t_indirect);
 
130
                ap->flags &= ~MOUNT_FLAG_REMOUNT;
 
131
diff --git a/include/automount.h b/include/automount.h
 
132
index 46cb6c6..1f14d5b 100644
 
133
--- a/include/automount.h
 
134
+++ b/include/automount.h
 
135
@@ -428,6 +428,9 @@ struct autofs_point {
 
136
        struct list_head submounts;     /* List of child submounts */
 
137
 };
 
138
 
 
139
+/* Foreably unlink existing mounts at startup. */
 
140
+extern int do_force_unlink;
 
141
+
 
142
 /* Standard functions used by daemon or modules */
 
143
 
 
144
 #define        MOUNT_OFFSET_OK         0
 
145
diff --git a/man/automount.8 b/man/automount.8
 
146
index d9285bf..9fcaaf4 100644
 
147
--- a/man/automount.8
 
148
+++ b/man/automount.8
 
149
@@ -84,6 +84,11 @@ path name as specified in the master map.
 
150
 .TP
 
151
 .I "\-C, \-\-dont-check-daemon"
 
152
 Don't check if the daemon is currently running (see NOTES).
 
153
+.TP
 
154
+.I "\-F, \-\-force"
 
155
+Force an unlink umount of existing mounts under autofs managed mount points
 
156
+during startup. This can cause problems for processes with working directories
 
157
+within these mounts (see NOTES).
 
158
 .SH ARGUMENTS
 
159
 \fBautomount\fP takes one optional argument, the name of the master map to
 
160
 use.
 
161
@@ -132,6 +137,14 @@ for certain types of automount maps. The mounts of the seperate daemons
 
162
 might interfere with one another. The implications of running multiple
 
163
 daemon instances needs to be checked and tested before we can say this
 
164
 is supported.
 
165
+.P
 
166
+If the option to force an unlink of mounts at startup is used then processes
 
167
+whose working directory is within unlinked automounted directories will not
 
168
+get the correct pwd from the system. This is because, after the mount is
 
169
+unlinked from the mount tree, anything that needs to walk back up the mount
 
170
+tree to construct a path, such as getcwd(2) and the proc filesystem
 
171
+/proc/<pid>/cwd, cannot work because the point from which the path is
 
172
+constructed has been detached from the mount tree.
 
173
 .SH "SEE ALSO"
 
174
 .BR autofs (5),
 
175
 .BR autofs (8),
 
176
diff --git a/redhat/autofs.init.in b/redhat/autofs.init.in
 
177
index 65c786e..471667e 100644
 
178
--- a/redhat/autofs.init.in
 
179
+++ b/redhat/autofs.init.in
 
180
@@ -137,6 +137,10 @@ case "$1" in
 
181
        start)
 
182
                start
 
183
                ;;
 
184
+       forcestart)
 
185
+               OPTIONS="$OPTIONS --force"
 
186
+               start
 
187
+               ;;
 
188
        stop)
 
189
                stop
 
190
                ;;
 
191
@@ -146,6 +150,10 @@ case "$1" in
 
192
        restart)
 
193
                restart
 
194
                ;;
 
195
+       forcerestart)
 
196
+               OPTIONS="$OPTIONS --force"
 
197
+               restart
 
198
+               ;;
 
199
        reload)
 
200
                reload
 
201
                ;;
 
202
@@ -155,7 +163,7 @@ case "$1" in
 
203
                fi
 
204
                ;;
 
205
        *)
 
206
-               echo $"Usage: $0 {start|stop|status|restart|reload|condrestart}"
 
207
+               echo $"Usage: $0 {start|forcestart|stop|status|restart|orcerestart|reload|condrestart}"
 
208
                exit 1;
 
209
                ;;
 
210
 esac
 
211
diff --git a/samples/rc.autofs.in b/samples/rc.autofs.in
 
212
index 51f5b02..2877fe2 100644
 
213
--- a/samples/rc.autofs.in
 
214
+++ b/samples/rc.autofs.in
 
215
@@ -117,17 +117,25 @@ case "$1" in
 
216
        start)
 
217
                start
 
218
                ;;
 
219
+       forcestart)
 
220
+               OPTIONS="$OPTIONS --force"
 
221
+               start
 
222
+               ;;
 
223
        stop)
 
224
                stop
 
225
                ;;
 
226
        restart)
 
227
                restart
 
228
                ;;
 
229
+       forcerestart)
 
230
+               OPTIONS="$OPTIONS --force"
 
231
+               restart
 
232
+               ;;
 
233
        reload)
 
234
                reload
 
235
                ;;
 
236
        *)
 
237
-               echo $"Usage: $0 {start|stop|restart|reload}"
 
238
+               echo $"Usage: $0 {start|forcestart|stop|restart|forcerestart|reload}"
 
239
                exit 1;
 
240
                ;;
 
241
 esac