aboutsummaryrefslogtreecommitdiff
path: root/contrib/amd/amd/mapc.c
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/amd/amd/mapc.c')
-rw-r--r--contrib/amd/amd/mapc.c42
1 files changed, 24 insertions, 18 deletions
diff --git a/contrib/amd/amd/mapc.c b/contrib/amd/amd/mapc.c
index e27928bf03d0..865e07a86e53 100644
--- a/contrib/amd/amd/mapc.c
+++ b/contrib/amd/amd/mapc.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997-1999 Erez Zadok
+ * Copyright (c) 1997-2001 Erez Zadok
* Copyright (c) 1989 Jan-Simon Pendry
* Copyright (c) 1989 Imperial College of Science, Technology & Medicine
* Copyright (c) 1989 The Regents of the University of California.
@@ -38,7 +38,7 @@
*
* %W% (Berkeley) %G%
*
- * $Id: mapc.c,v 1.5 1999/09/30 21:01:31 ezk Exp $
+ * $Id: mapc.c,v 1.7.2.3 2001/04/14 21:08:22 ezk Exp $
*
*/
@@ -230,7 +230,7 @@ static map_type maptypes[] =
NULL, /* isup function */
passwd_search,
error_mtime,
- MAPC_ALL
+ MAPC_INC
},
#endif /* HAVE_MAP_PASSWD */
#ifdef HAVE_MAP_HESIOD
@@ -241,7 +241,7 @@ static map_type maptypes[] =
hesiod_isup, /* is Hesiod up or not? */
hesiod_search,
error_mtime,
- MAPC_ALL
+ MAPC_INC
},
#endif /* HAVE_MAP_HESIOD */
#ifdef HAVE_MAP_LDAP
@@ -252,7 +252,7 @@ static map_type maptypes[] =
NULL, /* isup function */
amu_ldap_search,
amu_ldap_mtime,
- MAPC_ALL
+ MAPC_INC
},
#endif /* HAVE_MAP_LDAP */
#ifdef HAVE_MAP_UNION
@@ -296,7 +296,7 @@ static map_type maptypes[] =
NULL, /* isup function */
ndbm_search,
ndbm_mtime,
- MAPC_ALL
+ MAPC_INC
},
#endif /* HAVE_MAP_NDBM */
#ifdef HAVE_MAP_FILE
@@ -498,26 +498,25 @@ mapc_reload_map(mnt_map *m)
{
int error;
kv *maphash[NKVHASH], *tmphash[NKVHASH];
+ time_t t;
+
+ error = (*m->mtime) (m, m->map_name, &t);
+ if (error) {
+ t = m->modify;
+ }
/*
* skip reloading maps that have not been modified, unless
* amq -f was used (do_mapc_reload is 0)
*/
if (m->reloads != 0 && do_mapc_reload != 0) {
- time_t t;
- error = (*m->mtime) (m, m->map_name, &t);
- if (!error) {
- if (t <= m->modify) {
+ if (t <= m->modify) {
plog(XLOG_INFO, "reload of map %s is not needed (in sync)", m->map_name);
#ifdef DEBUG
dlog("map %s last load time is %d, last modify time is %d",
m->map_name, (int) m->modify, (int) t);
#endif /* DEBUG */
return;
- } else {
- /* reload of the map is needed, update map reload time */
- m->modify = t;
- }
}
}
@@ -547,6 +546,7 @@ mapc_reload_map(mnt_map *m)
memcpy((voidp) m->kvhash, (voidp) maphash, sizeof(m->kvhash));
mapc_clear(m);
memcpy((voidp) m->kvhash, (voidp) tmphash, sizeof(m->kvhash));
+ m->modify = t;
}
m->wildcard = 0;
@@ -584,7 +584,7 @@ mapc_create(char *map, char *opt, const char *type)
mt < maptypes + sizeof(maptypes) / sizeof(maptypes[0]);
mt++) {
if (STREQ(type, mt->name)) {
- plog(XLOG_INFO, "initializing amd conf map %s of type %s", map, type);
+ plog(XLOG_INFO, "initializing amd.conf map %s of type %s", map, type);
if ((*mt->init) (m, map, &modify) == 0) {
break;
} else {
@@ -780,6 +780,7 @@ mapc_meta_search(mnt_map *m, char *key, char **pval, int recurse)
plog(XLOG_ERROR, "Null map request for %s", key);
return ENOENT;
}
+
if (m->flags & MAPC_SYNC) {
/*
* Get modify time...
@@ -787,7 +788,6 @@ mapc_meta_search(mnt_map *m, char *key, char **pval, int recurse)
time_t t;
error = (*m->mtime) (m, m->map_name, &t);
if (error || t > m->modify) {
- m->modify = t;
plog(XLOG_INFO, "Map %s is out of date", m->map_name);
mapc_sync(m);
}
@@ -1122,6 +1122,9 @@ make_entry_chain(am_node *mp, const nfsentry *current_chain, int fully_browsable
return retval;
}
+ if (mp->am_pref)
+ preflen = strlen(mp->am_pref);
+
/* iterate over keys */
for (i = 0; i < NKVHASH; i++) {
kv *k;
@@ -1142,12 +1145,15 @@ make_entry_chain(am_node *mp, const nfsentry *current_chain, int fully_browsable
/*
* If the map has a prefix-string then check if the key starts with
- * this * string, and if it does, skip over this prefix.
+ * this string, and if it does, skip over this prefix. If it has a
+ * prefix and it doesn't match the start of the key, skip it.
*/
- if (preflen) {
+ if (preflen && (preflen <= (strlen(key)))) {
if (!NSTREQ(key, mp->am_pref, preflen))
continue;
key += preflen;
+ } else if (preflen) {
+ continue;
}
/* no more '/' are allowed, unless browsable_dirs=full was used */