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