summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSimo Sorce <simo@redhat.com>2013-01-08 00:35:05 -0500
committerJakub Hrozek <jhrozek@redhat.com>2013-01-15 10:53:02 +0100
commit2913240aee51ce81195148a4d814e967f66839c4 (patch)
tree271176b5688f86df6c3fb60a3596c28dfd7ee187 /src
parent043bda72889e9ef0c48b80b21c99e9e18c5f49d7 (diff)
downloadsssd-2913240aee51ce81195148a4d814e967f66839c4.tar.gz
sssd-2913240aee51ce81195148a4d814e967f66839c4.tar.xz
sssd-2913240aee51ce81195148a4d814e967f66839c4.zip
Add domain argument to sysdb autofs functions
Diffstat (limited to 'src')
-rw-r--r--src/db/sysdb_autofs.c37
-rw-r--r--src/db/sysdb_autofs.h10
-rw-r--r--src/db/sysdb_upgrade.c3
-rw-r--r--src/providers/ldap/sdap_async_autofs.c23
-rw-r--r--src/providers/ldap/sdap_autofs.c6
-rw-r--r--src/responder/autofs/autofssrv_cmd.c4
-rw-r--r--src/tests/sysdb-tests.c21
-rw-r--r--src/tools/sss_cache.c2
8 files changed, 68 insertions, 38 deletions
diff --git a/src/db/sysdb_autofs.c b/src/db/sysdb_autofs.c
index d0af1eef7..f8fe3925b 100644
--- a/src/db/sysdb_autofs.c
+++ b/src/db/sysdb_autofs.c
@@ -29,15 +29,16 @@
static struct ldb_dn *
sysdb_autofsmap_dn(TALLOC_CTX *mem_ctx,
struct sysdb_ctx *sysdb,
+ struct sss_domain_info *domain,
const char *map_name)
{
- return sysdb_custom_dn(sysdb, mem_ctx,
- sysdb->domain, map_name, AUTOFS_MAP_SUBDIR);
+ return sysdb_custom_dn(sysdb, mem_ctx, domain, map_name, AUTOFS_MAP_SUBDIR);
}
static struct ldb_dn *
sysdb_autofsentry_dn(TALLOC_CTX *mem_ctx,
struct sysdb_ctx *sysdb,
+ struct sss_domain_info *domain,
const char *map_name,
const char *entry_name,
const char *entry_value)
@@ -70,8 +71,7 @@ sysdb_autofsentry_dn(TALLOC_CTX *mem_ctx,
}
dn = ldb_dn_new_fmt(mem_ctx, sysdb->ldb, SYSDB_TMPL_AUTOFS_ENTRY,
- rdn, map_name, AUTOFS_MAP_SUBDIR,
- sysdb->domain->name);
+ rdn, map_name, AUTOFS_MAP_SUBDIR, domain->name);
done:
talloc_free(tmp_ctx);
@@ -80,6 +80,7 @@ done:
errno_t
sysdb_save_autofsmap(struct sysdb_ctx *sysdb_ctx,
+ struct sss_domain_info *domain,
const char *name,
const char *autofsmapname,
struct sysdb_attrs *attrs,
@@ -142,7 +143,7 @@ sysdb_save_autofsmap(struct sysdb_ctx *sysdb_ctx,
goto done;
}
- ret = sysdb_store_custom(sysdb_ctx, sysdb_ctx->domain, name, AUTOFS_MAP_SUBDIR, attrs);
+ ret = sysdb_store_custom(sysdb_ctx, domain, name, AUTOFS_MAP_SUBDIR, attrs);
if (ret != EOK) {
DEBUG(SSSDBG_OP_FAILURE, ("sysdb_store_custom failed [%d]: %s\n",
ret, strerror(ret)));
@@ -157,15 +158,17 @@ done:
errno_t
sysdb_delete_autofsmap(struct sysdb_ctx *sysdb_ctx,
+ struct sss_domain_info *domain,
const char *name)
{
DEBUG(SSSDBG_TRACE_FUNC, ("Deleting autofs map %s\n", name));
- return sysdb_delete_custom(sysdb_ctx, sysdb_ctx->domain, name, AUTOFS_MAP_SUBDIR);
+ return sysdb_delete_custom(sysdb_ctx, domain, name, AUTOFS_MAP_SUBDIR);
}
errno_t
sysdb_get_map_byname(TALLOC_CTX *mem_ctx,
struct sysdb_ctx *sysdb,
+ struct sss_domain_info *domain,
const char *map_name,
struct ldb_message **_map)
{
@@ -200,7 +203,7 @@ sysdb_get_map_byname(TALLOC_CTX *mem_ctx,
goto done;
}
- ret = sysdb_search_custom(tmp_ctx, sysdb, sysdb->domain, filter,
+ ret = sysdb_search_custom(tmp_ctx, sysdb, domain, filter,
AUTOFS_MAP_SUBDIR, attrs,
&count, &msgs);
if (ret != EOK && ret != ENOENT) {
@@ -228,6 +231,7 @@ done:
errno_t
sysdb_save_autofsentry(struct sysdb_ctx *sysdb_ctx,
+ struct sss_domain_info *domain,
const char *map,
const char *key,
const char *value,
@@ -290,7 +294,7 @@ sysdb_save_autofsentry(struct sysdb_ctx *sysdb_ctx,
goto done;
}
- dn = sysdb_autofsentry_dn(tmp_ctx, sysdb_ctx, map, key, value);
+ dn = sysdb_autofsentry_dn(tmp_ctx, sysdb_ctx, domain, map, key, value);
if (!dn) {
ret = ENOMEM;
goto done;
@@ -315,6 +319,7 @@ done:
errno_t
sysdb_del_autofsentry(struct sysdb_ctx *sysdb_ctx,
+ struct sss_domain_info *domain,
const char *map,
const char *key,
const char *value)
@@ -322,7 +327,7 @@ sysdb_del_autofsentry(struct sysdb_ctx *sysdb_ctx,
struct ldb_dn *dn;
errno_t ret;
- dn = sysdb_autofsentry_dn(sysdb_ctx, sysdb_ctx, map, key, value);
+ dn = sysdb_autofsentry_dn(sysdb_ctx, sysdb_ctx, domain, map, key, value);
if (!dn) {
return ENOMEM;
}
@@ -335,6 +340,7 @@ sysdb_del_autofsentry(struct sysdb_ctx *sysdb_ctx,
errno_t
sysdb_autofs_entries_by_map(TALLOC_CTX *mem_ctx,
struct sysdb_ctx *sysdb,
+ struct sss_domain_info *domain,
const char *mapname,
size_t *_count,
struct ldb_message ***_entries)
@@ -356,7 +362,7 @@ sysdb_autofs_entries_by_map(TALLOC_CTX *mem_ctx,
return ENOMEM;
}
- mapdn = sysdb_autofsmap_dn(tmp_ctx, sysdb, mapname);
+ mapdn = sysdb_autofsmap_dn(tmp_ctx, sysdb, domain, mapname);
if (!mapdn) {
ret = ENOMEM;
goto done;
@@ -393,6 +399,7 @@ done:
errno_t
sysdb_set_autofsmap_attr(struct sysdb_ctx *sysdb,
+ struct sss_domain_info *domain,
const char *name,
struct sysdb_attrs *attrs,
int mod_op)
@@ -406,7 +413,7 @@ sysdb_set_autofsmap_attr(struct sysdb_ctx *sysdb,
return ENOMEM;
}
- dn = sysdb_autofsmap_dn(tmp_ctx, sysdb, name);
+ dn = sysdb_autofsmap_dn(tmp_ctx, sysdb, domain, name);
if (!dn) {
ret = ENOMEM;
goto done;
@@ -420,7 +427,8 @@ done:
}
errno_t
-sysdb_invalidate_autofs_maps(struct sysdb_ctx *sysdb)
+sysdb_invalidate_autofs_maps(struct sysdb_ctx *sysdb,
+ struct sss_domain_info *domain)
{
errno_t ret;
TALLOC_CTX *tmp_ctx;
@@ -447,7 +455,7 @@ sysdb_invalidate_autofs_maps(struct sysdb_ctx *sysdb)
goto done;
}
- ret = sysdb_search_custom(tmp_ctx, sysdb, sysdb->domain, filter,
+ ret = sysdb_search_custom(tmp_ctx, sysdb, domain, filter,
AUTOFS_MAP_SUBDIR, attrs,
&count, &msgs);
if (ret != EOK && ret != ENOENT) {
@@ -484,7 +492,8 @@ sysdb_invalidate_autofs_maps(struct sysdb_ctx *sysdb)
continue;
}
- ret = sysdb_set_autofsmap_attr(sysdb, name, sys_attrs, SYSDB_MOD_REP);
+ ret = sysdb_set_autofsmap_attr(sysdb, domain, name,
+ sys_attrs, SYSDB_MOD_REP);
if (ret != EOK) {
DEBUG(SSSDBG_MINOR_FAILURE, ("Could not expire map %s\n", name));
continue;
diff --git a/src/db/sysdb_autofs.h b/src/db/sysdb_autofs.h
index 8c8d0f560..0d1309462 100644
--- a/src/db/sysdb_autofs.h
+++ b/src/db/sysdb_autofs.h
@@ -37,6 +37,7 @@
errno_t
sysdb_save_autofsmap(struct sysdb_ctx *sysdb_ctx,
+ struct sss_domain_info *domain,
const char *name,
const char *autofsmapname,
struct sysdb_attrs *attrs,
@@ -46,21 +47,25 @@ sysdb_save_autofsmap(struct sysdb_ctx *sysdb_ctx,
errno_t
sysdb_get_map_byname(TALLOC_CTX *mem_ctx,
struct sysdb_ctx *sysdb,
+ struct sss_domain_info *domain,
const char *map_name,
struct ldb_message **map);
errno_t
sysdb_delete_autofsmap(struct sysdb_ctx *sysdb_ctx,
+ struct sss_domain_info *domain,
const char *name);
errno_t
sysdb_save_autofsentry(struct sysdb_ctx *sysdb_ctx,
+ struct sss_domain_info *domain,
const char *map,
const char *key,
const char *value,
struct sysdb_attrs *attrs);
errno_t
sysdb_del_autofsentry(struct sysdb_ctx *sysdb_ctx,
+ struct sss_domain_info *domain,
const char *map,
const char *key,
const char *value);
@@ -68,17 +73,20 @@ sysdb_del_autofsentry(struct sysdb_ctx *sysdb_ctx,
errno_t
sysdb_autofs_entries_by_map(TALLOC_CTX *mem_ctx,
struct sysdb_ctx *sysdb,
+ struct sss_domain_info *domain,
const char *mapname,
size_t *_count,
struct ldb_message ***_entries);
errno_t
sysdb_set_autofsmap_attr(struct sysdb_ctx *sysdb,
+ struct sss_domain_info *domain,
const char *name,
struct sysdb_attrs *attrs,
int mod_op);
errno_t
-sysdb_invalidate_autofs_maps(struct sysdb_ctx *sysdb);
+sysdb_invalidate_autofs_maps(struct sysdb_ctx *sysdb,
+ struct sss_domain_info *domain);
#endif /* _SYSDB_AUTOFS_H_ */
diff --git a/src/db/sysdb_upgrade.c b/src/db/sysdb_upgrade.c
index 42a048d1a..205c5bd02 100644
--- a/src/db/sysdb_upgrade.c
+++ b/src/db/sysdb_upgrade.c
@@ -1192,7 +1192,8 @@ int sysdb_upgrade_11(struct sysdb_ctx *sysdb, const char **ver)
continue;
}
- ret = sysdb_save_autofsentry(sysdb, (const char *) val->data,
+ ret = sysdb_save_autofsentry(sysdb, sysdb->domain,
+ (const char *) val->data,
key, value, NULL);
if (ret != EOK) {
DEBUG(SSSDBG_OP_FAILURE,
diff --git a/src/providers/ldap/sdap_async_autofs.c b/src/providers/ldap/sdap_async_autofs.c
index fdffd1d5a..6306991e2 100644
--- a/src/providers/ldap/sdap_async_autofs.c
+++ b/src/providers/ldap/sdap_async_autofs.c
@@ -66,6 +66,7 @@ get_autofs_entry_key(struct sysdb_attrs *entry, struct sdap_options *opts)
static errno_t
mod_autofs_entry(struct sysdb_ctx *sysdb,
+ struct sss_domain_info *domain,
const char *map,
struct sdap_options *opts,
struct sysdb_attrs *entry,
@@ -88,10 +89,10 @@ mod_autofs_entry(struct sysdb_ctx *sysdb,
switch (mod_op) {
case AUTOFS_MAP_OP_ADD:
- ret = sysdb_save_autofsentry(sysdb, map, key, value, NULL);
+ ret = sysdb_save_autofsentry(sysdb, domain, map, key, value, NULL);
break;
case AUTOFS_MAP_OP_DEL:
- ret = sysdb_del_autofsentry(sysdb, map, key, value);
+ ret = sysdb_del_autofsentry(sysdb, domain, map, key, value);
break;
}
@@ -100,6 +101,7 @@ mod_autofs_entry(struct sysdb_ctx *sysdb,
static errno_t
mod_autofs_entries(struct sysdb_ctx *sysdb,
+ struct sss_domain_info *domain,
struct sdap_options *opts,
const char *map,
char **mod_entries,
@@ -139,7 +141,7 @@ mod_autofs_entries(struct sysdb_ctx *sysdb,
continue;
}
- ret = mod_autofs_entry(sysdb, map, opts, entries[j], mod_op);
+ ret = mod_autofs_entry(sysdb, domain, map, opts, entries[j], mod_op);
if (ret != EOK) {
DEBUG(SSSDBG_OP_FAILURE,
("Cannot modify autofs entry [%d]: %s. Ignoring.\n",
@@ -173,25 +175,27 @@ done:
static errno_t
save_autofs_entries(struct sysdb_ctx *sysdb,
+ struct sss_domain_info *domain,
struct sdap_options *opts,
const char *map,
char **add_entries,
struct sysdb_attrs **entries,
size_t num_entries)
{
- return mod_autofs_entries(sysdb, opts, map, add_entries,
+ return mod_autofs_entries(sysdb, domain, opts, map, add_entries,
entries, num_entries, AUTOFS_MAP_OP_ADD);
}
static errno_t
del_autofs_entries(struct sysdb_ctx *sysdb,
+ struct sss_domain_info *domain,
struct sdap_options *opts,
const char *map,
char **add_entries,
struct sysdb_attrs **entries,
size_t num_entries)
{
- return mod_autofs_entries(sysdb, opts, map, add_entries,
+ return mod_autofs_entries(sysdb, domain, opts, map, add_entries,
entries, num_entries, AUTOFS_MAP_OP_DEL);
}
@@ -210,7 +214,7 @@ save_autofs_map(struct sysdb_ctx *sysdb,
now = time(NULL);
- ret = sysdb_save_autofsmap(sysdb, mapname, mapname,
+ ret = sysdb_save_autofsmap(sysdb, dom, mapname, mapname,
NULL, dom->autofsmap_timeout, now);
if (ret != EOK) {
return ret;
@@ -826,7 +830,8 @@ sdap_autofs_setautomntent_save(struct tevent_req *req)
}
}
- ret = sysdb_autofs_entries_by_map(tmp_ctx, state->sysdb, state->mapname,
+ ret = sysdb_autofs_entries_by_map(tmp_ctx, state->sysdb,
+ state->dom, state->mapname,
&count, &entries);
if (ret != EOK && ret != ENOENT) {
DEBUG(SSSDBG_OP_FAILURE,
@@ -890,7 +895,7 @@ sdap_autofs_setautomntent_save(struct tevent_req *req)
/* Create entries that don't exist yet */
if (add_entries && add_entries[0]) {
- ret = save_autofs_entries(state->sysdb, state->opts,
+ ret = save_autofs_entries(state->sysdb, state->dom, state->opts,
state->mapname, add_entries,
state->entries, state->entries_count);
if (ret != EOK) {
@@ -910,7 +915,7 @@ sdap_autofs_setautomntent_save(struct tevent_req *req)
goto done;
}
- ret = del_autofs_entries(state->sysdb, state->opts,
+ ret = del_autofs_entries(state->sysdb, state->dom, state->opts,
state->mapname, del_entries,
entries_attrs, count);
if (ret != EOK) {
diff --git a/src/providers/ldap/sdap_autofs.c b/src/providers/ldap/sdap_autofs.c
index 7e6f3ecf7..97b9f3edc 100644
--- a/src/providers/ldap/sdap_autofs.c
+++ b/src/providers/ldap/sdap_autofs.c
@@ -98,7 +98,8 @@ void sdap_autofs_handler(struct be_req *be_req)
autofs_req->mapname ? autofs_req->mapname : "<ALL>\n"));
if (autofs_req->invalidate) {
- ret = sysdb_invalidate_autofs_maps(id_ctx->be->sysdb);
+ ret = sysdb_invalidate_autofs_maps(id_ctx->be->sysdb,
+ id_ctx->be->domain);
if (ret != EOK) {
DEBUG(SSSDBG_MINOR_FAILURE, ("Could not invalidate autofs maps, "
"backend might return stale entries\n"));
@@ -256,7 +257,8 @@ sdap_autofs_get_map_done(struct tevent_req *subreq)
}
if (ret == ENOENT) {
- ret = sysdb_delete_autofsmap(state->ctx->be->sysdb, state->map_name);
+ ret = sysdb_delete_autofsmap(state->ctx->be->sysdb,
+ state->ctx->be->domain, state->map_name);
if (ret != EOK && ret != ENOENT) {
DEBUG(SSSDBG_OP_FAILURE,
("Cannot delete autofs map %s [%d]: %s\n",
diff --git a/src/responder/autofs/autofssrv_cmd.c b/src/responder/autofs/autofssrv_cmd.c
index b85079d0d..7443ebbfa 100644
--- a/src/responder/autofs/autofssrv_cmd.c
+++ b/src/responder/autofs/autofssrv_cmd.c
@@ -654,7 +654,7 @@ lookup_automntmap_step(struct setautomntent_lookup_ctx *lookup_ctx)
/* Look into the cache */
talloc_free(dctx->map);
- ret = sysdb_get_map_byname(dctx, sysdb, lookup_ctx->mapname,
+ ret = sysdb_get_map_byname(dctx, sysdb, dom, lookup_ctx->mapname,
&dctx->map);
if (ret != EOK && ret != ENOENT) {
DEBUG(SSSDBG_OP_FAILURE, ("Could not check cache\n"));
@@ -706,7 +706,7 @@ lookup_automntmap_step(struct setautomntent_lookup_ctx *lookup_ctx)
/* OK, the map is in cache and valid.
* Let's get all members and return it
*/
- ret = sysdb_autofs_entries_by_map(map, sysdb, map->mapname,
+ ret = sysdb_autofs_entries_by_map(map, sysdb, dom, map->mapname,
&map->entry_count,
&map->entries);
if (ret != EOK && ret != ENOENT) {
diff --git a/src/tests/sysdb-tests.c b/src/tests/sysdb-tests.c
index fa583e5ef..7735316be 100644
--- a/src/tests/sysdb-tests.c
+++ b/src/tests/sysdb-tests.c
@@ -4529,7 +4529,8 @@ START_TEST(test_autofs_create_map)
autofsmapname = talloc_asprintf(test_ctx, "testmap%d", _i);
fail_if(autofsmapname == NULL, "Out of memory\n");
- ret = sysdb_save_autofsmap(test_ctx->sysdb, autofsmapname,
+ ret = sysdb_save_autofsmap(test_ctx->sysdb,
+ test_ctx->domain, autofsmapname,
autofsmapname, NULL, 0, 0);
fail_if(ret != EOK, "Could not store autofs map %s", autofsmapname);
talloc_free(test_ctx);
@@ -4549,7 +4550,7 @@ START_TEST(test_autofs_retrieve_map)
autofsmapname = talloc_asprintf(test_ctx, "testmap%d", _i);
fail_if(autofsmapname == NULL, "Out of memory\n");
- ret = sysdb_get_map_byname(test_ctx, test_ctx->sysdb,
+ ret = sysdb_get_map_byname(test_ctx, test_ctx->sysdb, test_ctx->domain,
autofsmapname, &map);
fail_if(ret != EOK, "Could not retrieve autofs map %s", autofsmapname);
fail_if(map == NULL, "No map retrieved?\n");
@@ -4569,7 +4570,8 @@ START_TEST(test_autofs_delete_map)
autofsmapname = talloc_asprintf(test_ctx, "testmap%d", _i);
fail_if(autofsmapname == NULL, "Out of memory\n");
- ret = sysdb_delete_autofsmap(test_ctx->sysdb, autofsmapname);
+ ret = sysdb_delete_autofsmap(test_ctx->sysdb,
+ test_ctx->domain, autofsmapname);
fail_if(ret != EOK, "Could not retrieve autofs map %s", autofsmapname);
talloc_free(test_ctx);
}
@@ -4588,7 +4590,7 @@ START_TEST(test_autofs_retrieve_map_neg)
autofsmapname = talloc_asprintf(test_ctx, "testmap%d", _i);
fail_if(autofsmapname == NULL, "Out of memory\n");
- ret = sysdb_get_map_byname(test_ctx, test_ctx->sysdb,
+ ret = sysdb_get_map_byname(test_ctx, test_ctx->sysdb, test_ctx->domain,
autofsmapname, &map);
fail_if(ret != ENOENT, "Expected ENOENT, got %d instead\n", ret);
fail_if(map != NULL, "Unexpected map found\n");
@@ -4620,7 +4622,8 @@ START_TEST(test_autofs_store_entry_in_map)
autofsval = talloc_asprintf(test_ctx, "testserver:/testval%d", ii);
fail_if(autofsval == NULL, "Out of memory\n");
- ret = sysdb_save_autofsentry(test_ctx->sysdb, autofsmapname, autofskey,
+ ret = sysdb_save_autofsentry(test_ctx->sysdb, test_ctx->domain,
+ autofsmapname, autofskey,
autofsval, NULL);
fail_if(ret != EOK, "Could not save autofs entry %s", autofskey);
}
@@ -4644,7 +4647,8 @@ START_TEST(test_autofs_retrieve_keys_by_map)
autofsmapname = talloc_asprintf(test_ctx, "testmap%d", _i);
fail_if(autofsmapname == NULL, "Out of memory\n");
- ret = sysdb_autofs_entries_by_map(test_ctx, test_ctx->sysdb,
+ ret = sysdb_autofs_entries_by_map(test_ctx,
+ test_ctx->sysdb, test_ctx->domain,
autofsmapname, &count, &entries);
fail_if(ret != EOK, "Cannot get autofs entries for map %s\n",
autofsmapname);
@@ -4674,7 +4678,8 @@ START_TEST(test_autofs_key_duplicate)
autofsval = talloc_asprintf(test_ctx, "testserver:/testval%d", _i);
fail_if(autofsval == NULL, "Out of memory\n");
- ret = sysdb_save_autofsentry(test_ctx->sysdb, autofsmapname, autofskey,
+ ret = sysdb_save_autofsentry(test_ctx->sysdb, test_ctx->domain,
+ autofsmapname, autofskey,
autofsval, NULL);
fail_if(ret != EOK, "Could not save autofs entry %s", autofskey);
talloc_free(test_ctx);
@@ -4706,7 +4711,7 @@ START_TEST(test_autofs_get_duplicate_keys)
fail_if(filter == NULL, "Out of memory\n");
dn = ldb_dn_new_fmt(test_ctx, test_ctx->sysdb->ldb, SYSDB_TMPL_CUSTOM_SUBTREE,
- AUTOFS_MAP_SUBDIR, test_ctx->sysdb->domain->name);
+ AUTOFS_MAP_SUBDIR, test_ctx->domain->name);
fail_if(dn == NULL, "Out of memory\n");
ret = sysdb_search_entry(test_ctx, test_ctx->sysdb, dn, LDB_SCOPE_SUBTREE,
diff --git a/src/tools/sss_cache.c b/src/tools/sss_cache.c
index c54697145..afdff7912 100644
--- a/src/tools/sss_cache.c
+++ b/src/tools/sss_cache.c
@@ -382,7 +382,7 @@ static errno_t invalidate_entry(TALLOC_CTX *ctx, struct sysdb_ctx *sysdb,
sys_attrs, SYSDB_MOD_REP);
break;
case TYPE_AUTOFSMAP:
- ret = sysdb_set_autofsmap_attr(sysdb, name,
+ ret = sysdb_set_autofsmap_attr(sysdb, domain, name,
sys_attrs, SYSDB_MOD_REP);
break;
default: