[PATCH][REGRESSION] The username set on the commandline is not parsed correctly

Andreas Schneider asn at samba.org
Mon Jun 19 12:57:59 UTC 2017


Hi,

this is a patch for https://bugzilla.samba.org/show_bug.cgi?id=12849

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!

See attached patched.


Please review.


Thanks,


	Andreas

-- 
Andreas Schneider                   GPG-ID: CC014E3D
Samba Team                             asn at samba.org
www.samba.org
-------------- next part --------------
>From 940cf645c5602c445e108302bde2caa7d01dff92 Mon Sep 17 00:00:00 2001
From: Andreas Schneider <asn at samba.org>
Date: Mon, 19 Jun 2017 14:50:33 +0200
Subject: [PATCH] s3:pop_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 <asn at samba.org>
---
 source3/lib/popt_common.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/source3/lib/popt_common.c b/source3/lib/popt_common.c
index 1c1e3d7c9d4..28a028d07b7 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,16 @@ void popt_common_credentials_post(void)
 	}
 
 	set_cmdline_auth_info_getpass(cmdline_auth_info);
+
+	/*
+	 * Read the username and set it again so the string gets completely
+	 * parsed. It might contain the DOMAIN name and use the winbind
+	 * separator set in the config file.
+	 */
+	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,
-- 
2.13.1



More information about the samba-technical mailing list