summaryrefslogtreecommitdiffstats
path: root/src/db
diff options
context:
space:
mode:
authorSumit Bose <sbose@redhat.com>2015-11-19 11:42:39 +0100
committerJakub Hrozek <jhrozek@redhat.com>2015-11-20 14:51:44 +0100
commitaedc71fe8360a51785933523f14bb5c4e7e2c38b (patch)
treeac06160ae0877fcea938d7f8c24ca99e91d4cc68 /src/db
parent17c1656db0a1c4153f80a893978c1c28a5784d55 (diff)
downloadsssd-aedc71fe8360a51785933523f14bb5c4e7e2c38b.tar.gz
sssd-aedc71fe8360a51785933523f14bb5c4e7e2c38b.tar.xz
sssd-aedc71fe8360a51785933523f14bb5c4e7e2c38b.zip
IPA: fix override with the same name
If the user name of a AD user is overridden with the name itself in an IPA override object SSSD adds this name twice to the alias list causing an ldb error when trying to write the user object to the cache. As a result the user is not available. This patch makes sure that there are no duplicated alias names. Resolves https://fedorahosted.org/sssd/ticket/2874 Reviewed-by: Jakub Hrozek <jhrozek@redhat.com>
Diffstat (limited to 'src/db')
-rw-r--r--src/db/sysdb.c18
-rw-r--r--src/db/sysdb.h4
2 files changed, 18 insertions, 4 deletions
diff --git a/src/db/sysdb.c b/src/db/sysdb.c
index 07a83a8a8..a71364d7c 100644
--- a/src/db/sysdb.c
+++ b/src/db/sysdb.c
@@ -598,7 +598,7 @@ int sysdb_attrs_add_string(struct sysdb_attrs *attrs,
return sysdb_attrs_add_val(attrs, name, &v);
}
-int sysdb_attrs_add_lower_case_string(struct sysdb_attrs *attrs,
+int sysdb_attrs_add_lower_case_string(struct sysdb_attrs *attrs, bool safe,
const char *name, const char *str)
{
char *lc_str;
@@ -614,7 +614,11 @@ int sysdb_attrs_add_lower_case_string(struct sysdb_attrs *attrs,
return ENOMEM;
}
- ret = sysdb_attrs_add_string(attrs, name, lc_str);
+ if (safe) {
+ ret = sysdb_attrs_add_string_safe(attrs, name, lc_str);
+ } else {
+ ret = sysdb_attrs_add_string(attrs, name, lc_str);
+ }
talloc_free(lc_str);
return ret;
@@ -729,7 +733,15 @@ int sysdb_attrs_add_time_t(struct sysdb_attrs *attrs,
int sysdb_attrs_add_lc_name_alias(struct sysdb_attrs *attrs,
const char *value)
{
- return sysdb_attrs_add_lower_case_string(attrs, SYSDB_NAME_ALIAS, value);
+ return sysdb_attrs_add_lower_case_string(attrs, false, SYSDB_NAME_ALIAS,
+ value);
+}
+
+int sysdb_attrs_add_lc_name_alias_safe(struct sysdb_attrs *attrs,
+ const char *value)
+{
+ return sysdb_attrs_add_lower_case_string(attrs, true, SYSDB_NAME_ALIAS,
+ value);
}
int sysdb_attrs_copy_values(struct sysdb_attrs *src,
diff --git a/src/db/sysdb.h b/src/db/sysdb.h
index 4f488c088..ad1bf75b7 100644
--- a/src/db/sysdb.h
+++ b/src/db/sysdb.h
@@ -315,7 +315,7 @@ int sysdb_attrs_add_string_safe(struct sysdb_attrs *attrs,
const char *name, const char *str);
int sysdb_attrs_add_string(struct sysdb_attrs *attrs,
const char *name, const char *str);
-int sysdb_attrs_add_lower_case_string(struct sysdb_attrs *attrs,
+int sysdb_attrs_add_lower_case_string(struct sysdb_attrs *attrs, bool safe,
const char *name, const char *str);
int sysdb_attrs_add_mem(struct sysdb_attrs *attrs, const char *name,
const void *mem, size_t size);
@@ -329,6 +329,8 @@ int sysdb_attrs_add_time_t(struct sysdb_attrs *attrs,
const char *name, time_t value);
int sysdb_attrs_add_lc_name_alias(struct sysdb_attrs *attrs,
const char *value);
+int sysdb_attrs_add_lc_name_alias_safe(struct sysdb_attrs *attrs,
+ const char *value);
int sysdb_attrs_copy_values(struct sysdb_attrs *src,
struct sysdb_attrs *dst,
const char *name);