Blame SOURCES/autofs-5.0.9-amd-lookup-add-conf-handling-for-amd-maps.patch

304803
autofs-5.0.9 - amd lookup add conf handling for amd maps
304803
304803
From: Ian Kent <ikent@redhat.com>
304803
304803
304803
---
304803
 include/defaults.h |  111 ++++++++
304803
 lib/defaults.c     |  753 ++++++++++++++++++++++++++++++++++++++++++++++++----
304803
 2 files changed, 811 insertions(+), 53 deletions(-)
304803
304803
diff --git a/include/defaults.h b/include/defaults.h
304803
index 3bfcd49..033acaf 100644
304803
--- a/include/defaults.h
304803
+++ b/include/defaults.h
304803
@@ -46,6 +46,91 @@
304803
 
304803
 #define DEFAULT_MAP_HASH_TABLE_SIZE	"1024"
304803
 
304803
+/* Config entry flags */
304803
+#define CONF_NONE			0x00000000
304803
+#define CONF_ENV			0x00000001
304803
+#define CONF_NOTUSED			0x00000002
304803
+#define CONF_NOTSUP			0x00000004
304803
+#define CONF_BROWSABLE_DIRS		0x00000008
304803
+#define CONF_MOUNT_TYPE_AUTOFS		0x00000010
304803
+#define CONF_SELECTORS_IN_DEFAULTS	0x00000020
304803
+#define CONF_NORMALIZE_HOSTNAMES	0x00000040
304803
+#define CONF_PROCESS_LOCK		0x00000080
304803
+#define CONF_RESTART_EXISTING_MOUNTS	0x00000100
304803
+#define CONF_SHOW_STATFS_ENTRIES	0x00000200
304803
+#define CONF_FULLY_QUALIFIED_HOSTS	0x00000400
304803
+#define CONF_UNMOUNT_ON_EXIT		0x00000800
304803
+#define CONF_AUTOFS_USE_LOFS		0x00001000
304803
+#define CONF_DOMAIN_STRIP		0x00002000
304803
+#define CONF_NORMALIZE_SLASHES		0x00004000
304803
+#define CONF_FORCED_UNMOUNTS 		0x00008000
304803
+
304803
+#define DEFAULT_AMD_NULL_VALUE			NULL
304803
+
304803
+#define DEFAULT_AMD_AUTO_ATTRCACHE		DEFAULT_AMD_NULL_VALUE
304803
+#define DEFAULT_AMD_AUTO_DIR			"/a"
304803
+#define DEFAULT_AMD_AUTOFS_USE_LOFS		"yes"
304803
+#define DEFAULT_AMD_BROWSABLE_DIRS		"no"
304803
+#define DEFAULT_AMD_CACHE_DURATION		"300"
304803
+#define DEFAULT_AMD_CLUSTER			DEFAULT_AMD_NULL_VALUE
304803
+#define DEFAULT_AMD_DEBUG_MTAB_FILE		DEFAULT_AMD_NULL_VALUE
304803
+#define DEFAULT_AMD_DEBUG_OPTIONS		DEFAULT_AMD_NULL_VALUE
304803
+#define DEFAULT_AMD_DISMOUNT_INTERVAL		DEFAULT_TIMEOUT
304803
+#define DEFAULT_AMD_DOMAIN_STRIP		"yes"
304803
+#define DEFAULT_AMD_EXEC_MAP_TIMEOUT		"10"
304803
+#define DEFAULT_AMD_FORCED_UMOUNTS		"no"
304803
+#define DEFAULT_AMD_FULLY_QUALIFIED_HOSTS	"no"
304803
+#define DEFAULT_AMD_FULL_OS			DEFAULT_AMD_NULL_VALUE
304803
+#define DEFAULT_AMD_HESIOD_BASE			"automount"
304803
+#define DEFAULT_AMD_KARCH			DEFAULT_AMD_NULL_VALUE
304803
+#define DEFAULT_AMD_LDAP_BASE			DEFAULT_AMD_NULL_VALUE
304803
+#define DEFAULT_AMD_LDAP_CACHE_MAXMEM		"131072"
304803
+#define DEFAULT_AMD_LDAP_CACHE_SECONDS		"0"
304803
+#define DEFAULT_AMD_LDAP_HOSTPORTS		DEFAULT_AMD_NULL_VALUE
304803
+#define DEFAULT_AMD_LDAP_PROTO_VERSION		"2"
304803
+#define DEFAULT_AMD_SUB_DOMAIN			DEFAULT_AMD_NULL_VALUE
304803
+#define DEFAULT_AMD_LOCALHOST_ADDRESS		"localhost"
304803
+#define DEFAULT_AMD_LOG_FILE			DEFAULT_AMD_NULL_VALUE
304803
+#define DEFAULT_AMD_LOG_OPTIONS			"defaults"
304803
+#define DEFAULT_AMD_MAP_DEFAULTS		DEFAULT_AMD_NULL_VALUE
304803
+#define DEFAULT_AMD_MAP_OPTIONS			DEFAULT_AMD_NULL_VALUE
304803
+#define DEFAULT_AMD_MAP_RELOAD_INTERVAL		"3600"
304803
+#define DEFAULT_AMD_MAP_TYPE			DEFAULT_AMD_NULL_VALUE
304803
+#define DEFAULT_AMD_MOUNT_TYPE			"autofs"
304803
+#define DEFAULT_AMD_PID_FILE			DEFAULT_AMD_NULL_VALUE
304803
+#define DEFAULT_AMD_PORTMAP_PROGRAM		DEFAULT_AMD_NULL_VALUE
304803
+#define DEFAULT_AMD_PREFERRED_AMQ_PORT		DEFAULT_AMD_NULL_VALUE
304803
+#define DEFAULT_AMD_NFS_ALLOW_ANY_INTERFACE	DEFAULT_AMD_NULL_VALUE
304803
+#define DEFAULT_AMD_NFS_ALLOW_INSECURE_PORT	DEFAULT_AMD_NULL_VALUE
304803
+#define DEFAULT_AMD_NFS_PROTO			DEFAULT_AMD_NULL_VALUE
304803
+#define DEFAULT_AMD_NFS_RETRANSMIT_COUNTER	DEFAULT_AMD_NULL_VALUE
304803
+#define DEFAULT_AMD_NFS_RETRANSMIT_COUNTER_UDP	DEFAULT_AMD_NULL_VALUE
304803
+#define DEFAULT_AMD_NFS_RETRANSMIT_COUNTER_TCP	DEFAULT_AMD_NULL_VALUE
304803
+#define DEFAULT_AMD_NFS_RETRANSMIT_COUNTER_TOPLVL DEFAULT_AMD_NULL_VALUE
304803
+#define DEFAULT_AMD_NFS_RETRY_INTERVAL		DEFAULT_AMD_NULL_VALUE
304803
+#define DEFAULT_AMD_NFS_RETRY_INTERVAL_UDP	DEFAULT_AMD_NULL_VALUE
304803
+#define DEFAULT_AMD_NFS_RETRY_INTERVAL_TCP	DEFAULT_AMD_NULL_VALUE
304803
+#define DEFAULT_AMD_NFS_RETRY_INTERVAL_TOPLVL	DEFAULT_AMD_NULL_VALUE
304803
+#define DEFAULT_AMD_NFS_VERS			DEFAULT_AMD_NULL_VALUE
304803
+#define DEFAULT_AMD_NFS_VERS_PING		DEFAULT_AMD_NULL_VALUE
304803
+#define DEFAULT_AMD_NIS_DOMAIN			DEFAULT_AMD_NULL_VALUE
304803
+#define DEFAULT_AMD_NORMALIZE_HOSTNAMES		"no"
304803
+#define DEFAULT_AMD_NORMALIZE_SLASHES		"yes"
304803
+#define DEFAULT_AMD_OS				DEFAULT_AMD_NULL_VALUE
304803
+#define DEFAULT_AMD_OSVER			DEFAULT_AMD_NULL_VALUE
304803
+#define DEFAULT_AMD_PLOCK			"yes"
304803
+#define DEFAULT_AMD_PRINT_PID			DEFAULT_AMD_NULL_VALUE
304803
+#define DEFAULT_AMD_PRINT_VERSION		DEFAULT_AMD_NULL_VALUE
304803
+#define DEFAULT_AMD_RESTART_MOUNTS		"no"
304803
+#define DEFAULT_AMD_SEARCH_PATH			DEFAULT_AMD_NULL_VALUE
304803
+#define DEFAULT_AMD_SELECTORS_IN_DEFAULTS	"no"
304803
+#define DEFAULT_AMD_SHOW_STATFS_ENTRIES		DEFAULT_AMD_NULL_VALUE
304803
+#define DEFAULT_AMD_SUN_MAP_SYNTAX		DEFAULT_AMD_NULL_VALUE
304803
+#define DEFAULT_AMD_TRUNCATE_LOG		DEFAULT_AMD_NULL_VALUE
304803
+#define DEFAULT_AMD_UMOUNT_ON_EXIT		"yes"
304803
+#define DEFAULT_AMD_USE_TCPWRAPPERS		DEFAULT_AMD_NULL_VALUE
304803
+#define DEFAULT_AMD_VENDOR			"unknown"
304803
+
304803
 #ifdef WITH_LDAP
