autofs/autofs-5.1.8-eliminate-realpath-from-mount-of-submount.patch
2023-06-13 10:51:59 +08:00

102 lines
3.4 KiB
Diff

autofs-5.1.8 - eliminate realpath from mount of submount
From: Ian Kent <raven@themaw.net>
None of the tests I have show that the realpath local variable in the
autofs submount mount function is needed, remove it.
Signed-off-by: Ian Kent <raven@themaw.net>
---
modules/mount_autofs.c | 25 ++++---------------------
1 file changed, 4 insertions(+), 21 deletions(-)
--- autofs-5.1.4.orig/modules/mount_autofs.c
+++ autofs-5.1.4/modules/mount_autofs.c
@@ -50,7 +50,6 @@ int mount_mount(struct autofs_point *ap,
{
struct startup_cond suc;
pthread_t thid;
- char realpath[PATH_MAX + 1];
char mountpoint[PATH_MAX + 1];
const char **argv;
int argc, status;
@@ -73,11 +72,6 @@ int mount_mount(struct autofs_point *ap,
/* Root offset of multi-mount */
if (root[strlen(root) - 1] == '/') {
- err = snprintf(realpath, PATH_MAX + 1, "%s/%s", ap->path, name);
- if (err > PATH_MAX) {
- error(ap->logopt, MODPREFIX "string too long for realpath");
- return 1;
- }
err = snprintf(mountpoint, PATH_MAX + 1, "%s", root);
if (err > PATH_MAX) {
error(ap->logopt, MODPREFIX "string too long for mountpoint");
@@ -91,22 +85,12 @@ int mount_mount(struct autofs_point *ap,
error(ap->logopt, MODPREFIX "string too long for mountpoint");
return 1;
}
- err = snprintf(realpath, PATH_MAX + 1, "%s", name);
- if (err > PATH_MAX) {
- error(ap->logopt, MODPREFIX "string too long for realpath");
- return 1;
- }
} else {
err = snprintf(mountpoint, PATH_MAX + 1, "%s", root);
if (err > PATH_MAX) {
error(ap->logopt, MODPREFIX "string too long for mountpoint");
return 1;
}
- err = snprintf(realpath, PATH_MAX + 1, "%s", name);
- if (err > PATH_MAX) {
- error(ap->logopt, MODPREFIX "string too long for realpath");
- return 1;
- }
}
} else {
err = snprintf(mountpoint, PATH_MAX + 1, "%s/%s", root, name);
@@ -114,7 +98,6 @@ int mount_mount(struct autofs_point *ap,
error(ap->logopt, MODPREFIX "string too long for mountpoint");
return 1;
}
- strcpy(realpath, mountpoint);
}
options = NULL;
@@ -180,7 +163,7 @@ int mount_mount(struct autofs_point *ap,
master = ap->entry->master;
- entry = master_new_mapent(master, realpath, ap->entry->age);
+ entry = master_new_mapent(master, mountpoint, ap->entry->age);
if (!entry) {
error(ap->logopt,
MODPREFIX "failed to malloc master_mapent struct");
@@ -332,7 +315,7 @@ int mount_mount(struct autofs_point *ap,
mnt = mnts_add_submount(nap);
if (!mnt) {
crit(ap->logopt,
- MODPREFIX "failed to allocate mount %s", realpath);
+ MODPREFIX "failed to allocate mount %s", mountpoint);
handle_mounts_startup_cond_destroy(&suc);
master_free_map_source(source, 1);
master_free_mapent(entry);
@@ -349,7 +332,7 @@ int mount_mount(struct autofs_point *ap,
crit(ap->logopt,
MODPREFIX
"failed to create mount handler thread for %s",
- realpath);
+ mountpoint);
handle_mounts_startup_cond_destroy(&suc);
mnts_remove_submount(nap->path);
master_free_map_source(source, 1);
@@ -370,7 +353,7 @@ int mount_mount(struct autofs_point *ap,
if (suc.status) {
crit(ap->logopt,
- MODPREFIX "failed to create submount for %s", realpath);
+ MODPREFIX "failed to create submount for %s", mountpoint);
handle_mounts_startup_cond_destroy(&suc);
mnts_remove_submount(nap->path);
master_free_map_source(source, 1);