summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSumit Bose <sbose@redhat.com>2016-07-05 15:53:39 +0200
committerJakub Hrozek <jhrozek@redhat.com>2016-07-07 10:30:15 +0200
commit1ea5a9c1930f531b21f8bc67c9c071d8ce533786 (patch)
tree1cabca8ede8972a2f632075ea26ce48d66231a00
parent8531bd4585f9135ffd4cbb9bb4c880dc77b5adc4 (diff)
downloadsssd-1ea5a9c1930f531b21f8bc67c9c071d8ce533786.zip
sssd-1ea5a9c1930f531b21f8bc67c9c071d8ce533786.tar.gz
sssd-1ea5a9c1930f531b21f8bc67c9c071d8ce533786.tar.xz
SYSDB: qualify_attr: create new attribute only once
Reviewed-by: Jakub Hrozek <jhrozek@redhat.com>
-rw-r--r--src/db/sysdb_upgrade.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/db/sysdb_upgrade.c b/src/db/sysdb_upgrade.c
index 04c1942..1d2978c 100644
--- a/src/db/sysdb_upgrade.c
+++ b/src/db/sysdb_upgrade.c
@@ -1690,6 +1690,7 @@ static errno_t qualify_attr(struct ldb_message *msg,
const char *rawname;
int ret;
struct ldb_val val;
+ bool exists = false;
el = ldb_msg_find_element(msg, attrname);
if (el == NULL) {
@@ -1733,9 +1734,13 @@ static errno_t qualify_attr(struct ldb_message *msg,
DEBUG(SSSDBG_TRACE_FUNC, "Qualified %s:%s into %s\n",
attrname, rawname, fqval);
- ret = ldb_msg_add_empty(mod_msg, attrname, LDB_FLAG_MOD_REPLACE, NULL);
- if (ret != LDB_SUCCESS) {
- continue;
+ if (!exists) {
+ ret = ldb_msg_add_empty(mod_msg, attrname, LDB_FLAG_MOD_REPLACE, NULL);
+ if (ret != LDB_SUCCESS) {
+ continue;
+ }
+
+ exists = true;
}
ret = ldb_msg_add_steal_string(mod_msg, attrname, fqval);