[PATCH] Add two more tests for substitutions

Jeremy Allison jra at samba.org
Fri Mar 17 18:25:03 UTC 2017


On Fri, Mar 17, 2017 at 03:09:52PM +0100, Andreas Schneider via samba-technical wrote:
> On Friday, 17 March 2017 12:12:33 CET Andreas Schneider via samba-technical 
> wrote:
> > On Thursday, 16 March 2017 01:16:31 CET Jeremy Allison wrote:
> > > On Wed, Mar 15, 2017 at 10:53:08AM -0700, Jeremy Allison via
> > > samba-technical
> > wrote:
> > > > On Wed, Mar 15, 2017 at 01:12:12PM +0100, Andreas Schneider via samba-
> > 
> > technical wrote:
> > > > > Hi,
> > > > > 
> > > > > attached are two tests to tests substitutions for the share path name
> > > > > and also the 'template homedir'.
> > > > > 
> > > > > 
> > > > > Review and push much appreciated!
> > > > 
> > > > Great work Andreas, thanks for these ! RB+ and pushed.
> > > 
> > > Andreas, I'm getting an autobuild fail on these with:
> > > 
> > > Can you look into this ?
> > > 
> > > Sorry,
> > 
> > Don't be sorry, this actually reveals a real bug! I opened:
> > 
> > 
> > 	https://bugzilla.samba.org/show_bug.cgi?id=12699
> > 
> > 
> > Could also be a regression, but I'm not sure!
> > 
> > 
> > The attached patchset addresses the issue.
> > 
> > 
> > Please review again.
> 
> I've looked into it with Volker and he spotted the correct fix. See 
> attachment.

Oh good catch ! RB+.

> 
> -- 
> Andreas Schneider                   GPG-ID: CC014E3D
> Samba Team                             asn at samba.org
> www.samba.org

