[SSSD] [sssd PR#136][synchronized] Tlog integration WIP
URL: https://github.com/SSSD/sssd/pull/136 Author: spbnick Title: #136: Tlog integration WIP Action: synchronized To pull the PR as Git branch: git remote add ghsssd https://github.com/SSSD/sssd git fetch ghsssd pull/136/head:pr136 git checkout pr136 From 32d6411ef99a1a2abd78314cc7131af8ddb69db7 Mon Sep 17 00:00:00 2001 From: Nikolai KondrashovDate: Fri, 24 Mar 2017 16:24:22 +0200 Subject: [PATCH 01/14] CACHE_REQ: Propagate num_results to cache_req_state The num_results field in struct cache_req_state was only set in case of well-known objects, set it also for the regular results for uniformity, and for later use by session recording code. --- src/responder/common/cache_req/cache_req.c | 9 +++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/responder/common/cache_req/cache_req.c b/src/responder/common/cache_req/cache_req.c index aca150d..077282e 100644 --- a/src/responder/common/cache_req/cache_req.c +++ b/src/responder/common/cache_req/cache_req.c @@ -536,7 +536,8 @@ static void cache_req_search_domains_done(struct tevent_req *subreq) static errno_t cache_req_search_domains_recv(TALLOC_CTX *mem_ctx, struct tevent_req *req, - struct cache_req_result ***_results) + struct cache_req_result ***_results, + size_t *_num_results) { struct cache_req_search_domains_state *state; @@ -547,6 +548,9 @@ cache_req_search_domains_recv(TALLOC_CTX *mem_ctx, if (_results != NULL) { *_results = talloc_steal(mem_ctx, state->results); } +if (_num_results != NULL) { +*_num_results = state->num_results; +} return EOK; } @@ -851,7 +855,8 @@ static void cache_req_done(struct tevent_req *subreq) req = tevent_req_callback_data(subreq, struct tevent_req); state = tevent_req_data(req, struct cache_req_state); -ret = cache_req_search_domains_recv(state, subreq, >results); +ret = cache_req_search_domains_recv(state, subreq, +>results, >num_results); talloc_zfree(subreq); if (ret == ENOENT && state->first_iteration) { From 6519d96c520aca0bd30c20d9cc40ce4e74f5b7cd Mon Sep 17 00:00:00 2001 From: Nikolai Kondrashov Date: Wed, 22 Mar 2017 14:32:35 +0200 Subject: [PATCH 02/14] NSS: Move output name formatting to utils Move NSS nss_get_name_from_msg and the core of sized_output_name to the utils to make them available to provider and other responders. --- src/responder/nss/nss_protocol_grent.c | 3 +- src/responder/nss/nss_protocol_pwent.c | 2 +- src/responder/nss/nss_utils.c | 55 +-- src/util/sss_nss.c | 68 ++ src/util/sss_nss.h | 10 + 5 files changed, 90 insertions(+), 48 deletions(-) diff --git a/src/responder/nss/nss_protocol_grent.c b/src/responder/nss/nss_protocol_grent.c index 283ab9f..5f208e0 100644 --- a/src/responder/nss/nss_protocol_grent.c +++ b/src/responder/nss/nss_protocol_grent.c @@ -19,6 +19,7 @@ */ #include "responder/nss/nss_protocol.h" +#include "util/sss_nss.h" static errno_t nss_get_grent(TALLOC_CTX *mem_ctx, @@ -41,7 +42,7 @@ nss_get_grent(TALLOC_CTX *mem_ctx, } /* Get fields. */ -name = nss_get_name_from_msg(domain, msg); +name = sss_nss_get_name_from_msg(domain, msg); gid = sss_view_ldb_msg_find_attr_as_uint64(domain, msg, SYSDB_GIDNUM, 0); if (name == NULL || gid == 0) { diff --git a/src/responder/nss/nss_protocol_pwent.c b/src/responder/nss/nss_protocol_pwent.c index edda9d3..c0b8e79 100644 --- a/src/responder/nss/nss_protocol_pwent.c +++ b/src/responder/nss/nss_protocol_pwent.c @@ -225,7 +225,7 @@ nss_get_pwent(TALLOC_CTX *mem_ctx, /* Get fields. */ upn = ldb_msg_find_attr_as_string(msg, SYSDB_UPN, NULL); -name = nss_get_name_from_msg(domain, msg); +name = sss_nss_get_name_from_msg(domain, msg); gid = nss_get_gid(domain, msg); uid = sss_view_ldb_msg_find_attr_as_uint64(domain, msg, SYSDB_UIDNUM, 0); diff --git a/src/responder/nss/nss_utils.c b/src/responder/nss/nss_utils.c index f839930..42fe33e 100644 --- a/src/responder/nss/nss_utils.c +++ b/src/responder/nss/nss_utils.c @@ -22,37 +22,11 @@ #include #include "util/util.h" +#include "util/sss_nss.h" #include "confdb/confdb.h" #include "responder/common/responder.h" #include "responder/nss/nss_private.h" -const char * -nss_get_name_from_msg(struct sss_domain_info *domain, - struct ldb_message *msg) -{ -const char *name; - -/* If domain has a view associated we return overridden name - * if possible. */ -if (DOM_HAS_VIEWS(domain)) { -name = ldb_msg_find_attr_as_string(msg, OVERRIDE_PREFIX SYSDB_NAME, - NULL); -if (name != NULL) { -
[SSSD] [sssd PR#136][synchronized] Tlog integration WIP
URL: https://github.com/SSSD/sssd/pull/136 Author: spbnick Title: #136: Tlog integration WIP Action: synchronized To pull the PR as Git branch: git remote add ghsssd https://github.com/SSSD/sssd git fetch ghsssd pull/136/head:pr136 git checkout pr136 From 462f3f323f3ef9aa2efcb08a6a6ba8a3c58b9a3b Mon Sep 17 00:00:00 2001 From: Nikolai KondrashovDate: Wed, 22 Mar 2017 14:32:35 +0200 Subject: [PATCH 01/11] NSS: Move output name formatting to utils Move NSS nss_get_name_from_msg and the core of sized_output_name to the utils to make them available to provider and other responders. --- src/responder/nss/nss_protocol_grent.c | 3 +- src/responder/nss/nss_protocol_pwent.c | 2 +- src/responder/nss/nss_utils.c | 55 +-- src/util/sss_nss.c | 68 ++ src/util/sss_nss.h | 10 + 5 files changed, 90 insertions(+), 48 deletions(-) diff --git a/src/responder/nss/nss_protocol_grent.c b/src/responder/nss/nss_protocol_grent.c index 283ab9f..5f208e0 100644 --- a/src/responder/nss/nss_protocol_grent.c +++ b/src/responder/nss/nss_protocol_grent.c @@ -19,6 +19,7 @@ */ #include "responder/nss/nss_protocol.h" +#include "util/sss_nss.h" static errno_t nss_get_grent(TALLOC_CTX *mem_ctx, @@ -41,7 +42,7 @@ nss_get_grent(TALLOC_CTX *mem_ctx, } /* Get fields. */ -name = nss_get_name_from_msg(domain, msg); +name = sss_nss_get_name_from_msg(domain, msg); gid = sss_view_ldb_msg_find_attr_as_uint64(domain, msg, SYSDB_GIDNUM, 0); if (name == NULL || gid == 0) { diff --git a/src/responder/nss/nss_protocol_pwent.c b/src/responder/nss/nss_protocol_pwent.c index edda9d3..c0b8e79 100644 --- a/src/responder/nss/nss_protocol_pwent.c +++ b/src/responder/nss/nss_protocol_pwent.c @@ -225,7 +225,7 @@ nss_get_pwent(TALLOC_CTX *mem_ctx, /* Get fields. */ upn = ldb_msg_find_attr_as_string(msg, SYSDB_UPN, NULL); -name = nss_get_name_from_msg(domain, msg); +name = sss_nss_get_name_from_msg(domain, msg); gid = nss_get_gid(domain, msg); uid = sss_view_ldb_msg_find_attr_as_uint64(domain, msg, SYSDB_UIDNUM, 0); diff --git a/src/responder/nss/nss_utils.c b/src/responder/nss/nss_utils.c index f839930..42fe33e 100644 --- a/src/responder/nss/nss_utils.c +++ b/src/responder/nss/nss_utils.c @@ -22,37 +22,11 @@ #include #include "util/util.h" +#include "util/sss_nss.h" #include "confdb/confdb.h" #include "responder/common/responder.h" #include "responder/nss/nss_private.h" -const char * -nss_get_name_from_msg(struct sss_domain_info *domain, - struct ldb_message *msg) -{ -const char *name; - -/* If domain has a view associated we return overridden name - * if possible. */ -if (DOM_HAS_VIEWS(domain)) { -name = ldb_msg_find_attr_as_string(msg, OVERRIDE_PREFIX SYSDB_NAME, - NULL); -if (name != NULL) { -return name; -} -} - -/* Otherwise we try to return name override from - * Default Truest View for trusted users. */ -name = ldb_msg_find_attr_as_string(msg, SYSDB_DEFAULT_OVERRIDE_NAME, NULL); -if (name != NULL) { -return name; -} - -/* If no override is found we return the original name. */ -return ldb_msg_find_attr_as_string(msg, SYSDB_NAME, NULL); -} - int sized_output_name(TALLOC_CTX *mem_ctx, struct resp_ctx *rctx, const char *orig_name, @@ -61,7 +35,7 @@ int sized_output_name(TALLOC_CTX *mem_ctx, { TALLOC_CTX *tmp_ctx = NULL; errno_t ret; -char *username; +char *name_str; struct sized_string *name; tmp_ctx = talloc_new(NULL); @@ -69,30 +43,19 @@ int sized_output_name(TALLOC_CTX *mem_ctx, return ENOMEM; } -username = sss_output_name(tmp_ctx, orig_name, name_dom->case_preserve, - rctx->override_space); -if (username == NULL) { -ret = EIO; -goto done; -} - -if (name_dom->fqnames) { -username = sss_tc_fqname(tmp_ctx, name_dom->names, name_dom, username); -if (username == NULL) { -DEBUG(SSSDBG_CRIT_FAILURE, "sss_replace_space failed\n"); -ret = EIO; -goto done; -} -} - name = talloc_zero(tmp_ctx, struct sized_string); if (name == NULL) { ret = ENOMEM; goto done; } -to_sized_string(name, username); -name->str = talloc_steal(name, username); +ret = sss_nss_output_name(mem_ctx, name_dom, orig_name, + rctx->override_space, _str); +if (ret != EOK) { +goto done; +} + +to_sized_string(name, name_str); *_name = talloc_steal(mem_ctx, name); ret = EOK; done: diff --git a/src/util/sss_nss.c b/src/util/sss_nss.c index cf91a2c..54ff40a 100644 --- a/src/util/sss_nss.c +++