From c8d72bc1454e8cdbbd4152a1170a05325db1642b Mon Sep 17 00:00:00 2001 From: CentOS Sources Date: Mar 31 2020 09:38:58 +0000 Subject: import autofs-5.0.7-109.el7 --- diff --git a/SOURCES/autofs-5.0.9-fix-reset-flex-scan-buffer-on-init.patch b/SOURCES/autofs-5.0.9-fix-reset-flex-scan-buffer-on-init.patch new file mode 100644 index 0000000..8f3dc90 --- /dev/null +++ b/SOURCES/autofs-5.0.9-fix-reset-flex-scan-buffer-on-init.patch @@ -0,0 +1,38 @@ +autofs-5.0.9 - fix reset flex scan buffer on init + +From: Ian Kent + +If a scan results in an error the flex scan buffer is sometimes +not properly reset for the next scan. + +This can result in an incorrect success return for a subsequent +operation, such as a map re-read, for a master map line that's +actually incorrect. Given the success return autofs tries to add +a master map entry that doesn't have the needed information, such +as the mount path, and a SEGV results. +--- + CHANGELOG | 1 + + lib/master_tok.l | 2 ++ + 2 files changed, 3 insertions(+) + +--- autofs-5.0.7.orig/CHANGELOG ++++ autofs-5.0.7/CHANGELOG +@@ -328,6 +328,7 @@ + - improve hostname lookup error logging. + - allow period following macro in selector value. + - fix macro expansion in selector values. ++- fix reset flex scan buffer on init. + + 25/07/2012 autofs-5.0.7 + ======================= +--- autofs-5.0.7.orig/lib/master_tok.l ++++ autofs-5.0.7/lib/master_tok.l +@@ -448,6 +448,8 @@ void master_set_scan_buffer(const char * + memset(buff, 0, sizeof(buff)); + optr = buff; + ++ YY_FLUSH_BUFFER; ++ + line = buffer; + line_pos = &line[0]; + /* diff --git a/SOURCES/autofs-5.1.5-add-config-option-for-ignore-mount-option.patch b/SOURCES/autofs-5.1.5-add-config-option-for-ignore-mount-option.patch new file mode 100644 index 0000000..6cf0e1f --- /dev/null +++ b/SOURCES/autofs-5.1.5-add-config-option-for-ignore-mount-option.patch @@ -0,0 +1,155 @@ +autofs-5.1.5 - add config option for "ignore" mount option + +From: Ian Kent + +Add a configuration option to control whether the autofs pseudo +mount option is used on autofs mounts. + +The default setting is "no" to avoid unexpected behaviour and +so is an opt-in setting for those who understand that, if user +space utilities and libraries honour this, then autofs mounts +will be ommitted from mount table listings. + +Signed-off-by: Ian Kent +--- + CHANGELOG | 1 + + include/defaults.h | 2 ++ + lib/defaults.c | 17 +++++++++++++++++ + lib/master.c | 3 ++- + man/autofs.conf.5.in | 7 +++++++ + redhat/autofs.conf.default.in | 9 +++++++++ + samples/autofs.conf.default.in | 9 +++++++++ + 7 files changed, 47 insertions(+), 1 deletion(-) + +--- autofs-5.0.7.orig/CHANGELOG ++++ autofs-5.0.7/CHANGELOG +@@ -336,6 +336,7 @@ + - fix unlink_mount_tree() not umounting mounts. + - add ignore mount option. + - use ignore option for offset mounts as well. ++- add config option for "ignore" mount option + + 25/07/2012 autofs-5.0.7 + ======================= +--- autofs-5.0.7.orig/include/defaults.h ++++ autofs-5.0.7/include/defaults.h +@@ -51,6 +51,7 @@ + + #define DEFAULT_USE_HOSTNAME_FOR_MOUNTS "0" + #define DEFAULT_DISABLE_NOT_FOUND_MESSAGE "0" ++#define DEFAULT_USE_IGNORE_MOUNT_OPTION "0" + + #define DEFAULT_SSS_MASTER_MAP_WAIT "0" + #define DEFAULT_USE_MOUNT_REQUEST_LOG_ID "0" +@@ -174,6 +175,7 @@ const char *defaults_get_auth_conf_file( + unsigned int defaults_get_map_hash_table_size(void); + unsigned int defaults_use_hostname_for_mounts(void); + unsigned int defaults_disable_not_found_message(void); ++unsigned int defaults_get_use_ignore_mount_option(void); + unsigned int defaults_get_sss_master_map_wait(void); + unsigned int defaults_get_use_mount_request_log_id(void); + +--- autofs-5.0.7.orig/lib/defaults.c ++++ autofs-5.0.7/lib/defaults.c +@@ -76,6 +76,7 @@ + + #define NAME_USE_HOSTNAME_FOR_MOUNTS "use_hostname_for_mounts" + #define NAME_DISABLE_NOT_FOUND_MESSAGE "disable_not_found_message" ++#define NAME_USE_IGNORE_MOUNT_OPTION "use_ignore_mount_option" + + #define NAME_SSS_MASTER_MAP_WAIT "sss_master_map_wait" + #define NAME_USE_MOUNT_REQUEST_LOG_ID "use_mount_request_log_id" +@@ -363,6 +364,11 @@ static int conf_load_autofs_defaults(voi + if (ret == CFG_FAIL) + goto error; + ++ ret = conf_update(sec, NAME_USE_IGNORE_MOUNT_OPTION, ++ DEFAULT_USE_IGNORE_MOUNT_OPTION, CONF_ENV); ++ if (ret == CFG_FAIL) ++ goto error; ++ + ret = conf_update(sec, NAME_SSS_MASTER_MAP_WAIT, + DEFAULT_SSS_MASTER_MAP_WAIT, CONF_ENV); + if (ret == CFG_FAIL) +@@ -1873,6 +1879,17 @@ unsigned int defaults_get_use_mount_requ + + return res; + } ++ ++unsigned int defaults_get_use_ignore_mount_option(void) ++{ ++ int res; ++ ++ res = conf_get_yesno(autofs_gbl_sec, NAME_USE_IGNORE_MOUNT_OPTION); ++ if (res < 0) ++ res = atoi(DEFAULT_USE_IGNORE_MOUNT_OPTION); ++ ++ return res; ++} + + unsigned int defaults_get_sss_master_map_wait(void) + { +--- autofs-5.0.7.orig/lib/master.c ++++ autofs-5.0.7/lib/master.c +@@ -101,7 +101,8 @@ int master_add_autofs_point(struct maste + ap->negative_timeout = global_negative_timeout; + ap->exp_timeout = defaults_get_timeout(); + ap->exp_runfreq = 0; +- ap->flags = MOUNT_FLAG_IGNORE; ++ if (defaults_get_use_ignore_mount_option()) ++ ap->flags = MOUNT_FLAG_IGNORE; + if (ghost) + ap->flags |= MOUNT_FLAG_GHOST; + +--- autofs-5.0.7.orig/man/autofs.conf.5.in ++++ autofs-5.0.7/man/autofs.conf.5.in +@@ -151,6 +151,13 @@ That produces, IMHO, unnecessary noise i + has been added to provide the ability to turn it off. The default is "no" + to maintain the current behaviour. + .TP ++.B use_ignore_mount_option ++.br ++An option to enable the use of autofs pseudo option "disable". This option ++is used as a hint to user space that the mount entry should be ommitted from ++mount table listings. The default is "no" to avoid unexpected changes in ++behaviour and so is an opt-in setting. ++.TP + .B sss_master_map_wait + .br + Set the time to wait and retry if sssd returns "no such entry" when starting +--- autofs-5.0.7.orig/redhat/autofs.conf.default.in ++++ autofs-5.0.7/redhat/autofs.conf.default.in +@@ -183,6 +183,15 @@ mount_nfs_default_protocol = 4 + # + #disable_not_found_message = "no" + # ++# use_ignore_mount_option - This option is used to enable the use of autofs ++# pseudo option "disable". This option is used as a ++# hint to user space that the mount entry should be ++# ommitted from mount table listings. The default is ++# "no" to avoid unexpected changes in behaviour and ++# so is an opt-in setting. ++# ++#use_ignore_mount_option = no ++# + # sss_master_map_wait - When sssd is starting up it can sometimes return + # "no such entry" for a short time until it has read + # in the LDAP map information. Internal default is 0 +--- autofs-5.0.7.orig/samples/autofs.conf.default.in ++++ autofs-5.0.7/samples/autofs.conf.default.in +@@ -182,6 +182,15 @@ browse_mode = no + # + #disable_not_found_message = "no" + # ++# use_ignore_mount_option - This option is used to enable the use of autofs ++# pseudo option "disable". This option is used as a ++# hint to user space that the mount entry should be ++# ommitted from mount table listings. The default is ++# "no" to avoid unexpected changes in behaviour and ++# so is an opt-in setting. ++# ++#use_ignore_mount_option = no ++# + # sss_master_map_wait - When sssd is starting up it can sometimes return + # "no such entry" for a short time until it has read + # in the LDAP map information. Internal default is 0 diff --git a/SOURCES/autofs-5.1.5-add-glibc-getmntent.patch b/SOURCES/autofs-5.1.5-add-glibc-getmntent.patch new file mode 100644 index 0000000..70fc161 --- /dev/null +++ b/SOURCES/autofs-5.1.5-add-glibc-getmntent.patch @@ -0,0 +1,127 @@ +autofs-5.1.5 - add glibc getmntent_r() + +From: Ian Kent + +Add a slightly modified version of the glibc getmntent_r() function +so autofs can read the proc mount table directly. + +Signed-off-by: Ian Kent +--- + CHANGELOG | 1 + lib/mounts.c | 95 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + 2 files changed, 96 insertions(+) + +--- autofs-5.0.7.orig/CHANGELOG ++++ autofs-5.0.7/CHANGELOG +@@ -340,6 +340,7 @@ + - use bit flags for autofs mount types in mnt_list. + - use mp instead of path in mnt_list entries. + - always use PROC_MOUNTS to make mount lists. ++- add glibc getmntent_r(). + + 25/07/2012 autofs-5.0.7 + ======================= +--- autofs-5.0.7.orig/lib/mounts.c ++++ autofs-5.0.7/lib/mounts.c +@@ -787,6 +787,101 @@ done: + return ret; + } + ++/* From glibc decode_name() */ ++/* Since the values in a line are separated by spaces, a name cannot ++ * contain a space. Therefore some programs encode spaces in names ++ * by the strings "\040". We undo the encoding when reading an entry. ++ * The decoding happens in place. ++ */ ++static char *local_decode_name(char *buf) ++{ ++ char *rp = buf; ++ char *wp = buf; ++ ++ do { ++ if (rp[0] == '\\' && rp[1] == '0' && ++ rp[2] == '4' && rp[3] == '0') { ++ /* \040 is a SPACE. */ ++ *wp++ = ' '; ++ rp += 3; ++ } else if (rp[0] == '\\' && rp[1] == '0' && ++ rp[2] == '1' && rp[3] == '1') { ++ /* \011 is a TAB. */ ++ *wp++ = '\t'; ++ rp += 3; ++ } else if (rp[0] == '\\' && rp[1] == '0' && ++ rp[2] == '1' && rp[3] == '2') { ++ /* \012 is a NEWLINE. */ ++ *wp++ = '\n'; ++ rp += 3; ++ } else if (rp[0] == '\\' && rp[1] == '\\') { ++ /* ++ * We have to escape \\ to be able to represent ++ * all characters. ++ */ ++ *wp++ = '\\'; ++ rp += 1; ++ } else if (rp[0] == '\\' && rp[1] == '1' && ++ rp[2] == '3' && rp[3] == '4') { ++ /* \134 is also \\. */ ++ *wp++ = '\\'; ++ rp += 3; ++ } else ++ *wp++ = *rp; ++ } while (*rp++ != '\0'); ++ ++ return buf; ++} ++ ++/* From glibc getmntent_r() */ ++static struct mntent * ++local_getmntent_r(FILE *tab, struct mntent *mnt, char *buf, int size) ++{ ++ char *cp, *head; ++ ++ do { ++ char *end_ptr; ++ ++ if (fgets(buf, size, tab) == NULL) ++ return 0; ++ ++ end_ptr = strchr(buf, '\n'); ++ if (end_ptr != NULL) { ++ while (end_ptr[-1] == ' ' || end_ptr[-1] == '\t') ++ end_ptr--; ++ *end_ptr = '\0'; ++ } else { ++ /* Whole line was not read. Do it now but forget it. */ ++ char tmp[1024]; ++ while (fgets(tmp, sizeof tmp, tab) != NULL) ++ if (strchr(tmp, '\n') != NULL) ++ break; ++ } ++ ++ head = buf + strspn(buf, " \t"); ++ /* skip empty lines and comment lines */ ++ } while (head[0] == '\0' || head[0] == '#'); ++ ++ cp = strsep(&head, " \t"); ++ mnt->mnt_fsname = cp != NULL ? local_decode_name(cp) : (char *) ""; ++ if (head) ++ head += strspn(head, " \t"); ++ cp = strsep(&head, " \t"); ++ mnt->mnt_dir = cp != NULL ? local_decode_name (cp) : (char *) ""; ++ if (head) ++ head += strspn(head, " \t"); ++ cp = strsep(&head, " \t"); ++ mnt->mnt_type = cp != NULL ? local_decode_name (cp) : (char *) ""; ++ if (head) ++ head += strspn (head, " \t"); ++ cp = strsep (&head, " \t"); ++ mnt->mnt_opts = cp != NULL ? local_decode_name (cp) : (char *) ""; ++ ++ /* autofs doesn't need freq or passno */ ++ ++ return mnt; ++} ++ + /* + * Get list of mounts under path in longest->shortest order + */ diff --git a/SOURCES/autofs-5.1.5-add-ignore-mount-option.patch b/SOURCES/autofs-5.1.5-add-ignore-mount-option.patch new file mode 100644 index 0000000..b081e77 --- /dev/null +++ b/SOURCES/autofs-5.1.5-add-ignore-mount-option.patch @@ -0,0 +1,90 @@ +autofs-5.1.5 - add ignore mount option + +From: Ian Kent + +Add mount option "ignore", if the kernel supports it, as an +indicator to applications to ignore the mount entry. + +Signed-off-by: Ian Kent +--- + CHANGELOG | 1 + + daemon/direct.c | 10 ++++++++++ + daemon/indirect.c | 10 ++++++++++ + include/automount.h | 3 +++ + lib/master.c | 4 ++-- + 5 files changed, 26 insertions(+), 2 deletions(-) + +--- autofs-5.0.7.orig/daemon/direct.c ++++ autofs-5.0.7/daemon/direct.c +@@ -423,6 +423,16 @@ int do_mount_autofs_direct(struct autofs + mp->options = tmp; + } + } ++ ++ if ((ap->flags & MOUNT_FLAG_IGNORE) && ++ ((get_kver_major() == 5 && get_kver_minor() > 4) || ++ (get_kver_major() > 5))) { ++ char *tmp = realloc(mp->options, strlen(mp->options) + 7); ++ if (tmp) { ++ strcat(tmp, ",ignore"); ++ mp->options = tmp; ++ } ++ } + } + + /* In case the directory doesn't exist, try to mkdir it */ +--- autofs-5.0.7.orig/daemon/indirect.c ++++ autofs-5.0.7/daemon/indirect.c +@@ -132,6 +132,16 @@ static int do_mount_autofs_indirect(stru + } + } + ++ if ((ap->flags & MOUNT_FLAG_IGNORE) && ++ ((get_kver_major() == 5 && get_kver_minor() > 4) || ++ (get_kver_major() > 5))) { ++ char *tmp = realloc(options, strlen(options) + 7); ++ if (tmp) { ++ strcat(tmp, ",ignore"); ++ options = tmp; ++ } ++ } ++ + /* In case the directory doesn't exist, try to mkdir it */ + if (mkdir_path(root, 0555) < 0) { + if (errno != EEXIST && errno != EROFS) { +--- autofs-5.0.7.orig/include/automount.h ++++ autofs-5.0.7/include/automount.h +@@ -541,6 +541,9 @@ struct kernel_mod_version { + /* Use strict expire semantics if requested and kernel supports it */ + #define MOUNT_FLAG_STRICTEXPIRE 0x0400 + ++/* Indicator for applications to ignore the mount entry */ ++#define MOUNT_FLAG_IGNORE 0x0800 ++ + struct autofs_point { + pthread_t thid; + char *path; /* Mount point name */ +--- autofs-5.0.7.orig/lib/master.c ++++ autofs-5.0.7/lib/master.c +@@ -101,9 +101,9 @@ int master_add_autofs_point(struct maste + ap->negative_timeout = global_negative_timeout; + ap->exp_timeout = defaults_get_timeout(); + ap->exp_runfreq = 0; +- ap->flags = 0; ++ ap->flags = MOUNT_FLAG_IGNORE; + if (ghost) +- ap->flags = MOUNT_FLAG_GHOST; ++ ap->flags |= MOUNT_FLAG_GHOST; + + if (nobind) + ap->flags |= MOUNT_FLAG_NOBIND; +--- autofs-5.0.7.orig/CHANGELOG ++++ autofs-5.0.7/CHANGELOG +@@ -334,6 +334,7 @@ + - remove a couple of old debug messages. + - fix amd entry memory leak. + - fix unlink_mount_tree() not umounting mounts. ++- add ignore mount option. + + 25/07/2012 autofs-5.0.7 + ======================= diff --git a/SOURCES/autofs-5.1.5-always-use-PROC_MOUNTS-to-make-mount-lists.patch b/SOURCES/autofs-5.1.5-always-use-PROC_MOUNTS-to-make-mount-lists.patch new file mode 100644 index 0000000..e605136 --- /dev/null +++ b/SOURCES/autofs-5.1.5-always-use-PROC_MOUNTS-to-make-mount-lists.patch @@ -0,0 +1,377 @@ +autofs-5.1.5 - always use PROC_MOUNTS to make mount lists + +From: Ian Kent + +If it's necessary to read a mount table then always use the proc file +system mount table. + +This could be very inefficient for cases where the mtab (_PATH_MOUNTED) +is specified but the mtab has been a symlink to the proc mount tables +for quite a while now so it doesn't make any difference always using +the proc tables. + +Signed-off-by: Ian Kent +--- + CHANGELOG | 1 + + daemon/automount.c | 6 +++--- + daemon/direct.c | 14 +++++++------- + daemon/indirect.c | 8 ++++---- + daemon/lookup.c | 4 ++-- + daemon/spawn.c | 2 +- + daemon/state.c | 2 +- + include/mounts.h | 6 +++--- + lib/mounts.c | 32 ++++++++++++++++---------------- + modules/parse_amd.c | 4 ++-- + 10 files changed, 40 insertions(+), 39 deletions(-) + +--- autofs-5.0.7.orig/CHANGELOG ++++ autofs-5.0.7/CHANGELOG +@@ -339,6 +339,7 @@ + - add config option for "ignore" mount option + - use bit flags for autofs mount types in mnt_list. + - use mp instead of path in mnt_list entries. ++- always use PROC_MOUNTS to make mount lists. + + 25/07/2012 autofs-5.0.7 + ======================= +--- autofs-5.0.7.orig/daemon/automount.c ++++ autofs-5.0.7/daemon/automount.c +@@ -331,7 +331,7 @@ static int walk_tree(const char *base, i + struct stat st, *pst = &st; + int ret; + +- if (!is_mounted(_PATH_MOUNTED, base, MNTS_REAL)) ++ if (!is_mounted(base, MNTS_REAL)) + ret = lstat(base, pst); + else { + pst = NULL; +@@ -595,11 +595,11 @@ static int umount_subtree_mounts(struct + * If this is the root of a multi-mount we've had to umount + * it already to ensure it's ok to remove any offset triggers. + */ +- if (!is_mm_root && is_mounted(_PATH_MOUNTED, path, MNTS_REAL)) { ++ if (!is_mm_root && is_mounted(path, MNTS_REAL)) { + struct amd_entry *entry; + debug(ap->logopt, "unmounting dir = %s", path); + if (umount_ent(ap, path) && +- is_mounted(_PATH_MOUNTED, path, MNTS_REAL)) { ++ is_mounted(path, MNTS_REAL)) { + warn(ap->logopt, "could not umount dir %s", path); + left++; + goto done; +--- autofs-5.0.7.orig/daemon/direct.c ++++ autofs-5.0.7/daemon/direct.c +@@ -207,7 +207,7 @@ int umount_autofs_direct(struct autofs_p + struct mnt_list *mnts; + struct mapent *me, *ne; + +- mnts = tree_make_mnt_tree(_PROC_MOUNTS, "/"); ++ mnts = tree_make_mnt_tree("/"); + pthread_cleanup_push(mnts_cleanup, mnts); + nc = ap->entry->master->nc; + cache_readlock(nc); +@@ -521,7 +521,7 @@ int mount_autofs_direct(struct autofs_po + return -1; + } + +- mnts = tree_make_mnt_tree(_PROC_MOUNTS, "/"); ++ mnts = tree_make_mnt_tree("/"); + pthread_cleanup_push(mnts_cleanup, mnts); + pthread_cleanup_push(master_source_lock_cleanup, ap->entry); + master_source_readlock(ap->entry); +@@ -589,7 +589,7 @@ int umount_autofs_offset(struct autofs_p + int opened = 0; + + if (me->ioctlfd != -1) { +- if (is_mounted(_PATH_MOUNTED, me->key, MNTS_REAL)) { ++ if (is_mounted(me->key, MNTS_REAL)) { + error(ap->logopt, + "attempt to umount busy offset %s", me->key); + return 1; +@@ -597,7 +597,7 @@ int umount_autofs_offset(struct autofs_p + ioctlfd = me->ioctlfd; + } else { + /* offset isn't mounted, return success and try to recover */ +- if (!is_mounted(_PROC_MOUNTS, me->key, MNTS_AUTOFS)) { ++ if (!is_mounted(me->key, MNTS_AUTOFS)) { + debug(ap->logopt, + "offset %s not mounted", + me->key); +@@ -713,7 +713,7 @@ int mount_autofs_offset(struct autofs_po + if (!(ret == -1 && errno == ENOENT)) + return MOUNT_OFFSET_FAIL; + } else { +- if (is_mounted(_PROC_MOUNTS, me->key, MNTS_AUTOFS)) { ++ if (is_mounted(me->key, MNTS_AUTOFS)) { + if (ap->state != ST_READMAP) + warn(ap->logopt, + "trigger %s already mounted", me->key); +@@ -767,7 +767,7 @@ int mount_autofs_offset(struct autofs_po + * the kernel NFS client. + */ + if (me->multi != me && +- is_mounted(_PROC_MOUNTS, mountpoint, MNTS_REAL)) ++ is_mounted(mountpoint, MNTS_REAL)) + return MOUNT_OFFSET_IGNORE; + + /* +@@ -887,7 +887,7 @@ void *expire_proc_direct(void *arg) + + left = 0; + +- mnts = tree_make_mnt_tree(_PROC_MOUNTS, "/"); ++ mnts = tree_make_mnt_tree("/"); + pthread_cleanup_push(mnts_cleanup, mnts); + + /* Get a list of mounts select real ones and expire them if possible */ +--- autofs-5.0.7.orig/daemon/indirect.c ++++ autofs-5.0.7/daemon/indirect.c +@@ -103,7 +103,7 @@ static int do_mount_autofs_indirect(stru + if (ret == 0) + return -1; + } else { +- mnts = get_mnt_list(_PROC_MOUNTS, ap->path, 1); ++ mnts = get_mnt_list(ap->path, 1); + if (mnts) { + ret = unlink_mount_tree(ap, mnts); + free_mnt_list(mnts); +@@ -429,7 +429,7 @@ void *expire_proc_indirect(void *arg) + left = 0; + + /* Get a list of real mounts and expire them if possible */ +- mnts = get_mnt_list(_PROC_MOUNTS, ap->path, 0); ++ mnts = get_mnt_list(ap->path, 0); + pthread_cleanup_push(mnts_cleanup, mnts); + for (next = mnts; next; next = next->next) { + char *ind_key; +@@ -450,7 +450,7 @@ void *expire_proc_indirect(void *arg) + struct stat st; + + /* It's got a mount, deal with in the outer loop */ +- if (is_mounted(_PATH_MOUNTED, next->mp, MNTS_REAL)) { ++ if (is_mounted(next->mp, MNTS_REAL)) { + pthread_setcancelstate(cur_state, NULL); + continue; + } +@@ -559,7 +559,7 @@ void *expire_proc_indirect(void *arg) + pthread_cleanup_pop(1); + + count = offsets = submnts = 0; +- mnts = get_mnt_list(_PROC_MOUNTS, ap->path, 0); ++ mnts = get_mnt_list(ap->path, 0); + pthread_cleanup_push(mnts_cleanup, mnts); + /* Are there any real mounts left */ + for (next = mnts; next; next = next->next) { +--- autofs-5.0.7.orig/daemon/lookup.c ++++ autofs-5.0.7/daemon/lookup.c +@@ -1419,7 +1419,7 @@ void lookup_prune_one_cache(struct autof + valid = NULL; + } + if (!valid && +- is_mounted(_PATH_MOUNTED, path, MNTS_REAL)) { ++ is_mounted(path, MNTS_REAL)) { + debug(ap->logopt, "prune posponed, %s mounted", path); + free(key); + free(path); +@@ -1442,7 +1442,7 @@ void lookup_prune_one_cache(struct autof + + if (valid) + cache_delete(mc, key); +- else if (!is_mounted(_PROC_MOUNTS, path, MNTS_AUTOFS)) { ++ else if (!is_mounted(path, MNTS_AUTOFS)) { + dev_t devid = ap->dev; + status = CHE_FAIL; + if (ap->type == LKP_DIRECT) +--- autofs-5.0.7.orig/daemon/spawn.c ++++ autofs-5.0.7/daemon/spawn.c +@@ -406,7 +406,7 @@ static int do_spawn(unsigned logopt, uns + if (!is_bind) + goto done; + +- if (is_mounted(_PROC_MOUNTS, argv[loc], MNTS_AUTOFS)) { ++ if (is_mounted(argv[loc], MNTS_AUTOFS)) { + fprintf(stderr, + "error: can't bind to an autofs mount\n"); + close(STDOUT_FILENO); +--- autofs-5.0.7.orig/daemon/state.c ++++ autofs-5.0.7/daemon/state.c +@@ -499,7 +499,7 @@ static void *do_readmap(void *arg) + struct mapent *me; + unsigned int append_alarm = !ap->exp_runfreq; + +- mnts = tree_make_mnt_tree(_PROC_MOUNTS, "/"); ++ mnts = tree_make_mnt_tree("/"); + pthread_cleanup_push(tree_mnts_cleanup, mnts); + nc = ap->entry->master->nc; + cache_readlock(nc); +--- autofs-5.0.7.orig/include/mounts.h ++++ autofs-5.0.7/include/mounts.h +@@ -99,11 +99,11 @@ char *make_mnt_name_string(char *path); + int ext_mount_add(struct list_head *, const char *, unsigned int); + int ext_mount_remove(struct list_head *, const char *); + int ext_mount_inuse(const char *); +-struct mnt_list *get_mnt_list(const char *table, const char *path, int include); ++struct mnt_list *get_mnt_list(const char *path, int include); + void free_mnt_list(struct mnt_list *list); +-int is_mounted(const char *table, const char *mp, unsigned int type); ++int is_mounted(const char *mp, unsigned int type); + void tree_free_mnt_tree(struct mnt_list *tree); +-struct mnt_list *tree_make_mnt_tree(const char *table, const char *path); ++struct mnt_list *tree_make_mnt_tree(const char *path); + int tree_get_mnt_list(struct mnt_list *mnts, struct list_head *list, const char *path, int include); + int tree_get_mnt_sublist(struct mnt_list *mnts, struct list_head *list, const char *path, int include); + int tree_find_mnt_ents(struct mnt_list *mnts, struct list_head *list, const char *path); +--- autofs-5.0.7.orig/lib/mounts.c ++++ autofs-5.0.7/lib/mounts.c +@@ -790,7 +790,7 @@ done: + /* + * Get list of mounts under path in longest->shortest order + */ +-struct mnt_list *get_mnt_list(const char *table, const char *path, int include) ++struct mnt_list *get_mnt_list(const char *path, int include) + { + FILE *tab; + size_t pathlen = strlen(path); +@@ -804,7 +804,7 @@ struct mnt_list *get_mnt_list(const char + if (!path || !pathlen || pathlen > PATH_MAX) + return NULL; + +- tab = open_setmntent_r(table); ++ tab = open_setmntent_r(_PROC_MOUNTS); + if (!tab) { + char *estr = strerror_r(errno, buf, PATH_MAX - 1); + logerr("setmntent: %s", estr); +@@ -893,7 +893,7 @@ void free_mnt_list(struct mnt_list *list + } + } + +-static int table_is_mounted(const char *table, const char *mp, unsigned int type) ++static int table_is_mounted(const char *mp, unsigned int type) + { + struct mntent *mnt; + struct mntent mnt_wrk; +@@ -905,7 +905,7 @@ static int table_is_mounted(const char * + if (!mp || !mp_len || mp_len >= PATH_MAX) + return 0; + +- tab = open_setmntent_r(table); ++ tab = open_setmntent_r(_PROC_MOUNTS); + if (!tab) { + char *estr = strerror_r(errno, buf, PATH_MAX - 1); + logerr("setmntent: %s", estr); +@@ -958,14 +958,14 @@ static int ioctl_is_mounted(const char * + return 0; + } + +-int is_mounted(const char *table, const char *mp, unsigned int type) ++int is_mounted(const char *mp, unsigned int type) + { + struct ioctl_ops *ops = get_ioctl_ops(); + + if (ops->ismountpoint) + return ioctl_is_mounted(mp, type); + else +- return table_is_mounted(table, mp, type); ++ return table_is_mounted(mp, type); + } + + /* +@@ -1012,7 +1012,7 @@ void tree_free_mnt_tree(struct mnt_list + /* + * Make tree of system mounts in /proc/mounts. + */ +-struct mnt_list *tree_make_mnt_tree(const char *table, const char *path) ++struct mnt_list *tree_make_mnt_tree(const char *path) + { + FILE *tab; + struct mntent mnt_wrk; +@@ -1023,7 +1023,7 @@ struct mnt_list *tree_make_mnt_tree(cons + size_t plen; + int eq; + +- tab = open_setmntent_r(table); ++ tab = open_setmntent_r(_PROC_MOUNTS); + if (!tab) { + char *estr = strerror_r(errno, buf, PATH_MAX - 1); + logerr("setmntent: %s", estr); +@@ -1851,7 +1851,7 @@ void set_indirect_mount_tree_catatonic(s + struct mapent_cache *mc; + struct mapent *me; + +- if (!is_mounted(_PROC_MOUNTS, ap->path, MNTS_AUTOFS)) ++ if (!is_mounted(ap->path, MNTS_AUTOFS)) + return; + + map = entry->maps; +@@ -1915,7 +1915,7 @@ int umount_ent(struct autofs_point *ap, + * so that we do not try to call rmdir_path on the + * directory. + */ +- if (!rv && is_mounted(_PATH_MOUNTED, path, MNTS_REAL)) { ++ if (!rv && is_mounted(path, MNTS_REAL)) { + crit(ap->logopt, + "the umount binary reported that %s was " + "unmounted, but there is still something " +@@ -2048,7 +2048,7 @@ int mount_multi_triggers(struct autofs_p + */ + if (ap->state == ST_READMAP && ap->flags & MOUNT_FLAG_REMOUNT) { + if (oe->ioctlfd != -1 || +- is_mounted(_PROC_MOUNTS, oe->key, MNTS_REAL)) { ++ is_mounted(oe->key, MNTS_REAL)) { + char oe_root[PATH_MAX + 1]; + strcpy(oe_root, root); + strcat(oe_root, offset); +@@ -2137,7 +2137,7 @@ int umount_multi_triggers(struct autofs_ + left += umount_multi_triggers(ap, oe, root, oe_base); + + if (oe->ioctlfd != -1 || +- is_mounted(_PROC_MOUNTS, oe->key, MNTS_REAL)) { ++ is_mounted(oe->key, MNTS_REAL)) { + left++; + continue; + } +@@ -2180,10 +2180,10 @@ int umount_multi_triggers(struct autofs_ + * delete the offsets from the cache and we need to put + * the offset triggers back. + */ +- if (is_mounted(_PATH_MOUNTED, root, MNTS_REAL)) { ++ if (is_mounted(root, MNTS_REAL)) { + info(ap->logopt, "unmounting dir = %s", root); + if (umount_ent(ap, root) && +- is_mounted(_PATH_MOUNTED, root, MNTS_REAL)) { ++ is_mounted(root, MNTS_REAL)) { + if (mount_multi_triggers(ap, me, root, strlen(root), "/") < 0) + warn(ap->logopt, + "failed to remount offset triggers"); +@@ -2283,9 +2283,9 @@ int clean_stale_multi_triggers(struct au + * ESTALE errors when attempting list the directory. + */ + if (oe->ioctlfd != -1 || +- is_mounted(_PROC_MOUNTS, oe->key, MNTS_REAL)) { ++ is_mounted(oe->key, MNTS_REAL)) { + if (umount_ent(ap, oe->key) && +- is_mounted(_PROC_MOUNTS, oe->key, MNTS_REAL)) { ++ is_mounted(oe->key, MNTS_REAL)) { + debug(ap->logopt, + "offset %s has active mount, invalidate", + oe->key); +--- autofs-5.0.7.orig/modules/parse_amd.c ++++ autofs-5.0.7/modules/parse_amd.c +@@ -1175,7 +1175,7 @@ static int do_generic_mount(struct autof + * multiple times since they are outside of + * the automount filesystem. + */ +- if (!is_mounted(_PATH_MOUNTED, entry->fs, MNTS_REAL)) { ++ if (!is_mounted(entry->fs, MNTS_REAL)) { + ret = do_mount(ap, entry->fs, "/", 1, + target, entry->type, opts); + if (ret) +@@ -1218,7 +1218,7 @@ static int do_nfs_mount(struct autofs_po + target, entry->type, opts, + mount_nfs->context); + } else { +- if (!is_mounted(_PATH_MOUNTED, entry->fs, MNTS_REAL)) { ++ if (!is_mounted(entry->fs, MNTS_REAL)) { + ret = mount_nfs->mount_mount(ap, entry->fs, "/", 1, + target, entry->type, opts, + mount_nfs->context); diff --git a/SOURCES/autofs-5.1.5-dont-use-tree_is_mounted-for-mounted-checks.patch b/SOURCES/autofs-5.1.5-dont-use-tree_is_mounted-for-mounted-checks.patch new file mode 100644 index 0000000..00943f8 --- /dev/null +++ b/SOURCES/autofs-5.1.5-dont-use-tree_is_mounted-for-mounted-checks.patch @@ -0,0 +1,172 @@ +autofs-5.1.5 - don't use tree_is_mounted() for mounted checks + +From: Ian Kent + +Always use is_mounted() for mounted checks. + +If the proc mount table actually needs to be used this could be +very inefficient but the miscelaneous device ioctl interface +has been available to quite a few years now so it really needs +to be used to avoid the scanning of mount tables. + +Signed-off-by: Ian Kent +--- + CHANGELOG | 1 + + daemon/direct.c | 12 ++++-------- + daemon/state.c | 4 ++-- + include/automount.h | 2 +- + include/mounts.h | 1 - + lib/mounts.c | 40 ---------------------------------------- + 6 files changed, 8 insertions(+), 52 deletions(-) + +--- autofs-5.0.7.orig/CHANGELOG ++++ autofs-5.0.7/CHANGELOG +@@ -343,6 +343,7 @@ + - add glibc getmntent_r(). + - use local getmntent_r in table_is_mounted(). + - refactor unlink_active_mounts() in direct.c. ++- don't use tree_is_mounted() for mounted checks. + + 25/07/2012 autofs-5.0.7 + ======================= +--- autofs-5.0.7.orig/daemon/direct.c ++++ autofs-5.0.7/daemon/direct.c +@@ -82,7 +82,7 @@ static void mnts_cleanup(void *arg) + return; + } + +-int do_umount_autofs_direct(struct autofs_point *ap, struct mnt_list *mnts, struct mapent *me) ++int do_umount_autofs_direct(struct autofs_point *ap, struct mapent *me) + { + struct ioctl_ops *ops = get_ioctl_ops(); + char buf[MAX_ERR_BUF]; +@@ -98,7 +98,7 @@ int do_umount_autofs_direct(struct autof + + if (me->ioctlfd != -1) { + if (ap->state == ST_READMAP && +- tree_is_mounted(mnts, me->key, MNTS_REAL)) { ++ is_mounted(me->key, MNTS_REAL)) { + error(ap->logopt, + "attempt to umount busy direct mount %s", + me->key); +@@ -204,11 +204,8 @@ int umount_autofs_direct(struct autofs_p + { + struct map_source *map; + struct mapent_cache *nc, *mc; +- struct mnt_list *mnts; + struct mapent *me, *ne; + +- mnts = tree_make_mnt_tree("/"); +- pthread_cleanup_push(mnts_cleanup, mnts); + nc = ap->entry->master->nc; + cache_readlock(nc); + pthread_cleanup_push(cache_lock_cleanup, nc); +@@ -233,7 +230,7 @@ int umount_autofs_direct(struct autofs_p + * catatonic regardless of the reason for the + * failed umount. + */ +- error = do_umount_autofs_direct(ap, mnts, me); ++ error = do_umount_autofs_direct(ap, me); + if (!error) + goto done; + +@@ -246,7 +243,6 @@ done: + map = map->next; + } + pthread_cleanup_pop(1); +- pthread_cleanup_pop(1); + + close(ap->state_pipe[0]); + close(ap->state_pipe[1]); +@@ -933,7 +929,7 @@ void *expire_proc_direct(void *arg) + } + + /* It's got a mount, deal with in the outer loop */ +- if (tree_is_mounted(mnts, me->key, MNTS_REAL)) { ++ if (is_mounted(me->key, MNTS_REAL)) { + pthread_setcancelstate(cur_state, NULL); + continue; + } +--- autofs-5.0.7.orig/daemon/state.c ++++ autofs-5.0.7/daemon/state.c +@@ -438,8 +438,8 @@ static void do_readmap_mount(struct auto + else + ap->exp_runfreq = runfreq; + } +- } else if (!tree_is_mounted(mnts, me->key, MNTS_REAL)) +- do_umount_autofs_direct(ap, mnts, me); ++ } else if (!is_mounted(me->key, MNTS_REAL)) ++ do_umount_autofs_direct(ap, me); + else + debug(ap->logopt, + "%s is mounted", me->key); +--- autofs-5.0.7.orig/include/automount.h ++++ autofs-5.0.7/include/automount.h +@@ -597,7 +597,7 @@ void submount_signal_parent(struct autof + void close_mount_fds(struct autofs_point *ap); + int umount_autofs(struct autofs_point *ap, const char *root, int force); + int umount_autofs_indirect(struct autofs_point *ap, const char *root); +-int do_umount_autofs_direct(struct autofs_point *ap, struct mnt_list *mnts, struct mapent *me); ++int do_umount_autofs_direct(struct autofs_point *ap, struct mapent *me); + int umount_autofs_direct(struct autofs_point *ap); + int umount_autofs_offset(struct autofs_point *ap, struct mapent *me); + int handle_packet_expire_indirect(struct autofs_point *ap, autofs_packet_expire_indirect_t *pkt); +--- autofs-5.0.7.orig/include/mounts.h ++++ autofs-5.0.7/include/mounts.h +@@ -107,7 +107,6 @@ struct mnt_list *tree_make_mnt_tree(cons + int tree_get_mnt_list(struct mnt_list *mnts, struct list_head *list, const char *path, int include); + int tree_get_mnt_sublist(struct mnt_list *mnts, struct list_head *list, const char *path, int include); + int tree_find_mnt_ents(struct mnt_list *mnts, struct list_head *list, const char *path); +-int tree_is_mounted(struct mnt_list *mnts, const char *path, unsigned int type); + void set_tsd_user_vars(unsigned int, uid_t, gid_t); + const char *mount_type_str(unsigned int); + void set_exp_timeout(struct autofs_point *ap, struct map_source *source, time_t timeout); +--- autofs-5.0.7.orig/lib/mounts.c ++++ autofs-5.0.7/lib/mounts.c +@@ -1362,46 +1362,6 @@ int tree_find_mnt_ents(struct mnt_list * + return 0; + } + +-int tree_is_mounted(struct mnt_list *mnts, const char *path, unsigned int type) +-{ +- struct ioctl_ops *ops = get_ioctl_ops(); +- struct list_head *p; +- struct list_head list; +- int mounted = 0; +- +- if (ops->ismountpoint) +- return ioctl_is_mounted(path, type); +- +- INIT_LIST_HEAD(&list); +- +- if (!tree_find_mnt_ents(mnts, &list, path)) +- return 0; +- +- list_for_each(p, &list) { +- struct mnt_list *mptr; +- +- mptr = list_entry(p, struct mnt_list, entries); +- +- if (type) { +- if (type & MNTS_REAL) { +- if (mptr->flags & MNTS_AUTOFS) { +- mounted = 1; +- break; +- } +- } else if (type & MNTS_AUTOFS) { +- if (mptr->flags & MNTS_AUTOFS) { +- mounted = 1; +- break; +- } +- } else { +- mounted = 1; +- break; +- } +- } +- } +- return mounted; +-} +- + void set_tsd_user_vars(unsigned int logopt, uid_t uid, gid_t gid) + { + struct thread_stdenv_vars *tsv; diff --git a/SOURCES/autofs-5.1.5-fix-amd-entry-memory-leak.patch b/SOURCES/autofs-5.1.5-fix-amd-entry-memory-leak.patch new file mode 100644 index 0000000..42c48dc --- /dev/null +++ b/SOURCES/autofs-5.1.5-fix-amd-entry-memory-leak.patch @@ -0,0 +1,33 @@ +autofs-5.1.5 - fix amd entry memory leak + +From: Ian Kent + +Fix an incorrect free of an amd_entry structure. + +Signed-off-by: Ian Kent +--- + CHANGELOG | 1 + + lib/master.c | 2 +- + 2 files changed, 2 insertions(+), 1 deletion(-) + +--- autofs-5.0.7.orig/CHANGELOG ++++ autofs-5.0.7/CHANGELOG +@@ -332,6 +332,7 @@ + - remove unused function has_fstab_option(). + - remove unused function reverse_mnt_list(). + - remove a couple of old debug messages. ++- fix amd entry memory leak. + + 25/07/2012 autofs-5.0.7 + ======================= +--- autofs-5.0.7.orig/lib/master.c ++++ autofs-5.0.7/lib/master.c +@@ -154,7 +154,7 @@ void master_free_autofs_point(struct aut + ext_mount_remove(&entry->ext_mount, entry->fs); + if (!list_empty(&entry->entries)) + list_del(&entry->entries); +- free(entry); ++ free_amd_entry(entry); + } + mounts_mutex_unlock(ap); + diff --git a/SOURCES/autofs-5.1.5-fix-missing-initialization-of-autofs_point-flags.patch b/SOURCES/autofs-5.1.5-fix-missing-initialization-of-autofs_point-flags.patch new file mode 100644 index 0000000..dc4f9ae --- /dev/null +++ b/SOURCES/autofs-5.1.5-fix-missing-initialization-of-autofs_point-flags.patch @@ -0,0 +1,34 @@ +autofs-5.1.5 - fix missing initialization of autofs_point flags + +From: Ian Kent + +When adding the "use_ignore_mount_option" configuration option I added +a "use without initialization" for ap->flags. + +Signed-off-by: Ian Kent +--- + CHANGELOG | 1 + + lib/master.c | 2 ++ + 2 files changed, 3 insertions(+) + +--- autofs-5.0.7.orig/CHANGELOG ++++ autofs-5.0.7/CHANGELOG +@@ -349,6 +349,7 @@ + - use local_getmntent_r() for unlink_mount_tree(). + - use local getmntent_r() in get_mnt_list(). + - use local getmntent_r() in tree_make_mnt_list(). ++- fix missing initialization of autofs_point flags. + + 25/07/2012 autofs-5.0.7 + ======================= +--- autofs-5.0.7.orig/lib/master.c ++++ autofs-5.0.7/lib/master.c +@@ -101,6 +101,8 @@ int master_add_autofs_point(struct maste + ap->negative_timeout = global_negative_timeout; + ap->exp_timeout = defaults_get_timeout(); + ap->exp_runfreq = 0; ++ ap->flags = 0; ++ + if (defaults_get_use_ignore_mount_option()) + ap->flags = MOUNT_FLAG_IGNORE; + if (ghost) diff --git a/SOURCES/autofs-5.1.5-fix-unlink_mount_tree-not-umounting-mounts.patch b/SOURCES/autofs-5.1.5-fix-unlink_mount_tree-not-umounting-mounts.patch new file mode 100644 index 0000000..104d1b1 --- /dev/null +++ b/SOURCES/autofs-5.1.5-fix-unlink_mount_tree-not-umounting-mounts.patch @@ -0,0 +1,136 @@ +autofs-5.1.5 - fix unlink_mount_tree() not umounting mounts + +From: Ian Kent + +At some point a check matching process group id of mounts was added to +the unlink_mount_tree() function so that mounts not matching the group +id of the calling process would be skipped. + +But unlink_mount_tree() is meant to force a cleanup of mounts from a +previous automount process so the process group of the current process +can never match so all mounts are skipped. + +Signed-off-by: Ian Kent +--- + CHANGELOG | 1 + + daemon/direct.c | 7 ------- + daemon/indirect.c | 9 --------- + include/mounts.h | 1 - + lib/mounts.c | 20 -------------------- + 5 files changed, 1 insertion(+), 37 deletions(-) + +--- autofs-5.0.7.orig/CHANGELOG ++++ autofs-5.0.7/CHANGELOG +@@ -333,6 +333,7 @@ + - remove unused function reverse_mnt_list(). + - remove a couple of old debug messages. + - fix amd entry memory leak. ++- fix unlink_mount_tree() not umounting mounts. + + 25/07/2012 autofs-5.0.7 + ======================= +--- autofs-5.0.7.orig/daemon/direct.c ++++ autofs-5.0.7/daemon/direct.c +@@ -264,10 +264,6 @@ static int unlink_mount_tree(struct auto + { + struct list_head *p; + int rv, ret; +- pid_t pgrp = getpgrp(); +- char spgrp[20]; +- +- sprintf(spgrp, "pgrp=%d", pgrp); + + ret = 1; + list_for_each(p, list) { +@@ -275,9 +271,6 @@ static int unlink_mount_tree(struct auto + + mnt = list_entry(p, struct mnt_list, list); + +- if (strstr(mnt->opts, spgrp)) +- continue; +- + if (strcmp(mnt->fs_type, "autofs")) + rv = spawn_umount(ap->logopt, "-l", mnt->path, NULL); + else +--- autofs-5.0.7.orig/daemon/indirect.c ++++ autofs-5.0.7/daemon/indirect.c +@@ -44,19 +44,10 @@ static int unlink_mount_tree(struct auto + { + struct mnt_list *this; + int rv, ret; +- pid_t pgrp = getpgrp(); +- char spgrp[20]; +- +- sprintf(spgrp, "pgrp=%d", pgrp); + + ret = 1; + this = mnts; + while (this) { +- if (strstr(this->opts, spgrp)) { +- this = this->next; +- continue; +- } +- + if (strcmp(this->fs_type, "autofs")) + rv = spawn_umount(ap->logopt, "-l", this->path, NULL); + else +--- autofs-5.0.7.orig/include/mounts.h ++++ autofs-5.0.7/include/mounts.h +@@ -53,7 +53,6 @@ struct mnt_list { + char *fs_name; + char *fs_type; + char *opts; +- pid_t owner; + /* + * List operations ie. get_mnt_list. + */ +--- autofs-5.0.7.orig/lib/mounts.c ++++ autofs-5.0.7/lib/mounts.c +@@ -799,7 +799,6 @@ struct mnt_list *get_mnt_list(const char + struct mntent *mnt; + struct mnt_list *ent, *mptr, *last; + struct mnt_list *list = NULL; +- char *pgrp; + size_t len; + + if (!path || !pathlen || pathlen > PATH_MAX) +@@ -880,15 +879,6 @@ struct mnt_list *get_mnt_list(const char + return NULL; + } + strcpy(ent->opts, mnt->mnt_opts); +- +- ent->owner = 0; +- pgrp = strstr(mnt->mnt_opts, "pgrp="); +- if (pgrp) { +- char *end = strchr(pgrp, ','); +- if (end) +- *end = '\0'; +- sscanf(pgrp, "pgrp=%d", &ent->owner); +- } + } + endmntent(tab); + +@@ -1062,7 +1052,6 @@ struct mnt_list *tree_make_mnt_tree(cons + struct mntent *mnt; + struct mnt_list *ent, *mptr; + struct mnt_list *tree = NULL; +- char *pgrp; + size_t plen; + int eq; + +@@ -1141,15 +1130,6 @@ struct mnt_list *tree_make_mnt_tree(cons + } + strcpy(ent->opts, mnt->mnt_opts); + +- ent->owner = 0; +- pgrp = strstr(mnt->mnt_opts, "pgrp="); +- if (pgrp) { +- char *end = strchr(pgrp, ','); +- if (end) +- *end = '\0'; +- sscanf(pgrp, "pgrp=%d", &ent->owner); +- } +- + mptr = tree; + while (mptr) { + int elen = strlen(ent->path); diff --git a/SOURCES/autofs-5.1.5-move-unlink_mount_tree-to-lib_mounts_c.patch b/SOURCES/autofs-5.1.5-move-unlink_mount_tree-to-lib_mounts_c.patch new file mode 100644 index 0000000..2b255a1 --- /dev/null +++ b/SOURCES/autofs-5.1.5-move-unlink_mount_tree-to-lib_mounts_c.patch @@ -0,0 +1,134 @@ +autofs-5.1.5 - move unlink_mount_tree() to lib/mounts.c + +From: Ian Kent + +Both daemon/direct.c and daemon/indirect.c use the same function to +lazy umount a list of mounts, move that function to lib/mounts.c. + +Signed-off-by: Ian Kent +--- + CHANGELOG | 1 + + daemon/direct.c | 2 -- + daemon/indirect.c | 34 ---------------------------------- + include/mounts.h | 1 + + lib/mounts.c | 35 +++++++++++++++++++++++++++++++++++ + 5 files changed, 37 insertions(+), 36 deletions(-) + +--- autofs-5.0.7.orig/CHANGELOG ++++ autofs-5.0.7/CHANGELOG +@@ -345,6 +345,7 @@ + - refactor unlink_active_mounts() in direct.c. + - don't use tree_is_mounted() for mounted checks. + - use single unlink_umount_tree() for both direct and indirect mounts. ++- move unlink_mount_tree() to lib/mounts.c. + + 25/07/2012 autofs-5.0.7 + ======================= +--- autofs-5.0.7.orig/daemon/direct.c ++++ autofs-5.0.7/daemon/direct.c +@@ -49,8 +49,6 @@ pthread_key_t key_mnt_direct_params; + pthread_key_t key_mnt_offset_params; + pthread_once_t key_mnt_params_once = PTHREAD_ONCE_INIT; + +-int unlink_mount_tree(struct autofs_point *ap, struct mnt_list *mnts); +- + static void key_mnt_params_destroy(void *arg) + { + struct mnt_params *mp; +--- autofs-5.0.7.orig/daemon/indirect.c ++++ autofs-5.0.7/daemon/indirect.c +@@ -40,40 +40,6 @@ + /* Attribute to create detached thread */ + extern pthread_attr_t th_attr_detached; + +-int unlink_mount_tree(struct autofs_point *ap, struct mnt_list *mnts) +-{ +- struct mnt_list *this; +- int rv, ret; +- +- ret = 1; +- this = mnts; +- while (this) { +- if (this->flags & MNTS_AUTOFS) +- rv = umount2(this->mp, MNT_DETACH); +- else +- rv = spawn_umount(ap->logopt, "-l", this->mp, NULL); +- if (rv == -1) { +- debug(ap->logopt, +- "can't unlink %s from mount tree", this->mp); +- +- switch (errno) { +- case EINVAL: +- warn(ap->logopt, +- "bad superblock or not mounted"); +- break; +- +- case ENOENT: +- case EFAULT: +- ret = 0; +- warn(ap->logopt, "bad path for mount"); +- break; +- } +- } +- this = this->next; +- } +- return ret; +-} +- + static int do_mount_autofs_indirect(struct autofs_point *ap, const char *root) + { + const char *str_indirect = mount_type_str(t_indirect); +--- autofs-5.0.7.orig/include/mounts.h ++++ autofs-5.0.7/include/mounts.h +@@ -100,6 +100,7 @@ int ext_mount_add(struct list_head *, co + int ext_mount_remove(struct list_head *, const char *); + int ext_mount_inuse(const char *); + struct mnt_list *get_mnt_list(const char *path, int include); ++int unlink_mount_tree(struct autofs_point *ap, struct mnt_list *mnts); + void free_mnt_list(struct mnt_list *list); + int is_mounted(const char *mp, unsigned int type); + void tree_free_mnt_tree(struct mnt_list *tree); +--- autofs-5.0.7.orig/lib/mounts.c ++++ autofs-5.0.7/lib/mounts.c +@@ -882,6 +882,41 @@ local_getmntent_r(FILE *tab, struct mnte + return mnt; + } + ++int unlink_mount_tree(struct autofs_point *ap, struct mnt_list *mnts) ++{ ++ struct mnt_list *this; ++ int rv, ret; ++ ++ ret = 1; ++ this = mnts; ++ while (this) { ++ if (this->flags & MNTS_AUTOFS) ++ rv = umount2(this->mp, MNT_DETACH); ++ else ++ rv = spawn_umount(ap->logopt, "-l", this->mp, NULL); ++ if (rv == -1) { ++ debug(ap->logopt, ++ "can't unlink %s from mount tree", this->mp); ++ ++ switch (errno) { ++ case EINVAL: ++ warn(ap->logopt, ++ "bad superblock or not mounted"); ++ break; ++ ++ case ENOENT: ++ case EFAULT: ++ ret = 0; ++ warn(ap->logopt, "bad path for mount"); ++ break; ++ } ++ } ++ this = this->next; ++ } ++ ++ return ret; ++} ++ + /* + * Get list of mounts under path in longest->shortest order + */ diff --git a/SOURCES/autofs-5.1.5-refactor-unlink_active_mounts-in-direct_c.patch b/SOURCES/autofs-5.1.5-refactor-unlink_active_mounts-in-direct_c.patch new file mode 100644 index 0000000..8ba98a5 --- /dev/null +++ b/SOURCES/autofs-5.1.5-refactor-unlink_active_mounts-in-direct_c.patch @@ -0,0 +1,116 @@ +autofs-5.1.5 - refactor unlink_active_mounts() in direct_c + +From: Ian Kent + +In daemon/direct.c:unlink_active_mounts() the tree_get_mnt_list() call +returns 1 for a non-empty list which amounts to a mounted check and then +handles the case where the map is being read. + +But the check that's carried out is to distinguish between a readmap +and a mount activity which should be handled by the caller instead of +burying the check away in the unlink_active_mounts() function. + +Signed-off-by: Ian Kent +--- + CHANGELOG | 1 + daemon/direct.c | 63 +++++++++++++++++++++++++++----------------------------- + 2 files changed, 32 insertions(+), 32 deletions(-) + +--- autofs-5.0.7.orig/CHANGELOG ++++ autofs-5.0.7/CHANGELOG +@@ -342,6 +342,7 @@ + - always use PROC_MOUNTS to make mount lists. + - add glibc getmntent_r(). + - use local getmntent_r in table_is_mounted(). ++- refactor unlink_active_mounts() in direct.c. + + 25/07/2012 autofs-5.0.7 + ======================= +--- autofs-5.0.7.orig/daemon/direct.c ++++ autofs-5.0.7/daemon/direct.c +@@ -298,37 +298,12 @@ static int unlink_mount_tree(struct auto + + static int unlink_active_mounts(struct autofs_point *ap, struct mnt_list *mnts, struct mapent *me) + { +- struct ioctl_ops *ops = get_ioctl_ops(); + struct list_head list; + + INIT_LIST_HEAD(&list); + +- if (tree_get_mnt_list(mnts, &list, me->key, 1)) { +- if (ap->state == ST_READMAP) { +- time_t tout = get_exp_timeout(ap, me->source); +- int save_ioctlfd, ioctlfd; +- +- save_ioctlfd = ioctlfd = me->ioctlfd; +- +- if (ioctlfd == -1) +- ops->open(ap->logopt, +- &ioctlfd, me->dev, me->key); +- +- if (ioctlfd < 0) { +- error(ap->logopt, +- "failed to create ioctl fd for %s", +- me->key); +- return 0; +- } +- +- ops->timeout(ap->logopt, ioctlfd, tout); +- +- if (save_ioctlfd == -1) +- ops->close(ap->logopt, ioctlfd); +- +- return 0; +- } +- } ++ if (!tree_get_mnt_list(mnts, &list, me->key, 1)) ++ return 1; + + if (!unlink_mount_tree(ap, &list)) { + debug(ap->logopt, +@@ -370,16 +345,40 @@ int do_mount_autofs_direct(struct autofs + if (ret == 0) + return -1; + } else { ++ if (ap->state == ST_READMAP && is_mounted(me->key, MNTS_ALL)) { ++ time_t tout = get_exp_timeout(ap, me->source); ++ int save_ioctlfd, ioctlfd; ++ ++ save_ioctlfd = ioctlfd = me->ioctlfd; ++ ++ if (ioctlfd == -1) ++ ops->open(ap->logopt, ++ &ioctlfd, me->dev, me->key); ++ ++ if (ioctlfd < 0) { ++ error(ap->logopt, ++ "failed to create ioctl fd for %s", ++ me->key); ++ return 0; ++ } ++ ++ ops->timeout(ap->logopt, ioctlfd, tout); ++ ++ if (save_ioctlfd == -1) ++ ops->close(ap->logopt, ioctlfd); ++ ++ return 0; ++ } ++ + /* +- * A return of 0 indicates we're re-reading the map. + * A return of 1 indicates we successfully unlinked +- * the mount tree if there was one. A return of -1 +- * inducates we failed to unlink the mount tree so ++ * the mount tree if there was one. A return of 0 ++ * indicates we failed to unlink the mount tree so + * we have to return a failure. + */ + ret = unlink_active_mounts(ap, mnts, me); +- if (ret == -1 || ret == 0) +- return ret; ++ if (!ret) ++ return -1; + + if (me->ioctlfd != -1) { + error(ap->logopt, "active direct mount %s", me->key); diff --git a/SOURCES/autofs-5.1.5-remove-a-couple-of-old-debug-messages.patch b/SOURCES/autofs-5.1.5-remove-a-couple-of-old-debug-messages.patch new file mode 100644 index 0000000..66fa1a5 --- /dev/null +++ b/SOURCES/autofs-5.1.5-remove-a-couple-of-old-debug-messages.patch @@ -0,0 +1,38 @@ +autofs-5.1.5 - remove a couple of old debug messages + +From: Ian Kent + +Remove a couple of debug log messages from lookup_ghost(). +These messages have not shown a problem here and should be +removed. + +Signed-off-by: Ian Kent +--- + CHANGELOG | 1 + + daemon/lookup.c | 5 ----- + 2 files changed, 1 insertion(+), 5 deletions(-) + +--- autofs-5.0.7.orig/CHANGELOG ++++ autofs-5.0.7/CHANGELOG +@@ -331,6 +331,7 @@ + - fix reset flex scan buffer on init. + - remove unused function has_fstab_option(). + - remove unused function reverse_mnt_list(). ++- remove a couple of old debug messages. + + 25/07/2012 autofs-5.0.7 + ======================= +--- autofs-5.0.7.orig/daemon/lookup.c ++++ autofs-5.0.7/daemon/lookup.c +@@ -791,11 +791,6 @@ int lookup_ghost(struct autofs_point *ap + + /* Directory already exists? */ + if (!ret) { +- /* Shouldn't need this +- me->dev = st.st_dev; +- me->ino = st.st_ino; +- */ +- debug(ap->logopt, "me->dev %d me->ino %d", me->dev, me->ino); + free(fullpath); + goto next; + } diff --git a/SOURCES/autofs-5.1.5-remove-unused-function-has_fstab_option.patch b/SOURCES/autofs-5.1.5-remove-unused-function-has_fstab_option.patch new file mode 100644 index 0000000..e99336a --- /dev/null +++ b/SOURCES/autofs-5.1.5-remove-unused-function-has_fstab_option.patch @@ -0,0 +1,71 @@ +autofs-5.1.5 - remove unused function has_fstab_option() + +From: Ian Kent + +This function is not used, remove it. + +Signed-off-by: Ian Kent +--- + CHANGELOG | 1 + + include/mounts.h | 1 - + lib/mounts.c | 29 ----------------------------- + 3 files changed, 1 insertion(+), 30 deletions(-) + +--- autofs-5.0.7.orig/CHANGELOG ++++ autofs-5.0.7/CHANGELOG +@@ -329,6 +329,7 @@ + - allow period following macro in selector value. + - fix macro expansion in selector values. + - fix reset flex scan buffer on init. ++- remove unused function has_fstab_option(). + + 25/07/2012 autofs-5.0.7 + ======================= +--- autofs-5.0.7.orig/include/mounts.h ++++ autofs-5.0.7/include/mounts.h +@@ -103,7 +103,6 @@ struct mnt_list *get_mnt_list(const char + struct mnt_list *reverse_mnt_list(struct mnt_list *list); + void free_mnt_list(struct mnt_list *list); + int is_mounted(const char *table, const char *path, unsigned int type); +-int has_fstab_option(const char *opt); + void tree_free_mnt_tree(struct mnt_list *tree); + struct mnt_list *tree_make_mnt_tree(const char *table, const char *path); + int tree_get_mnt_list(struct mnt_list *mnts, struct list_head *list, const char *path, int include); +--- autofs-5.0.7.orig/lib/mounts.c ++++ autofs-5.0.7/lib/mounts.c +@@ -1020,35 +1020,6 @@ int is_mounted(const char *table, const + return table_is_mounted(table, path, type); + } + +-int has_fstab_option(const char *opt) +-{ +- struct mntent *mnt; +- struct mntent mnt_wrk; +- char buf[PATH_MAX * 3]; +- FILE *tab; +- int ret = 0; +- +- if (!opt) +- return 0; +- +- tab = open_setmntent_r(_PATH_MNTTAB); +- if (!tab) { +- char *estr = strerror_r(errno, buf, PATH_MAX - 1); +- logerr("setmntent: %s", estr); +- return 0; +- } +- +- while ((mnt = getmntent_r(tab, &mnt_wrk, buf, PATH_MAX * 3))) { +- if (hasmntopt(mnt, opt)) { +- ret = 1; +- break; +- } +- } +- endmntent(tab); +- +- return ret; +-} +- + /* + * Since we have to look at the entire mount tree for direct + * mounts (all mounts under "/") and we may have a large number diff --git a/SOURCES/autofs-5.1.5-remove-unused-function-reverse_mnt_list.patch b/SOURCES/autofs-5.1.5-remove-unused-function-reverse_mnt_list.patch new file mode 100644 index 0000000..58d4ec6 --- /dev/null +++ b/SOURCES/autofs-5.1.5-remove-unused-function-reverse_mnt_list.patch @@ -0,0 +1,63 @@ +autofs-5.1.5 - remove unused function reverse_mnt_list() + +From: Ian Kent + +This function is not used, remove it. + +Signed-off-by: Ian Kent +--- + CHANGELOG | 1 + + include/mounts.h | 1 - + lib/mounts.c | 21 --------------------- + 3 files changed, 1 insertion(+), 22 deletions(-) + +--- autofs-5.0.7.orig/CHANGELOG ++++ autofs-5.0.7/CHANGELOG +@@ -330,6 +330,7 @@ + - fix macro expansion in selector values. + - fix reset flex scan buffer on init. + - remove unused function has_fstab_option(). ++- remove unused function reverse_mnt_list(). + + 25/07/2012 autofs-5.0.7 + ======================= +--- autofs-5.0.7.orig/include/mounts.h ++++ autofs-5.0.7/include/mounts.h +@@ -100,7 +100,6 @@ int ext_mount_add(struct list_head *, co + int ext_mount_remove(struct list_head *, const char *); + int ext_mount_inuse(const char *); + struct mnt_list *get_mnt_list(const char *table, const char *path, int include); +-struct mnt_list *reverse_mnt_list(struct mnt_list *list); + void free_mnt_list(struct mnt_list *list); + int is_mounted(const char *table, const char *path, unsigned int type); + void tree_free_mnt_tree(struct mnt_list *tree); +--- autofs-5.0.7.orig/lib/mounts.c ++++ autofs-5.0.7/lib/mounts.c +@@ -895,27 +895,6 @@ struct mnt_list *get_mnt_list(const char + return list; + } + +-/* +- * Reverse a list of mounts +- */ +-struct mnt_list *reverse_mnt_list(struct mnt_list *list) +-{ +- struct mnt_list *next, *last; +- +- if (!list) +- return NULL; +- +- next = list; +- last = NULL; +- while (next) { +- struct mnt_list *this = next; +- next = this->next; +- this->next = last; +- last = this; +- } +- return last; +-} +- + void free_mnt_list(struct mnt_list *list) + { + struct mnt_list *next; diff --git a/SOURCES/autofs-5.1.5-use-bit-flags-for-autofs-mount-types-in-mnt_list.patch b/SOURCES/autofs-5.1.5-use-bit-flags-for-autofs-mount-types-in-mnt_list.patch new file mode 100644 index 0000000..992495a --- /dev/null +++ b/SOURCES/autofs-5.1.5-use-bit-flags-for-autofs-mount-types-in-mnt_list.patch @@ -0,0 +1,279 @@ +autofs-5.1.5 - use bit flags for autofs mount types in mnt_list + +From: Ian Kent + +Several fields in struct mnt_list don't need to be saved as strings +so change to using bit flags for them instead. + +Signed-off-by: Ian Kent +--- + CHANGELOG | 1 + daemon/direct.c | 10 ++--- + daemon/indirect.c | 16 ++++---- + include/mounts.h | 7 ++- + lib/mounts.c | 97 +++++++++++------------------------------------------- + 5 files changed, 38 insertions(+), 93 deletions(-) + +--- autofs-5.0.7.orig/CHANGELOG ++++ autofs-5.0.7/CHANGELOG +@@ -337,6 +337,7 @@ + - add ignore mount option. + - use ignore option for offset mounts as well. + - add config option for "ignore" mount option ++- use bit flags for autofs mount types in mnt_list. + + 25/07/2012 autofs-5.0.7 + ======================= +--- autofs-5.0.7.orig/daemon/direct.c ++++ autofs-5.0.7/daemon/direct.c +@@ -271,10 +271,10 @@ static int unlink_mount_tree(struct auto + + mnt = list_entry(p, struct mnt_list, list); + +- if (strcmp(mnt->fs_type, "autofs")) +- rv = spawn_umount(ap->logopt, "-l", mnt->path, NULL); +- else ++ if (mnt->flags & MNTS_AUTOFS) + rv = umount2(mnt->path, MNT_DETACH); ++ else ++ rv = spawn_umount(ap->logopt, "-l", mnt->path, NULL); + if (rv == -1) { + debug(ap->logopt, + "can't unlink %s from mount tree", mnt->path); +@@ -911,7 +911,7 @@ void *expire_proc_direct(void *arg) + if (!me) + continue; + +- if (!strcmp(next->fs_type, "autofs")) { ++ if (next->flags & MNTS_AUTOFS) { + struct stat st; + int ioctlfd; + +@@ -922,7 +922,7 @@ void *expire_proc_direct(void *arg) + * one of them and pass on state change. + */ + pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &cur_state); +- if (strstr(next->opts, "indirect")) { ++ if (next->flags & MNTS_INDIRECT) { + master_notify_submount(ap, next->path, ap->state); + pthread_setcancelstate(cur_state, NULL); + continue; +--- autofs-5.0.7.orig/daemon/indirect.c ++++ autofs-5.0.7/daemon/indirect.c +@@ -48,10 +48,10 @@ static int unlink_mount_tree(struct auto + ret = 1; + this = mnts; + while (this) { +- if (strcmp(this->fs_type, "autofs")) +- rv = spawn_umount(ap->logopt, "-l", this->path, NULL); +- else ++ if (this->flags & MNTS_AUTOFS) + rv = umount2(this->path, MNT_DETACH); ++ else ++ rv = spawn_umount(ap->logopt, "-l", this->path, NULL); + if (rv == -1) { + debug(ap->logopt, + "can't unlink %s from mount tree", this->path); +@@ -435,15 +435,15 @@ void *expire_proc_indirect(void *arg) + char *ind_key; + int ret; + +- if (!strcmp(next->fs_type, "autofs")) { ++ if (next->flags & MNTS_AUTOFS) { + /* + * If we have submounts check if this path lives below + * one of them and pass on the state change. + */ + pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &cur_state); +- if (strstr(next->opts, "indirect")) ++ if (next->flags & MNTS_INDIRECT) + master_notify_submount(ap, next->path, ap->state); +- else if (strstr(next->opts, "offset")) { ++ else if (next->flags & MNTS_OFFSET) { + struct map_source *map; + struct mapent_cache *mc = NULL; + struct mapent *me = NULL; +@@ -563,10 +563,10 @@ void *expire_proc_indirect(void *arg) + pthread_cleanup_push(mnts_cleanup, mnts); + /* Are there any real mounts left */ + for (next = mnts; next; next = next->next) { +- if (strcmp(next->fs_type, "autofs")) ++ if (!(next->flags & MNTS_AUTOFS)) + count++; + else { +- if (strstr(next->opts, "indirect")) ++ if (next->flags & MNTS_INDIRECT) + submnts++; + else + offsets++; +--- autofs-5.0.7.orig/include/mounts.h ++++ autofs-5.0.7/include/mounts.h +@@ -35,6 +35,9 @@ + #define MNTS_ALL 0x0001 + #define MNTS_REAL 0x0002 + #define MNTS_AUTOFS 0x0004 ++#define MNTS_INDIRECT 0x0008 ++#define MNTS_DIRECT 0x0010 ++#define MNTS_OFFSET 0x0020 + + #define REMOUNT_SUCCESS 0x0000 + #define REMOUNT_FAIL 0x0001 +@@ -50,9 +53,7 @@ struct mapent; + + struct mnt_list { + char *path; +- char *fs_name; +- char *fs_type; +- char *opts; ++ unsigned int flags; + /* + * List operations ie. get_mnt_list. + */ +--- autofs-5.0.7.orig/lib/mounts.c ++++ autofs-5.0.7/lib/mounts.c +@@ -856,29 +856,17 @@ struct mnt_list *get_mnt_list(const char + } + strcpy(ent->path, mnt->mnt_dir); + +- ent->fs_name = malloc(strlen(mnt->mnt_fsname) + 1); +- if (!ent->fs_name) { +- endmntent(tab); +- free_mnt_list(list); +- return NULL; +- } +- strcpy(ent->fs_name, mnt->mnt_fsname); ++ if (!strcmp(mnt->mnt_type, "autofs")) ++ ent->flags |= MNTS_AUTOFS; + +- ent->fs_type = malloc(strlen(mnt->mnt_type) + 1); +- if (!ent->fs_type) { +- endmntent(tab); +- free_mnt_list(list); +- return NULL; +- } +- strcpy(ent->fs_type, mnt->mnt_type); +- +- ent->opts = malloc(strlen(mnt->mnt_opts) + 1); +- if (!ent->opts) { +- endmntent(tab); +- free_mnt_list(list); +- return NULL; ++ if (ent->flags & MNTS_AUTOFS) { ++ if (strstr(mnt->mnt_opts, "indirect")) ++ ent->flags |= MNTS_INDIRECT; ++ else if (strstr(mnt->mnt_opts, "direct")) ++ ent->flags |= MNTS_DIRECT; ++ else if (strstr(mnt->mnt_opts, "offset")) ++ ent->flags |= MNTS_OFFSET; + } +- strcpy(ent->opts, mnt->mnt_opts); + } + endmntent(tab); + +@@ -901,15 +889,6 @@ void free_mnt_list(struct mnt_list *list + if (this->path) + free(this->path); + +- if (this->fs_name) +- free(this->fs_name); +- +- if (this->fs_type) +- free(this->fs_type); +- +- if (this->opts) +- free(this->opts); +- + free(this); + } + } +@@ -1022,22 +1001,11 @@ void tree_free_mnt_tree(struct mnt_list + list_del(&this->self); + + free(this->path); +- free(this->fs_name); +- free(this->fs_type); +- +- if (this->opts) +- free(this->opts); + + free(this); + } + + free(tree->path); +- free(tree->fs_name); +- free(tree->fs_type); +- +- if (tree->opts) +- free(tree->opts); +- + free(tree); + } + +@@ -1097,38 +1065,17 @@ struct mnt_list *tree_make_mnt_tree(cons + } + strcpy(ent->path, mnt->mnt_dir); + +- ent->fs_name = malloc(strlen(mnt->mnt_fsname) + 1); +- if (!ent->fs_name) { +- free(ent->path); +- free(ent); +- endmntent(tab); +- tree_free_mnt_tree(tree); +- return NULL; +- } +- strcpy(ent->fs_name, mnt->mnt_fsname); +- +- ent->fs_type = malloc(strlen(mnt->mnt_type) + 1); +- if (!ent->fs_type) { +- free(ent->fs_name); +- free(ent->path); +- free(ent); +- endmntent(tab); +- tree_free_mnt_tree(tree); +- return NULL; +- } +- strcpy(ent->fs_type, mnt->mnt_type); ++ if (!strcmp(mnt->mnt_type, "autofs")) ++ ent->flags |= MNTS_AUTOFS; + +- ent->opts = malloc(strlen(mnt->mnt_opts) + 1); +- if (!ent->opts) { +- free(ent->fs_type); +- free(ent->fs_name); +- free(ent->path); +- free(ent); +- endmntent(tab); +- tree_free_mnt_tree(tree); +- return NULL; ++ if (ent->flags & MNTS_AUTOFS) { ++ if (strstr(mnt->mnt_opts, "indirect")) ++ ent->flags |= MNTS_INDIRECT; ++ else if (strstr(mnt->mnt_opts, "direct")) ++ ent->flags |= MNTS_DIRECT; ++ else if (strstr(mnt->mnt_opts, "offset")) ++ ent->flags |= MNTS_OFFSET; + } +- strcpy(ent->opts, mnt->mnt_opts); + + mptr = tree; + while (mptr) { +@@ -1341,17 +1288,13 @@ int tree_is_mounted(struct mnt_list *mnt + mptr = list_entry(p, struct mnt_list, entries); + + if (type) { +- unsigned int autofs_fs; +- +- autofs_fs = !strcmp(mptr->fs_type, "autofs"); +- + if (type & MNTS_REAL) { +- if (!autofs_fs) { ++ if (mptr->flags & MNTS_AUTOFS) { + mounted = 1; + break; + } + } else if (type & MNTS_AUTOFS) { +- if (autofs_fs) { ++ if (mptr->flags & MNTS_AUTOFS) { + mounted = 1; + break; + } diff --git a/SOURCES/autofs-5.1.5-use-ignore-option-for-offset-mounts-as-well.patch b/SOURCES/autofs-5.1.5-use-ignore-option-for-offset-mounts-as-well.patch new file mode 100644 index 0000000..16a3093 --- /dev/null +++ b/SOURCES/autofs-5.1.5-use-ignore-option-for-offset-mounts-as-well.patch @@ -0,0 +1,44 @@ +autofs-5.1.5 - use ignore option for offset mounts as well + +From: Ian Kent + +The pseudo option "ignore" (that's used as a hint that applications +should ignore this mount when reporting a list of mounts) has been +added to direct and indirect mounts but hasn't been added to offset +mounts. + +Signed-off-by: Ian Kent +--- + CHANGELOG | 1 + + daemon/direct.c | 10 ++++++++++ + 2 files changed, 11 insertions(+) + +--- autofs-5.0.7.orig/CHANGELOG ++++ autofs-5.0.7/CHANGELOG +@@ -335,6 +335,7 @@ + - fix amd entry memory leak. + - fix unlink_mount_tree() not umounting mounts. + - add ignore mount option. ++- use ignore option for offset mounts as well. + + 25/07/2012 autofs-5.0.7 + ======================= +--- autofs-5.0.7.orig/daemon/direct.c ++++ autofs-5.0.7/daemon/direct.c +@@ -433,6 +433,16 @@ int do_mount_autofs_direct(struct autofs + mp->options = tmp; + } + } ++ ++ if ((ap->flags & MOUNT_FLAG_IGNORE) && ++ ((get_kver_major() == 5 && get_kver_minor() > 4) || ++ (get_kver_major() > 5))) { ++ char *tmp = realloc(mp->options, strlen(mp->options) + 7); ++ if (tmp) { ++ strcat(tmp, ",ignore"); ++ mp->options = tmp; ++ } ++ } + } + + /* In case the directory doesn't exist, try to mkdir it */ diff --git a/SOURCES/autofs-5.1.5-use-local-getmntent_r-in-get_mnt_list.patch b/SOURCES/autofs-5.1.5-use-local-getmntent_r-in-get_mnt_list.patch new file mode 100644 index 0000000..01fd571 --- /dev/null +++ b/SOURCES/autofs-5.1.5-use-local-getmntent_r-in-get_mnt_list.patch @@ -0,0 +1,53 @@ +autofs-5.1.5 - use local getmntent_r() in get_mnt_list() + +From: Ian Kent + +Change get_mnt_list() to use the local getmntent_r() instead of +the glibc version so that if glibc is changed to support the +autofs "ignore" hint automount(8) won't be affected. + +Signed-off-by: Ian Kent +--- + CHANGELOG | 1 + + lib/mounts.c | 8 ++++---- + 2 files changed, 5 insertions(+), 4 deletions(-) + +--- autofs-5.0.7.orig/CHANGELOG ++++ autofs-5.0.7/CHANGELOG +@@ -347,6 +347,7 @@ + - use single unlink_umount_tree() for both direct and indirect mounts. + - move unlink_mount_tree() to lib/mounts.c. + - use local_getmntent_r() for unlink_mount_tree(). ++- use local getmntent_r() in get_mnt_list(). + + 25/07/2012 autofs-5.0.7 + ======================= +--- autofs-5.0.7.orig/lib/mounts.c ++++ autofs-5.0.7/lib/mounts.c +@@ -957,14 +957,14 @@ struct mnt_list *get_mnt_list(const char + if (!path || !pathlen || pathlen > PATH_MAX) + return NULL; + +- tab = open_setmntent_r(_PROC_MOUNTS); ++ tab = open_fopen_r(_PROC_MOUNTS); + if (!tab) { + char *estr = strerror_r(errno, buf, PATH_MAX - 1); +- logerr("setmntent: %s", estr); ++ logerr("fopen: %s", estr); + return NULL; + } + +- while ((mnt = getmntent_r(tab, &mnt_wrk, buf, PATH_MAX * 3))) { ++ while ((mnt = local_getmntent_r(tab, &mnt_wrk, buf, PATH_MAX * 3))) { + len = strlen(mnt->mnt_dir); + + if ((!include && len <= pathlen) || +@@ -1021,7 +1021,7 @@ struct mnt_list *get_mnt_list(const char + ent->flags |= MNTS_OFFSET; + } + } +- endmntent(tab); ++ fclose(tab); + + return list; + } diff --git a/SOURCES/autofs-5.1.5-use-local-getmntent_r-in-table_is_mounted.patch b/SOURCES/autofs-5.1.5-use-local-getmntent_r-in-table_is_mounted.patch new file mode 100644 index 0000000..1fe100e --- /dev/null +++ b/SOURCES/autofs-5.1.5-use-local-getmntent_r-in-table_is_mounted.patch @@ -0,0 +1,53 @@ +autofs-5.1.5 - use local getmntent_r in table_is_mounted() + +From: Ian Kent + +Use the local_getmntent_r() funtion copied from glibc in the function +table_is_mounted() so that if glibc is changed to support the autofs +"ignore" hint automount(8) won't be affected. + +Signed-off-by: Ian Kent +--- + CHANGELOG | 1 + + lib/mounts.c | 8 ++++---- + 2 files changed, 5 insertions(+), 4 deletions(-) + +--- autofs-5.0.7.orig/CHANGELOG ++++ autofs-5.0.7/CHANGELOG +@@ -341,6 +341,7 @@ + - use mp instead of path in mnt_list entries. + - always use PROC_MOUNTS to make mount lists. + - add glibc getmntent_r(). ++- use local getmntent_r in table_is_mounted(). + + 25/07/2012 autofs-5.0.7 + ======================= +--- autofs-5.0.7.orig/lib/mounts.c ++++ autofs-5.0.7/lib/mounts.c +@@ -1000,14 +1000,14 @@ static int table_is_mounted(const char * + if (!mp || !mp_len || mp_len >= PATH_MAX) + return 0; + +- tab = open_setmntent_r(_PROC_MOUNTS); ++ tab = open_fopen_r(_PROC_MOUNTS); + if (!tab) { + char *estr = strerror_r(errno, buf, PATH_MAX - 1); +- logerr("setmntent: %s", estr); ++ logerr("fopen: %s", estr); + return 0; + } + +- while ((mnt = getmntent_r(tab, &mnt_wrk, buf, PATH_MAX * 3))) { ++ while ((mnt = local_getmntent_r(tab, &mnt_wrk, buf, PATH_MAX * 3))) { + size_t len = strlen(mnt->mnt_dir); + + if (type) { +@@ -1029,7 +1029,7 @@ static int table_is_mounted(const char * + break; + } + } +- endmntent(tab); ++ fclose(tab); + + return ret; + } diff --git a/SOURCES/autofs-5.1.5-use-local-getmntent_r-in-tree_get_mnt_list.patch b/SOURCES/autofs-5.1.5-use-local-getmntent_r-in-tree_get_mnt_list.patch new file mode 100644 index 0000000..4f12982 --- /dev/null +++ b/SOURCES/autofs-5.1.5-use-local-getmntent_r-in-tree_get_mnt_list.patch @@ -0,0 +1,55 @@ +autofs-5.1.5 - use local getmntent_r() in tree_make_mnt_list() + +From: Ian Kent + +Change tree_make_mnt_list() to use the local getmntent_r() instead of +the glibc version so that if glibc is changed to support the autofs +"ignore" hint automount(8) won't be affected. + +Signed-off-by: Ian Kent +--- + CHANGELOG | 1 + + lib/mounts.c | 8 ++++---- + 2 files changed, 5 insertions(+), 4 deletions(-) + +--- autofs-5.0.7.orig/CHANGELOG ++++ autofs-5.0.7/CHANGELOG +@@ -348,6 +348,7 @@ + - move unlink_mount_tree() to lib/mounts.c. + - use local_getmntent_r() for unlink_mount_tree(). + - use local getmntent_r() in get_mnt_list(). ++- use local getmntent_r() in tree_make_mnt_list(). + + 25/07/2012 autofs-5.0.7 + ======================= +--- autofs-5.0.7.orig/lib/mounts.c ++++ autofs-5.0.7/lib/mounts.c +@@ -1176,16 +1176,16 @@ struct mnt_list *tree_make_mnt_tree(cons + size_t plen; + int eq; + +- tab = open_setmntent_r(_PROC_MOUNTS); ++ tab = open_fopen_r(_PROC_MOUNTS); + if (!tab) { + char *estr = strerror_r(errno, buf, PATH_MAX - 1); +- logerr("setmntent: %s", estr); ++ logerr("fopen: %s", estr); + return NULL; + } + + plen = strlen(path); + +- while ((mnt = getmntent_r(tab, &mnt_wrk, buf, PATH_MAX * 3))) { ++ while ((mnt = local_getmntent_r(tab, &mnt_wrk, buf, PATH_MAX * 3))) { + size_t len = strlen(mnt->mnt_dir); + + /* Not matching path */ +@@ -1277,7 +1277,7 @@ struct mnt_list *tree_make_mnt_tree(cons + if (!tree) + tree = ent; + } +- endmntent(tab); ++ fclose(tab); + + return tree; + } diff --git a/SOURCES/autofs-5.1.5-use-local_getmntent_r-for-unlink_mount_tree.patch b/SOURCES/autofs-5.1.5-use-local_getmntent_r-for-unlink_mount_tree.patch new file mode 100644 index 0000000..68e7b4e --- /dev/null +++ b/SOURCES/autofs-5.1.5-use-local_getmntent_r-for-unlink_mount_tree.patch @@ -0,0 +1,179 @@ +autofs-5.1.5 - use local_getmntent_r() for unlink_mount_tree() + +From: Ian Kent + +Now that unlink_mount_tree() is located in a single location and +only one function is used for this, change it to use our local +getmntent_r() function so that if glibc is changed to support the +autofs "ignore" hint automount(8) won't be affected. + +Signed-off-by: Ian Kent +--- + CHANGELOG | 1 + + daemon/direct.c | 24 ++++++------------------ + daemon/indirect.c | 17 ++++++----------- + include/mounts.h | 2 +- + lib/mounts.c | 45 ++++++++++++++++++++++++++++++++++----------- + 5 files changed, 48 insertions(+), 41 deletions(-) + +--- autofs-5.0.7.orig/CHANGELOG ++++ autofs-5.0.7/CHANGELOG +@@ -346,6 +346,7 @@ + - don't use tree_is_mounted() for mounted checks. + - use single unlink_umount_tree() for both direct and indirect mounts. + - move unlink_mount_tree() to lib/mounts.c. ++- use local_getmntent_r() for unlink_mount_tree(). + + 25/07/2012 autofs-5.0.7 + ======================= +--- autofs-5.0.7.orig/daemon/direct.c ++++ autofs-5.0.7/daemon/direct.c +@@ -285,8 +285,6 @@ int do_mount_autofs_direct(struct autofs + if (ret == 0) + return -1; + } else { +- struct mnt_list *mnts; +- + if (ap->state == ST_READMAP && is_mounted(me->key, MNTS_ALL)) { + time_t tout = get_exp_timeout(ap, me->source); + int save_ioctlfd, ioctlfd; +@@ -312,22 +310,12 @@ int do_mount_autofs_direct(struct autofs + return 0; + } + +- mnts = get_mnt_list(me->key, 1); +- if (mnts) { +- /* +- * A return of 1 indicates we successfully unlinked +- * the mount tree if there was one. A return of 0 +- * indicates we failed to unlink the mount tree so +- * we have to return a failure. +- */ +- ret = unlink_mount_tree(ap, mnts); +- free_mnt_list(mnts); +- if (!ret) { +- error(ap->logopt, +- "already mounted as other than autofs " +- "or failed to unlink entry in tree"); +- return -1; +- } ++ ret = unlink_mount_tree(ap, ap->path); ++ if (!ret) { ++ error(ap->logopt, ++ "already mounted as other than autofs " ++ "or failed to unlink entry in tree"); ++ goto out_err; + } + + if (me->ioctlfd != -1) { +--- autofs-5.0.7.orig/daemon/indirect.c ++++ autofs-5.0.7/daemon/indirect.c +@@ -50,7 +50,6 @@ static int do_mount_autofs_indirect(stru + const char *map_name = hosts_map_name; + const char *type; + struct stat st; +- struct mnt_list *mnts; + int ret; + + /* If the map is being shared the exp_timeout can't be inherited +@@ -69,16 +68,12 @@ static int do_mount_autofs_indirect(stru + if (ret == 0) + return -1; + } else { +- mnts = get_mnt_list(ap->path, 1); +- if (mnts) { +- ret = unlink_mount_tree(ap, mnts); +- free_mnt_list(mnts); +- if (!ret) { +- error(ap->logopt, +- "already mounted as other than autofs " +- "or failed to unlink entry in tree"); +- goto out_err; +- } ++ ret = unlink_mount_tree(ap, ap->path); ++ if (!ret) { ++ error(ap->logopt, ++ "already mounted as other than autofs " ++ "or failed to unlink entry in tree"); ++ goto out_err; + } + } + +--- autofs-5.0.7.orig/include/mounts.h ++++ autofs-5.0.7/include/mounts.h +@@ -100,7 +100,7 @@ int ext_mount_add(struct list_head *, co + int ext_mount_remove(struct list_head *, const char *); + int ext_mount_inuse(const char *); + struct mnt_list *get_mnt_list(const char *path, int include); +-int unlink_mount_tree(struct autofs_point *ap, struct mnt_list *mnts); ++int unlink_mount_tree(struct autofs_point *ap, const char *mp); + void free_mnt_list(struct mnt_list *list); + int is_mounted(const char *mp, unsigned int type); + void tree_free_mnt_tree(struct mnt_list *tree); +--- autofs-5.0.7.orig/lib/mounts.c ++++ autofs-5.0.7/lib/mounts.c +@@ -882,21 +882,44 @@ local_getmntent_r(FILE *tab, struct mnte + return mnt; + } + +-int unlink_mount_tree(struct autofs_point *ap, struct mnt_list *mnts) ++int unlink_mount_tree(struct autofs_point *ap, const char *mp) + { +- struct mnt_list *this; +- int rv, ret; ++ FILE *tab; ++ struct mntent *mnt; ++ struct mntent mnt_wrk; ++ char buf[PATH_MAX * 3]; ++ unsigned int mp_len = strlen(mp); ++ int rv, ret = 1; + +- ret = 1; +- this = mnts; +- while (this) { +- if (this->flags & MNTS_AUTOFS) +- rv = umount2(this->mp, MNT_DETACH); ++ tab = open_fopen_r(_PROC_MOUNTS); ++ if (!tab) { ++ char *estr = strerror_r(errno, buf, PATH_MAX - 1); ++ logerr("fopen: %s", estr); ++ return 0; ++ } ++ ++ while ((mnt = local_getmntent_r(tab, &mnt_wrk, buf, PATH_MAX * 3))) { ++ unsigned int mnt_dir_len; ++ int is_autofs; ++ ++ if (strncmp(mnt->mnt_dir, mp, mp_len)) ++ continue; ++ ++ mnt_dir_len = strlen(mnt->mnt_dir); ++ is_autofs = !strcmp(mnt->mnt_type, "autofs"); ++ ++ if (mnt_dir_len == mp_len && !is_autofs) { ++ ret = 0; ++ break; ++ } ++ ++ if (is_autofs) ++ rv = umount2(mnt->mnt_dir, MNT_DETACH); + else +- rv = spawn_umount(ap->logopt, "-l", this->mp, NULL); ++ rv = spawn_umount(ap->logopt, "-l", mnt->mnt_dir, NULL); + if (rv == -1) { + debug(ap->logopt, +- "can't unlink %s from mount tree", this->mp); ++ "can't unlink %s from mount tree", mnt->mnt_dir); + + switch (errno) { + case EINVAL: +@@ -911,8 +934,8 @@ int unlink_mount_tree(struct autofs_poin + break; + } + } +- this = this->next; + } ++ fclose(tab); + + return ret; + } diff --git a/SOURCES/autofs-5.1.5-use-mp-instead-of-path-in-mnt_list-entries.patch b/SOURCES/autofs-5.1.5-use-mp-instead-of-path-in-mnt_list-entries.patch new file mode 100644 index 0000000..22d9389 --- /dev/null +++ b/SOURCES/autofs-5.1.5-use-mp-instead-of-path-in-mnt_list-entries.patch @@ -0,0 +1,430 @@ +autofs-5.1.5 - use mp instead of path in mnt_list entries + +From: Ian Kent + +Use the simpler, more instructive mp instead of path in the +mnt_list structure. + +Signed-off-by: Ian Kent +--- + CHANGELOG | 1 + daemon/direct.c | 18 +++++++------- + daemon/indirect.c | 22 ++++++++--------- + include/mounts.h | 4 +-- + lib/mounts.c | 68 +++++++++++++++++++++++++++--------------------------- + 5 files changed, 57 insertions(+), 56 deletions(-) + +--- autofs-5.0.7.orig/CHANGELOG ++++ autofs-5.0.7/CHANGELOG +@@ -338,6 +338,7 @@ + - use ignore option for offset mounts as well. + - add config option for "ignore" mount option + - use bit flags for autofs mount types in mnt_list. ++- use mp instead of path in mnt_list entries. + + 25/07/2012 autofs-5.0.7 + ======================= +--- autofs-5.0.7.orig/daemon/direct.c ++++ autofs-5.0.7/daemon/direct.c +@@ -272,12 +272,12 @@ static int unlink_mount_tree(struct auto + mnt = list_entry(p, struct mnt_list, list); + + if (mnt->flags & MNTS_AUTOFS) +- rv = umount2(mnt->path, MNT_DETACH); ++ rv = umount2(mnt->mp, MNT_DETACH); + else +- rv = spawn_umount(ap->logopt, "-l", mnt->path, NULL); ++ rv = spawn_umount(ap->logopt, "-l", mnt->mp, NULL); + if (rv == -1) { + debug(ap->logopt, +- "can't unlink %s from mount tree", mnt->path); ++ "can't unlink %s from mount tree", mnt->mp); + + switch (errno) { + case EINVAL: +@@ -906,7 +906,7 @@ void *expire_proc_direct(void *arg) + */ + pthread_cleanup_push(master_source_lock_cleanup, ap->entry); + master_source_readlock(ap->entry); +- me = lookup_source_mapent(ap, next->path, LKP_DISTINCT); ++ me = lookup_source_mapent(ap, next->mp, LKP_DISTINCT); + pthread_cleanup_pop(1); + if (!me) + continue; +@@ -923,7 +923,7 @@ void *expire_proc_direct(void *arg) + */ + pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &cur_state); + if (next->flags & MNTS_INDIRECT) { +- master_notify_submount(ap, next->path, ap->state); ++ master_notify_submount(ap, next->mp, ap->state); + pthread_setcancelstate(cur_state, NULL); + continue; + } +@@ -954,7 +954,7 @@ void *expire_proc_direct(void *arg) + cache_writelock(me->mc); + if (me->ioctlfd != -1 && + fstat(me->ioctlfd, &st) != -1 && +- !count_mounts(ap, next->path, st.st_dev)) { ++ !count_mounts(ap, next->mp, st.st_dev)) { + ops->close(ap->logopt, me->ioctlfd); + me->ioctlfd = -1; + cache_unlock(me->mc); +@@ -965,7 +965,7 @@ void *expire_proc_direct(void *arg) + + ioctlfd = me->ioctlfd; + +- ret = ops->expire(ap->logopt, ioctlfd, next->path, now); ++ ret = ops->expire(ap->logopt, ioctlfd, next->mp, now); + if (ret) { + left++; + pthread_setcancelstate(cur_state, NULL); +@@ -988,10 +988,10 @@ void *expire_proc_direct(void *arg) + if (ap->state == ST_EXPIRE || ap->state == ST_PRUNE) + pthread_testcancel(); + +- debug(ap->logopt, "send expire to trigger %s", next->path); ++ debug(ap->logopt, "send expire to trigger %s", next->mp); + + pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &cur_state); +- ret = ops->expire(ap->logopt, ioctlfd, next->path, now); ++ ret = ops->expire(ap->logopt, ioctlfd, next->mp, now); + if (ret) + left++; + pthread_setcancelstate(cur_state, NULL); +--- autofs-5.0.7.orig/daemon/indirect.c ++++ autofs-5.0.7/daemon/indirect.c +@@ -49,12 +49,12 @@ static int unlink_mount_tree(struct auto + this = mnts; + while (this) { + if (this->flags & MNTS_AUTOFS) +- rv = umount2(this->path, MNT_DETACH); ++ rv = umount2(this->mp, MNT_DETACH); + else +- rv = spawn_umount(ap->logopt, "-l", this->path, NULL); ++ rv = spawn_umount(ap->logopt, "-l", this->mp, NULL); + if (rv == -1) { + debug(ap->logopt, +- "can't unlink %s from mount tree", this->path); ++ "can't unlink %s from mount tree", this->mp); + + switch (errno) { + case EINVAL: +@@ -442,7 +442,7 @@ void *expire_proc_indirect(void *arg) + */ + pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &cur_state); + if (next->flags & MNTS_INDIRECT) +- master_notify_submount(ap, next->path, ap->state); ++ master_notify_submount(ap, next->mp, ap->state); + else if (next->flags & MNTS_OFFSET) { + struct map_source *map; + struct mapent_cache *mc = NULL; +@@ -450,13 +450,13 @@ void *expire_proc_indirect(void *arg) + struct stat st; + + /* It's got a mount, deal with in the outer loop */ +- if (is_mounted(_PATH_MOUNTED, next->path, MNTS_REAL)) { ++ if (is_mounted(_PATH_MOUNTED, next->mp, MNTS_REAL)) { + pthread_setcancelstate(cur_state, NULL); + continue; + } + + /* Don't touch submounts */ +- if (master_find_submount(ap, next->path)) { ++ if (master_find_submount(ap, next->mp)) { + pthread_setcancelstate(cur_state, NULL); + continue; + } +@@ -467,7 +467,7 @@ void *expire_proc_indirect(void *arg) + while (map) { + mc = map->mc; + cache_writelock(mc); +- me = cache_lookup_distinct(mc, next->path); ++ me = cache_lookup_distinct(mc, next->mp); + if (me) + break; + cache_unlock(mc); +@@ -509,7 +509,7 @@ void *expire_proc_indirect(void *arg) + * If the mount corresponds to an offset trigger then + * the key is the path, otherwise it's the last component. + */ +- ind_key = strrchr(next->path, '/'); ++ ind_key = strrchr(next->mp, '/'); + if (ind_key) + ind_key++; + +@@ -522,7 +522,7 @@ void *expire_proc_indirect(void *arg) + */ + pthread_cleanup_push(master_source_lock_cleanup, ap->entry); + master_source_readlock(ap->entry); +- me = lookup_source_mapent(ap, next->path, LKP_DISTINCT); ++ me = lookup_source_mapent(ap, next->mp, LKP_DISTINCT); + if (!me && ind_key) + me = lookup_source_mapent(ap, ind_key, LKP_NORMAL); + pthread_cleanup_pop(1); +@@ -534,10 +534,10 @@ void *expire_proc_indirect(void *arg) + cache_unlock(me->mc); + } + +- debug(ap->logopt, "expire %s", next->path); ++ debug(ap->logopt, "expire %s", next->mp); + + pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &cur_state); +- ret = ops->expire(ap->logopt, ioctlfd, next->path, now); ++ ret = ops->expire(ap->logopt, ioctlfd, next->mp, now); + if (ret) + left++; + pthread_setcancelstate(cur_state, NULL); +--- autofs-5.0.7.orig/include/mounts.h ++++ autofs-5.0.7/include/mounts.h +@@ -52,7 +52,7 @@ extern const unsigned int t_offset; + struct mapent; + + struct mnt_list { +- char *path; ++ char *mp; + unsigned int flags; + /* + * List operations ie. get_mnt_list. +@@ -101,7 +101,7 @@ int ext_mount_remove(struct list_head *, + int ext_mount_inuse(const char *); + struct mnt_list *get_mnt_list(const char *table, const char *path, int include); + void free_mnt_list(struct mnt_list *list); +-int is_mounted(const char *table, const char *path, unsigned int type); ++int is_mounted(const char *table, const char *mp, unsigned int type); + void tree_free_mnt_tree(struct mnt_list *tree); + struct mnt_list *tree_make_mnt_tree(const char *table, const char *path); + int tree_get_mnt_list(struct mnt_list *mnts, struct list_head *list, const char *path, int include); +--- autofs-5.0.7.orig/lib/mounts.c ++++ autofs-5.0.7/lib/mounts.c +@@ -818,8 +818,8 @@ struct mnt_list *get_mnt_list(const char + strncmp(mnt->mnt_dir, path, pathlen) != 0) + continue; + +- /* Not a subdirectory of requested path ? */ +- /* pathlen == 1 => everything is subdir */ ++ /* Not a subdirectory of requested mp? */ ++ /* mp_len == 1 => everything is subdir */ + if (pathlen > 1 && len > pathlen && + mnt->mnt_dir[pathlen] != '/') + continue; +@@ -835,7 +835,7 @@ struct mnt_list *get_mnt_list(const char + mptr = list; + last = NULL; + while (mptr) { +- if (len >= strlen(mptr->path)) ++ if (len >= strlen(mptr->mp)) + break; + last = mptr; + mptr = mptr->next; +@@ -848,13 +848,13 @@ struct mnt_list *get_mnt_list(const char + + ent->next = mptr; + +- ent->path = malloc(len + 1); +- if (!ent->path) { ++ ent->mp = malloc(len + 1); ++ if (!ent->mp) { + endmntent(tab); + free_mnt_list(list); + return NULL; + } +- strcpy(ent->path, mnt->mnt_dir); ++ strcpy(ent->mp, mnt->mnt_dir); + + if (!strcmp(mnt->mnt_type, "autofs")) + ent->flags |= MNTS_AUTOFS; +@@ -886,23 +886,23 @@ void free_mnt_list(struct mnt_list *list + + next = this->next; + +- if (this->path) +- free(this->path); ++ if (this->mp) ++ free(this->mp); + + free(this); + } + } + +-static int table_is_mounted(const char *table, const char *path, unsigned int type) ++static int table_is_mounted(const char *table, const char *mp, unsigned int type) + { + struct mntent *mnt; + struct mntent mnt_wrk; + char buf[PATH_MAX * 3]; +- size_t pathlen = strlen(path); ++ size_t mp_len = strlen(mp); + FILE *tab; + int ret = 0; + +- if (!path || !pathlen || pathlen >= PATH_MAX) ++ if (!mp || !mp_len || mp_len >= PATH_MAX) + return 0; + + tab = open_setmntent_r(table); +@@ -929,7 +929,7 @@ static int table_is_mounted(const char * + continue; + } + +- if (pathlen == len && !strncmp(path, mnt->mnt_dir, pathlen)) { ++ if (mp_len == len && !strncmp(mp, mnt->mnt_dir, mp_len)) { + ret = 1; + break; + } +@@ -939,12 +939,12 @@ static int table_is_mounted(const char * + return ret; + } + +-static int ioctl_is_mounted(const char *path, unsigned int type) ++static int ioctl_is_mounted(const char *mp, unsigned int type) + { + struct ioctl_ops *ops = get_ioctl_ops(); + unsigned int mounted; + +- ops->ismountpoint(LOGOPT_NONE, -1, path, &mounted); ++ ops->ismountpoint(LOGOPT_NONE, -1, mp, &mounted); + if (mounted) { + switch (type) { + case MNTS_ALL: +@@ -958,14 +958,14 @@ static int ioctl_is_mounted(const char * + return 0; + } + +-int is_mounted(const char *table, const char *path, unsigned int type) ++int is_mounted(const char *table, const char *mp, unsigned int type) + { + struct ioctl_ops *ops = get_ioctl_ops(); + + if (ops->ismountpoint) +- return ioctl_is_mounted(path, type); ++ return ioctl_is_mounted(mp, type); + else +- return table_is_mounted(table, path, type); ++ return table_is_mounted(table, mp, type); + } + + /* +@@ -1000,12 +1000,12 @@ void tree_free_mnt_tree(struct mnt_list + + list_del(&this->self); + +- free(this->path); ++ free(this->mp); + + free(this); + } + +- free(tree->path); ++ free(tree->mp); + free(tree); + } + +@@ -1056,14 +1056,14 @@ struct mnt_list *tree_make_mnt_tree(cons + INIT_LIST_HEAD(&ent->entries); + INIT_LIST_HEAD(&ent->sublist); + +- ent->path = malloc(len + 1); +- if (!ent->path) { ++ ent->mp = malloc(len + 1); ++ if (!ent->mp) { + endmntent(tab); + free(ent); + tree_free_mnt_tree(tree); + return NULL; + } +- strcpy(ent->path, mnt->mnt_dir); ++ strcpy(ent->mp, mnt->mnt_dir); + + if (!strcmp(mnt->mnt_type, "autofs")) + ent->flags |= MNTS_AUTOFS; +@@ -1079,8 +1079,8 @@ struct mnt_list *tree_make_mnt_tree(cons + + mptr = tree; + while (mptr) { +- int elen = strlen(ent->path); +- int mlen = strlen(mptr->path); ++ int elen = strlen(ent->mp); ++ int mlen = strlen(mptr->mp); + + if (elen < mlen) { + if (mptr->left) { +@@ -1100,7 +1100,7 @@ struct mnt_list *tree_make_mnt_tree(cons + } + } + +- eq = strcmp(ent->path, mptr->path); ++ eq = strcmp(ent->mp, mptr->mp); + if (eq < 0) { + if (mptr->left) + mptr = mptr->left; +@@ -1140,7 +1140,7 @@ int tree_get_mnt_list(struct mnt_list *m + return 0; + + plen = strlen(path); +- mlen = strlen(mnts->path); ++ mlen = strlen(mnts->mp); + if (mlen < plen) + return tree_get_mnt_list(mnts->right, list, path, include); + else { +@@ -1149,10 +1149,10 @@ int tree_get_mnt_list(struct mnt_list *m + tree_get_mnt_list(mnts->left, list, path, include); + + if ((!include && mlen <= plen) || +- strncmp(mnts->path, path, plen)) ++ strncmp(mnts->mp, path, plen)) + goto skip; + +- if (plen > 1 && mlen > plen && mnts->path[plen] != '/') ++ if (plen > 1 && mlen > plen && mnts->mp[plen] != '/') + goto skip; + + INIT_LIST_HEAD(&mnts->list); +@@ -1187,7 +1187,7 @@ int tree_get_mnt_sublist(struct mnt_list + return 0; + + plen = strlen(path); +- mlen = strlen(mnts->path); ++ mlen = strlen(mnts->mp); + if (mlen < plen) + return tree_get_mnt_sublist(mnts->right, list, path, include); + else { +@@ -1196,10 +1196,10 @@ int tree_get_mnt_sublist(struct mnt_list + tree_get_mnt_sublist(mnts->left, list, path, include); + + if ((!include && mlen <= plen) || +- strncmp(mnts->path, path, plen)) ++ strncmp(mnts->mp, path, plen)) + goto skip; + +- if (plen > 1 && mlen > plen && mnts->path[plen] != '/') ++ if (plen > 1 && mlen > plen && mnts->mp[plen] != '/') + goto skip; + + INIT_LIST_HEAD(&mnts->sublist); +@@ -1231,7 +1231,7 @@ int tree_find_mnt_ents(struct mnt_list * + return 0; + + plen = strlen(path); +- mlen = strlen(mnts->path); ++ mlen = strlen(mnts->mp); + if (mlen < plen) + return tree_find_mnt_ents(mnts->right, list, path); + else if (mlen > plen) +@@ -1241,7 +1241,7 @@ int tree_find_mnt_ents(struct mnt_list * + + tree_find_mnt_ents(mnts->left, list, path); + +- if (!strcmp(mnts->path, path)) { ++ if (!strcmp(mnts->mp, path)) { + INIT_LIST_HEAD(&mnts->entries); + list_add(&mnts->entries, list); + } +@@ -1252,7 +1252,7 @@ int tree_find_mnt_ents(struct mnt_list * + + this = list_entry(p, struct mnt_list, self); + +- if (!strcmp(this->path, path)) { ++ if (!strcmp(this->mp, path)) { + INIT_LIST_HEAD(&this->entries); + list_add(&this->entries, list); + } diff --git a/SOURCES/autofs-5.1.5-use-single-unlink_umount_tree-for-both-direct-and-indirect-mounts.patch b/SOURCES/autofs-5.1.5-use-single-unlink_umount_tree-for-both-direct-and-indirect-mounts.patch new file mode 100644 index 0000000..e11cf39 --- /dev/null +++ b/SOURCES/autofs-5.1.5-use-single-unlink_umount_tree-for-both-direct-and-indirect-mounts.patch @@ -0,0 +1,271 @@ +autofs-5.1.5 - use single unlink_umount_tree() for both direct and indirect mounts + +From: Ian Kent + +Use the same function, unlink_umount_tree(), for forced unlink of mounts +for both indirect and direct mounts. + +Signed-off-by: Ian Kent +--- + CHANGELOG | 1 + daemon/direct.c | 96 +++++++++++++--------------------------------------- + daemon/indirect.c | 2 - + daemon/state.c | 17 +-------- + include/automount.h | 2 - + 5 files changed, 30 insertions(+), 88 deletions(-) + +--- autofs-5.0.7.orig/CHANGELOG ++++ autofs-5.0.7/CHANGELOG +@@ -344,6 +344,7 @@ + - use local getmntent_r in table_is_mounted(). + - refactor unlink_active_mounts() in direct.c. + - don't use tree_is_mounted() for mounted checks. ++- use single unlink_umount_tree() for both direct and indirect mounts. + + 25/07/2012 autofs-5.0.7 + ======================= +--- autofs-5.0.7.orig/daemon/direct.c ++++ autofs-5.0.7/daemon/direct.c +@@ -49,6 +49,8 @@ pthread_key_t key_mnt_direct_params; + pthread_key_t key_mnt_offset_params; + pthread_once_t key_mnt_params_once = PTHREAD_ONCE_INIT; + ++int unlink_mount_tree(struct autofs_point *ap, struct mnt_list *mnts); ++ + static void key_mnt_params_destroy(void *arg) + { + struct mnt_params *mp; +@@ -256,64 +258,8 @@ done: + return 0; + } + +-static int unlink_mount_tree(struct autofs_point *ap, struct list_head *list) +-{ +- struct list_head *p; +- int rv, ret; +- +- ret = 1; +- list_for_each(p, list) { +- struct mnt_list *mnt; +- +- mnt = list_entry(p, struct mnt_list, list); +- +- if (mnt->flags & MNTS_AUTOFS) +- rv = umount2(mnt->mp, MNT_DETACH); +- else +- rv = spawn_umount(ap->logopt, "-l", mnt->mp, NULL); +- if (rv == -1) { +- debug(ap->logopt, +- "can't unlink %s from mount tree", mnt->mp); +- +- switch (errno) { +- case EINVAL: +- warn(ap->logopt, +- "bad superblock or not mounted"); +- break; +- +- case ENOENT: +- case EFAULT: +- ret = 0; +- warn(ap->logopt, "bad path for mount"); +- break; +- } +- } +- } +- return ret; +-} +- +-static int unlink_active_mounts(struct autofs_point *ap, struct mnt_list *mnts, struct mapent *me) +-{ +- struct list_head list; +- +- INIT_LIST_HEAD(&list); +- +- if (!tree_get_mnt_list(mnts, &list, me->key, 1)) +- return 1; +- +- if (!unlink_mount_tree(ap, &list)) { +- debug(ap->logopt, +- "already mounted as other than autofs " +- "or failed to unlink entry in tree"); +- return 0; +- } +- +- return 1; +-} +- + int do_mount_autofs_direct(struct autofs_point *ap, +- struct mnt_list *mnts, struct mapent *me, +- time_t timeout) ++ struct mapent *me, time_t timeout) + { + const char *str_direct = mount_type_str(t_direct); + struct ioctl_ops *ops = get_ioctl_ops(); +@@ -341,6 +287,8 @@ int do_mount_autofs_direct(struct autofs + if (ret == 0) + return -1; + } else { ++ struct mnt_list *mnts; ++ + if (ap->state == ST_READMAP && is_mounted(me->key, MNTS_ALL)) { + time_t tout = get_exp_timeout(ap, me->source); + int save_ioctlfd, ioctlfd; +@@ -366,15 +314,23 @@ int do_mount_autofs_direct(struct autofs + return 0; + } + +- /* +- * A return of 1 indicates we successfully unlinked +- * the mount tree if there was one. A return of 0 +- * indicates we failed to unlink the mount tree so +- * we have to return a failure. +- */ +- ret = unlink_active_mounts(ap, mnts, me); +- if (!ret) +- return -1; ++ mnts = get_mnt_list(me->key, 1); ++ if (mnts) { ++ /* ++ * A return of 1 indicates we successfully unlinked ++ * the mount tree if there was one. A return of 0 ++ * indicates we failed to unlink the mount tree so ++ * we have to return a failure. ++ */ ++ ret = unlink_mount_tree(ap, mnts); ++ free_mnt_list(mnts); ++ if (!ret) { ++ error(ap->logopt, ++ "already mounted as other than autofs " ++ "or failed to unlink entry in tree"); ++ return -1; ++ } ++ } + + if (me->ioctlfd != -1) { + error(ap->logopt, "active direct mount %s", me->key); +@@ -500,7 +456,6 @@ int mount_autofs_direct(struct autofs_po + struct map_source *map; + struct mapent_cache *nc, *mc; + struct mapent *me, *ne, *nested; +- struct mnt_list *mnts; + time_t now = time(NULL); + + if (strcmp(ap->path, "/-")) { +@@ -516,8 +471,6 @@ int mount_autofs_direct(struct autofs_po + return -1; + } + +- mnts = tree_make_mnt_tree("/"); +- pthread_cleanup_push(mnts_cleanup, mnts); + pthread_cleanup_push(master_source_lock_cleanup, ap->entry); + master_source_readlock(ap->entry); + nc = ap->entry->master->nc; +@@ -545,7 +498,7 @@ int mount_autofs_direct(struct autofs_po + if (ne) { + if (map->master_line < ne->age) { + /* TODO: check return, locking me */ +- do_mount_autofs_direct(ap, mnts, me, timeout); ++ do_mount_autofs_direct(ap, me, timeout); + } + me = cache_enumerate(mc, me); + continue; +@@ -562,7 +515,7 @@ int mount_autofs_direct(struct autofs_po + } + + /* TODO: check return, locking me */ +- do_mount_autofs_direct(ap, mnts, me, timeout); ++ do_mount_autofs_direct(ap, me, timeout); + + me = cache_enumerate(mc, me); + } +@@ -571,7 +524,6 @@ int mount_autofs_direct(struct autofs_po + } + pthread_cleanup_pop(1); + pthread_cleanup_pop(1); +- pthread_cleanup_pop(1); + + return 0; + } +--- autofs-5.0.7.orig/daemon/indirect.c ++++ autofs-5.0.7/daemon/indirect.c +@@ -40,7 +40,7 @@ + /* Attribute to create detached thread */ + extern pthread_attr_t th_attr_detached; + +-static int unlink_mount_tree(struct autofs_point *ap, struct mnt_list *mnts) ++int unlink_mount_tree(struct autofs_point *ap, struct mnt_list *mnts) + { + struct mnt_list *this; + int rv, ret; +--- autofs-5.0.7.orig/daemon/state.c ++++ autofs-5.0.7/daemon/state.c +@@ -350,14 +350,7 @@ static void do_readmap_cleanup(void *arg + return; + } + +-static void tree_mnts_cleanup(void *arg) +-{ +- struct mnt_list *mnts = (struct mnt_list *) arg; +- tree_free_mnt_tree(mnts); +- return; +-} +- +-static void do_readmap_mount(struct autofs_point *ap, struct mnt_list *mnts, ++static void do_readmap_mount(struct autofs_point *ap, + struct map_source *map, struct mapent *me, time_t now) + { + struct mapent_cache *nc; +@@ -444,7 +437,7 @@ static void do_readmap_mount(struct auto + debug(ap->logopt, + "%s is mounted", me->key); + } else +- do_mount_autofs_direct(ap, mnts, me, get_exp_timeout(ap, map)); ++ do_mount_autofs_direct(ap, me, get_exp_timeout(ap, map)); + + return; + } +@@ -455,7 +448,6 @@ static void *do_readmap(void *arg) + struct map_source *map; + struct mapent_cache *nc, *mc; + struct readmap_args *ra; +- struct mnt_list *mnts; + int status; + time_t now; + +@@ -499,8 +491,6 @@ static void *do_readmap(void *arg) + struct mapent *me; + unsigned int append_alarm = !ap->exp_runfreq; + +- mnts = tree_make_mnt_tree("/"); +- pthread_cleanup_push(tree_mnts_cleanup, mnts); + nc = ap->entry->master->nc; + cache_readlock(nc); + pthread_cleanup_push(cache_lock_cleanup, nc); +@@ -518,7 +508,7 @@ static void *do_readmap(void *arg) + cache_readlock(mc); + me = cache_enumerate(mc, NULL); + while (me) { +- do_readmap_mount(ap, mnts, map, me, now); ++ do_readmap_mount(ap, map, me, now); + me = cache_enumerate(mc, me); + } + lookup_prune_one_cache(ap, map->mc, now); +@@ -538,7 +528,6 @@ static void *do_readmap(void *arg) + + pthread_cleanup_pop(1); + pthread_cleanup_pop(1); +- pthread_cleanup_pop(1); + } + + pthread_cleanup_pop(1); +--- autofs-5.0.7.orig/include/automount.h ++++ autofs-5.0.7/include/automount.h +@@ -590,7 +590,7 @@ void *expire_proc_indirect(void *); + 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, const char *root); +-int do_mount_autofs_direct(struct autofs_point *ap, struct mnt_list *mnts, struct mapent *me, time_t timeout); ++int do_mount_autofs_direct(struct autofs_point *ap, struct mapent *me, time_t timeout); + int mount_autofs_direct(struct autofs_point *ap); + int mount_autofs_offset(struct autofs_point *ap, struct mapent *me, const char *root, const char *offset); + void submount_signal_parent(struct autofs_point *ap, unsigned int success); diff --git a/SPECS/autofs.spec b/SPECS/autofs.spec index 0dd1dc8..97c14de 100644 --- a/SPECS/autofs.spec +++ b/SPECS/autofs.spec @@ -8,7 +8,7 @@ Summary: A tool for automatically mounting and unmounting filesystems Name: autofs Version: 5.0.7 -Release: 106%{?dist} +Release: 109%{?dist} Epoch: 1 License: GPLv2+ Group: System Environment/Daemons @@ -494,6 +494,31 @@ Patch870: autofs-5.1.4-improve-hostname-lookup-error-logging.patch Patch871: autofs-5.1.5-allow-period-following-macro-in-selector-value.patch Patch872: autofs-5.1.5-fix-macro-expansion-in-selector-values.patch +Patch880: autofs-5.0.9-fix-reset-flex-scan-buffer-on-init.patch + +# Bug 1728914 +Patch900: autofs-5.1.5-remove-unused-function-has_fstab_option.patch +Patch901: autofs-5.1.5-remove-unused-function-reverse_mnt_list.patch +Patch902: autofs-5.1.5-remove-a-couple-of-old-debug-messages.patch +Patch903: autofs-5.1.5-fix-amd-entry-memory-leak.patch +Patch904: autofs-5.1.5-fix-unlink_mount_tree-not-umounting-mounts.patch +Patch905: autofs-5.1.5-add-ignore-mount-option.patch +Patch906: autofs-5.1.5-use-ignore-option-for-offset-mounts-as-well.patch +Patch907: autofs-5.1.5-add-config-option-for-ignore-mount-option.patch +Patch908: autofs-5.1.5-use-bit-flags-for-autofs-mount-types-in-mnt_list.patch +Patch909: autofs-5.1.5-use-mp-instead-of-path-in-mnt_list-entries.patch +Patch910: autofs-5.1.5-always-use-PROC_MOUNTS-to-make-mount-lists.patch +Patch911: autofs-5.1.5-add-glibc-getmntent.patch +Patch912: autofs-5.1.5-use-local-getmntent_r-in-table_is_mounted.patch +Patch913: autofs-5.1.5-refactor-unlink_active_mounts-in-direct_c.patch +Patch914: autofs-5.1.5-dont-use-tree_is_mounted-for-mounted-checks.patch +Patch915: autofs-5.1.5-use-single-unlink_umount_tree-for-both-direct-and-indirect-mounts.patch +Patch916: autofs-5.1.5-move-unlink_mount_tree-to-lib_mounts_c.patch +Patch917: autofs-5.1.5-use-local_getmntent_r-for-unlink_mount_tree.patch +Patch918: autofs-5.1.5-use-local-getmntent_r-in-get_mnt_list.patch +Patch919: autofs-5.1.5-use-local-getmntent_r-in-tree_get_mnt_list.patch +Patch920: autofs-5.1.5-fix-missing-initialization-of-autofs_point-flags.patch + Buildroot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) %if %{with_systemd} BuildRequires: systemd-units @@ -1026,6 +1051,31 @@ echo %{version}-%{release} > .version %patch871 -p1 %patch872 -p1 +%patch880 -p1 + +# Bug 1728914 +%patch900 -p1 +%patch901 -p1 +%patch902 -p1 +%patch903 -p1 +%patch904 -p1 +%patch905 -p1 +%patch906 -p1 +%patch907 -p1 +%patch908 -p1 +%patch909 -p1 +%patch910 -p1 +%patch911 -p1 +%patch912 -p1 +%patch913 -p1 +%patch914 -p1 +%patch915 -p1 +%patch916 -p1 +%patch917 -p1 +%patch918 -p1 +%patch919 -p1 +%patch920 -p1 + %build LDFLAGS=-Wl,-z,now %configure --disable-mount-locking \ @@ -1122,6 +1172,43 @@ fi %dir /etc/auto.master.d %changelog +* Tue Aug 20 2019 Ian Kent - 5.0.7-109 +- bz1728914 - getmntent returns additional "-hosts" entries when + automounter is used with "hosts" map + - fix missing initialization of autofs_point flags. +- Related: rhbz#1728914 + +* Fri Aug 09 2019 Ian Kent - 5.0.7-108 +- bz1728914 - getmntent returns additional "-hosts" entries when + automounter is used with "hosts" map + - remove unused function has_fstab_option(). + - remove unused function reverse_mnt_list(). + - remove a couple of old debug messages. + - fix amd entry memory leak. + - fix unlink_mount_tree() not umounting mounts. + - add ignore mount option. + - use ignore option for offset mounts as well. + - add config option for "ignore" mount option + - use bit flags for autofs mount types in mnt_list. + - use mp instead of path in mnt_list entries. + - always use PROC_MOUNTS to make mount lists. + - add glibc getmntent_r(). + - use local getmntent_r in table_is_mounted(). + - refactor unlink_active_mounts() in direct.c. + - don't use tree_is_mounted() for mounted checks. + - use single unlink_umount_tree() for both direct and indirect mounts. + - move unlink_mount_tree() to lib/mounts.c. + - use local_getmntent_r() for unlink_mount_tree(). + - use local getmntent_r() in get_mnt_list(). + - use local getmntent_r() in tree_make_mnt_list(). +- Resolves: rhbz#1728914 + +* Tue Jul 30 2019 Ian Kent - 5.0.7-107 +- bz1734057 - automount segfaults if a bad hosts entry is added + in /etc/auto.master + - fix reset flex scan buffer on init. +- Resolves: rhbz#1734057 + * Thu Mar 07 2019 Ian Kent - 5.0.7-106 - bz1685804 - autofs doesn't expand macros in amd map selectors - workaround getaddrinfo(3) ai_canonname bug.