From c3f1f8f4c59025f3a1a4dc91fde36dee1d291a9d Mon Sep 17 00:00:00 2001 From: CentOS Sources Date: Nov 05 2019 21:29:08 +0000 Subject: import autofs-5.1.4-35.el8 --- diff --git a/SOURCES/autofs-5.1.4-add-NULL-check-in-prepare_attempt_prefix.patch b/SOURCES/autofs-5.1.4-add-NULL-check-in-prepare_attempt_prefix.patch new file mode 100644 index 0000000..cd730cf --- /dev/null +++ b/SOURCES/autofs-5.1.4-add-NULL-check-in-prepare_attempt_prefix.patch @@ -0,0 +1,34 @@ +autofs-5.1.4 - add NULL check in prepare_attempt_prefix() + +From: Ian Kent + +prepare_attempt_prefix() calls calloc(3) and continues without +checking if the allocation succeeded. + +Signed-off-by: Ian Kent +--- + CHANGELOG | 1 + + lib/log.c | 2 ++ + 2 files changed, 3 insertions(+) + +--- autofs-5.1.4.orig/CHANGELOG ++++ autofs-5.1.4/CHANGELOG +@@ -39,6 +39,7 @@ xx/xx/2018 autofs-5.1.5 + - better handle hesiod support not built in. + - fix hesiod string check in master_parse(). + - remove autofs4 module load code. ++- add NULL check in prepare_attempt_prefix(). + + 19/12/2017 autofs-5.1.4 + - fix spec file url. +--- autofs-5.1.4.orig/lib/log.c ++++ autofs-5.1.4/lib/log.c +@@ -44,6 +44,8 @@ static char *prepare_attempt_prefix(cons + + snprintf(buffer, ATTEMPT_ID_SIZE, "%02lx", *attempt_id); + prefixed_msg = (char *) calloc(len, sizeof(char)); ++ if (!prefixed_msg) ++ return NULL; + strcpy(prefixed_msg, buffer); + strcat(prefixed_msg, "|"); + strcat(prefixed_msg, msg); diff --git a/SOURCES/autofs-5.1.4-add-systemd-service-command-line-option.patch b/SOURCES/autofs-5.1.4-add-systemd-service-command-line-option.patch new file mode 100644 index 0000000..ba8838d --- /dev/null +++ b/SOURCES/autofs-5.1.4-add-systemd-service-command-line-option.patch @@ -0,0 +1,137 @@ +autofs-5.1.4 - add systemd service command line option + +From: Ian Kent + +When run as a systemd service using the systemd notification method to +synchronise startup, logging should be done to syslog so the log entry +format is consistent between daemon and systemd usage. + +So, rather than run use the forground option, add an option to tell +the automounter it's being run as a systemd service and use syslog +for logging when its present on the command line. + +Signed-off-by: Ian Kent +--- + CHANGELOG | 1 + + daemon/automount.c | 22 +++++++++++++++++++--- + include/automount.h | 1 + + man/automount.8 | 4 ++++ + samples/autofs.service.in | 2 +- + 5 files changed, 26 insertions(+), 4 deletions(-) + +--- autofs-5.1.4.orig/CHANGELOG ++++ autofs-5.1.4/CHANGELOG +@@ -43,6 +43,7 @@ xx/xx/2018 autofs-5.1.5 + - update build info with systemd. + - use flags for startup boolean options. + - move close stdio descriptors to become_daemon(). ++- add systemd service command line option. + + 19/12/2017 autofs-5.1.4 + - fix spec file url. +--- autofs-5.1.4.orig/daemon/automount.c ++++ autofs-5.1.4/daemon/automount.c +@@ -1210,13 +1210,21 @@ static void become_daemon(unsigned int f + } + + /* Detach from foreground process */ +- if (flags & DAEMON_FLAGS_FOREGROUND) { ++ if (flags & DAEMON_FLAGS_FOREGROUND && ++ !(flags & DAEMON_FLAGS_SYSTEMD_SERVICE)) { + if ((flags & DAEMON_FLAGS_CHECK_DAEMON) && !aquire_flag_file()) { + fprintf(stderr, "%s: program is already running.\n", + program); + exit(1); + } + log_to_stderr(); ++ } else if (flags & DAEMON_FLAGS_SYSTEMD_SERVICE) { ++ if ((flags & DAEMON_FLAGS_CHECK_DAEMON) && !aquire_flag_file()) { ++ fprintf(stderr, "%s: program is already running.\n", ++ program); ++ exit(1); ++ } ++ open_log(); + } else { + int nullfd; + +@@ -1925,6 +1933,8 @@ static void usage(void) + " -d --debug log debuging info\n" + " -Dvariable=value, --define variable=value\n" + " define global macro variable\n" ++ " -S --systemd-service\n" ++ " run automounter as a systemd service\n" + " -f --foreground do not fork into background\n" + " -r --random-multimount-selection\n" + " use ramdom replicated server selection\n" +@@ -2190,7 +2200,7 @@ int main(int argc, char *argv[]) + time_t timeout; + time_t age = monotonic_time(NULL); + struct rlimit rlim; +- const char *options = "+hp:t:vmdD:fVrO:l:n:CFM"; ++ const char *options = "+hp:t:vmdD:SfVrO:l:n:CFM"; + static const struct option long_options[] = { + {"help", 0, 0, 'h'}, + {"pid-file", 1, 0, 'p'}, +@@ -2198,6 +2208,7 @@ int main(int argc, char *argv[]) + {"verbose", 0, 0, 'v'}, + {"debug", 0, 0, 'd'}, + {"define", 1, 0, 'D'}, ++ {"systemd-service", 0, 0, 'S'}, + {"foreground", 0, 0, 'f'}, + {"random-multimount-selection", 0, 0, 'r'}, + {"negative-timeout", 1, 0, 'n'}, +@@ -2266,6 +2277,10 @@ int main(int argc, char *argv[]) + macro_parse_globalvar(optarg); + break; + ++ case 'S': ++ flags |= DAEMON_FLAGS_SYSTEMD_SERVICE; ++ break; ++ + case 'f': + flags |= DAEMON_FLAGS_FOREGROUND; + break; +@@ -2653,7 +2668,8 @@ int main(int argc, char *argv[]) + } + + #ifdef WITH_SYSTEMD +- sd_notify(1, "READY=1"); ++ if (flags & DAEMON_FLAGS_SYSTEMD_SERVICE) ++ sd_notify(1, "READY=1"); + #endif + + state_mach_thid = pthread_self(); +--- autofs-5.1.4.orig/include/automount.h ++++ autofs-5.1.4/include/automount.h +@@ -67,6 +67,7 @@ + #endif + + #define DAEMON_FLAGS_FOREGROUND 0x0001 ++#define DAEMON_FLAGS_SYSTEMD_SERVICE 0x0002 + #define DAEMON_FLAGS_HAVE_GLOBAL_OPTIONS 0x0004 + #define DAEMON_FLAGS_GHOST 0x0008 + #define DAEMON_FLAGS_CHECK_DAEMON 0x0010 +--- autofs-5.1.4.orig/man/automount.8 ++++ autofs-5.1.4/man/automount.8 +@@ -57,6 +57,10 @@ Define a global macro substitution varia + are over-ridden macro definitions of the same name specified in + mount entries. + .TP ++.I \-S, \-\-systemd-service ++Used when running the automounter as a systemd service to ensure log entry ++format is consistent with the log entry format when running as a daemon. ++.TP + .I "\-f, \-\-foreground" + Run the daemon in the foreground and log to stderr instead of syslog." + .TP +--- autofs-5.1.4.orig/samples/autofs.service.in ++++ autofs-5.1.4/samples/autofs.service.in +@@ -6,7 +6,7 @@ Wants=network-online.target rpc-statd.se + [Service] + Type=notify + EnvironmentFile=-@@autofsconfdir@@/autofs +-ExecStart=@@sbindir@@/automount $OPTIONS --foreground --dont-check-daemon ++ExecStart=@@sbindir@@/automount $OPTIONS --systemd-service --dont-check-daemon + ExecReload=/usr/bin/kill -HUP $MAINPID + KillMode=process + TimeoutSec=180 diff --git a/SOURCES/autofs-5.1.4-move-close-stdio-descriptors-to-become_daemon.patch b/SOURCES/autofs-5.1.4-move-close-stdio-descriptors-to-become_daemon.patch new file mode 100644 index 0000000..4a4642e --- /dev/null +++ b/SOURCES/autofs-5.1.4-move-close-stdio-descriptors-to-become_daemon.patch @@ -0,0 +1,117 @@ +autofs-5.1.4 - move close stdio descriptors to become_daemon() + +From: Ian Kent + +Move the stdio file descriptor close to the become_daemon() function +as closing these file descriptors, ie. detaching from ttys, is part +of the preperation for becoming a system daemon. + +Signed-off-by: Ian Kent +--- + CHANGELOG | 1 + + daemon/automount.c | 27 ++++++++++++++++++++++++++- + include/log.h | 1 - + lib/log.c | 29 ----------------------------- + 4 files changed, 27 insertions(+), 31 deletions(-) + +--- autofs-5.1.4.orig/CHANGELOG ++++ autofs-5.1.4/CHANGELOG +@@ -42,6 +42,7 @@ xx/xx/2018 autofs-5.1.5 + - add NULL check in prepare_attempt_prefix(). + - update build info with systemd. + - use flags for startup boolean options. ++- move close stdio descriptors to become_daemon(). + + 19/12/2017 autofs-5.1.4 + - fix spec file url. +--- autofs-5.1.4.orig/daemon/automount.c ++++ autofs-5.1.4/daemon/automount.c +@@ -1218,6 +1218,8 @@ static void become_daemon(unsigned int f + } + log_to_stderr(); + } else { ++ int nullfd; ++ + if (open_pipe(start_pipefd) < 0) { + fprintf(stderr, "%s: failed to create start_pipefd.\n", + program); +@@ -1261,7 +1263,30 @@ static void become_daemon(unsigned int f + close(start_pipefd[1]); + exit(*pst_stat); + } +- log_to_syslog(); ++ ++ /* Redirect all our file descriptors to /dev/null */ ++ nullfd = open("/dev/null", O_RDWR); ++ if (nullfd < 0) { ++ char *estr = strerror_r(errno, buf, MAX_ERR_BUF); ++ fprintf(stderr, "cannot open /dev/null: %s", estr); ++ res = write(start_pipefd[1], pst_stat, sizeof(*pst_stat)); ++ close(start_pipefd[1]); ++ exit(*pst_stat); ++ } ++ ++ if (dup2(nullfd, STDIN_FILENO) < 0 || ++ dup2(nullfd, STDOUT_FILENO) < 0 || ++ dup2(nullfd, STDERR_FILENO) < 0) { ++ char *estr = strerror_r(errno, buf, MAX_ERR_BUF); ++ fprintf(stderr, ++ "redirecting file descriptors failed: %s", estr); ++ res = write(start_pipefd[1], pst_stat, sizeof(*pst_stat)); ++ close(start_pipefd[1]); ++ exit(*pst_stat); ++ } ++ ++ open_log(); ++ close(nullfd); + } + + /* Write pid file if requested */ +--- autofs-5.1.4.orig/include/log.h ++++ autofs-5.1.4/include/log.h +@@ -36,7 +36,6 @@ extern void set_log_debug_ap(struct auto + extern void set_mnt_logging(unsigned global_logopt); + + extern void open_log(void); +-extern void log_to_syslog(void); + extern void log_to_stderr(void); + + extern void log_info(unsigned int, const char* msg, ...); +--- autofs-5.1.4.orig/lib/log.c ++++ autofs-5.1.4/lib/log.c +@@ -314,35 +314,6 @@ void open_log(void) + return; + } + +-void log_to_syslog(void) +-{ +- char buf[MAX_ERR_BUF]; +- int nullfd; +- +- open_log(); +- +- /* Redirect all our file descriptors to /dev/null */ +- nullfd = open("/dev/null", O_RDWR); +- if (nullfd < 0) { +- char *estr = strerror_r(errno, buf, MAX_ERR_BUF); +- fprintf(stderr, "cannot open /dev/null: %s", estr); +- exit(1); +- } +- +- if (dup2(nullfd, STDIN_FILENO) < 0 || +- dup2(nullfd, STDOUT_FILENO) < 0 || +- dup2(nullfd, STDERR_FILENO) < 0) { +- char *estr = strerror_r(errno, buf, MAX_ERR_BUF); +- fprintf(stderr, +- "redirecting file descriptors failed: %s", estr); +- exit(1); +- } +- +- close(nullfd); +- +- return; +-} +- + void log_to_stderr(void) + { + if (syslog_open) { diff --git a/SOURCES/autofs-5.1.4-remove-autofs4-module-load-code.patch b/SOURCES/autofs-5.1.4-remove-autofs4-module-load-code.patch new file mode 100644 index 0000000..27c0dfa --- /dev/null +++ b/SOURCES/autofs-5.1.4-remove-autofs4-module-load-code.patch @@ -0,0 +1,222 @@ +autofs-5.1.4 - remove autofs4 module load code + +From: Ian Kent + +The autofs kernel module has finally been renamed from autofs4 to +autofs so autoloading works so there is no need for manual loading. + +The module load function has been commented out in the source for +a long time so there should not be any adverse affects from removing +it. + +Signed-off-by: Ian Kent +--- + CHANGELOG | 1 + configure | 61 ---------------------------------------------------- + configure.in | 1 + daemon/automount.c | 8 ------ + daemon/module.c | 35 ----------------------------- + include/automount.h | 7 ----- + include/config.h.in | 6 ----- + 7 files changed, 1 insertion(+), 118 deletions(-) + +--- autofs-5.1.4.orig/CHANGELOG ++++ autofs-5.1.4/CHANGELOG +@@ -38,6 +38,7 @@ xx/xx/2018 autofs-5.1.5 + - fix amd parser opts option handling. + - better handle hesiod support not built in. + - fix hesiod string check in master_parse(). ++- remove autofs4 module load code. + + 19/12/2017 autofs-5.1.4 + - fix spec file url. +--- autofs-5.1.4.orig/configure ++++ autofs-5.1.4/configure +@@ -659,8 +659,6 @@ PATH_YACC + YACC + PATH_LEX + LEX +-HAVE_MODPROBE +-MODPROBE + HAVE_E4FSCK + E4FSCK + HAVE_E3FSCK +@@ -4155,65 +4153,6 @@ else + HAVE_E4FSCK=0 + fi + +-for ac_prog in modprobe +-do +- # Extract the first word of "$ac_prog", so it can be a program name with args. +-set dummy $ac_prog; ac_word=$2 +-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +-$as_echo_n "checking for $ac_word... " >&6; } +-if ${ac_cv_path_MODPROBE+:} false; then : +- $as_echo_n "(cached) " >&6 +-else +- case $MODPROBE in +- [\\/]* | ?:[\\/]*) +- ac_cv_path_MODPROBE="$MODPROBE" # Let the user override the test with a path. +- ;; +- *) +- as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +-for as_dir in $searchpath +-do +- IFS=$as_save_IFS +- test -z "$as_dir" && as_dir=. +- for ac_exec_ext in '' $ac_executable_extensions; do +- if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then +- ac_cv_path_MODPROBE="$as_dir/$ac_word$ac_exec_ext" +- $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 +- break 2 +- fi +-done +- done +-IFS=$as_save_IFS +- +- ;; +-esac +-fi +-MODPROBE=$ac_cv_path_MODPROBE +-if test -n "$MODPROBE"; then +- { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MODPROBE" >&5 +-$as_echo "$MODPROBE" >&6; } +-else +- { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +-$as_echo "no" >&6; } +-fi +- +- +- test -n "$MODPROBE" && break +-done +- +-if test -n "$MODPROBE"; then +- +-$as_echo "#define HAVE_MODPROBE 1" >>confdefs.h +- +- +-cat >>confdefs.h <<_ACEOF +-#define PATH_MODPROBE "$MODPROBE" +-_ACEOF +- +- HAVE_MODPROBE=1 +-else +- HAVE_MODPROBE=0 +-fi +- + + for ac_prog in flex lex + do +--- autofs-5.1.4.orig/configure.in ++++ autofs-5.1.4/configure.in +@@ -161,7 +161,6 @@ AF_PATH_INCLUDE(UMOUNT, umount, /bin/umo + AF_PATH_INCLUDE(E2FSCK, fsck.ext2 e2fsck, , $searchpath) + AF_PATH_INCLUDE(E3FSCK, fsck.ext3 e3fsck, , $searchpath) + AF_PATH_INCLUDE(E4FSCK, fsck.ext4 e4fsck, , $searchpath) +-AF_PATH_INCLUDE(MODPROBE, modprobe, , $searchpath) + + AF_CHECK_PROG(LEX, flex lex, , $searchpath) + AF_CHECK_PROG(YACC, bison, , $searchpath) +--- autofs-5.1.4.orig/daemon/automount.c ++++ autofs-5.1.4/daemon/automount.c +@@ -2336,14 +2336,6 @@ int main(int argc, char *argv[]) + exit(exit_code); + } + +-#if 0 +- if (!load_autofs4_module()) { +- fprintf(stderr, "%s: can't load %s filesystem module.\n", +- program, FS_MODULE_NAME); +- exit(1); +- } +-#endif +- + /* Don't need the kernel module just to look at the configured maps */ + if (!dumpmaps && (!query_kproto_ver() || get_kver_major() < 5)) { + fprintf(stderr, +--- autofs-5.1.4.orig/daemon/module.c ++++ autofs-5.1.4/daemon/module.c +@@ -19,41 +19,6 @@ + #include "automount.h" + #include "nsswitch.h" + +-int load_autofs4_module(void) +-{ +- FILE *fp; +- char buf[PATH_MAX]; +- int ret; +- +- /* +- * Check if module already loaded or compiled in. +- * If both autofs v3 and v4 are coplied in and +- * the v3 module registers first or the v4 module +- * is an older version we will catch it at mount +- * time. +- */ +- fp = open_fopen_r("/proc/filesystems"); +- if (!fp) { +- logerr("cannot open /proc/filesystems"); +- return 0; +- } +- +- while (fgets(buf, sizeof(buf), fp)) { +- if (strstr(buf, "autofs")) { +- fclose(fp); +- return 1; +- } +- } +- fclose(fp); +- +- ret = spawnl(LOGOPT_NONE, PATH_MODPROBE, PATH_MODPROBE, +- "-q", FS_MODULE_NAME, NULL); +- if (ret) +- return 0; +- +- return 1; +-} +- + int open_lookup(const char *name, const char *err_prefix, const char *mapfmt, + int argc, const char *const *argv, struct lookup_mod **lookup) + { +--- autofs-5.1.4.orig/include/automount.h ++++ autofs-5.1.4/include/automount.h +@@ -52,17 +52,10 @@ + #error Failed to locate umount(8)! + #endif + +-#ifndef HAVE_MODPROBE +-#error Failed to locate modprobe(8)! +-#endif +- + #ifndef HAVE_LINUX_PROCFS + #error Failed to verify existence of procfs filesystem! + #endif + +-#define FS_MODULE_NAME "autofs4" +-int load_autofs4_module(void); +- + /* The -s (sloppy) option to mount is good, if we have it... */ + + #ifdef HAVE_SLOPPY_MOUNT +--- autofs-5.1.4.orig/include/config.h.in ++++ autofs-5.1.4/include/config.h.in +@@ -48,9 +48,6 @@ + /* Define to 1 if you have the header file. */ + #undef HAVE_MEMORY_H + +-/* define if you have MODPROBE */ +-#undef HAVE_MODPROBE +- + /* define if you have MOUNT */ + #undef HAVE_MOUNT + +@@ -129,9 +126,6 @@ + /* define if you have LEX */ + #undef PATH_LEX + +-/* define if you have MODPROBE */ +-#undef PATH_MODPROBE +- + /* define if you have MOUNT */ + #undef PATH_MOUNT + diff --git a/SOURCES/autofs-5.1.4-update-build-info-with-systemd.patch b/SOURCES/autofs-5.1.4-update-build-info-with-systemd.patch new file mode 100644 index 0000000..7c9f381 --- /dev/null +++ b/SOURCES/autofs-5.1.4-update-build-info-with-systemd.patch @@ -0,0 +1,41 @@ +autofs-5.1.4 - update build info with systemd + +From: Ian Kent + +Update the show_build_info() function to include systemd +build info. + +Signed-off-by: Ian Kent +--- + CHANGELOG | 1 + + daemon/automount.c | 9 +++++++++ + 2 files changed, 10 insertions(+) + +--- autofs-5.1.4.orig/CHANGELOG ++++ autofs-5.1.4/CHANGELOG +@@ -40,6 +40,7 @@ xx/xx/2018 autofs-5.1.5 + - fix hesiod string check in master_parse(). + - remove autofs4 module load code. + - add NULL check in prepare_attempt_prefix(). ++- update build info with systemd. + + 19/12/2017 autofs-5.1.4 + - fix spec file url. +--- autofs-5.1.4.orig/daemon/automount.c ++++ autofs-5.1.4/daemon/automount.c +@@ -1951,6 +1951,15 @@ static void show_build_info(void) + } + #endif + ++#ifdef WITH_SYSTEMD ++ printf("WITH_SYSTEMD "); ++ count = count + 13; ++ ++ if (count > 60) { ++ printf("\n "); ++ count = 0; ++ } ++#endif + + #ifdef WITH_HESIOD + printf("WITH_HESIOD "); diff --git a/SOURCES/autofs-5.1.4-use-flags-for-startup-boolean-options.patch b/SOURCES/autofs-5.1.4-use-flags-for-startup-boolean-options.patch new file mode 100644 index 0000000..b744ce7 --- /dev/null +++ b/SOURCES/autofs-5.1.4-use-flags-for-startup-boolean-options.patch @@ -0,0 +1,217 @@ +autofs-5.1.4 - use flags for startup boolean options + +From: Ian Kent + +The daemon uses a number of boolean flags each stored in unsigned int +variables. But a single bit flag is sufficient storage for most of +these flags. + +So use bit flags for these where possible. + +Signed-off-by: Ian Kent +--- + CHANGELOG | 1 + + daemon/automount.c | 45 ++++++++++++++++++++++----------------------- + include/automount.h | 6 ++++++ + lib/master.c | 4 ++-- + 4 files changed, 31 insertions(+), 25 deletions(-) + +--- autofs-5.1.4.orig/CHANGELOG ++++ autofs-5.1.4/CHANGELOG +@@ -41,6 +41,7 @@ xx/xx/2018 autofs-5.1.5 + - remove autofs4 module load code. + - add NULL check in prepare_attempt_prefix(). + - update build info with systemd. ++- use flags for startup boolean options. + + 19/12/2017 autofs-5.1.4 + - fix spec file url. +--- autofs-5.1.4.orig/daemon/automount.c ++++ autofs-5.1.4/daemon/automount.c +@@ -1195,7 +1195,7 @@ static int handle_packet(struct autofs_p + return -1; + } + +-static void become_daemon(unsigned foreground, unsigned daemon_check) ++static void become_daemon(unsigned int flags) + { + FILE *pidfp; + char buf[MAX_ERR_BUF]; +@@ -1210,8 +1210,8 @@ static void become_daemon(unsigned foreg + } + + /* Detach from foreground process */ +- if (foreground) { +- if (daemon_check && !aquire_flag_file()) { ++ if (flags & DAEMON_FLAGS_FOREGROUND) { ++ if ((flags & DAEMON_FLAGS_CHECK_DAEMON) && !aquire_flag_file()) { + fprintf(stderr, "%s: program is already running.\n", + program); + exit(1); +@@ -1238,7 +1238,7 @@ static void become_daemon(unsigned foreg + } + close(start_pipefd[0]); + +- if (daemon_check && !aquire_flag_file()) { ++ if ((flags & DAEMON_FLAGS_CHECK_DAEMON) && !aquire_flag_file()) { + fprintf(stderr, "%s: program is already running.\n", + program); + /* Return success if already running */ +@@ -2158,8 +2158,8 @@ int main(int argc, char *argv[]) + { + int res, opt, status; + int logpri = -1; +- unsigned ghost, logging, daemon_check; +- unsigned dumpmaps, foreground, have_global_options; ++ unsigned int flags; ++ unsigned int logging; + unsigned master_read; + int master_wait; + time_t timeout; +@@ -2202,17 +2202,15 @@ int main(int argc, char *argv[]) + + nfs_mount_uses_string_options = check_nfs_mount_version(&vers, &check); + ++ flags = defaults_get_browse_mode() ? DAEMON_FLAGS_GHOST : 0; ++ flags |= DAEMON_FLAGS_CHECK_DAEMON; ++ + kpkt_len = get_kpkt_len(); + master_wait = defaults_get_master_wait(); + timeout = defaults_get_timeout(); +- ghost = defaults_get_browse_mode(); + logging = defaults_get_logging(); + global_selection_options = 0; + global_options = NULL; +- have_global_options = 0; +- foreground = 0; +- dumpmaps = 0; +- daemon_check = 1; + + remove_empty_args(argv, &argc); + +@@ -2244,7 +2242,7 @@ int main(int argc, char *argv[]) + break; + + case 'f': +- foreground = 1; ++ flags |= DAEMON_FLAGS_FOREGROUND; + break; + + case 'V': +@@ -2260,7 +2258,7 @@ int main(int argc, char *argv[]) + break; + + case 'm': +- dumpmaps = 1; ++ flags |= DAEMON_FLAGS_DUMP_MAPS; + break; + + case 'M': +@@ -2268,9 +2266,9 @@ int main(int argc, char *argv[]) + break; + + case 'O': +- if (!have_global_options) { ++ if (!(flags & DAEMON_FLAGS_HAVE_GLOBAL_OPTIONS)) { + global_options = strdup(optarg); +- have_global_options = 1; ++ flags |= DAEMON_FLAGS_HAVE_GLOBAL_OPTIONS; + break; + } + printf("%s: global options already specified.\n", +@@ -2295,7 +2293,7 @@ int main(int argc, char *argv[]) + break; + + case 'C': +- daemon_check = 0; ++ flags &= ~DAEMON_FLAGS_CHECK_DAEMON; + break; + + case 'F': +@@ -2346,7 +2344,8 @@ int main(int argc, char *argv[]) + } + + /* Don't need the kernel module just to look at the configured maps */ +- if (!dumpmaps && (!query_kproto_ver() || get_kver_major() < 5)) { ++ if (!(flags & DAEMON_FLAGS_DUMP_MAPS) && ++ (!query_kproto_ver() || get_kver_major() < 5)) { + fprintf(stderr, + "%s: test mount forbidden or " + "incorrect kernel protocol version, " +@@ -2377,7 +2376,7 @@ int main(int argc, char *argv[]) + /* Get processor information for predefined escapes */ + macro_init(); + +- if (dumpmaps) { ++ if (flags & DAEMON_FLAGS_DUMP_MAPS) { + struct master_mapent *entry; + struct list_head *head, *p; + struct mapent_cache *nc; +@@ -2395,9 +2394,9 @@ int main(int argc, char *argv[]) + } + + if (master) +- master_list = master_new(NULL, timeout, ghost); ++ master_list = master_new(NULL, timeout, flags); + else +- master_list = master_new(master, timeout, ghost); ++ master_list = master_new(master, timeout, flags); + if (!master_list) { + printf("%s: can't create master map", program); + macro_free_global_table(); +@@ -2443,9 +2442,9 @@ int main(int argc, char *argv[]) + } + + if (argc == 0) +- master_list = master_new(NULL, timeout, ghost); ++ master_list = master_new(NULL, timeout, flags); + else +- master_list = master_new(argv[0], timeout, ghost); ++ master_list = master_new(argv[0], timeout, flags); + + if (!master_list) { + printf("%s: can't create master map %s", program, argv[0]); +@@ -2453,7 +2452,7 @@ int main(int argc, char *argv[]) + exit(1); + } + +- become_daemon(foreground, daemon_check); ++ become_daemon(flags); + + if (pthread_attr_init(&th_attr)) { + logerr("%s: failed to init thread attribute struct!", +--- autofs-5.1.4.orig/include/automount.h ++++ autofs-5.1.4/include/automount.h +@@ -66,6 +66,12 @@ + #define SLOPPY + #endif + ++#define DAEMON_FLAGS_FOREGROUND 0x0001 ++#define DAEMON_FLAGS_HAVE_GLOBAL_OPTIONS 0x0004 ++#define DAEMON_FLAGS_GHOST 0x0008 ++#define DAEMON_FLAGS_CHECK_DAEMON 0x0010 ++#define DAEMON_FLAGS_DUMP_MAPS 0x0020 ++ + #define AUTOFS_SUPER_MAGIC 0x00000187L + #define SMB_SUPER_MAGIC 0x0000517BL + #define CIFS_MAGIC_NUMBER 0xFF534D42L +--- autofs-5.1.4.orig/lib/master.c ++++ autofs-5.1.4/lib/master.c +@@ -922,7 +922,7 @@ void master_free_mapent(struct master_ma + return; + } + +-struct master *master_new(const char *name, unsigned int timeout, unsigned int ghost) ++struct master *master_new(const char *name, unsigned int timeout, unsigned int flags) + { + struct master *master; + char *tmp; +@@ -948,7 +948,7 @@ struct master *master_new(const char *na + master->depth = 0; + master->reading = 0; + master->read_fail = 0; +- master->default_ghost = ghost; ++ master->default_ghost = flags & DAEMON_FLAGS_GHOST; + master->default_timeout = timeout; + master->default_logging = defaults_get_logging(); + master->logopt = master->default_logging; diff --git a/SOURCES/autofs-5.1.5-add-NULL-check-for-get_addr_string-return.patch b/SOURCES/autofs-5.1.5-add-NULL-check-for-get_addr_string-return.patch new file mode 100644 index 0000000..be021c3 --- /dev/null +++ b/SOURCES/autofs-5.1.5-add-NULL-check-for-get_addr_string-return.patch @@ -0,0 +1,39 @@ +autofs-5.1.5 - add NULL check for get_addr_string() return + +From: Ian Kent + +When constructing the mount location string in mount_nfs.c:mount_mount() +the return from get_addr_string() is not checked for NULL. + +Signed-off-by: Ian Kent +--- + CHANGELOG | 1 + + modules/mount_nfs.c | 6 ++++++ + 2 files changed, 7 insertions(+) + +--- autofs-5.1.4.orig/CHANGELOG ++++ autofs-5.1.4/CHANGELOG +@@ -45,6 +45,7 @@ xx/xx/2018 autofs-5.1.5 + - move close stdio descriptors to become_daemon(). + - add systemd service command line option. + - support strictexpire mount option. ++- add NULL check for get_addr_string() return. + + 19/12/2017 autofs-5.1.4 + - fix spec file url. +--- autofs-5.1.4.orig/modules/mount_nfs.c ++++ autofs-5.1.4/modules/mount_nfs.c +@@ -333,7 +333,13 @@ dont_probe: + socklen_t len = INET6_ADDRSTRLEN; + char n_buf[len + 1]; + const char *n_addr; ++ + n_addr = get_addr_string(this->addr, n_buf, len); ++ if (!n_addr) { ++ char *estr = strerror_r(errno, buf, MAX_ERR_BUF); ++ error(ap->logopt, "get_addr_string: %s", estr); ++ goto forced_fail; ++ } + loc = malloc(strlen(n_addr) + strlen(this->path) + 4); + if (!loc) { + char *estr = strerror_r(errno, buf, MAX_ERR_BUF); diff --git a/SOURCES/autofs-5.1.5-add-mount_verbose-configuration-option.patch b/SOURCES/autofs-5.1.5-add-mount_verbose-configuration-option.patch new file mode 100644 index 0000000..8521252 --- /dev/null +++ b/SOURCES/autofs-5.1.5-add-mount_verbose-configuration-option.patch @@ -0,0 +1,174 @@ +autofs-5.1.5 - add mount_verbose configuration option + +From: Lars R. Damerow + +This option makes automount pass the -v flag to mount(8). + +Signed-off-by: Lars R. Damerow +Signed-off-by: Ian Kent +--- + CHANGELOG | 1 + + daemon/spawn.c | 20 ++++++++++++-------- + include/defaults.h | 2 ++ + lib/defaults.c | 17 +++++++++++++++++ + man/autofs.conf.5.in | 4 ++++ + redhat/autofs.conf.default.in | 4 ++++ + samples/autofs.conf.default.in | 4 ++++ + 7 files changed, 44 insertions(+), 8 deletions(-) + +--- autofs-5.1.4.orig/CHANGELOG ++++ autofs-5.1.4/CHANGELOG +@@ -47,6 +47,7 @@ xx/xx/2018 autofs-5.1.5 + - support strictexpire mount option. + - add NULL check for get_addr_string() return. + - use malloc(3) in spawn.c. ++- add mount_verbose configuration option. + + 19/12/2017 autofs-5.1.4 + - fix spec file url. +--- autofs-5.1.4.orig/daemon/spawn.c ++++ autofs-5.1.4/daemon/spawn.c +@@ -558,12 +558,14 @@ int spawn_mount(unsigned logopt, ...) + char prog[] = PATH_MOUNT; + char arg0[] = PATH_MOUNT; + char argn[] = "-n"; ++ char argvr[] = "-v"; + /* In case we need to use the fake option to mount */ + char arg_fake[] = "-f"; + unsigned int options; + unsigned int retries = MTAB_LOCK_RETRIES; + int update_mtab = 1, ret, printed = 0; + unsigned int wait = defaults_get_mount_wait(); ++ int verbose = defaults_get_mount_verbose(); + char buf[PATH_MAX + 1]; + unsigned int argv_len; + +@@ -590,8 +592,10 @@ int spawn_mount(unsigned logopt, ...) + } + } + +- /* Alloc 1 extra slot in case we need to use the "-f" option */ +- argv_len = sizeof(char *) * (argc + 2); ++ /* Alloc 2 extra slots in case we need to use the "-f" or "-v" options ++ * plus the NULL slot for end of args. ++ */ ++ argv_len = sizeof(char *) * (argc + 3); + argv = malloc(argv_len); + if (!argv) { + char buf[MAX_ERR_BUF]; +@@ -604,12 +608,12 @@ int spawn_mount(unsigned logopt, ...) + argv[0] = arg0; + + va_start(arg, logopt); +- if (update_mtab) +- p = argv + 1; +- else { +- argv[1] = argn; +- p = argv + 2; +- } ++ p = argv + 1; ++ if (!update_mtab) ++ *(p++) = argn; ++ if (verbose) ++ *(p++) = argvr; ++ + while ((*p = va_arg(arg, char *))) { + if (options == SPAWN_OPT_OPEN && !strcmp(*p, "-t")) { + *(++p) = va_arg(arg, char *); +--- autofs-5.1.4.orig/include/defaults.h ++++ autofs-5.1.4/include/defaults.h +@@ -27,6 +27,7 @@ + #define DEFAULT_TIMEOUT "600" + #define DEFAULT_MASTER_WAIT "10" + #define DEFAULT_NEGATIVE_TIMEOUT "60" ++#define DEFAULT_MOUNT_VERBOSE "0" + #define DEFAULT_MOUNT_WAIT "-1" + #define DEFAULT_UMOUNT_WAIT "12" + #define DEFAULT_BROWSE_MODE "1" +@@ -166,6 +167,7 @@ unsigned int defaults_get_ldap_timeout(v + unsigned int defaults_get_ldap_network_timeout(void); + unsigned int defaults_get_mount_nfs_default_proto(void); + unsigned int defaults_get_append_options(void); ++unsigned int defaults_get_mount_verbose(void); + unsigned int defaults_get_mount_wait(void); + unsigned int defaults_get_umount_wait(void); + const char *defaults_get_auth_conf_file(void); +--- autofs-5.1.4.orig/lib/defaults.c ++++ autofs-5.1.4/lib/defaults.c +@@ -68,6 +68,7 @@ + + #define NAME_MOUNT_NFS_DEFAULT_PROTOCOL "mount_nfs_default_protocol" + #define NAME_APPEND_OPTIONS "append_options" ++#define NAME_MOUNT_VERBOSE "mount_verbose" + #define NAME_MOUNT_WAIT "mount_wait" + #define NAME_UMOUNT_WAIT "umount_wait" + #define NAME_AUTH_CONF_FILE "auth_conf_file" +@@ -328,6 +329,11 @@ static int conf_load_autofs_defaults(voi + if (ret == CFG_FAIL) + goto error; + ++ ret = conf_update(sec, NAME_MOUNT_VERBOSE, ++ DEFAULT_MOUNT_VERBOSE, CONF_ENV); ++ if (ret == CFG_FAIL) ++ goto error; ++ + ret = conf_update(sec, NAME_MOUNT_WAIT, + DEFAULT_MOUNT_WAIT, CONF_ENV); + if (ret == CFG_FAIL) +@@ -1780,6 +1786,17 @@ unsigned int defaults_get_append_options + + return res; + } ++ ++unsigned int defaults_get_mount_verbose(void) ++{ ++ long res; ++ ++ res = conf_get_yesno(autofs_gbl_sec, NAME_MOUNT_VERBOSE); ++ if (res < 0) ++ res = atoi(DEFAULT_MOUNT_VERBOSE); ++ ++ return res; ++} + + unsigned int defaults_get_mount_wait(void) + { +--- autofs-5.1.4.orig/man/autofs.conf.5.in ++++ autofs-5.1.4/man/autofs.conf.5.in +@@ -41,6 +41,10 @@ Set the default timeout for caching fail + 60). If the equivalent command line option is given it will override this + setting. + .TP ++.B mount_verbose ++.br ++Use the verbose flag when spawning mount(8) (program default "no"). ++.TP + .B mount_wait + .br + Set the default time to wait for a response from a spawned mount(8) +--- autofs-5.1.4.orig/redhat/autofs.conf.default.in ++++ autofs-5.1.4/redhat/autofs.conf.default.in +@@ -26,6 +26,10 @@ timeout = 300 + # + #negative_timeout = 60 + # ++# mount_verbose - use the -v flag when calling mount(8). ++# ++#mount_verbose = no ++# + # mount_wait - time to wait for a response from mount(8). + # Setting this timeout can cause problems when + # mount would otherwise wait for a server that +--- autofs-5.1.4.orig/samples/autofs.conf.default.in ++++ autofs-5.1.4/samples/autofs.conf.default.in +@@ -26,6 +26,10 @@ timeout = 300 + # + #negative_timeout = 60 + # ++# mount_verbose - use the -v flag when calling mount(8). ++# ++#mount_verbose = no ++# + # mount_wait - time to wait for a response from mount(8). + # Setting this timeout can cause problems when + # mount would otherwise wait for a server that diff --git a/SOURCES/autofs-5.1.5-add-strictexpire-mount-option.patch b/SOURCES/autofs-5.1.5-add-strictexpire-mount-option.patch new file mode 100644 index 0000000..3809b9e --- /dev/null +++ b/SOURCES/autofs-5.1.5-add-strictexpire-mount-option.patch @@ -0,0 +1,200 @@ +autofs-5.1.5 - support strictexpire mount option + +From: Ian Kent + +Kernel commit 092a53452b (("autofs: take more care to not update +last_used on path walk") helped to (partially) resolve a problem +where automounts were not expiring due to aggressive accesses from +user space. + +This patch was later reverted because, for very large environments, +it meant more mount requests from clients and when there are a lot +of clients this caused a fairly significant increase in server load. + +But there is a need for both types of expire check, depending on use +case, so a mount option to allow for strict update of last use of +autofs dentrys has been added ito the autofs file system (which just +means not updating the last use on path walk accesses). + +So add support for this master map mount entry option in the user +space code. + +Signed-off-by: Ian Kent +--- + CHANGELOG | 1 + + daemon/direct.c | 10 ++++++++++ + daemon/indirect.c | 10 ++++++++++ + include/automount.h | 3 +++ + lib/master_parse.y | 8 +++++++- + lib/master_tok.l | 1 + + man/auto.master.5.in | 8 ++++++++ + modules/mount_autofs.c | 5 +++++ + 8 files changed, 45 insertions(+), 1 deletion(-) + +--- autofs-5.1.4.orig/CHANGELOG ++++ autofs-5.1.4/CHANGELOG +@@ -44,6 +44,7 @@ xx/xx/2018 autofs-5.1.5 + - use flags for startup boolean options. + - move close stdio descriptors to become_daemon(). + - add systemd service command line option. ++- support strictexpire mount option. + + 19/12/2017 autofs-5.1.4 + - fix spec file url. +--- autofs-5.1.4.orig/daemon/direct.c ++++ autofs-5.1.4/daemon/direct.c +@@ -421,6 +421,16 @@ int do_mount_autofs_direct(struct autofs + mp->options = make_options_string(ap->path, ap->kpipefd, str_direct); + if (!mp->options) + return 0; ++ ++ if ((ap->flags & MOUNT_FLAG_STRICTEXPIRE) && ++ ((get_kver_major() == 5 && get_kver_minor() > 3) || ++ (get_kver_major() > 5))) { ++ char *tmp = realloc(mp->options, strlen(mp->options) + 12); ++ if (tmp) { ++ strcat(tmp, ",strictexpire"); ++ mp->options = tmp; ++ } ++ } + } + + /* In case the directory doesn't exist, try to mkdir it */ +--- autofs-5.1.4.orig/daemon/indirect.c ++++ autofs-5.1.4/daemon/indirect.c +@@ -132,6 +132,16 @@ static int do_mount_autofs_indirect(stru + goto out_err; + } + ++ if ((ap->flags & MOUNT_FLAG_STRICTEXPIRE) && ++ ((get_kver_major() == 5 && get_kver_minor() > 3) || ++ (get_kver_major() > 5))) { ++ char *tmp = realloc(options, strlen(options) + 12); ++ if (tmp) { ++ strcat(tmp, ",strictexpire"); ++ options = tmp; ++ } ++ } ++ + /* In case the directory doesn't exist, try to mkdir it */ + if (mkdir_path(root, mp_mode) < 0) { + if (errno != EEXIST && errno != EROFS) { +--- autofs-5.1.4.orig/include/automount.h ++++ autofs-5.1.4/include/automount.h +@@ -553,6 +553,9 @@ struct kernel_mod_version { + #define MOUNT_FLAG_SLAVE 0x0100 + #define MOUNT_FLAG_PRIVATE 0x0200 + ++/* Use strict expire semantics if requested and kernel supports it */ ++#define MOUNT_FLAG_STRICTEXPIRE 0x0400 ++ + struct autofs_point { + pthread_t thid; + char *path; /* Mount point name */ +--- autofs-5.1.4.orig/lib/master_parse.y ++++ autofs-5.1.4/lib/master_parse.y +@@ -58,6 +58,7 @@ static char *format; + static long timeout; + static long negative_timeout; + static unsigned symlnk; ++static unsigned strictexpire; + static unsigned slave; + static unsigned private; + static unsigned nobind; +@@ -105,7 +106,7 @@ static int master_fprintf(FILE *, char * + %token MAP + %token OPT_TIMEOUT OPT_NTIMEOUT OPT_NOBIND OPT_NOGHOST OPT_GHOST OPT_VERBOSE + %token OPT_DEBUG OPT_RANDOM OPT_USE_WEIGHT OPT_SYMLINK OPT_MODE +-%token OPT_SLAVE OPT_PRIVATE ++%token OPT_STRICTEXPIRE OPT_SLAVE OPT_PRIVATE + %token COLON COMMA NL DDASH + %type map + %type options +@@ -206,6 +207,7 @@ line: + | PATH OPT_DEBUG { master_notify($1); YYABORT; } + | PATH OPT_TIMEOUT { master_notify($1); YYABORT; } + | PATH OPT_SYMLINK { master_notify($1); YYABORT; } ++ | PATH OPT_STRICTEXPIRE { master_notify($1); YYABORT; } + | PATH OPT_SLAVE { master_notify($1); YYABORT; } + | PATH OPT_PRIVATE { master_notify($1); YYABORT; } + | PATH OPT_NOBIND { master_notify($1); YYABORT; } +@@ -619,6 +621,7 @@ option: daemon_option + daemon_option: OPT_TIMEOUT NUMBER { timeout = $2; } + | OPT_NTIMEOUT NUMBER { negative_timeout = $2; } + | OPT_SYMLINK { symlnk = 1; } ++ | OPT_STRICTEXPIRE { strictexpire = 1; } + | OPT_SLAVE { slave = 1; } + | OPT_PRIVATE { private = 1; } + | OPT_NOBIND { nobind = 1; } +@@ -693,6 +696,7 @@ static void local_init_vars(void) + timeout = -1; + negative_timeout = 0; + symlnk = 0; ++ strictexpire = 0; + slave = 0; + private = 0; + nobind = 0; +@@ -901,6 +905,8 @@ int master_parse_entry(const char *buffe + entry->ap->flags |= MOUNT_FLAG_USE_WEIGHT_ONLY; + if (symlnk) + entry->ap->flags |= MOUNT_FLAG_SYMLINK; ++ if (strictexpire) ++ entry->ap->flags |= MOUNT_FLAG_STRICTEXPIRE; + if (slave) + entry->ap->flags |= MOUNT_FLAG_SLAVE; + if (private) +--- autofs-5.1.4.orig/lib/master_tok.l ++++ autofs-5.1.4/lib/master_tok.l +@@ -391,6 +391,7 @@ MODE (--mode{OPTWS}|--mode{OPTWS}={OPTW + -?nobrowse { return(OPT_NOGHOST); } + -?slave { return(OPT_SLAVE); } + -?private { return(OPT_PRIVATE); } ++ -?strictexpire { return(OPT_STRICTEXPIRE); } + -g|--ghost|-?browse { return(OPT_GHOST); } + -v|--verbose { return(OPT_VERBOSE); } + -d|--debug { return(OPT_DEBUG); } +--- autofs-5.1.4.orig/man/auto.master.5.in ++++ autofs-5.1.4/man/auto.master.5.in +@@ -199,6 +199,14 @@ entries only, either in the master map ( + or with individual map entries. The option is ignored for direct mounts + and non-root offest mount entries. + .TP ++.I "strictexpire" ++Use a strict expire policy for this automount. Using this option means ++that last use of autofs directory entries will not be updated during ++path walks so that mounts in an automount won't be kept mounted by ++applications scanning the mount tree. Note that this doesn't completely ++resolve the problem of expired automounts being immediately re-mounted ++due to application accesses triggered by the expire itself. ++.TP + .I slave \fPor\fI private + This option allows mount propagation of bind mounts to be set to + either \fIslave\fP or \fIprivate\fP. This option may be needed when using +--- autofs-5.1.4.orig/modules/mount_autofs.c ++++ autofs-5.1.4/modules/mount_autofs.c +@@ -57,6 +57,7 @@ int mount_mount(struct autofs_point *ap, + int nobind = ap->flags & MOUNT_FLAG_NOBIND; + int ghost = ap->flags & MOUNT_FLAG_GHOST; + int symlnk = ap->flags & MOUNT_FLAG_SYMLINK; ++ int strictexpire = ap->flags & MOUNT_FLAG_STRICTEXPIRE; + time_t timeout = get_exp_timeout(ap, ap->entry->maps); + unsigned logopt = ap->logopt; + struct map_type_info *info; +@@ -131,6 +132,8 @@ int mount_mount(struct autofs_point *ap, + ghost = 1; + else if (_strncmp("symlink", cp, 7) == 0) + symlnk = 1; ++ else if (_strncmp("strictexpire", cp, 12) == 0) ++ strictexpire = 1; + else if (_strncmp("hosts", cp, 5) == 0) + hosts = 1; + else if (_strncmp("timeout=", cp, 8) == 0) { +@@ -173,6 +176,8 @@ int mount_mount(struct autofs_point *ap, + nap->parent = ap; + if (symlnk) + nap->flags |= MOUNT_FLAG_SYMLINK; ++ if (strictexpire) ++ nap->flags |= MOUNT_FLAG_STRICTEXPIRE; + + if (hosts) + argc = 0; diff --git a/SOURCES/autofs-5.1.5-allow-period-following-macro-in-selector-value.patch b/SOURCES/autofs-5.1.5-allow-period-following-macro-in-selector-value.patch new file mode 100644 index 0000000..a96c68f --- /dev/null +++ b/SOURCES/autofs-5.1.5-allow-period-following-macro-in-selector-value.patch @@ -0,0 +1,34 @@ +autofs-5.1.5 - allow period following macro in selector value + +From: Ian Kent + +If a ${} macro is used in a selector (such as hostd) the parser doesn't +permit a period to follow it (such as when the value is a host name). + +Signed-off-by: Ian Kent +--- + CHANGELOG | 1 + + modules/amd_tok.l | 2 +- + 2 files changed, 2 insertions(+), 1 deletion(-) + +--- autofs-5.1.4.orig/CHANGELOG ++++ autofs-5.1.4/CHANGELOG +@@ -51,6 +51,7 @@ xx/xx/2018 autofs-5.1.5 + - optionally log mount requestor process info. + - log mount call arguments if mount_verbose is set. + - make expire remaining log level debug. ++- allow period following macro in selector value. + + 19/12/2017 autofs-5.1.4 + - fix spec file url. +--- autofs-5.1.4.orig/modules/amd_tok.l ++++ autofs-5.1.4/modules/amd_tok.l +@@ -95,7 +95,7 @@ V6MASK (12[0-8]|1[0-1][0-9]|[1-9][0-9]| + + FOPT (({QSTR}|{FSTR}|{MACRO})+) + OPTS ({OSTR}(=({VSTR}|{MACRO})+)?) +-SOPT (({SSTR}|{QSTR}|{MACRO})+) ++SOPT ({SSTR}|{QSTR}|{MACRO}(\.|{SSTR}|{QSTR}|{MACRO})+) + NOPT ({SSTR}|(({IP4ADDR}(\/{V4MASK})?)|({IP6ADDR}(\/{V6MASK})?))) + + MAPOPT (fs|type|maptype|pref|sublink|cache) diff --git a/SOURCES/autofs-5.1.5-fix-macro-expansion-in-selector-values.patch b/SOURCES/autofs-5.1.5-fix-macro-expansion-in-selector-values.patch new file mode 100644 index 0000000..0b2a5d0 --- /dev/null +++ b/SOURCES/autofs-5.1.5-fix-macro-expansion-in-selector-values.patch @@ -0,0 +1,419 @@ +autofs-5.1.5 - fix macro expansion in selector values + +From: Ian Kent + +Macro expansion is not done in selector values before use, for example +in "hostd==${/key}.." the ${/key} is not expanded before +use leading to an attempt to use an invalid host name. + +Signed-off-by: Ian Kent +--- + CHANGELOG | 1 + modules/parse_amd.c | 286 ++++++++++++++++++++++++++++++++++------------------ + 2 files changed, 193 insertions(+), 94 deletions(-) + +--- autofs-5.1.4.orig/CHANGELOG ++++ autofs-5.1.4/CHANGELOG +@@ -52,6 +52,7 @@ xx/xx/2018 autofs-5.1.5 + - log mount call arguments if mount_verbose is set. + - make expire remaining log level debug. + - allow period following macro in selector value. ++- fix macro expansion in selector values. + + 19/12/2017 autofs-5.1.4 + - fix spec file url. +--- autofs-5.1.4.orig/modules/parse_amd.c ++++ autofs-5.1.4/modules/parse_amd.c +@@ -231,17 +231,29 @@ static struct substvar *add_lookup_vars( + return list; + } + +-static int match_my_name(unsigned int logopt, const char *name, struct substvar *sv) ++static int match_my_name(struct autofs_point *ap, const char *name, struct substvar *sv) + { + struct addrinfo hints, *cni, *ni, *haddr; + char host[NI_MAXHOST + 1], numeric[NI_MAXHOST + 1]; ++ unsigned int logopt = ap->logopt; + const struct substvar *v; ++ char *exp_name = NULL; + int rv = 0, ret; + ++ if (!expand_selectors(ap, name, &exp_name, sv)) ++ exp_name = strdup(name); ++ if (!exp_name) { ++ error(logopt, ++ MODPREFIX "error: failed to alloc space for name"); ++ goto out; ++ } ++ + v = macro_findvar(sv, "host", 4); + if (v) { +- if (!strcmp(v->val, name)) +- return 1; ++ if (!strcmp(v->val, exp_name)) { ++ rv = 1; ++ goto out; ++ } + } + + if (!v || !v->val) { +@@ -268,11 +280,11 @@ static int match_my_name(unsigned int lo + hints.ai_flags = AI_V4MAPPED | AI_ADDRCONFIG | AI_CANONNAME; + + /* Resolve comparison name to its names and compare */ +- ret = getaddrinfo(name, NULL, &hints, &ni); ++ ret = getaddrinfo(exp_name, NULL, &hints, &ni); + if (ret) { + error(logopt, MODPREFIX + "hostname lookup for %s failed: %s\n", +- name, gai_strerror(ret)); ++ exp_name, gai_strerror(ret)); + freeaddrinfo(cni); + goto out; + } +@@ -310,18 +322,180 @@ next: + freeaddrinfo(ni); + freeaddrinfo(cni); + out: ++ if (exp_name) ++ free(exp_name); + return rv; + } + +-static int eval_selector(unsigned int logopt, ++static int sel_strcmp(struct autofs_point *ap, ++ const struct substvar *v, struct selector *s, ++ struct substvar *sv) ++{ ++ char *expand = NULL; ++ int ret = 0; ++ int res; ++ ++ res = expand_selectors(ap, s->comp.value, &expand, sv); ++ if (res) ++ res = strcmp(v->val, expand); ++ else ++ res = strcmp(v->val, s->comp.value); ++ ++ if (s->compare & SEL_COMP_EQUAL && !res) { ++ debug(ap->logopt, MODPREFIX ++ "matched selector %s(%s) == %s", ++ v->def, v->val, expand ? expand : s->comp.value); ++ ret = 1; ++ } else if (s->compare & SEL_COMP_NOTEQUAL && res) { ++ debug(ap->logopt, MODPREFIX ++ "matched selector %s(%s) != %s", ++ v->def, v->val, expand ? expand : s->comp.value); ++ ret = 1; ++ } else ++ debug(ap->logopt, MODPREFIX ++ "did not match selector %s(%s) %s %s", ++ v->def, v->val, ++ (s->compare & SEL_COMP_EQUAL ? "==" : "!="), ++ expand ? expand : s->comp.value); ++ ++ if (expand) ++ free(expand); ++ ++ return ret; ++} ++ ++static int sel_lstat(struct autofs_point *ap, ++ struct selector *s, struct substvar *sv) ++{ ++ struct stat st; ++ char *expand = NULL; ++ int res, ret; ++ ++ /* Sould be OK to fail on any error here */ ++ res = expand_selectors(ap, s->func.arg1, &expand, sv); ++ if (res) ++ ret = !lstat(expand, &st); ++ else ++ ret = !lstat(s->func.arg1, &st); ++ ++ if (s->compare == SEL_COMP_NOT) ++ ret = !ret; ++ if (ret) ++ debug(ap->logopt, MODPREFIX ++ "matched selector %s(%s)", ++ s->sel->name, expand ? expand : s->func.arg1); ++ else ++ debug(ap->logopt, MODPREFIX ++ "did not match selector %s(%s)", ++ s->sel->name, expand ? expand : s->func.arg1); ++ if (expand) ++ free(expand); ++ ++ return ret; ++} ++ ++static int sel_in_network(struct autofs_point *ap, ++ struct selector *s, struct substvar *sv) ++{ ++ char *expand = NULL; ++ int res, ret; ++ ++ res = expand_selectors(ap, s->func.arg1, &expand, sv); ++ if (!res) ++ ret = in_network(s->func.arg1); ++ else ++ ret = in_network(expand); ++ ++ if (s->compare == SEL_COMP_NOT) ++ ret = !ret; ++ if (ret) ++ debug(ap->logopt, MODPREFIX ++ "matched selector %s(%s)", ++ s->sel->name, expand ? expand : s->func.arg1); ++ else ++ debug(ap->logopt, MODPREFIX ++ "did not match selector %s(%s)", ++ s->sel->name, expand ? expand : s->func.arg1); ++ ++ if (expand) ++ free(expand); ++ ++ return ret; ++} ++ ++static int sel_netgrp(struct autofs_point *ap, ++ struct selector *s, struct substvar *sv) ++{ ++ char *exp_arg1 = NULL, *exp_arg2 = NULL; ++ const struct substvar *v; ++ int res, ret = 0; ++ char *host; ++ ++ if (s->func.arg2) { ++ res = expand_selectors(ap, s->func.arg2, &exp_arg2, sv); ++ if (res) ++ host = exp_arg2; ++ else ++ host = s->func.arg2; ++ } else { ++ if (s->sel->selector == SEL_NETGRP) ++ v = macro_findvar(sv, "host", 4); ++ else ++ v = macro_findvar(sv, "hostd", 5); ++ if (!v || !*v->val) { ++ error(ap->logopt, MODPREFIX ++ "failed to get value of ${host}"); ++ goto out; ++ } ++ host = v->val; ++ } ++ ++ res = expand_selectors(ap, s->func.arg1, &exp_arg1, sv); ++ if (res) ++ ret = innetgr(exp_arg1, host, NULL, NULL); ++ else ++ ret = innetgr(s->func.arg1, host, NULL, NULL); ++ ++ if (s->compare == SEL_COMP_NOT) ++ ret = !ret; ++ if (ret) { ++ if (!s->func.arg2) ++ debug(ap->logopt, MODPREFIX ++ "matched selector %s(%s)", ++ s->sel->name, exp_arg1 ? exp_arg1 : s->func.arg1); ++ else ++ debug(ap->logopt, MODPREFIX ++ "matched selector %s(%s,%s)", s->sel->name, ++ exp_arg1 ? exp_arg1 : s->func.arg1, ++ exp_arg2 ? exp_arg2 : s->func.arg2); ++ } else { ++ if (!s->func.arg2) ++ debug(ap->logopt, MODPREFIX ++ "did not match selector %s(%s)", ++ s->sel->name, exp_arg1 ? exp_arg1 : s->func.arg1); ++ else ++ debug(ap->logopt, MODPREFIX ++ "did not match selector %s(%s,%s)", s->sel->name, ++ exp_arg1 ? exp_arg1 : s->func.arg1, ++ exp_arg2 ? exp_arg2 : s->func.arg2); ++ } ++out: ++ if (exp_arg1) ++ free(exp_arg1); ++ if (exp_arg2) ++ free(exp_arg2); ++ ++ return ret; ++} ++ ++static int eval_selector(struct autofs_point *ap, + struct amd_entry *this, struct substvar *sv) + { + struct selector *s = this->selector; ++ unsigned int logopt = ap->logopt; + const struct substvar *v; + unsigned int s_type; + unsigned int v_type; +- struct stat st; +- char *host; + int res, val, ret = 0; + + s_type = s->sel->flags & SEL_FLAGS_TYPE_MASK; +@@ -339,26 +513,7 @@ static int eval_selector(unsigned int lo + + switch (v_type) { + case SEL_FLAG_STR: +- res = strcmp(v->val, s->comp.value); +- if (s->compare & SEL_COMP_EQUAL && !res) { +- debug(logopt, MODPREFIX +- "matched selector %s(%s) == %s", +- v->def, v->val, s->comp.value); +- ret = 1; +- break; +- } else if (s->compare & SEL_COMP_NOTEQUAL && res) { +- debug(logopt, MODPREFIX +- "matched selector %s(%s) != %s", +- v->def, v->val, s->comp.value); +- ret = 1; +- break; +- } +- +- debug(logopt, MODPREFIX +- "did not match selector %s(%s) %s %s", +- v->def, v->val, +- (s->compare & SEL_COMP_EQUAL ? "==" : "!="), +- s->comp.value); ++ ret = sel_strcmp(ap, v, s, sv); + break; + + case SEL_FLAG_NUM: +@@ -434,7 +589,7 @@ static int eval_selector(unsigned int lo + break; + + case SEL_XHOST: +- ret = match_my_name(logopt, s->func.arg1, sv); ++ ret = match_my_name(ap, s->func.arg1, sv); + if (s->compare == SEL_COMP_NOT) + ret = !ret; + if (ret) +@@ -448,32 +603,11 @@ static int eval_selector(unsigned int lo + break; + + case SEL_EXISTS: +- /* Sould be OK to fail on any error here */ +- ret = !lstat(s->func.arg1, &st); +- if (s->compare == SEL_COMP_NOT) +- ret = !ret; +- if (ret) +- debug(logopt, MODPREFIX +- "matched selector %s(%s)", +- s->sel->name, s->func.arg1); +- else +- debug(logopt, MODPREFIX +- "did not match selector %s(%s)", +- s->sel->name, s->func.arg1); ++ ret = sel_lstat(ap, s, sv); + break; + + case SEL_IN_NETWORK: +- ret = in_network(s->func.arg1); +- if (s->compare == SEL_COMP_NOT) +- ret = !ret; +- if (ret) +- debug(logopt, MODPREFIX +- "matched selector %s(%s)", +- s->sel->name, s->func.arg1); +- else +- debug(logopt, MODPREFIX +- "did not match selector %s(%s)", +- s->sel->name, s->func.arg1); ++ ret = sel_in_network(ap, s, sv); + break; + + default: +@@ -492,43 +626,7 @@ static int eval_selector(unsigned int lo + switch (s->sel->selector) { + case SEL_NETGRP: + case SEL_NETGRPD: +- if (s->func.arg2) +- host = s->func.arg2; +- else { +- if (s->sel->selector == SEL_NETGRP) +- v = macro_findvar(sv, "host", 4); +- else +- v = macro_findvar(sv, "hostd", 5); +- if (!v || !*v->val) { +- error(logopt, MODPREFIX +- "failed to get value of ${host}"); +- break; +- } +- host = v->val; +- } +- ret = innetgr(s->func.arg1, host, NULL, NULL); +- if (s->compare == SEL_COMP_NOT) +- ret = !ret; +- if (ret) { +- if (!s->func.arg2) +- debug(logopt, MODPREFIX +- "matched selector %s(%s)", +- s->sel->name, s->func.arg1); +- else +- debug(logopt, MODPREFIX +- "matched selector %s(%s,%s)", +- s->sel->name, s->func.arg1, +- s->func.arg2); +- } else { +- if (!s->func.arg2) +- debug(logopt, MODPREFIX +- "did not match selector %s(%s)", +- s->sel->name, s->func.arg1); +- else +- debug(logopt, MODPREFIX +- "did not match selector %s(%s,%s)", +- s->sel->name, s->func.arg1, s->func.arg2); +- } ++ ret = sel_netgrp(ap, s, sv); + break; + + default: +@@ -1753,7 +1851,7 @@ static void update_prefix(struct autofs_ + return; + } + +-static int match_selectors(unsigned int logopt, ++static int match_selectors(struct autofs_point *ap, + struct amd_entry *entry, struct substvar *sv) + { + struct selector *s = entry->selector; +@@ -1761,7 +1859,7 @@ static int match_selectors(unsigned int + + /* No selectors, always match */ + if (!s) { +- debug(logopt, MODPREFIX "no selectors found in location"); ++ debug(ap->logopt, MODPREFIX "no selectors found in location"); + return 1; + } + +@@ -1769,7 +1867,7 @@ static int match_selectors(unsigned int + + /* All selectors must match */ + while (s) { +- ret = eval_selector(logopt, entry, sv); ++ ret = eval_selector(ap, entry, sv); + if (!ret) + break; + s = s->next; +@@ -1939,7 +2037,7 @@ static struct amd_entry *select_default_ + if (!this->selector) + continue; + +- if (match_selectors(ap->logopt, this, sv)) { ++ if (match_selectors(ap, this, sv)) { + if (entry_default) { + /*update_with_defaults(entry_default, this, sv);*/ + free_amd_entry(entry_default); +@@ -2192,7 +2290,7 @@ int parse_mount(struct autofs_point *ap, + break; + } + +- if (!match_selectors(ap->logopt, this, sv)) ++ if (!match_selectors(ap, this, sv)) + continue; + + at_least_one = 1; diff --git a/SOURCES/autofs-5.1.5-log-mount-call-arguments-if-mount_verbose-is-set.patch b/SOURCES/autofs-5.1.5-log-mount-call-arguments-if-mount_verbose-is-set.patch new file mode 100644 index 0000000..ee3b686 --- /dev/null +++ b/SOURCES/autofs-5.1.5-log-mount-call-arguments-if-mount_verbose-is-set.patch @@ -0,0 +1,222 @@ +autofs-5.1.5 - log mount call arguments if mount_verbose is set + +From: Lars R. Damerow + +Override the debug log only setting if mount_verbose is set so that +mount parameter information is logged on mount. + +Signed-off-by: Lars R. Damerow +Signed-off-by: Ian Kent +--- + CHANGELOG | 1 + + modules/mount_afs.c | 6 +++++- + modules/mount_bind.c | 10 +++++++--- + modules/mount_ext2.c | 16 ++++++++++------ + modules/mount_generic.c | 14 +++++++++----- + modules/mount_nfs.c | 29 +++++++++++++++++------------ + 6 files changed, 49 insertions(+), 27 deletions(-) + +--- autofs-5.1.4.orig/CHANGELOG ++++ autofs-5.1.4/CHANGELOG +@@ -49,6 +49,7 @@ xx/xx/2018 autofs-5.1.5 + - use malloc(3) in spawn.c. + - add mount_verbose configuration option. + - optionally log mount requestor process info. ++- log mount call arguments if mount_verbose is set. + + 19/12/2017 autofs-5.1.4 + - fix spec file url. +--- autofs-5.1.4.orig/modules/mount_afs.c ++++ autofs-5.1.4/modules/mount_afs.c +@@ -37,10 +37,14 @@ int mount_mount(struct autofs_point *ap, + char dest[PATH_MAX + 1]; + size_t r_len = strlen(root); + size_t d_len = r_len + name_len + 2; ++ void (*mountlog)(unsigned int, const char*, ...) = &log_debug; + + if (ap->flags & MOUNT_FLAG_REMOUNT) + return 0; + ++ if (defaults_get_mount_verbose()) ++ mountlog = &log_info; ++ + if (d_len > PATH_MAX) + return 1; + +@@ -53,7 +57,7 @@ int mount_mount(struct autofs_point *ap, + if (dest[strlen(dest)-1] == '/') + dest[strlen(dest)-1] = '\0'; + +- debug(ap->logopt, MODPREFIX "mounting AFS %s -> %s", dest, what); ++ mountlog(ap->logopt, MODPREFIX "mounting AFS %s -> %s", dest, what); + + return symlink(what, dest); /* Try it. If it fails, return the error. */ + } +--- autofs-5.1.4.orig/modules/mount_bind.c ++++ autofs-5.1.4/modules/mount_bind.c +@@ -81,10 +81,14 @@ int mount_mount(struct autofs_point *ap, + int err; + int i, len; + int symlnk = (*name != '/' && (ap->flags & MOUNT_FLAG_SYMLINK)); ++ void (*mountlog)(unsigned int, const char*, ...) = &log_debug; + + if (ap->flags & MOUNT_FLAG_REMOUNT) + return 0; + ++ if (defaults_get_mount_verbose()) ++ mountlog = &log_info; ++ + /* Extract "symlink" pseudo-option which forces local filesystems + * to be symlinked instead of bound. + */ +@@ -164,9 +168,9 @@ int mount_mount(struct autofs_point *ap, + if (!status) + existed = 0; + +- debug(ap->logopt, MODPREFIX +- "calling mount --bind -o %s %s %s", +- options, what, fullpath); ++ mountlog(ap->logopt, MODPREFIX ++ "calling mount --bind -o %s %s %s", ++ options, what, fullpath); + + err = spawn_bind_mount(ap->logopt, "-o", + options, what, fullpath, NULL); +--- autofs-5.1.4.orig/modules/mount_ext2.c ++++ autofs-5.1.4/modules/mount_ext2.c +@@ -47,10 +47,14 @@ int mount_mount(struct autofs_point *ap, + int err, ro = 0; + const char *fsck_prog; + int len, status, existed = 1; ++ void (*mountlog)(unsigned int, const char*, ...) = &log_debug; + + if (ap->flags & MOUNT_FLAG_REMOUNT) + return 0; + ++ if (defaults_get_mount_verbose()) ++ mountlog = &log_info; ++ + /* Root offset of multi-mount */ + len = strlen(root); + if (root[len - 1] == '/') { +@@ -121,15 +125,15 @@ int mount_mount(struct autofs_point *ap, + } + + if (options) { +- debug(ap->logopt, MODPREFIX +- "calling mount -t %s -o %s %s %s", +- fstype, options, what, fullpath); ++ mountlog(ap->logopt, MODPREFIX ++ "calling mount -t %s -o %s %s %s", ++ fstype, options, what, fullpath); + err = spawn_mount(ap->logopt, "-t", fstype, + "-o", options, what, fullpath, NULL); + } else { +- debug(ap->logopt, +- MODPREFIX "calling mount -t %s %s %s", +- fstype, what, fullpath); ++ mountlog(ap->logopt, ++ MODPREFIX "calling mount -t %s %s %s", ++ fstype, what, fullpath); + err = spawn_mount(ap->logopt, "-t", fstype, what, fullpath, NULL); + } + +--- autofs-5.1.4.orig/modules/mount_generic.c ++++ autofs-5.1.4/modules/mount_generic.c +@@ -46,10 +46,14 @@ int mount_mount(struct autofs_point *ap, + char buf[MAX_ERR_BUF]; + int err; + int len, status, existed = 1; ++ void (*mountlog)(unsigned int, const char*, ...) = &log_debug; + + if (ap->flags & MOUNT_FLAG_REMOUNT) + return 0; + ++ if (defaults_get_mount_verbose()) ++ mountlog = &log_info; ++ + /* Root offset of multi-mount */ + len = strlen(root); + if (root[len - 1] == '/') { +@@ -80,15 +84,15 @@ int mount_mount(struct autofs_point *ap, + existed = 0; + + if (options && options[0]) { +- debug(ap->logopt, +- MODPREFIX "calling mount -t %s -o %s %s %s", +- fstype, options, what, fullpath); ++ mountlog(ap->logopt, ++ MODPREFIX "calling mount -t %s -o %s %s %s", ++ fstype, options, what, fullpath); + + err = spawn_mount(ap->logopt, "-t", fstype, + "-o", options, what, fullpath, NULL); + } else { +- debug(ap->logopt, MODPREFIX "calling mount -t %s %s %s", +- fstype, what, fullpath); ++ mountlog(ap->logopt, MODPREFIX "calling mount -t %s %s %s", ++ fstype, what, fullpath); + err = spawn_mount(ap->logopt, "-t", fstype, what, fullpath, NULL); + } + +--- autofs-5.1.4.orig/modules/mount_nfs.c ++++ autofs-5.1.4/modules/mount_nfs.c +@@ -77,13 +77,17 @@ int mount_mount(struct autofs_point *ap, + int port = -1; + int ro = 0; /* Set if mount bind should be read-only */ + int rdma = 0; ++ void (*mountlog)(unsigned int, const char*, ...) = &log_debug; + + if (ap->flags & MOUNT_FLAG_REMOUNT) + return 0; + +- debug(ap->logopt, +- MODPREFIX "root=%s name=%s what=%s, fstype=%s, options=%s", +- root, name, what, fstype, options); ++ if (defaults_get_mount_verbose()) ++ mountlog = &log_info; ++ ++ mountlog(ap->logopt, ++ MODPREFIX "root=%s name=%s what=%s, fstype=%s, options=%s", ++ root, name, what, fstype, options); + + mount_default_proto = defaults_get_mount_nfs_default_proto(); + vers = NFS_VERS_DEFAULT | NFS_PROTO_DEFAULT; +@@ -203,9 +207,9 @@ int mount_mount(struct autofs_point *ap, + if ((vers & NFS_PROTO_MASK) == 0) + vers |= NFS_PROTO_MASK; + +- debug(ap->logopt, MODPREFIX +- "nfs options=\"%s\", nobind=%d, nosymlink=%d, ro=%d", +- nfsoptions, nobind, nosymlink, ro); ++ mountlog(ap->logopt, MODPREFIX ++ "nfs options=\"%s\", nobind=%d, nosymlink=%d, ro=%d", ++ nfsoptions, nobind, nosymlink, ro); + } + + if (!parse_location(ap->logopt, &hosts, what, flags)) { +@@ -379,17 +383,18 @@ dont_probe: + } + + if (nfsoptions && *nfsoptions) { +- debug(ap->logopt, +- MODPREFIX "calling mount -t %s " SLOPPY +- "-o %s %s %s", fstype, nfsoptions, loc, fullpath); ++ mountlog(ap->logopt, ++ MODPREFIX "calling mount -t %s " SLOPPY ++ "-o %s %s %s", fstype, nfsoptions, loc, ++ fullpath); + + err = spawn_mount(ap->logopt, + "-t", fstype, SLOPPYOPT "-o", + nfsoptions, loc, fullpath, NULL); + } else { +- debug(ap->logopt, +- MODPREFIX "calling mount -t %s %s %s", +- fstype, loc, fullpath); ++ mountlog(ap->logopt, ++ MODPREFIX "calling mount -t %s %s %s", ++ fstype, loc, fullpath); + err = spawn_mount(ap->logopt, + "-t", fstype, loc, fullpath, NULL); + } diff --git a/SOURCES/autofs-5.1.5-make-expire-remaining-log-level-debug.patch b/SOURCES/autofs-5.1.5-make-expire-remaining-log-level-debug.patch new file mode 100644 index 0000000..4d115ea --- /dev/null +++ b/SOURCES/autofs-5.1.5-make-expire-remaining-log-level-debug.patch @@ -0,0 +1,55 @@ +autofs-5.1.5 - make expire remaining log level debug + +From: Ian Kent + +The log message listing the remaining mounts should be log level +debug not info. + +Signed-off-by: Ian Kent +--- + CHANGELOG | 1 + + daemon/direct.c | 2 +- + daemon/indirect.c | 4 ++-- + 3 files changed, 4 insertions(+), 3 deletions(-) + +--- autofs-5.1.4.orig/CHANGELOG ++++ autofs-5.1.4/CHANGELOG +@@ -50,6 +50,7 @@ xx/xx/2018 autofs-5.1.5 + - add mount_verbose configuration option. + - optionally log mount requestor process info. + - log mount call arguments if mount_verbose is set. ++- make expire remaining log level debug. + + 19/12/2017 autofs-5.1.4 + - fix spec file url. +--- autofs-5.1.4.orig/daemon/direct.c ++++ autofs-5.1.4/daemon/direct.c +@@ -990,7 +990,7 @@ void *expire_proc_direct(void *arg) + pthread_cleanup_pop(1); + + if (left) +- info(ap->logopt, "%d remaining in %s", left, ap->path); ++ debug(ap->logopt, "%d remaining in %s", left, ap->path); + + ec.status = left; + +--- autofs-5.1.4.orig/daemon/indirect.c ++++ autofs-5.1.4/daemon/indirect.c +@@ -578,7 +578,7 @@ void *expire_proc_indirect(void *arg) + pthread_cleanup_pop(1); + + if (submnts) +- info(ap->logopt, ++ debug(ap->logopt, + "%d submounts remaining in %s", submnts, ap->path); + + /* +@@ -586,7 +586,7 @@ void *expire_proc_indirect(void *arg) + * words) the umounts are done by the time we reach here + */ + if (count) +- info(ap->logopt, "%d remaining in %s", count, ap->path); ++ debug(ap->logopt, "%d remaining in %s", count, ap->path); + + ec.status = left; + diff --git a/SOURCES/autofs-5.1.5-optionally-log-mount-requestor-process-info.patch b/SOURCES/autofs-5.1.5-optionally-log-mount-requestor-process-info.patch new file mode 100644 index 0000000..d731970 --- /dev/null +++ b/SOURCES/autofs-5.1.5-optionally-log-mount-requestor-process-info.patch @@ -0,0 +1,155 @@ +autofs-5.1.5 - optionally log mount requestor process info + +From: Lars R. Damerow + +This information can be helpful to determine who or what is making +particular mount requests, especially when used in conjunction with +the use_mount_request_log_id option. + +Signed-off-by: Lars R. Damerow +Signed-off-by: Ian Kent +--- + CHANGELOG | 1 + + daemon/direct.c | 6 ++++++ + daemon/indirect.c | 6 ++++++ + include/log.h | 2 ++ + lib/log.c | 39 +++++++++++++++++++++++++++++++++++++++ + man/autofs.conf.5.in | 3 ++- + redhat/autofs.conf.default.in | 4 +++- + samples/autofs.conf.default.in | 4 +++- + 8 files changed, 62 insertions(+), 3 deletions(-) + +--- autofs-5.1.4.orig/CHANGELOG ++++ autofs-5.1.4/CHANGELOG +@@ -48,6 +48,7 @@ xx/xx/2018 autofs-5.1.5 + - add NULL check for get_addr_string() return. + - use malloc(3) in spawn.c. + - add mount_verbose configuration option. ++- optionally log mount requestor process info. + + 19/12/2017 autofs-5.1.4 + - fix spec file url. +--- autofs-5.1.4.orig/daemon/direct.c ++++ autofs-5.1.4/daemon/direct.c +@@ -1242,6 +1242,12 @@ static void *do_mount_direct(void *arg) + + pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &state); + ++ if (defaults_get_mount_verbose()) { ++ pid_t ppid = log_pidinfo(ap, mt.pid, "requestor"); ++ if (ppid > 0) ++ log_pidinfo(ap, ppid, "parent"); ++ } ++ + status = fstat(mt.ioctlfd, &st); + if (status == -1) { + error(ap->logopt, +--- autofs-5.1.4.orig/daemon/indirect.c ++++ autofs-5.1.4/daemon/indirect.c +@@ -758,6 +758,12 @@ static void *do_mount_indirect(void *arg + + pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &state); + ++ if (defaults_get_mount_verbose()) { ++ pid_t ppid = log_pidinfo(ap, mt.pid, "requestor"); ++ if (ppid > 0) ++ log_pidinfo(ap, ppid, "parent"); ++ } ++ + len = ncat_path(buf, sizeof(buf), ap->path, mt.name, mt.len); + if (!len) { + crit(ap->logopt, "path to be mounted is to long"); +--- autofs-5.1.4.orig/include/log.h ++++ autofs-5.1.4/include/log.h +@@ -46,6 +46,8 @@ extern void log_crit(unsigned, const cha + extern void log_debug(unsigned int, const char* msg, ...); + extern void logmsg(const char* msg, ...); + ++extern pid_t log_pidinfo(struct autofs_point *ap, pid_t pid, char *label); ++ + #define debug(opt, msg, args...) \ + do { log_debug(opt, "%s: " msg, __FUNCTION__, ##args); } while (0) + +--- autofs-5.1.4.orig/lib/log.c ++++ autofs-5.1.4/lib/log.c +@@ -325,3 +325,42 @@ void log_to_stderr(void) + + return; + } ++ ++pid_t log_pidinfo(struct autofs_point *ap, pid_t pid, char *label) { ++ char buf[PATH_MAX + 1] = ""; ++ FILE *statfile; ++ ++ pid_t tgid, ppid; ++ int uid, euid, gid, egid; ++ char comm[64] = ""; ++ ++ sprintf(buf, "/proc/%d/status", pid); ++ statfile = fopen(buf, "r"); ++ if (statfile == NULL) { ++ info(ap->logopt, "pidinfo %s: failed to open %s", label, buf); ++ return -1; ++ } ++ ++ while (fgets(buf, sizeof(buf), statfile) != NULL) { ++ if (strncmp(buf, "Name:", 5) == 0) { ++ sscanf(buf, "Name:\t%s", (char *) &comm); ++ } else if (strncmp(buf, "Tgid:", 5) == 0) { ++ sscanf(buf, "Tgid:\t%d", (int *) &tgid); ++ } else if (strncmp(buf, "PPid:", 5) == 0) { ++ sscanf(buf, "PPid:\t%d", (int *) &ppid); ++ } else if (strncmp(buf, "Uid:", 4) == 0) { ++ sscanf(buf, ++ "Uid:\t%d\t%d", (int *) &uid, (int *) &euid); ++ } else if (strncmp(buf, "Gid:", 4) == 0) { ++ sscanf(buf, ++ "Gid:\t%d\t%d", (int *) &gid, (int *) &egid); ++ } ++ } ++ fclose(statfile); ++ ++ info(ap->logopt, ++ "pidinfo %s: pid:%d comm:%s tgid:%d uid:%d euid:%d gid:%d egid:%d", ++ label, pid, comm, tgid, uid, euid, gid, egid); ++ ++ return ppid; ++} +--- autofs-5.1.4.orig/man/autofs.conf.5.in ++++ autofs-5.1.4/man/autofs.conf.5.in +@@ -43,7 +43,8 @@ setting. + .TP + .B mount_verbose + .br +-Use the verbose flag when spawning mount(8) (program default "no"). ++Use the verbose flag when spawning mount(8), and log some process info ++about the requestor and its parent (program default "no"). + .TP + .B mount_wait + .br +--- autofs-5.1.4.orig/redhat/autofs.conf.default.in ++++ autofs-5.1.4/redhat/autofs.conf.default.in +@@ -26,7 +26,9 @@ timeout = 300 + # + #negative_timeout = 60 + # +-# mount_verbose - use the -v flag when calling mount(8). ++# mount_verbose - use the -v flag when calling mount(8) and log some ++# process information about the requestor and its ++# parent. + # + #mount_verbose = no + # +--- autofs-5.1.4.orig/samples/autofs.conf.default.in ++++ autofs-5.1.4/samples/autofs.conf.default.in +@@ -26,7 +26,9 @@ timeout = 300 + # + #negative_timeout = 60 + # +-# mount_verbose - use the -v flag when calling mount(8). ++# mount_verbose - use the -v flag when calling mount(8) and log some ++# process information about the requestor and its ++# parent. + # + #mount_verbose = no + # diff --git a/SOURCES/autofs-5.1.5-use-malloc-in-spawn_c.patch b/SOURCES/autofs-5.1.5-use-malloc-in-spawn_c.patch new file mode 100644 index 0000000..72634af --- /dev/null +++ b/SOURCES/autofs-5.1.5-use-malloc-in-spawn_c.patch @@ -0,0 +1,161 @@ +autofs-5.1.5 - use malloc(3) in spawn.c + +From: Ian Kent + +Use malloc(3) in spawn.c functions instead of alloca(3) as a failure +return for this function is undefined. + +Signed-off-by: Ian Kent +--- + CHANGELOG | 1 + + daemon/spawn.c | 50 ++++++++++++++++++++++++++++++++++++++++++++------ + 2 files changed, 45 insertions(+), 6 deletions(-) + +--- autofs-5.1.4.orig/CHANGELOG ++++ autofs-5.1.4/CHANGELOG +@@ -46,6 +46,7 @@ xx/xx/2018 autofs-5.1.5 + - add systemd service command line option. + - support strictexpire mount option. + - add NULL check for get_addr_string() return. ++- use malloc(3) in spawn.c. + + 19/12/2017 autofs-5.1.4 + - fix spec file url. +--- autofs-5.1.4.orig/daemon/spawn.c ++++ autofs-5.1.4/daemon/spawn.c +@@ -521,22 +521,33 @@ int spawnv(unsigned logopt, const char * + int spawnl(unsigned logopt, const char *prog, ...) + { + va_list arg; +- int argc; ++ int argc, ret; + char **argv, **p; ++ unsigned int argv_len; + + va_start(arg, prog); + for (argc = 1; va_arg(arg, char *); argc++); + va_end(arg); + +- if (!(argv = alloca(sizeof(char *) * argc))) ++ argv_len = sizeof(char *) * (argc + 1); ++ argv = malloc(argv_len); ++ if (!argv) { ++ char buf[MAX_ERR_BUF]; ++ char *estr = strerror_r(errno, buf, sizeof(buf)); ++ crit(logopt, "malloc: %s", estr); + return -1; ++ } ++ memset(argv, 0, argv_len); + + va_start(arg, prog); + p = argv; + while ((*p++ = va_arg(arg, char *))); + va_end(arg); + +- return do_spawn(logopt, -1, SPAWN_OPT_NONE, prog, (const char **) argv); ++ ret = do_spawn(logopt, -1, SPAWN_OPT_NONE, prog, (const char **) argv); ++ free(argv); ++ ++ return ret; + } + + int spawn_mount(unsigned logopt, ...) +@@ -554,6 +565,7 @@ int spawn_mount(unsigned logopt, ...) + int update_mtab = 1, ret, printed = 0; + unsigned int wait = defaults_get_mount_wait(); + char buf[PATH_MAX + 1]; ++ unsigned int argv_len; + + /* If we use mount locking we can't validate the location */ + #ifdef ENABLE_MOUNT_LOCKING +@@ -579,8 +591,15 @@ int spawn_mount(unsigned logopt, ...) + } + + /* Alloc 1 extra slot in case we need to use the "-f" option */ +- if (!(argv = alloca(sizeof(char *) * (argc + 2)))) ++ argv_len = sizeof(char *) * (argc + 2); ++ argv = malloc(argv_len); ++ if (!argv) { ++ char buf[MAX_ERR_BUF]; ++ char *estr = strerror_r(errno, buf, sizeof(buf)); ++ crit(logopt, "malloc: %s", estr); + return -1; ++ } ++ memset(argv, 0, argv_len); + + argv[0] = arg0; + +@@ -655,6 +674,7 @@ int spawn_mount(unsigned logopt, ...) + umount(argv[argc]); + ret = MNT_FORCE_FAIL; + } ++ free(argv); + + return ret; + } +@@ -683,6 +703,7 @@ int spawn_bind_mount(unsigned logopt, .. + int update_mtab = 1, ret, printed = 0; + unsigned int wait = defaults_get_mount_wait(); + char buf[PATH_MAX + 1]; ++ unsigned int argv_len; + + /* If we use mount locking we can't validate the location */ + #ifdef ENABLE_MOUNT_LOCKING +@@ -711,8 +732,15 @@ int spawn_bind_mount(unsigned logopt, .. + } + } + +- if (!(argv = alloca(sizeof(char *) * (argc + 2)))) ++ argv_len = sizeof(char *) * (argc + 2); ++ argv = malloc(argv_len); ++ if (!argv) { ++ char buf[MAX_ERR_BUF]; ++ char *estr = strerror_r(errno, buf, sizeof(buf)); ++ crit(logopt, "malloc: %s", estr); + return -1; ++ } ++ memset(argv, 0, argv_len); + + argv[0] = arg0; + argv[1] = bind; +@@ -774,6 +802,7 @@ int spawn_bind_mount(unsigned logopt, .. + umount(argv[argc]); + ret = MNT_FORCE_FAIL; + } ++ free(argv); + + return ret; + } +@@ -796,6 +825,7 @@ int spawn_umount(unsigned logopt, ...) + int update_mtab = 1, ret, printed = 0; + unsigned int wait = defaults_get_umount_wait(); + char buf[PATH_MAX + 1]; ++ unsigned int argv_len; + + #ifdef ENABLE_MOUNT_LOCKING + options = SPAWN_OPT_LOCK; +@@ -821,8 +851,15 @@ int spawn_umount(unsigned logopt, ...) + if (arg_c) + argc++;; + +- if (!(argv = alloca(sizeof(char *) * (argc + 1)))) ++ argv_len = sizeof(char *) * (argc + 1); ++ argv = malloc(argv_len); ++ if (!argv) { ++ char buf[MAX_ERR_BUF]; ++ char *estr = strerror_r(errno, buf, sizeof(buf)); ++ crit(logopt, "malloc: %s", estr); + return -1; ++ } ++ memset(argv, 0, argv_len); + + p = argv; + *p++ = arg0; +@@ -870,6 +907,7 @@ int spawn_umount(unsigned logopt, ...) + "and /etc/mtab will differ"); + ret = 0; + } ++ free(argv); + + return ret; + } diff --git a/SPECS/autofs.spec b/SPECS/autofs.spec index 2ce1c39..389fd3d 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.1.4 -Release: 29%{?dist} +Release: 35%{?dist} Epoch: 1 License: GPLv2+ Group: System Environment/Daemons @@ -53,6 +53,22 @@ Patch37: autofs-5.1.4-fix-amd-parser-opts-option-handling.patch Patch38: autofs-5.1.4-better-handle-hesiod-support-not-built-in.patch Patch39: autofs-5.1.5-fix-hesiod-string-check-in-master_parse.patch +Patch40: autofs-5.1.4-remove-autofs4-module-load-code.patch +Patch41: autofs-5.1.4-add-NULL-check-in-prepare_attempt_prefix.patch +Patch42: autofs-5.1.4-update-build-info-with-systemd.patch +Patch43: autofs-5.1.4-use-flags-for-startup-boolean-options.patch +Patch44: autofs-5.1.4-move-close-stdio-descriptors-to-become_daemon.patch +Patch45: autofs-5.1.4-add-systemd-service-command-line-option.patch +Patch46: autofs-5.1.5-add-strictexpire-mount-option.patch +Patch47: autofs-5.1.5-add-NULL-check-for-get_addr_string-return.patch +Patch48: autofs-5.1.5-use-malloc-in-spawn_c.patch +Patch49: autofs-5.1.5-add-mount_verbose-configuration-option.patch +Patch50: autofs-5.1.5-optionally-log-mount-requestor-process-info.patch +Patch51: autofs-5.1.5-log-mount-call-arguments-if-mount_verbose-is-set.patch +Patch52: autofs-5.1.5-make-expire-remaining-log-level-debug.patch +Patch53: autofs-5.1.5-allow-period-following-macro-in-selector-value.patch +Patch54: autofs-5.1.5-fix-macro-expansion-in-selector-values.patch + %if %{with_systemd} BuildRequires: systemd-units BuildRequires: systemd-devel @@ -152,6 +168,22 @@ echo %{version}-%{release} > .version %patch38 -p1 %patch39 -p1 +%patch40 -p1 +%patch41 -p1 +%patch42 -p1 +%patch43 -p1 +%patch44 -p1 +%patch45 -p1 +%patch46 -p1 +%patch47 -p1 +%patch48 -p1 +%patch49 -p1 +%patch50 -p1 +%patch51 -p1 +%patch52 -p1 +%patch53 -p1 +%patch54 -p1 + %build LDFLAGS=-Wl,-z,now %configure --disable-mount-locking --enable-ignore-busy --with-libtirpc --without-hesiod %{?systemd_configure_arg:} @@ -245,6 +277,49 @@ fi %dir /etc/auto.master.d %changelog +* Thu Jun 13 2019 Ian Kent - 5.1.4-35 +- bz1681956 - autofs changes blocked until gating tests are added + - correct test name in gating.yaml. +- Related: rhbz#1681956 + +* Thu Jun 13 2019 Ian Kent - 5.1.4-34 +- bz1681956 - autofs changes blocked until gating tests are added + - add gating.yaml for manual gate testing. +- Related: rhbz#1681956 + +* Tue May 21 2019 Ian Kent - 5.1.4-33 +- bz1689466 - Sanitize autofs logging + - make expire remaining log level debug. +- bz1685805 - autofs doesn't expand macros in amd map selectors + - allow period following macro in selector value. + - fix macro expansion in selector values. +- Resolves: rhbz#1689466 rhbz#1685805 + +* Mon Apr 29 2019 Ian Kent - 5.1.4-32 +- bz1703876 - [RFE] Enable additional logging information for autofs + - add NULL check for get_addr_string() return. + - use malloc(3) in spawn.c. + - add mount_verbose configuration option. + - optionally log mount requestor process info. + - log mount call arguments if mount_verbose is set. +- Resolves: rhbz#1703876 + +* Mon Apr 29 2019 Ian Kent - 5.1.4-31 +- bz1689467 - path_resolution on an autofs managed path resets the timer. Can + this be made configurable? + - support strictexpire mount option. +- Resolves: rhbz#1689467 + +* Tue Apr 23 2019 Ian Kent - 5.1.4-30 +- bz1689469 - [autofs] The log no longer print PID of automount process + - remove autofs4 module load code. + - add NULL check in prepare_attempt_prefix(). + - update build info with systemd. + - use flags for startup boolean options. + - move close stdio descriptors to become_daemon(). + - add systemd service command line option. +- Resolves: rhbz#1689469 + * Mon Dec 03 2018 Ian Kent - 5.1.4-29 - bz1654541 - autofs crash when parsing master map - fix hesiod string check in master_parse().