summaryrefslogtreecommitdiffstats
path: root/src/db
diff options
context:
space:
mode:
authorSumit Bose <sbose@redhat.com>2013-12-13 11:44:59 +0100
committerJakub Hrozek <jhrozek@redhat.com>2013-12-19 10:24:16 +0100
commit15a1519ec9c23f598716ffa89e533cd9bfb2a4f3 (patch)
tree8dda85aa957c9b29cd7db696c6caae7fb8ac64ae /src/db
parentc9124effceb40890bc9dd157155618067a7b8d2f (diff)
downloadsssd-15a1519ec9c23f598716ffa89e533cd9bfb2a4f3.tar.gz
sssd-15a1519ec9c23f598716ffa89e533cd9bfb2a4f3.tar.xz
sssd-15a1519ec9c23f598716ffa89e533cd9bfb2a4f3.zip
Use lower-case name for case-insensitive searches
The patch makes sure that a completely lower-cased version of a fully qualified name is used for case insensitive searches. Currently there are code paths where the domain name was used as configured and was not lower-cased. To make sure this patch does not break with old entries in the cache or case sensitive domains a third template was added to the related filters templates which is either filled with a completely lower-cased version or with the old version. The other two template values are unchanged.
Diffstat (limited to 'src/db')
-rw-r--r--src/db/sysdb.h10
-rw-r--r--src/db/sysdb_ops.c8
-rw-r--r--src/db/sysdb_search.c30
3 files changed, 32 insertions, 16 deletions
diff --git a/src/db/sysdb.h b/src/db/sysdb.h
index cec8bdd20..2230f2c4b 100644
--- a/src/db/sysdb.h
+++ b/src/db/sysdb.h
@@ -144,23 +144,23 @@
#define SYSDB_NC "objectclass="SYSDB_NETGROUP_CLASS
#define SYSDB_MPGC "|("SYSDB_UC")("SYSDB_GC")"
-#define SYSDB_PWNAM_FILTER "(&("SYSDB_UC")(|("SYSDB_NAME_ALIAS"=%s)("SYSDB_NAME"=%s)))"
+#define SYSDB_PWNAM_FILTER "(&("SYSDB_UC")(|("SYSDB_NAME_ALIAS"=%s)("SYSDB_NAME_ALIAS"=%s)("SYSDB_NAME"=%s)))"
#define SYSDB_PWUID_FILTER "(&("SYSDB_UC")("SYSDB_UIDNUM"=%lu))"
#define SYSDB_PWSID_FILTER "(&("SYSDB_UC")("SYSDB_SID_STR"=%s))"
#define SYSDB_PWENT_FILTER "("SYSDB_UC")"
-#define SYSDB_GRNAM_FILTER "(&("SYSDB_GC")(|("SYSDB_NAME_ALIAS"=%s)("SYSDB_NAME"=%s)))"
+#define SYSDB_GRNAM_FILTER "(&("SYSDB_GC")(|("SYSDB_NAME_ALIAS"=%s)("SYSDB_NAME_ALIAS"=%s)("SYSDB_NAME"=%s)))"
#define SYSDB_GRGID_FILTER "(&("SYSDB_GC")("SYSDB_GIDNUM"=%lu))"
#define SYSDB_GRSID_FILTER "(&("SYSDB_GC")("SYSDB_SID_STR"=%s))"
#define SYSDB_GRENT_FILTER "("SYSDB_GC")"
-#define SYSDB_GRNAM_MPG_FILTER "(&("SYSDB_MPGC")(|("SYSDB_NAME_ALIAS"=%s)("SYSDB_NAME"=%s)))"
+#define SYSDB_GRNAM_MPG_FILTER "(&("SYSDB_MPGC")(|("SYSDB_NAME_ALIAS"=%s)("SYSDB_NAME_ALIAS"=%s)("SYSDB_NAME"=%s)))"
#define SYSDB_GRGID_MPG_FILTER "(&("SYSDB_MPGC")("SYSDB_GIDNUM"=%lu))"
#define SYSDB_GRENT_MPG_FILTER "("SYSDB_MPGC")"
#define SYSDB_INITGR_FILTER "(&("SYSDB_GC")("SYSDB_GIDNUM"=*))"
-#define SYSDB_NETGR_FILTER "(&("SYSDB_NC")(|("SYSDB_NAME_ALIAS"=%s)("SYSDB_NAME"=%s)))"
-#define SYSDB_NETGR_TRIPLES_FILTER "(|("SYSDB_NAME"=%s)("SYSDB_NAME_ALIAS"=%s)("SYSDB_MEMBEROF"=%s))"
+#define SYSDB_NETGR_FILTER "(&("SYSDB_NC")(|("SYSDB_NAME_ALIAS"=%s)("SYSDB_NAME_ALIAS"=%s)("SYSDB_NAME"=%s)))"
+#define SYSDB_NETGR_TRIPLES_FILTER "(|("SYSDB_NAME_ALIAS"=%s)("SYSDB_NAME"=%s)("SYSDB_NAME_ALIAS"=%s)("SYSDB_MEMBEROF"=%s))"
#define SYSDB_SID_FILTER "(&(|("SYSDB_UC")("SYSDB_GC"))("SYSDB_SID_STR"=%s))"
diff --git a/src/db/sysdb_ops.c b/src/db/sysdb_ops.c
index adbe9a158..cb331e1e2 100644
--- a/src/db/sysdb_ops.c
+++ b/src/db/sysdb_ops.c
@@ -305,6 +305,7 @@ int sysdb_search_user_by_name(TALLOC_CTX *mem_ctx,
struct ldb_dn *basedn;
size_t msgs_count = 0;
char *sanitized_name;
+ char *lc_sanitized_name;
char *filter;
int ret;
@@ -320,13 +321,14 @@ int sysdb_search_user_by_name(TALLOC_CTX *mem_ctx,
goto done;
}
- ret = sss_filter_sanitize(tmp_ctx, name, &sanitized_name);
+ ret = sss_filter_sanitize_for_dom(tmp_ctx, name, domain, &sanitized_name,
+ &lc_sanitized_name);
if (ret != EOK) {
goto done;
}
- filter = talloc_asprintf(tmp_ctx, SYSDB_PWNAM_FILTER, sanitized_name,
- sanitized_name);
+ filter = talloc_asprintf(tmp_ctx, SYSDB_PWNAM_FILTER, lc_sanitized_name,
+ sanitized_name, sanitized_name);
if (!filter) {
ret = ENOMEM;
goto done;
diff --git a/src/db/sysdb_search.c b/src/db/sysdb_search.c
index 83681384f..d5b7a305f 100644
--- a/src/db/sysdb_search.c
+++ b/src/db/sysdb_search.c
@@ -37,6 +37,7 @@ int sysdb_getpwnam(TALLOC_CTX *mem_ctx,
struct ldb_dn *base_dn;
struct ldb_result *res;
char *sanitized_name;
+ char *lc_sanitized_name;
const char *src_name;
int ret;
@@ -60,13 +61,15 @@ int sysdb_getpwnam(TALLOC_CTX *mem_ctx,
goto done;
}
- ret = sss_filter_sanitize(tmp_ctx, src_name, &sanitized_name);
+ ret = sss_filter_sanitize_for_dom(tmp_ctx, src_name, domain,
+ &sanitized_name, &lc_sanitized_name);
if (ret != EOK) {
goto done;
}
ret = ldb_search(domain->sysdb->ldb, tmp_ctx, &res, base_dn,
LDB_SCOPE_SUBTREE, attrs, SYSDB_PWNAM_FILTER,
+ lc_sanitized_name,
sanitized_name, sanitized_name);
if (ret) {
ret = sysdb_error_to_errno(ret);
@@ -210,6 +213,7 @@ int sysdb_getgrnam(TALLOC_CTX *mem_ctx,
struct ldb_dn *base_dn;
struct ldb_result *res;
const char *src_name;
+ char *lc_sanitized_name;
int ret;
tmp_ctx = talloc_new(NULL);
@@ -239,14 +243,15 @@ int sysdb_getgrnam(TALLOC_CTX *mem_ctx,
goto done;
}
- ret = sss_filter_sanitize(tmp_ctx, src_name, &sanitized_name);
+ ret = sss_filter_sanitize_for_dom(tmp_ctx, src_name, domain,
+ &sanitized_name, &lc_sanitized_name);
if (ret != EOK) {
goto done;
}
ret = ldb_search(domain->sysdb->ldb, tmp_ctx, &res, base_dn,
LDB_SCOPE_SUBTREE, attrs, fmt_filter,
- sanitized_name, sanitized_name);
+ lc_sanitized_name, sanitized_name, sanitized_name);
if (ret) {
ret = sysdb_error_to_errno(ret);
goto done;
@@ -473,6 +478,7 @@ int sysdb_get_user_attr(TALLOC_CTX *mem_ctx,
struct ldb_dn *base_dn;
struct ldb_result *res;
char *sanitized_name;
+ char *lc_sanitized_name;
int ret;
tmp_ctx = talloc_new(NULL);
@@ -487,14 +493,15 @@ int sysdb_get_user_attr(TALLOC_CTX *mem_ctx,
goto done;
}
- ret = sss_filter_sanitize(tmp_ctx, name, &sanitized_name);
+ ret = sss_filter_sanitize_for_dom(tmp_ctx, name, domain, &sanitized_name,
+ &lc_sanitized_name);
if (ret != EOK) {
goto done;
}
ret = ldb_search(domain->sysdb->ldb, tmp_ctx, &res, base_dn,
LDB_SCOPE_SUBTREE, attributes,
- SYSDB_PWNAM_FILTER, sanitized_name,
+ SYSDB_PWNAM_FILTER, lc_sanitized_name, sanitized_name,
sanitized_name);
if (ret) {
ret = sysdb_error_to_errno(ret);
@@ -776,6 +783,7 @@ errno_t sysdb_getnetgr(TALLOC_CTX *mem_ctx,
struct ldb_dn *base_dn;
struct ldb_result *result;
char *sanitized_netgroup;
+ char *lc_sanitized_netgroup;
char *netgroup_dn;
int lret;
errno_t ret;
@@ -793,7 +801,9 @@ errno_t sysdb_getnetgr(TALLOC_CTX *mem_ctx,
goto done;
}
- ret = sss_filter_sanitize(tmp_ctx, netgroup, &sanitized_netgroup);
+ ret = sss_filter_sanitize_for_dom(tmp_ctx, netgroup, domain,
+ &sanitized_netgroup,
+ &lc_sanitized_netgroup);
if (ret != EOK) {
goto done;
}
@@ -807,7 +817,7 @@ errno_t sysdb_getnetgr(TALLOC_CTX *mem_ctx,
lret = ldb_search(domain->sysdb->ldb, tmp_ctx, &result, base_dn,
LDB_SCOPE_SUBTREE, attrs,
- SYSDB_NETGR_TRIPLES_FILTER,
+ SYSDB_NETGR_TRIPLES_FILTER, lc_sanitized_netgroup,
sanitized_netgroup, sanitized_netgroup,
netgroup_dn);
ret = sysdb_error_to_errno(lret);
@@ -833,6 +843,7 @@ int sysdb_get_netgroup_attr(TALLOC_CTX *mem_ctx,
struct ldb_dn *base_dn;
struct ldb_result *result;
char *sanitized_netgroup;
+ char *lc_sanitized_netgroup;
int ret;
tmp_ctx = talloc_new(NULL);
@@ -847,7 +858,9 @@ int sysdb_get_netgroup_attr(TALLOC_CTX *mem_ctx,
goto done;
}
- ret = sss_filter_sanitize(tmp_ctx, netgrname, &sanitized_netgroup);
+ ret = sss_filter_sanitize_for_dom(tmp_ctx, netgrname, domain,
+ &sanitized_netgroup,
+ &lc_sanitized_netgroup);
if (ret != EOK) {
goto done;
}
@@ -855,6 +868,7 @@ int sysdb_get_netgroup_attr(TALLOC_CTX *mem_ctx,
ret = ldb_search(domain->sysdb->ldb, tmp_ctx, &result, base_dn,
LDB_SCOPE_SUBTREE, attributes,
SYSDB_NETGR_FILTER,
+ lc_sanitized_netgroup,
sanitized_netgroup,
sanitized_netgroup);
if (ret) {