summaryrefslogtreecommitdiffstats
path: root/src/responder
diff options
context:
space:
mode:
authorLukas Slebodnik <lslebodn@redhat.com>2014-07-23 17:23:00 +0200
committerJakub Hrozek <jhrozek@redhat.com>2014-07-28 10:11:51 +0200
commit21bc143c2855638242e9dfe01ea66198b5883b8a (patch)
tree653fa3b89f5c512887bfbcd3478c24f30f400809 /src/responder
parent022c6b90bb37851c0e8704c0e5388ebc113c6470 (diff)
downloadsssd-21bc143c2855638242e9dfe01ea66198b5883b8a.tar.gz
sssd-21bc143c2855638242e9dfe01ea66198b5883b8a.tar.xz
sssd-21bc143c2855638242e9dfe01ea66198b5883b8a.zip
NSS: Replace spaces with specified string in names.
This patch add possibility to replace whitespace in user and group names with a specified string. With string "-", sssd will return the same result as winbind enabled option "winbind normalize names" Resolves: https://fedorahosted.org/sssd/ticket/1854 Reviewed-by: Pavel Reichl <preichl@redhat.com> Reviewed-by: Michal Židek <mzidek@redhat.com>
Diffstat (limited to 'src/responder')
-rw-r--r--src/responder/nss/nsssrv.c5
-rw-r--r--src/responder/nss/nsssrv.h1
-rw-r--r--src/responder/nss/nsssrv_cmd.c62
3 files changed, 67 insertions, 1 deletions
diff --git a/src/responder/nss/nsssrv.c b/src/responder/nss/nsssrv.c
index 84a6b7fed..cf4525a71 100644
--- a/src/responder/nss/nsssrv.c
+++ b/src/responder/nss/nsssrv.c
@@ -298,6 +298,11 @@ static int nss_get_config(struct nss_ctx *nctx,
&nctx->homedir_substr);
if (ret != EOK) goto done;
+ ret = confdb_get_string(cdb, nctx, CONFDB_NSS_CONF_ENTRY,
+ CONFDB_NSS_OVERRIDE_DEFAULT_WHITESPACE, NULL,
+ &nctx->override_default_wsp_str);
+ if (ret != EOK) goto done;
+
ret = 0;
done:
return ret;
diff --git a/src/responder/nss/nsssrv.h b/src/responder/nss/nsssrv.h
index a5b946b7e..07443027e 100644
--- a/src/responder/nss/nsssrv.h
+++ b/src/responder/nss/nsssrv.h
@@ -69,6 +69,7 @@ struct nss_ctx {
char **etc_shells;
char *shell_fallback;
char *default_shell;
+ char *override_default_wsp_str;
struct sss_mc_ctx *pwd_mc_ctx;
struct sss_mc_ctx *grp_mc_ctx;
diff --git a/src/responder/nss/nsssrv_cmd.c b/src/responder/nss/nsssrv_cmd.c
index a168a3e5d..75349085d 100644
--- a/src/responder/nss/nsssrv_cmd.c
+++ b/src/responder/nss/nsssrv_cmd.c
@@ -371,6 +371,15 @@ static int fill_pwent(struct sss_packet *packet,
"sss_get_cased_name failed, skipping\n");
continue;
}
+
+ tmpstr = sss_replace_whitespaces(tmp_ctx, tmpstr,
+ nctx->override_default_wsp_str);
+ if (tmpstr == NULL) {
+ DEBUG(SSSDBG_CRIT_FAILURE,
+ "sss_replace_whitespaces failed, skipping\n");
+ continue;
+ }
+
to_sized_string(&name, tmpstr);
tmpstr = ldb_msg_find_attr_as_string(msg, SYSDB_GECOS, NULL);
@@ -743,6 +752,14 @@ static int nss_cmd_getpwnam_search(struct nss_dom_ctx *dctx)
name = sss_get_cased_name(cmdctx, cmdctx->name, dom->case_sensitive);
if (!name) return ENOMEM;
+ name = sss_reverse_replace_whitespaces(dctx, name,
+ nctx->override_default_wsp_str);
+ if (name == NULL) {
+ DEBUG(SSSDBG_CRIT_FAILURE,
+ "sss_reverse_replace_whitespaces failed\n");
+ return ENOMEM;
+ }
+
/* verify this user has not yet been negatively cached,
* or has been permanently filtered */
ret = sss_ncache_check_user(nctx->ncache, nctx->neg_timeout,
@@ -2316,7 +2333,7 @@ static int fill_members(struct sss_packet *packet,
int memnum = *_memnum;
size_t rzero= *_rzero;
size_t rsize = *_rsize;
- char *tmpstr;
+ const char *tmpstr;
struct sized_string name;
TALLOC_CTX *tmp_ctx = NULL;
@@ -2344,6 +2361,15 @@ static int fill_members(struct sss_packet *packet,
continue;
}
+ tmpstr = sss_replace_whitespaces(tmp_ctx, tmpstr,
+ nctx->override_default_wsp_str);
+ if (tmpstr == NULL) {
+ DEBUG(SSSDBG_CRIT_FAILURE,
+ "sss_replace_whitespaces failed\n");
+ ret = ENOMEM;
+ goto done;
+ }
+
if (nctx->filter_users_in_groups) {
ret = sss_ncache_check_user(nctx->ncache,
nctx->neg_timeout,
@@ -2498,6 +2524,15 @@ static int fill_grent(struct sss_packet *packet,
"sss_get_cased_name failed, skipping\n");
continue;
}
+
+ tmpstr = sss_replace_whitespaces(tmp_ctx, tmpstr,
+ nctx->override_default_wsp_str);
+ if (tmpstr == NULL) {
+ DEBUG(SSSDBG_CRIT_FAILURE,
+ "sss_replace_whitespaces failed, skipping\n");
+ continue;
+ }
+
to_sized_string(&name, tmpstr);
/* fill in gid and name and set pointer for number of members */
@@ -2692,6 +2727,14 @@ static int nss_cmd_getgrnam_search(struct nss_dom_ctx *dctx)
name = sss_get_cased_name(dctx, cmdctx->name, dom->case_sensitive);
if (!name) return ENOMEM;
+ name = sss_reverse_replace_whitespaces(dctx, name,
+ nctx->override_default_wsp_str);
+ if (name == NULL) {
+ DEBUG(SSSDBG_CRIT_FAILURE,
+ "sss_reverse_replace_whitespaces failed\n");
+ return ENOMEM;
+ }
+
/* verify this group has not yet been negatively cached,
* or has been permanently filtered */
ret = sss_ncache_check_group(nctx->ncache, nctx->neg_timeout,
@@ -3715,6 +3758,14 @@ static int nss_cmd_initgroups_search(struct nss_dom_ctx *dctx)
name = sss_get_cased_name(dctx, cmdctx->name, dom->case_sensitive);
if (!name) return ENOMEM;
+ name = sss_reverse_replace_whitespaces(dctx, name,
+ nctx->override_default_wsp_str);
+ if (name == NULL) {
+ DEBUG(SSSDBG_CRIT_FAILURE,
+ "sss_reverse_replace_whitespaces failed\n");
+ return ENOMEM;
+ }
+
/* verify this user has not yet been negatively cached,
* or has been permanently filtered */
ret = sss_ncache_check_user(nctx->ncache, nctx->neg_timeout,
@@ -3874,6 +3925,15 @@ static errno_t nss_cmd_getsidby_search(struct nss_dom_ctx *dctx)
goto done;
}
+ name = sss_reverse_replace_whitespaces(dctx, name,
+ nctx->override_default_wsp_str);
+ if (name == NULL) {
+ DEBUG(SSSDBG_CRIT_FAILURE,
+ "sss_reverse_replace_whitespaces failed\n");
+ ret = ENOMEM;
+ goto done;
+ }
+
/* For subdomains a fully qualified name is needed for
* sysdb_search_user_by_name and sysdb_search_group_by_name. */
if (IS_SUBDOMAIN(dom)) {