|
|
29d2b9 |
autofs-5.1.7 - pass root length to mount_fullpath()
|
|
|
29d2b9 |
|
|
|
29d2b9 |
From: Ian Kent <raven@themaw.net>
|
|
|
29d2b9 |
|
|
|
29d2b9 |
The length of root may already be known, add a parameter to allow
|
|
|
29d2b9 |
passing it to mount_fullpath() so a strlen() call can be avoided.
|
|
|
29d2b9 |
|
|
|
29d2b9 |
Signed-off-by: Ian Kent <raven@themaw.net>
|
|
|
29d2b9 |
---
|
|
|
29d2b9 |
CHANGELOG | 1 +
|
|
|
29d2b9 |
include/mounts.h | 2 +-
|
|
|
29d2b9 |
lib/mounts.c | 11 +++++++----
|
|
|
29d2b9 |
modules/mount_bind.c | 2 +-
|
|
|
29d2b9 |
modules/mount_changer.c | 2 +-
|
|
|
29d2b9 |
modules/mount_ext2.c | 2 +-
|
|
|
29d2b9 |
modules/mount_generic.c | 2 +-
|
|
|
29d2b9 |
modules/mount_nfs.c | 2 +-
|
|
|
29d2b9 |
modules/parse_sun.c | 4 ++--
|
|
|
29d2b9 |
9 files changed, 16 insertions(+), 12 deletions(-)
|
|
|
29d2b9 |
|
|
|
29d2b9 |
diff --git a/CHANGELOG b/CHANGELOG
|
|
|
29d2b9 |
index 8494f0dc..1c9e2a2d 100644
|
|
|
29d2b9 |
--- a/CHANGELOG
|
|
|
29d2b9 |
+++ b/CHANGELOG
|
|
|
29d2b9 |
@@ -44,6 +44,7 @@
|
|
|
29d2b9 |
- remove obsolete functions.
|
|
|
29d2b9 |
- remove redundant local var from sun_mount().
|
|
|
29d2b9 |
- use mount_fullpath() in one spot in parse_mount().
|
|
|
29d2b9 |
+- pass root length to mount_fullpath().
|
|
|
29d2b9 |
|
|
|
29d2b9 |
25/01/2021 autofs-5.1.7
|
|
|
29d2b9 |
- make bind mounts propagation slave by default.
|
|
|
29d2b9 |
diff --git a/include/mounts.h b/include/mounts.h
|
|
|
29d2b9 |
index ec895e1c..d7980976 100644
|
|
|
29d2b9 |
--- a/include/mounts.h
|
|
|
29d2b9 |
+++ b/include/mounts.h
|
|
|
29d2b9 |
@@ -131,7 +131,7 @@ int check_nfs_mount_version(struct nfs_mount_vers *, struct nfs_mount_vers *);
|
|
|
29d2b9 |
extern unsigned int nfs_mount_uses_string_options;
|
|
|
29d2b9 |
|
|
|
29d2b9 |
int mount_fullpath(char *fullpath, size_t max_len,
|
|
|
29d2b9 |
- const char *root, const char *name);
|
|
|
29d2b9 |
+ const char *root, size_t root_len, const char *name);
|
|
|
29d2b9 |
|
|
|
29d2b9 |
struct amd_entry;
|
|
|
29d2b9 |
|
|
|
29d2b9 |
diff --git a/lib/mounts.c b/lib/mounts.c
|
|
|
29d2b9 |
index c120d2a8..6b8e4c92 100644
|
|
|
29d2b9 |
--- a/lib/mounts.c
|
|
|
29d2b9 |
+++ b/lib/mounts.c
|
|
|
29d2b9 |
@@ -362,11 +362,14 @@ int check_nfs_mount_version(struct nfs_mount_vers *vers,
|
|
|
29d2b9 |
#endif
|
|
|
29d2b9 |
|
|
|
29d2b9 |
int mount_fullpath(char *fullpath, size_t max_len,
|
|
|
29d2b9 |
- const char *root, const char *name)
|
|
|
29d2b9 |
+ const char *root, size_t root_len, const char *name)
|
|
|
29d2b9 |
{
|
|
|
29d2b9 |
int last, len;
|
|
|
29d2b9 |
|
|
|
29d2b9 |
- last = strlen(root) - 1;
|
|
|
29d2b9 |
+ if (root_len)
|
|
|
29d2b9 |
+ last = root_len - 1;
|
|
|
29d2b9 |
+ else
|
|
|
29d2b9 |
+ last = strlen(root) - 1;
|
|
|
29d2b9 |
|
|
|
29d2b9 |
/* Root offset of multi-mount or direct or offset mount.
|
|
|
29d2b9 |
* Direct or offset mount, name (or root) is absolute path.
|
|
|
29d2b9 |
@@ -1685,7 +1688,7 @@ void tree_mapent_cleanup_offsets(struct mapent *oe)
|
|
|
29d2b9 |
else {
|
|
|
29d2b9 |
char mp[PATH_MAX + 1];
|
|
|
29d2b9 |
|
|
|
29d2b9 |
- if (!mount_fullpath(mp, PATH_MAX, ap->path, oe->key))
|
|
|
29d2b9 |
+ if (!mount_fullpath(mp, PATH_MAX, ap->path, ap->len, oe->key))
|
|
|
29d2b9 |
error(ap->logopt, "mount path is too long");
|
|
|
29d2b9 |
else
|
|
|
29d2b9 |
tree_mapent_umount_mount(ap, mp);
|
|
|
29d2b9 |
@@ -1922,7 +1925,7 @@ int tree_mapent_umount_offsets(struct mapent *oe, int nonstrict)
|
|
|
29d2b9 |
* one of these keys is the root of a multi-mount the mount
|
|
|
29d2b9 |
* path must be constructed.
|
|
|
29d2b9 |
*/
|
|
|
29d2b9 |
- if (!mount_fullpath(mp, PATH_MAX, ap->path, oe->key)) {
|
|
|
29d2b9 |
+ if (!mount_fullpath(mp, PATH_MAX, ap->path, ap->len, oe->key)) {
|
|
|
29d2b9 |
error(ap->logopt, "mount path is too long");
|
|
|
29d2b9 |
return 0;
|
|
|
29d2b9 |
}
|
|
|
29d2b9 |
diff --git a/modules/mount_bind.c b/modules/mount_bind.c
|
|
|
29d2b9 |
index c17c6f18..7f64332b 100644
|
|
|
29d2b9 |
--- a/modules/mount_bind.c
|
|
|
29d2b9 |
+++ b/modules/mount_bind.c
|
|
|
29d2b9 |
@@ -122,7 +122,7 @@ int mount_mount(struct autofs_point *ap, const char *root, const char *name, int
|
|
|
29d2b9 |
}
|
|
|
29d2b9 |
}
|
|
|
29d2b9 |
|
|
|
29d2b9 |
- len = mount_fullpath(fullpath, PATH_MAX, root, name);
|
|
|
29d2b9 |
+ len = mount_fullpath(fullpath, PATH_MAX, root, 0, name);
|
|
|
29d2b9 |
if (!len) {
|
|
|
29d2b9 |
error(ap->logopt,
|
|
|
29d2b9 |
MODPREFIX "mount point path too long");
|
|
|
29d2b9 |
diff --git a/modules/mount_changer.c b/modules/mount_changer.c
|
|
|
29d2b9 |
index d02b5f45..8adb9f9a 100644
|
|
|
29d2b9 |
--- a/modules/mount_changer.c
|
|
|
29d2b9 |
+++ b/modules/mount_changer.c
|
|
|
29d2b9 |
@@ -59,7 +59,7 @@ int mount_mount(struct autofs_point *ap, const char *root, const char *name, int
|
|
|
29d2b9 |
|
|
|
29d2b9 |
fstype = "iso9660";
|
|
|
29d2b9 |
|
|
|
29d2b9 |
- len = mount_fullpath(fullpath, PATH_MAX, root, name);
|
|
|
29d2b9 |
+ len = mount_fullpath(fullpath, PATH_MAX, root, 0, name);
|
|
|
29d2b9 |
if (!len) {
|
|
|
29d2b9 |
error(ap->logopt,
|
|
|
29d2b9 |
MODPREFIX "mount point path too long");
|
|
|
29d2b9 |
diff --git a/modules/mount_ext2.c b/modules/mount_ext2.c
|
|
|
29d2b9 |
index 53e6ee10..f4002e58 100644
|
|
|
29d2b9 |
--- a/modules/mount_ext2.c
|
|
|
29d2b9 |
+++ b/modules/mount_ext2.c
|
|
|
29d2b9 |
@@ -55,7 +55,7 @@ int mount_mount(struct autofs_point *ap, const char *root, const char *name, int
|
|
|
29d2b9 |
if (defaults_get_mount_verbose())
|
|
|
29d2b9 |
mountlog = &log_info;
|
|
|
29d2b9 |
|
|
|
29d2b9 |
- len = mount_fullpath(fullpath, PATH_MAX, root, name);
|
|
|
29d2b9 |
+ len = mount_fullpath(fullpath, PATH_MAX, root, 0, name);
|
|
|
29d2b9 |
if (!len) {
|
|
|
29d2b9 |
error(ap->logopt,
|
|
|
29d2b9 |
MODPREFIX "mount point path too long");
|
|
|
29d2b9 |
diff --git a/modules/mount_generic.c b/modules/mount_generic.c
|
|
|
29d2b9 |
index c9deb7ae..8cd0f4ab 100644
|
|
|
29d2b9 |
--- a/modules/mount_generic.c
|
|
|
29d2b9 |
+++ b/modules/mount_generic.c
|
|
|
29d2b9 |
@@ -54,7 +54,7 @@ int mount_mount(struct autofs_point *ap, const char *root, const char *name, int
|
|
|
29d2b9 |
if (defaults_get_mount_verbose())
|
|
|
29d2b9 |
mountlog = &log_info;
|
|
|
29d2b9 |
|
|
|
29d2b9 |
- len = mount_fullpath(fullpath, PATH_MAX, root, name);
|
|
|
29d2b9 |
+ len = mount_fullpath(fullpath, PATH_MAX, root, 0, name);
|
|
|
29d2b9 |
if (!len) {
|
|
|
29d2b9 |
error(ap->logopt,
|
|
|
29d2b9 |
MODPREFIX "mount point path too long");
|
|
|
29d2b9 |
diff --git a/modules/mount_nfs.c b/modules/mount_nfs.c
|
|
|
29d2b9 |
index c70210f4..0314a78f 100644
|
|
|
29d2b9 |
--- a/modules/mount_nfs.c
|
|
|
29d2b9 |
+++ b/modules/mount_nfs.c
|
|
|
29d2b9 |
@@ -213,7 +213,7 @@ int mount_mount(struct autofs_point *ap, const char *root, const char *name, int
|
|
|
29d2b9 |
}
|
|
|
29d2b9 |
|
|
|
29d2b9 |
/* Construct mount point directory */
|
|
|
29d2b9 |
- len = mount_fullpath(fullpath, PATH_MAX, root, name);
|
|
|
29d2b9 |
+ len = mount_fullpath(fullpath, PATH_MAX, root, 0, name);
|
|
|
29d2b9 |
if (!len) {
|
|
|
29d2b9 |
error(ap->logopt,
|
|
|
29d2b9 |
MODPREFIX "mount point path too long");
|
|
|
29d2b9 |
diff --git a/modules/parse_sun.c b/modules/parse_sun.c
|
|
|
29d2b9 |
index d3fc6c7f..b1c2611c 100644
|
|
|
29d2b9 |
--- a/modules/parse_sun.c
|
|
|
29d2b9 |
+++ b/modules/parse_sun.c
|
|
|
29d2b9 |
@@ -1089,7 +1089,7 @@ static int mount_subtree(struct autofs_point *ap, struct mapent_cache *mc,
|
|
|
29d2b9 |
struct mapent *ro;
|
|
|
29d2b9 |
size_t len;
|
|
|
29d2b9 |
|
|
|
29d2b9 |
- len = mount_fullpath(key, PATH_MAX, ap->path, me->key);
|
|
|
29d2b9 |
+ len = mount_fullpath(key, PATH_MAX, ap->path, ap->len, me->key);
|
|
|
29d2b9 |
if (!len) {
|
|
|
29d2b9 |
warn(ap->logopt, "path loo long");
|
|
|
29d2b9 |
return 1;
|
|
|
29d2b9 |
@@ -1359,7 +1359,7 @@ dont_expand:
|
|
|
29d2b9 |
time_t age;
|
|
|
29d2b9 |
int l;
|
|
|
29d2b9 |
|
|
|
29d2b9 |
- m_root_len = mount_fullpath(m_root, PATH_MAX, ap->path, name);
|
|
|
29d2b9 |
+ m_root_len = mount_fullpath(m_root, PATH_MAX, ap->path, ap->len, name);
|
|
|
29d2b9 |
if (!m_root_len) {
|
|
|
29d2b9 |
error(ap->logopt,
|
|
|
29d2b9 |
MODPREFIX "multi-mount root path too long");
|