summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakub Hrozek <jhrozek@redhat.com>2012-11-17 23:00:03 +0100
committerJakub Hrozek <jhrozek@redhat.com>2012-11-20 18:02:17 +0100
commit25285335d6d41400870e64f07904e899263699f5 (patch)
tree02c60245e984f19af31c45f181f525b0d10a9137
parentff4e9f4d59368004b3917a86dc82c24deb47d905 (diff)
downloadsssd-25285335d6d41400870e64f07904e899263699f5.tar.gz
sssd-25285335d6d41400870e64f07904e899263699f5.tar.bz2
sssd-25285335d6d41400870e64f07904e899263699f5.zip
SYSDB: Use the add_string convenience functions for managing ghost user attribute
Using the convenience function instead of low-level ldb calls makes the code more compact and more readable.
-rw-r--r--src/db/sysdb_ops.c33
1 files changed, 9 insertions, 24 deletions
diff --git a/src/db/sysdb_ops.c b/src/db/sysdb_ops.c
index 52f0cef5..8b624a39 100644
--- a/src/db/sysdb_ops.c
+++ b/src/db/sysdb_ops.c
@@ -1046,24 +1046,13 @@ int sysdb_add_user(struct sysdb_ctx *sysdb,
}
msg->dn = groups[i]->dn;
- ret = ldb_msg_add_empty(msg, SYSDB_MEMBER, SYSDB_MOD_ADD, NULL);
- if (ret != LDB_SUCCESS) {
- ERROR_OUT(ret, ENOMEM, done);
- }
- ret = ldb_msg_add_string(msg, SYSDB_MEMBER, userdn);
- if (ret != LDB_SUCCESS) {
- ERROR_OUT(ret, EINVAL, done);
- }
+ ret = add_string(msg, LDB_FLAG_MOD_ADD, SYSDB_MEMBER, userdn);
+ if (ret) goto done;
+
+ ret = add_string(msg, LDB_FLAG_MOD_DELETE, SYSDB_GHOST, name);
+ if (ret) goto done;
- ret = ldb_msg_add_empty(msg, SYSDB_GHOST, SYSDB_MOD_DEL, NULL);
- if (ret != LDB_SUCCESS) {
- ERROR_OUT(ret, ENOMEM, done);
- }
- ret = ldb_msg_add_string(msg, SYSDB_GHOST, name);
- if (ret != LDB_SUCCESS) {
- ERROR_OUT(ret, EINVAL, done);
- }
/* Delete aliases from the ghost attribute as well */
for (j = 0; j < alias_el->num_values; j++) {
ret = ldb_msg_add_string(msg, SYSDB_GHOST,
@@ -2332,14 +2321,10 @@ int sysdb_delete_user(struct sysdb_ctx *sysdb,
}
msg->dn = msgs[i]->dn;
- ret = ldb_msg_add_empty(msg, SYSDB_GHOST, SYSDB_MOD_DEL, NULL);
- if (ret != LDB_SUCCESS) {
- ERROR_OUT(ret, ENOMEM, fail);
- }
- ret = ldb_msg_add_string(msg, SYSDB_GHOST, name);
- if (ret != LDB_SUCCESS) {
- ERROR_OUT(ret, EINVAL, fail);
- }
+
+ ret = add_string(msg, LDB_FLAG_MOD_DELETE, SYSDB_GHOST, name);
+ if (ret) goto fail;
+
ret = ldb_modify(sysdb->ldb, msg);
ret = sysdb_error_to_errno(ret);
if (ret != EOK) {