Blame SOURCES/autofs-5.0.9-amd-lookup-rework-config-handling.patch

304803
autofs-5.0.9 - amd lookup rework config handling
304803
304803
From: Ian Kent <ikent@redhat.com>
304803
304803
Re-work the autofs configuration sub-system to use sections.
304803
Initially this means we have an anonomous section (for backward
304803
compatibility) and an "autofs" section for the autofs global
304803
configuration.
304803
---
304803
 daemon/automount.c  |    1 
304803
 include/automount.h |   18 +
304803
 include/defaults.h  |   27 +-
304803
 lib/cache.c         |   19 -
304803
 lib/defaults.c      |  836 +++++++++++++++++++++++++++++++++++++--------------
304803
 5 files changed, 644 insertions(+), 257 deletions(-)
304803
304803
diff --git a/daemon/automount.c b/daemon/automount.c
304803
index 0dd6477..fd5a19b 100644
304803
--- a/daemon/automount.c
304803
+++ b/daemon/automount.c
304803
@@ -2339,6 +2339,7 @@ int main(int argc, char *argv[])
304803
 		unlink(pid_file);
304803
 		pid_file = NULL;
304803
 	}
304803
+	defaults_conf_release();
304803
 	closelog();
304803
 	release_flag_file();
304803
 	macro_free_global_table();
304803
diff --git a/include/automount.h b/include/automount.h
304803
index 1aabfa4..6da1926 100644
304803
--- a/include/automount.h
304803
+++ b/include/automount.h
304803
@@ -136,6 +136,24 @@ struct autofs_point;
304803
 #define UMOUNT_RETRIES		8
304803
 #define EXPIRE_RETRIES		3
304803
 
304803
+static u_int32_t inline hash(const char *key, unsigned int size)
304803
+{
304803
+	u_int32_t hashval;
304803
+	char *s = (char *) key;
304803
+
304803
+	for (hashval = 0; *s != '\0';) {
304803
+		hashval += (unsigned char) *s++;
304803
+		hashval += (hashval << 10);
304803
+		hashval ^= (hashval >> 6);
304803
+	}
304803
+
304803
+	hashval += (hashval << 3);
304803
+	hashval ^= (hashval >> 11);
304803
+	hashval += (hashval << 15);
304803
+
304803
+	return hashval % size;
304803
+}
304803
+
304803
 struct mapent_cache {
304803
 	pthread_rwlock_t rwlock;
304803
 	unsigned int size;
304803
diff --git a/include/defaults.h b/include/defaults.h
304803
index 871e14b..3bfcd49 100644
304803
--- a/include/defaults.h
304803
+++ b/include/defaults.h
304803
@@ -2,7 +2,9 @@
304803
  *
304803
  *  defaults.h - system initialization defaults.
304803
  *
304803
- *   Copyright 2006 Ian Kent <raven@themaw.net>
304803
+ *   Copyright 2013 Red Hat, Inc.
304803
+ *   Copyright 2006, 2013 Ian Kent <raven@themaw.net>
304803
+ *   All rights reserved.
304803
  *
304803
  *   This program is free software; you can redistribute it and/or modify
304803
  *   it under the terms of the GNU General Public License as published by
304803
@@ -22,15 +24,15 @@
304803
 
304803
 #define DEFAULT_MASTER_MAP_NAME	"auto.master"
304803
 
304803
-#define DEFAULT_TIMEOUT			600
304803
-#define DEFAULT_NEGATIVE_TIMEOUT	60
304803
-#define DEFAULT_MOUNT_WAIT		-1
304803
-#define DEFAULT_UMOUNT_WAIT		12
304803
-#define DEFAULT_BROWSE_MODE		1
304803
-#define DEFAULT_LOGGING			0
304803
+#define DEFAULT_TIMEOUT			"600"
304803
+#define DEFAULT_NEGATIVE_TIMEOUT	"60"
304803
+#define DEFAULT_MOUNT_WAIT		"-1"
304803
+#define DEFAULT_UMOUNT_WAIT		"12"
304803
+#define DEFAULT_BROWSE_MODE		"1"
304803
+#define DEFAULT_LOGGING			"none"
304803
 
304803
-#define DEFAULT_LDAP_TIMEOUT		-1
304803
-#define DEFAULT_LDAP_NETWORK_TIMEOUT	8
304803
+#define DEFAULT_LDAP_TIMEOUT		"-1"
304803
+#define DEFAULT_LDAP_NETWORK_TIMEOUT	"8"
304803
 
304803
 #define DEFAULT_MAP_OBJ_CLASS		"nisMap"
304803
 #define DEFAULT_ENTRY_OBJ_CLASS		"nisObject"
304803
@@ -38,11 +40,11 @@
304803
 #define DEFAULT_ENTRY_ATTR		"cn"
304803
 #define DEFAULT_VALUE_ATTR		"nisMapEntry"
304803
 
304803
-#define DEFAULT_NFS_MOUNT_PROTOCOL	3
304803
-#define DEFAULT_APPEND_OPTIONS		1
304803
+#define DEFAULT_MOUNT_NFS_DEFAULT_PROTOCOL	"3"
304803
+#define DEFAULT_APPEND_OPTIONS		"1"
304803
 #define DEFAULT_AUTH_CONF_FILE		AUTOFS_MAP_DIR "/autofs_ldap_auth.conf"
304803
 
304803
-#define DEFAULT_MAP_HASH_TABLE_SIZE	1024
304803
+#define DEFAULT_MAP_HASH_TABLE_SIZE	"1024"
304803
 
304803
 #ifdef WITH_LDAP
304803
 struct ldap_schema;
304803
@@ -56,6 +58,7 @@ struct ldap_schema *defaults_get_schema(void);
304803
 #endif
304803
 
304803
 unsigned int defaults_read_config(unsigned int);
304803
+void defaults_conf_release(void);
304803
 const char *defaults_get_master_map(void);
304803
 int defaults_master_set(void);
304803
 unsigned int defaults_get_timeout(void);
304803
diff --git a/lib/cache.c b/lib/cache.c
304803
index f2efcd3..9af1709 100644
304803
--- a/lib/cache.c
304803
+++ b/lib/cache.c
304803
@@ -20,7 +20,6 @@
304803
 #include <ctype.h>
304803
 #include <stdio.h>
304803
 #include <sys/param.h>
304803
-#include <sys/types.h>
304803
 #include <sys/stat.h>
304803
 
304803
 #include "automount.h"
304803
@@ -362,24 +361,6 @@ struct mapent_cache *cache_init_null_cache(struct master *master)
304803
 	return mc;
304803
 }
304803
 
