Browse Source

- autofs: add latest patches from upstream

master
vanhofen 6 years ago
parent
commit
c4b87586d3
  1. 38
      archive-patches/autofs-5.1.4/autofs-5.1.4-add-NULL-check-in-prepare_attempt_prefix.patch
  2. 191
      archive-patches/autofs-5.1.4/autofs-5.1.4-add-master-map-pseudo-options-for-mount-propagation.patch
  3. 147
      archive-patches/autofs-5.1.4/autofs-5.1.4-add-systemd-service-command-line-option.patch
  4. 138
      archive-patches/autofs-5.1.4/autofs-5.1.4-better-handle-hesiod-support-not-built-in.patch
  5. 46
      archive-patches/autofs-5.1.4/autofs-5.1.4-fix-age-setting-at-startup.patch
  6. 72
      archive-patches/autofs-5.1.4/autofs-5.1.4-fix-amd-parser-opts-option-handling.patch
  7. 44
      archive-patches/autofs-5.1.4/autofs-5.1.4-fix-incorrect-locking-in-sss-lookup.patch
  8. 39
      archive-patches/autofs-5.1.4/autofs-5.1.4-fix-indent-in-automount-8-man-page.patch
  9. 38
      archive-patches/autofs-5.1.4/autofs-5.1.4-fix-possible-NULL-pointer-access-in-get_defaults_entry.patch
  10. 44
      archive-patches/autofs-5.1.4/autofs-5.1.4-fix-program-usage-message.patch
  11. 102
      archive-patches/autofs-5.1.4/autofs-5.1.4-fix-update_negative_cache-map-source-usage.patch
  12. 38
      archive-patches/autofs-5.1.4/autofs-5.1.4-fix-use-after-free-in-parse_ldap_config.patch
  13. 68
      archive-patches/autofs-5.1.4/autofs-5.1.4-mark-removed-cache-entry-negative.patch
  14. 125
      archive-patches/autofs-5.1.4/autofs-5.1.4-move-close-stdio-descriptors-to-become_daemon.patch
  15. 359
      archive-patches/autofs-5.1.4/autofs-5.1.4-refactor-negative-map-entry-check.patch
  16. 236
      archive-patches/autofs-5.1.4/autofs-5.1.4-remove-autofs4-module-load-code.patch
  17. 38
      archive-patches/autofs-5.1.4/autofs-5.1.4-remove-couple-of-undeeded-requires.patch
  18. 41
      archive-patches/autofs-5.1.4/autofs-5.1.4-remove-unused-function-dump_master.patch
  19. 57
      archive-patches/autofs-5.1.4/autofs-5.1.4-remove-unused-function-dump_state_queue.patch
  20. 73
      archive-patches/autofs-5.1.4/autofs-5.1.4-set-bind-mount-as-propagation-slave.patch
  21. 45
      archive-patches/autofs-5.1.4/autofs-5.1.4-update-build-info-with-systemd.patch
  22. 225
      archive-patches/autofs-5.1.4/autofs-5.1.4-use-flags-for-startup-boolean-options.patch
  23. 22
      archive-patches/autofs-5.1.4/patch_order-5.1.4

38
archive-patches/autofs-5.1.4/autofs-5.1.4-add-NULL-check-in-prepare_attempt_prefix.patch

@ -0,0 +1,38 @@
autofs-5.1.4 - add NULL check in prepare_attempt_prefix()
From: Ian Kent <raven@themaw.net>
prepare_attempt_prefix() calls calloc(3) and continues without
checking if the allocation succeeded.
Signed-off-by: Ian Kent <raven@themaw.net>
---
CHANGELOG | 1 +
lib/log.c | 2 ++
2 files changed, 3 insertions(+)
diff --git a/CHANGELOG b/CHANGELOG
index 0a56df5a..ad9932a2 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -43,6 +43,7 @@ xx/xx/2018 autofs-5.1.5
- better handle hesiod support not built in.
- fix indent in automount(8) man page.
- remove autofs4 module load code.
+- add NULL check in prepare_attempt_prefix().
19/12/2017 autofs-5.1.4
- fix spec file url.
diff --git a/lib/log.c b/lib/log.c
index f6ab77c1..41f95fe8 100644
--- a/lib/log.c
+++ b/lib/log.c
@@ -44,6 +44,8 @@ static char *prepare_attempt_prefix(const char *msg)
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);

191
archive-patches/autofs-5.1.4/autofs-5.1.4-add-master-map-pseudo-options-for-mount-propagation.patch

