Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/db/sysdb.h
Original file line number Diff line number Diff line change
Expand Up @@ -1082,6 +1082,10 @@ int sysdb_search_group_by_name(TALLOC_CTX *mem_ctx,
const char **attrs,
struct ldb_message **msg);

bool sysdb_entry_in_cache(struct sss_domain_info *domain,
const char *name,
enum sysdb_obj_type type);

int sysdb_search_group_by_gid(TALLOC_CTX *mem_ctx,
struct sss_domain_info *domain,
gid_t gid,
Expand Down
41 changes: 41 additions & 0 deletions src/db/sysdb_ops.c
Original file line number Diff line number Diff line change
Expand Up @@ -796,6 +796,47 @@ int sysdb_search_group_by_name(TALLOC_CTX *mem_ctx,
return sysdb_search_by_name(mem_ctx, domain, name, SYSDB_GROUP, attrs, msg);
}

bool sysdb_entry_in_cache(struct sss_domain_info *domain,
const char *name,
enum sysdb_obj_type type)
{
static const char *no_attrs[] = { NULL };
TALLOC_CTX *tmp_ctx;
struct ldb_dn *dn;
struct ldb_result *res;
int lret;
bool ret;

tmp_ctx = talloc_new(NULL);
if (tmp_ctx == NULL) {
return false;
}

switch (type) {
case SYSDB_USER:
dn = sysdb_user_dn(tmp_ctx, domain, name);
break;
case SYSDB_GROUP:
dn = sysdb_group_dn(tmp_ctx, domain, name);
break;
default:
dn = NULL;
break;
}

if (dn == NULL) {
ret = false;
} else {
lret = ldb_search(domain->sysdb->ldb, tmp_ctx, &res, dn,
LDB_SCOPE_BASE, no_attrs, NULL);
ret = (lret == LDB_SUCCESS && res->count == 1);
}

talloc_free(tmp_ctx);

return ret;
}

static int
sysdb_search_group_by_id(TALLOC_CTX *mem_ctx,
struct sss_domain_info *domain,
Expand Down
10 changes: 1 addition & 9 deletions src/providers/ldap/sdap_async_initgroups.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ errno_t sdap_add_incomplete_groups(struct sysdb_ctx *sysdb,
int ldap_groups_count)
{
TALLOC_CTX *tmp_ctx;
struct ldb_message *msg;
int i;
const char *groupname = NULL;
const char *original_dn = NULL;
Expand Down Expand Up @@ -92,15 +91,8 @@ errno_t sdap_add_incomplete_groups(struct sysdb_ctx *sysdb,
subdomain = domain;
}

ret = sysdb_search_group_by_name(tmp_ctx, subdomain, groupname,
NULL, &msg);
if (ret == EOK) {
if (sysdb_entry_in_cache(subdomain, groupname, SYSDB_GROUP)) {
continue;
} else if (ret != ENOENT) {
DEBUG(SSSDBG_CRIT_FAILURE,
"search for group failed [%d]: %s\n",
ret, strerror(ret));
goto done;
}

DEBUG(SSSDBG_TRACE_LIBS, "Group #%d [%s] is not cached, "
Expand Down
Loading