|
|
2fc102 |
From b0af402f8201d28922892b18792474f4ec546f36 Mon Sep 17 00:00:00 2001
|
|
|
2fc102 |
From: Sumit Bose <sbose@redhat.com>
|
|
|
2fc102 |
Date: Fri, 13 Dec 2013 11:44:59 +0100
|
|
|
2fc102 |
Subject: [PATCH 39/41] Use lower-case name for case-insensitive searches
|
|
|
2fc102 |
|
|
|
2fc102 |
The patch makes sure that a completely lower-cased version of a fully
|
|
|
2fc102 |
qualified name is used for case insensitive searches. Currently there
|
|
|
2fc102 |
are code paths where the domain name was used as configured and was not
|
|
|
2fc102 |
lower-cased.
|
|
|
2fc102 |
|
|
|
2fc102 |
To make sure this patch does not break with old entries in the cache or
|
|
|
2fc102 |
case sensitive domains a third template was added to the related filters
|
|
|
2fc102 |
templates which is either filled with a completely lower-cased version or
|
|
|
2fc102 |
with the old version. The other two template values are unchanged.
|
|
|
2fc102 |
---
|
|
|
2fc102 |
src/db/sysdb.h | 10 +++++-----
|
|
|
2fc102 |
src/db/sysdb_ops.c | 8 +++++---
|
|
|
2fc102 |
src/db/sysdb_search.c | 30 ++++++++++++++++++++--------
|
|
|
2fc102 |
src/responder/pam/pam_LOCAL_domain.c | 4 ++--
|
|
|
2fc102 |
src/tests/cmocka/test_utils.c | 38 ++++++++++++++++++++++++++++++++++++
|
|
|
2fc102 |
src/util/sss_tc_utf8.c | 30 ++++++++++++++++++++++++++++
|
|
|
2fc102 |
src/util/util.h | 6 ++++++
|
|
|
2fc102 |
7 files changed, 108 insertions(+), 18 deletions(-)
|
|
|
2fc102 |
|
|
|
2fc102 |
diff --git a/src/db/sysdb.h b/src/db/sysdb.h
|
|
|
2fc102 |
index f3358d642efd1c13203061c43e455a5c26c72740..f1ed8158ccff70f85940d63f247e23451c22c30f 100644
|
|
|
2fc102 |
--- a/src/db/sysdb.h
|
|
|
2fc102 |
+++ b/src/db/sysdb.h
|
|
|
2fc102 |
@@ -144,23 +144,23 @@
|
|
|
2fc102 |
#define SYSDB_NC "objectclass="SYSDB_NETGROUP_CLASS
|
|
|
2fc102 |
#define SYSDB_MPGC "|("SYSDB_UC")("SYSDB_GC")"
|
|
|
2fc102 |
|
|
|
2fc102 |
-#define SYSDB_PWNAM_FILTER "(&("SYSDB_UC")(|("SYSDB_NAME_ALIAS"=%s)("SYSDB_NAME"=%s)))"
|
|
|
2fc102 |
+#define SYSDB_PWNAM_FILTER "(&("SYSDB_UC")(|("SYSDB_NAME_ALIAS"=%s)("SYSDB_NAME_ALIAS"=%s)("SYSDB_NAME"=%s)))"
|
|
|
2fc102 |
#define SYSDB_PWUID_FILTER "(&("SYSDB_UC")("SYSDB_UIDNUM"=%lu))"
|
|
|
2fc102 |
#define SYSDB_PWSID_FILTER "(&("SYSDB_UC")("SYSDB_SID_STR"=%s))"
|
|
|
2fc102 |
#define SYSDB_PWENT_FILTER "("SYSDB_UC")"
|
|
|
2fc102 |
|
|
|
2fc102 |
-#define SYSDB_GRNAM_FILTER "(&("SYSDB_GC")(|("SYSDB_NAME_ALIAS"=%s)("SYSDB_NAME"=%s)))"
|
|
|
2fc102 |
+#define SYSDB_GRNAM_FILTER "(&("SYSDB_GC")(|("SYSDB_NAME_ALIAS"=%s)("SYSDB_NAME_ALIAS"=%s)("SYSDB_NAME"=%s)))"
|
|
|
2fc102 |
#define SYSDB_GRGID_FILTER "(&("SYSDB_GC")("SYSDB_GIDNUM"=%lu))"
|
|
|
2fc102 |
#define SYSDB_GRSID_FILTER "(&("SYSDB_GC")("SYSDB_SID_STR"=%s))"
|
|
|
2fc102 |
#define SYSDB_GRENT_FILTER "("SYSDB_GC")"
|
|
|
2fc102 |
-#define SYSDB_GRNAM_MPG_FILTER "(&("SYSDB_MPGC")(|("SYSDB_NAME_ALIAS"=%s)("SYSDB_NAME"=%s)))"
|
|
|
2fc102 |
+#define SYSDB_GRNAM_MPG_FILTER "(&("SYSDB_MPGC")(|("SYSDB_NAME_ALIAS"=%s)("SYSDB_NAME_ALIAS"=%s)("SYSDB_NAME"=%s)))"
|
|
|
2fc102 |
#define SYSDB_GRGID_MPG_FILTER "(&("SYSDB_MPGC")("SYSDB_GIDNUM"=%lu))"
|
|
|
2fc102 |
#define SYSDB_GRENT_MPG_FILTER "("SYSDB_MPGC")"
|
|
|
2fc102 |
|
|
|
2fc102 |
#define SYSDB_INITGR_FILTER "(&("SYSDB_GC")("SYSDB_GIDNUM"=*))"
|
|
|
2fc102 |
|
|
|
2fc102 |
-#define SYSDB_NETGR_FILTER "(&("SYSDB_NC")(|("SYSDB_NAME_ALIAS"=%s)("SYSDB_NAME"=%s)))"
|
|
|
2fc102 |
-#define SYSDB_NETGR_TRIPLES_FILTER "(|("SYSDB_NAME"=%s)("SYSDB_NAME_ALIAS"=%s)("SYSDB_MEMBEROF"=%s))"
|
|
|
2fc102 |
+#define SYSDB_NETGR_FILTER "(&("SYSDB_NC")(|("SYSDB_NAME_ALIAS"=%s)("SYSDB_NAME_ALIAS"=%s)("SYSDB_NAME"=%s)))"
|
|
|
2fc102 |
+#define SYSDB_NETGR_TRIPLES_FILTER "(|("SYSDB_NAME_ALIAS"=%s)("SYSDB_NAME"=%s)("SYSDB_NAME_ALIAS"=%s)("SYSDB_MEMBEROF"=%s))"
|
|
|
2fc102 |
|
|
|
2fc102 |
#define SYSDB_SID_FILTER "(&(|("SYSDB_UC")("SYSDB_GC"))("SYSDB_SID_STR"=%s))"
|
|
|
2fc102 |
|
|
|
2fc102 |
diff --git a/src/db/sysdb_ops.c b/src/db/sysdb_ops.c
|
|
|
2fc102 |
index 890bf1eb3cc5fc0b6eb6f7a145aee6d87945cd8d..a5dfd443c84b87609881f9042b3e82958c3b0e5f 100644
|
|
|
2fc102 |
--- a/src/db/sysdb_ops.c
|
|
|
2fc102 |
+++ b/src/db/sysdb_ops.c
|
|
|
2fc102 |
@@ -305,6 +305,7 @@ int sysdb_search_user_by_name(TALLOC_CTX *mem_ctx,
|
|
|
2fc102 |
struct ldb_dn *basedn;
|
|
|
2fc102 |
size_t msgs_count = 0;
|
|
|
2fc102 |
char *sanitized_name;
|
|
|
2fc102 |
+ char *lc_sanitized_name;
|
|
|
2fc102 |
char *filter;
|
|
|
2fc102 |
int ret;
|
|
|
2fc102 |
|
|
|
2fc102 |
@@ -320,13 +321,14 @@ int sysdb_search_user_by_name(TALLOC_CTX *mem_ctx,
|
|
|
2fc102 |
goto done;
|
|
|
2fc102 |
}
|
|
|
2fc102 |
|
|
|
2fc102 |
- ret = sss_filter_sanitize(tmp_ctx, name, &sanitized_name);
|
|
|
2fc102 |
+ ret = sss_filter_sanitize_for_dom(tmp_ctx, name, domain, &sanitized_name,
|
|
|
2fc102 |
+ &lc_sanitized_name);
|
|
|
2fc102 |
if (ret != EOK) {
|
|
|
2fc102 |
goto done;
|
|
|
2fc102 |
}
|
|
|
2fc102 |
|
|
|
2fc102 |
- filter = talloc_asprintf(tmp_ctx, SYSDB_PWNAM_FILTER, sanitized_name,
|
|
|
2fc102 |
- sanitized_name);
|
|
|
2fc102 |
+ filter = talloc_asprintf(tmp_ctx, SYSDB_PWNAM_FILTER, lc_sanitized_name,
|
|
|
2fc102 |
+ sanitized_name, sanitized_name);
|
|
|
2fc102 |
if (!filter) {
|
|
|
2fc102 |
ret = ENOMEM;
|
|
|
2fc102 |
goto done;
|
|
|
2fc102 |
diff --git a/src/db/sysdb_search.c b/src/db/sysdb_search.c
|
|
|
2fc102 |
index d15fc73ce2272bff53650ae9dd0dbdad99a849e6..308710a2c780b9a709930b7d8a16a0c07471aff7 100644
|
|
|
2fc102 |
--- a/src/db/sysdb_search.c
|
|
|
2fc102 |
+++ b/src/db/sysdb_search.c
|
|
|
2fc102 |
@@ -38,6 +38,7 @@ int sysdb_getpwnam(TALLOC_CTX *mem_ctx,
|
|
|
2fc102 |
struct ldb_dn *base_dn;
|
|
|
2fc102 |
struct ldb_result *res;
|
|
|
2fc102 |
char *sanitized_name;
|
|
|
2fc102 |
+ char *lc_sanitized_name;
|
|
|
2fc102 |
const char *src_name;
|
|
|
2fc102 |
int ret;
|
|
|
2fc102 |
|
|
|
2fc102 |
@@ -61,13 +62,15 @@ int sysdb_getpwnam(TALLOC_CTX *mem_ctx,
|
|
|
2fc102 |
goto done;
|
|
|
2fc102 |
}
|
|
|
2fc102 |
|
|
|
2fc102 |
- ret = sss_filter_sanitize(tmp_ctx, src_name, &sanitized_name);
|
|
|
2fc102 |
+ ret = sss_filter_sanitize_for_dom(tmp_ctx, src_name, domain,
|
|
|
2fc102 |
+ &sanitized_name, &lc_sanitized_name);
|
|
|
2fc102 |
if (ret != EOK) {
|
|
|
2fc102 |
goto done;
|
|
|
2fc102 |
}
|
|
|
2fc102 |
|
|
|
2fc102 |
ret = ldb_search(sysdb->ldb, tmp_ctx, &res, base_dn,
|
|
|
2fc102 |
LDB_SCOPE_SUBTREE, attrs, SYSDB_PWNAM_FILTER,
|
|
|
2fc102 |
+ lc_sanitized_name,
|
|
|
2fc102 |
sanitized_name, sanitized_name);
|
|
|
2fc102 |
if (ret) {
|
|
|
2fc102 |
ret = sysdb_error_to_errno(ret);
|
|
|
2fc102 |
@@ -214,6 +217,7 @@ int sysdb_getgrnam(TALLOC_CTX *mem_ctx,
|
|
|
2fc102 |
struct ldb_dn *base_dn;
|
|
|
2fc102 |
struct ldb_result *res;
|
|
|
2fc102 |
const char *src_name;
|
|
|
2fc102 |
+ char *lc_sanitized_name;
|
|
|
2fc102 |
int ret;
|
|
|
2fc102 |
|
|
|
2fc102 |
tmp_ctx = talloc_new(NULL);
|
|
|
2fc102 |
@@ -243,14 +247,15 @@ int sysdb_getgrnam(TALLOC_CTX *mem_ctx,
|
|
|
2fc102 |
goto done;
|
|
|
2fc102 |
}
|
|
|
2fc102 |
|
|
|
2fc102 |
- ret = sss_filter_sanitize(tmp_ctx, src_name, &sanitized_name);
|
|
|
2fc102 |
+ ret = sss_filter_sanitize_for_dom(tmp_ctx, src_name, domain,
|
|
|
2fc102 |
+ &sanitized_name, &lc_sanitized_name);
|
|
|
2fc102 |
if (ret != EOK) {
|
|
|
2fc102 |
goto done;
|
|
|
2fc102 |
}
|
|
|
2fc102 |
|
|
|
2fc102 |
ret = ldb_search(sysdb->ldb, tmp_ctx, &res, base_dn,
|
|
|
2fc102 |
LDB_SCOPE_SUBTREE, attrs, fmt_filter,
|
|
|
2fc102 |
- sanitized_name, sanitized_name);
|
|
|
2fc102 |
+ lc_sanitized_name, sanitized_name, sanitized_name);
|
|
|
2fc102 |
if (ret) {
|
|
|
2fc102 |
ret = sysdb_error_to_errno(ret);
|
|
|
2fc102 |
goto done;
|
|
|
2fc102 |
@@ -481,6 +486,7 @@ int sysdb_get_user_attr(TALLOC_CTX *mem_ctx,
|
|
|
2fc102 |
struct ldb_dn *base_dn;
|
|
|
2fc102 |
struct ldb_result *res;
|
|
|
2fc102 |
char *sanitized_name;
|
|
|
2fc102 |
+ char *lc_sanitized_name;
|
|
|
2fc102 |
int ret;
|
|
|
2fc102 |
|
|
|
2fc102 |
tmp_ctx = talloc_new(NULL);
|
|
|
2fc102 |
@@ -495,14 +501,15 @@ int sysdb_get_user_attr(TALLOC_CTX *mem_ctx,
|
|
|
2fc102 |
goto done;
|
|
|
2fc102 |
}
|
|
|
2fc102 |
|
|
|
2fc102 |
- ret = sss_filter_sanitize(tmp_ctx, name, &sanitized_name);
|
|
|
2fc102 |
+ ret = sss_filter_sanitize_for_dom(tmp_ctx, name, domain, &sanitized_name,
|
|
|
2fc102 |
+ &lc_sanitized_name);
|
|
|
2fc102 |
if (ret != EOK) {
|
|
|
2fc102 |
goto done;
|
|
|
2fc102 |
}
|
|
|
2fc102 |
|
|
|
2fc102 |
ret = ldb_search(sysdb->ldb, tmp_ctx, &res, base_dn,
|
|
|
2fc102 |
LDB_SCOPE_SUBTREE, attributes,
|
|
|
2fc102 |
- SYSDB_PWNAM_FILTER, sanitized_name,
|
|
|
2fc102 |
+ SYSDB_PWNAM_FILTER, lc_sanitized_name, sanitized_name,
|
|
|
2fc102 |
sanitized_name);
|
|
|
2fc102 |
if (ret) {
|
|
|
2fc102 |
ret = sysdb_error_to_errno(ret);
|
|
|
2fc102 |
@@ -785,6 +792,7 @@ errno_t sysdb_getnetgr(TALLOC_CTX *mem_ctx,
|
|
|
2fc102 |
struct ldb_dn *base_dn;
|
|
|
2fc102 |
struct ldb_result *result;
|
|
|
2fc102 |
char *sanitized_netgroup;
|
|
|
2fc102 |
+ char *lc_sanitized_netgroup;
|
|
|
2fc102 |
char *netgroup_dn;
|
|
|
2fc102 |
int lret;
|
|
|
2fc102 |
errno_t ret;
|
|
|
2fc102 |
@@ -802,7 +810,9 @@ errno_t sysdb_getnetgr(TALLOC_CTX *mem_ctx,
|
|
|
2fc102 |
goto done;
|
|
|
2fc102 |
}
|
|
|
2fc102 |
|
|
|
2fc102 |
- ret = sss_filter_sanitize(tmp_ctx, netgroup, &sanitized_netgroup);
|
|
|
2fc102 |
+ ret = sss_filter_sanitize_for_dom(tmp_ctx, netgroup, domain,
|
|
|
2fc102 |
+ &sanitized_netgroup,
|
|
|
2fc102 |
+ &lc_sanitized_netgroup);
|
|
|
2fc102 |
if (ret != EOK) {
|
|
|
2fc102 |
goto done;
|
|
|
2fc102 |
}
|
|
|
2fc102 |
@@ -816,7 +826,7 @@ errno_t sysdb_getnetgr(TALLOC_CTX *mem_ctx,
|
|
|
2fc102 |
|
|
|
2fc102 |
lret = ldb_search(sysdb->ldb, tmp_ctx, &result, base_dn,
|
|
|
2fc102 |
LDB_SCOPE_SUBTREE, attrs,
|
|
|
2fc102 |
- SYSDB_NETGR_TRIPLES_FILTER,
|
|
|
2fc102 |
+ SYSDB_NETGR_TRIPLES_FILTER, lc_sanitized_netgroup,
|
|
|
2fc102 |
sanitized_netgroup, sanitized_netgroup,
|
|
|
2fc102 |
netgroup_dn);
|
|
|
2fc102 |
ret = sysdb_error_to_errno(lret);
|
|
|
2fc102 |
@@ -843,6 +853,7 @@ int sysdb_get_netgroup_attr(TALLOC_CTX *mem_ctx,
|
|
|
2fc102 |
struct ldb_dn *base_dn;
|
|
|
2fc102 |
struct ldb_result *result;
|
|
|
2fc102 |
char *sanitized_netgroup;
|
|
|
2fc102 |
+ char *lc_sanitized_netgroup;
|
|
|
2fc102 |
int ret;
|
|
|
2fc102 |
|
|
|
2fc102 |
tmp_ctx = talloc_new(NULL);
|
|
|
2fc102 |
@@ -857,7 +868,9 @@ int sysdb_get_netgroup_attr(TALLOC_CTX *mem_ctx,
|
|
|
2fc102 |
goto done;
|
|
|
2fc102 |
}
|
|
|
2fc102 |
|
|
|
2fc102 |
- ret = sss_filter_sanitize(tmp_ctx, netgrname, &sanitized_netgroup);
|
|
|
2fc102 |
+ ret = sss_filter_sanitize_for_dom(tmp_ctx, netgrname, domain,
|
|
|
2fc102 |
+ &sanitized_netgroup,
|
|
|
2fc102 |
+ &lc_sanitized_netgroup);
|
|
|
2fc102 |
if (ret != EOK) {
|
|
|
2fc102 |
goto done;
|
|
|
2fc102 |
}
|
|
|
2fc102 |
@@ -865,6 +878,7 @@ int sysdb_get_netgroup_attr(TALLOC_CTX *mem_ctx,
|
|
|
2fc102 |
ret = ldb_search(sysdb->ldb, tmp_ctx, &result, base_dn,
|
|
|
2fc102 |
LDB_SCOPE_SUBTREE, attributes,
|
|
|
2fc102 |
SYSDB_NETGR_FILTER,
|
|
|
2fc102 |
+ lc_sanitized_netgroup,
|
|
|
2fc102 |
sanitized_netgroup,
|
|
|
2fc102 |
sanitized_netgroup);
|
|
|
2fc102 |
if (ret) {
|
|
|
2fc102 |
diff --git a/src/responder/pam/pam_LOCAL_domain.c b/src/responder/pam/pam_LOCAL_domain.c
|
|
|
2fc102 |
index e7776cba3b74a86ef63dad30f08b4436a59a89be..49ddbcda39468e6a4f2065d97df309ce881b6aa4 100644
|
|
|
2fc102 |
--- a/src/responder/pam/pam_LOCAL_domain.c
|
|
|
2fc102 |
+++ b/src/responder/pam/pam_LOCAL_domain.c
|
|
|
2fc102 |
@@ -258,12 +258,12 @@ int LOCAL_pam_handler(struct pam_auth_req *preq)
|
|
|
2fc102 |
|
|
|
2fc102 |
if (res->count < 1) {
|
|
|
2fc102 |
DEBUG(4, ("No user found with filter ["SYSDB_PWNAM_FILTER"]\n",
|
|
|
2fc102 |
- pd->user, pd->user));
|
|
|
2fc102 |
+ pd->user, pd->user, pd->user));
|
|
|
2fc102 |
pd->pam_status = PAM_USER_UNKNOWN;
|
|
|
2fc102 |
goto done;
|
|
|
2fc102 |
} else if (res->count > 1) {
|
|
|
2fc102 |
DEBUG(4, ("More than one object found with filter ["SYSDB_PWNAM_FILTER"]\n",
|
|
|
2fc102 |
- pd->user, pd->user));
|
|
|
2fc102 |
+ pd->user, pd->user, pd->user));
|
|
|
2fc102 |
lreq->error = EFAULT;
|
|
|
2fc102 |
goto done;
|
|
|
2fc102 |
}
|
|
|
2fc102 |
diff --git a/src/tests/cmocka/test_utils.c b/src/tests/cmocka/test_utils.c
|
|
|
2fc102 |
index 1be59ab69cfa632010c5e1700dc79f59b6f48fde..61e8e9f07ca2f6772b12fe602acb3d2872b39c10 100644
|
|
|
2fc102 |
--- a/src/tests/cmocka/test_utils.c
|
|
|
2fc102 |
+++ b/src/tests/cmocka/test_utils.c
|
|
|
2fc102 |
@@ -177,6 +177,41 @@ void test_find_subdomain_by_sid_missing_sid(void **state)
|
|
|
2fc102 |
}
|
|
|
2fc102 |
}
|
|
|
2fc102 |
|
|
|
2fc102 |
+#define TEST_SANITIZE_INPUT "TestUser@Test.Domain"
|
|
|
2fc102 |
+#define TEST_SANITIZE_LC_INPUT "testuser@test.domain"
|
|
|
2fc102 |
+
|
|
|
2fc102 |
+void test_sss_filter_sanitize_for_dom(void **state)
|
|
|
2fc102 |
+{
|
|
|
2fc102 |
+ struct dom_list_test_ctx *test_ctx;
|
|
|
2fc102 |
+ int ret;
|
|
|
2fc102 |
+ char *sanitized;
|
|
|
2fc102 |
+ char *lc_sanitized;
|
|
|
2fc102 |
+ struct sss_domain_info *dom;
|
|
|
2fc102 |
+
|
|
|
2fc102 |
+ test_ctx = talloc_get_type(*state, struct dom_list_test_ctx);
|
|
|
2fc102 |
+ dom = test_ctx->dom_list;
|
|
|
2fc102 |
+
|
|
|
2fc102 |
+ dom->case_sensitive = true;
|
|
|
2fc102 |
+
|
|
|
2fc102 |
+ ret = sss_filter_sanitize_for_dom(test_ctx, TEST_SANITIZE_INPUT, dom,
|
|
|
2fc102 |
+ &sanitized, &lc_sanitized);
|
|
|
2fc102 |
+ assert_int_equal(ret, EOK);
|
|
|
2fc102 |
+ assert_string_equal(sanitized, TEST_SANITIZE_INPUT);
|
|
|
2fc102 |
+ assert_string_equal(lc_sanitized, TEST_SANITIZE_INPUT);
|
|
|
2fc102 |
+ talloc_free(sanitized);
|
|
|
2fc102 |
+ talloc_free(lc_sanitized);
|
|
|
2fc102 |
+
|
|
|
2fc102 |
+ dom->case_sensitive = false;
|
|
|
2fc102 |
+
|
|
|
2fc102 |
+ ret = sss_filter_sanitize_for_dom(test_ctx, TEST_SANITIZE_INPUT, dom,
|
|
|
2fc102 |
+ &sanitized, &lc_sanitized);
|
|
|
2fc102 |
+ assert_int_equal(ret, EOK);
|
|
|
2fc102 |
+ assert_string_equal(sanitized, TEST_SANITIZE_INPUT);
|
|
|
2fc102 |
+ assert_string_equal(lc_sanitized, TEST_SANITIZE_LC_INPUT);
|
|
|
2fc102 |
+ talloc_free(sanitized);
|
|
|
2fc102 |
+ talloc_free(lc_sanitized);
|
|
|
2fc102 |
+}
|
|
|
2fc102 |
+
|
|
|
2fc102 |
int main(int argc, const char *argv[])
|
|
|
2fc102 |
{
|
|
|
2fc102 |
poptContext pc;
|
|
|
2fc102 |
@@ -194,6 +229,9 @@ int main(int argc, const char *argv[])
|
|
|
2fc102 |
setup_dom_list, teardown_dom_list),
|
|
|
2fc102 |
unit_test_setup_teardown(test_find_subdomain_by_sid_missing_sid,
|
|
|
2fc102 |
setup_dom_list, teardown_dom_list),
|
|
|
2fc102 |
+
|
|
|
2fc102 |
+ unit_test_setup_teardown(test_sss_filter_sanitize_for_dom,
|
|
|
2fc102 |
+ setup_dom_list, teardown_dom_list),
|
|
|
2fc102 |
};
|
|
|
2fc102 |
|
|
|
2fc102 |
/* Set debug level to invalid value so we can deside if -d 0 was used. */
|
|
|
2fc102 |
diff --git a/src/util/sss_tc_utf8.c b/src/util/sss_tc_utf8.c
|
|
|
2fc102 |
index 6a976211f7b77d329ba3261577c43466406f3da9..e1426a44f3518783dca4f22cd6016cdde92d0f56 100644
|
|
|
2fc102 |
--- a/src/util/sss_tc_utf8.c
|
|
|
2fc102 |
+++ b/src/util/sss_tc_utf8.c
|
|
|
2fc102 |
@@ -55,3 +55,33 @@ sss_tc_utf8_tolower(TALLOC_CTX *mem_ctx, const uint8_t *s, size_t len, size_t *_
|
|
|
2fc102 |
return ret;
|
|
|
2fc102 |
}
|
|
|
2fc102 |
|
|
|
2fc102 |
+errno_t sss_filter_sanitize_for_dom(TALLOC_CTX *mem_ctx,
|
|
|
2fc102 |
+ const char *input,
|
|
|
2fc102 |
+ struct sss_domain_info *dom,
|
|
|
2fc102 |
+ char **sanitized,
|
|
|
2fc102 |
+ char **lc_sanitized)
|
|
|
2fc102 |
+{
|
|
|
2fc102 |
+ int ret;
|
|
|
2fc102 |
+
|
|
|
2fc102 |
+ ret = sss_filter_sanitize(mem_ctx, input, sanitized);
|
|
|
2fc102 |
+ if (ret != EOK) {
|
|
|
2fc102 |
+ DEBUG(SSSDBG_OP_FAILURE, ("sss_filter_sanitize failed.\n"));
|
|
|
2fc102 |
+ return ret;
|
|
|
2fc102 |
+ }
|
|
|
2fc102 |
+
|
|
|
2fc102 |
+ if (dom->case_sensitive) {
|
|
|
2fc102 |
+ *lc_sanitized = talloc_strdup(mem_ctx, *sanitized);
|
|
|
2fc102 |
+ } else {
|
|
|
2fc102 |
+ *lc_sanitized = sss_tc_utf8_str_tolower(mem_ctx, *sanitized);
|
|
|
2fc102 |
+ }
|
|
|
2fc102 |
+
|
|
|
2fc102 |
+ if (*lc_sanitized == NULL) {
|
|
|
2fc102 |
+ DEBUG(SSSDBG_OP_FAILURE, ("%s failed.\n",
|
|
|
2fc102 |
+ dom->case_sensitive ?
|
|
|
2fc102 |
+ "talloc_strdup" :
|
|
|
2fc102 |
+ "sss_tc_utf8_str_tolower"));
|
|
|
2fc102 |
+ return ENOMEM;
|
|
|
2fc102 |
+ }
|
|
|
2fc102 |
+
|
|
|
2fc102 |
+ return EOK;
|
|
|
2fc102 |
+}
|
|
|
2fc102 |
diff --git a/src/util/util.h b/src/util/util.h
|
|
|
2fc102 |
index 058c1c27986f9749a18dd4c92ddb9428349a1dac..3334476ab83a137d957765fe2c9afba4ad0d014c 100644
|
|
|
2fc102 |
--- a/src/util/util.h
|
|
|
2fc102 |
+++ b/src/util/util.h
|
|
|
2fc102 |
@@ -484,6 +484,12 @@ errno_t sss_filter_sanitize(TALLOC_CTX *mem_ctx,
|
|
|
2fc102 |
const char *input,
|
|
|
2fc102 |
char **sanitized);
|
|
|
2fc102 |
|
|
|
2fc102 |
+errno_t sss_filter_sanitize_for_dom(TALLOC_CTX *mem_ctx,
|
|
|
2fc102 |
+ const char *input,
|
|
|
2fc102 |
+ struct sss_domain_info *dom,
|
|
|
2fc102 |
+ char **sanitized,
|
|
|
2fc102 |
+ char **lc_sanitized);
|
|
|
2fc102 |
+
|
|
|
2fc102 |
char *
|
|
|
2fc102 |
sss_escape_ip_address(TALLOC_CTX *mem_ctx, int family, const char *addr);
|
|
|
2fc102 |
|
|
|
2fc102 |
--
|
|
|
2fc102 |
1.8.4.2
|
|
|
2fc102 |
|