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

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