From: Andreas Schneider Date: Mon, 19 Jun 2017 12:50:33 +0000 (+0200) Subject: s3:popt_common: Reparse the username in popt_common_credentials_post() X-Git-Tag: tevent-0.9.32~47 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0caf40ec0196de0de016fda0d4aff0734d498d2b;p=thirdparty%2Fsamba.git s3:popt_common: Reparse the username in popt_common_credentials_post() When we parse the username in the options handling, the smb.conf file has not been loaded yet. So we are not aware of a 'winbind separator' set in the config file. We need to read and set the username again in the post-processing of the credentials. https://bugzilla.samba.org/show_bug.cgi?id=12849 Signed-off-by: Andreas Schneider Reviewed-by: Stefan Metzmacher --- diff --git a/source3/lib/popt_common.c b/source3/lib/popt_common.c index 1c1e3d7c9d4..65b6efeeb54 100644 --- a/source3/lib/popt_common.c +++ b/source3/lib/popt_common.c @@ -247,6 +247,8 @@ void popt_common_credentials_set_delay_post(void) void popt_common_credentials_post(void) { + const char *username = NULL; + if (get_cmdline_auth_info_use_machine_account(cmdline_auth_info) && !set_cmdline_auth_info_machine_account_creds(cmdline_auth_info)) { @@ -256,6 +258,20 @@ void popt_common_credentials_post(void) } set_cmdline_auth_info_getpass(cmdline_auth_info); + + /* + * When we set the username during the handling of the options passed to + * the binary we haven't loaded the config yet. This means that we + * didnn't take the 'winbind separator' into account. + * + * The username might contain the domain name and thus it hasn't been + * correctly parsed yet. If we have a username we need to set it again + * to run the string parser for the username correctly. + */ + username = get_cmdline_auth_info_username(cmdline_auth_info); + if (username != NULL && username[0] != '\0') { + set_cmdline_auth_info_username(cmdline_auth_info, username); + } } static void popt_common_credentials_callback(poptContext con,