|
|
306fa1 |
autofs-5.0.8 - pass map_source as function paramter where possible
|
|
|
306fa1 |
|
|
|
306fa1 |
From: Ian Kent <raven@themaw.net>
|
|
|
306fa1 |
|
|
|
306fa1 |
Some unnecessary complexity has been added along the way when passing
|
|
|
306fa1 |
the map source to functions in lookup modules. Improve that where
|
|
|
306fa1 |
possible.
|
|
|
306fa1 |
---
|
|
|
306fa1 |
CHANGELOG | 1
|
|
|
306fa1 |
modules/lookup_file.c | 82 +++++++++++++++--------------------------------
|
|
|
306fa1 |
modules/lookup_ldap.c | 37 ++++++---------------
|
|
|
306fa1 |
modules/lookup_nisplus.c | 36 ++++----------------
|
|
|
306fa1 |
modules/lookup_yp.c | 36 ++++----------------
|
|
|
306fa1 |
5 files changed, 56 insertions(+), 136 deletions(-)
|
|
|
306fa1 |
|
|
|
306fa1 |
--- autofs-5.0.7.orig/CHANGELOG
|
|
|
306fa1 |
+++ autofs-5.0.7/CHANGELOG
|
|
|
306fa1 |
@@ -84,6 +84,7 @@
|
|
|
306fa1 |
- fix cache readlock not taken on lookup.
|
|
|
306fa1 |
- fix compilation of lookup_ldap.c without sasl.
|
|
|
306fa1 |
- fix undefined authtype_requires_creds err if ldap enabled but without sasl.
|
|
|
306fa1 |
+- pass map_source as function paramter where possible.
|
|
|
306fa1 |
|
|
|
306fa1 |
25/07/2012 autofs-5.0.7
|
|
|
306fa1 |
=======================
|
|
|
306fa1 |
--- autofs-5.0.7.orig/modules/lookup_file.c
|
|
|
306fa1 |
+++ autofs-5.0.7/modules/lookup_file.c
|
|
|
306fa1 |
@@ -529,21 +529,17 @@ static int check_self_include(const char
|
|
|
306fa1 |
|
|
|
306fa1 |
static struct map_source *
|
|
|
306fa1 |
prepare_plus_include(struct autofs_point *ap,
|
|
|
306fa1 |
+ struct map_source *source,
|
|
|
306fa1 |
time_t age, char *key, unsigned int inc,
|
|
|
306fa1 |
struct lookup_context *ctxt)
|
|
|
306fa1 |
{
|
|
|
306fa1 |
- struct map_source *current;
|
|
|
306fa1 |
- struct map_source *source;
|
|
|
306fa1 |
+ struct map_source *new;
|
|
|
306fa1 |
struct map_type_info *info;
|
|
|
306fa1 |
const char *argv[2];
|
|
|
306fa1 |
char **tmp_argv, **tmp_opts;
|
|
|
306fa1 |
int argc;
|
|
|
306fa1 |
char *buf;
|
|
|
306fa1 |
|
|
|
306fa1 |
- current = ap->entry->current;
|
|
|
306fa1 |
- ap->entry->current = NULL;
|
|
|
306fa1 |
- master_source_current_signal(ap->entry);
|
|
|
306fa1 |
-
|
|
|
306fa1 |
/*
|
|
|
306fa1 |
* TODO:
|
|
|
306fa1 |
* Initially just consider the passed in key to be a simple map
|
|
|
306fa1 |
@@ -596,21 +592,21 @@ prepare_plus_include(struct autofs_point
|
|
|
306fa1 |
}
|
|
|
306fa1 |
argc += ctxt->opts_argc;
|
|
|
306fa1 |
|
|
|
306fa1 |
- source = master_find_source_instance(current,
|
|
|
306fa1 |
- info->type, info->format,
|
|
|
306fa1 |
- argc, (const char **) tmp_argv);
|
|
|
306fa1 |
- if (source) {
|
|
|
306fa1 |
+ new = master_find_source_instance(source,
|
|
|
306fa1 |
+ info->type, info->format,
|
|
|
306fa1 |
+ argc, (const char **) tmp_argv);
|
|
|
306fa1 |
+ if (new) {
|
|
|
306fa1 |
/*
|
|
|
306fa1 |
* Make sure included map age is in sync with its owner
|
|
|
306fa1 |
* or we could incorrectly wipe out its entries.
|
|
|
306fa1 |
*/
|
|
|
306fa1 |
- source->age = age;
|
|
|
306fa1 |
- source->stale = 1;
|
|
|
306fa1 |
+ new->age = age;
|
|
|
306fa1 |
+ new->stale = 1;
|
|
|
306fa1 |
} else {
|
|
|
306fa1 |
- source = master_add_source_instance(current,
|
|
|
306fa1 |
- info->type, info->format, age,
|
|
|
306fa1 |
- argc, (const char **) tmp_argv);
|
|
|
306fa1 |
- if (!source) {
|
|
|
306fa1 |
+ new = master_add_source_instance(source,
|
|
|
306fa1 |
+ info->type, info->format, age,
|
|
|
306fa1 |
+ argc, (const char **) tmp_argv);
|
|
|
306fa1 |
+ if (!new) {
|
|
|
306fa1 |
free_argv(argc, (const char **) tmp_argv);
|
|
|
306fa1 |
free_map_type_info(info);
|
|
|
306fa1 |
free(buf);
|
|
|
306fa1 |
@@ -620,14 +616,14 @@ prepare_plus_include(struct autofs_point
|
|
|
306fa1 |
}
|
|
|
306fa1 |
free_argv(argc, (const char **) tmp_argv);
|
|
|
306fa1 |
|
|
|
306fa1 |
- source->depth = current->depth + 1;
|
|
|
306fa1 |
+ new->depth = source->depth + 1;
|
|
|
306fa1 |
if (inc)
|
|
|
306fa1 |
- source->recurse = 1;
|
|
|
306fa1 |
+ new->recurse = 1;
|
|
|
306fa1 |
|
|
|
306fa1 |
free_map_type_info(info);
|
|
|
306fa1 |
free(buf);
|
|
|
306fa1 |
|
|
|
306fa1 |
- return source;
|
|
|
306fa1 |
+ return new;
|
|
|
306fa1 |
}
|
|
|
306fa1 |
|
|
|
306fa1 |
int lookup_read_map(struct autofs_point *ap, time_t age, void *context)
|
|
|
306fa1 |
@@ -689,10 +685,8 @@ int lookup_read_map(struct autofs_point
|
|
|
306fa1 |
|
|
|
306fa1 |
inc = check_self_include(key, ctxt);
|
|
|
306fa1 |
|
|
|
306fa1 |
- master_source_current_wait(ap->entry);
|
|
|
306fa1 |
- ap->entry->current = source;
|
|
|
306fa1 |
-
|
|
|
306fa1 |
- inc_source = prepare_plus_include(ap, age, key, inc, ctxt);
|
|
|
306fa1 |
+ inc_source = prepare_plus_include(ap, source,
|
|
|
306fa1 |
+ age, key, inc, ctxt);
|
|
|
306fa1 |
if (!inc_source) {
|
|
|
306fa1 |
debug(ap->logopt,
|
|
|
306fa1 |
"failed to select included map %s", key);
|
|
|
306fa1 |
@@ -731,10 +725,10 @@ int lookup_read_map(struct autofs_point
|
|
|
306fa1 |
}
|
|
|
306fa1 |
|
|
|
306fa1 |
static int lookup_one(struct autofs_point *ap,
|
|
|
306fa1 |
+ struct map_source *source,
|
|
|
306fa1 |
const char *key, int key_len,
|
|
|
306fa1 |
struct lookup_context *ctxt)
|
|
|
306fa1 |
{
|
|
|
306fa1 |
- struct map_source *source;
|
|
|
306fa1 |
struct mapent_cache *mc;
|
|
|
306fa1 |
char mkey[KEY_MAX_LEN + 1];
|
|
|
306fa1 |
char mapent[MAPENT_MAX_LEN + 1];
|
|
|
306fa1 |
@@ -743,10 +737,6 @@ static int lookup_one(struct autofs_poin
|
|
|
306fa1 |
unsigned int k_len, m_len;
|
|
|
306fa1 |
int entry, ret;
|
|
|
306fa1 |
|
|
|
306fa1 |
- source = ap->entry->current;
|
|
|
306fa1 |
- ap->entry->current = NULL;
|
|
|
306fa1 |
- master_source_current_signal(ap->entry);
|
|
|
306fa1 |
-
|
|
|
306fa1 |
mc = source->mc;
|
|
|
306fa1 |
|
|
|
306fa1 |
f = open_fopen_r(ctxt->mapname);
|
|
|
306fa1 |
@@ -773,10 +763,8 @@ static int lookup_one(struct autofs_poin
|
|
|
306fa1 |
|
|
|
306fa1 |
inc = check_self_include(mkey, ctxt);
|
|
|
306fa1 |
|
|
|
306fa1 |
- master_source_current_wait(ap->entry);
|
|
|
306fa1 |
- ap->entry->current = source;
|
|
|
306fa1 |
-
|
|
|
306fa1 |
- inc_source = prepare_plus_include(ap, age, mkey, inc, ctxt);
|
|
|
306fa1 |
+ inc_source = prepare_plus_include(ap, source,
|
|
|
306fa1 |
+ age, mkey, inc, ctxt);
|
|
|
306fa1 |
if (!inc_source) {
|
|
|
306fa1 |
debug(ap->logopt,
|
|
|
306fa1 |
MODPREFIX
|
|
|
306fa1 |
@@ -837,9 +825,9 @@ static int lookup_one(struct autofs_poin
|
|
|
306fa1 |
return CHE_MISSING;
|
|
|
306fa1 |
}
|
|
|
306fa1 |
|
|
|
306fa1 |
-static int lookup_wild(struct autofs_point *ap, struct lookup_context *ctxt)
|
|
|
306fa1 |
+static int lookup_wild(struct autofs_point *ap,
|
|
|
306fa1 |
+ struct map_source *source, struct lookup_context *ctxt)
|
|
|
306fa1 |
{
|
|
|
306fa1 |
- struct map_source *source;
|
|
|
306fa1 |
struct mapent_cache *mc;
|
|
|
306fa1 |
char mkey[KEY_MAX_LEN + 1];
|
|
|
306fa1 |
char mapent[MAPENT_MAX_LEN + 1];
|
|
|
306fa1 |
@@ -848,10 +836,6 @@ static int lookup_wild(struct autofs_poi
|
|
|
306fa1 |
unsigned int k_len, m_len;
|
|
|
306fa1 |
int entry, ret;
|
|
|
306fa1 |
|
|
|
306fa1 |
- source = ap->entry->current;
|
|
|
306fa1 |
- ap->entry->current = NULL;
|
|
|
306fa1 |
- master_source_current_signal(ap->entry);
|
|
|
306fa1 |
-
|
|
|
306fa1 |
mc = source->mc;
|
|
|
306fa1 |
|
|
|
306fa1 |
f = open_fopen_r(ctxt->mapname);
|
|
|
306fa1 |
@@ -895,24 +879,17 @@ static int lookup_wild(struct autofs_poi
|
|
|
306fa1 |
}
|
|
|
306fa1 |
|
|
|
306fa1 |
static int check_map_indirect(struct autofs_point *ap,
|
|
|
306fa1 |
+ struct map_source *source,
|
|
|
306fa1 |
char *key, int key_len,
|
|
|
306fa1 |
struct lookup_context *ctxt)
|
|
|
306fa1 |
{
|
|
|
306fa1 |
- struct map_source *source;
|
|
|
306fa1 |
struct mapent_cache *mc;
|
|
|
306fa1 |
struct mapent *exists;
|
|
|
306fa1 |
int ret = CHE_OK;
|
|
|
306fa1 |
|
|
|
306fa1 |
- source = ap->entry->current;
|
|
|
306fa1 |
- ap->entry->current = NULL;
|
|
|
306fa1 |
- master_source_current_signal(ap->entry);
|
|
|
306fa1 |
-
|
|
|
306fa1 |
mc = source->mc;
|
|
|
306fa1 |
|
|
|
306fa1 |
- master_source_current_wait(ap->entry);
|
|
|
306fa1 |
- ap->entry->current = source;
|
|
|
306fa1 |
-
|
|
|
306fa1 |
- ret = lookup_one(ap, key, key_len, ctxt);
|
|
|
306fa1 |
+ ret = lookup_one(ap, source, key, key_len, ctxt);
|
|
|
306fa1 |
if (ret == CHE_COMPLETED)
|
|
|
306fa1 |
return NSS_STATUS_COMPLETED;
|
|
|
306fa1 |
|
|
|
306fa1 |
@@ -935,10 +912,7 @@ static int check_map_indirect(struct aut
|
|
|
306fa1 |
struct mapent *we;
|
|
|
306fa1 |
int wild = CHE_MISSING;
|
|
|
306fa1 |
|
|
|
306fa1 |
- master_source_current_wait(ap->entry);
|
|
|
306fa1 |
- ap->entry->current = source;
|
|
|
306fa1 |
-
|
|
|
306fa1 |
- wild = lookup_wild(ap, ctxt);
|
|
|
306fa1 |
+ wild = lookup_wild(ap, source, ctxt);
|
|
|
306fa1 |
/*
|
|
|
306fa1 |
* Check for map change and update as needed for
|
|
|
306fa1 |
* following cache lookup.
|
|
|
306fa1 |
@@ -1072,10 +1046,8 @@ int lookup_mount(struct autofs_point *ap
|
|
|
306fa1 |
if (!lkp_key)
|
|
|
306fa1 |
return NSS_STATUS_UNKNOWN;
|
|
|
306fa1 |
|
|
|
306fa1 |
- master_source_current_wait(ap->entry);
|
|
|
306fa1 |
- ap->entry->current = source;
|
|
|
306fa1 |
-
|
|
|
306fa1 |
- status = check_map_indirect(ap, lkp_key, strlen(lkp_key), ctxt);
|
|
|
306fa1 |
+ status = check_map_indirect(ap, source,
|
|
|
306fa1 |
+ lkp_key, strlen(lkp_key), ctxt);
|
|
|
306fa1 |
free(lkp_key);
|
|
|
306fa1 |
if (status) {
|
|
|
306fa1 |
if (status == NSS_STATUS_COMPLETED)
|
|
|
306fa1 |
--- autofs-5.0.7.orig/modules/lookup_ldap.c
|
|
|
306fa1 |
+++ autofs-5.0.7/modules/lookup_ldap.c
|
|
|
306fa1 |
@@ -2321,20 +2321,16 @@ next:
|
|
|
306fa1 |
|
|
|
306fa1 |
|
|
|
306fa1 |
static int read_one_map(struct autofs_point *ap,
|
|
|
306fa1 |
+ struct map_source *source,
|
|
|
306fa1 |
struct lookup_context *ctxt,
|
|
|
306fa1 |
time_t age, int *result_ldap)
|
|
|
306fa1 |
{
|
|
|
306fa1 |
- struct map_source *source;
|
|
|
306fa1 |
struct ldap_search_params sp;
|
|
|
306fa1 |
char buf[MAX_ERR_BUF];
|
|
|
306fa1 |
char *class, *info, *entry;
|
|
|
306fa1 |
char *attrs[3];
|
|
|
306fa1 |
int rv, l;
|
|
|
306fa1 |
|
|
|
306fa1 |
- source = ap->entry->current;
|
|
|
306fa1 |
- ap->entry->current = NULL;
|
|
|
306fa1 |
- master_source_current_signal(ap->entry);
|
|
|
306fa1 |
-
|
|
|
306fa1 |
/*
|
|
|
306fa1 |
* If we don't need to create directories then there's no use
|
|
|
306fa1 |
* reading the map. We always need to read the whole map for
|
|
|
306fa1 |
@@ -2453,11 +2449,16 @@ static int read_one_map(struct autofs_po
|
|
|
306fa1 |
int lookup_read_map(struct autofs_point *ap, time_t age, void *context)
|
|
|
306fa1 |
{
|
|
|
306fa1 |
struct lookup_context *ctxt = (struct lookup_context *) context;
|
|
|
306fa1 |
+ struct map_source *source;
|
|
|
306fa1 |
int rv = LDAP_SUCCESS;
|
|
|
306fa1 |
int ret, cur_state;
|
|
|
306fa1 |
|
|
|
306fa1 |
+ source = ap->entry->current;
|
|
|
306fa1 |
+ ap->entry->current = NULL;
|
|
|
306fa1 |
+ master_source_current_signal(ap->entry);
|
|
|
306fa1 |
+
|
|
|
306fa1 |
pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &cur_state);
|
|
|
306fa1 |
- ret = read_one_map(ap, ctxt, age, &rv;;
|
|
|
306fa1 |
+ ret = read_one_map(ap, source, ctxt, age, &rv;;
|
|
|
306fa1 |
if (ret != NSS_STATUS_SUCCESS) {
|
|
|
306fa1 |
switch (rv) {
|
|
|
306fa1 |
case LDAP_SIZELIMIT_EXCEEDED:
|
|
|
306fa1 |
@@ -2474,10 +2475,9 @@ int lookup_read_map(struct autofs_point
|
|
|
306fa1 |
return ret;
|
|
|
306fa1 |
}
|
|
|
306fa1 |
|
|
|
306fa1 |
-static int lookup_one(struct autofs_point *ap,
|
|
|
306fa1 |
+static int lookup_one(struct autofs_point *ap, struct map_source *source,
|
|
|
306fa1 |
char *qKey, int qKey_len, struct lookup_context *ctxt)
|
|
|
306fa1 |
{
|
|
|
306fa1 |
- struct map_source *source;
|
|
|
306fa1 |
struct mapent_cache *mc;
|
|
|
306fa1 |
int rv, i, l, ql, count;
|
|
|
306fa1 |
char buf[MAX_ERR_BUF];
|
|
|
306fa1 |
@@ -2496,10 +2496,6 @@ static int lookup_one(struct autofs_poin
|
|
|
306fa1 |
unsigned int wild = 0;
|
|
|
306fa1 |
int ret = CHE_MISSING;
|
|
|
306fa1 |
|
|
|
306fa1 |
- source = ap->entry->current;
|
|
|
306fa1 |
- ap->entry->current = NULL;
|
|
|
306fa1 |
- master_source_current_signal(ap->entry);
|
|
|
306fa1 |
-
|
|
|
306fa1 |
mc = source->mc;
|
|
|
306fa1 |
|
|
|
306fa1 |
if (ctxt == NULL) {
|
|
|
306fa1 |
@@ -2834,27 +2830,20 @@ next:
|
|
|
306fa1 |
}
|
|
|
306fa1 |
|
|
|
306fa1 |
static int check_map_indirect(struct autofs_point *ap,
|
|
|
306fa1 |
+ struct map_source *source,
|
|
|
306fa1 |
char *key, int key_len,
|
|
|
306fa1 |
struct lookup_context *ctxt)
|
|
|
306fa1 |
{
|
|
|
306fa1 |
- struct map_source *source;
|
|
|
306fa1 |
struct mapent_cache *mc;
|
|
|
306fa1 |
struct mapent *me;
|
|
|
306fa1 |
time_t now = time(NULL);
|
|
|
306fa1 |
time_t t_last_read;
|
|
|
306fa1 |
int ret, cur_state;
|
|
|
306fa1 |
|
|
|
306fa1 |
- source = ap->entry->current;
|
|
|
306fa1 |
- ap->entry->current = NULL;
|
|
|
306fa1 |
- master_source_current_signal(ap->entry);
|
|
|
306fa1 |
-
|
|
|
306fa1 |
mc = source->mc;
|
|
|
306fa1 |
|
|
|
306fa1 |
- master_source_current_wait(ap->entry);
|
|
|
306fa1 |
- ap->entry->current = source;
|
|
|
306fa1 |
-
|
|
|
306fa1 |
pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &cur_state);
|
|
|
306fa1 |
- ret = lookup_one(ap, key, key_len, ctxt);
|
|
|
306fa1 |
+ ret = lookup_one(ap, source, key, key_len, ctxt);
|
|
|
306fa1 |
if (ret == CHE_FAIL) {
|
|
|
306fa1 |
pthread_setcancelstate(cur_state, NULL);
|
|
|
306fa1 |
return NSS_STATUS_NOTFOUND;
|
|
|
306fa1 |
@@ -2974,10 +2963,8 @@ int lookup_mount(struct autofs_point *ap
|
|
|
306fa1 |
if (!lkp_key)
|
|
|
306fa1 |
return NSS_STATUS_UNKNOWN;
|
|
|
306fa1 |
|
|
|
306fa1 |
- master_source_current_wait(ap->entry);
|
|
|
306fa1 |
- ap->entry->current = source;
|
|
|
306fa1 |
-
|
|
|
306fa1 |
- status = check_map_indirect(ap, lkp_key, strlen(lkp_key), ctxt);
|
|
|
306fa1 |
+ status = check_map_indirect(ap, source,
|
|
|
306fa1 |
+ lkp_key, strlen(lkp_key), ctxt);
|
|
|
306fa1 |
free(lkp_key);
|
|
|
306fa1 |
if (status)
|
|
|
306fa1 |
return status;
|
|
|
306fa1 |
--- autofs-5.0.7.orig/modules/lookup_nisplus.c
|
|
|
306fa1 |
+++ autofs-5.0.7/modules/lookup_nisplus.c
|
|
|
306fa1 |
@@ -267,10 +267,10 @@ int lookup_read_map(struct autofs_point
|
|
|
306fa1 |
}
|
|
|
306fa1 |
|
|
|
306fa1 |
static int lookup_one(struct autofs_point *ap,
|
|
|
306fa1 |
+ struct map_source *source,
|
|
|
306fa1 |
const char *key, int key_len,
|
|
|
306fa1 |
struct lookup_context *ctxt)
|
|
|
306fa1 |
{
|
|
|
306fa1 |
- struct map_source *source;
|
|
|
306fa1 |
struct mapent_cache *mc;
|
|
|
306fa1 |
char *tablename;
|
|
|
306fa1 |
nis_result *result;
|
|
|
306fa1 |
@@ -280,10 +280,6 @@ static int lookup_one(struct autofs_poin
|
|
|
306fa1 |
int ret, cur_state;
|
|
|
306fa1 |
char buf[MAX_ERR_BUF];
|
|
|
306fa1 |
|
|
|
306fa1 |
- source = ap->entry->current;
|
|
|
306fa1 |
- ap->entry->current = NULL;
|
|
|
306fa1 |
- master_source_current_signal(ap->entry);
|
|
|
306fa1 |
-
|
|
|
306fa1 |
mc = source->mc;
|
|
|
306fa1 |
|
|
|
306fa1 |
pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &cur_state);
|
|
|
306fa1 |
@@ -326,9 +322,9 @@ static int lookup_one(struct autofs_poin
|
|
|
306fa1 |
return ret;
|
|
|
306fa1 |
}
|
|
|
306fa1 |
|
|
|
306fa1 |
-static int lookup_wild(struct autofs_point *ap, struct lookup_context *ctxt)
|
|
|
306fa1 |
+static int lookup_wild(struct autofs_point *ap,
|
|
|
306fa1 |
+ struct map_source *source, struct lookup_context *ctxt)
|
|
|
306fa1 |
{
|
|
|
306fa1 |
- struct map_source *source;
|
|
|
306fa1 |
struct mapent_cache *mc;
|
|
|
306fa1 |
char *tablename;
|
|
|
306fa1 |
nis_result *result;
|
|
|
306fa1 |
@@ -338,10 +334,6 @@ static int lookup_wild(struct autofs_poi
|
|
|
306fa1 |
int ret, cur_state;
|
|
|
306fa1 |
char buf[MAX_ERR_BUF];
|
|
|
306fa1 |
|
|
|
306fa1 |
- source = ap->entry->current;
|
|
|
306fa1 |
- ap->entry->current = NULL;
|
|
|
306fa1 |
- master_source_current_signal(ap->entry);
|
|
|
306fa1 |
-
|
|
|
306fa1 |
mc = source->mc;
|
|
|
306fa1 |
|
|
|
306fa1 |
pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &cur_state);
|
|
|
306fa1 |
@@ -383,27 +375,20 @@ static int lookup_wild(struct autofs_poi
|
|
|
306fa1 |
}
|
|
|
306fa1 |
|
|
|
306fa1 |
static int check_map_indirect(struct autofs_point *ap,
|
|
|
306fa1 |
+ struct map_source *source,
|
|
|
306fa1 |
char *key, int key_len,
|
|
|
306fa1 |
struct lookup_context *ctxt)
|
|
|
306fa1 |
{
|
|
|
306fa1 |
- struct map_source *source;
|
|
|
306fa1 |
struct mapent_cache *mc;
|
|
|
306fa1 |
struct mapent *me, *exists;
|
|
|
306fa1 |
time_t now = time(NULL);
|
|
|
306fa1 |
time_t t_last_read;
|
|
|
306fa1 |
int ret = 0;
|
|
|
306fa1 |
|
|
|
306fa1 |
- source = ap->entry->current;
|
|
|
306fa1 |
- ap->entry->current = NULL;
|
|
|
306fa1 |
- master_source_current_signal(ap->entry);
|
|
|
306fa1 |
-
|
|
|
306fa1 |
mc = source->mc;
|
|
|
306fa1 |
|
|
|
306fa1 |
- master_source_current_wait(ap->entry);
|
|
|
306fa1 |
- ap->entry->current = source;
|
|
|
306fa1 |
-
|
|
|
306fa1 |
/* check map and if change is detected re-read map */
|
|
|
306fa1 |
- ret = lookup_one(ap, key, key_len, ctxt);
|
|
|
306fa1 |
+ ret = lookup_one(ap, source, key, key_len, ctxt);
|
|
|
306fa1 |
if (ret == CHE_FAIL)
|
|
|
306fa1 |
return NSS_STATUS_NOTFOUND;
|
|
|
306fa1 |
|
|
|
306fa1 |
@@ -452,10 +437,7 @@ static int check_map_indirect(struct aut
|
|
|
306fa1 |
int wild = CHE_MISSING;
|
|
|
306fa1 |
struct mapent *we;
|
|
|
306fa1 |
|
|
|
306fa1 |
- master_source_current_wait(ap->entry);
|
|
|
306fa1 |
- ap->entry->current = source;
|
|
|
306fa1 |
-
|
|
|
306fa1 |
- wild = lookup_wild(ap, ctxt);
|
|
|
306fa1 |
+ wild = lookup_wild(ap, source, ctxt);
|
|
|
306fa1 |
/*
|
|
|
306fa1 |
* Check for map change and update as needed for
|
|
|
306fa1 |
* following cache lookup.
|
|
|
306fa1 |
@@ -553,10 +535,8 @@ int lookup_mount(struct autofs_point *ap
|
|
|
306fa1 |
if (!lkp_key)
|
|
|
306fa1 |
return NSS_STATUS_UNKNOWN;
|
|
|
306fa1 |
|
|
|
306fa1 |
- master_source_current_wait(ap->entry);
|
|
|
306fa1 |
- ap->entry->current = source;
|
|
|
306fa1 |
-
|
|
|
306fa1 |
- status = check_map_indirect(ap, lkp_key, strlen(lkp_key), ctxt);
|
|
|
306fa1 |
+ status = check_map_indirect(ap, source,
|
|
|
306fa1 |
+ lkp_key, strlen(lkp_key), ctxt);
|
|
|
306fa1 |
if (status)
|
|
|
306fa1 |
return status;
|
|
|
306fa1 |
}
|
|
|
306fa1 |
--- autofs-5.0.7.orig/modules/lookup_yp.c
|
|
|
306fa1 |
+++ autofs-5.0.7/modules/lookup_yp.c
|
|
|
306fa1 |
@@ -377,10 +377,10 @@ int lookup_read_map(struct autofs_point
|
|
|
306fa1 |
}
|
|
|
306fa1 |
|
|
|
306fa1 |
static int lookup_one(struct autofs_point *ap,
|
|
|
306fa1 |
+ struct map_source *source,
|
|
|
306fa1 |
const char *key, int key_len,
|
|
|
306fa1 |
struct lookup_context *ctxt)
|
|
|
306fa1 |
{
|
|
|
306fa1 |
- struct map_source *source;
|
|
|
306fa1 |
struct mapent_cache *mc;
|
|
|
306fa1 |
char *mapname;
|
|
|
306fa1 |
char *mapent;
|
|
|
306fa1 |
@@ -388,10 +388,6 @@ static int lookup_one(struct autofs_poin
|
|
|
306fa1 |
time_t age = time(NULL);
|
|
|
306fa1 |
int ret;
|
|
|
306fa1 |
|
|
|
306fa1 |
- source = ap->entry->current;
|
|
|
306fa1 |
- ap->entry->current = NULL;
|
|
|
306fa1 |
- master_source_current_signal(ap->entry);
|
|
|
306fa1 |
-
|
|
|
306fa1 |
mc = source->mc;
|
|
|
306fa1 |
|
|
|
306fa1 |
mapname = alloca(strlen(ctxt->mapname) + 1);
|
|
|
306fa1 |
@@ -436,9 +432,9 @@ static int lookup_one(struct autofs_poin
|
|
|
306fa1 |
return ret;
|
|
|
306fa1 |
}
|
|
|
306fa1 |
|
|
|
306fa1 |
-static int lookup_wild(struct autofs_point *ap, struct lookup_context *ctxt)
|
|
|
306fa1 |
+static int lookup_wild(struct autofs_point *ap,
|
|
|
306fa1 |
+ struct map_source *source, struct lookup_context *ctxt)
|
|
|
306fa1 |
{
|
|
|
306fa1 |
- struct map_source *source;
|
|
|
306fa1 |
struct mapent_cache *mc;
|
|
|
306fa1 |
char *mapname;
|
|
|
306fa1 |
char *mapent;
|
|
|
306fa1 |
@@ -446,10 +442,6 @@ static int lookup_wild(struct autofs_poi
|
|
|
306fa1 |
time_t age = time(NULL);
|
|
|
306fa1 |
int ret;
|
|
|
306fa1 |
|
|
|
306fa1 |
- source = ap->entry->current;
|
|
|
306fa1 |
- ap->entry->current = NULL;
|
|
|
306fa1 |
- master_source_current_signal(ap->entry);
|
|
|
306fa1 |
-
|
|
|
306fa1 |
mc = source->mc;
|
|
|
306fa1 |
|
|
|
306fa1 |
mapname = alloca(strlen(ctxt->mapname) + 1);
|
|
|
306fa1 |
@@ -489,26 +481,19 @@ static int lookup_wild(struct autofs_poi
|
|
|
306fa1 |
}
|
|
|
306fa1 |
|
|
|
306fa1 |
static int check_map_indirect(struct autofs_point *ap,
|
|
|
306fa1 |
+ struct map_source *source,
|
|
|
306fa1 |
char *key, int key_len,
|
|
|
306fa1 |
struct lookup_context *ctxt)
|
|
|
306fa1 |
{
|
|
|
306fa1 |
- struct map_source *source;
|
|
|
306fa1 |
struct mapent_cache *mc;
|
|
|
306fa1 |
struct mapent *exists;
|
|
|
306fa1 |
unsigned int map_order;
|
|
|
306fa1 |
int ret = 0;
|
|
|
306fa1 |
|
|
|
306fa1 |
- source = ap->entry->current;
|
|
|
306fa1 |
- ap->entry->current = NULL;
|
|
|
306fa1 |
- master_source_current_signal(ap->entry);
|
|
|
306fa1 |
-
|
|
|
306fa1 |
mc = source->mc;
|
|
|
306fa1 |
|
|
|
306fa1 |
- master_source_current_wait(ap->entry);
|
|
|
306fa1 |
- ap->entry->current = source;
|
|
|
306fa1 |
-
|
|
|
306fa1 |
/* check map and if change is detected re-read map */
|
|
|
306fa1 |
- ret = lookup_one(ap, key, key_len, ctxt);
|
|
|
306fa1 |
+ ret = lookup_one(ap, source, key, key_len, ctxt);
|
|
|
306fa1 |
if (ret == CHE_FAIL)
|
|
|
306fa1 |
return NSS_STATUS_NOTFOUND;
|
|
|
306fa1 |
|
|
|
306fa1 |
@@ -556,10 +541,7 @@ static int check_map_indirect(struct aut
|
|
|
306fa1 |
struct mapent *we;
|
|
|
306fa1 |
int wild = CHE_MISSING;
|
|
|
306fa1 |
|
|
|
306fa1 |
- master_source_current_wait(ap->entry);
|
|
|
306fa1 |
- ap->entry->current = source;
|
|
|
306fa1 |
-
|
|
|
306fa1 |
- wild = lookup_wild(ap, ctxt);
|
|
|
306fa1 |
+ wild = lookup_wild(ap, source, ctxt);
|
|
|
306fa1 |
/*
|
|
|
306fa1 |
* Check for map change and update as needed for
|
|
|
306fa1 |
* following cache lookup.
|
|
|
306fa1 |
@@ -657,10 +639,8 @@ int lookup_mount(struct autofs_point *ap
|
|
|
306fa1 |
if (!lkp_key)
|
|
|
306fa1 |
return NSS_STATUS_UNKNOWN;
|
|
|
306fa1 |
|
|
|
306fa1 |
- master_source_current_wait(ap->entry);
|
|
|
306fa1 |
- ap->entry->current = source;
|
|
|
306fa1 |
-
|
|
|
306fa1 |
- status = check_map_indirect(ap, lkp_key, strlen(lkp_key), ctxt);
|
|
|
306fa1 |
+ status = check_map_indirect(ap, source,
|
|
|
306fa1 |
+ lkp_key, strlen(lkp_key), ctxt);
|
|
|
306fa1 |
free(lkp_key);
|
|
|
306fa1 |
if (status)
|
|
|
306fa1 |
return status;
|