304803
 struct ldap_schema;
304803
 struct ldap_searchdn;
304803
@@ -75,5 +160,31 @@ unsigned int defaults_get_umount_wait(void);
304803
 const char *defaults_get_auth_conf_file(void);
304803
 unsigned int defaults_get_map_hash_table_size(void);
304803
 
304803
+unsigned int conf_amd_mount_section_exists(const char *);
304803
+char *conf_amd_get_arch(void);
304803
+char *conf_amd_get_karch(void);
304803
+char *conf_amd_get_os(void);
304803
+char *conf_amd_get_os_ver(void);
304803
+char *conf_amd_get_vendor(void);
304803
+char *conf_amd_get_full_os(void);
304803
+char *conf_amd_get_auto_dir(void);
304803
+char *conf_amd_get_cluster(void);
304803
+unsigned int conf_amd_get_exec_map_timeout(void);
304803
+char *conf_amd_get_hesiod_base(void);
304803
+char *conf_amd_get_karch(void);
304803
+char *conf_amd_get_ldap_base(void);
304803
+char *conf_amd_get_ldap_hostports(void);
304803
+char *conf_amd_get_sub_domain(void);
304803
+char *conf_amd_get_localhost_address(void);
304803
+unsigned int conf_amd_get_log_options(void);
304803
+char *conf_amd_get_nfs_proto(void);
304803
+char *conf_amd_get_nis_domain(void);
304803
+unsigned int conf_amd_set_nis_domain(const char *);
304803
+char *conf_amd_get_map_defaults(const char *);
304803
+char *conf_amd_get_map_type(const char *);
304803
+char *conf_amd_get_search_path(const char *);
304803
+unsigned int conf_amd_get_dismount_interval(const char *);
304803
+unsigned long conf_amd_get_flags(const char *);
304803
+
304803
 #endif
304803
 
304803
diff --git a/lib/defaults.c b/lib/defaults.c
304803
index 29f3f00..bb304f3 100644
304803
--- a/lib/defaults.c
304803
+++ b/lib/defaults.c
304803
@@ -18,6 +18,7 @@
304803
 #include <stdio.h>
304803
 #include <ctype.h>
304803
 #include <string.h>
304803
+#include <sys/utsname.h>
304803
 #include <sys/stat.h>
304803
 
304803
 #include "config.h"
304803
@@ -30,9 +31,11 @@
304803
 #include "automount.h"
304803
 
304803
 #define AUTOFS_GLOBAL_SECTION		"autofs"
304803
+#define AMD_GLOBAL_SECTION		"amd"
304803
 
304803
 #define DEFAULT_CONFIG_FILE		AUTOFS_CONF_DIR "/autofs"
304803
 #define MAX_LINE_LEN			256
304803
+#define MAX_SECTION_NAME		MAX_LINE_LEN
304803
 
304803
 #define NAME_MASTER_MAP			"master_map_name"
304803
 
304803
@@ -61,20 +64,84 @@
304803
 
304803
 #define NAME_MAP_HASH_TABLE_SIZE	"map_hash_table_size"
304803
 