@ -0,0 +1,191 @@
autofs-5.1.4 - add master map pseudo options for mount propagation
From: Ian Kent <raven@themaw.net>
Add master map entry pseudo mount option of "slave" or "private" to
allow mount propagation of bind mounts to be set to either "slave" or
"private".
This option may be needed when using multi-mounts that have bind mounts
that bind to a file system that is propagation shared. This is becuase
the bind mount will have the same properties as its target which causes
problems for offset mounts. When this happens an unwanted offset mount
is propagated back to the target file system resulting in a deadlock
when attempting to access the offset.
By default bind mounts will inherit the mount propagation of the target
file system.
Signed-off-by: Ian Kent <raven@themaw.net>
---
CHANGELOG | 1 +
include/automount.h | 4 ++++
lib/master_parse.y | 13 +++++++++++++
lib/master_tok.l | 2 ++
man/auto.master.5.in | 12 ++++++++++++
modules/mount_bind.c | 30 +++++++++++++++++++-----------
6 files changed, 51 insertions(+), 11 deletions(-)
diff --git a/CHANGELOG b/CHANGELOG
index 88829564..4765a66e 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -35,6 +35,7 @@ xx/xx/2018 autofs-5.1.5
- fix program usage message.
- mark removed cache entry negative.
- set bind mount as propagation slave.
+- add master map pseudo options for mount propagation.
19/12/2017 autofs-5.1.4
- fix spec file url.
diff --git a/include/automount.h b/include/automount.h
index e5c19d23..417dacbb 100644
--- a/include/automount.h
+++ b/include/automount.h
@@ -549,6 +549,10 @@ struct kernel_mod_version {
/* Read amd map even if it's not to be ghosted (browsable) */
#define MOUNT_FLAG_AMD_CACHE_ALL 0x0080
+/* Set mount propagation for bind mounts */
+#define MOUNT_FLAG_SLAVE 0x0100
+#define MOUNT_FLAG_PRIVATE 0x0200
+
struct autofs_point {
pthread_t thid;
char *path; /* Mount point name */
diff --git a/lib/master_parse.y b/lib/master_parse.y
index 5d687a70..84ca5ca1 100644
--- a/lib/master_parse.y
+++ b/lib/master_parse.y
@@ -58,6 +58,8 @@ static char *format;
static long timeout;
static long negative_timeout;
static unsigned symlnk;
+static unsigned slave;
+static unsigned private;
static unsigned nobind;
static unsigned ghost;
extern unsigned global_selection_options;
@@ -103,6 +105,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 COLON COMMA NL DDASH
%type <strtype> map
%type <strtype> options
@@ -196,6 +199,8 @@ line:
| PATH OPT_DEBUG { master_notify($1); YYABORT; }
| PATH OPT_TIMEOUT { master_notify($1); YYABORT; }
| PATH OPT_SYMLINK { 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; }
| PATH OPT_GHOST { master_notify($1); YYABORT; }
| PATH OPT_NOGHOST { master_notify($1); YYABORT; }
@@ -600,6 +605,8 @@ option: daemon_option
daemon_option: OPT_TIMEOUT NUMBER { timeout = $2; }
| OPT_NTIMEOUT NUMBER { negative_timeout = $2; }
| OPT_SYMLINK { symlnk = 1; }
+ | OPT_SLAVE { slave = 1; }
+ | OPT_PRIVATE { private = 1; }
| OPT_NOBIND { nobind = 1; }
| OPT_NOGHOST { ghost = 0; }
| OPT_GHOST { ghost = 1; }
@@ -672,6 +679,8 @@ static void local_init_vars(void)
timeout = -1;
negative_timeout = 0;
symlnk = 0;
+ slave = 0;
+ private = 0;
nobind = 0;
ghost = defaults_get_browse_mode();
random_selection = global_selection_options & MOUNT_FLAG_RANDOM_SELECT;
@@ -878,6 +887,10 @@ int master_parse_entry(const char *buffer, unsigned int default_timeout, unsigne
entry->ap->flags |= MOUNT_FLAG_USE_WEIGHT_ONLY;
if (symlnk)
entry->ap->flags |= MOUNT_FLAG_SYMLINK;
+ if (slave)
+ entry->ap->flags |= MOUNT_FLAG_SLAVE;
+ if (private)
+ entry->ap->flags |= MOUNT_FLAG_PRIVATE;
if (negative_timeout)
entry->ap->negative_timeout = negative_timeout;
if (mode && mode < LONG_MAX)
diff --git a/lib/master_tok.l b/lib/master_tok.l
index 41ac4995..f4e940ce 100644
--- a/lib/master_tok.l
+++ b/lib/master_tok.l
@@ -389,6 +389,8 @@ MODE (--mode{OPTWS}|--mode{OPTWS}={OPTWS})
-?symlink { return(OPT_SYMLINK); }
-?nobind { return(OPT_NOBIND); }
-?nobrowse { return(OPT_NOGHOST); }
+ -?slave { return(OPT_SLAVE); }
+ -?private { return(OPT_PRIVATE); }
-g|--ghost|-?browse { return(OPT_GHOST); }
-v|--verbose { return(OPT_VERBOSE); }
-d|--debug { return(OPT_DEBUG); }
diff --git a/man/auto.master.5.in b/man/auto.master.5.in
index e9afb97f..68242d45 100644
--- a/man/auto.master.5.in
+++ b/man/auto.master.5.in
@@ -199,6 +199,18 @@ entries only, either in the master map (so it effects all map entries)
or with individual map entries. The option is ignored for direct mounts
and non-root offest mount entries.
.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
+multi-mounts that have bind mounts that bind to a file system that is
+propagation shared. This is becuase the bind mount will have the same
+properties as its target which causes problems for offset mounts. When
+this happens an unwanted offset mount is propagated back to the target
+file system resulting in a deadlock when attempting to access the offset.
+This option is a an autofs pseudo mount option that can be used in the
+master map only. By default bind mounts will inherit the mount propagation
+of the target file system.
+.TP
.I "\-r, \-\-random-multimount-selection"
Enables the use of random selection when choosing a host from a
list of replicated servers. This option is applied to this mount
diff --git a/modules/mount_bind.c b/modules/mount_bind.c
index fe1ad9b6..b64cdccc 100644
--- a/modules/mount_bind.c
+++ b/modules/mount_bind.c
@@ -186,17 +186,25 @@ int mount_mount(struct autofs_point *ap, const char *root, const char *name, int
what, fstype, fullpath);
}
- /* The bind mount has succeeded but if the target
- * mount is propagation shared propagation of child
- * mounts (autofs offset mounts for example) back to
- * the target of the bind mount must be avoided or
- * autofs trigger mounts will deadlock.
- */
- err = mount(NULL, fullpath, NULL, MS_SLAVE, NULL);
- if (err)
- warn(ap->logopt,
- "failed to set propagation type for %s",
- fullpath);
+ if (ap->flags & (MOUNT_FLAG_SLAVE | MOUNT_FLAG_PRIVATE)) {
+ int flags = MS_SLAVE;
+
+ if (ap->flags & MOUNT_FLAG_PRIVATE)
+ flags = MS_PRIVATE;
+
+ /* The bind mount has succeeded but if the target
+ * mount is propagation shared propagation of child
+ * mounts (autofs offset mounts for example) back to
+ * the target of the bind mount must be avoided or
+ * autofs trigger mounts will deadlock.
+ */
+ err = mount(NULL, fullpath, NULL, flags, NULL);
+ if (err) {
+ warn(ap->logopt,
+ "failed to set propagation for %s",
+ fullpath, root);
+ }
+ }
return 0;
} else {

147
archive-patches/autofs-5.1.4/autofs-5.1.4-add-systemd-service-command-line-option.patch

@ -0,0 +1,147 @@
autofs-5.1.4 - add systemd service command line option
From: Ian Kent <raven@themaw.net>
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 <raven@themaw.net>
---
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(-)
diff --git a/CHANGELOG b/CHANGELOG
index 4e1d9c98..21fc9ca7 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -47,6 +47,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.
diff --git a/daemon/automount.c b/daemon/automount.c
index c1360ed6..4628f20c 100644
--- a/daemon/automount.c
+++ b/daemon/automount.c
@@ -1210,13 +1210,21 @@ static void become_daemon(unsigned int flags)
}
/* 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();
diff --git a/include/automount.h b/include/automount.h
index 848fd0be..45fde53e 100644
--- a/include/automount.h
+++ b/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
diff --git a/man/automount.8 b/man/automount.8
index 68d2aaa3..9f92288e 100644
--- a/man/automount.8
+++ b/man/automount.8
@@ -57,6 +57,10 @@ Define a global macro substitution variable. Global definitions
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
diff --git a/samples/autofs.service.in b/samples/autofs.service.in
index 281d31ef..175a806d 100644
--- a/samples/autofs.service.in
+++ b/samples/autofs.service.in
@@ -6,7 +6,7 @@ Wants=network-online.target rpc-statd.service rpcbind.service
[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

138
archive-patches/autofs-5.1.4/autofs-5.1.4-better-handle-hesiod-support-not-built-in.patch

@ -0,0 +1,138 @@
autofs-5.1.4 - better handle hesiod support not built in
From: Ian Kent <raven@themaw.net>
The configure option --without-hesiod is not handled well.
If this option is given and hesiod is seen in the master
map parser or the amd map parser issue a message telling
the user hesiod support isn't built in.
Signed-off-by: Ian Kent <raven@themaw.net>
---
CHANGELOG | 1 +
lib/master_parse.y | 18 ++++++++++++++++--
modules/amd_parse.y | 7 +++++++
modules/parse_amd.c | 28 +++++++++++++++++++++++++---
4 files changed, 49 insertions(+), 5 deletions(-)
diff --git a/CHANGELOG b/CHANGELOG
index 5a317f12..8e9bd665 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -40,6 +40,7 @@ xx/xx/2018 autofs-5.1.5
- fix incorrect locking in sss lookup.
- fix amd parser opts option handling.
- fix possible NULL pointer dereference in get_defaults_entry().
+- better handle hesiod support not built in.
19/12/2017 autofs-5.1.4
- fix spec file url.
diff --git a/lib/master_parse.y b/lib/master_parse.y
index 84ca5ca1..9aa57327 100644
--- a/lib/master_parse.y
+++ b/lib/master_parse.y
@@ -171,7 +171,14 @@ line:
if ((tmp = strchr($2, ',')))
*tmp++ = '\0';
-
+#ifndef WITH_HESIOD
+ /* Map type or or map type parser is hesiod */
+ if (!strcmp($2, "hesiod") || !strcmp(tmp, "hesiod")) {
+ master_error("hesiod support not built in");
+ local_free_vars();
+ YYABORT;
+ }
+#endif
if (type)
free(type);
type = master_strdup($2);
@@ -352,7 +359,14 @@ map: PATH
if ((tmp = strchr($1, ',')))
*tmp++ = '\0';
-
+#ifndef WITH_HESIOD
+ /* Map type or or map type parser is hesiod */
+ if (!strcmp($1, "hesiod") || !strcmp(tmp, "hesiod")) {
+ master_error("hesiod support not built in");
+ local_free_vars();
+ YYABORT;
+ }
+#endif
if (type)
free(type);
if (strcmp($1, "exec"))
diff --git a/modules/amd_parse.y b/modules/amd_parse.y
index be923c2f..17fd9b20 100644
--- a/modules/amd_parse.y
+++ b/modules/amd_parse.y
@@ -574,6 +574,13 @@ static int match_map_option_map_type(char *map_option, char *type)
!strcmp(map_type, "nisplus") ||
!strcmp(map_type, "ldap") ||
!strcmp(map_type, "hesiod")) {
+#ifndef WITH_HESIOD
+ if (!strcmp(map_type, "hesiod")) {
+ amd_msg("hesiod support not built in");
+ free(map_type);
+ return 0;
+ }
+#endif
amd_set_value(&entry.map_type, map_type);
} else if (!strcmp(map_type, "exec")) {
/* autofs uses "program" for "exec" map type */
diff --git a/modules/parse_amd.c b/modules/parse_amd.c
index 7399d19e..0e48e5ce 100644
--- a/modules/parse_amd.c
+++ b/modules/parse_amd.c
@@ -1871,15 +1871,25 @@ struct amd_entry *make_default_entry(struct autofs_point *ap,
if (amd_parse_list(ap, defaults, &dflts, &sv))
return NULL;
defaults_entry = list_entry(dflts.next, struct amd_entry, list);
- list_del_init(&defaults_entry->list);
/*
* If map type isn't given try to inherit from
* parent. A NULL map type is valid and means
* use configured nss sources.
*/
map_type = conf_amd_get_map_type(ap->path);
- if (map_type)
+ if (map_type) {
defaults_entry->map_type = map_type;
+#ifndef HAVE_HESIOD
+ if (!strcmp(map_type, "hesiod")) {
+ warn(ap->logopt, MODPREFIX
+ "hesiod support not built in, "
+ "defaults map entry not set");
+ defaults_entry = NULL;
+ }
+#endif
+ }
+ if (defaults_entry)
+ list_del_init(&defaults_entry->list);
/* The list should now be empty .... */
free_amd_entry_list(&dflts);
return defaults_entry;
@@ -2005,8 +2015,20 @@ static struct amd_entry *get_defaults_entry(struct autofs_point *ap,
* use configured nss sources.
*/
char *map_type = conf_amd_get_map_type(ap->path);
- if (map_type)
+ if (map_type) {
entry->map_type = map_type;
+#ifndef HAVE_HESIOD
+ if (!strcmp(map_type, "hesiod")) {
+ warn(ap->logopt, MODPREFIX
+ "hesiod support not built in, "
+ "attempting to use internal "
+ "default");
+ free_amd_entry(entry);
+ free(expand);
+ goto out;
+ }
+#endif
+ }
}
free(expand);
}

46
archive-patches/autofs-5.1.4/autofs-5.1.4-fix-age-setting-at-startup.patch

@ -0,0 +1,46 @@
autofs-5.1.4 - fix age setting at startup
From: Ian Kent <raven@themaw.net>
Commit 2b567ace7d, which resets the master map list on startup
before retrying a read, incorrectly sets age using time() when
it should use monotonic_time().
This causes lookup failures for submounts in cases where a master
map read retry was needed.
The failure happens because the mount entry age is greater than
the map entry age which is meant to indicate the map is no longer
valid which is not the case.
Signed-off-by: Ian Kent <raven@themaw.net>
---
CHANGELOG | 1 +
daemon/automount.c | 2 +-
2 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/CHANGELOG b/CHANGELOG
index 740f804f..c39aa0e5 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -30,6 +30,7 @@ xx/xx/2018 autofs-5.1.5
- change expire type naming to better reflect usage.
- use defines for expire type.
- enable SIGUSR2 handling in rpm spec file.
+- fix age setting at startup.
19/12/2017 autofs-5.1.4
- fix spec file url.
diff --git a/daemon/automount.c b/daemon/automount.c
index 3fbfb9aa..99534295 100644
--- a/daemon/automount.c
+++ b/daemon/automount.c
@@ -2606,7 +2606,7 @@ int main(int argc, char *argv[])
* we have anyway.
*/
do_master_list_reset(master_list);
- age = time(NULL);
+ age = monotonic_time(NULL);
master_read_master(master_list, age, 1);
}
}

