]> git.pld-linux.org Git - packages/autofs.git/blame - autofs-5.0.2-fix-offset-dir-create.patch
- 5.0.3 with few official patches. ldap fixes needed
[packages/autofs.git] / autofs-5.0.2-fix-offset-dir-create.patch
CommitLineData
3d551623
PG
1diff --git a/CHANGELOG b/CHANGELOG
2index 8df22ae..2ce58b4 100644
3--- a/CHANGELOG
4+++ b/CHANGELOG
5@@ -6,6 +6,7 @@
6 - add multi nsswitch lookup.
7 - change random multiple server selection option name to be consistent
8 with existing downstream version 4 naming.
9+- fix mount point directory creation for bind mounts.
10
11 18/06/2007 autofs-5.0.2
12 -----------------------
13diff --git a/daemon/automount.c b/daemon/automount.c
14index 294c511..9809b9c 100644
15--- a/daemon/automount.c
16+++ b/daemon/automount.c
17@@ -104,11 +104,14 @@ static int do_mkdir(const char *parent, const char *path, mode_t mode)
18 status = statfs(parent, &fs);
19 if ((status != -1 && fs.f_type == (__SWORD_TYPE) AUTOFS_SUPER_MAGIC) ||
20 contained_in_local_fs(path)) {
21- if (mkdir(path, mode) == -1)
22+ if (mkdir(path, mode) == -1) {
23+ errno = EACCES;
24 return 0;
25+ }
26 return 1;
27 }
28
29+ errno = EACCES;
30 return 0;
31 }
32
33diff --git a/daemon/direct.c b/daemon/direct.c
34index 179e74b..9a39a6f 100644
35--- a/daemon/direct.c
36+++ b/daemon/direct.c
37@@ -604,6 +604,14 @@ int umount_autofs_offset(struct autofs_point *ap, struct mapent *me)
38 }
39 ioctlfd = me->ioctlfd;
40 } else {
41+ /* offset isn't mounted, return success and try to recover */
42+ if (!is_mounted(_PROC_MOUNTS, me->key, MNTS_AUTOFS)) {
43+ debug(ap->logopt,
44+ "offset %s unexpectedly not mounted",
45+ me->key);
46+ return 0;
47+ }
48+
49 ioctlfd = open(me->key, O_RDONLY);
50 if (ioctlfd != -1) {
51 if ((cl_flags = fcntl(ioctlfd, F_GETFD, 0)) != -1) {
52@@ -689,11 +697,19 @@ force_umount:
53 } else
54 msg("umounted offset mount %s", me->key);
55
56+ if (!rv && me->dir_created) {
57+ if (rmdir(me->key) == -1) {
58+ char *estr = strerror_r(errno, buf, MAX_ERR_BUF);
59+ warn(ap->logopt, "failed to remove dir %s: %s",
60+ me->key, estr);
61+ }
62+ }
63 return rv;
64 }
65
66-int mount_autofs_offset(struct autofs_point *ap, struct mapent *me, int is_autofs_fs)
67+int mount_autofs_offset(struct autofs_point *ap, struct mapent *me)
68 {
69+ char buf[MAX_ERR_BUF];
70 struct mnt_params *mp;
71 time_t timeout = ap->exp_timeout;
72 struct stat st;
73@@ -740,36 +756,38 @@ int mount_autofs_offset(struct autofs_point *ap, struct mapent *me, int is_autof
74 return 0;
75 }
76
77- if (is_autofs_fs) {
78- /* In case the directory doesn't exist, try to mkdir it */
79- if (mkdir_path(me->key, 0555) < 0) {
80- if (errno != EEXIST) {
81- crit(ap->logopt,
82- "failed to create mount directory %s %d",
83- me->key, errno);
84- return -1;
85- }
86+ /* In case the directory doesn't exist, try to mkdir it */
87+ if (mkdir_path(me->key, 0555) < 0) {
88+ if (errno == EEXIST) {
89 /*
90 * If we recieve an error, and it's EEXIST
91 * we know the directory was not created.
92 */
93 me->dir_created = 0;
94+ } else if (errno == EACCES) {
95+ /*
96+ * We require the mount point directory to exist when
97+ * installing multi-mount triggers into a host
98+ * filesystem.
99+ *
100+ * If it doesn't exist it is not a valid part of the
101+ * mount heirachy.
102+ */
103+ char *estr = strerror_r(errno, buf, MAX_ERR_BUF);
104+ debug(ap->logopt,
105+ "can't create mount directory: %s, %s",
106+ me->key, estr);
107+ return -1;
108 } else {
109- /* No errors so the directory was successfully created */
110- me->dir_created = 1;
111+ char *estr = strerror_r(errno, buf, MAX_ERR_BUF);
112+ crit(ap->logopt,
113+ "failed to create mount directory: %s, %s",
114+ me->key, estr);
115+ return -1;
116 }
117 } else {
118- me->dir_created = 0;
119-
120- /*
121- * We require the mount point directory to exist when
122- * installing multi-mount triggers into a host filesystem.
123- *
124- * If it doesn't exist it is not a valid part of the
125- * mount heirachy so we silently succeed here.
126- */
127- if (stat(me->key, &st) == -1 && errno == ENOENT)
128- return 0;
129+ /* No errors so the directory was successfully created */
130+ me->dir_created = 1;
131 }
132
133 debug(ap->logopt,
134@@ -832,10 +850,8 @@ out_close:
135 out_umount:
136 umount(me->key);
137 out_err:
138- if (is_autofs_fs) {
139- if (stat(me->key, &st) == 0 && me->dir_created)
140- rmdir_path(ap, me->key, st.st_dev);
141- }
142+ if (stat(me->key, &st) == 0 && me->dir_created)
143+ rmdir_path(ap, me->key, st.st_dev);
144
145 return -1;
146 }
147diff --git a/include/automount.h b/include/automount.h
148index 106ed0a..d9e4ecd 100644
149--- a/include/automount.h
150+++ b/include/automount.h
151@@ -470,7 +470,7 @@ void *expire_proc_direct(void *);
152 int expire_offsets_direct(struct autofs_point *ap, struct mapent *me, int now);
153 int mount_autofs_indirect(struct autofs_point *ap);
154 int mount_autofs_direct(struct autofs_point *ap);
155-int mount_autofs_offset(struct autofs_point *ap, struct mapent *me, int is_autofs_fs);
156+int mount_autofs_offset(struct autofs_point *ap, struct mapent *me);
157 void submount_signal_parent(struct autofs_point *ap, unsigned int success);
158 int umount_autofs(struct autofs_point *ap, int force);
159 int umount_autofs_indirect(struct autofs_point *ap);
160diff --git a/lib/parse_subs.c b/lib/parse_subs.c
161index 0c45905..ad19f34 100644
162--- a/lib/parse_subs.c
163+++ b/lib/parse_subs.c
164@@ -388,10 +388,8 @@ int mount_multi_triggers(struct autofs_point *ap, char *root, struct mapent *me,
165 struct mapent *oe;
166 struct list_head *pos = NULL;
167 unsigned int fs_path_len;
168- struct statfs fs;
169- struct stat st;
170- unsigned int mounted, is_autofs_fs;
171- int ret, start;
172+ unsigned int mounted;
173+ int start;
174
175 fs_path_len = strlen(root) + strlen(base);
176 if (fs_path_len > PATH_MAX)
177@@ -399,15 +397,6 @@ int mount_multi_triggers(struct autofs_point *ap, char *root, struct mapent *me,
178
179 strcpy(path, root);
180 strcat(path, base);
181- ret = statfs(path, &fs);
182- if (ret == -1) {
183- /* There's no mount yet - it must be autofs */
184- if (errno == ENOENT)
185- is_autofs_fs = 1;
186- else
187- return -1;
188- } else
189- is_autofs_fs = fs.f_type == (__SWORD_TYPE) AUTOFS_SUPER_MAGIC ? 1 : 0;
190
191 mounted = 0;
192 start = strlen(root);
193@@ -424,20 +413,9 @@ int mount_multi_triggers(struct autofs_point *ap, char *root, struct mapent *me,
194 if (!oe)
195 goto cont;
196
197- /*
198- * If the host filesystem is not an autofs fs
199- * we require the mount point directory exist
200- * and that permissions are OK.
201- */
202- if (!is_autofs_fs) {
203- ret = stat(oe->key, &st);
204- if (ret == -1)
205- goto cont;
206- }
207-
208 debug(ap->logopt, "mount offset %s", oe->key);
209
210- if (mount_autofs_offset(ap, oe, is_autofs_fs) < 0)
211+ if (mount_autofs_offset(ap, oe) < 0)
212 warn(ap->logopt, "failed to mount offset");
213 else
214 mounted++;
This page took 1.443555 seconds and 4 git commands to generate.