From 61602026ed8c91efd166000562899670449f1b50 Mon Sep 17 00:00:00 2001 From: Pavel Reichl Date: Fri, 11 Jul 2014 15:21:59 +0100 Subject: SYSDB: SSS_LDB_SEARCH - macro around ldb_search MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This patch amends previous patch 5153e8b9793dea1e212ca08af0f77ea1d023cbb7. Macro SSS_LDB_SEARCH is used instead of using fuction sss_ldb_search as a wrapper around ldb_search which could lead to premature expansion of variadic parameters. Part of solution for: https://fedorahosted.org/sssd/ticket/1991 Reviewed-by: Lukáš Slebodník --- src/db/sysdb.h | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'src/db/sysdb.h') diff --git a/src/db/sysdb.h b/src/db/sysdb.h index 3cef1e66b..295949cf4 100644 --- a/src/db/sysdb.h +++ b/src/db/sysdb.h @@ -481,11 +481,6 @@ int sysdb_get_netgroup_attr(TALLOC_CTX *mem_ctx, const char **attributes, struct ldb_result **res); -errno_t sss_ldb_search(struct ldb_context *ldb, TALLOC_CTX *mem_ctx, - struct ldb_result **_result, struct ldb_dn *base, - enum ldb_scope scope, const char * const *attrs, - const char *exp_fmt, ...) SSS_ATTRIBUTE_PRINTF(7, 8); - /* functions that modify the databse * they have to be called within a transaction * See sysdb_transaction_send()/_recv() */ @@ -514,6 +509,18 @@ int sysdb_search_entry(TALLOC_CTX *mem_ctx, size_t *_msgs_count, struct ldb_message ***_msgs); +#define SSS_LDB_SEARCH(ret, ldb, mem_ctx, _result, base, scope, attrs, \ + exp_fmt, ...) do { \ + int _sls_lret; \ + \ + _sls_lret = ldb_search(ldb, mem_ctx, _result, base, scope, attrs, \ + exp_fmt, ##__VA_ARGS__); \ + ret = sysdb_error_to_errno(_sls_lret); \ + if (ret == EOK && (*_result)->count == 0) { \ + ret = ENOENT; \ + } \ +} while(0) + /* Search User (by uid, sid or name) */ int sysdb_search_user_by_name(TALLOC_CTX *mem_ctx, struct sss_domain_info *domain, -- cgit