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

Andreas Schneider asn at samba.org
Mon Jun 19 13:56:54 UTC 2017


On Monday, 19 June 2017 14:57:59 CEST Andreas Schneider via samba-technical 
wrote:
> 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


This one includes a test!

-- 
Andreas Schneider                   GPG-ID: CC014E3D
Samba Team                             asn at samba.org
www.samba.org
-------------- next part --------------
>From ef08fde84fb36384f31488df85906f41ac0cc7c5 Mon Sep 17 00:00:00 2001
From: Andreas Schneider <asn at samba.org>
Date: Mon, 19 Jun 2017 14:34:02 +0200
Subject: [PATCH 1/2] selftest: Use 'ad_dc' as the default for testenv

Signed-off-by: Andreas Schneider <asn at samba.org>
---
 selftest/selftest.pl | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/selftest/selftest.pl b/selftest/selftest.pl
index f05fc5cde49..6869132f7af 100755
--- a/selftest/selftest.pl
+++ b/selftest/selftest.pl
@@ -445,7 +445,7 @@ if (defined($ENV{SMBD_MAXTIME}) and $ENV{SMBD_MAXTIME} ne "") {
 
 unless ($opt_list) {
 	if ($opt_target eq "samba") {
-		$testenv_default = "ad_dc_ntvfs";
+		$testenv_default = "ad_dc";
 		require target::Samba;
 		$target = new Samba($bindir, $ldap, $srcdir, $server_maxtime);
 	} elsif ($opt_target eq "samba3") {
-- 
2.13.1


>From 3869b279cca5080882afb80ab9291bb87013c749 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 2/2] 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 <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