[PATCH] net cache samlogon list|show|ndrdump|delete (was: RFC: net cache samlogon list|show|delete)

Ralph Böhme slow at samba.org
Tue Jul 4 07:19:18 UTC 2017


On Mon, Jul 03, 2017 at 10:26:14PM +0200, Ralph Böhme wrote:
> On Tue, Jul 04, 2017 at 07:35:04AM +1200, Andrew Bartlett wrote:
> > On Mon, 2017-07-03 at 14:34 +0200, Ralph Böhme via samba-technical
> > wrote:
> > > attached is an updated version where I removed an overlooked if(0) {...}.
> > > 
> > > Cheerio!
> > > -slow
> > 
> > Sorry to ask this late, but can we have some tests for this?
> 
> sure, Andreas already requested this. I have a WIP patch:
> <https://git.samba.org/?p=slow/samba.git;a=commitdiff;h=f8b4d51dcba68de0a4c376f0f7930ddf0f6854a6>
> 
> I'll followup tomorrow with the final patch.

attached.

Please review&push if ok. Thanks!

Cheerio!
-slow
-------------- next part --------------
From 3ef87523169f92ebcf1796133779974859eb485d Mon Sep 17 00:00:00 2001
From: Ralph Boehme <slow at samba.org>
Date: Mon, 3 Jul 2017 18:36:29 +0200
Subject: [PATCH] s3/tests: add a net cache samlogon test

Signed-off-by: Ralph Boehme <slow at samba.org>
---
 source3/script/tests/test_net_cache_samlogon.sh | 43 +++++++++++++++++++++++++
 source3/selftest/tests.py                       |  4 +++
 2 files changed, 47 insertions(+)
 create mode 100755 source3/script/tests/test_net_cache_samlogon.sh

diff --git a/source3/script/tests/test_net_cache_samlogon.sh b/source3/script/tests/test_net_cache_samlogon.sh
new file mode 100755
index 0000000..ba181d2
--- /dev/null
+++ b/source3/script/tests/test_net_cache_samlogon.sh
@@ -0,0 +1,43 @@
+#!/bin/sh
+#
+# Test 'net cache samlogon' command.
+#
+
+if [ $# -lt 4 ]; then
+cat <<EOF
+Usage: $0 SERVER SHARE USER PASS
+EOF
+exit 1;
+fi
+
+SERVER=$1
+SHARE=$2
+USER=$3
+PASS=$4
+
+failed=0
+
+incdir=`dirname $0`/../../../testprogs/blackbox
+. $incdir/subunit.sh
+
+# Ensure the samlogon cache is primed
+testit "Prime samlogon cache" $BINDIR/smbclient -U$USER%$PASS //$SERVER/$SHARE -c exit || failed=$(expr $failed + 1)
+
+# Ensure list works and remember the sid and name of the first entry
+testit "net cache samlogon list" $BINDIR/net cache samlogon list || failed=$(expr $failed + 1)
+list=$($BINDIR/net cache samlogon list)
+
+usersid=$($BINDIR/net cache samlogon list | grep '^S-' | head -n 1 | awk '{ print $1 }')
+username=$($BINDIR/net cache samlogon list | grep '^S-' | head -n 1 | awk '{ print $2 }')
+
+# Test the show command with the sid from the previous list command
+testit "net cache samlogon show $usersid" $BINDIR/net cache samlogon show $usersid || failed=$(expr $failed + 1)
+tmp=$($BINDIR/net cache samlogon show $usersid | awk '/^Name:/ {print $2}')
+testit "net cache samlogon show SID name matches name from list command" test x"$tmp" == x"$username" || failed=$(expr $failed + 1)
+
+testit "net cache samlogon ndrdump $usersid" $BINDIR/net cache samlogon ndrdump $usersid || failed=$(expr $failed + 1)
+tmp=$($BINDIR/net cache samlogon ndrdump $usersid | head -n 1 | grep "netr_SamInfo3: struct netr_SamInfo3")
+retval=$?
+testit "net cache samlogon ndrdump returns netr_SamInfo3 structure" test $retval -eq 0 || failed=$(expr $failed + 1)
+
+testok $0 $failed
diff --git a/source3/selftest/tests.py b/source3/selftest/tests.py
index f07084f..d459ede 100755
--- a/source3/selftest/tests.py
+++ b/source3/selftest/tests.py
@@ -556,6 +556,10 @@ plantestsuite("samba3.blackbox.net_tdb", "simpleserver:local",
                 smbclient3, '$SERVER', 'tmp', '$USERNAME', '$PASSWORD',
                 configuration, '$LOCAL_PATH', '$LOCK_DIR' ])
 
+plantestsuite("samba3.blackbox.net_cache_samlogon", "ad_member:local",
+              [ os.path.join(samba3srcdir, "script/tests/test_net_cache_samlogon.sh"),
+                '$SERVER', 'tmp', '$DC_USERNAME', '$DC_PASSWORD'])
+
 plantestsuite("samba3.blackbox.net_dom_join_fail_dc", "nt4_dc",
               [os.path.join(samba3srcdir, "script/tests/test_net_dom_join_fail_dc.sh"),
                "$USERNAME", "$PASSWORD", "$SERVER", "$PREFIX/net_dom_join_fail_dc",
-- 
2.9.4



More information about the samba-technical mailing list