304803
-static u_int32_t hash(const char *key, unsigned int size)
304803
-{
304803
-	u_int32_t hashval;
304803
-	char *s = (char *) key;
304803
-
304803
-	for (hashval = 0; *s != '\0';) {
304803
-		hashval += (unsigned char) *s++;
304803
-		hashval += (hashval << 10);
304803
-		hashval ^= (hashval >> 6);
304803
-	}
304803
-
304803
-	hashval += (hashval << 3);
304803
-	hashval ^= (hashval >> 11);
304803
-	hashval += (hashval << 15);
304803
-
304803
-	return hashval % size;
304803
-}
304803
-
304803
 static u_int32_t ino_hash(dev_t dev, ino_t ino, unsigned int size)
304803
 {
304803
 	u_int32_t hashval;
304803
diff --git a/lib/defaults.c b/lib/defaults.c
304803
index 7c65387..29f3f00 100644
304803
--- a/lib/defaults.c
304803
+++ b/lib/defaults.c
304803
@@ -2,7 +2,9 @@
304803
  *
304803
  *  defaults.h - system initialization defaults.
304803
  *
304803
- *   Copyright 2006 Ian Kent <raven@themaw.net> - All Rights Reserved
304803
+ *   Copyright 2013 Red Hat, Inc.
304803
+ *   Copyright 2006, 2013 Ian Kent <raven@themaw.net>
304803
+ *   All rights reserved.
304803
  *
304803
  *   This program is free software; you can redistribute it and/or modify
304803
  *   it under the terms of the GNU General Public License as published by
304803
@@ -16,6 +18,7 @@
304803
 #include <stdio.h>
304803
 #include <ctype.h>
304803
 #include <string.h>
304803
+#include <sys/stat.h>
304803
 
304803
 #include "config.h"
304803
 #include "list.h"
304803
@@ -26,132 +29,450 @@
304803
 #include "log.h"
304803
 #include "automount.h"
304803
 
304803
-#define DEFAULTS_CONFIG_FILE		AUTOFS_CONF_DIR "/autofs"
304803
+#define AUTOFS_GLOBAL_SECTION		"autofs"
304803
+
304803
+#define DEFAULT_CONFIG_FILE		AUTOFS_CONF_DIR "/autofs"
304803
 #define MAX_LINE_LEN			256
304803
 
304803
-#define ENV_NAME_MASTER_MAP		"MASTER_MAP_NAME"
304803
+#define NAME_MASTER_MAP			"master_map_name"
304803
+
304803
+#define NAME_TIMEOUT			"timeout"
304803
+#define NAME_NEGATIVE_TIMEOUT		"negative_timeout"
304803
+#define NAME_BROWSE_MODE		"browse_mode"
304803
+#define NAME_LOGGING			"logging"
304803
+
304803
+#define NAME_LDAP_URI			"ldap_uri"
304803
+#define NAME_LDAP_TIMEOUT		"ldap_timeout"
304803
+#define NAME_LDAP_NETWORK_TIMEOUT	"ldap_network_timeout"
304803
+
304803
+#define NAME_SEARCH_BASE		"search_base"
304803
 
304803
-#define ENV_NAME_TIMEOUT		"TIMEOUT"
304803
-#define ENV_NAME_NEGATIVE_TIMEOUT	"NEGATIVE_TIMEOUT"
304803
-#define ENV_NAME_BROWSE_MODE		"BROWSE_MODE"
304803
-#define ENV_NAME_LOGGING		"LOGGING"
304803
+#define NAME_MAP_OBJ_CLASS		"map_object_class"
304803
+#define NAME_ENTRY_OBJ_CLASS		"entry_object_class"
304803
+#define NAME_MAP_ATTR			"map_attribute"
304803
+#define NAME_ENTRY_ATTR			"entry_attribute"
304803
+#define NAME_VALUE_ATTR			"value_attribute"
304803
 
304803
-#define LDAP_URI			"LDAP_URI"
304803
-#define ENV_LDAP_TIMEOUT		"LDAP_TIMEOUT"
304803
-#define ENV_LDAP_NETWORK_TIMEOUT	"LDAP_NETWORK_TIMEOUT"
304803
+#define NAME_MOUNT_NFS_DEFAULT_PROTOCOL	"mount_nfs_default_protocol"
304803
+#define NAME_APPEND_OPTIONS		"append_options"
304803
+#define NAME_MOUNT_WAIT			"mount_wait"
304803
+#define NAME_UMOUNT_WAIT		"umount_wait"
304803
+#define NAME_AUTH_CONF_FILE		"auth_conf_file"
304803
 
304803
-#define SEARCH_BASE			"SEARCH_BASE"
304803
+#define NAME_MAP_HASH_TABLE_SIZE	"map_hash_table_size"
304803
 
304803
-#define ENV_NAME_MAP_OBJ_CLASS		"MAP_OBJECT_CLASS"
304803
-#define ENV_NAME_ENTRY_OBJ_CLASS	"ENTRY_OBJECT_CLASS"
304803
-#define ENV_NAME_MAP_ATTR		"MAP_ATTRIBUTE"
304803
-#define ENV_NAME_ENTRY_ATTR		"ENTRY_ATTRIBUTE"
304803
-#define ENV_NAME_VALUE_ATTR		"VALUE_ATTRIBUTE"
304803
+/* Status returns */
304803
+#define CFG_OK		0x0000
304803
+#define CFG_FAIL	0x0001
304803
+#define CFG_EXISTS	0x0002
304803
+#define CFG_NOTFOUND	0x0004
304803
 
304803
-#define ENV_MOUNT_NFS_DEFAULT_PROTOCOL	"MOUNT_NFS_DEFAULT_PROTOCOL"
304803
-#define ENV_APPEND_OPTIONS		"APPEND_OPTIONS"
304803
-#define ENV_MOUNT_WAIT			"MOUNT_WAIT"
304803
-#define ENV_UMOUNT_WAIT			"UMOUNT_WAIT"
304803
-#define ENV_AUTH_CONF_FILE		"AUTH_CONF_FILE"
304803
+/* Config entry flags */
304803
+#define CONF_ENV		0x00000001
304803
 
304803
-#define ENV_MAP_HASH_TABLE_SIZE		"MAP_HASH_TABLE_SIZE"
304803
+#define CFG_TABLE_SIZE	128
304803
 
304803
 static const char *default_master_map_name = DEFAULT_MASTER_MAP_NAME;
304803
 static const char *default_auth_conf_file  = DEFAULT_AUTH_CONF_FILE;
304803
+static const char *autofs_gbl_sec	   = AUTOFS_GLOBAL_SECTION;
304803
+
304803
+struct conf_option {
304803
+	char *section;
304803
+	char *name;
304803
+	char *value;
304803
+	unsigned long flags;
304803
+	struct conf_option *next;
304803
+};
304803
+
304803
+struct conf_cache {
304803
+	struct conf_option **hash;
304803
+	time_t modified;
304803
+};
304803
+static pthread_mutex_t conf_mutex = PTHREAD_MUTEX_INITIALIZER;
304803
+static struct conf_cache *config = NULL;
304803
+
304803
+static int conf_load_autofs_defaults(void);
304803
+static int conf_update(const char *, const char *, const char *, unsigned long);
304803
+static void conf_delete(const char *, const char *);
304803
+static struct conf_option *conf_lookup(const char *, const char *);
304803
+
304803
+
304803
+static void message(unsigned int to_syslog, const char *msg, ...)
304803
+{
304803
+	va_list ap;
304803
+
304803
+	va_start(ap, msg);
304803
+	if (to_syslog)
304803
+		vsyslog(LOG_CRIT, msg, ap);
304803
+	else {
304803
+		vfprintf(stderr, msg, ap);
304803
+		fputc('\n', stderr);
304803
+	}
304803
+	va_end(ap);
304803
+
304803
+	return;
304803
+}
304803
 
304803
-static char *get_env_string(const char *name)
304803
+static int conf_init(void)
304803
 {
304803
-	char *val, *res;
304803
+	struct conf_cache *cc;
304803
+	unsigned int size = CFG_TABLE_SIZE;
304803
+	unsigned int i;
304803
+
304803
+	cc = malloc(sizeof(struct conf_cache));
304803
+	if (!cc)
304803
+		return CFG_FAIL;
304803
+	cc->modified = 0;
304803
+
304803
+	cc->hash = malloc(size * sizeof(struct conf_option *));
304803
+	if (!cc->hash) {
304803
+		free(cc);
304803
+		return CFG_FAIL;
304803
+	}
304803
 
304803
-	val = getenv(name);
304803
-	if (!val)
304803
-		return NULL;
304803
+	for (i = 0; i < size; i++) {
304803
+		cc->hash[i] = NULL;
304803
+	}
304803
 
304803
-	res = strdup(val);
304803
-	if (!res)
304803
-		return NULL;
304803
+	config = cc;
304803
 
304803
-	return res;
304803
+	return CFG_OK;
304803
 }
304803
 
304803
-static long get_env_number(const char *name)
304803
+static void __conf_release(void)
304803
 {
304803
-	char *val;
304803
-	long res = -1;
304803
-
304803
-	val = getenv(name);
304803
-	if (!val)
304803
-		return -1;
304803
+	struct conf_cache *cc = config;
304803
+	unsigned int size = CFG_TABLE_SIZE;
304803
+	struct conf_option *co, *next;
304803
+	unsigned int i;
304803
+
304803
+	for (i = 0; i < size; i++) {
304803
+		co = cc->hash[i];
304803
+		if (co == NULL)
304803
+			continue;
304803
+		next = co->next;
304803
+		free(co->section);
304803
+		free(co->name);
304803
+		if (co->value)
304803
+			free(co->value);
304803
+		free(co);
304803
+
304803
+		while (next) {
304803
+			co = next;
304803
+			next = co->next;
304803
+			free(co->section);
304803
+			free(co->name);
304803
+			if (co->value)
304803
+				free(co->value);
304803
+			free(co);
304803
+		}
304803
+		cc->hash[i] = NULL;
304803
+	}
304803
 
304803
-	if (isdigit(*val))
304803
-		res = atol(val);
304803
+	free(cc->hash);
304803
+	free(cc);
304803
+	config = NULL;
304803
 
304803
-	if (res < 0)
304803
-		return -1;
304803
+	return;
304803
+}
304803
 
304803
-	return res;
304803
+void defaults_conf_release(void)
304803
+{
304803
+	pthread_mutex_lock(&conf_mutex);
304803
+	__conf_release();
304803
+	pthread_mutex_unlock(&conf_mutex);
304803
+	return;
304803
 }
304803
 
304803
-static int get_env_yesno(const char *name)
304803
+static int conf_load_autofs_defaults(void)
304803
 {
304803
-	const char *val;
304803
-	int res = -1;
304803
+	struct conf_option *co;
304803
+	const char *sec = autofs_gbl_sec;
304803
+	int ret;
304803
 
304803
-	val = getenv(name);
304803
-	if (!val)
304803
-		return -1;
304803
+	ret = conf_update(sec, NAME_MASTER_MAP,
304803
+			  DEFAULT_MASTER_MAP_NAME, CONF_ENV);
304803
+	if (ret == CFG_FAIL)
304803
+		goto error;
304803
+
304803
+	ret = conf_update(sec, NAME_TIMEOUT,
304803
+			  DEFAULT_TIMEOUT, CONF_ENV);
304803
+	if (ret == CFG_FAIL)
304803
+		goto error;
304803
+
304803
+	ret = conf_update(sec, NAME_NEGATIVE_TIMEOUT,
304803
+			  DEFAULT_NEGATIVE_TIMEOUT, CONF_ENV);
304803
+	if (ret == CFG_FAIL)
304803
+		goto error;
304803
+
304803
+	ret = conf_update(sec, NAME_BROWSE_MODE,
304803
+			  DEFAULT_BROWSE_MODE, CONF_ENV);
304803
+	if (ret == CFG_FAIL)
304803
+		goto error;
304803
+
304803
+	ret = conf_update(sec, NAME_LOGGING,
304803
+			  DEFAULT_LOGGING, CONF_ENV);
304803
+	if (ret == CFG_FAIL)
304803
+		goto error;
304803
+
304803
+	ret = conf_update(sec, NAME_LDAP_TIMEOUT,
304803
+			  DEFAULT_LDAP_TIMEOUT, CONF_ENV);
304803
+	if (ret == CFG_FAIL)
304803
+		goto error;
304803
+
304803
+	ret = conf_update(sec, NAME_LDAP_NETWORK_TIMEOUT,
304803
+			  DEFAULT_LDAP_NETWORK_TIMEOUT, CONF_ENV);
304803
+	if (ret == CFG_FAIL)
304803
+		goto error;
304803
+
304803
+	ret = conf_update(sec, NAME_MAP_OBJ_CLASS,
304803
+			  DEFAULT_MAP_OBJ_CLASS, CONF_ENV);
304803
+	if (ret == CFG_FAIL)
304803
+		goto error;
304803
+
304803
+	ret = conf_update(sec, NAME_ENTRY_OBJ_CLASS,
304803
+			  DEFAULT_ENTRY_OBJ_CLASS, CONF_ENV);
304803
+	if (ret == CFG_FAIL)
304803
+		goto error;
304803
+
304803
+	ret = conf_update(sec, NAME_MAP_ATTR,
304803
+			  DEFAULT_MAP_ATTR, CONF_ENV);
304803
+	if (ret == CFG_FAIL)
304803
+		goto error;
304803
+
304803
+	ret = conf_update(sec, NAME_ENTRY_ATTR,
304803
+			  DEFAULT_ENTRY_ATTR, CONF_ENV);
304803
+	if (ret == CFG_FAIL)
304803
+		goto error;
304803
+
304803
+	ret = conf_update(sec, NAME_VALUE_ATTR,
304803
+			  DEFAULT_VALUE_ATTR, CONF_ENV);
304803
+	if (ret == CFG_FAIL)
304803
+		goto error;
304803
+
304803
+	ret = conf_update(sec, NAME_APPEND_OPTIONS,
304803
+			  DEFAULT_APPEND_OPTIONS, CONF_ENV);
304803
+	if (ret == CFG_FAIL)
304803
+		goto error;
304803
+
304803
+	ret = conf_update(sec, NAME_MOUNT_WAIT,
304803
+			  DEFAULT_MOUNT_WAIT, CONF_ENV);
304803
+	if (ret == CFG_FAIL)
304803
+		goto error;
304803
+
304803
+	ret = conf_update(sec, NAME_UMOUNT_WAIT,
304803
+			  DEFAULT_UMOUNT_WAIT, CONF_ENV);
304803
+	if (ret == CFG_FAIL)
304803
+		goto error;
304803
+
304803
+	ret = conf_update(sec, NAME_AUTH_CONF_FILE,
304803
+			  DEFAULT_AUTH_CONF_FILE, CONF_ENV);
304803
+	if (ret == CFG_FAIL)
304803
+		goto error;
304803
+
304803
+	ret = conf_update(sec, NAME_MOUNT_NFS_DEFAULT_PROTOCOL,
304803
+			  DEFAULT_MOUNT_NFS_DEFAULT_PROTOCOL, CONF_ENV);
304803
+	if (ret == CFG_FAIL)
304803
+		goto error;
304803
+
304803
+	/* LDAP_URI nad SEARCH_BASE can occur multiple times */
304803
+	while ((co = conf_lookup(sec, NAME_LDAP_URI)))
304803
+		conf_delete(co->section, co->name);
304803
+
304803
+	while ((co = conf_lookup(sec, NAME_SEARCH_BASE)))
304803
+		conf_delete(co->section, co->name);
304803
 
304803
-	if (isdigit(*val))
304803
-		res = atoi(val);
304803
-	else if (!strcasecmp(val, "yes"))
304803
-		return 1;
304803
-	else if (!strcasecmp(val, "no"))
304803
-		return 0;
304803
+	return 1;
304803
 
304803
-	return res;
304803
+error:
304803
+	return 0;
304803
 }
304803
 
304803
-/*
304803
- * We've changed the key names so we need to check for the
304803
- * config key and it's old name for backward conpatibility.
304803
-*/
304803
-static int check_set_config_value(const char *res, const char *name, const char *value, unsigned to_syslog)
304803
+static int conf_add(const char *section, const char *key, const char *value, unsigned long flags)
304803
 {
304803
-	char *old_name;
304803
+	struct conf_option *co;
304803
+	char *sec, *name, *val, *tmp;
304803
+	unsigned int size = CFG_TABLE_SIZE;
304803
+	u_int32_t index;
304803
 	int ret;
304803
 
304803
-	if (!strcasecmp(res, name)) {
304803
-		ret = setenv(name, value, 0);
304803
-		if (ret) {
304803
-			if (!to_syslog)
304803
-				fprintf(stderr,
304803
-				        "can't set config value for %s, "
304803
-					"error %d\n", name, ret);
304803
-			else
304803
-				logmsg("can't set config value for %s, "
304803
-				      "error %d", name, ret);
304803
+	sec = name = val = NULL;
304803
+
304803
+	co = conf_lookup(section, key);
304803
+	if (co) {
304803
+		ret = CFG_EXISTS;
304803
+		goto error;
304803
+	}
304803
+
304803
+	ret = CFG_FAIL;
304803
+
304803
+	/* Environment overrides file value */
304803
+	if (((flags & CFG_ENV) && (tmp = getenv(key))) || value) {
304803
+		if (tmp)
304803
+			val = strdup(tmp);
304803
+		else
304803
+			val = strdup(value);
304803
+		if (!val)
304803
+			goto error;
304803
+	}
304803
+
304803
+	name = strdup(key);
304803
+	if (!key)
304803
+		goto error;
304803
+
304803
+	sec = strdup(section);
304803
+	if (!sec)
304803
+		goto error;
304803
+
304803
+	co = malloc(sizeof(struct conf_option));
304803
+	if (!co)
304803
+		goto error;
304803
+
304803
+	co->section = sec;
304803
+	co->name = name;
304803
+	co->value = val;
304803
+	co->flags = flags;
304803
+	co->next = NULL;
304803
+
304803
+	/* Don't change user set values in the environment */
304803
+	if (flags & CONF_ENV)
304803
+		setenv(name, value, 0);
304803
+
304803
+	index = hash(key, size);
304803
+	if (!config->hash[index])
304803
+		config->hash[index] = co;
304803
+	else {
304803
+		struct conf_option *last = NULL, *next;
304803
+		next = config->hash[index];
304803
+		while (next) {
304803
+			last = next;
304803
+			next = last->next;
304803
 		}
304803
-		return 1;
304803
+		last->next = co;
304803
 	}
304803
 
304803
-	old_name = alloca(strlen(name) + 9);
304803
-	strcpy(old_name, "DEFAULT_");
304803
-	strcat(old_name, name);
304803
+	return CFG_OK;
304803
+
304803
+error:
304803
+	if (name)
304803
+		free(name);
304803
+	if (val)
304803
+		free(val);
304803
+	if (sec)
304803
+		free(sec);
304803
+
304803
+	return ret;
304803
+}
304803
 
304803
-	if (!strcasecmp(res, old_name)) {
304803
-		ret = setenv(name, value, 0);
304803
-		if (ret) {
304803
-			if (!to_syslog)
304803
-				fprintf(stderr,
304803
-				        "can't set config value for %s, "
304803
-					"error %d\n", name, ret);
304803
+static void conf_delete(const char *section, const char *key)
304803
+{
304803
+	struct conf_option *co, *last;
304803
+	unsigned int size = CFG_TABLE_SIZE;
304803
+
304803
+	last = NULL;
304803
+	for (co = config->hash[hash(key, size)]; co != NULL; co = co->next) {
304803
+		if (strcasecmp(section, co->section))
304803
+			continue;
304803
+		if (!strcasecmp(key, co->name))
304803
+			break;
304803
+		last = co;
304803
+	}
304803
+
304803
+	if (!co)
304803
+		return;
304803
+
304803
+	if (last)
304803
+		last->next = co->next;
304803
+
304803
+	free(co->section);
304803
+	free(co->name);
304803
+	if (co->value);
304803
+		free(co->value);
304803
+	free(co);
304803
+}
304803
+
304803
+static int conf_update(const char *section,
304803
+			const char *key, const char *value,
304803
+			unsigned long flags)
304803
+{
304803
+	struct conf_option *co = NULL;
304803
+	int ret;
304803
+
304803
+	ret = CFG_FAIL;
304803
+	co = conf_lookup(section, key);
304803
+	if (!co)
304803
+		ret = conf_add(section, key, value, flags);
304803
+	else {
304803
+		char *val = NULL, *tmp;
304803
+		/* Environment overrides file value */
304803
+		if (((flags & CONF_ENV) && (tmp = getenv(key))) || value) {
304803
+			if (tmp)
304803
+				val = strdup(tmp);
304803
 			else
304803
-				logmsg("can't set config value for %s, "
304803
-				      "error %d\n", name, ret);
304803
+				val = strdup(value);
304803
+			if (!val)
304803
+				goto error;
304803
 		}
304803
-		return 1;
304803
+		if (co->value)
304803
+			free(co->value);
304803
+		co->value = val;
304803
+		if (flags)
304803
+			co->flags = flags;
304803
+		/* Don't change user set values in the environment */
304803
+		if (flags & CONF_ENV)
304803
+			setenv(key, value, 0);
304803
 	}
304803
-	return 0;
304803
+
304803
+	return CFG_OK;
304803
+
304803
+error:
304803
+	return ret;
304803
+}
304803
+
304803
+static struct conf_option *conf_lookup(const char *section, const char *key)
304803
+{
304803
+	struct conf_option *co;
304803
+	unsigned int size = CFG_TABLE_SIZE;
304803
+
304803
+	if (!key || !section)
304803
+		return NULL;
304803
+
304803
+	for (co = config->hash[hash(key, size)]; co != NULL; co = co->next) {
304803
+		if (strcasecmp(section, co->section))
304803
+			continue;
304803
+		if (!strcasecmp(key, co->name))
304803
+			break;
304803
+		/*
304803
+		 * Strip "DEFAULT_" and look for config entry for
304803
+		 * backward compatibility with old style config names.
304803
+		 */
304803
+		if (strlen(key) <= 8)
304803
+			continue;
304803
+		if (!strncasecmp("DEFAULT_", key, 8) &&
304803
+		    !strcasecmp(key + 8, co->name))
304803
+			break;
304803
+	}
304803
+
304803
+	return co;
304803
+}
304803
+
304803
+/*
304803
+ * We've changed the key names so we need to check for the
304803
+ * config key and it's old name for backward conpatibility.
304803
+*/
304803
+static int check_set_config_value(const char *res, const char *value)
304803
+{
304803
+	const char *sec = autofs_gbl_sec;
304803
+	int ret;
304803
+
304803
+	if (!strcasecmp(res, NAME_LDAP_URI))
304803
+		ret = conf_add(sec, res, value, 0);
304803
+	else if (!strcasecmp(res, NAME_SEARCH_BASE))
304803
+		ret = conf_add(sec, res, value, 0);
304803
+	else
304803
+		ret = conf_update(sec, res, value, 0);
304803
+
304803
+	return ret;
304803
 }
304803
 
304803
 static int parse_line(char *line, char **res, char **value)
304803
@@ -200,6 +521,119 @@ static int parse_line(char *line, char **res, char **value)
304803
 	return 1;
304803
 }
304803
 
304803
+/*
304803
+ * Read config env variables and check they have been set.
304803
+ *
304803
+ * This simple minded routine assumes the config file
304803
+ * is valid bourne shell script without spaces around "="
304803
+ * and that it has valid values.
304803
+ */
304803
+unsigned int defaults_read_config(unsigned int to_syslog)
304803
+{
304803
+	FILE *f;
304803
+	char buf[MAX_LINE_LEN];
304803
+	struct stat stb;
304803
+	char *res;
304803
+	int ret;
304803
+
304803
+	f = open_fopen_r(DEFAULT_CONFIG_FILE);
304803
+	if (!f)
304803
+		return 0;
304803
+
304803
+	pthread_mutex_lock(&conf_mutex);
304803
+	if (config) {
304803
+		if (fstat(fileno(f), &stb) != -1) {
304803
+			/* Config hasn't been updated */
304803
+			if (stb.st_mtime <= config->modified)
304803
+				goto out;
304803
+		}
304803
+	} else {
304803
+		if (conf_init()) {
304803
+			pthread_mutex_unlock(&conf_mutex);
304803
+			message(to_syslog, "failed to init config");
304803
+			return 0;
304803
+		}
304803
+	}
304803
+
304803
+	/* Set configuration to defaults */
304803
+	ret = conf_load_autofs_defaults();
304803
+	if (!ret) {
304803
+		pthread_mutex_unlock(&conf_mutex);
304803
+		message(to_syslog, "failed to reset autofs default config");
304803
+		return 0;
304803
+	}
304803
+
304803
+	while ((res = fgets(buf, MAX_LINE_LEN, f))) {
304803
+		char *key, *value;
304803
+		if (!parse_line(res, &key, &value))
304803
+			continue;
304803
+		check_set_config_value(key, value);
304803
+	}
304803
+
304803
+	if (fstat(fileno(f), &stb) != -1)
304803
+		config->modified = stb.st_mtime;
304803
+	else
304803
+		message(to_syslog, "failed to update config modified time");
304803
+
304803
+	if (!feof(f) || ferror(f)) {
304803
+		pthread_mutex_unlock(&conf_mutex);
304803
+		message(to_syslog,
304803
+			"fgets returned error %d while reading %s",
304803
+			ferror(f), DEFAULT_CONFIG_FILE);
304803
+		fclose(f);
304803
+		return 0;
304803
+	}
304803
+out:
304803
+	pthread_mutex_unlock(&conf_mutex);
304803
+	fclose(f);
304803
+	return 1;
304803
+}
304803
+
304803
+static char *conf_get_string(const char *section, const char *name)
304803
+{
304803
+	struct conf_option *co;
304803
+	char *val = NULL;
304803
+
304803
+	pthread_mutex_lock(&conf_mutex);
304803
+	co = conf_lookup(section, name);
304803
+	if (co && co->value)
304803
+		val = strdup(co->value);
304803
+	pthread_mutex_unlock(&conf_mutex);
304803
+	return val;
304803
+}
304803
+
304803
+static long conf_get_number(const char *section, const char *name)
304803
+{
304803
+	struct conf_option *co;
304803
+	long val = -1;
304803
+
304803
+	pthread_mutex_lock(&conf_mutex);
304803
+	co = conf_lookup(section, name);
304803
+	if (co && co->value)
304803
+		val = atol(co->value);
304803
+	pthread_mutex_unlock(&conf_mutex);
304803
+	return val;
304803
+}
304803
+
304803
+static int conf_get_yesno(const char *section, const char *name)
304803
+{
304803
+	struct conf_option *co;
304803
+	int val = -1;
304803
+
304803
+	pthread_mutex_lock(&conf_mutex);
304803
+	co = conf_lookup(section, name);
304803
+	if (co && co->value) {
304803
+		if (isdigit(*co->value))
304803
+			val = atoi(co->value);
304803
+		else if (!strcasecmp(co->value, "yes"))
304803
+			val = 1;
304803
+		else if (!strcasecmp(co->value, "no"))
304803
+			val = 0;
304803
+	}
304803
+	pthread_mutex_unlock(&conf_mutex);
304803
+	return val;
304803
+}
304803
+
304803
 #ifdef WITH_LDAP
304803
 void defaults_free_uris(struct list_head *list)
304803
 {
304803
@@ -229,7 +663,7 @@ static unsigned int add_uris(char *value, struct list_head *list)
304803
 	char *str, *tok, *ptr = NULL;
304803
 	size_t len = strlen(value) + 1;
304803
 
304803
-	str = alloca(len);
304803
+	str = malloc(len);
304803
 	if (!str)
304803
 		return 0;
304803
 	strcpy(str, value);
304803
@@ -253,44 +687,48 @@ static unsigned int add_uris(char *value, struct list_head *list)
304803
 
304803
 		tok = strtok_r(NULL, " ", &ptr);
304803
 	}
304803
+	free(str);
304803
 
304803
 	return 1;
304803
 }
304803
 
304803
 struct list_head *defaults_get_uris(void)
304803
 {
304803
-	FILE *f;
304803
-	char buf[MAX_LINE_LEN];
304803
-	char *res;
304803
+	struct conf_option *co;
304803
 	struct list_head *list;
304803
 
304803
-	f = open_fopen_r(DEFAULTS_CONFIG_FILE);
304803
-	if (!f)
304803
-		return NULL;
304803
-
304803
 	list = malloc(sizeof(struct list_head));
304803
 	if (!list) {
304803
-		fclose(f);
304803
 		return NULL;
304803
 	}
304803
 	INIT_LIST_HEAD(list);
304803
 
304803
-	while ((res = fgets(buf, MAX_LINE_LEN, f))) {
304803
-		char *key, *value;
304803
+	if (defaults_read_config(0)) {
304803
+		free(list);
304803
+		return NULL;
304803
+	}
304803
 
304803
-		if (!parse_line(res, &key, &value))
304803
-			continue;
304803
+	pthread_mutex_lock(&conf_mutex);
304803
+	co = conf_lookup(autofs_gbl_sec, NAME_LDAP_URI);
304803
+	if (!co || !co->value) {
304803
+		pthread_mutex_unlock(&conf_mutex);
304803
+		free(list);
304803
+		return NULL;
304803
+	}
304803
 
304803
-		if (!strcasecmp(res, LDAP_URI))
304803
-			add_uris(value, list);
304803
+	while (co) {
304803
+		if (!strcasecmp(co->name, NAME_LDAP_URI))
304803
+			if (co->value)
304803
+				add_uris(co->value, list);
304803
+		co = co->next;
304803
 	}
304803
+	pthread_mutex_unlock(&conf_mutex);
304803
 
304803
 	if (list_empty(list)) {
304803
 		free(list);
304803
 		list = NULL;
304803
 	}
304803
 
304803
-	fclose(f);
304803
 	return list;
304803
 }
304803
 
304803
@@ -390,45 +828,50 @@ void defaults_free_searchdns(struct ldap_searchdn *sdn)
304803
 
304803
 struct ldap_searchdn *defaults_get_searchdns(void)
304803
 {
304803
-	FILE *f;
304803
-	char buf[MAX_LINE_LEN];
304803
-	char *res;
304803
+	struct conf_option *co;
304803
 	struct ldap_searchdn *sdn, *last;
304803
 
304803
-	f = open_fopen_r(DEFAULTS_CONFIG_FILE);
304803
-	if (!f)
304803
+	if (defaults_read_config(0))
304803
 		return NULL;
304803
 
304803
+	pthread_mutex_lock(&conf_mutex);
304803
+	co = conf_lookup(autofs_gbl_sec, NAME_SEARCH_BASE);
304803
+	if (!co || !co->value) {
304803
+		pthread_mutex_unlock(&conf_mutex);
304803
+		return NULL;
304803
+	}
304803
+
304803
 	sdn = last = NULL;
304803
 
304803
-	while ((res = fgets(buf, MAX_LINE_LEN, f))) {
304803
-		char *key, *value;
304803
+	while (co) {
304803
+		struct ldap_searchdn *new;
304803
 
304803
-		if (!parse_line(res, &key, &value))
304803
+		if (!co->value || strcasecmp(co->name, NAME_SEARCH_BASE) ) {
304803
+			co = co->next;
304803
 			continue;
304803
+		}
304803
 
304803
-		if (!strcasecmp(key, SEARCH_BASE)) {
304803
-			struct ldap_searchdn *new = alloc_searchdn(value);
304803
+		new = alloc_searchdn(co->value);
304803
+		if (!new) {
304803
+			pthread_mutex_unlock(&conf_mutex);
304803
+			defaults_free_searchdns(sdn);
304803
+			return NULL;
304803
+		}
304803
 
304803
-			if (!new) {
304803
-				defaults_free_searchdns(sdn);
304803
-				fclose(f);
304803
-				return NULL;
304803
-			}
304803
+		if (!last)
304803
+			last = new;
304803
+		else {
304803
+			last->next = new;
304803
+			last = new;
304803
+		}
304803
 
304803
-			if (!last)
304803
-				last = new;
304803
-			else {
304803
-				last->next = new;
304803
-				last = new;
304803
-			}
304803
+		if (!sdn)
304803
+			sdn = new;
304803
 
304803
-			if (!sdn)
304803
-				sdn = new;
304803
-		}
304803
+		co = co->next;
304803
 	}
304803
+	pthread_mutex_unlock(&conf_mutex);
304803
 
304803
-	fclose(f);
304803
 	return sdn;
304803
 }
304803
 
304803
@@ -436,25 +879,26 @@ struct ldap_schema *defaults_get_schema(void)
304803
 {
304803
 	struct ldap_schema *schema;
304803
 	char *mc, *ma, *ec, *ea, *va;
304803
+	const char *sec = autofs_gbl_sec;
304803
 
304803
-	mc = get_env_string(ENV_NAME_MAP_OBJ_CLASS);
304803
+	mc = conf_get_string(sec, NAME_MAP_OBJ_CLASS);
304803
 	if (!mc)
304803
 		return NULL;
304803
 
304803
-	ma = get_env_string(ENV_NAME_MAP_ATTR);
304803
+	ma = conf_get_string(sec, NAME_MAP_ATTR);
304803
 	if (!ma) {
304803
 		free(mc);
304803
 		return NULL;
304803
 	}
304803
 
304803
-	ec = get_env_string(ENV_NAME_ENTRY_OBJ_CLASS);
304803
+	ec = conf_get_string(sec, NAME_ENTRY_OBJ_CLASS);
304803
 	if (!ec) {
304803
 		free(mc);
304803
 		free(ma);
304803
 		return NULL;
304803
 	}
304803
 
304803
-	ea = get_env_string(ENV_NAME_ENTRY_ATTR);
304803
+	ea = conf_get_string(sec, NAME_ENTRY_ATTR);
304803
 	if (!ea) {
304803
 		free(mc);
304803
 		free(ma);
304803
@@ -462,7 +906,7 @@ struct ldap_schema *defaults_get_schema(void)
304803
 		return NULL;
304803
 	}
304803
 
304803
-	va = get_env_string(ENV_NAME_VALUE_ATTR);
304803
+	va = conf_get_string(sec, NAME_VALUE_ATTR);
304803
 	if (!va) {
304803
 		free(mc);
304803
 		free(ma);
304803
@@ -491,72 +935,9 @@ struct ldap_schema *defaults_get_schema(void)
304803
 }
304803
 #endif
304803
 
304803
-/*
304803
- * Read config env variables and check they have been set.
304803
- *
304803
- * This simple minded routine assumes the config file
304803
- * is valid bourne shell script without spaces around "="
304803
- * and that it has valid values.
304803
- */
304803
-unsigned int defaults_read_config(unsigned int to_syslog)
304803
-{
304803
-	FILE *f;
304803
-	char buf[MAX_LINE_LEN];
304803
-	char *res;
304803
-
304803
-	f = open_fopen_r(DEFAULTS_CONFIG_FILE);
304803
-	if (!f)
304803
-		return 0;
304803
-
304803
-	while ((res = fgets(buf, MAX_LINE_LEN, f))) {
304803
-		char *key, *value;
304803
-
304803
-		if (!parse_line(res, &key, &value))
304803
-			continue;
304803
-
304803
-		if (check_set_config_value(key, ENV_NAME_MASTER_MAP, value, to_syslog) ||
304803
-		    check_set_config_value(key, ENV_NAME_TIMEOUT, value, to_syslog) ||
304803
-		    check_set_config_value(key, ENV_NAME_NEGATIVE_TIMEOUT, value, to_syslog) ||
304803
-		    check_set_config_value(key, ENV_NAME_BROWSE_MODE, value, to_syslog) ||
304803
-		    check_set_config_value(key, ENV_NAME_LOGGING, value, to_syslog) ||
304803
-		    check_set_config_value(key, ENV_LDAP_TIMEOUT, value, to_syslog) ||
304803
-		    check_set_config_value(key, ENV_LDAP_NETWORK_TIMEOUT, value, to_syslog) ||
304803
-		    check_set_config_value(key, ENV_NAME_MAP_OBJ_CLASS, value, to_syslog) ||
304803
-		    check_set_config_value(key, ENV_NAME_ENTRY_OBJ_CLASS, value, to_syslog) ||
304803
-		    check_set_config_value(key, ENV_NAME_MAP_ATTR, value, to_syslog) ||
304803
-		    check_set_config_value(key, ENV_NAME_ENTRY_ATTR, value, to_syslog) ||
304803
-		    check_set_config_value(key, ENV_NAME_VALUE_ATTR, value, to_syslog) ||
304803
-		    check_set_config_value(key, ENV_APPEND_OPTIONS, value, to_syslog) ||
304803
-		    check_set_config_value(key, ENV_MOUNT_WAIT, value, to_syslog) ||
304803
-		    check_set_config_value(key, ENV_UMOUNT_WAIT, value, to_syslog) ||
304803
-		    check_set_config_value(key, ENV_AUTH_CONF_FILE, value, to_syslog) ||
304803
-		    check_set_config_value(key, ENV_MAP_HASH_TABLE_SIZE, value, to_syslog) ||
304803
-		    check_set_config_value(key, ENV_MOUNT_NFS_DEFAULT_PROTOCOL, value, to_syslog))
304803
-			;
304803
-	}
304803
-
304803
-	if (!feof(f) || ferror(f)) {
304803
-		if (!to_syslog) {
304803
-			fprintf(stderr,
304803
-				"fgets returned error %d while reading %s\n",
304803
-				ferror(f), DEFAULTS_CONFIG_FILE);
304803
-		} else {
304803
-			logmsg("fgets returned error %d while reading %s",
304803
-			      ferror(f), DEFAULTS_CONFIG_FILE);
304803
-		}
304803
-		fclose(f);
304803
-		return 0;
304803
-	}
304803
-
304803
-	fclose(f);
304803
-	return 1;
304803
-}
304803
-
304803
 const char *defaults_get_master_map(void)
304803
 {
304803
-	char *master;
304803
-
304803
-	master = get_env_string(ENV_NAME_MASTER_MAP);
304803
+	char *master = conf_get_string(autofs_gbl_sec, NAME_MASTER_MAP);
304803
 	if (!master)
304803
 		return strdup(default_master_map_name);
304803
 
304803
@@ -565,20 +946,23 @@ const char *defaults_get_master_map(void)
304803
 
304803
 int defaults_master_set(void)
304803
 {
304803
-	char *val = getenv(ENV_NAME_MASTER_MAP);
304803
-	if (!val)
304803
-		return 0;
304803
+	struct conf_option *co;
304803
 
304803
-	return 1;
304803
+	pthread_mutex_lock(&conf_mutex);
304803
+	co = conf_lookup(autofs_gbl_sec, NAME_MASTER_MAP);
304803
+	pthread_mutex_unlock(&conf_mutex);
304803
+	if (co)
304803
+		return 1;
304803
+	return 0;
304803
 }
304803
 
304803
 unsigned int defaults_get_timeout(void)
304803
 {
304803
 	long timeout;
304803
 
304803
-	timeout = get_env_number(ENV_NAME_TIMEOUT);
304803
+	timeout = conf_get_number(autofs_gbl_sec, NAME_TIMEOUT);
304803
 	if (timeout < 0)
304803
-		timeout = DEFAULT_TIMEOUT;
304803
+		timeout = atol(DEFAULT_TIMEOUT);
304803
 
304803
 	return (unsigned int) timeout;
304803
 }
304803
@@ -587,9 +971,9 @@ unsigned int defaults_get_negative_timeout(void)
304803
 {
304803
 	long n_timeout;
304803
 
304803
-	n_timeout = get_env_number(ENV_NAME_NEGATIVE_TIMEOUT);
304803
+	n_timeout = conf_get_number(autofs_gbl_sec, NAME_NEGATIVE_TIMEOUT);
304803
 	if (n_timeout <= 0)
304803
-		n_timeout = DEFAULT_NEGATIVE_TIMEOUT;
304803
+		n_timeout = atol(DEFAULT_NEGATIVE_TIMEOUT);
304803
 
304803
 	return (unsigned int) n_timeout;
304803
 }
304803
@@ -598,9 +982,9 @@ unsigned int defaults_get_browse_mode(void)
304803
 {
304803
 	int res;
304803
 
304803
-	res = get_env_yesno(ENV_NAME_BROWSE_MODE);
304803
+	res = conf_get_yesno(autofs_gbl_sec, NAME_BROWSE_MODE);
304803
 	if (res < 0)
304803
-		res = DEFAULT_BROWSE_MODE;
304803
+		res = atoi(DEFAULT_BROWSE_MODE);
304803
 
304803
 	return res;
304803
 }
304803
@@ -608,14 +992,14 @@ unsigned int defaults_get_browse_mode(void)
304803
 unsigned int defaults_get_logging(void)
304803
 {
304803
 	char *res;
304803
-	unsigned int logging = DEFAULT_LOGGING;
304803
+	unsigned int logging = LOGOPT_NONE;
304803
 
304803
-	res = get_env_string(ENV_NAME_LOGGING);
304803
+	res = conf_get_string(autofs_gbl_sec, NAME_LOGGING);
304803
 	if (!res)
304803
 		return logging;
304803
 
304803
 	if (!strcasecmp(res, "none"))
304803
-		logging = DEFAULT_LOGGING;
304803
+		logging = LOGOPT_NONE;
304803
 	else {
304803
 		if (!strcasecmp(res, "verbose"))
304803
 			logging |= LOGOPT_VERBOSE;
304803
@@ -633,9 +1017,9 @@ unsigned int defaults_get_ldap_timeout(void)
304803
 {
304803
 	int res;
304803
 
304803
-	res = get_env_number(ENV_LDAP_TIMEOUT);
304803
+	res = conf_get_number(autofs_gbl_sec, NAME_LDAP_TIMEOUT);
304803
 	if (res < 0)
304803
-		res = DEFAULT_LDAP_TIMEOUT;
304803
+		res = atoi(DEFAULT_LDAP_TIMEOUT);
304803
 
304803
 	return res;
304803
 }
304803
@@ -644,20 +1028,20 @@ unsigned int defaults_get_ldap_network_timeout(void)
304803
 {
304803
 	int res;
304803
 
304803
-	res = get_env_number(ENV_LDAP_NETWORK_TIMEOUT);
304803
+	res = conf_get_number(autofs_gbl_sec, NAME_LDAP_NETWORK_TIMEOUT);
304803
 	if (res < 0)
304803
-		res = DEFAULT_LDAP_NETWORK_TIMEOUT;
304803
+		res = atoi(DEFAULT_LDAP_NETWORK_TIMEOUT);
304803
 
304803
 	return res;
304803
 }
304803
 
304803
 unsigned int defaults_get_mount_nfs_default_proto(void)
304803
 {
304803
-	long proto;
304803
+	int proto;
304803
 
304803
-	proto = get_env_number(ENV_MOUNT_NFS_DEFAULT_PROTOCOL);
304803
+	proto = conf_get_number(autofs_gbl_sec, NAME_MOUNT_NFS_DEFAULT_PROTOCOL);
304803
 	if (proto < 2 || proto > 4)
304803
-		proto = DEFAULT_NFS_MOUNT_PROTOCOL;
304803
+		proto = atoi(DEFAULT_MOUNT_NFS_DEFAULT_PROTOCOL);
304803
 
304803
 	return (unsigned int) proto;
304803
 }
304803
@@ -666,9 +1050,9 @@ unsigned int defaults_get_append_options(void)
304803
 {
304803
 	int res;
304803
 
304803
-	res = get_env_yesno(ENV_APPEND_OPTIONS);
304803
+	res = conf_get_yesno(autofs_gbl_sec, NAME_APPEND_OPTIONS);
304803
 	if (res < 0)
304803
-		res = DEFAULT_APPEND_OPTIONS;
304803
+		res = atoi(DEFAULT_APPEND_OPTIONS);
304803
 
304803
 	return res;
304803
 }
304803
@@ -677,9 +1061,9 @@ unsigned int defaults_get_mount_wait(void)
304803
 {
304803
 	long wait;
304803
 
304803
-	wait = get_env_number(ENV_MOUNT_WAIT);
304803
+	wait = conf_get_number(autofs_gbl_sec, NAME_MOUNT_WAIT);
304803
 	if (wait < 0)
304803
-		wait = DEFAULT_MOUNT_WAIT;
304803
+		wait = atoi(DEFAULT_MOUNT_WAIT);
304803
 
304803
 	return (unsigned int) wait;
304803
 }
304803
@@ -688,9 +1072,9 @@ unsigned int defaults_get_umount_wait(void)
304803
 {
304803
 	long wait;
304803
 
304803
-	wait = get_env_number(ENV_UMOUNT_WAIT);
304803
+	wait = conf_get_number(autofs_gbl_sec, NAME_UMOUNT_WAIT);
304803
 	if (wait < 0)
304803
-		wait = DEFAULT_UMOUNT_WAIT;
304803
+		wait = atoi(DEFAULT_UMOUNT_WAIT);
304803
 
304803
 	return (unsigned int) wait;
304803
 }
304803
@@ -699,7 +1083,7 @@ const char *defaults_get_auth_conf_file(void)
304803
 {
304803
 	char *cf;
304803
 
304803
-	cf = get_env_string(ENV_AUTH_CONF_FILE);
304803
+	cf = conf_get_string(autofs_gbl_sec, NAME_AUTH_CONF_FILE);
304803
 	if (!cf)
304803
 		return strdup(default_auth_conf_file);
304803
 
304803
@@ -710,9 +1094,9 @@ unsigned int defaults_get_map_hash_table_size(void)
304803
 {
304803
 	long size;
304803
 
304803
-	size = get_env_number(ENV_MAP_HASH_TABLE_SIZE);
304803
+	size = conf_get_number(autofs_gbl_sec, NAME_MAP_HASH_TABLE_SIZE);
304803
 	if (size < 0)
304803
-		size = DEFAULT_MAP_HASH_TABLE_SIZE;
304803
+		size = atoi(DEFAULT_MAP_HASH_TABLE_SIZE);
304803
 
304803
 	return (unsigned int) size;
304803
 }