autofs-5.1.2 - add master read wait option
From: Ian Kent <raven@themaw.net>
Add command line and configuration options to set the amount of time to
wait for the master map to become available at program start.
Signed-off-by: Ian Kent <raven@themaw.net>
---
CHANGELOG | 1 +
daemon/automount.c | 11 +++++++++--
include/defaults.h | 2 ++
lib/defaults.c | 17 +++++++++++++++++
man/autofs.conf.5.in | 5 +++++
man/automount.8 | 4 ++++
redhat/autofs.conf.default.in | 7 +++++++
samples/autofs.conf.default.in | 7 +++++++
8 files changed, 52 insertions(+), 2 deletions(-)
--- autofs-5.0.7.orig/CHANGELOG
+++ autofs-5.0.7/CHANGELOG
@@ -207,6 +207,7 @@
- fix use-after-free in st_queue_handler().
- add config option to supress not found log message.
- wait for master map available at start.
+- add master read wait option.
25/07/2012 autofs-5.0.7
=======================
--- autofs-5.0.7.orig/daemon/automount.c
+++ autofs-5.0.7/daemon/automount.c
@@ -2082,10 +2082,11 @@ int main(int argc, char *argv[])
unsigned ghost, logging, daemon_check;
unsigned dumpmaps, foreground, have_global_options;
unsigned master_read;
+ int master_wait;
time_t timeout;
time_t age = time(NULL);
struct rlimit rlim;
- const char *options = "+hp:t:vmdD:fVrO:l:n:CF";
+ const char *options = "+hp:t:vmdD:fVrO:l:n:CFM";
static const struct option long_options[] = {
{"help", 0, 0, 'h'},
{"pid-file", 1, 0, 'p'},
@@ -2102,6 +2103,7 @@ int main(int argc, char *argv[])
{"set-log-priority", 1, 0, 'l'},
{"dont-check-daemon", 0, 0, 'C'},
{"force", 0, 0, 'F'},
+ {"master-wait", 1, 0, 'M'},
{0, 0, 0, 0}
};
@@ -2122,6 +2124,7 @@ int main(int argc, char *argv[])
nfs_mount_uses_string_options = check_nfs_mount_version(&vers, &check);
kpkt_len = get_kpkt_len();
+ master_wait = defaults_get_master_wait();
timeout = defaults_get_timeout();
ghost = defaults_get_browse_mode();
logging = defaults_get_logging();
@@ -2181,6 +2184,10 @@ int main(int argc, char *argv[])
dumpmaps = 1;
break;
+ case 'M':
+ master_wait = getnumopt(optarg, opt);
+ break;
+
case 'O':
if (!have_global_options) {
global_options = strdup(optarg);
@@ -2502,7 +2509,7 @@ int main(int argc, char *argv[])
* a signal is received, in which case exit returning an
* error.
*/
- if (!do_master_read_master(master_list, -1)) {
+ if (!do_master_read_master(master_list, master_wait)) {
logerr("%s: failed to read master map!", program);
master_kill(master_list);
release_flag_file();
--- autofs-5.0.7.orig/include/defaults.h
+++ autofs-5.0.7/include/defaults.h
@@ -25,6 +25,7 @@
#define DEFAULT_MASTER_MAP_NAME "auto.master"
#define DEFAULT_TIMEOUT "600"
+#define DEFAULT_MASTER_WAIT "-1"
#define DEFAULT_NEGATIVE_TIMEOUT "60"
#define DEFAULT_MOUNT_WAIT "-1"
#define DEFAULT_UMOUNT_WAIT "12"
@@ -152,6 +153,7 @@ void defaults_conf_release(void);
const char *defaults_get_master_map(void);
int defaults_master_set(void);
unsigned int defaults_get_timeout(void);
+int defaults_get_master_wait(void);
unsigned int defaults_get_negative_timeout(void);
unsigned int defaults_get_browse_mode(void);
unsigned int defaults_get_logging(void);
--- autofs-5.0.7.orig/lib/defaults.c
+++ autofs-5.0.7/lib/defaults.c
@@ -47,6 +47,7 @@
#define NAME_MASTER_MAP "master_map_name"
#define NAME_TIMEOUT "timeout"
+#define NAME_MASTER_WAIT "master_wait"
#define NAME_NEGATIVE_TIMEOUT "negative_timeout"
#define NAME_BROWSE_MODE "browse_mode"
#define NAME_LOGGING "logging"
@@ -287,6 +288,11 @@ static int conf_load_autofs_defaults(voi
if (ret == CFG_FAIL)
goto error;
+ ret = conf_update(sec, NAME_MASTER_WAIT,
+ DEFAULT_MASTER_WAIT, CONF_ENV);
+ if (ret == CFG_FAIL)
+ goto error;
+
ret = conf_update(sec, NAME_NEGATIVE_TIMEOUT,
DEFAULT_NEGATIVE_TIMEOUT, CONF_ENV);
if (ret == CFG_FAIL)
@@ -1568,6 +1574,17 @@ unsigned int defaults_get_timeout(void)
return (unsigned int) timeout;
}
+int defaults_get_master_wait(void)
+{
+ long wait;
+
+ wait = conf_get_number(autofs_gbl_sec, NAME_MASTER_WAIT);
+ if (wait < 0)
+ wait = atol(DEFAULT_MASTER_WAIT);
+
+ return (int) wait;
+}
+
unsigned int defaults_get_negative_timeout(void)
{
long n_timeout;
--- autofs-5.0.7.orig/man/autofs.conf.5.in
+++ autofs-5.0.7/man/autofs.conf.5.in
@@ -30,6 +30,11 @@ default is 10 minutes, but the default i
overrides this and sets the timeout to 5 minutes to be consistent
with earlier autofs releases.
.TP
+.B master_wait
+sets the default maximum time to wait for the master map to become
+available if it cannot be read at program start (program default -1,
+wait forever).
+.TP
.B negative_timeout
.br
Set the default timeout for caching failed key lookups (program default
--- autofs-5.0.7.orig/man/automount.8
+++ autofs-5.0.7/man/automount.8
@@ -37,6 +37,10 @@ The internal program default is 10 minut
installed configuration overrides this and sets the timeout
to 5 minutes to be consistent with earlier autofs releases.
.TP
+.I "\-M <seconds>, \-\-master-wait <seconds>"
+Set the maximum time to wait for the master map to become available
+if it cannot be read at program start.
+.TP
.I "\-n <seconds>, \-\-negative\-timeout <seconds>"
Set the default timeout for caching failed key lookups. The default is 60 seconds.
.TP
--- autofs-5.0.7.orig/redhat/autofs.conf.default.in
+++ autofs-5.0.7/redhat/autofs.conf.default.in
@@ -14,6 +14,13 @@
#
timeout = 300
#
+# master_wait - set the default maximum time to wait for the
+# master map to become available if it cannot
+# be read at program start (default -1, wait
+# forever).
+#
+#master_wait = -1
+#
# negative_timeout - set the default negative timeout for
# failed mount attempts (default 60).
#
--- autofs-5.0.7.orig/samples/autofs.conf.default.in
+++ autofs-5.0.7/samples/autofs.conf.default.in
@@ -14,6 +14,13 @@
#
timeout = 300
#
+# master_wait - set the default maximum time to wait for the
+# master map to become available if it cannot
+# be read at program start (default -1, wait
+# forever).
+#
+# master_wait = -1
+#
# negative_timeout - set the default negative timeout for
# failed mount attempts (default 60).
#