304803
+#define NAME_AMD_ARCH				"arch"
304803
+#define NAME_AMD_AUTO_ATTRCACHE			"auto_attrcache"
304803
+#define NAME_AMD_AUTO_DIR			"auto_dir"
304803
+#define NAME_AMD_AUTOFS_USE_LOFS		"autofs_use_lofs"
304803
+#define NAME_AMD_BROWSABLE_DIRS			"browsable_dirs"
304803
+#define NAME_AMD_CACHE_DURATION			"cache_duration"
304803
+#define NAME_AMD_CLUSTER			"cluster"
304803
+#define NAME_AMD_DEBUG_MTAB_FILE		"debug_mtab_file"
304803
+#define NAME_AMD_DEBUG_OPTIONS			"debug_options"
304803
+#define NAME_AMD_DISMOUNT_INTERVAL		"dismount_interval"
304803
+#define NAME_AMD_DOMAIN_STRIP			"domain_strip"
304803
+#define NAME_AMD_EXEC_MAP_TIMEOUT		"exec_map_timeout"
304803
+#define NAME_AMD_FORCED_UMOUNTS			"forced_unmounts"
304803
+#define NAME_AMD_FULLY_QUALIFIED_HOSTS		"fully_qualified_hosts"
304803
+#define NAME_AMD_FULL_OS			"full_os"
304803
+#define NAME_AMD_HESIOD_BASE			"hesiod_base"
304803
+#define NAME_AMD_KARCH				"karch"
304803
+#define NAME_AMD_LDAP_BASE			"ldap_base"
304803
+#define NAME_AMD_LDAP_CACHE_MAXMEM		"ldap_cache_maxmem"
304803
+#define NAME_AMD_LDAP_CACHE_SECONDS		"ldap_cache_seconds"
304803
+#define NAME_AMD_LDAP_HOSTPORTS			"ldap_hostports"
304803
+#define NAME_AMD_LDAP_PROTO_VERSION		"ldap_proto_version"
304803
+#define NAME_AMD_SUB_DOMAIN			"local_domain"
304803
+#define NAME_AMD_LOCALHOST_ADDRESS		"localhost_address"
304803
+#define NAME_AMD_LOG_FILE			"log_file"
304803
+#define NAME_AMD_LOG_OPTIONS			"log_options"
304803
+#define NAME_AMD_MAP_DEFAULTS			"map_defaults"
304803
+#define NAME_AMD_MAP_OPTIONS			"map_options"
304803
+#define NAME_AMD_MAP_RELOAD_INTERVAL		"map_reload_interval"
304803
+#define NAME_AMD_MAP_TYPE			"map_type"
304803
+#define NAME_AMD_MOUNT_TYPE			"mount_type"
304803
+#define NAME_AMD_PID_FILE			"pid_file"
304803
+#define NAME_AMD_PORTMAP_PROGRAM		"portmap_program"
304803
+#define NAME_AMD_PREFERRED_AMQ_PORT		"preferred_amq_port"
304803
+#define NAME_AMD_NFS_ALLOW_ANY_INTERFACE	"nfs_allow_any_interface"
304803
+#define NAME_AMD_NFS_ALLOW_INSECURE_PORT	"nfs_allow_insecure_port"
304803
+#define NAME_AMD_NFS_PROTO			"nfs_proto"
304803
+#define NAME_AMD_NFS_RETRANSMIT_COUNTER		"nfs_retransmit_counter"
304803
+#define NAME_AMD_NFS_RETRANSMIT_COUNTER_UDP	"nfs_retransmit_counter_udp"
304803
+#define NAME_AMD_NFS_RETRANSMIT_COUNTER_TCP	"nfs_retransmit_counter_tcp"
304803
+#define NAME_AMD_NFS_RETRANSMIT_COUNTER_TOPLVL	"nfs_retransmit_counter_toplvl"
304803
+#define NAME_AMD_NFS_RETRY_INTERVAL		"nfs_retry_interval"
304803
+#define NAME_AMD_NFS_RETRY_INTERVAL_UDP		"nfs_retry_interval_udp"
304803
+#define NAME_AMD_NFS_RETRY_INTERVAL_TCP		"nfs_retry_interval_tcp"
304803
+#define NAME_AMD_NFS_RETRY_INTERVAL_TOPLVL	"nfs_retry_interval_toplvl"
304803
+#define NAME_AMD_NFS_VERS			"nfs_vers"
304803
+#define NAME_AMD_NFS_VERS_PING			"nfs_vers_ping"
304803
+#define NAME_AMD_NIS_DOMAIN			"nis_domain"
304803
+#define NAME_AMD_NORMALIZE_HOSTNAMES		"normalize_hostnames"
304803
+#define NAME_AMD_NORMALIZE_SLASHES		"normalize_slashes"
304803
+#define NAME_AMD_OS				"os"
304803
+#define NAME_AMD_OSVER				"osver"
304803
+#define NAME_AMD_PLOCK				"plock"
304803
+#define NAME_AMD_PRINT_PID			"print_pid"
304803
+#define NAME_AMD_PRINT_VERSION			"print_version"
304803
+#define NAME_AMD_RESTART_MOUNTS			"restart_mounts"
304803
+#define NAME_AMD_SEARCH_PATH			"search_path"
304803
+#define NAME_AMD_SELECTORS_ON_DEFAULT		"selectors_on_default"
304803
+#define NAME_AMD_SELECTORS_IN_DEFAULTS		"selectors_in_defaults"
304803
+#define NAME_AMD_SHOW_STATFS_ENTRIES		"show_statfs_entries"
304803
+#define NAME_AMD_SUN_MAP_SYNTAX			"sun_map_syntax"
304803
+#define NAME_AMD_TRUNCATE_LOG			"truncate_log"
304803
+#define NAME_AMD_UMOUNT_ON_EXIT			"unmount_on_exit"
304803
+#define NAME_AMD_USE_TCPWRAPPERS		"use_tcpwrappers"
304803
+#define NAME_AMD_VENDOR				"vendor"
304803
+
304803
 /* Status returns */
304803
 #define CFG_OK		0x0000
304803
 #define CFG_FAIL	0x0001
304803
 #define CFG_EXISTS	0x0002
304803
 #define CFG_NOTFOUND	0x0004
304803
 
304803
-/* Config entry flags */
304803
-#define CONF_ENV		0x00000001
304803
-
304803
 #define CFG_TABLE_SIZE	128
304803
 
304803
 static const char *default_master_map_name = DEFAULT_MASTER_MAP_NAME;
304803
 static const char *default_auth_conf_file  = DEFAULT_AUTH_CONF_FILE;
304803
 static const char *autofs_gbl_sec	   = AUTOFS_GLOBAL_SECTION;
304803
+static const char *amd_gbl_sec		   = AMD_GLOBAL_SECTION;
304803
 
304803
 struct conf_option {
304803
 	char *section;
304803
@@ -288,30 +355,211 @@ error:
304803
 	return 0;
304803
 }
304803
 
