summaryrefslogtreecommitdiff
path: root/src/db
diff options
context:
space:
mode:
authorJakub Hrozek <jhrozek@redhat.com>2012-09-23 17:18:50 +0200
committerJakub Hrozek <jhrozek@redhat.com>2012-09-24 18:18:30 +0200
commite75a152157e054a2ed46acecbe8b5cfb9853773c (patch)
treeea6d942492af92e0f30a662a2fc5ec494e6d25ae /src/db
parentf17d26a8db285622a5cd5f21c7488b62eedc2cf8 (diff)
downloadsssd-e75a152157e054a2ed46acecbe8b5cfb9853773c.tar.gz
sssd-e75a152157e054a2ed46acecbe8b5cfb9853773c.tar.bz2
sssd-e75a152157e054a2ed46acecbe8b5cfb9853773c.zip
AUTOFS: Use both key and value in entry RDN
This patch switches from using just key in the RDN to using both key and value. That is neccessary to allow multiple direct mounts in a single map.
Diffstat (limited to 'src/db')
-rw-r--r--src/db/sysdb_autofs.c48
-rw-r--r--src/db/sysdb_autofs.h3
2 files changed, 40 insertions, 11 deletions
diff --git a/src/db/sysdb_autofs.c b/src/db/sysdb_autofs.c
index b3df33f6..bf4e9b17 100644
--- a/src/db/sysdb_autofs.c
+++ b/src/db/sysdb_autofs.c
@@ -39,22 +39,42 @@ static struct ldb_dn *
sysdb_autofsentry_dn(TALLOC_CTX *mem_ctx,
struct sysdb_ctx *sysdb,
const char *map_name,
- const char *entry_name)
+ const char *entry_name,
+ const char *entry_value)
{
errno_t ret;
+ TALLOC_CTX *tmp_ctx;
char *clean_name;
- struct ldb_dn *dn;
+ char *clean_value;
+ const char *rdn;
+ struct ldb_dn *dn = NULL;
- ret = sysdb_dn_sanitize(NULL, entry_name, &clean_name);
- if (ret != EOK) {
+ tmp_ctx = talloc_new(NULL);
+ if (!tmp_ctx) {
return NULL;
}
+ ret = sysdb_dn_sanitize(tmp_ctx, entry_name, &clean_name);
+ if (ret != EOK) {
+ goto done;
+ }
+
+ ret = sysdb_dn_sanitize(tmp_ctx, entry_value, &clean_value);
+ if (ret != EOK) {
+ goto done;
+ }
+
+ rdn = talloc_asprintf(tmp_ctx, "%s%s", clean_name, clean_value);
+ if (!rdn) {
+ goto done;
+ }
+
dn = ldb_dn_new_fmt(mem_ctx, sysdb->ldb, SYSDB_TMPL_AUTOFS_ENTRY,
- clean_name, map_name, AUTOFS_MAP_SUBDIR,
+ rdn, map_name, AUTOFS_MAP_SUBDIR,
sysdb->domain->name);
- talloc_free(clean_name);
+done:
+ talloc_free(tmp_ctx);
return dn;
}
@@ -217,6 +237,7 @@ sysdb_save_autofsentry(struct sysdb_ctx *sysdb_ctx,
TALLOC_CTX *tmp_ctx;
struct ldb_message *msg;
struct ldb_dn *dn;
+ const char *name;
DEBUG(SSSDBG_TRACE_FUNC,
("Adding autofs entry [%s] - [%s]\n", key, value));
@@ -256,14 +277,20 @@ sysdb_save_autofsentry(struct sysdb_ctx *sysdb_ctx,
goto done;
}
- ret = sysdb_attrs_add_string(attrs, SYSDB_NAME, key);
+ name = talloc_asprintf(tmp_ctx, "%s%s", key, value);
+ if (!name) {
+ ret = ENOMEM;
+ goto done;
+ }
+
+ ret = sysdb_attrs_add_string(attrs, SYSDB_NAME, name);
if (ret != EOK) {
DEBUG(SSSDBG_OP_FAILURE, ("Could not set name attribute [%d]: %s\n",
ret, strerror(ret)));
goto done;
}
- dn = sysdb_autofsentry_dn(tmp_ctx, sysdb_ctx, map, key);
+ dn = sysdb_autofsentry_dn(tmp_ctx, sysdb_ctx, map, key, value);
if (!dn) {
ret = ENOMEM;
goto done;
@@ -289,12 +316,13 @@ done:
errno_t
sysdb_del_autofsentry(struct sysdb_ctx *sysdb_ctx,
const char *map,
- const char *key)
+ const char *key,
+ const char *value)
{
struct ldb_dn *dn;
errno_t ret;
- dn = sysdb_autofsentry_dn(sysdb_ctx, sysdb_ctx, map, key);
+ dn = sysdb_autofsentry_dn(sysdb_ctx, sysdb_ctx, map, key, value);
if (!dn) {
return ENOMEM;
}
diff --git a/src/db/sysdb_autofs.h b/src/db/sysdb_autofs.h
index 616c2cbd..c4b5253a 100644
--- a/src/db/sysdb_autofs.h
+++ b/src/db/sysdb_autofs.h
@@ -62,7 +62,8 @@ sysdb_save_autofsentry(struct sysdb_ctx *sysdb_ctx,
errno_t
sysdb_del_autofsentry(struct sysdb_ctx *sysdb_ctx,
const char *map,
- const char *key);
+ const char *key,
+ const char *value);
errno_t
sysdb_autofs_entries_by_map(TALLOC_CTX *mem_ctx,