You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

188 lines
5.7 KiB

autofs-5.1.5 - add mount_verbose configuration option
From: Lars R. Damerow <lars@pixar.com>
This option makes automount pass the -v flag to mount(8).
Signed-off-by: Lars R. Damerow <lars@pixar.com>
Signed-off-by: Ian Kent <raven@themaw.net>
---
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(-)
diff --git a/CHANGELOG b/CHANGELOG
index b3c3b3b9..c2a0c7f1 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -3,6 +3,7 @@ xx/xx/2019 autofs-5.1.6
- fix hesiod string check in master_parse().
- add NULL check for get_addr_string() return.
- use malloc(3) in spawn.c.
+- add mount_verbose configuration option.
30/10/2018 autofs-5.1.5
- fix flag file permission.
diff --git a/daemon/spawn.c b/daemon/spawn.c
index 2ab5c46f..4eb268ab 100644
--- a/daemon/spawn.c
+++ b/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 *);
diff --git a/include/defaults.h b/include/defaults.h
index b28fde34..baa4b4c9 100644
--- a/include/defaults.h
+++ b/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(void);
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);
diff --git a/lib/defaults.c b/lib/defaults.c
index ae4d27c1..4ac5a180 100644
--- a/lib/defaults.c
+++ b/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(void)
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)
@@ -1781,6 +1787,17 @@ unsigned int defaults_get_append_options(void)
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)
{
long wait;
diff --git a/man/autofs.conf.5.in b/man/autofs.conf.5.in
index cd7fc2f2..31136e2e 100644
--- a/man/autofs.conf.5.in
+++ b/man/autofs.conf.5.in
@@ -41,6 +41,10 @@ Set the default timeout for caching failed key lookups (program default
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)
diff --git a/redhat/autofs.conf.default.in b/redhat/autofs.conf.default.in
index a72a79f6..7949f51a 100644
--- a/redhat/autofs.conf.default.in
+++ b/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
diff --git a/samples/autofs.conf.default.in b/samples/autofs.conf.default.in
index 2693a975..d33625f1 100644
--- a/samples/autofs.conf.default.in
+++ b/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