|
|
306fa1 |
autofs-5.0.9 - amd lookup fix old conf handling
|
|
|
306fa1 |
|
|
|
306fa1 |
From: Ian Kent <ikent@redhat.com>
|
|
|
306fa1 |
|
|
|
306fa1 |
When the configuration changed to using lower case option names
|
|
|
306fa1 |
old configuration files with upper case names stopped working.
|
|
|
306fa1 |
|
|
|
306fa1 |
This is because, for configuration option lookup the hash of
|
|
|
306fa1 |
the option string always needs to be the same case, which was
|
|
|
306fa1 |
overlooked at the time.
|
|
|
306fa1 |
|
|
|
306fa1 |
Also fix a couple of other things, possible incorect return
|
|
|
306fa1 |
from conf_update() what adding a new entry and change to using
|
|
|
306fa1 |
isblank() instead of checking for a space only.
|
|
|
306fa1 |
---
|
|
|
306fa1 |
lib/defaults.c | 27 +++++++++++++++++++++------
|
|
|
306fa1 |
1 file changed, 21 insertions(+), 6 deletions(-)
|
|
|
306fa1 |
|
|
|
306fa1 |
diff --git a/lib/defaults.c b/lib/defaults.c
|
|
|
306fa1 |
index 3fa2216..7043dfc 100644
|
|
|
306fa1 |
--- a/lib/defaults.c
|
|
|
306fa1 |
+++ b/lib/defaults.c
|
|
|
306fa1 |
@@ -43,6 +43,7 @@
|
|
|
306fa1 |
#define OLD_CONFIG_FILE AUTOFS_CONF_DIR "/autofs"
|
|
|
306fa1 |
#define MAX_LINE_LEN 256
|
|
|
306fa1 |
#define MAX_SECTION_NAME MAX_LINE_LEN
|
|
|
306fa1 |
+#define MAX_CFG_NAME_LEN 31
|
|
|
306fa1 |
|
|
|
306fa1 |
#define NAME_MASTER_MAP "master_map_name"
|
|
|
306fa1 |
|
|
|
306fa1 |
@@ -661,7 +662,7 @@ static int conf_update(const char *section,
|
|
|
306fa1 |
ret = CFG_FAIL;
|
|
|
306fa1 |
co = conf_lookup(section, key);
|
|
|
306fa1 |
if (!co)
|
|
|
306fa1 |
- ret = conf_add(section, key, value, flags);
|
|
|
306fa1 |
+ return conf_add(section, key, value, flags);
|
|
|
306fa1 |
else {
|
|
|
306fa1 |
char *val = NULL, *tmp = NULL;
|
|
|
306fa1 |
/* Environment overrides file value */
|
|
|
306fa1 |
@@ -691,15 +692,29 @@ error:
|
|
|
306fa1 |
return ret;
|
|
|
306fa1 |
}
|
|
|
306fa1 |
|
|
|
306fa1 |
+static u_int32_t get_hash(const char *key, unsigned int size)
|
|
|
306fa1 |
+{
|
|
|
306fa1 |
+ const char *pkey = key;
|
|
|
306fa1 |
+ char lkey[MAX_CFG_NAME_LEN];
|
|
|
306fa1 |
+ char *plkey = &lkey[0];
|
|
|
306fa1 |
+
|
|
|
306fa1 |
+ while (*pkey)
|
|
|
306fa1 |
+ *plkey++ = tolower(*pkey++);
|
|
|
306fa1 |
+ *plkey = '\0';
|
|
|
306fa1 |
+ return hash(lkey, size);
|
|
|
306fa1 |
+}
|
|
|
306fa1 |
+
|
|
|
306fa1 |
static struct conf_option *conf_lookup(const char *section, const char *key)
|
|
|
306fa1 |
{
|
|
|
306fa1 |
struct conf_option *co;
|
|
|
306fa1 |
+ u_int32_t key_hash;
|
|
|
306fa1 |
unsigned int size = CFG_TABLE_SIZE;
|
|
|
306fa1 |
|
|
|
306fa1 |
if (!key || !section)
|
|
|
306fa1 |
return NULL;
|
|
|
306fa1 |
|
|
|
306fa1 |
- for (co = config->hash[hash(key, size)]; co != NULL; co = co->next) {
|
|
|
306fa1 |
+ key_hash = get_hash(key, size);
|
|
|
306fa1 |
+ for (co = config->hash[key_hash]; co != NULL; co = co->next) {
|
|
|
306fa1 |
if (strcasecmp(section, co->section))
|
|
|
306fa1 |
continue;
|
|
|
306fa1 |
if (!strcasecmp(key, co->name))
|
|
|
306fa1 |
@@ -772,7 +787,7 @@ static int parse_line(char *line, char **sec, char **res, char **value)
|
|
|
306fa1 |
if (*key == '#' || (*key != '[' && !isalpha(*key)))
|
|
|
306fa1 |
return 0;
|
|
|
306fa1 |
|
|
|
306fa1 |
- while (*key && *key == ' ')
|
|
|
306fa1 |
+ while (*key && isblank(*key))
|
|
|
306fa1 |
key++;
|
|
|
306fa1 |
|
|
|
306fa1 |
if (!*key)
|
|
|
306fa1 |
@@ -780,13 +795,13 @@ static int parse_line(char *line, char **sec, char **res, char **value)
|
|
|
306fa1 |
|
|
|
306fa1 |
if (*key == '[') {
|
|
|
306fa1 |
char *tmp;
|
|
|
306fa1 |
- while (*key && (*key == '[' || *key == ' '))
|
|
|
306fa1 |
+ while (*key && (*key == '[' || isblank(*key)))
|
|
|
306fa1 |
key++;
|
|
|
306fa1 |
tmp = strchr(key, ']');
|
|
|
306fa1 |
if (!tmp)
|
|
|
306fa1 |
return 0;
|
|
|
306fa1 |
*tmp = ' ';
|
|
|
306fa1 |
- while (*tmp && *tmp == ' ') {
|
|
|
306fa1 |
+ while (*tmp && isblank(*tmp)) {
|
|
|
306fa1 |
*tmp = '\0';
|
|
|
306fa1 |
tmp--;
|
|
|
306fa1 |
}
|
|
|
306fa1 |
@@ -803,7 +818,7 @@ static int parse_line(char *line, char **sec, char **res, char **value)
|
|
|
306fa1 |
|
|
|
306fa1 |
*val++ = '\0';
|
|
|
306fa1 |
|
|
|
306fa1 |
- while (*(--tmp) == ' ')
|
|
|
306fa1 |
+ while (isblank(*(--tmp)))
|
|
|
306fa1 |
*tmp = '\0';
|
|
|
306fa1 |
|
|
|
306fa1 |
while (*val && (*val == '"' || isblank(*val)))
|