> From 090d3986da4ab346a40e3651b9f3e449705d7bbb Mon Sep 17 00:00:00 2001
> From: Volker Lendecke <vl at samba.org>
> Date: Fri, 17 Mar 2017 13:52:57 +0100
> Subject: [PATCH 1/4] s3:winbind: Use the correct talloc context for user
>  information
> 
> This fixes the substitution for 'template homedir'.
> 
> BUG: https://bugzilla.samba.org/show_bug.cgi?id=12699
> 
> Signed-off-by: Volker Lendecke <vl at samba.org>
> Reviewed-by: Andreas Schneider <asn at samba.org>
> ---
>  source3/winbindd/wb_queryuser.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/source3/winbindd/wb_queryuser.c b/source3/winbindd/wb_queryuser.c
> index be4d3d3e665..69b4c8dad5a 100644
> --- a/source3/winbindd/wb_queryuser.c
> +++ b/source3/winbindd/wb_queryuser.c
> @@ -329,7 +329,7 @@ static void wb_queryuser_got_group_name(struct tevent_req *subreq)
>  	NTSTATUS status;
>  	const char *domain_name;
>  
> -	status = wb_lookupsid_recv(subreq, state, &type, &domain_name,
> +	status = wb_lookupsid_recv(subreq, state->info, &type, &domain_name,
>  				   &state->info->primary_group_name);
>  	TALLOC_FREE(subreq);
>  	if (tevent_req_nterror(req, status)) {
> -- 
> 2.12.0
> 
> 
> From 7ca3a549814a9dedf805d7a3eeb21ec3f8e0b7e1 Mon Sep 17 00:00:00 2001
> From: Andreas Schneider <asn at samba.org>
> Date: Fri, 17 Mar 2017 10:04:19 +0100
> Subject: [PATCH 2/4] selftest: Define template homedir for 'ad_member' env
> 
> BUG: https://bugzilla.samba.org/show_bug.cgi?id=12699
> 
> With this set, the samba3.local.nss test for ad_member will ensure that
> we correctly substitute those smb.conf options.
> 
> Signed-off-by: Andreas Schneider <asn at samba.org>
> ---
>  selftest/target/Samba3.pm | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/selftest/target/Samba3.pm b/selftest/target/Samba3.pm
> index d754b5f9ac1..79699f053bb 100755
> --- a/selftest/target/Samba3.pm
> +++ b/selftest/target/Samba3.pm
> @@ -399,6 +399,7 @@ sub setup_admember($$$$)
>          workgroup = $dcvars->{DOMAIN}
>          realm = $dcvars->{REALM}
>          netbios aliases = foo bar
> +	template homedir = /home/%D/%G/%U
>  
>  [subDUG]
>  	path = $share_dir/D_%D/U_%U/G_%G
> -- 
> 2.12.0
> 
> 
> From 247344da3c3e33f416ef8e6d010907bc1a9bc196 Mon Sep 17 00:00:00 2001
> From: Andreas Schneider <asn at samba.org>
> Date: Wed, 15 Mar 2017 12:37:08 +0100
> Subject: [PATCH 3/4] s3:tests: Add a subsitution test for %D %u %g
> 
> BUG: https://bugzilla.samba.org/show_bug.cgi?id=12699
> 
> Signed-off-by: Andreas Schneider <asn at samba.org>
> ---
>  selftest/target/Samba3.pm                  | 19 ++++++++++++++++++-
>  source3/script/tests/test_substitutions.sh |  9 +++++++--
>  2 files changed, 25 insertions(+), 3 deletions(-)
> 
> diff --git a/selftest/target/Samba3.pm b/selftest/target/Samba3.pm
> index 79699f053bb..74997b43c8f 100755
> --- a/selftest/target/Samba3.pm
> +++ b/selftest/target/Samba3.pm
> @@ -394,6 +394,19 @@ sub setup_admember($$$$)
>  	$substitution_path = "$share_dir/D_SAMBADOMAIN/U_alice/G_domain users";
>  	push(@dirs, $substitution_path);
>  
> +	# Using '/' as the winbind separator is a bad idea ...
> +	$substitution_path = "$share_dir/D_SAMBADOMAIN/u_SAMBADOMAIN";
> +	push(@dirs, $substitution_path);
> +
> +	$substitution_path = "$share_dir/D_SAMBADOMAIN/u_SAMBADOMAIN/alice";
> +	push(@dirs, $substitution_path);
> +
> +	$substitution_path = "$share_dir/D_SAMBADOMAIN/u_SAMBADOMAIN/alice/g_SAMBADOMAIN";
> +	push(@dirs, $substitution_path);
> +
> +	$substitution_path = "$share_dir/D_SAMBADOMAIN/u_SAMBADOMAIN/alice/g_SAMBADOMAIN/domain users";
> +	push(@dirs, $substitution_path);
> +
>  	my $member_options = "
>  	security = ads
>          workgroup = $dcvars->{DOMAIN}
> @@ -401,10 +414,14 @@ sub setup_admember($$$$)
>          netbios aliases = foo bar
>  	template homedir = /home/%D/%G/%U
>  
> -[subDUG]
> +[sub_dug]
>  	path = $share_dir/D_%D/U_%U/G_%G
>  	writeable = yes
>  
> +[sub_dug2]
> +	path = $share_dir/D_%D/u_%u/g_%g
> +	writeable = yes
> +
>  ";
>  
>  	my $ret = $self->provision($prefix,
> diff --git a/source3/script/tests/test_substitutions.sh b/source3/script/tests/test_substitutions.sh
> index 0852ad969f0..1a46f11c85d 100755
> --- a/source3/script/tests/test_substitutions.sh
> +++ b/source3/script/tests/test_substitutions.sh
> @@ -24,9 +24,14 @@ smbclient="$samba_bindir/smbclient"
>  . $samba_srcdir/testprogs/blackbox/subunit.sh
>  . $samba_srcdir/testprogs/blackbox/common_test_fns.inc
>  
> -SMB_UNC="//$SERVER/subDUG"
> +SMB_UNC="//$SERVER/sub_dug"
>  
> -test_smbclient "Test login to share with substitution" \
> +test_smbclient "Test login to share with substitution (DUG)" \
> +	"ls" "$SMB_UNC" "-U$USERNAME%$PASSWORD" || failed=$(expr $failed + 1)
> +
> +SMB_UNC="//$SERVER/sub_dug2"
> +
> +test_smbclient "Test login to share with substitution (Dug)" \
>  	"ls" "$SMB_UNC" "-U$USERNAME%$PASSWORD" || failed=$(expr $failed + 1)
>  
>  exit $failed
> -- 
> 2.12.0
> 
> 
> From cf0221b055e8a662c943870f9a11ac96edd34d7d Mon Sep 17 00:00:00 2001
> From: Andreas Schneider <asn at samba.org>
> Date: Wed, 15 Mar 2017 13:04:43 +0100
> Subject: [PATCH 4/4] s3:tests: Add another test to verify substitution of
>  'template homedir'
> 
> BUG: https://bugzilla.samba.org/show_bug.cgi?id=12699
> 
> Signed-off-by: Andreas Schneider <asn at samba.org>
> ---
>  source3/script/tests/test_substitutions.sh | 26 +++++++++++++++++++-------
>  source3/selftest/tests.py                  |  2 +-
>  2 files changed, 20 insertions(+), 8 deletions(-)
> 
> diff --git a/source3/script/tests/test_substitutions.sh b/source3/script/tests/test_substitutions.sh
> index 1a46f11c85d..5620097c22a 100755
> --- a/source3/script/tests/test_substitutions.sh
> +++ b/source3/script/tests/test_substitutions.sh
> @@ -5,33 +5,45 @@
>  
>  if [ $# -lt 4 ]; then
>  cat <<EOF
> -Usage: test_substitutions.sh SERVER USERNAME PASSWORD PREFIX
> +Usage: test_substitutions.sh SERVER DOMAIN USERNAME PASSWORD PREFIX
>  EOF
>  exit 1;
>  fi
>  
>  SERVER=$1
> -USERNAME=$2
> -PASSWORD=$3
> -PREFIX=$4
> -shift 4
> +DOMAIN=$2
> +USERNAME=$3
> +PASSWORD=$4
> +PREFIX=$5
> +shift 5
>  failed=0
>  
>  samba_bindir="$BINDIR"
>  samba_srcdir="$SRCDIR"
>  smbclient="$samba_bindir/smbclient"
> +wbinfo="$samba_bindir/wbinfo"
>  
>  . $samba_srcdir/testprogs/blackbox/subunit.sh
>  . $samba_srcdir/testprogs/blackbox/common_test_fns.inc
>  
> +test_wbinfo_template_homedir()
> +{
> +	user="$1"
> +	shift
> +
> +	$wbinfo -i $user | grep "/home/$DOMAIN/Domain Users/alice"
> +}
> +
>  SMB_UNC="//$SERVER/sub_dug"
>  
> -test_smbclient "Test login to share with substitution (DUG)" \
> +test_smbclient "Test login to share with substitution (sub_dug)" \
>  	"ls" "$SMB_UNC" "-U$USERNAME%$PASSWORD" || failed=$(expr $failed + 1)
>  
>  SMB_UNC="//$SERVER/sub_dug2"
>  
> -test_smbclient "Test login to share with substitution (Dug)" \
> +test_smbclient "Test login to share with substitution (sub_dug2)" \
>  	"ls" "$SMB_UNC" "-U$USERNAME%$PASSWORD" || failed=$(expr $failed + 1)
>  
> +testit "wbinfo -i $DOMAIN+alice" test_wbinfo_template_homedir $DOMAIN/alice || failed=$(expr $failed + 1)
> +
>  exit $failed
> diff --git a/source3/selftest/tests.py b/source3/selftest/tests.py
> index 54f5b7baa03..436576229ac 100755
> --- a/source3/selftest/tests.py
> +++ b/source3/selftest/tests.py
> @@ -181,7 +181,7 @@ t = "--krb5auth=$DOMAIN/$DC_USERNAME%$DC_PASSWORD"
>  plantestsuite("samba3.wbinfo_simple.(%s:local).%s" % (env, t), "%s:local" % env, [os.path.join(srcdir(), "nsswitch/tests/test_wbinfo_simple.sh"), t])
>  t = "WBCLIENT-MULTI-PING"
>  plantestsuite("samba3.smbtorture_s3.%s" % t, env, [os.path.join(samba3srcdir, "script/tests/test_smbtorture_s3.sh"), t, '//foo/bar', '""', '""', smbtorture3, ""])
> -plantestsuite("samba3.substitutions", env, [os.path.join(samba3srcdir, "script/tests/test_substitutions.sh"), "$SERVER", "alice", "Secret007", "$PREFIX"])
> +plantestsuite("samba3.substitutions", env, [os.path.join(samba3srcdir, "script/tests/test_substitutions.sh"), "$SERVER", "$DOMAIN", "alice", "Secret007", "$PREFIX"])
>  
>  plantestsuite("samba3.ntlm_auth.krb5 with old ccache(ktest:local)", "ktest:local", [os.path.join(samba3srcdir, "script/tests/test_ntlm_auth_krb5.sh"), valgrindify(python), samba3srcdir, ntlm_auth3, '$PREFIX/ktest/krb5_ccache-2', '$SERVER', configuration])
>  
> -- 
> 2.12.0
> 




More information about the samba-technical mailing list