diff options
Diffstat (limited to 'src/providers')
-rw-r--r-- | src/providers/dp_refresh.c | 23 | ||||
-rw-r--r-- | src/providers/dp_refresh.h | 1 | ||||
-rw-r--r-- | src/providers/ldap/sdap_refresh.c | 29 |
3 files changed, 53 insertions, 0 deletions
diff --git a/src/providers/dp_refresh.c b/src/providers/dp_refresh.c index f599618e0..169ef71ed 100644 --- a/src/providers/dp_refresh.c +++ b/src/providers/dp_refresh.c @@ -109,6 +109,26 @@ static errno_t be_refresh_get_users(TALLOC_CTX *mem_ctx, return ret; } +static errno_t be_refresh_get_groups(TALLOC_CTX *mem_ctx, + struct sss_domain_info *domain, + time_t period, + char ***_values) +{ + struct ldb_dn *base_dn = NULL; + errno_t ret; + + base_dn = sysdb_group_base_dn(mem_ctx, domain); + if (base_dn == NULL) { + return ENOMEM; + } + + ret = be_refresh_get_values(mem_ctx, domain, period, SYSDB_GROUP_CLASS, + base_dn, SYSDB_NAME, _values); + + talloc_free(base_dn); + return ret; +} + static errno_t be_refresh_get_netgroups(TALLOC_CTX *mem_ctx, struct sss_domain_info *domain, time_t period, @@ -161,6 +181,9 @@ struct be_refresh_ctx *be_refresh_ctx_init(TALLOC_CTX *mem_ctx) ctx->callbacks[BE_REFRESH_TYPE_USERS].name = "users"; ctx->callbacks[BE_REFRESH_TYPE_USERS].get_values = be_refresh_get_users; + ctx->callbacks[BE_REFRESH_TYPE_GROUPS].name = "groups"; + ctx->callbacks[BE_REFRESH_TYPE_GROUPS].get_values = be_refresh_get_groups; + ctx->callbacks[BE_REFRESH_TYPE_NETGROUPS].name = "netgroups"; ctx->callbacks[BE_REFRESH_TYPE_NETGROUPS].get_values \ = be_refresh_get_netgroups; diff --git a/src/providers/dp_refresh.h b/src/providers/dp_refresh.h index a0d42734b..89ccfcfb4 100644 --- a/src/providers/dp_refresh.h +++ b/src/providers/dp_refresh.h @@ -45,6 +45,7 @@ typedef errno_t enum be_refresh_type { BE_REFRESH_TYPE_USERS, + BE_REFRESH_TYPE_GROUPS, BE_REFRESH_TYPE_NETGROUPS, BE_REFRESH_TYPE_SENTINEL }; diff --git a/src/providers/ldap/sdap_refresh.c b/src/providers/ldap/sdap_refresh.c index 8fff9d492..bda50aeb3 100644 --- a/src/providers/ldap/sdap_refresh.c +++ b/src/providers/ldap/sdap_refresh.c @@ -78,6 +78,9 @@ static struct tevent_req *sdap_refresh_send(TALLOC_CTX *mem_ctx, case BE_REQ_USER: state->type = "user"; break; + case BE_REQ_GROUP: + state->type = "group"; + break; case BE_REQ_NETGROUP: state->type = "netgroup"; break; @@ -220,6 +223,23 @@ static errno_t sdap_refresh_users_recv(struct tevent_req *req) } static struct tevent_req * +sdap_refresh_groups_send(TALLOC_CTX *mem_ctx, + struct tevent_context *ev, + struct be_ctx *be_ctx, + struct sss_domain_info *domain, + char **names, + void *pvt) +{ + return sdap_refresh_send(mem_ctx, ev, be_ctx, domain, + BE_REQ_GROUP, names, pvt); +} + +static errno_t sdap_refresh_groups_recv(struct tevent_req *req) +{ + return sdap_refresh_recv(req); +} + +static struct tevent_req * sdap_refresh_netgroups_send(TALLOC_CTX *mem_ctx, struct tevent_context *ev, struct be_ctx *be_ctx, @@ -250,6 +270,15 @@ errno_t sdap_refresh_init(struct be_refresh_ctx *refresh_ctx, "will not work [%d]: %s\n", ret, strerror(ret)); } + ret = be_refresh_add_cb(refresh_ctx, BE_REFRESH_TYPE_GROUPS, + sdap_refresh_groups_send, + sdap_refresh_groups_recv, + id_ctx); + if (ret != EOK && ret != EEXIST) { + DEBUG(SSSDBG_MINOR_FAILURE, "Periodical refresh of groups " + "will not work [%d]: %s\n", ret, strerror(ret)); + } + ret = be_refresh_add_cb(refresh_ctx, BE_REFRESH_TYPE_NETGROUPS, sdap_refresh_netgroups_send, sdap_refresh_netgroups_recv, |