72
archive-patches/autofs-5.1.4/autofs-5.1.4-fix-amd-parser-opts-option-handling.patch

@ -0,0 +1,72 @@
autofs-5.1.4 - fix amd parser opts option handling
From: Ian Kent <raven@themaw.net>
The recent implementation of the amd map program mount feature
introduced a regression in the amd parser where only the first
option of a comma separated list of is applied to a mount entry.
Signed-off-by: Ian Kent <raven@themaw.net>
---
CHANGELOG | 1 +
modules/amd_parse.y | 4 ++--
modules/parse_amd.c | 4 +++-
3 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/CHANGELOG b/CHANGELOG
index aa485e8f..0365a161 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -38,6 +38,7 @@ xx/xx/2018 autofs-5.1.5
- add master map pseudo options for mount propagation.
- fix use after free in parse_ldap_config().
- fix incorrect locking in sss lookup.
+- fix amd parser opts option handling.
19/12/2017 autofs-5.1.4
- fix spec file url.
diff --git a/modules/amd_parse.y b/modules/amd_parse.y
index 5bd688d9..be923c2f 100644
--- a/modules/amd_parse.y
+++ b/modules/amd_parse.y
@@ -401,7 +401,7 @@ option_assignment: MAP_OPTION OPTION_ASSIGN FS_TYPE
}
| MNT_OPTION OPTION_ASSIGN options
{
- if (!match_mnt_option_options($1, $3)) {
+ if (!match_mnt_option_options($1, opts)) {
amd_notify($1);
YYABORT;
}
@@ -409,7 +409,7 @@ option_assignment: MAP_OPTION OPTION_ASSIGN FS_TYPE
}
| MNT_OPTION OPTION_ASSIGN QUOTE options QUOTE
{
- if (!match_mnt_option_options($1, $4)) {
+ if (!match_mnt_option_options($1, opts)) {
amd_notify($1);
YYABORT;
}
diff --git a/modules/parse_amd.c b/modules/parse_amd.c
index ea57270a..627c3c00 100644
--- a/modules/parse_amd.c
+++ b/modules/parse_amd.c
@@ -2136,6 +2136,7 @@ int parse_mount(struct autofs_point *ap, const char *name,
list_del_init(&this->list);
cur_defaults = this;
update_with_defaults(defaults_entry, cur_defaults, sv);
+ debug(ap->logopt, "merged /defaults entry with defaults");
continue;
} else if (this->flags & AMD_DEFAULTS_RESET) {
struct amd_entry *nd, *new;
@@ -2174,8 +2175,9 @@ int parse_mount(struct autofs_point *ap, const char *name,
at_least_one = 1;
- debug(ap->logopt, "expand mount entry");
+ debug(ap->logopt, "update mount entry with defaults");
update_with_defaults(cur_defaults, this, sv);
+ debug(ap->logopt, "expand mount entry");
sv = expand_entry(ap, this, flags, sv);
sv = merge_entry_options(ap, this, sv);
normalize_sublink(ap->logopt, this, sv);

44
archive-patches/autofs-5.1.4/autofs-5.1.4-fix-incorrect-locking-in-sss-lookup.patch

@ -0,0 +1,44 @@
autofs-5.1.4 - fix incorrect locking in sss lookup
From: Ian Kent <raven@themaw.net>
Commit 766e0f6c4, autofs-5.0.7 - fix fix wildcard multi map regression,
introduced a deadlock during restart when the sss modules is used.
Looking at the comment above the code which takes the lock it clearly
does this incorrectly.
Signed-off-by: Ian Kent <raven@themaw.net>
---
CHANGELOG | 1 +
modules/lookup_sss.c | 4 ++--
2 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/CHANGELOG b/CHANGELOG
index 3bf86e84..aa485e8f 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -37,6 +37,7 @@ xx/xx/2018 autofs-5.1.5
- set bind mount as propagation slave.
- add master map pseudo options for mount propagation.
- fix use after free in parse_ldap_config().
+- fix incorrect locking in sss lookup.
19/12/2017 autofs-5.1.4
- fix spec file url.
diff --git a/modules/lookup_sss.c b/modules/lookup_sss.c
index 88ec1693..78598300 100644
--- a/modules/lookup_sss.c
+++ b/modules/lookup_sss.c
@@ -786,9 +786,9 @@ int lookup_mount(struct autofs_point *ap, const char *name, int name_len, void *
* when we're starting up so just take the readlock in that
*/
if (ap->flags & MOUNT_FLAG_REMOUNT)
- cache_writelock(mc);
- else
cache_readlock(mc);
+ else
+ cache_writelock(mc);
me = cache_lookup(mc, key);
/* Stale mapent => check for entry in alternate source or wildcard */
if (me && !me->mapent) {

39
archive-patches/autofs-5.1.4/autofs-5.1.4-fix-indent-in-automount-8-man-page.patch

@ -0,0 +1,39 @@
autofs-5.1.4 - fix indent in automount(8) man page
From: Ian Kent <raven@themaw.net>
The .P paragraph directive resets paragraph indentation but
the following sentence belongs to the comand line option
above.
Signed-off-by: Ian Kent <raven@themaw.net>
---
CHANGELOG | 1 +
man/automount.8 | 2 +-
2 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/CHANGELOG b/CHANGELOG
index 8e9bd665..1a9296f5 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -41,6 +41,7 @@ xx/xx/2018 autofs-5.1.5
- fix amd parser opts option handling.
- fix possible NULL pointer dereference in get_defaults_entry().
- better handle hesiod support not built in.
+- fix indent in automount(8) man page.
19/12/2017 autofs-5.1.4
- fix spec file url.
diff --git a/man/automount.8 b/man/automount.8
index 1e15ecd2..68d2aaa3 100644
--- a/man/automount.8
+++ b/man/automount.8
@@ -106,7 +106,7 @@ will lead to everything (debug logging) being logged witch can then also
be disabled, returning the daemon to verbose logging. This option can be
specified to change the logging priority of an already running automount
process.
-.P
+
The \fIpath\fP argument corresponds to the automounted
path name as specified in the master map.
.TP

38
archive-patches/autofs-5.1.4/autofs-5.1.4-fix-possible-NULL-pointer-access-in-get_defaults_entry.patch

@ -0,0 +1,38 @@
autofs-5.1.4 - fix possible NULL pointer dereference in get_defaults_entry()
From: Ian Kent <raven@themaw.net>
Function select_default_entry() can call make_default_entry() so a NULL
return is possible.
Signed-off-by: Ian Kent <raven@themaw.net>
---
CHANGELOG | 1 +
modules/parse_amd.c | 2 +-
2 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/CHANGELOG b/CHANGELOG
index 0365a161..5a317f12 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -39,6 +39,7 @@ xx/xx/2018 autofs-5.1.5
- fix use after free in parse_ldap_config().
- fix incorrect locking in sss lookup.
- fix amd parser opts option handling.
+- fix possible NULL pointer dereference in get_defaults_entry().
19/12/2017 autofs-5.1.4
- fix spec file url.
diff --git a/modules/parse_amd.c b/modules/parse_amd.c
index 627c3c00..7399d19e 100644
--- a/modules/parse_amd.c
+++ b/modules/parse_amd.c
@@ -1998,7 +1998,7 @@ static struct amd_entry *get_defaults_entry(struct autofs_point *ap,
goto out;
}
entry = select_default_entry(ap, &dflts, sv);
- if (!entry->map_type) {
+ if (entry && !entry->map_type) {
/*
* If map type isn't given try to inherit from
* parent. A NULL map type is valid and means

44
archive-patches/autofs-5.1.4/autofs-5.1.4-fix-program-usage-message.patch

@ -0,0 +1,44 @@
autofs-5.1.4 - fix program usage message
From: Ian Kent <raven@themaw.net>
There is a discrepancy between the list of options in the usage
message of automount(8) and the options listed in the man page.
Signed-off-by: Ian Kent <raven@themaw.net>
---
CHANGELOG | 1 +
daemon/automount.c | 6 +++++-
2 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/CHANGELOG b/CHANGELOG
index 70e043ee..f126de66 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -32,6 +32,7 @@ xx/xx/2018 autofs-5.1.5
- enable SIGUSR2 handling in rpm spec file.
- fix age setting at startup.
- fix update_negative_cache() map source usage.
+- fix program usage message.
19/12/2017 autofs-5.1.4
- fix spec file url.
diff --git a/daemon/automount.c b/daemon/automount.c
index 99534295..05ec8a62 100644
--- a/daemon/automount.c
+++ b/daemon/automount.c
@@ -1893,9 +1893,13 @@ static void usage(void)
" -h --help this text\n"
" -p --pid-file f write process id to file f\n"
" -t --timeout n auto-unmount in n seconds (0-disable)\n"
+ " -M --master-wait n\n"
+ " maximum wait time (seconds) for master\n"
+ " map to become available\n"
" -v --verbose be verbose\n"
" -d --debug log debuging info\n"
- " -D --define define global macro variable\n"
+ " -Dvariable=value, --define variable=value\n"
+ " define global macro variable\n"
" -f --foreground do not fork into background\n"
" -r --random-multimount-selection\n"
" use ramdom replicated server selection\n"

102
archive-patches/autofs-5.1.4/autofs-5.1.4-fix-update_negative_cache-map-source-usage.patch

@ -0,0 +1,102 @@
autofs-5.1.4 - fix update_negative_cache() map source usage
From: Ian Kent <raven@themaw.net>
File map sources can be either plain text or executable.
When the map path is specified without a type (eg. when a
full path is used) an instance map source is used and the
original map is left unchanged.
But update_negative_cache() fails to take this into account
causing it to update the wrong map cache.
When a map reload is done the map entry appears to not exist
so the new map entry is added.
This could go unnoticed except that, after a map read, the
map entry cache cleans stale map entries and the existence
of this negative entry causes the new map entry to be deleted
and map lookups continue to fail.
In hindsite the use of an instance map source for this is
probably uneccessary but changing it will be risky so, for
now, just make update_negative_cache() use the correct map.
Signed-off-by: Ian Kent <raven@themaw.net>
---
CHANGELOG | 1 +
daemon/lookup.c | 38 ++++++++++++++++++++++++++++++++++++--
2 files changed, 37 insertions(+), 2 deletions(-)
diff --git a/CHANGELOG b/CHANGELOG
index c39aa0e5..70e043ee 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -31,6 +31,7 @@ xx/xx/2018 autofs-5.1.5
- use defines for expire type.
- enable SIGUSR2 handling in rpm spec file.
- fix age setting at startup.
+- fix update_negative_cache() map source usage.
19/12/2017 autofs-5.1.4
- fix spec file url.
diff --git a/daemon/lookup.c b/daemon/lookup.c
index 6a722b3b..418f01cb 100644
--- a/daemon/lookup.c
+++ b/daemon/lookup.c
@@ -1100,6 +1100,37 @@ static enum nsswitch_status lookup_map_name(struct nss_source *this,
return result;
}
+static struct map_source *lookup_get_map_source(struct master_mapent *entry)
+{
+ struct map_source *map = entry->maps;
+ struct stat st;
+ char *type;
+
+ if (map->type || *map->argv[0] != '/')
+ return map;
+
+ if (*(map->argv[0] + 1) == '/')
+ return map;
+
+ if (stat(map->argv[0], &st) == -1)
+ return NULL;
+
+ if (!S_ISREG(st.st_mode))
+ return NULL;
+
+ if (st.st_mode & __S_IEXEC)
+ type = "program";
+ else
+ type = "file";
+
+ /* This is a file source with a path starting with "/".
+ * But file maps can be either plain text or executable
+ * so they use a map instance and the actual map source
+ * remains untouched.
+ */
+ return master_find_source_instance(map, type, map->format, 0, NULL);
+}
+
static void update_negative_cache(struct autofs_point *ap, struct map_source *source, const char *name)
{
struct master_mapent *entry = ap->entry;
@@ -1133,11 +1164,14 @@ static void update_negative_cache(struct autofs_point *ap, struct map_source *so
logmsg("key \"%s\" not found in map source(s).", name);
}
- /* Doesn't exist in any source, just add it somewhere */
+ /* Doesn't exist in any source, just add it somewhere.
+ * Also take care to use the same map source used by
+ * map reads and key lookups for the update.
+ */
if (source)
map = source;
else
- map = entry->maps;
+ map = lookup_get_map_source(entry);
if (map) {
time_t now = monotonic_time(NULL);
int rv = CHE_FAIL;

38
archive-patches/autofs-5.1.4/autofs-5.1.4-fix-use-after-free-in-parse_ldap_config.patch

@ -0,0 +1,38 @@
autofs-5.1.4 - fix use after free in parse_ldap_config()
From: Ian Kent <raven@themaw.net>
Commit a4a2af5f30 (covarity fixes) incorrecly frees local variable
authtype after assigning it to a lookup context structure member.
Signed-off-by: Ian Kent <raven@themaw.net>
---
CHANGELOG | 1 +
modules/lookup_ldap.c | 2 --
2 files changed, 1 insertion(+), 2 deletions(-)
diff --git a/CHANGELOG b/CHANGELOG
index 4765a66e..3bf86e84 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -36,6 +36,7 @@ xx/xx/2018 autofs-5.1.5
- mark removed cache entry negative.
- set bind mount as propagation slave.
- add master map pseudo options for mount propagation.
+- fix use after free in parse_ldap_config().
19/12/2017 autofs-5.1.4
- fix spec file url.
diff --git a/modules/lookup_ldap.c b/modules/lookup_ldap.c
index 06c96973..911a34a5 100644
--- a/modules/lookup_ldap.c
+++ b/modules/lookup_ldap.c
@@ -1383,8 +1383,6 @@ auth_fail:
user, secret ? "specified" : "unspecified",
client_princ, client_cc);
}
- if (authtype)
- free(authtype);
out:
xmlFreeDoc(doc);
if (auth_conf)

68
archive-patches/autofs-5.1.4/autofs-5.1.4-mark-removed-cache-entry-negative.patch

@ -0,0 +1,68 @@
autofs-5.1.4 - mark removed cache entry negative
From: Ian Kent <raven@themaw.net>
When re-reading a map, entries that have been removed are detected
and deleted from the map entry cache by lookup_prune_cache().
If a removed map entry is mounted at the time lookup_prune_cache()
is called the map entry is skipped. This is done becuase the next
lookup (following the mount expire, which needs the cache entry to
remain) will detect the stale cache entry and a map update done
resulting in the stale entry being removed.
But if a map re-read is performed while the cache entry is mounted
the cache will appear to up to date so the removed entry will remain
valid even after it has expired.
To cover this case it's sufficient to mark the mounted cache entry
negative during the cache prune which prevents further lookups from
using the stale entry.
Signed-off-by: Ian Kent <raven@themaw.net>
---
CHANGELOG | 1 +
daemon/lookup.c | 12 +++++++++---
2 files changed, 10 insertions(+), 3 deletions(-)
diff --git a/CHANGELOG b/CHANGELOG
index f126de66..42950d51 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -33,6 +33,7 @@ xx/xx/2018 autofs-5.1.5
- fix age setting at startup.
- fix update_negative_cache() map source usage.
- fix program usage message.
+- mark removed cache entry negative.
19/12/2017 autofs-5.1.4
- fix spec file url.
diff --git a/daemon/lookup.c b/daemon/lookup.c
index 418f01cb..18df9352 100644
--- a/daemon/lookup.c
+++ b/daemon/lookup.c
@@ -1417,15 +1417,21 @@ void lookup_prune_one_cache(struct autofs_point *ap, struct mapent_cache *mc, ti
if (valid && valid->mc == mc) {
/*
* We've found a map entry that has been removed from
- * the current cache so it isn't really valid.
+ * the current cache so it isn't really valid. Set the
+ * mapent negative to prevent further mount requests
+ * using the cache entry.
*/
+ debug(ap->logopt, "removed map entry detected, mark negative");
+ if (valid->mapent) {
+ free(valid->mapent);
+ valid->mapent = NULL;
+ }
cache_unlock(valid->mc);
valid = NULL;
}
if (!valid &&
is_mounted(_PATH_MOUNTED, path, MNTS_REAL)) {
- debug(ap->logopt,
- "prune check posponed, %s mounted", path);
+ debug(ap->logopt, "prune posponed, %s mounted", path);
free(key);
free(path);
continue;

125
archive-patches/autofs-5.1.4/autofs-5.1.4-move-close-stdio-descriptors-to-become_daemon.patch

@ -0,0 +1,125 @@
autofs-5.1.4 - move close stdio descriptors to become_daemon()
From: Ian Kent <raven@themaw.net>
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 <raven@themaw.net>
---
CHANGELOG | 1 +
daemon/automount.c | 27 ++++++++++++++++++++++++++-
include/log.h | 1 -
lib/log.c | 29 -----------------------------
4 files changed, 27 insertions(+), 31 deletions(-)
diff --git a/CHANGELOG b/CHANGELOG
index 4c5f276e..4e1d9c98 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -46,6 +46,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.
diff --git a/daemon/automount.c b/daemon/automount.c
index d891562a..c1360ed6 100644
--- a/daemon/automount.c
+++ b/daemon/automount.c
@@ -1218,6 +1218,8 @@ static void become_daemon(unsigned int flags)
}
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 flags)
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 */
diff --git a/include/log.h b/include/log.h
index 7a394cbe..c9b17b3c 100644
--- a/include/log.h
+++ b/include/log.h
@@ -36,7 +36,6 @@ extern void set_log_debug_ap(struct autofs_point *ap);
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, ...);
diff --git a/lib/log.c b/lib/log.c
index 41f95fe8..ca771d72 100644
--- a/lib/log.c
+++ b/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) {

359
archive-patches/autofs-5.1.4/autofs-5.1.4-refactor-negative-map-entry-check.patch

@ -0,0 +1,359 @@
autofs-5.1.4 - refactor negative map entry check
From: Ian Kent <raven@themaw.net>
Create a function to check for a negative map entry on lookup and use
it in each of the relevant modules.
Signed-off-by: Ian Kent <raven@themaw.net>
---
CHANGELOG | 1 +
include/automount.h | 1 +
lib/cache.c | 30 ++++++++++++++++++++++++++++++
modules/lookup_file.c | 22 ++--------------------
modules/lookup_hesiod.c | 22 ++--------------------
modules/lookup_hosts.c | 22 ++--------------------
modules/lookup_ldap.c | 22 ++--------------------
modules/lookup_nisplus.c | 22 ++--------------------
modules/lookup_program.c | 22 ++--------------------
modules/lookup_sss.c | 22 ++--------------------
modules/lookup_yp.c | 22 ++--------------------
11 files changed, 48 insertions(+), 160 deletions(-)
diff --git a/CHANGELOG b/CHANGELOG
index 21fc9ca7..0de3f31b 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -48,6 +48,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.
+- refactor negative map entry check.
19/12/2017 autofs-5.1.4
- fix spec file url.
diff --git a/include/automount.h b/include/automount.h
index 45fde53e..947daa10 100644
--- a/include/automount.h
+++ b/include/automount.h
@@ -223,6 +223,7 @@ struct mapent *cache_partial_match(struct mapent_cache *mc, const char *prefix);
struct mapent *cache_partial_match_wild(struct mapent_cache *mc, const char *prefix);
int cache_add(struct mapent_cache *mc, struct map_source *ms, const char *key, const char *mapent, time_t age);
int cache_update_offset(struct mapent_cache *mc, const char *mkey, const char *key, const char *mapent, time_t age);
+int cache_lookup_negative(struct mapent *me, const char *key);
void cache_update_negative(struct mapent_cache *mc, struct map_source *ms, const char *key, time_t timeout);
int cache_set_parents(struct mapent *mm);
int cache_update(struct mapent_cache *mc, struct map_source *ms, const char *key, const char *mapent, time_t age);
diff --git a/lib/cache.c b/lib/cache.c
index 44e323dd..d3b6642b 100644
--- a/lib/cache.c
+++ b/lib/cache.c
@@ -771,6 +771,36 @@ done:
return ret;
}
+/* Called with cache_lock held for map entry me and is released
+ * on return.
+ */
+int cache_lookup_negative(struct mapent *me, const char *key)
+{
+ if (me->status >= monotonic_time(NULL)) {
+ cache_unlock(me->mc);
+ return CHE_UNAVAIL;
+ } else {
+ struct mapent_cache *smc = me->mc;
+ struct mapent *sme;
+
+ if (me->mapent)
+ cache_unlock(smc);
+ else {
+ cache_unlock(smc);
+ cache_writelock(smc);
+ sme = cache_lookup_distinct(smc, key);
+ /* Negative timeout expired for non-existent entry. */
+ if (sme && !sme->mapent) {
+ if (cache_pop_mapent(sme) == CHE_FAIL)
+ cache_delete(smc, key);
+ }
+ cache_unlock(smc);
+ }
+ }
+
+ return CHE_OK;
+}
+
void cache_update_negative(struct mapent_cache *mc,
struct map_source *ms, const char *key,
time_t timeout)
diff --git a/modules/lookup_file.c b/modules/lookup_file.c
index ed5caa47..6986830b 100644
--- a/modules/lookup_file.c
+++ b/modules/lookup_file.c
@@ -1177,27 +1177,9 @@ int lookup_mount(struct autofs_point *ap, const char *name, int name_len, void *
/* Check if we recorded a mount fail for this key anywhere */
me = lookup_source_mapent(ap, key, LKP_DISTINCT);
if (me) {
- if (me->status >= monotonic_time(NULL)) {
- cache_unlock(me->mc);
+ /* negative timeout has not passed, return fail */
+ if (cache_lookup_negative(me, key) == CHE_UNAVAIL)
return NSS_STATUS_NOTFOUND;
- } else {
- struct mapent_cache *smc = me->mc;
- struct mapent *sme;
-
- if (me->mapent)
- cache_unlock(smc);
- else {
- cache_unlock(smc);
- cache_writelock(smc);
- sme = cache_lookup_distinct(smc, key);
- /* Negative timeout expired for non-existent entry. */
- if (sme && !sme->mapent) {
- if (cache_pop_mapent(sme) == CHE_FAIL)
- cache_delete(smc, key);
- }
- cache_unlock(smc);
- }
- }
}
/*
diff --git a/modules/lookup_hesiod.c b/modules/lookup_hesiod.c
index b3278d20..54cf278c 100644
--- a/modules/lookup_hesiod.c
+++ b/modules/lookup_hesiod.c
@@ -397,27 +397,9 @@ int lookup_mount(struct autofs_point *ap, const char *name, int name_len, void *
/* Check if we recorded a mount fail for this key anywhere */
me = lookup_source_mapent(ap, name, LKP_DISTINCT);
if (me) {
- if (me->status >= monotonic_time(NULL)) {
- cache_unlock(me->mc);
+ /* negative timeout has not passed, return fail */
+ if (cache_lookup_negative(me, name) == CHE_UNAVAIL)
return NSS_STATUS_NOTFOUND;
- } else {
- struct mapent_cache *smc = me->mc;
- struct mapent *sme;
-
- if (me->mapent)
- cache_unlock(smc);
- else {
- cache_unlock(smc);
- cache_writelock(smc);
- sme = cache_lookup_distinct(smc, name);
- /* Negative timeout expired for non-existent entry. */
- if (sme && !sme->mapent) {
- if (cache_pop_mapent(sme) == CHE_FAIL)
- cache_delete(smc, name);
- }
- cache_unlock(smc);
- }
- }
}
/* If this is not here the filesystem stays busy, for some reason... */
diff --git a/modules/lookup_hosts.c b/modules/lookup_hosts.c
index 163b02d5..744062e2 100644
--- a/modules/lookup_hosts.c
+++ b/modules/lookup_hosts.c
@@ -314,27 +314,9 @@ int lookup_mount(struct autofs_point *ap, const char *name, int name_len, void *
/* Check if we recorded a mount fail for this key anywhere */
me = lookup_source_mapent(ap, name, LKP_DISTINCT);
if (me) {
- if (me->status >= monotonic_time(NULL)) {
- cache_unlock(me->mc);
+ /* negative timeout has not passed, return fail */
+ if (cache_lookup_negative(me, name) == CHE_UNAVAIL)
return NSS_STATUS_NOTFOUND;
- } else {
- struct mapent_cache *smc = me->mc;
- struct mapent *sme;
-
- if (me->mapent)
- cache_unlock(smc);
- else {
- cache_unlock(smc);
- cache_writelock(smc);
- sme = cache_lookup_distinct(smc, name);
- /* Negative timeout expired for non-existent entry. */
- if (sme && !sme->mapent) {
- if (cache_pop_mapent(sme) == CHE_FAIL)
- cache_delete(smc, name);
- }
- cache_unlock(smc);
- }
- }
}
cache_readlock(mc);
diff --git a/modules/lookup_ldap.c b/modules/lookup_ldap.c
index 911a34a5..f7432a2a 100644
--- a/modules/lookup_ldap.c
+++ b/modules/lookup_ldap.c
@@ -3687,27 +3687,9 @@ int lookup_mount(struct autofs_point *ap, const char *name, int name_len, void *
/* Check if we recorded a mount fail for this key anywhere */
me = lookup_source_mapent(ap, key, LKP_DISTINCT);
if (me) {
- if (me->status >= monotonic_time(NULL)) {
- cache_unlock(me->mc);
+ /* negative timeout has not passed, return fail */
+ if (cache_lookup_negative(me, key) == CHE_UNAVAIL)
return NSS_STATUS_NOTFOUND;
- } else {
- struct mapent_cache *smc = me->mc;
- struct mapent *sme;
-
- if (me->mapent)
- cache_unlock(smc);
- else {
- cache_unlock(smc);
- cache_writelock(smc);
- sme = cache_lookup_distinct(smc, key);
- /* Negative timeout expired for non-existent entry. */
- if (sme && !sme->mapent) {
- if (cache_pop_mapent(sme) == CHE_FAIL)
- cache_delete(smc, key);
- }
- cache_unlock(smc);
- }
- }
}
/*
diff --git a/modules/lookup_nisplus.c b/modules/lookup_nisplus.c
index 8dee4630..cbd03cdb 100644
--- a/modules/lookup_nisplus.c
+++ b/modules/lookup_nisplus.c
@@ -709,27 +709,9 @@ int lookup_mount(struct autofs_point *ap, const char *name, int name_len, void *
/* Check if we recorded a mount fail for this key anywhere */
me = lookup_source_mapent(ap, key, LKP_DISTINCT);
if (me) {
- if (me->status >= monotonic_time(NULL)) {
- cache_unlock(me->mc);
+ /* negative timeout has not passed, return fail */
+ if (cache_lookup_negative(me, key) == CHE_UNAVAIL)
return NSS_STATUS_NOTFOUND;
- } else {
- struct mapent_cache *smc = me->mc;
- struct mapent *sme;
-
- if (me->mapent)
- cache_unlock(smc);
- else {
- cache_unlock(smc);
- cache_writelock(smc);
- sme = cache_lookup_distinct(smc, key);
- /* Negative timeout expired for non-existent entry. */
- if (sme && !sme->mapent) {
- if (cache_pop_mapent(sme) == CHE_FAIL)
- cache_delete(smc, key);
- }
- cache_unlock(smc);
- }
- }
}
/*
diff --git a/modules/lookup_program.c b/modules/lookup_program.c
index 56e19394..fcb1af74 100644
--- a/modules/lookup_program.c
+++ b/modules/lookup_program.c
@@ -601,27 +601,9 @@ int lookup_mount(struct autofs_point *ap, const char *name, int name_len, void *
/* Check if we recorded a mount fail for this key anywhere */
me = lookup_source_mapent(ap, name, LKP_DISTINCT);
if (me) {
- if (me->status >= monotonic_time(NULL)) {
- cache_unlock(me->mc);
+ /* negative timeout has not passed, return fail */
+ if (cache_lookup_negative(me, name) == CHE_UNAVAIL)
return NSS_STATUS_NOTFOUND;
- } else {
- struct mapent_cache *smc = me->mc;
- struct mapent *sme;
-
- if (me->mapent)
- cache_unlock(smc);
- else {
- cache_unlock(smc);
- cache_writelock(smc);
- sme = cache_lookup_distinct(smc, name);
- /* Negative timeout expired for non-existent entry. */
- if (sme && !sme->mapent) {
- if (cache_pop_mapent(sme) == CHE_FAIL)
- cache_delete(smc, name);
- }
- cache_unlock(smc);
- }
- }
}
/* Catch installed direct offset triggers */
diff --git a/modules/lookup_sss.c b/modules/lookup_sss.c
index 78598300..ce60acd3 100644
--- a/modules/lookup_sss.c
+++ b/modules/lookup_sss.c
@@ -726,27 +726,9 @@ int lookup_mount(struct autofs_point *ap, const char *name, int name_len, void *
/* Check if we recorded a mount fail for this key anywhere */
me = lookup_source_mapent(ap, key, LKP_DISTINCT);
if (me) {
- if (me->status >= monotonic_time(NULL)) {
- cache_unlock(me->mc);
+ /* negative timeout has not passed, return fail */
+ if (cache_lookup_negative(me, key) == CHE_UNAVAIL)
return NSS_STATUS_NOTFOUND;
- } else {
- struct mapent_cache *smc = me->mc;
- struct mapent *sme;
-
- if (me->mapent)
- cache_unlock(smc);
- else {
- cache_unlock(smc);
- cache_writelock(smc);
- sme = cache_lookup_distinct(smc, key);
- /* Negative timeout expired for non-existent entry. */
- if (sme && !sme->mapent) {
- if (cache_pop_mapent(sme) == CHE_FAIL)
- cache_delete(smc, key);
- }
- cache_unlock(smc);
- }
- }
}
/*
diff --git a/modules/lookup_yp.c b/modules/lookup_yp.c
index d1ffcae4..38f75497 100644
--- a/modules/lookup_yp.c
+++ b/modules/lookup_yp.c
@@ -813,27 +813,9 @@ int lookup_mount(struct autofs_point *ap, const char *name, int name_len, void *
/* Check if we recorded a mount fail for this key anywhere */
me = lookup_source_mapent(ap, key, LKP_DISTINCT);
if (me) {
- if (me->status >= monotonic_time(NULL)) {
- cache_unlock(me->mc);
+ /* negative timeout has not passed, return fail */
+ if (cache_lookup_negative(me, key) == CHE_UNAVAIL)
return NSS_STATUS_NOTFOUND;
- } else {
- struct mapent_cache *smc = me->mc;
- struct mapent *sme;
-
- if (me->mapent)
- cache_unlock(smc);
- else {
- cache_unlock(smc);
- cache_writelock(smc);
- sme = cache_lookup_distinct(smc, key);
- /* Negative timeout expired for non-existent entry. */
- if (sme && !sme->mapent) {
- if (cache_pop_mapent(sme) == CHE_FAIL)
- cache_delete(smc, key);
- }
- cache_unlock(smc);
- }
- }
}
/*

236
archive-patches/autofs-5.1.4/autofs-5.1.4-remove-autofs4-module-load-code.patch

@ -0,0 +1,236 @@
autofs-5.1.4 - remove autofs4 module load code
From: Ian Kent <raven@themaw.net>
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 <raven@themaw.net>
---
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(-)
diff --git a/CHANGELOG b/CHANGELOG
index 1a9296f5..0a56df5a 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -42,6 +42,7 @@ xx/xx/2018 autofs-5.1.5
- fix possible NULL pointer dereference in get_defaults_entry().
- better handle hesiod support not built in.
- fix indent in automount(8) man page.
+- remove autofs4 module load code.
19/12/2017 autofs-5.1.4
- fix spec file url.
diff --git a/configure b/configure
index 827921ba..2116668a 100755
--- a/configure
+++ b/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
diff --git a/configure.in b/configure.in
index 4b0a81f2..dbee99f4 100644
--- a/configure.in
+++ b/configure.in
@@ -161,7 +161,6 @@ AF_PATH_INCLUDE(UMOUNT, umount, /bin/umount, $searchpath)
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)
diff --git a/daemon/automount.c b/daemon/automount.c
index 05ec8a62..2c0def54 100644
--- a/daemon/automount.c
+++ b/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,
diff --git a/daemon/module.c b/daemon/module.c
index b1a94f56..be96a82b 100644
--- a/daemon/module.c
+++ b/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)
{
diff --git a/include/automount.h b/include/automount.h
index 417dacbb..eccd16aa 100644
--- a/include/automount.h
+++ b/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
diff --git a/include/config.h.in b/include/config.h.in
index 991a2bda..a4879494 100644
--- a/include/config.h.in
+++ b/include/config.h.in
@@ -48,9 +48,6 @@
/* Define to 1 if you have the <memory.h> 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

38
archive-patches/autofs-5.1.4/autofs-5.1.4-remove-couple-of-undeeded-requires.patch

@ -0,0 +1,38 @@
autofs-5.1.4 - remove couple of undeeded requires
From: Ian Kent <raven@themaw.net>
Remove a couple of apparently undeeded Requires entries from the tar
spec file.
Signed-off-by: Ian Kent <raven@themaw.net>
---
CHANGELOG | 1 +
autofs.spec | 2 +-
2 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/CHANGELOG b/CHANGELOG
index 2a551426..5e1bdf42 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -51,6 +51,7 @@ xx/xx/2018 autofs-5.1.5
- refactor negative map entry check.
- remove unused function dump_master().
- remove unused function dump_state_queue().
+- remove couple of undeeded requires.
19/12/2017 autofs-5.1.4
- fix spec file url.
diff --git a/autofs.spec b/autofs.spec
index 6419e3e3..53654437 100644
--- a/autofs.spec
+++ b/autofs.spec
@@ -39,7 +39,7 @@ BuildRequires: libtirpc-devel
%endif
BuildRequires: autoconf, hesiod-devel, openldap-devel, bison, flex, cyrus-sasl-devel
Requires: chkconfig
-Requires: /bin/bash mktemp sed textutils sh-utils grep /bin/ps
+Requires: /bin/bash sed grep /bin/ps
%if %{with_systemd}
Requires(post): systemd-sysv
Requires(post): systemd-units

41
archive-patches/autofs-5.1.4/autofs-5.1.4-remove-unused-function-dump_master.patch

@ -0,0 +1,41 @@
autofs-5.1.4 - remove unused function dump_master()
From: Ian Kent <raven@themaw.net>
Signed-off-by: Ian Kent <raven@themaw.net>
---
CHANGELOG | 1 +
lib/master.c | 11 -----------
2 files changed, 1 insertion(+), 11 deletions(-)
diff --git a/CHANGELOG b/CHANGELOG
index 0de3f31b..32e34e35 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -49,6 +49,7 @@ xx/xx/2018 autofs-5.1.5
- move close stdio descriptors to become_daemon().
- add systemd service command line option.
- refactor negative map entry check.
+- remove unused function dump_master().
19/12/2017 autofs-5.1.4
- fix spec file url.
diff --git a/lib/master.c b/lib/master.c
index ba5272f0..5f3a3d99 100644
--- a/lib/master.c
+++ b/lib/master.c
@@ -1965,14 +1965,3 @@ int master_kill(struct master *master)
return 1;
}
-
-void dump_master(struct master *master)
-{
- struct list_head *p, *head;
-
- head = &master->mounts;
- list_for_each(p, head) {
- struct master_mapent *this = list_entry(p, struct master_mapent, list);
- logmsg("path %s", this->path);
- }
-}

57
archive-patches/autofs-5.1.4/autofs-5.1.4-remove-unused-function-dump_state_queue.patch

@ -0,0 +1,57 @@
autofs-5.1.4 - remove unused function dump_state_queue()
From: Ian Kent <raven@themaw.net>
Signed-off-by: Ian Kent <raven@themaw.net>
---
CHANGELOG | 1 +
daemon/state.c | 24 ------------------------
2 files changed, 1 insertion(+), 24 deletions(-)
diff --git a/CHANGELOG b/CHANGELOG
index 32e34e35..2a551426 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -50,6 +50,7 @@ xx/xx/2018 autofs-5.1.5
- add systemd service command line option.
- refactor negative map entry check.
- remove unused function dump_master().
+- remove unused function dump_state_queue().
19/12/2017 autofs-5.1.4
- fix spec file url.
diff --git a/daemon/state.c b/daemon/state.c
index 3d91f5b1..ca9534c4 100644
--- a/daemon/state.c
+++ b/daemon/state.c
@@ -52,30 +52,6 @@ void st_mutex_unlock(void)
fatal(status);
}
-void dump_state_queue(void)
-{
- struct list_head *head = &state_queue;
- struct list_head *p, *q;
-
- logmsg("dumping queue");
-
- list_for_each(p, head) {
- struct state_queue *entry;
-
- entry = list_entry(p, struct state_queue, list);
- logmsg("queue list head path %s state %d busy %d",
- entry->ap->path, entry->state, entry->busy);
-
- list_for_each(q, &entry->pending) {
- struct state_queue *this;
-
- this = list_entry(q, struct state_queue, pending);
- logmsg("queue list entry path %s state %d busy %d",
- this->ap->path, this->state, this->busy);
- }
- }
-}
-
void nextstate(int statefd, enum states next)
{
char buf[MAX_ERR_BUF];

73
archive-patches/autofs-5.1.4/autofs-5.1.4-set-bind-mount-as-propagation-slave.patch

@ -0,0 +1,73 @@
autofs-5.1.4 - set bind mount as propagation slave
From: Ian Kent <raven@themaw.net>
When using a multi-mount with mount targets that are on the
local machine and resulting bind mounts are made to a file
system that is mount propagation shared (such as the root
file system on systemd managed systems) the autofs offset
mount triggers made within the bind mount will be propagated
back to the target file system.
When this happens the target of the offset (the unwanted
propagated mount) is itself an autofs trigger mount and
accessing the path results in a deadlock.
In order for these multi-mounts to function properly in this
case bind mounts that contain mount triggers must be set to
propagation slave or private so the backward propagation
doesn't occur.
Signed-off-by: Ian Kent <raven@themaw.net>
---
CHANGELOG | 1 +
modules/mount_bind.c | 16 +++++++++++++++-
2 files changed, 16 insertions(+), 1 deletion(-)
diff --git a/CHANGELOG b/CHANGELOG
index 42950d51..88829564 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -34,6 +34,7 @@ xx/xx/2018 autofs-5.1.5
- fix update_negative_cache() map source usage.
- fix program usage message.
- mark removed cache entry negative.
+- set bind mount as propagation slave.
19/12/2017 autofs-5.1.4
- fix spec file url.
diff --git a/modules/mount_bind.c b/modules/mount_bind.c
index 5effa880..fe1ad9b6 100644
--- a/modules/mount_bind.c
+++ b/modules/mount_bind.c
@@ -20,6 +20,7 @@
#include <sys/param.h>
#include <sys/types.h>
#include <sys/stat.h>
+#include <sys/mount.h>
#define MODULE_MOUNT
#include "automount.h"
@@ -183,8 +184,21 @@ int mount_mount(struct autofs_point *ap, const char *root, const char *name, int
debug(ap->logopt,
MODPREFIX "mounted %s type %s on %s",
what, fstype, fullpath);
- return 0;
}
+
+ /* The bind mount has succeeded but if the target
+ * mount is propagation shared propagation of child
+ * mounts (autofs offset mounts for example) back to
+ * the target of the bind mount must be avoided or
+ * autofs trigger mounts will deadlock.
+ */
+ err = mount(NULL, fullpath, NULL, MS_SLAVE, NULL);
+ if (err)
+ warn(ap->logopt,
+ "failed to set propagation type for %s",
+ fullpath);
+
+ return 0;
} else {
char *cp;
char basepath[PATH_MAX];

45
archive-patches/autofs-5.1.4/autofs-5.1.4-update-build-info-with-systemd.patch

@ -0,0 +1,45 @@
autofs-5.1.4 - update build info with systemd
From: Ian Kent <raven@themaw.net>
Update the show_build_info() function to include systemd
build info.
Signed-off-by: Ian Kent <raven@themaw.net>
---
CHANGELOG | 1 +
daemon/automount.c | 9 +++++++++
2 files changed, 10 insertions(+)
diff --git a/CHANGELOG b/CHANGELOG
index ad9932a2..b30e52c6 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -44,6 +44,7 @@ xx/xx/2018 autofs-5.1.5
- fix indent in automount(8) man page.
- 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.
diff --git a/daemon/automount.c b/daemon/automount.c
index 2c0def54..a99d6b33 100644
--- a/daemon/automount.c
+++ b/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 ");

225
archive-patches/autofs-5.1.4/autofs-5.1.4-use-flags-for-startup-boolean-options.patch

@ -0,0 +1,225 @@
autofs-5.1.4 - use flags for startup boolean options
From: Ian Kent <raven@themaw.net>
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 <raven@themaw.net>
---
CHANGELOG | 1 +
daemon/automount.c | 45 ++++++++++++++++++++++-----------------------
include/automount.h | 6 ++++++
lib/master.c | 4 ++--
4 files changed, 31 insertions(+), 25 deletions(-)
diff --git a/CHANGELOG b/CHANGELOG
index b30e52c6..4c5f276e 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -45,6 +45,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.
diff --git a/daemon/automount.c b/daemon/automount.c
index a99d6b33..d891562a 100644
--- a/daemon/automount.c
+++ b/daemon/automount.c
@@ -1195,7 +1195,7 @@ static int handle_packet(struct autofs_point *ap)
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 foreground, unsigned daemon_check)
}
/* 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 foreground, unsigned daemon_check)
}
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!",
diff --git a/include/automount.h b/include/automount.h
index eccd16aa..848fd0be 100644
--- a/include/automount.h
+++ b/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
diff --git a/lib/master.c b/lib/master.c
index 76717d57..ba5272f0 100644
--- a/lib/master.c
+++ b/lib/master.c
@@ -922,7 +922,7 @@ void master_free_mapent(struct master_mapent *entry)
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 *name, unsigned int timeout, unsigned int g
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;

22
archive-patches/autofs-5.1.4/patch_order-5.1.4

@ -31,3 +31,25 @@ autofs-5.1.4-change-expire-type-naming-to-better-reflect-usage.patch
autofs-5.1.4-use-defines-for-expire-type.patch
autofs-5.1.4-make-umount_ent-recognise-forced-umount.patch
autofs-5.1.4-enable-SIGUSR2-handling-in-rpm-spec-file.patch
autofs-5.1.4-fix-age-setting-at-startup.patch
autofs-5.1.4-fix-update_negative_cache-map-source-usage.patch
autofs-5.1.4-fix-program-usage-message.patch
autofs-5.1.4-mark-removed-cache-entry-negative.patch
autofs-5.1.4-set-bind-mount-as-propagation-slave.patch
autofs-5.1.4-add-master-map-pseudo-options-for-mount-propagation.patch
autofs-5.1.4-fix-use-after-free-in-parse_ldap_config.patch
autofs-5.1.4-fix-incorrect-locking-in-sss-lookup.patch
autofs-5.1.4-fix-amd-parser-opts-option-handling.patch
autofs-5.1.4-fix-possible-NULL-pointer-access-in-get_defaults_entry.patch
autofs-5.1.4-better-handle-hesiod-support-not-built-in.patch
autofs-5.1.4-fix-indent-in-automount-8-man-page.patch
autofs-5.1.4-remove-autofs4-module-load-code.patch
autofs-5.1.4-add-NULL-check-in-prepare_attempt_prefix.patch
autofs-5.1.4-update-build-info-with-systemd.patch
autofs-5.1.4-use-flags-for-startup-boolean-options.patch
autofs-5.1.4-move-close-stdio-descriptors-to-become_daemon.patch
autofs-5.1.4-add-systemd-service-command-line-option.patch
autofs-5.1.4-refactor-negative-map-entry-check.patch
autofs-5.1.4-remove-unused-function-dump_master.patch
autofs-5.1.4-remove-unused-function-dump_state_queue.patch
autofs-5.1.4-remove-couple-of-undeeded-requires.patch

Loading…
Cancel
Save