304803
+static int conf_load_amd_defaults(void)
304803
+{
304803
+	struct utsname uts;
304803
+	const char *sec = amd_gbl_sec;
304803
+	char *host_os_name, *host_os_version, *host_arch;
304803
+	int ret;
304803
+
304803
+	if (uname(&uts)) {
304803
+		host_os_name = uts.sysname;
304803
+		host_os_version = uts.release;
304803
+		host_arch = uts.machine;
304803
+	} else {
304803
+		host_os_name = NULL;
304803
+		host_os_version = NULL;
304803
+		host_arch = NULL;
304803
+	}
304803
+
304803
+	ret = conf_update(sec, NAME_AMD_ARCH, host_arch, CONF_NONE);
304803
+	if (ret == CFG_FAIL)
304803
+		goto error;
304803
+
304803
+	ret = conf_update(sec, NAME_AMD_KARCH, host_arch, CONF_NONE);
304803
+	if (ret == CFG_FAIL)
304803
+		goto error;
304803
+
304803
+	ret = conf_update(sec, NAME_AMD_OS, host_os_name, CONF_NONE);
304803
+	if (ret == CFG_FAIL)
304803
+		goto error;
304803
+
304803
+	ret = conf_update(sec, NAME_AMD_OSVER, host_os_version, CONF_NONE);
304803
+	if (ret == CFG_FAIL)
304803
+		goto error;
304803
+
304803
+	ret = conf_update(sec, NAME_AMD_AUTO_DIR,
304803
+			  DEFAULT_AMD_AUTO_DIR, CONF_NONE);
304803
+	if (ret == CFG_FAIL)
304803
+		goto error;
304803
+
304803
+	ret = conf_update(sec, NAME_AMD_AUTOFS_USE_LOFS,
304803
+			  DEFAULT_AMD_AUTO_DIR, CONF_NONE);
304803
+	if (ret == CFG_FAIL)
304803
+		goto error;
304803
+
304803
+	ret = conf_update(sec, NAME_AMD_BROWSABLE_DIRS,
304803
+			  DEFAULT_AMD_BROWSABLE_DIRS, CONF_NONE);
304803
+	if (ret == CFG_FAIL)
304803
+		goto error;
304803
+
304803
+	ret = conf_update(sec, NAME_AMD_CLUSTER,
304803
+			  DEFAULT_AMD_CLUSTER, CONF_NONE);
304803
+	if (ret == CFG_FAIL)
304803
+		goto error;
304803
+
304803
+	/*
304803
+	 * DISMOUNT_INTERVAL defers to the autofs default so we
304803
+	 * don't set an amd default in the configuration.
304803
+	 */
304803
+	/*ret = conf_update(sec, NAME_AMD_DISMOUNT_INTERVAL,
304803
+			  DEFAULT_AMD_DISMOUNT_INTERVAL, CONF_NONE);
304803
+	if (ret == CFG_FAIL)
304803
+		goto error;*/
304803
+
304803
+	ret = conf_update(sec, NAME_AMD_DOMAIN_STRIP,
304803
+			  DEFAULT_AMD_DOMAIN_STRIP, CONF_NONE);
304803
+	if (ret == CFG_FAIL)
304803
+		goto error;
304803
+
304803
+	ret = conf_update(sec, NAME_AMD_EXEC_MAP_TIMEOUT,
304803
+			  DEFAULT_AMD_EXEC_MAP_TIMEOUT, CONF_NONE);
304803
+	if (ret == CFG_FAIL)
304803
+		goto error;
304803
+
304803
+	ret = conf_update(sec, NAME_AMD_FORCED_UMOUNTS,
304803
+			  DEFAULT_AMD_FORCED_UMOUNTS, CONF_NONE);
304803
+	if (ret == CFG_FAIL)
304803
+		goto error;
304803
+
304803
+	ret = conf_update(sec, NAME_AMD_FULLY_QUALIFIED_HOSTS,
304803
+			  DEFAULT_AMD_FULLY_QUALIFIED_HOSTS, CONF_NONE);
304803
+	if (ret == CFG_FAIL)
304803
+		goto error;
304803
+
304803
+	ret = conf_update(sec, NAME_AMD_FULL_OS,
304803
+			  DEFAULT_AMD_FULL_OS, CONF_NONE);
304803
+	if (ret == CFG_FAIL)
304803
+		goto error;
304803
+
304803
+	ret = conf_update(sec, NAME_AMD_HESIOD_BASE,
304803
+			  DEFAULT_AMD_HESIOD_BASE, CONF_NONE);
304803
+	if (ret == CFG_FAIL)
304803
+		goto error;
304803
+
304803
+	ret = conf_update(sec, NAME_AMD_KARCH, host_arch, CONF_NONE);
304803
+	if (ret == CFG_FAIL)
304803
+		goto error;
304803
+
304803
+	ret = conf_update(sec, NAME_AMD_LDAP_BASE,
304803
+			  DEFAULT_AMD_LDAP_BASE, CONF_NONE);
304803
+	if (ret == CFG_FAIL)
304803
+		goto error;
304803
+
304803
+	ret = conf_update(sec, NAME_AMD_LDAP_HOSTPORTS,
304803
+			  DEFAULT_AMD_LDAP_HOSTPORTS, CONF_NONE);
304803
+	if (ret == CFG_FAIL)
304803
+		goto error;
304803
+
304803
+	ret = conf_update(sec, NAME_AMD_SUB_DOMAIN,
304803
+			  DEFAULT_AMD_SUB_DOMAIN, CONF_NONE);
304803
+	if (ret == CFG_FAIL)
304803
+		goto error;
304803
+
304803
+	ret = conf_update(sec, NAME_AMD_LOCALHOST_ADDRESS,
304803
+			  DEFAULT_AMD_LOCALHOST_ADDRESS, CONF_NONE);
304803
+	if (ret == CFG_FAIL)
304803
+		goto error;
304803
+
304803
+	ret = conf_update(sec, NAME_AMD_LOG_OPTIONS,
304803
+			  DEFAULT_AMD_LOG_OPTIONS, CONF_NONE);
304803
+	if (ret == CFG_FAIL)
304803
+		goto error;
304803
+
304803
+	ret = conf_update(sec, NAME_AMD_MAP_DEFAULTS,
304803
+			  DEFAULT_AMD_MAP_DEFAULTS, CONF_NONE);
304803
+	if (ret == CFG_FAIL)
304803
+		goto error;
304803
+
304803
+	ret = conf_update(sec, NAME_AMD_MAP_TYPE,
304803
+			  DEFAULT_AMD_MAP_TYPE, CONF_NONE);
304803
+	if (ret == CFG_FAIL)
304803
+		goto error;
304803
+
304803
+	ret = conf_update(sec, NAME_AMD_NIS_DOMAIN,
304803
+			  DEFAULT_AMD_NIS_DOMAIN, CONF_NONE);
304803
+	if (ret == CFG_FAIL)
304803
+		goto error;
304803
+
304803
+	ret = conf_update(sec, NAME_AMD_NORMALIZE_HOSTNAMES,
304803
+			  DEFAULT_AMD_NORMALIZE_HOSTNAMES, CONF_NONE);
304803
+	if (ret == CFG_FAIL)
304803
+		goto error;
304803
+
304803
+	ret = conf_update(sec, NAME_AMD_NORMALIZE_SLASHES,
304803
+			  DEFAULT_AMD_NORMALIZE_SLASHES, CONF_NONE);
304803
+	if (ret == CFG_FAIL)
304803
+		goto error;
304803
+
304803
+	ret = conf_update(sec, NAME_AMD_OS, host_os_name, CONF_NONE);
304803
+	if (ret == CFG_FAIL)
304803
+		goto error;
304803
+
304803
+	ret = conf_update(sec, NAME_AMD_RESTART_MOUNTS,
304803
+			  DEFAULT_AMD_RESTART_MOUNTS, CONF_NONE);
304803
+	if (ret == CFG_FAIL)
304803
+		goto error;
304803
+
304803
+	ret = conf_update(sec, NAME_AMD_SEARCH_PATH,
304803
+			  DEFAULT_AMD_SEARCH_PATH, CONF_NONE);
304803
+	if (ret == CFG_FAIL)
304803
+		goto error;
304803
+
304803
+	/* selectors_on_default is depricated, use selectors_in_defaults */
304803
+	ret = conf_update(sec, NAME_AMD_SELECTORS_ON_DEFAULT,
304803
+			  DEFAULT_AMD_SELECTORS_IN_DEFAULTS, CONF_NONE);
304803
+	if (ret == CFG_FAIL)
304803
+		goto error;
304803
+
304803
+	ret = conf_update(sec, NAME_AMD_SELECTORS_IN_DEFAULTS,
304803
+			  DEFAULT_AMD_SELECTORS_IN_DEFAULTS, CONF_NONE);
304803
+	if (ret == CFG_FAIL)
304803
+		goto error;
304803
+
304803
+	ret = conf_update(sec, NAME_AMD_UMOUNT_ON_EXIT,
304803
+			  DEFAULT_AMD_UMOUNT_ON_EXIT, CONF_NONE);
304803
+	if (ret == CFG_FAIL)
304803
+		goto error;
304803
+
304803
+	ret = conf_update(sec, NAME_AMD_VENDOR,
304803
+			  DEFAULT_AMD_VENDOR, CONF_NONE);
304803
+	if (ret == CFG_FAIL)
304803
+		goto error;
304803
+
304803
+	return 1;
304803
+
304803
+error:
304803
+	return 0;
304803
+}
304803
+
304803
 static int conf_add(const char *section, const char *key, const char *value, unsigned long flags)
