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

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