summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPavel Březina <pbrezina@redhat.com>2015-02-19 12:00:52 +0100
committerJakub Hrozek <jhrozek@redhat.com>2015-03-08 22:27:19 +0100
commite77d6366ff9e49dbbb607f1709f1ae4190b99489 (patch)
tree47e8029c95caed397e25f125e0687c6940f19441 /src
parent17531a398cc9084036cb08d69fe876a8f12707bb (diff)
downloadsssd-e77d6366ff9e49dbbb607f1709f1ae4190b99489.tar.gz
sssd-e77d6366ff9e49dbbb607f1709f1ae4190b99489.tar.xz
sssd-e77d6366ff9e49dbbb607f1709f1ae4190b99489.zip
be_refresh: support users
Resolves: https://fedorahosted.org/sssd/ticket/2346 Reviewed-by: Jakub Hrozek <jhrozek@redhat.com>
Diffstat (limited to 'src')
-rw-r--r--src/db/sysdb.c7
-rw-r--r--src/db/sysdb.h2
-rw-r--r--src/providers/dp_refresh.c23
-rw-r--r--src/providers/dp_refresh.h1
-rw-r--r--src/providers/ldap/sdap_refresh.c29
5 files changed, 62 insertions, 0 deletions
diff --git a/src/db/sysdb.c b/src/db/sysdb.c
index 61a224001..2bb4a41aa 100644
--- a/src/db/sysdb.c
+++ b/src/db/sysdb.c
@@ -172,6 +172,13 @@ struct ldb_dn *sysdb_user_dn(TALLOC_CTX *mem_ctx, struct sss_domain_info *dom,
return dn;
}
+struct ldb_dn *sysdb_user_base_dn(TALLOC_CTX *mem_ctx,
+ struct sss_domain_info *dom)
+{
+ return ldb_dn_new_fmt(mem_ctx, dom->sysdb->ldb,
+ SYSDB_TMPL_USER_BASE, dom->name);
+}
+
struct ldb_dn *sysdb_group_dn(TALLOC_CTX *mem_ctx,
struct sss_domain_info *dom, const char *name)
{
diff --git a/src/db/sysdb.h b/src/db/sysdb.h
index 0574a91fb..2ee6ee6e6 100644
--- a/src/db/sysdb.h
+++ b/src/db/sysdb.h
@@ -383,6 +383,8 @@ errno_t sysdb_get_rdn(struct sysdb_ctx *sysdb, TALLOC_CTX *mem_ctx,
const char *dn, char **_name, char **_val);
struct ldb_dn *sysdb_user_dn(TALLOC_CTX *mem_ctx, struct sss_domain_info *dom,
const char *name);
+struct ldb_dn *sysdb_user_base_dn(TALLOC_CTX *mem_ctx,
+ struct sss_domain_info *dom);
struct ldb_dn *sysdb_group_dn(TALLOC_CTX *mem_ctx, struct sss_domain_info *dom,
const char *name);
struct ldb_dn *sysdb_netgroup_dn(TALLOC_CTX *mem_ctx,
diff --git a/src/providers/dp_refresh.c b/src/providers/dp_refresh.c
index bd02d0cd9..f599618e0 100644
--- a/src/providers/dp_refresh.c
+++ b/src/providers/dp_refresh.c
@@ -89,6 +89,26 @@ done:
return ret;
}
+static errno_t be_refresh_get_users(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_user_base_dn(mem_ctx, domain);
+ if (base_dn == NULL) {
+ return ENOMEM;
+ }
+
+ ret = be_refresh_get_values(mem_ctx, domain, period, SYSDB_USER_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,
@@ -138,6 +158,9 @@ struct be_refresh_ctx *be_refresh_ctx_init(TALLOC_CTX *mem_ctx)
return NULL;
}
+ 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_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 d7c775fff..a0d42734b 100644
--- a/src/providers/dp_refresh.h
+++ b/src/providers/dp_refresh.h
@@ -44,6 +44,7 @@ typedef errno_t
(*be_refresh_recv_t)(struct tevent_req *req);
enum be_refresh_type {
+ BE_REFRESH_TYPE_USERS,
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 e300e28b6..8fff9d492 100644
--- a/src/providers/ldap/sdap_refresh.c
+++ b/src/providers/ldap/sdap_refresh.c
@@ -75,6 +75,9 @@ static struct tevent_req *sdap_refresh_send(TALLOC_CTX *mem_ctx,
}
switch (entry_type) {
+ case BE_REQ_USER:
+ state->type = "user";
+ break;
case BE_REQ_NETGROUP:
state->type = "netgroup";
break;
@@ -200,6 +203,23 @@ static errno_t sdap_refresh_recv(struct tevent_req *req)
}
static struct tevent_req *
+sdap_refresh_users_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_USER, names, pvt);
+}
+
+static errno_t sdap_refresh_users_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,
@@ -221,6 +241,15 @@ errno_t sdap_refresh_init(struct be_refresh_ctx *refresh_ctx,
{
errno_t ret;
+ ret = be_refresh_add_cb(refresh_ctx, BE_REFRESH_TYPE_USERS,
+ sdap_refresh_users_send,
+ sdap_refresh_users_recv,
+ id_ctx);
+ if (ret != EOK && ret != EEXIST) {
+ DEBUG(SSSDBG_MINOR_FAILURE, "Periodical refresh of users "
+ "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,