Blame SOURCES/0073-sysdb-add-sysdb_del_autofsentry_by_key.patch

5cd47f
From 49b5baf0e6ef978d971427160677c2c95e89c418 Mon Sep 17 00:00:00 2001
5cd47f
From: =?UTF-8?q?Pavel=20B=C5=99ezina?= <pbrezina@redhat.com>
5cd47f
Date: Thu, 15 Aug 2019 13:50:17 +0200
5cd47f
Subject: [PATCH 73/90] sysdb: add sysdb_del_autofsentry_by_key
5cd47f
MIME-Version: 1.0
5cd47f
Content-Type: text/plain; charset=UTF-8
5cd47f
Content-Transfer-Encoding: 8bit
5cd47f
5cd47f
Resolves:
5cd47f
https://pagure.io/SSSD/sssd/issue/2607
5cd47f
5cd47f
Reviewed-by: Tomáš Halman <thalman@redhat.com>
5cd47f
---
5cd47f
 src/db/sysdb_autofs.c | 22 ++++++++++++++++++++++
5cd47f
 src/db/sysdb_autofs.h |  5 +++++
5cd47f
 2 files changed, 27 insertions(+)
5cd47f
5cd47f
diff --git a/src/db/sysdb_autofs.c b/src/db/sysdb_autofs.c
5cd47f
index 971abafa3..11841d50d 100644
5cd47f
--- a/src/db/sysdb_autofs.c
5cd47f
+++ b/src/db/sysdb_autofs.c
5cd47f
@@ -449,6 +449,28 @@ sysdb_del_autofsentry(struct sss_domain_info *domain,
5cd47f
     return ret;
5cd47f
 }
5cd47f
 
5cd47f
+errno_t
5cd47f
+sysdb_del_autofsentry_by_key(struct sss_domain_info *domain,
5cd47f
+                             const char *map_name,
5cd47f
+                             const char *entry_key)
5cd47f
+{
5cd47f
+    struct ldb_message *entry;
5cd47f
+    errno_t ret;
5cd47f
+
5cd47f
+    ret = sysdb_get_autofsentry(NULL, domain, map_name, entry_key, &entry);
5cd47f
+    if (ret == ENOENT) {
5cd47f
+        return EOK;
5cd47f
+    } else if (ret != EOK) {
5cd47f
+        DEBUG(SSSDBG_OP_FAILURE, "Unable to get autofs entry [%d]: %s\n",
5cd47f
+              ret, sss_strerror(ret));
5cd47f
+        return ret;
5cd47f
+    }
5cd47f
+
5cd47f
+    ret = sysdb_delete_entry(domain->sysdb, entry->dn, true);
5cd47f
+    talloc_free(entry);
5cd47f
+    return ret;
5cd47f
+}
5cd47f
+
5cd47f
 errno_t
5cd47f
 sysdb_autofs_entries_by_map(TALLOC_CTX *mem_ctx,
5cd47f
                             struct sss_domain_info *domain,
5cd47f
diff --git a/src/db/sysdb_autofs.h b/src/db/sysdb_autofs.h
5cd47f
index 79ecbd94e..3775e2a17 100644
5cd47f
--- a/src/db/sysdb_autofs.h
5cd47f
+++ b/src/db/sysdb_autofs.h
5cd47f
@@ -75,6 +75,11 @@ errno_t
5cd47f
 sysdb_del_autofsentry(struct sss_domain_info *domain,
5cd47f
                       const char *entry_dn);
5cd47f
 
5cd47f
+errno_t
5cd47f
+sysdb_del_autofsentry_by_key(struct sss_domain_info *domain,
5cd47f
+                             const char *map_name,
5cd47f
+                             const char *entry_key);
5cd47f
+
5cd47f
 errno_t
5cd47f
 sysdb_autofs_entries_by_map(TALLOC_CTX *mem_ctx,
5cd47f
                             struct sss_domain_info *domain,
5cd47f
-- 
5cd47f
2.20.1
5cd47f