From 7fcaa07e2009066647b2e6c71ab82ce5724b43b5 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Thu, 23 Oct 2014 17:58:40 +1300 Subject: [PATCH] winbindd4: Force home directory in internal winbind to use a lower-case username This is a BEHAVIOUR CHANGE from Samba 4.0 and 4.1, if mixed-case usernames were in use. However, it matches the behaviour in winbindd in all other use cases. Pair-programmed-with: Garming Sam Signed-off-by: Garming Sam Signed-off-by: Andrew Bartlett Reviewed-by: Stefan Metzmacher --- source4/winbind/wb_cmd_getpwnam.c | 10 ++++++++-- source4/winbind/wb_cmd_getpwuid.c | 10 ++++++++-- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/source4/winbind/wb_cmd_getpwnam.c b/source4/winbind/wb_cmd_getpwnam.c index c4f3db8df68..2a25ba3d16c 100644 --- a/source4/winbind/wb_cmd_getpwnam.c +++ b/source4/winbind/wb_cmd_getpwnam.c @@ -110,6 +110,7 @@ static void cmd_getpwnam_recv_user_info(struct composite_context *ctx) struct libnet_UserInfo *user_info; struct winbindd_pw *pw; char *username_with_domain; + char *lowercase_username; DEBUG(5, ("cmd_getpwnam_recv_user_info called\n")); @@ -122,10 +123,15 @@ static void cmd_getpwnam_recv_user_info(struct composite_context *ctx) state->ctx->status = libnet_UserInfo_recv(ctx, state, user_info); if(!composite_is_ok(state->ctx)) return; + lowercase_username = strlower_talloc(state, user_info->out.account_name); + if (composite_nomem(lowercase_username, state->ctx)) { + return; + } + username_with_domain = talloc_asprintf(pw, "%s%s%s", state->workgroup_name, lpcfg_winbind_separator(state->service->task->lp_ctx), - user_info->out.account_name); + lowercase_username); if(composite_nomem(username_with_domain, state->ctx)) return; WBSRV_SAMBA3_SET_STRING(pw->pw_name, username_with_domain); @@ -135,7 +141,7 @@ static void cmd_getpwnam_recv_user_info(struct composite_context *ctx) lpcfg_template_homedir(state->service->task->lp_ctx)); all_string_sub(pw->pw_dir, "%D", state->workgroup_name, sizeof(fstring) - 1); - all_string_sub(pw->pw_dir, "%U", user_info->out.account_name, + all_string_sub(pw->pw_dir, "%U", lowercase_username, sizeof(fstring) - 1); WBSRV_SAMBA3_SET_STRING(pw->pw_shell, lpcfg_template_shell(state->service->task->lp_ctx)); diff --git a/source4/winbind/wb_cmd_getpwuid.c b/source4/winbind/wb_cmd_getpwuid.c index 997776760cf..6da3c088d25 100644 --- a/source4/winbind/wb_cmd_getpwuid.c +++ b/source4/winbind/wb_cmd_getpwuid.c @@ -130,6 +130,7 @@ static void cmd_getpwuid_recv_user_info(struct composite_context *ctx) struct libnet_UserInfo *user_info; struct winbindd_pw *pw; char *username_with_domain; + char *lowercase_username; DEBUG(5, ("cmd_getpwuid_recv_user_info called\n")); @@ -142,10 +143,15 @@ static void cmd_getpwuid_recv_user_info(struct composite_context *ctx) state->ctx->status = libnet_UserInfo_recv(ctx, state, user_info); if (!composite_is_ok(state->ctx)) return; + lowercase_username = strlower_talloc(state, user_info->out.account_name); + if (composite_nomem(lowercase_username, state->ctx)) { + return; + } + username_with_domain = talloc_asprintf(pw, "%s%s%s", state->workgroup, lpcfg_winbind_separator(state->service->task->lp_ctx), - user_info->out.account_name); + lowercase_username); if(composite_nomem(username_with_domain, state->ctx)) return; WBSRV_SAMBA3_SET_STRING(pw->pw_name, username_with_domain); @@ -155,7 +161,7 @@ static void cmd_getpwuid_recv_user_info(struct composite_context *ctx) lpcfg_template_homedir(state->service->task->lp_ctx)); all_string_sub(pw->pw_dir, "%D", state->workgroup, sizeof(fstring) - 1); - all_string_sub(pw->pw_dir, "%U", user_info->out.account_name, + all_string_sub(pw->pw_dir, "%U", lowercase_username, sizeof(fstring) - 1); WBSRV_SAMBA3_SET_STRING(pw->pw_shell, lpcfg_template_shell(state->service->task->lp_ctx));