- fix mount point directory creation for bind mounts.
- add quoting for exports gathered by hosts map.
This commit is contained in:
parent
116833a296
commit
28f861124d
202
autofs-5.0.2-fix-offset-dir-create.patch
Normal file
202
autofs-5.0.2-fix-offset-dir-create.patch
Normal file
@ -0,0 +1,202 @@
|
||||
diff --git a/daemon/automount.c b/daemon/automount.c
|
||||
index 294c511..9809b9c 100644
|
||||
--- a/daemon/automount.c
|
||||
+++ b/daemon/automount.c
|
||||
@@ -104,11 +104,14 @@ static int do_mkdir(const char *parent, const char *path, mode_t mode)
|
||||
status = statfs(parent, &fs);
|
||||
if ((status != -1 && fs.f_type == (__SWORD_TYPE) AUTOFS_SUPER_MAGIC) ||
|
||||
contained_in_local_fs(path)) {
|
||||
- if (mkdir(path, mode) == -1)
|
||||
+ if (mkdir(path, mode) == -1) {
|
||||
+ errno = EACCES;
|
||||
return 0;
|
||||
+ }
|
||||
return 1;
|
||||
}
|
||||
|
||||
+ errno = EACCES;
|
||||
return 0;
|
||||
}
|
||||
|
||||
diff --git a/daemon/direct.c b/daemon/direct.c
|
||||
index 179e74b..9a39a6f 100644
|
||||
--- a/daemon/direct.c
|
||||
+++ b/daemon/direct.c
|
||||
@@ -604,6 +604,14 @@ int umount_autofs_offset(struct autofs_point *ap, struct mapent *me)
|
||||
}
|
||||
ioctlfd = me->ioctlfd;
|
||||
} else {
|
||||
+ /* offset isn't mounted, return success and try to recover */
|
||||
+ if (!is_mounted(_PROC_MOUNTS, me->key, MNTS_AUTOFS)) {
|
||||
+ debug(ap->logopt,
|
||||
+ "offset %s unexpectedly not mounted",
|
||||
+ me->key);
|
||||
+ return 0;
|
||||
+ }
|
||||
+
|
||||
ioctlfd = open(me->key, O_RDONLY);
|
||||
if (ioctlfd != -1) {
|
||||
if ((cl_flags = fcntl(ioctlfd, F_GETFD, 0)) != -1) {
|
||||
@@ -689,11 +697,19 @@ force_umount:
|
||||
} else
|
||||
msg("umounted offset mount %s", me->key);
|
||||
|
||||
+ if (!rv && me->dir_created) {
|
||||
+ if (rmdir(me->key) == -1) {
|
||||
+ char *estr = strerror_r(errno, buf, MAX_ERR_BUF);
|
||||
+ warn(ap->logopt, "failed to remove dir %s: %s",
|
||||
+ me->key, estr);
|
||||
+ }
|
||||
+ }
|
||||
return rv;
|
||||
}
|
||||
|
||||
-int mount_autofs_offset(struct autofs_point *ap, struct mapent *me, int is_autofs_fs)
|
||||
+int mount_autofs_offset(struct autofs_point *ap, struct mapent *me)
|
||||
{
|
||||
+ char buf[MAX_ERR_BUF];
|
||||
struct mnt_params *mp;
|
||||
time_t timeout = ap->exp_timeout;
|
||||
struct stat st;
|
||||
@@ -740,36 +756,38 @@ int mount_autofs_offset(struct autofs_point *ap, struct mapent *me, int is_autof
|
||||
return 0;
|
||||
}
|
||||
|
||||
- if (is_autofs_fs) {
|
||||
- /* In case the directory doesn't exist, try to mkdir it */
|
||||
- if (mkdir_path(me->key, 0555) < 0) {
|
||||
- if (errno != EEXIST) {
|
||||
- crit(ap->logopt,
|
||||
- "failed to create mount directory %s %d",
|
||||
- me->key, errno);
|
||||
- return -1;
|
||||
- }
|
||||
+ /* In case the directory doesn't exist, try to mkdir it */
|
||||
+ if (mkdir_path(me->key, 0555) < 0) {
|
||||
+ if (errno == EEXIST) {
|
||||
/*
|
||||
* If we recieve an error, and it's EEXIST
|
||||
* we know the directory was not created.
|
||||
*/
|
||||
me->dir_created = 0;
|
||||
+ } else if (errno == EACCES) {
|
||||
+ /*
|
||||
+ * We require the mount point directory to exist when
|
||||
+ * installing multi-mount triggers into a host
|
||||
+ * filesystem.
|
||||
+ *
|
||||
+ * If it doesn't exist it is not a valid part of the
|
||||
+ * mount heirachy.
|
||||
+ */
|
||||
+ char *estr = strerror_r(errno, buf, MAX_ERR_BUF);
|
||||
+ debug(ap->logopt,
|
||||
+ "can't create mount directory: %s, %s",
|
||||
+ me->key, estr);
|
||||
+ return -1;
|
||||
} else {
|
||||
- /* No errors so the directory was successfully created */
|
||||
- me->dir_created = 1;
|
||||
+ char *estr = strerror_r(errno, buf, MAX_ERR_BUF);
|
||||
+ crit(ap->logopt,
|
||||
+ "failed to create mount directory: %s, %s",
|
||||
+ me->key, estr);
|
||||
+ return -1;
|
||||
}
|
||||
} else {
|
||||
- me->dir_created = 0;
|
||||
-
|
||||
- /*
|
||||
- * We require the mount point directory to exist when
|
||||
- * installing multi-mount triggers into a host filesystem.
|
||||
- *
|
||||
- * If it doesn't exist it is not a valid part of the
|
||||
- * mount heirachy so we silently succeed here.
|
||||
- */
|
||||
- if (stat(me->key, &st) == -1 && errno == ENOENT)
|
||||
- return 0;
|
||||
+ /* No errors so the directory was successfully created */
|
||||
+ me->dir_created = 1;
|
||||
}
|
||||
|
||||
debug(ap->logopt,
|
||||
@@ -832,10 +850,8 @@ out_close:
|
||||
out_umount:
|
||||
umount(me->key);
|
||||
out_err:
|
||||
- if (is_autofs_fs) {
|
||||
- if (stat(me->key, &st) == 0 && me->dir_created)
|
||||
- rmdir_path(ap, me->key, st.st_dev);
|
||||
- }
|
||||
+ if (stat(me->key, &st) == 0 && me->dir_created)
|
||||
+ rmdir_path(ap, me->key, st.st_dev);
|
||||
|
||||
return -1;
|
||||
}
|
||||
diff --git a/include/automount.h b/include/automount.h
|
||||
index 106ed0a..d9e4ecd 100644
|
||||
--- a/include/automount.h
|
||||
+++ b/include/automount.h
|
||||
@@ -470,7 +470,7 @@ void *expire_proc_direct(void *);
|
||||
int expire_offsets_direct(struct autofs_point *ap, struct mapent *me, int now);
|
||||
int mount_autofs_indirect(struct autofs_point *ap);
|
||||
int mount_autofs_direct(struct autofs_point *ap);
|
||||
-int mount_autofs_offset(struct autofs_point *ap, struct mapent *me, int is_autofs_fs);
|
||||
+int mount_autofs_offset(struct autofs_point *ap, struct mapent *me);
|
||||
void submount_signal_parent(struct autofs_point *ap, unsigned int success);
|
||||
int umount_autofs(struct autofs_point *ap, int force);
|
||||
int umount_autofs_indirect(struct autofs_point *ap);
|
||||
diff --git a/lib/parse_subs.c b/lib/parse_subs.c
|
||||
index 0c45905..ad19f34 100644
|
||||
--- a/lib/parse_subs.c
|
||||
+++ b/lib/parse_subs.c
|
||||
@@ -388,10 +388,8 @@ int mount_multi_triggers(struct autofs_point *ap, char *root, struct mapent *me,
|
||||
struct mapent *oe;
|
||||
struct list_head *pos = NULL;
|
||||
unsigned int fs_path_len;
|
||||
- struct statfs fs;
|
||||
- struct stat st;
|
||||
- unsigned int mounted, is_autofs_fs;
|
||||
- int ret, start;
|
||||
+ unsigned int mounted;
|
||||
+ int start;
|
||||
|
||||
fs_path_len = strlen(root) + strlen(base);
|
||||
if (fs_path_len > PATH_MAX)
|
||||
@@ -399,15 +397,6 @@ int mount_multi_triggers(struct autofs_point *ap, char *root, struct mapent *me,
|
||||
|
||||
strcpy(path, root);
|
||||
strcat(path, base);
|
||||
- ret = statfs(path, &fs);
|
||||
- if (ret == -1) {
|
||||
- /* There's no mount yet - it must be autofs */
|
||||
- if (errno == ENOENT)
|
||||
- is_autofs_fs = 1;
|
||||
- else
|
||||
- return -1;
|
||||
- } else
|
||||
- is_autofs_fs = fs.f_type == (__SWORD_TYPE) AUTOFS_SUPER_MAGIC ? 1 : 0;
|
||||
|
||||
mounted = 0;
|
||||
start = strlen(root);
|
||||
@@ -424,20 +413,9 @@ int mount_multi_triggers(struct autofs_point *ap, char *root, struct mapent *me,
|
||||
if (!oe)
|
||||
goto cont;
|
||||
|
||||
- /*
|
||||
- * If the host filesystem is not an autofs fs
|
||||
- * we require the mount point directory exist
|
||||
- * and that permissions are OK.
|
||||
- */
|
||||
- if (!is_autofs_fs) {
|
||||
- ret = stat(oe->key, &st);
|
||||
- if (ret == -1)
|
||||
- goto cont;
|
||||
- }
|
||||
-
|
||||
debug(ap->logopt, "mount offset %s", oe->key);
|
||||
|
||||
- if (mount_autofs_offset(ap, oe, is_autofs_fs) < 0)
|
||||
+ if (mount_autofs_offset(ap, oe) < 0)
|
||||
warn(ap->logopt, "failed to mount offset");
|
||||
else
|
||||
mounted++;
|
||||
59
autofs-5.0.2-quote-exports.patch
Normal file
59
autofs-5.0.2-quote-exports.patch
Normal file
@ -0,0 +1,59 @@
|
||||
diff --git a/modules/lookup_hosts.c b/modules/lookup_hosts.c
|
||||
index a9a4c75..1f8fa15 100644
|
||||
--- a/modules/lookup_hosts.c
|
||||
+++ b/modules/lookup_hosts.c
|
||||
@@ -215,7 +215,7 @@ done:
|
||||
if (mapent) {
|
||||
int len = strlen(mapent) + 1;
|
||||
|
||||
- len += strlen(name) + 2*strlen(exp->ex_dir) + 3;
|
||||
+ len += strlen(name) + 2*(strlen(exp->ex_dir) + 2) + 3;
|
||||
mapent = realloc(mapent, len);
|
||||
if (!mapent) {
|
||||
char *estr;
|
||||
@@ -224,10 +224,11 @@ done:
|
||||
rpc_exports_free(exp);
|
||||
return NSS_STATUS_UNAVAIL;
|
||||
}
|
||||
- strcat(mapent, " ");
|
||||
+ strcat(mapent, " \"");
|
||||
strcat(mapent, exp->ex_dir);
|
||||
+ strcat(mapent, "\"");
|
||||
} else {
|
||||
- int len = 2*strlen(exp->ex_dir) + strlen(name) + 3;
|
||||
+ int len = 2*(strlen(exp->ex_dir) + 2) + strlen(name) + 3;
|
||||
|
||||
mapent = malloc(len);
|
||||
if (!mapent) {
|
||||
@@ -237,12 +238,15 @@ done:
|
||||
rpc_exports_free(exp);
|
||||
return NSS_STATUS_UNAVAIL;
|
||||
}
|
||||
- strcpy(mapent, exp->ex_dir);
|
||||
+ strcpy(mapent, "\"");
|
||||
+ strcat(mapent, exp->ex_dir);
|
||||
+ strcat(mapent, "\"");
|
||||
}
|
||||
- strcat(mapent, " ");
|
||||
+ strcat(mapent, " \"");
|
||||
strcat(mapent, name);
|
||||
strcat(mapent, ":");
|
||||
strcat(mapent, exp->ex_dir);
|
||||
+ strcat(mapent, "\"");
|
||||
|
||||
exp = exp->ex_next;
|
||||
}
|
||||
@@ -260,13 +264,9 @@ done:
|
||||
cache_update(mc, source, name, mapent, now);
|
||||
cache_unlock(mc);
|
||||
|
||||
- debug(LOGOPT_ANY, "source wait");
|
||||
-
|
||||
master_source_current_wait(ap->entry);
|
||||
ap->entry->current = source;
|
||||
|
||||
- debug(LOGOPT_ANY, "do parse_mount");
|
||||
-
|
||||
ret = ctxt->parse->parse_mount(ap, name, name_len,
|
||||
mapent, ctxt->parse->context);
|
||||
free(mapent);
|
||||
10
autofs.spec
10
autofs.spec
@ -4,7 +4,7 @@
|
||||
Summary: A tool for automatically mounting and unmounting filesystems
|
||||
Name: autofs
|
||||
Version: 5.0.2
|
||||
Release: 4
|
||||
Release: 5
|
||||
Epoch: 1
|
||||
License: GPL
|
||||
Group: System Environment/Daemons
|
||||
@ -14,6 +14,8 @@ Patch0: autofs-5.0.2-add-krb5-include.patch
|
||||
Patch1: autofs-5.0.2-bad-proto-init.patch
|
||||
Patch2: autofs-5.0.2-add-missing-multi-support.patch
|
||||
Patch3: autofs-5.0.2-add-multi-nsswitch-lookup.patch
|
||||
Patch4: autofs-5.0.2-fix-offset-dir-create.patch
|
||||
Patch5: autofs-5.0.2-quote-exports.patch
|
||||
Buildroot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
|
||||
BuildRequires: autoconf, hesiod-devel, openldap-devel, bison, flex, libxml2-devel, cyrus-sasl-devel, openssl-devel
|
||||
Conflicts: kernel < 2.6.17
|
||||
@ -59,6 +61,8 @@ echo %{version}-%{release} > .version
|
||||
%patch1 -p1
|
||||
%patch2 -p1
|
||||
%patch3 -p1
|
||||
%patch4 -p1
|
||||
%patch5 -p1
|
||||
|
||||
%build
|
||||
#CFLAGS="$RPM_OPT_FLAGS" ./configure --prefix=/usr --libdir=%{_libdir}
|
||||
@ -111,6 +115,10 @@ fi
|
||||
%{_libdir}/autofs/
|
||||
|
||||
%changelog
|
||||
* Mon Jul 16 2007 Ian Kent <ikent@redhat.com> - 5.0.2-5
|
||||
- fix mount point directory creation for bind mounts.
|
||||
- add quoting for exports gathered by hosts map.
|
||||
|
||||
* Mon Jun 25 2007 Ian Kent <ikent@redhat.com> - 5.0.2-4
|
||||
- update multi map nsswitch patch.
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user