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