|
|
9a499a |
autofs-5.1.6 - add helper to construct mount point path
|
|
|
9a499a |
|
|
|
9a499a |
From: Ian Kent <raven@themaw.net>
|
|
|
9a499a |
|
|
|
9a499a |
Add convenience helper to construct mount point path.
|
|
|
9a499a |
|
|
|
9a499a |
Signed-off-by: Ian Kent <raven@themaw.net>
|
|
|
9a499a |
---
|
|
|
9a499a |
CHANGELOG | 1 +
|
|
|
9a499a |
include/mounts.h | 3 +++
|
|
|
9a499a |
lib/mounts.c | 23 +++++++++++++++++++++++
|
|
|
9a499a |
modules/mount_bind.c | 19 +++++--------------
|
|
|
9a499a |
modules/mount_changer.c | 19 +++++--------------
|
|
|
9a499a |
modules/mount_ext2.c | 19 +++++--------------
|
|
|
9a499a |
modules/mount_generic.c | 19 +++++--------------
|
|
|
9a499a |
modules/mount_nfs.c | 21 ++++++++-------------
|
|
|
9a499a |
8 files changed, 55 insertions(+), 69 deletions(-)
|
|
|
9a499a |
|
|
|
9a499a |
--- autofs-5.1.4.orig/CHANGELOG
|
|
|
9a499a |
+++ autofs-5.1.4/CHANGELOG
|
|
|
9a499a |
@@ -135,6 +135,7 @@ xx/xx/2018 autofs-5.1.5
|
|
|
9a499a |
- move submount check into conditional_alarm_add().
|
|
|
9a499a |
- move lib/master.c to daemon/master.c.
|
|
|
9a499a |
- use master_list_empty() for list empty check.
|
|
|
9a499a |
+- add helper to construct mount point path.
|
|
|
9a499a |
|
|
|
9a499a |
19/12/2017 autofs-5.1.4
|
|
|
9a499a |
- fix spec file url.
|
|
|
9a499a |
--- autofs-5.1.4.orig/include/mounts.h
|
|
|
9a499a |
+++ autofs-5.1.4/include/mounts.h
|
|
|
9a499a |
@@ -94,6 +94,9 @@ unsigned int linux_version_code(void);
|
|
|
9a499a |
int check_nfs_mount_version(struct nfs_mount_vers *, struct nfs_mount_vers *);
|
|
|
9a499a |
extern unsigned int nfs_mount_uses_string_options;
|
|
|
9a499a |
|
|
|
9a499a |
+int mount_fullpath(char *fullpath, size_t max_len,
|
|
|
9a499a |
+ const char *root, const char *name);
|
|
|
9a499a |
+
|
|
|
9a499a |
struct amd_entry;
|
|
|
9a499a |
|
|
|
9a499a |
struct substvar *addstdenv(struct substvar *sv, const char *prefix);
|
|
|
9a499a |
--- autofs-5.1.4.orig/lib/mounts.c
|
|
|
9a499a |
+++ autofs-5.1.4/lib/mounts.c
|
|
|
9a499a |
@@ -339,6 +339,29 @@ int check_nfs_mount_version(struct nfs_m
|
|
|
9a499a |
}
|
|
|
9a499a |
#endif
|
|
|
9a499a |
|
|
|
9a499a |
+int mount_fullpath(char *fullpath, size_t max_len,
|
|
|
9a499a |
+ const char *root, const char *name)
|
|
|
9a499a |
+{
|
|
|
9a499a |
+ int last, len;
|
|
|
9a499a |
+
|
|
|
9a499a |
+ last = strlen(root) - 1;
|
|
|
9a499a |
+
|
|
|
9a499a |
+ /* Root offset of multi-mount or direct or offset mount.
|
|
|
9a499a |
+ * Direct or offset mount, name (or root) is absolute path.
|
|
|
9a499a |
+ */
|
|
|
9a499a |
+ if (root[last] == '/' || *name == '/')
|
|
|
9a499a |
+ len = snprintf(fullpath, max_len, "%s", root);
|
|
|
9a499a |
+ else
|
|
|
9a499a |
+ len = snprintf(fullpath, max_len, "%s/%s", root, name);
|
|
|
9a499a |
+
|
|
|
9a499a |
+ if (len >= max_len)
|
|
|
9a499a |
+ return 0;
|
|
|
9a499a |
+
|
|
|
9a499a |
+ fullpath[len] = '\0';
|
|
|
9a499a |
+
|
|
|
9a499a |
+ return len;
|
|
|
9a499a |
+}
|
|
|
9a499a |
+
|
|
|
9a499a |
static char *set_env_name(const char *prefix, const char *name, char *buf)
|
|
|
9a499a |
{
|
|
|
9a499a |
size_t len;
|
|
|
9a499a |
--- autofs-5.1.4.orig/modules/mount_bind.c
|
|
|
9a499a |
+++ autofs-5.1.4/modules/mount_bind.c
|
|
|
9a499a |
@@ -122,21 +122,12 @@ int mount_mount(struct autofs_point *ap,
|
|
|
9a499a |
}
|
|
|
9a499a |
}
|
|
|
9a499a |
|
|
|
9a499a |
- /* Root offset of multi-mount */
|
|
|
9a499a |
- len = strlen(root);
|
|
|
9a499a |
- if (root[len - 1] == '/') {
|
|
|
9a499a |
- len = snprintf(fullpath, len, "%s", root);
|
|
|
9a499a |
- } else if (*name == '/') {
|
|
|
9a499a |
- /*
|
|
|
9a499a |
- * Direct or offset mount, name is absolute path so
|
|
|
9a499a |
- * don't use root (but with move mount changes root
|
|
|
9a499a |
- * is now the same as name).
|
|
|
9a499a |
- */
|
|
|
9a499a |
- len = sprintf(fullpath, "%s", root);
|
|
|
9a499a |
- } else {
|
|
|
9a499a |
- len = sprintf(fullpath, "%s/%s", root, name);
|
|
|
9a499a |
+ len = mount_fullpath(fullpath, PATH_MAX, root, name);
|
|
|
9a499a |
+ if (!len) {
|
|
|
9a499a |
+ error(ap->logopt,
|
|
|
9a499a |
+ MODPREFIX "mount point path too long");
|
|
|
9a499a |
+ return 1;
|
|
|
9a499a |
}
|
|
|
9a499a |
- fullpath[len] = '\0';
|
|
|
9a499a |
|
|
|
9a499a |
i = len;
|
|
|
9a499a |
while (--i > 0 && fullpath[i] == '/')
|
|
|
9a499a |
--- autofs-5.1.4.orig/modules/mount_changer.c
|
|
|
9a499a |
+++ autofs-5.1.4/modules/mount_changer.c
|
|
|
9a499a |
@@ -59,21 +59,12 @@ int mount_mount(struct autofs_point *ap,
|
|
|
9a499a |
|
|
|
9a499a |
fstype = "iso9660";
|
|
|
9a499a |
|
|
|
9a499a |
- /* Root offset of multi-mount */
|
|
|
9a499a |
- len = strlen(root);
|
|
|
9a499a |
- if (root[len - 1] == '/') {
|
|
|
9a499a |
- len = snprintf(fullpath, len, "%s", root);
|
|
|
9a499a |
- } else if (*name == '/') {
|
|
|
9a499a |
- /*
|
|
|
9a499a |
- * Direct or offset mount, name is absolute path so
|
|
|
9a499a |
- * don't use root (but with move mount changes root
|
|
|
9a499a |
- * is now the same as name).
|
|
|
9a499a |
- */
|
|
|
9a499a |
- len = sprintf(fullpath, "%s", root);
|
|
|
9a499a |
- } else {
|
|
|
9a499a |
- len = sprintf(fullpath, "%s/%s", root, name);
|
|
|
9a499a |
+ len = mount_fullpath(fullpath, PATH_MAX, root, name);
|
|
|
9a499a |
+ if (!len) {
|
|
|
9a499a |
+ error(ap->logopt,
|
|
|
9a499a |
+ MODPREFIX "mount point path too long");
|
|
|
9a499a |
+ return 1;
|
|
|
9a499a |
}
|
|
|
9a499a |
- fullpath[len] = '\0';
|
|
|
9a499a |
|
|
|
9a499a |
debug(ap->logopt, MODPREFIX "calling umount %s", what);
|
|
|
9a499a |
|
|
|
9a499a |
--- autofs-5.1.4.orig/modules/mount_ext2.c
|
|
|
9a499a |
+++ autofs-5.1.4/modules/mount_ext2.c
|
|
|
9a499a |
@@ -55,21 +55,12 @@ int mount_mount(struct autofs_point *ap,
|
|
|
9a499a |
if (defaults_get_mount_verbose())
|
|
|
9a499a |
mountlog = &log_info;
|
|
|
9a499a |
|
|
|
9a499a |
- /* Root offset of multi-mount */
|
|
|
9a499a |
- len = strlen(root);
|
|
|
9a499a |
- if (root[len - 1] == '/') {
|
|
|
9a499a |
- len = snprintf(fullpath, len, "%s", root);
|
|
|
9a499a |
- } else if (*name == '/') {
|
|
|
9a499a |
- /*
|
|
|
9a499a |
- * Direct or offset mount, name is absolute path so
|
|
|
9a499a |
- * don't use root (but with move mount changes root
|
|
|
9a499a |
- * is now the same as name).
|
|
|
9a499a |
- */
|
|
|
9a499a |
- len = sprintf(fullpath, "%s", root);
|
|
|
9a499a |
- } else {
|
|
|
9a499a |
- len = sprintf(fullpath, "%s/%s", root, name);
|
|
|
9a499a |
+ len = mount_fullpath(fullpath, PATH_MAX, root, name);
|
|
|
9a499a |
+ if (!len) {
|
|
|
9a499a |
+ error(ap->logopt,
|
|
|
9a499a |
+ MODPREFIX "mount point path too long");
|
|
|
9a499a |
+ return 1;
|
|
|
9a499a |
}
|
|
|
9a499a |
- fullpath[len] = '\0';
|
|
|
9a499a |
|
|
|
9a499a |
debug(ap->logopt, MODPREFIX "calling mkdir_path %s", fullpath);
|
|
|
9a499a |
|
|
|
9a499a |
--- autofs-5.1.4.orig/modules/mount_generic.c
|
|
|
9a499a |
+++ autofs-5.1.4/modules/mount_generic.c
|
|
|
9a499a |
@@ -54,21 +54,12 @@ int mount_mount(struct autofs_point *ap,
|
|
|
9a499a |
if (defaults_get_mount_verbose())
|
|
|
9a499a |
mountlog = &log_info;
|
|
|
9a499a |
|
|
|
9a499a |
- /* Root offset of multi-mount */
|
|
|
9a499a |
- len = strlen(root);
|
|
|
9a499a |
- if (root[len - 1] == '/') {
|
|
|
9a499a |
- len = snprintf(fullpath, len, "%s", root);
|
|
|
9a499a |
- } else if (*name == '/') {
|
|
|
9a499a |
- /*
|
|
|
9a499a |
- * Direct or offset mount, name is absolute path so
|
|
|
9a499a |
- * don't use root (but with move mount changes root
|
|
|
9a499a |
- * is now the same as name).
|
|
|
9a499a |
- */
|
|
|
9a499a |
- len = sprintf(fullpath, "%s", root);
|
|
|
9a499a |
- } else {
|
|
|
9a499a |
- len = sprintf(fullpath, "%s/%s", root, name);
|
|
|
9a499a |
+ len = mount_fullpath(fullpath, PATH_MAX, root, name);
|
|
|
9a499a |
+ if (!len) {
|
|
|
9a499a |
+ error(ap->logopt,
|
|
|
9a499a |
+ MODPREFIX "mount point path too long");
|
|
|
9a499a |
+ return 1;
|
|
|
9a499a |
}
|
|
|
9a499a |
- fullpath[len] = '\0';
|
|
|
9a499a |
|
|
|
9a499a |
debug(ap->logopt, MODPREFIX "calling mkdir_path %s", fullpath);
|
|
|
9a499a |
|
|
|
9a499a |
--- autofs-5.1.4.orig/modules/mount_nfs.c
|
|
|
9a499a |
+++ autofs-5.1.4/modules/mount_nfs.c
|
|
|
9a499a |
@@ -212,6 +212,14 @@ int mount_mount(struct autofs_point *ap,
|
|
|
9a499a |
nfsoptions, nobind, nosymlink, ro);
|
|
|
9a499a |
}
|
|
|
9a499a |
|
|
|
9a499a |
+ /* Construct mount point directory */
|
|
|
9a499a |
+ len = mount_fullpath(fullpath, PATH_MAX, root, name);
|
|
|
9a499a |
+ if (!len) {
|
|
|
9a499a |
+ error(ap->logopt,
|
|
|
9a499a |
+ MODPREFIX "mount point path too long");
|
|
|
9a499a |
+ return 1;
|
|
|
9a499a |
+ }
|
|
|
9a499a |
+
|
|
|
9a499a |
if (!parse_location(ap->logopt, &hosts, what, flags)) {
|
|
|
9a499a |
info(ap->logopt, MODPREFIX "no hosts available");
|
|
|
9a499a |
return 1;
|
|
|
9a499a |
@@ -266,19 +274,6 @@ dont_probe:
|
|
|
9a499a |
return 1;
|
|
|
9a499a |
}
|
|
|
9a499a |
|
|
|
9a499a |
- /* Construct and perhaps create mount point directory */
|
|
|
9a499a |
-
|
|
|
9a499a |
- /* Root offset of multi-mount */
|
|
|
9a499a |
- len = strlen(root);
|
|
|
9a499a |
- if (root[len - 1] == '/') {
|
|
|
9a499a |
- len = snprintf(fullpath, len, "%s", root);
|
|
|
9a499a |
- } else if (*name == '/') {
|
|
|
9a499a |
- len = sprintf(fullpath, "%s", root);
|
|
|
9a499a |
- } else {
|
|
|
9a499a |
- len = sprintf(fullpath, "%s/%s", root, name);
|
|
|
9a499a |
- }
|
|
|
9a499a |
- fullpath[len] = '\0';
|
|
|
9a499a |
-
|
|
|
9a499a |
debug(ap->logopt, MODPREFIX "calling mkdir_path %s", fullpath);
|
|
|
9a499a |
|
|
|
9a499a |
status = mkdir_path(fullpath, mp_mode);
|