summaryrefslogtreecommitdiffstats
path: root/src/db
diff options
context:
space:
mode:
authorJakub Hrozek <jhrozek@redhat.com>2013-10-22 13:50:51 +0200
committerJakub Hrozek <jhrozek@redhat.com>2013-10-25 19:55:07 +0200
commit8b64ca35eb73667a589067788a6f9fb1f7d281c1 (patch)
tree516a78d9f0fe5742de2a9f346d4daa9f9d264156 /src/db
parentd67a80baf0bdc888297d3587c98f8a12d4827ebc (diff)
downloadsssd-8b64ca35eb73667a589067788a6f9fb1f7d281c1.tar.gz
sssd-8b64ca35eb73667a589067788a6f9fb1f7d281c1.tar.xz
sssd-8b64ca35eb73667a589067788a6f9fb1f7d281c1.zip
SYSDB: Add sysdb_delete_by_sid
Diffstat (limited to 'src/db')
-rw-r--r--src/db/sysdb.h4
-rw-r--r--src/db/sysdb_ops.c49
2 files changed, 53 insertions, 0 deletions
diff --git a/src/db/sysdb.h b/src/db/sysdb.h
index 2f73873f0..4d5ef0b47 100644
--- a/src/db/sysdb.h
+++ b/src/db/sysdb.h
@@ -812,6 +812,10 @@ int sysdb_delete_netgroup(struct sysdb_ctx *sysdb,
struct sss_domain_info *domain,
const char *name);
+int sysdb_delete_by_sid(struct sysdb_ctx *sysdb,
+ struct sss_domain_info *domain,
+ const char *sid_str);
+
errno_t sysdb_attrs_to_list(TALLOC_CTX *mem_ctx,
struct sysdb_attrs **attrs,
int attr_count,
diff --git a/src/db/sysdb_ops.c b/src/db/sysdb_ops.c
index ca23fadbf..094c27b7f 100644
--- a/src/db/sysdb_ops.c
+++ b/src/db/sysdb_ops.c
@@ -2841,6 +2841,55 @@ done:
return ret;
}
+int sysdb_delete_by_sid(struct sysdb_ctx *sysdb,
+ struct sss_domain_info *domain,
+ const char *sid_str)
+{
+ TALLOC_CTX *tmp_ctx;
+ struct ldb_result *res;
+ int ret;
+
+ if (!sid_str) return EINVAL;
+
+ tmp_ctx = talloc_new(NULL);
+ if (!tmp_ctx) {
+ return ENOMEM;
+ }
+
+ ret = sysdb_search_object_by_sid(tmp_ctx, sysdb, domain,
+ sid_str, NULL, &res);
+ if (ret != EOK) {
+ DEBUG(SSSDBG_OP_FAILURE, ("search by sid failed: %d (%s)\n",
+ ret, strerror(ret)));
+ goto done;
+ }
+
+ if (res->count > 1) {
+ DEBUG(SSSDBG_FATAL_FAILURE, ("getbysid call returned more than one " \
+ "result !?!\n"));
+ ret = EIO;
+ goto done;
+ }
+
+ if (res->count == 0) {
+ /* No existing entry. Just quit. */
+ ret = EOK;
+ goto done;
+ }
+
+ ret = sysdb_delete_entry(sysdb, res->msgs[0]->dn, false);
+ if (ret != EOK) {
+ goto done;
+ }
+
+done:
+ if (ret != EOK) {
+ DEBUG(SSSDBG_OP_FAILURE, ("Error: %d (%s)\n", ret, strerror(ret)));
+ }
+ talloc_free(tmp_ctx);
+ return ret;
+}
+
/* ========= Authentication against cached password ============ */