304803
 {
304803
 	struct conf_option *co;
304803
 	char *sec, *name, *val, *tmp;
304803
 	unsigned int size = CFG_TABLE_SIZE;
304803
 	u_int32_t index;
304803
-	int ret;
304803
-
304803
-	sec = name = val = NULL;
304803
-
304803
-	co = conf_lookup(section, key);
304803
-	if (co) {
304803
-		ret = CFG_EXISTS;
304803
-		goto error;
304803
-	}
304803
+	int ret = CFG_FAIL;
304803
 
304803
-	ret = CFG_FAIL;
304803
+	sec = name = val = tmp = NULL;
304803
 
304803
 	/* Environment overrides file value */
304803
-	if (((flags & CFG_ENV) && (tmp = getenv(key))) || value) {
304803
+	if (((flags & CONF_ENV) && (tmp = getenv(key))) || value) {
304803
 		if (tmp)
304803
 			val = strdup(tmp);
304803
-		else
304803
-			val = strdup(value);
304803
+		else {
304803
+			if (value)
304803
+				val = strdup(value);
304803
+		}
304803
 		if (!val)
304803
 			goto error;
304803
 	}
304803
@@ -335,7 +583,7 @@ static int conf_add(const char *section, const char *key, const char *value, uns
304803
 	co->next = NULL;
304803
 
304803
 	/* Don't change user set values in the environment */
304803
-	if (flags & CONF_ENV)
304803
+	if (flags & CONF_ENV && value)
304803
 		setenv(name, value, 0);
304803
 
304803
 	index = hash(key, size);
304803
@@ -386,7 +634,7 @@ static void conf_delete(const char *section, const char *key)
304803
 
304803
 	free(co->section);
304803
 	free(co->name);
304803
-	if (co->value);
304803
+	if (co->value)
304803
 		free(co->value);
304803
 	free(co);
304803
 }
304803
@@ -403,13 +651,15 @@ static int conf_update(const char *section,
304803
 	if (!co)
304803
 		ret = conf_add(section, key, value, flags);
304803
 	else {
304803
-		char *val = NULL, *tmp;
304803
+		char *val = NULL, *tmp = NULL;
304803
 		/* Environment overrides file value */
304803
 		if (((flags & CONF_ENV) && (tmp = getenv(key))) || value) {
304803
 			if (tmp)
304803
 				val = strdup(tmp);
304803
-			else
304803
-				val = strdup(value);
304803
+			else {
304803
+				if (value)
304803
+					val = strdup(value);
304803
+			}
304803
 			if (!val)
304803
 				goto error;
304803
 		}
304803
@@ -419,7 +669,7 @@ static int conf_update(const char *section,
304803
 		if (flags)
304803
 			co->flags = flags;
304803
 		/* Don't change user set values in the environment */
304803
-		if (flags & CONF_ENV)
304803
+		if (flags & CONF_ENV && value)
304803
 			setenv(key, value, 0);
304803
 	}
304803
 
304803
@@ -456,15 +706,39 @@ static struct conf_option *conf_lookup(const char *section, const char *key)
304803
 	return co;
304803
 }
304803
 
304803
+static unsigned int conf_section_exists(const char *section)
304803
+{
304803
+	struct conf_option *co;
304803
+	int ret;
304803
+
304803
+	if (!section)
304803
+		return 0;
304803
+
304803
+	ret = 0;
304803
+	pthread_mutex_lock(&conf_mutex);
304803
+	co = conf_lookup(section, section);
304803
+	if (co)
304803
+		ret = 1;
304803
+	pthread_mutex_unlock(&conf_mutex);
304803
+
304803
+	return ret;
304803
+}
304803
+
304803
 /*
304803
  * We've changed the key names so we need to check for the
304803
  * config key and it's old name for backward conpatibility.
304803
 */
304803
-static int check_set_config_value(const char *res, const char *value)
304803
+static int check_set_config_value(const char *section,
304803
+				  const char *res, const char *value)
304803
 {
304803
-	const char *sec = autofs_gbl_sec;
304803
+	const char *sec;
304803
 	int ret;
304803
 
304803
+	if (section)
304803
+		sec = section;
304803
+	else
304803
+		sec = autofs_gbl_sec;
304803
+
304803
 	if (!strcasecmp(res, NAME_LDAP_URI))
304803
 		ret = conf_add(sec, res, value, 0);
304803
 	else if (!strcasecmp(res, NAME_SEARCH_BASE))
304803
@@ -475,14 +749,15 @@ static int check_set_config_value(const char *res, const char *value)
304803
 	return ret;
304803
 }
304803
 
304803
-static int parse_line(char *line, char **res, char **value)
304803
+static int parse_line(char *line, char **sec, char **res, char **value)
304803
 {
304803
 	char *key, *val, *trailer;
304803
+	char *tmp;
304803
 	int len;
304803
 
304803
 	key = line;
304803
 
304803
-	if (*key == '#' || !isalpha(*key))
304803
+	if (*key == '#' || (*key != '[' && !isalpha(*key)))
304803
 		return 0;
304803
 
304803
 	while (*key && *key == ' ')
304803
@@ -491,11 +766,34 @@ static int parse_line(char *line, char **res, char **value)
304803
 	if (!*key)
304803
 		return 0;
304803
 
304803
+	if (*key == '[') {
304803
+		char *tmp;
304803
+		while (*key && (*key == '[' || *key == ' '))
304803
+			key++;
304803
+		tmp = strchr(key, ']');
304803
+		if (!tmp)
304803
+			return 0;
304803
+		*tmp = ' ';
304803
+		while (*tmp && *tmp == ' ') {
304803
+			*tmp = '\0';
304803
+			tmp--;
304803
+		}
304803
+		*sec = key;
304803
+		*res = NULL;
304803
+		*value = NULL;
304803
+		return 1;
304803
+	}
304803
+
304803
 	if (!(val = strchr(key, '=')))
304803
 		return 0;
304803
 
304803
+	tmp = val;
304803
+
304803
 	*val++ = '\0';
304803
 
304803
+	while (*(--tmp) == ' ')
304803
+		*tmp = '\0';
304803
+
304803
 	while (*val && (*val == '"' || isblank(*val)))
304803
 		val++;
304803
 
304803
@@ -515,12 +813,97 @@ static int parse_line(char *line, char **res, char **value)
304803
 	while (*trailer && (*trailer == '"' || isblank(*trailer)))
304803
 		*(trailer--) = '\0';;
304803
 
304803
+	*sec = NULL;
304803
 	*res = key;
304803
 	*value = val;
304803
 
304803
 	return 1;
304803
 }
304803
 
304803
+static int read_config(unsigned int to_syslog, FILE *f, const char *name)
304803
+{
304803
+	char buf[MAX_LINE_LEN];
304803
+	char secbuf[MAX_SECTION_NAME];
304803
+	char *new_sec;
304803
+	char *res;
304803
+
304803
+	new_sec = NULL;
304803
+	while ((res = fgets(buf, MAX_LINE_LEN, f))) {
304803
+		char *sec, *key, *value;
304803
+		sec = key = value = NULL;
304803
+		if (!parse_line(res, &sec, &key, &value))
304803
+			continue;
304803
+		if (sec) {
304803
+			strcpy(secbuf, sec);
304803
+			new_sec = &secbuf[0];
304803
+			conf_update(sec, sec, NULL, 0);
304803
+			continue;
304803
+		}
304803
+		if (!strcasecmp(res, NAME_AMD_MOUNT_TYPE)) {
304803
+			message(to_syslog,
304803
+				"%s is always autofs, ignored", res);
304803
+			continue;
304803
+		}
304803
+		if (!strcasecmp(res, NAME_AMD_PID_FILE)) {
304803
+			message(to_syslog,
304803
+				"%s must be specified as a command line"
304803
+				" option, ignored", res);
304803
+			continue;
304803
+		}
304803
+		if (!strcasecmp(res, NAME_AMD_RESTART_MOUNTS)) {
304803
+			message(to_syslog,
304803
+				"%s is always done by autofs, ignored", res);
304803
+			continue;
304803
+		}
304803
+		if (!strcasecmp(res, NAME_AMD_USE_TCPWRAPPERS) ||
304803
+		    !strcasecmp(res, NAME_AMD_AUTO_ATTRCACHE) ||
304803
+		    !strcasecmp(res, NAME_AMD_PRINT_PID) ||
304803
+		    !strcasecmp(res, NAME_AMD_PRINT_VERSION) ||
304803
+		    !strcasecmp(res, NAME_AMD_LOG_FILE) ||
304803
+		    !strcasecmp(res, NAME_AMD_PREFERRED_AMQ_PORT) ||
304803
+		    !strcasecmp(res, NAME_AMD_TRUNCATE_LOG) ||
304803
+		    !strcasecmp(res, NAME_AMD_DEBUG_MTAB_FILE) ||
304803
+		    !strcasecmp(res, NAME_AMD_DEBUG_OPTIONS) ||
304803
+		    !strcasecmp(res, NAME_AMD_SUN_MAP_SYNTAX) ||
304803
+		    !strcasecmp(res, NAME_AMD_PORTMAP_PROGRAM) ||
304803
+		    !strcasecmp(res, NAME_AMD_NFS_VERS) ||
304803
+		    !strcasecmp(res, NAME_AMD_NFS_VERS_PING) ||
304803
+		    !strcasecmp(res, NAME_AMD_NFS_PROTO) ||
304803
+		    !strcasecmp(res, NAME_AMD_NFS_ALLOW_ANY_INTERFACE) ||
304803
+		    !strcasecmp(res, NAME_AMD_NFS_ALLOW_INSECURE_PORT) ||
304803
+		    !strcasecmp(res, NAME_AMD_NFS_RETRANSMIT_COUNTER) ||
304803
+		    !strcasecmp(res, NAME_AMD_NFS_RETRANSMIT_COUNTER_UDP) ||
304803
+		    !strcasecmp(res, NAME_AMD_NFS_RETRANSMIT_COUNTER_TCP) ||
304803
+		    !strcasecmp(res, NAME_AMD_NFS_RETRANSMIT_COUNTER_TOPLVL) ||
304803
+		    !strcasecmp(res, NAME_AMD_NFS_RETRY_INTERVAL) ||
304803
+		    !strcasecmp(res, NAME_AMD_NFS_RETRY_INTERVAL_UDP) ||
304803
+		    !strcasecmp(res, NAME_AMD_NFS_RETRY_INTERVAL_TCP) ||
304803
+		    !strcasecmp(res, NAME_AMD_NFS_RETRY_INTERVAL_TOPLVL) ||
304803
+		    !strcasecmp(res, NAME_AMD_LDAP_CACHE_MAXMEM) ||
304803
+		    !strcasecmp(res, NAME_AMD_LDAP_CACHE_SECONDS) ||
304803
+		    !strcasecmp(res, NAME_AMD_LDAP_PROTO_VERSION) ||
304803
+		    !strcasecmp(res, NAME_AMD_SHOW_STATFS_ENTRIES) ||
304803
+		    !strcasecmp(res, NAME_AMD_CACHE_DURATION) ||
304803
+		    !strcasecmp(res, NAME_AMD_MAP_RELOAD_INTERVAL) ||
304803
+		    !strcasecmp(res, NAME_AMD_MAP_OPTIONS) ||
304803
+		    !strcasecmp(res, NAME_AMD_PLOCK)) {
304803
+			message(to_syslog,
304803
+				"%s is not used by autofs, ignored", res);
304803
+			continue;
304803
+		}
304803
+		check_set_config_value(new_sec, key, value);
304803
+	}
304803
+
304803
+	if (!feof(f) || ferror(f)) {
304803
+		message(to_syslog,
304803
+			"fgets returned error %d while reading config %s",
304803
+			ferror(f), name);
304803
+		return 0;
304803
+	}
304803
+
304803
+	return 0;
304803
+}
304803
+
304803
 /*
304803
  * Read config env variables and check they have been set.
304803
  *
304803
@@ -531,23 +914,11 @@ static int parse_line(char *line, char **res, char **value)
304803
 unsigned int defaults_read_config(unsigned int to_syslog)
304803
 {
304803
 	FILE *f;
304803
-	char buf[MAX_LINE_LEN];
304803
 	struct stat stb;
304803
-	char *res;
304803
 	int ret;
304803
 
304803
-	f = open_fopen_r(DEFAULT_CONFIG_FILE);
304803
-	if (!f)
304803
-		return 0;
304803
-
304803
 	pthread_mutex_lock(&conf_mutex);
304803
-	if (config) {
304803
-		if (fstat(fileno(f), &stb) != -1) {
304803
-			/* Config hasn't been updated */
304803
-			if (stb.st_mtime <= config->modified)
304803
-				goto out;
304803
-		}
304803
-	} else {
304803
+	if (!config) {
304803
 		if (conf_init()) {
304803
 			pthread_mutex_unlock(&conf_mutex);
304803
 			message(to_syslog, "failed to init config");
304803
@@ -563,29 +934,39 @@ unsigned int defaults_read_config(unsigned int to_syslog)
304803
 		return 0;
304803
 	}
304803
 
304803
-	while ((res = fgets(buf, MAX_LINE_LEN, f))) {
304803
-		char *key, *value;
304803
-		if (!parse_line(res, &key, &value))
304803
-			continue;
304803
-		check_set_config_value(key, value);
304803
+	ret = conf_load_amd_defaults();
304803
+	if (!ret) {
304803
+		pthread_mutex_unlock(&conf_mutex);
304803
+		message(to_syslog, "failed to reset amd default config");
304803
+		return 0;
304803
+	}
304803
+
304803
+	f = open_fopen_r(DEFAULT_CONFIG_FILE);
304803
+	if (!f) {
304803
+		message(to_syslog, "failed to to open config %s",
304803
+			DEFAULT_CONFIG_FILE);
304803
+		goto out;
304803
+	}
304803
+
304803
+	if (fstat(fileno(f), &stb) != -1) {
304803
+		/* Config hasn't been updated */
304803
+		if (stb.st_mtime <= config->modified) {
304803
+			fclose(f);
304803
+			goto out;
304803
+		}
304803
 	}
304803
 
304803
+	ret = read_config(to_syslog, f, DEFAULT_CONFIG_FILE);
304803
+
304803
 	if (fstat(fileno(f), &stb) != -1)
304803
 		config->modified = stb.st_mtime;
304803
 	else
304803
 		message(to_syslog, "failed to update config modified time");
304803
 
304803
-	if (!feof(f) || ferror(f)) {
304803
-		pthread_mutex_unlock(&conf_mutex);
304803
-		message(to_syslog,
304803
-			"fgets returned error %d while reading %s",
304803
-			ferror(f), DEFAULT_CONFIG_FILE);
304803
-		fclose(f);
304803
-		return 0;
304803
-	}
304803
+	fclose(f);
304803
+
304803
 out:
304803
 	pthread_mutex_unlock(&conf_mutex);
304803
-	fclose(f);
304803
 	return 1;
304803
 }
304803
 
304803
@@ -1101,3 +1482,269 @@ unsigned int defaults_get_map_hash_table_size(void)
304803
 	return (unsigned int) size;
304803
 }
304803
 
304803
+unsigned int conf_amd_mount_section_exists(const char *section)
304803
+{
304803
+	return conf_section_exists(section);
304803
+}
304803
+
304803
+char *conf_amd_get_arch(void)
304803
+{
304803
+	return conf_get_string(amd_gbl_sec, NAME_AMD_ARCH);
304803
+}
304803
+
304803
+char *conf_amd_get_karch(void)
304803
+{
304803
+	char *tmp = conf_get_string(amd_gbl_sec, NAME_AMD_KARCH);
304803
+	if (!tmp)
304803
+		tmp = conf_amd_get_arch();
304803
+
304803
+	return tmp;
304803
+}
304803
+
304803
+char *conf_amd_get_os(void)
304803
+{
304803
+	return conf_get_string(amd_gbl_sec, NAME_AMD_OS);
304803
+}
304803
+
304803
+char *conf_amd_get_os_ver(void)
304803
+{
304803
+	return conf_get_string(amd_gbl_sec, NAME_AMD_OSVER);
304803
+}
304803
+
304803
+char *conf_amd_get_vendor(void)
304803
+{
304803
+	return conf_get_string(amd_gbl_sec, NAME_AMD_VENDOR);
304803
+}
304803
+
304803
+char *conf_amd_get_full_os(void)
304803
+{
304803
+	return conf_get_string(amd_gbl_sec, NAME_AMD_FULL_OS);
304803
+}
304803
+
304803
+char *conf_amd_get_auto_dir(void)
304803
+{
304803
+	char *tmp = conf_get_string(amd_gbl_sec, NAME_AMD_AUTO_DIR);
304803
+	if (!tmp)
304803
+		return strdup(DEFAULT_AMD_AUTO_DIR);
304803
+
304803
+	return tmp;
304803
+}
304803
+
304803
+char *conf_amd_get_cluster(void)
304803
+{
304803
+	return conf_get_string(amd_gbl_sec, NAME_AMD_CLUSTER);
304803
+}
304803
+
304803
+unsigned int conf_amd_get_exec_map_timeout(void)
304803
+{
304803
+	long tmp = conf_get_number(amd_gbl_sec, NAME_AMD_EXEC_MAP_TIMEOUT);
304803
+	if (tmp == -1)
304803
+		tmp = atoi(DEFAULT_AMD_EXEC_MAP_TIMEOUT);
304803
+
304803
+	return (unsigned int) tmp;
304803
+}
304803
+
304803
+char *conf_amd_get_hesiod_base(void)
304803
+{
304803
+	return conf_get_string(amd_gbl_sec, NAME_AMD_HESIOD_BASE);
304803
+}
304803
+
304803
+char *conf_amd_get_ldap_base(void)
304803
+{
304803
+	return conf_get_string(amd_gbl_sec, NAME_AMD_LDAP_BASE);
304803
+}
304803
+
304803
+char *conf_amd_get_ldap_hostports(void)
304803
+{
304803
+	return conf_get_string(amd_gbl_sec, NAME_AMD_LDAP_HOSTPORTS);
304803
+}
304803
+
304803
+unsigned int conf_amd_get_ldap_proto_version(void)
304803
+{
304803
+	long tmp = conf_get_number(amd_gbl_sec, NAME_AMD_LDAP_PROTO_VERSION);
304803
+	if (tmp == -1)
304803
+		tmp = atoi(DEFAULT_AMD_LDAP_PROTO_VERSION);
304803
+
304803
+	return (unsigned int) tmp;
304803
+}
304803
+
304803
+char *conf_amd_get_sub_domain(void)
304803
+{
304803
+	return conf_get_string(amd_gbl_sec, NAME_AMD_SUB_DOMAIN);
304803
+}
304803
+
304803
+char *conf_amd_get_localhost_address(void)
304803
+{
304803
+	return conf_get_string(amd_gbl_sec, NAME_AMD_LOCALHOST_ADDRESS);
304803
+}
304803
+
304803
+unsigned int conf_amd_get_log_options(void)
304803
+{
304803
+	int log_level = -1;
304803
+	char *tmp = conf_get_string(amd_gbl_sec, NAME_AMD_LOG_OPTIONS);
304803
+	if (tmp) {
304803
+		if (strstr(tmp, "debug") || strstr(tmp, "all")) {
304803
+			if (log_level < LOG_DEBUG)
304803
+				log_level = LOG_DEBUG;
304803
+		}
304803
+		if (strstr(tmp, "info") ||
304803
+		    strstr(tmp, "user") ||
304803
+		    strcmp(tmp, "defaults")) {
304803
+			if (log_level < LOG_INFO)
304803
+				log_level = LOG_INFO;
304803
+		}
304803
+		if (strstr(tmp, "notice")) {
304803
+			if (log_level < LOG_NOTICE)
304803
+				log_level = LOG_NOTICE;
304803
+		}
304803
+		if (strstr(tmp, "warn") ||
304803
+		    strstr(tmp, "map") ||
304803
+		    strstr(tmp, "stats") ||
304803
+		    strstr(tmp, "warning")) {
304803
+			if (log_level < LOG_WARNING)
304803
+				log_level = LOG_WARNING;
304803
+		}
304803
+		if (strstr(tmp, "error")) {
304803
+			if (log_level < LOG_ERR)
304803
+				log_level = LOG_ERR;
304803
+		}
304803
+		if (strstr(tmp, "fatal")) {
304803
+			if (log_level < LOG_CRIT)
304803
+				log_level = LOG_CRIT;
304803
+		}
304803
+	}
304803
+
304803
+	if (log_level == -1)
304803
+		log_level = LOG_ERR;
304803
+
304803
+	return (unsigned int) log_level;
304803
+}
304803
+
304803
+char *conf_amd_get_nis_domain(void)
304803
+{
304803
+	return conf_get_string(amd_gbl_sec, NAME_AMD_NIS_DOMAIN);
304803
+}
304803
+
304803
+unsigned int conf_amd_set_nis_domain(const char *domain)
304803
+{
304803
+	int ret;
304803
+	ret = conf_update(amd_gbl_sec, NAME_AMD_NIS_DOMAIN, domain, CONF_NONE);
304803
+
304803
+	return (unsigned int) ret;
304803
+}
304803
+
304803
+char *conf_amd_get_map_defaults(const char *section)
304803
+{
304803
+	char *tmp = NULL;
304803
+	if (section)
304803
+		tmp = conf_get_string(section, NAME_AMD_MAP_DEFAULTS);
304803
+	if (!tmp)
304803
+		tmp = conf_get_string(amd_gbl_sec, NAME_AMD_MAP_DEFAULTS);
304803
+
304803
+	return tmp;
304803
+}
304803
+
304803
+char *conf_amd_get_map_type(const char *section)
304803
+{
304803
+	char *tmp = NULL;
304803
+	if (section)
304803
+		tmp = conf_get_string(section, NAME_AMD_MAP_TYPE);
304803
+	if (!tmp)
304803
+		tmp = conf_get_string(amd_gbl_sec, NAME_AMD_MAP_TYPE);
304803
+
304803
+	return tmp;
304803
+}
304803
+
304803
+char *conf_amd_get_search_path(const char *section)
304803
+{
304803
+	char *tmp = NULL;
304803
+	if (section)
304803
+		tmp = conf_get_string(section, NAME_AMD_SEARCH_PATH);
304803
+	if (!tmp)
304803
+		tmp = conf_get_string(amd_gbl_sec, NAME_AMD_SEARCH_PATH);
304803
+
304803
+	return tmp;
304803
+}
304803
+
304803
+unsigned int conf_amd_get_dismount_interval(const char *section)
304803
+{
304803
+	long tmp = -1;
304803
+	if (section)
304803
+		tmp = conf_get_number(section, NAME_AMD_DISMOUNT_INTERVAL);
304803
+	if (tmp == -1)
304803
+		tmp = conf_get_number(amd_gbl_sec, NAME_AMD_DISMOUNT_INTERVAL);
304803
+	if (tmp == -1)
304803
+		tmp = defaults_get_timeout();
304803
+	/*
304803
+	 * This won't happen as defaults_get_timeout() will return
304803
+	 * the autofs setting which is used if no other setting is
304803
+	 * found.
304803
+	 */
304803
+	if (tmp == -1)
304803
+		tmp = atoi(DEFAULT_TIMEOUT);
304803
+
304803
+	return (unsigned int) tmp;
304803
+}
304803
+
304803
+unsigned long conf_amd_get_flags(const char *section)
304803
+{
304803
+	const char *amd = amd_gbl_sec;
304803
+	unsigned long flags, tmp;
304803
+
304803
+	/* Always true for us */
304803
+	flags = CONF_MOUNT_TYPE_AUTOFS;
304803
+
304803
+	tmp = -1;
304803
+	if (section)
304803
+		tmp = conf_get_yesno(section, NAME_AMD_BROWSABLE_DIRS);
304803
+	if (tmp == -1)
304803
+		tmp = conf_get_yesno(amd, NAME_AMD_BROWSABLE_DIRS);
304803
+	if (tmp)
304803
+		flags |= CONF_BROWSABLE_DIRS;
304803
+
304803
+	tmp = -1;
304803
+	if (section)
304803
+		tmp = conf_get_yesno(section, NAME_AMD_SELECTORS_IN_DEFAULTS);
304803
+	if (tmp == -1)
304803
+		tmp = conf_get_yesno(amd, NAME_AMD_SELECTORS_IN_DEFAULTS);
304803
+	if (tmp)
304803
+		flags |= CONF_SELECTORS_IN_DEFAULTS;
304803
+
304803
+	tmp = conf_get_yesno(amd, NAME_AMD_NORMALIZE_HOSTNAMES);
304803
+	if (tmp)
304803
+		flags |= CONF_NORMALIZE_HOSTNAMES;
304803
+
304803
+	tmp = conf_get_yesno(amd, NAME_AMD_RESTART_MOUNTS);
304803
+	if (tmp)
304803
+		flags |= CONF_RESTART_EXISTING_MOUNTS;
304803
+
304803
+	tmp = conf_get_yesno(amd, NAME_AMD_FULLY_QUALIFIED_HOSTS);
304803
+	if (tmp)
304803
+		flags |= CONF_FULLY_QUALIFIED_HOSTS;
304803
+
304803
+	tmp = conf_get_yesno(amd, NAME_AMD_UMOUNT_ON_EXIT);
304803
+	if (tmp)
304803
+		flags |= CONF_UNMOUNT_ON_EXIT;
304803
+
304803
+	tmp = -1;
304803
+	if (section)
304803
+		tmp = conf_get_yesno(section, NAME_AMD_AUTOFS_USE_LOFS);
304803
+	if (tmp == -1)
304803
+		tmp = conf_get_yesno(amd, NAME_AMD_AUTOFS_USE_LOFS);
304803
+	if (tmp)
304803
+		flags |= CONF_AUTOFS_USE_LOFS;
304803
+
304803
+	tmp = conf_get_yesno(amd, NAME_AMD_DOMAIN_STRIP);
304803
+	if (tmp)
304803
+		flags |= CONF_DOMAIN_STRIP;
304803
+
304803
+	tmp = conf_get_yesno(amd, NAME_AMD_NORMALIZE_SLASHES);
304803
+	if (tmp)
304803
+		flags |= CONF_NORMALIZE_SLASHES;
304803
+
304803
+	tmp = conf_get_yesno(amd, NAME_AMD_FORCED_UMOUNTS);
304803
+	if (tmp)
304803
+		flags |= CONF_FORCED_UNMOUNTS;
304803
+
304803
+	return flags;
304803
+}