diff options
author | Ondrej Kos <okos@redhat.com> | 2013-01-07 14:40:16 +0100 |
---|---|---|
committer | Jakub Hrozek <jhrozek@redhat.com> | 2013-01-07 16:25:13 +0100 |
commit | b01d8c856117f42f1a2c11669c9704166dc8f9ca (patch) | |
tree | 7ea06b7d99eb229576e2d7d4bbbf3ec566a85010 | |
parent | 399518984f37bd67d2d547de66efb875bc21ccbc (diff) | |
download | sssd-b01d8c856117f42f1a2c11669c9704166dc8f9ca.tar.gz sssd-b01d8c856117f42f1a2c11669c9704166dc8f9ca.tar.bz2 sssd-b01d8c856117f42f1a2c11669c9704166dc8f9ca.zip |
SYSDB: Modify ghosts in permissive mode
https://fedorahosted.org/sssd/ticket/1714
The attempt to delete all ghosts for users name and aliases was failing,
resulting into failure of whole user-add operation. In permissive mode,
the attempts to delete non-existent entries are not interpreted as
error.
-rw-r--r-- | src/db/sysdb_ops.c | 34 |
1 files changed, 33 insertions, 1 deletions
diff --git a/src/db/sysdb_ops.c b/src/db/sysdb_ops.c index 4bbc76c5..5bc826a7 100644 --- a/src/db/sysdb_ops.c +++ b/src/db/sysdb_ops.c @@ -74,6 +74,38 @@ static uint32_t get_attr_as_uint32(struct ldb_message *msg, const char *attr) return l; } +static int sss_ldb_modify_permissive(struct ldb_context *ldb, + struct ldb_message *msg) +{ + struct ldb_request *req; + int ret = EOK; + + ret = ldb_build_mod_req(&req, ldb, ldb, + msg, + NULL, + NULL, + ldb_op_default_callback, + NULL); + + if (ret != LDB_SUCCESS) return ret; + + ret = ldb_request_add_control(req, LDB_CONTROL_PERMISSIVE_MODIFY_OID, + false, NULL); + if (ret != LDB_SUCCESS) { + talloc_free(req); + return ret; + } + + ret = ldb_request(ldb, req); + if (ret == LDB_SUCCESS) { + ret = ldb_wait(req->handle, LDB_WAIT_ALL); + } + + talloc_free(req); + + return ret; +} + #define ERROR_OUT(v, r, l) do { v = r; goto l; } while(0) @@ -1096,7 +1128,7 @@ int sysdb_add_user(struct sysdb_ctx *sysdb, } } - ret = ldb_modify(sysdb->ldb, msg); + ret = sss_ldb_modify_permissive(sysdb->ldb, msg); ret = sysdb_error_to_errno(ret); if (ret != EOK) { goto done; |