On 03/07/2016 01:11 PM, Pavel Březina wrote:
Hi,
see comments inline.
> errno_t sysdb_search_sudo_rules(TALLOC_CTX *mem_ctx,
> struct sss_domain_info *domain,
> const char *sub_filter,
> const char **attrs,
> size_t *msgs_count,
> struct ldb_message ***msgs)
> {
> TALLOC_CTX *tmp_ctx;
> struct ldb_dn *dn;
> char *filter;
> int ret;
>
> tmp_ctx = talloc_new(NULL);
> if (!tmp_ctx) {
> return ENOMEM;
> }
>
> dn = ldb_dn_new_fmt(tmp_ctx, domain->sysdb->ldb,
> SYSDB_TMPL_CUSTOM_SUBTREE,
> SUDORULE_SUBDIR, domain->name);
> if (!dn) {
> DEBUG(SSSDBG_OP_FAILURE, "Failed to build base dn\n");
> ret = ENOMEM;
> goto fail;
> }
>
> filter = talloc_asprintf(tmp_ctx, "(&%s%s)", SUDO_ALL_FILTER,
> sub_filter);
You also need to add case where sub_filter is NULL.
Thank you Pavel for comments. I have little question:
If sub_filter equal to NULL is given then
filter = (&(objectClass=sudoRule))
and that means that we can find all the rules.
Is it wrong?
> if (!filter) {
> DEBUG(SSSDBG_OP_FAILURE, "Failed to build filter\n");
> ret = ENOMEM;
> goto fail;
> }
>
> DEBUG(SSSDBG_TRACE_INTERNAL,
> "Search sudo rules with filter: %s\n", filter);
--
Petr^4 Čech