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

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