summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJakub Hrozek <jhrozek@redhat.com>2016-03-30 13:38:17 +0200
committerJakub Hrozek <jhrozek@redhat.com>2016-07-07 10:25:41 +0200
commit78f9a9d4a2725f1b2cb6e582c965b5e6f7bdff7d (patch)
treea6baa83812c2b1f7290fb1b8ffdfe453840784bd
parent187f65802ed26c49dbac2fba5e7cd1508f3db1e8 (diff)
downloadsssd-78f9a9d4a2725f1b2cb6e582c965b5e6f7bdff7d.tar.gz
sssd-78f9a9d4a2725f1b2cb6e582c965b5e6f7bdff7d.tar.xz
sssd-78f9a9d4a2725f1b2cb6e582c965b5e6f7bdff7d.zip
RESPONDER: Add a helper function sss_resp_create_fqname
When looking up entries in the responders that have not been yet converted to the cache_req API, we need to perform some common operations all the time. These include converting the name to the right case, reverse-replacing whitespace and converting the name to the qualified format for that domain. This patch adds a function that performs these steps to avoid code duplication. Reviewed-by: Sumit Bose <sbose@redhat.com>
-rw-r--r--src/responder/common/responder.h6
-rw-r--r--src/responder/common/responder_utils.c44
2 files changed, 50 insertions, 0 deletions
diff --git a/src/responder/common/responder.h b/src/responder/common/responder.h
index 23e7d46f8..335b313ce 100644
--- a/src/responder/common/responder.h
+++ b/src/responder/common/responder.h
@@ -356,4 +356,10 @@ errno_t sss_parse_inp_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx,
const char **parse_attr_list_ex(TALLOC_CTX *mem_ctx, const char *conf_str,
const char **defaults);
+char *sss_resp_create_fqname(TALLOC_CTX *mem_ctx,
+ struct resp_ctx *rctx,
+ struct sss_domain_info *dom,
+ bool name_is_upn,
+ const char *orig_name);
+
#endif /* __SSS_RESPONDER_H__ */
diff --git a/src/responder/common/responder_utils.c b/src/responder/common/responder_utils.c
index 815b61b39..b02212dfd 100644
--- a/src/responder/common/responder_utils.c
+++ b/src/responder/common/responder_utils.c
@@ -22,6 +22,7 @@
#include <talloc.h>
+#include "responder/common/responder.h"
#include "util/util.h"
static inline bool
@@ -149,3 +150,46 @@ done:
talloc_free(tmp_ctx);
return res;
}
+
+char *sss_resp_create_fqname(TALLOC_CTX *mem_ctx,
+ struct resp_ctx *rctx,
+ struct sss_domain_info *dom,
+ bool name_is_upn,
+ const char *orig_name)
+{
+ TALLOC_CTX *tmp_ctx;
+ char *name;
+
+ tmp_ctx = talloc_new(NULL);
+ if (tmp_ctx == NULL) {
+ return NULL;
+ }
+
+ name = sss_get_cased_name(tmp_ctx, orig_name, dom->case_sensitive);
+ if (name == NULL) {
+ DEBUG(SSSDBG_CRIT_FAILURE, "sss_get_cased_name failed\n");
+ talloc_free(tmp_ctx);
+ return NULL;
+ }
+
+ name = sss_reverse_replace_space(tmp_ctx, name, rctx->override_space);
+ if (name == NULL) {
+ DEBUG(SSSDBG_CRIT_FAILURE, "sss_reverse_replace_space failed\n");
+ talloc_free(tmp_ctx);
+ return NULL;
+ }
+
+
+ if (name_is_upn == false) {
+ name = sss_create_internal_fqname(tmp_ctx, name, dom->name);
+ if (name == NULL) {
+ DEBUG(SSSDBG_CRIT_FAILURE, "sss_create_internal_fqname failed\n");
+ talloc_free(tmp_ctx);
+ return NULL;
+ }
+ }
+
+ name = talloc_steal(mem_ctx, name);
+ talloc_free(tmp_ctx);
+ return name;
+}