diff options
author | Sumit Bose <sbose@redhat.com> | 2016-07-11 15:04:32 +0200 |
---|---|---|
committer | Jakub Hrozek <jhrozek@redhat.com> | 2016-07-12 14:23:21 +0200 |
commit | 26a3d4f2ef35a088e4c5fc928290052c89a2ff43 (patch) | |
tree | c52178d5791b5f76e9f65bbee669daac3d686cd9 /src/db | |
parent | 8ad1883c79fc1e356bbd2d3e4badd4af9955b9fc (diff) | |
download | sssd-26a3d4f2ef35a088e4c5fc928290052c89a2ff43.tar.gz sssd-26a3d4f2ef35a088e4c5fc928290052c89a2ff43.tar.xz sssd-26a3d4f2ef35a088e4c5fc928290052c89a2ff43.zip |
views: allow override added for non-default views at runtime
Currently a new override for a non-default view cannot be displayed at
run-time. It even does not only require a restart but the view must be
un-applied and applied again to make the changes visible.
This patch fixes this and makes non-default view behave like the default
view where the data from a newly added override are displayed after the
cached entry of the related object is expired.
Resolves https://fedorahosted.org/sssd/ticket/3092
Reviewed-by: Pavel Březina <pbrezina@redhat.com>
Diffstat (limited to 'src/db')
-rw-r--r-- | src/db/sysdb_views.c | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/src/db/sysdb_views.c b/src/db/sysdb_views.c index 7adc15230..2b89e5ca4 100644 --- a/src/db/sysdb_views.c +++ b/src/db/sysdb_views.c @@ -454,15 +454,23 @@ errno_t sysdb_store_override(struct sss_domain_info *domain, obj_override_dn = ldb_msg_find_attr_as_string(msgs[0], SYSDB_OVERRIDE_DN, NULL); if (obj_override_dn != NULL) { + /* obj_override_dn can either point to the object itself, i.e there is + * no override, or to a overide object. This means it can change from + * the object DN to a override DN and back but not from one override + * DN to a different override DN. If the new and the old DN are the + * same we do not need to update the original object. */ if (strcmp(obj_override_dn, override_dn_str) != 0) { - DEBUG(SSSDBG_CRIT_FAILURE, - "Existing [%s] and new [%s] override DN do not match.\n", - obj_override_dn, override_dn_str); - ret = EINVAL; - goto done; + if (strcmp(obj_override_dn, obj_dn_str) != 0 + && strcmp(override_dn_str, obj_dn_str) != 0) { + DEBUG(SSSDBG_CRIT_FAILURE, + "Existing [%s] and new [%s] override DN do not match.\n", + obj_override_dn, override_dn_str); + ret = EINVAL; + goto done; + } + } else { + add_ref = false; } - - add_ref = false; } ret = ldb_transaction_start(domain->sysdb->ldb); @@ -580,7 +588,9 @@ errno_t sysdb_store_override(struct sss_domain_info *domain, msg->dn = obj_dn; - ret = ldb_msg_add_empty(msg, SYSDB_OVERRIDE_DN, LDB_FLAG_MOD_ADD, + ret = ldb_msg_add_empty(msg, SYSDB_OVERRIDE_DN, + obj_override_dn == NULL ? LDB_FLAG_MOD_ADD + : LDB_FLAG_MOD_REPLACE, NULL); if (ret != LDB_SUCCESS) { DEBUG(SSSDBG_OP_FAILURE, "ldb_msg_add_empty failed.\n"); |