]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s3:secrets: re-add secrets_delete() helper to simplify deleting optional keys
authorStefan Metzmacher <metze@samba.org>
Mon, 22 May 2017 10:21:37 +0000 (12:21 +0200)
committerStefan Metzmacher <metze@samba.org>
Thu, 13 Jul 2017 08:51:19 +0000 (10:51 +0200)
BUG: https://bugzilla.samba.org/show_bug.cgi?id=12782

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
(cherry picked from commit fde4af1c329655d7ef3f55727632b3f026a3ea73)

source3/include/secrets.h
source3/passdb/secrets.c

index e7f87a9f67329f693d79f6e7f35b83bb8c1c4066..548003fc4fd61f4357f1e98e1bebe7bbb330797b 100644 (file)
@@ -89,6 +89,7 @@ void secrets_shutdown(void);
 void *secrets_fetch(const char *key, size_t *size);
 bool secrets_store(const char *key, const void *data, size_t size);
 bool secrets_delete_entry(const char *key);
+bool secrets_delete(const char *key);
 
 /* The following definitions come from passdb/machine_account_secrets.c */
 bool secrets_mark_domain_protected(const char *domain);
index ae00936948a8dcb758b763df9f752efc0fefa1bd..d843b604f0bcf7901623fb62a82fffa59c2ff0e0 100644 (file)
@@ -158,6 +158,25 @@ bool secrets_delete_entry(const char *key)
        return NT_STATUS_IS_OK(status);
 }
 
+/*
+ * Deletes the key if it exists.
+ */
+bool secrets_delete(const char *key)
+{
+       bool exists;
+
+       if (!secrets_init()) {
+               return false;
+       }
+
+       exists = dbwrap_exists(db_ctx, string_tdb_data(key));
+       if (!exists) {
+               return true;
+       }
+
+       return secrets_delete_entry(key);
+}
+
 /**
  * Form a key for fetching a trusted domain password
  *