The branch, master has been updated via 24d43f8 WHATSNEW: Add new 'net tdb locking' command via 8a46c7a selftest: Add test for 'net tdb' command via 5a6d5ed selftest: Make lockdir available in test environment via d80de47 docs-xml: Document net tdb command via 25b5bb3 net: Add net tdb command to print information from tdb records via 10b3678 ctdb: Print key as hex string instead of just the hash in hot record message via ee3b17b idmap_rfc2307: Test unix-ids-to-sids with 35 groups via da7481f selftest: Avoid idmap caching when testing idmap_rfc2307 via 803ea2d idmap_rfc2307: "ldap_next_entry" needs the previous entry, not the start via c0f1217 idmap_rfc2307: Don't stop after 30 entries via e663357 test_idmap_rfc2307: Test wbinfo -r for 35 supplementary group memberships via 1f5097e test_idmap_rfc2307: Do a recursive delete in ou=idmap via f34ff62 test_idmap_rfc2307: Correct usage via 1893bb9 test_idmap_rfc2307: Avoid a tmpfile via 9e816ea test_idmap_rfc2307: Remove the correct file via 17563f2 idmap_rfc2307: "ldap_next_entry" needs the previous entry, not the start via 54a0e7e idmap_rfc2307: Don't stop after 30 entries from af09a73 ctdb-logging: Initialize DEBUGLEVEL before changing the value
https://git.samba.org/?p=samba.git;a=shortlog;h=master - Log ----------------------------------------------------------------- commit 24d43f88408d69b38b685974685b159eec897e87 Author: Christof Schmitt <c...@samba.org> Date: Mon Feb 20 11:52:58 2017 -0700 WHATSNEW: Add new 'net tdb locking' command Signed-off-by: Christof Schmitt <c...@samba.org> Reviewed-by: Volker Lendecke <v...@samba.org> Autobuild-User(master): Christof Schmitt <c...@samba.org> Autobuild-Date(master): Tue May 9 01:14:25 CEST 2017 on sn-devel-144 commit 8a46c7ad0934c6750a71efd45db45219809df2fe Author: Christof Schmitt <c...@samba.org> Date: Thu Feb 16 16:23:47 2017 -0700 selftest: Add test for 'net tdb' command Signed-off-by: Christof Schmitt <c...@samba.org> Reviewed-by: Volker Lendecke <v...@samba.org> commit 5a6d5ede33b197710811e6f27eca55d9e7f74d37 Author: Christof Schmitt <c...@samba.org> Date: Thu Feb 16 16:23:43 2017 -0700 selftest: Make lockdir available in test environment Signed-off-by: Christof Schmitt <c...@samba.org> Reviewed-by: Volker Lendecke <v...@samba.org> commit d80de473f8161b7c6333ecbb31e7774213b4546b Author: Christof Schmitt <c...@samba.org> Date: Thu Feb 16 16:23:34 2017 -0700 docs-xml: Document net tdb command Signed-off-by: Christof Schmitt <c...@samba.org> Reviewed-by: Volker Lendecke <v...@samba.org> commit 25b5bb3056bbd7d0aaeeff106e9cfc9cc309bc78 Author: Christof Schmitt <c...@samba.org> Date: Thu Feb 16 16:22:38 2017 -0700 net: Add net tdb command to print information from tdb records The main purpose is to debug "hot" records from ctdb. ctdb tracks contended records and identifies them by key in the dbstatistics: DB Statistics: locking.tdb [...] Num Hot Keys: 1 Count:3 Key:6a4128e3ced4681b02a00000000000000000000000000000 This command allows querying additional information for the associated key to identify the affected file. For now this only adds a subcommand for the locking.tdb, but could be extended to others: net tdb locking 6a4128e3ced4681b02a00000000000000000000000000000 Share path: /test/share Name: testfile Number of share modes: 2 Signed-off-by: Christof Schmitt <c...@samba.org> Reviewed-by: Volker Lendecke <v...@samba.org> commit 10b36782bf61fd30e4693244c7b698895ad09c2d Author: Christof Schmitt <c...@samba.org> Date: Thu Feb 16 16:23:39 2017 -0700 ctdb: Print key as hex string instead of just the hash in hot record message Signed-off-by: Christof Schmitt <c...@samba.org> Reviewed-by: Volker Lendecke <v...@samba.org> commit ee3b17ba4674a17a411c9ec4271e087c8cd7dad1 Author: Volker Lendecke <v...@samba.org> Date: Thu Apr 6 12:50:08 2017 +0200 idmap_rfc2307: Test unix-ids-to-sids with 35 groups BUG: https://bugzilla.samba.org/show_bug.cgi?id=12757 Signed-off-by: Volker Lendecke <v...@samba.org> Reviewed-by: Christof Schmitt <c...@samba.org> commit da7481f835ddc1fab16d11ccbaf7f33c213af23a Author: Volker Lendecke <v...@samba.org> Date: Tue Apr 4 17:15:10 2017 +0200 selftest: Avoid idmap caching when testing idmap_rfc2307 BUG: https://bugzilla.samba.org/show_bug.cgi?id=12757 Signed-off-by: Volker Lendecke <v...@samba.org> Reviewed-by: Christof Schmitt <c...@samba.org> commit 803ea2d2b7820939d03f7eb381c3cf719a00ff4a Author: Volker Lendecke <v...@samba.org> Date: Fri Mar 31 15:23:39 2017 +0000 idmap_rfc2307: "ldap_next_entry" needs the previous entry, not the start BUG: https://bugzilla.samba.org/show_bug.cgi?id=12757 Signed-off-by: Volker Lendecke <v...@samba.org> Reviewed-by: Christof Schmitt <c...@samba.org> commit c0f12170e8b9fb3ab75f53bba637c72f6465192e Author: Volker Lendecke <v...@samba.org> Date: Fri Mar 31 15:20:07 2017 +0000 idmap_rfc2307: Don't stop after 30 entries We start over again and again, so we need to search in the whole list. This is a quick hack generating a bad O(n^2). The real fix is to call idmap_rfc2307_find_map with "maps" starting at the right offset, but that's an optimization for later when it's restructured BUG: https://bugzilla.samba.org/show_bug.cgi?id=12757 Signed-off-by: Volker Lendecke <v...@samba.org> Reviewed-by: Christof Schmitt <c...@samba.org> commit e663357b4d7d5cb0c4d8a0ebc97cfcb58429b894 Author: Volker Lendecke <v...@samba.org> Date: Tue Apr 4 15:28:36 2017 +0200 test_idmap_rfc2307: Test wbinfo -r for 35 supplementary group memberships BUG: https://bugzilla.samba.org/show_bug.cgi?id=12757 Signed-off-by: Volker Lendecke <v...@samba.org> Reviewed-by: Christof Schmitt <c...@samba.org> commit 1f5097e3fbf9931c830880637622bb0b05863466 Author: Volker Lendecke <v...@samba.org> Date: Tue Apr 4 15:12:02 2017 +0200 test_idmap_rfc2307: Do a recursive delete in ou=idmap We'll create more posix objects soon BUG: https://bugzilla.samba.org/show_bug.cgi?id=12757 Signed-off-by: Volker Lendecke <v...@samba.org> Reviewed-by: Christof Schmitt <c...@samba.org> commit f34ff621edbfd8b7c99cdadec166a80ae9c5646c Author: Volker Lendecke <v...@samba.org> Date: Tue Apr 4 14:59:45 2017 +0200 test_idmap_rfc2307: Correct usage We already have 13 args at this point, and growing BUG: https://bugzilla.samba.org/show_bug.cgi?id=12757 Signed-off-by: Volker Lendecke <v...@samba.org> Reviewed-by: Christof Schmitt <c...@samba.org> commit 1893bb9bc48d9251820a185c95c65562f2878074 Author: Volker Lendecke <v...@samba.org> Date: Tue Apr 4 14:15:26 2017 +0200 test_idmap_rfc2307: Avoid a tmpfile We can << directly into ldbadd BUG: https://bugzilla.samba.org/show_bug.cgi?id=12757 Signed-off-by: Volker Lendecke <v...@samba.org> Reviewed-by: Christof Schmitt <c...@samba.org> commit 9e816ea2f8d21d392b4e9050e443ef936629202e Author: Volker Lendecke <v...@samba.org> Date: Tue Apr 4 14:15:26 2017 +0200 test_idmap_rfc2307: Remove the correct file BUG: https://bugzilla.samba.org/show_bug.cgi?id=12757 Signed-off-by: Volker Lendecke <v...@samba.org> Reviewed-by: Christof Schmitt <c...@samba.org> commit 17563f295ffa7379daa5bf7cc89540df4ae4f7b3 Author: Volker Lendecke <v...@samba.org> Date: Fri Mar 31 15:23:39 2017 +0000 idmap_rfc2307: "ldap_next_entry" needs the previous entry, not the start BUG: https://bugzilla.samba.org/show_bug.cgi?id=12757 Signed-off-by: Volker Lendecke <v...@samba.org> Reviewed-by: Christof Schmitt <c...@samba.org> commit 54a0e7e3d7332f420f36a3a20dd62156e6adea46 Author: Volker Lendecke <v...@samba.org> Date: Fri Mar 31 15:20:07 2017 +0000 idmap_rfc2307: Don't stop after 30 entries We start over again and again, so we need to search in the whole list. This is a quick hack generating a bad O(n^2). The real fix is to call idmap_rfc2307_find_map with "maps" starting at the right offset, but that's an optimization for later when it's restructured BUG: https://bugzilla.samba.org/show_bug.cgi?id=12757 Signed-off-by: Volker Lendecke <v...@samba.org> Reviewed-by: Christof Schmitt <c...@samba.org> ----------------------------------------------------------------------- Summary of changes: WHATSNEW.txt | 10 +++ ctdb/server/ctdb_call.c | 11 ++- docs-xml/manpages/net.8.xml | 22 ++++++ nsswitch/tests/test_idmap_rfc2307.sh | 130 ++++++++++++++++++++++++++--------- selftest/selftest.pl | 1 + selftest/target/Samba3.pm | 3 + source3/script/tests/test_net_tdb.sh | 99 ++++++++++++++++++++++++++ source3/selftest/tests.py | 17 ++++- source3/utils/net.c | 8 +++ source3/utils/net_proto.h | 3 + source3/utils/net_tdb.c | 120 ++++++++++++++++++++++++++++++++ source3/utils/wscript_build | 1 + source3/winbindd/idmap_rfc2307.c | 9 +-- source3/winbindd/idmap_util.c | 5 +- 14 files changed, 394 insertions(+), 45 deletions(-) create mode 100755 source3/script/tests/test_net_tdb.sh create mode 100644 source3/utils/net_tdb.c Changeset truncated at 500 lines: diff --git a/WHATSNEW.txt b/WHATSNEW.txt index a385d07..f8c65b2 100644 --- a/WHATSNEW.txt +++ b/WHATSNEW.txt @@ -62,6 +62,16 @@ authentication, SMB and RPC authorization is covered, however password changes are not at this stage, and this support is not currently backed by a testsuite. + +Query record for open file or directory +--------------------------------------- + +The record attached to an open file or directory in Samba can be +queried through the 'net tdb locking' command. In clustered Samba this +can be useful to determine the file or directory triggering +corresponding "hot" record warnings in ctdb. + + Parameter changes ----------------- diff --git a/ctdb/server/ctdb_call.c b/ctdb/server/ctdb_call.c index ed943f9..3b84e75 100644 --- a/ctdb/server/ctdb_call.c +++ b/ctdb/server/ctdb_call.c @@ -825,6 +825,7 @@ ctdb_update_db_stat_hot_keys(struct ctdb_db_context *ctdb_db, TDB_DATA key, int count) { int i, id; + char *keystr; /* smallest value is always at index 0 */ if (count <= ctdb_db->statistics.hot_keys[0].count) { @@ -860,9 +861,13 @@ ctdb_update_db_stat_hot_keys(struct ctdb_db_context *ctdb_db, TDB_DATA key, ctdb_db->statistics.hot_keys[id].key.dsize = key.dsize; ctdb_db->statistics.hot_keys[id].key.dptr = talloc_memdup(ctdb_db, key.dptr, key.dsize); ctdb_db->statistics.hot_keys[id].count = count; - DEBUG(DEBUG_NOTICE, - ("Updated hot key database=%s key=0x%08x id=%d count=%d\n", - ctdb_db->db_name, ctdb_hash(&key), id, count)); + + keystr = hex_encode_talloc(ctdb_db, + (unsigned char *)key.dptr, key.dsize); + DEBUG(DEBUG_NOTICE,("Updated hot key database=%s key=%s id=%d " + "count=%d\n", ctdb_db->db_name, + keystr ? keystr : "" , id, count)); + talloc_free(keystr); sort_keys: for (i = 1; i < MAX_HOT_KEYS; i++) { diff --git a/docs-xml/manpages/net.8.xml b/docs-xml/manpages/net.8.xml index 4482ae8..a43a062 100644 --- a/docs-xml/manpages/net.8.xml +++ b/docs-xml/manpages/net.8.xml @@ -2707,6 +2707,28 @@ Dump the locking table of a certain global lock. </refsect2> <refsect2> + <title>TDB</title> + + <para>Print information from tdb records.</para> + + <refsect3> + <title>TDB LOCKING <replaceable>key</replaceable> [DUMP]</title> + + <para>List sharename, filename and number of share modes + for a record from locking.tdb. With the optional DUMP options, + dump the complete record.</para> + + <itemizedlist> + <listitem> + <para><replaceable>KEY</replaceable> + Key of the tdb record as hex string.</para> + </listitem> + </itemizedlist> + + </refsect3> +</refsect2> + +<refsect2> <title>HELP [COMMAND]</title> <para>Gives usage information for the specified command.</para> diff --git a/nsswitch/tests/test_idmap_rfc2307.sh b/nsswitch/tests/test_idmap_rfc2307.sh index 90e32a7..c62da5d 100755 --- a/nsswitch/tests/test_idmap_rfc2307.sh +++ b/nsswitch/tests/test_idmap_rfc2307.sh @@ -1,7 +1,9 @@ #!/bin/sh # Test id mapping through idmap_rfc2307 module -if [ $# -lt 9 ]; then - echo Usage: $0 DOMAIN USERNAME UID USERNAME2 UID2 GROUPNAME GID GROUPNAME2 GID2 LDAPPREFIX DC_SERVER DC_USERNAME DC_PASSWORD +if [ $# -lt 15 ]; then + echo Usage: $0 DOMAIN USERNAME UID USERNAME2 UID2 \ + GROUPNAME GID GROUPNAME2 GID2 GID_START NUMGROUPS \ + LDAPPREFIX DC_SERVER DC_USERNAME DC_PASSWORD exit 1 fi @@ -15,12 +17,20 @@ GROUPGID="$7" GROUPNAME2="$8" GROUPGID2="$9" shift 9 -LDAPPREFIX="$1" -DC_SERVER="$2" -DC_USERNAME="$3" -DC_PASSWORD="$4" +GID_START="$1" +NUMGROUPS="$2" +LDAPPREFIX="$3" +DC_SERVER="$4" +DC_USERNAME="$5" +DC_PASSWORD="$6" wbinfo="$VALGRIND $BINDIR/wbinfo" +net="$VALGRIND $BINDIR/net" + +ldbsearch="ldbsearch" +if [ -x "$BINDIR/ldbsearch" ]; then + ldbsearch="$BINDIR/ldbsearch" +fi ldbadd="ldbadd" if [ -x "$BINDIR/ldbadd" ]; then @@ -37,22 +47,23 @@ failed=0 . `dirname $0`/../../testprogs/blackbox/subunit.sh # Delete LDAP records -$VALGRIND $ldbdel -H ldap://$DC_SERVER -U$DOMAIN/$DC_USERNAME%$DC_PASSWORD "cn=$USERNAME,$LDAPPREFIX" -$VALGRIND $ldbdel -H ldap://$DC_SERVER -U$DOMAIN/$DC_USERNAME%$DC_PASSWORD "cn=$USERNAME2,$LDAPPREFIX" -$VALGRIND $ldbdel -H ldap://$DC_SERVER -U$DOMAIN/$DC_USERNAME%$DC_PASSWORD "cn=$GROUPNAME,$LDAPPREFIX" -$VALGRIND $ldbdel -H ldap://$DC_SERVER -U$DOMAIN/$DC_USERNAME%$DC_PASSWORD "cn=$GROUPNAME2,$LDAPPREFIX" +$VALGRIND $ldbsearch -H ldap://$DC_SERVER -U$DOMAIN/$DC_USERNAME%$DC_PASSWORD \ + -s one -b "$LDAPPREFIX" | grep '^dn:' | cut -d ' ' -f 2- | + xargs -d '\n' -n 1 -IDEL_DN \ + $ldbdel -H ldap://$DC_SERVER -U$DOMAIN/$DC_USERNAME%$DC_PASSWORD \ + "DEL_DN" $VALGRIND $ldbdel -H ldap://$DC_SERVER -U$DOMAIN/$DC_USERNAME%$DC_PASSWORD "$LDAPPREFIX" # Add id mapping information to LDAP -cat > $PREFIX/tmpldb <<EOF +testit "add ldap prefix" $VALGRIND $ldbadd -H ldap://$DC_SERVER \ + -U$DOMAIN/$DC_USERNAME%$DC_PASSWORD <<EOF dn: $LDAPPREFIX objectclass: organizationalUnit EOF -testit "add ldap prefix" $VALGRIND $ldbadd -H ldap://$DC_SERVER -U$DOMAIN/$DC_USERNAME%$DC_PASSWORD $PREFIX/tmpldb - -cat > $PREFIX/tmpldb <<EOF +testit "add ldap user mapping record" $VALGRIND $ldbadd -H ldap://$DC_SERVER \ + -U$DOMAIN/$DC_USERNAME%$DC_PASSWORD <<EOF dn: cn=$USERNAME,$LDAPPREFIX objectClass: organizationalPerson objectClass: posixAccount @@ -64,9 +75,8 @@ gidNumber: 1 homeDirectory: /home/admin EOF -testit "add ldap user mapping record" $VALGRIND $ldbadd -H ldap://$DC_SERVER -U$DOMAIN/$DC_USERNAME%$DC_PASSWORD $PREFIX/tmpldb - -cat > $PREFIX/tmpldb <<EOF +testit "add second ldap user mapping record" $VALGRIND $ldbadd \ + -H ldap://$DC_SERVER -U$DOMAIN/$DC_USERNAME%$DC_PASSWORD <<EOF dn: cn=$USERNAME2,$LDAPPREFIX objectClass: organizationalPerson objectClass: posixAccount @@ -78,9 +88,8 @@ gidNumber: 2 homeDirectory: /home/admin EOF -testit "add second ldap user mapping record" $VALGRIND $ldbadd -H ldap://$DC_SERVER -U$DOMAIN/$DC_USERNAME%$DC_PASSWORD $PREFIX/tmpldb - -cat > $PREFIX/tmpldb <<EOF +testit "add ldap group mapping record" $VALGRIND $ldbadd \ + -H ldap://$DC_SERVER -U$DOMAIN/$DC_USERNAME%$DC_PASSWORD <<EOF dn: cn=$GROUPNAME,$LDAPPREFIX objectClass: posixGroup objectClass: groupOfNames @@ -89,9 +98,8 @@ gidNumber: $GROUPGID member: cn=$USERNAME,$LDAPPREFIX EOF -testit "add ldap group mapping record" $VALGRIND $ldbadd -H ldap://$DC_SERVER -U$DOMAIN/$DC_USERNAME%$DC_PASSWORD $PREFIX/tmpldb - -cat > $PREFIX/tmpldb <<EOF +testit "add second ldap group mapping record" $VALGRIND $ldbadd \ + -H ldap://$DC_SERVER -U$DOMAIN/$DC_USERNAME%$DC_PASSWORD <<EOF dn: cn=$GROUPNAME2,$LDAPPREFIX objectClass: posixGroup objectClass: groupOfNames @@ -100,10 +108,6 @@ gidNumber: $GROUPGID2 member: cn=$USERNAME,$LDAPPREFIX EOF -testit "add second ldap group mapping record" $VALGRIND $ldbadd -H ldap://$DC_SERVER -U$DOMAIN/$DC_USERNAME%$DC_PASSWORD $PREFIX/tmpldb - -rm -f $PREFIX/tmpldbmodify - testit "wbinfo --name-to-sid" $wbinfo --name-to-sid "$DOMAIN/$USERNAME" || failed=$(expr $failed + 1) user_sid=$($wbinfo -n "$DOMAIN/$USERNAME" | cut -d " " -f1) echo "$DOMAIN/$USERNAME resolved to $user_sid" @@ -147,11 +151,75 @@ echo "SID $group_sid2 resolved to $group_name2" testit "test $group_name2 = $DOMAIN/$GROUPNAME2" test "$(echo $group_name2 | tr A-Z a-z)" = "$(echo $DOMAIN/$GROUPNAME2 | tr A-Z a-z)" || failed=$(expr $failed + 1) +i=0 +while [ ${i} -lt ${NUMGROUPS} ] ; do + GRP=$(printf "test_rfc2307_group_%3.3d" "$i") + GRP_GID=$(expr "$GID_START" + "$i") + testit "Add group $GRP" $net rpc group add "$GRP" -S "$DC_SERVER" \ + -U"${DOMAIN}\\${DC_USERNAME}"%"${DC_PASSWORD}" || + failed=$(expr $failed + 1) + testit "Add groupmem $GRP $USERNAME" \ + $net rpc group addmem "$GRP" "$USERNAME" \ + -S "$DC_SERVER" \ + -U"${DOMAIN}\\${DC_USERNAME}"%"${DC_PASSWORD}" || + failed=$(expr $failed + 1) + testit "Add group object for $GRP $GRP_GID" \ + $VALGRIND $ldbadd \ + -H ldap://$DC_SERVER -U$DOMAIN/$DC_USERNAME%$DC_PASSWORD <<EOF +dn: cn=$GRP,$LDAPPREFIX +objectClass: posixGroup +objectClass: groupOfNames +cn: $GRP +gidNumber: $GRP_GID +member: cn=$USERNAME,$LDAPPREFIX +EOF + i=$(expr "$i" + 1) +done + +# Test whether wbinfo --xids-to-sids finds everything + +GIDS="" +i=0 +while [ ${i} -lt ${NUMGROUPS} ] ; do + GIDS="$GIDS g$(expr ${i} + ${GID_START})" + i=$(expr "$i" + 1) +done +NUM_VALID_SIDS=$($wbinfo --unix-ids-to-sids="$GIDS" | grep -v ^S-0-0 | wc -l) + +testit "Count number of valid sids found" \ + test ${NUM_VALID_SIDS} = ${NUMGROUPS} || + failed=$(expr $failed + 1) + +# Test whether wbinfo -r shows all groups + +EXPECTED_USERGROUPS="1000000/1000001/2000002/" +i=0 +while [ ${i} -lt ${NUMGROUPS} ] ; do + EXPECTED_USERGROUPS="$EXPECTED_USERGROUPS$(expr ${i} + ${GID_START})/" + i=$(expr "$i" + 1) +done + +USERGROUPS=$($wbinfo -r $DOMAIN/$USERNAME | sort -n | tr '\n' '/') + +testit "Testing for expected group memberships" \ + test "$USERGROUPS" = "$EXPECTED_USERGROUPS" || + failed=$(expr $failed + 1) + +i=0 +while [ ${i} -lt ${NUMGROUPS} ] ; do + GRP=$(printf "test_rfc2307_group_%3.3d" ${i}) + testit "Del group $GRP" $net rpc group delete "$GRP" -S "$DC_SERVER" \ + -U"${DOMAIN}\\${DC_USERNAME}"%"${DC_PASSWORD}" || + failed=$(expr $failed + 1) + i=$(expr "$i" + 1) +done + # Delete LDAP records -$VALGRIND $ldbdel -H ldap://$DC_SERVER -U$DOMAIN/$DC_USERNAME%$DC_PASSWORD "cn=$USERNAME,$LDAPPREFIX" -$VALGRIND $ldbdel -H ldap://$DC_SERVER -U$DOMAIN/$DC_USERNAME%$DC_PASSWORD "cn=$USERNAME2,$LDAPPREFIX" -$VALGRIND $ldbdel -H ldap://$DC_SERVER -U$DOMAIN/$DC_USERNAME%$DC_PASSWORD "cn=$GROUPNAME,$LDAPPREFIX" -$VALGRIND $ldbdel -H ldap://$DC_SERVER -U$DOMAIN/$DC_USERNAME%$DC_PASSWORD "cn=$GROUPNAME2,$LDAPPREFIX" +$VALGRIND $ldbsearch -H ldap://$DC_SERVER -U$DOMAIN/$DC_USERNAME%$DC_PASSWORD \ + -s one -b "$LDAPPREFIX" | grep '^dn:' | cut -d ' ' -f 2- | + xargs -d '\n' -n 1 -IDEL_DN \ + $ldbdel -H ldap://$DC_SERVER -U$DOMAIN/$DC_USERNAME%$DC_PASSWORD \ + "DEL_DN" $VALGRIND $ldbdel -H ldap://$DC_SERVER -U$DOMAIN/$DC_USERNAME%$DC_PASSWORD "$LDAPPREFIX" exit $failed diff --git a/selftest/selftest.pl b/selftest/selftest.pl index 3ab07a7..f05fc5c 100755 --- a/selftest/selftest.pl +++ b/selftest/selftest.pl @@ -863,6 +863,7 @@ my @exported_envvars = ( "DNS_FORWARDER2", "RESOLV_CONF", "UNACCEPTABLE_PASSWORD", + "LOCK_DIR", # nss_wrapper "NSS_WRAPPER_PASSWD", diff --git a/selftest/target/Samba3.pm b/selftest/target/Samba3.pm index c241bd1..6d57584 100755 --- a/selftest/target/Samba3.pm +++ b/selftest/target/Samba3.pm @@ -507,6 +507,8 @@ sub setup_admember_rfc2307($$$$) security = ads workgroup = $dcvars->{DOMAIN} realm = $dcvars->{REALM} + idmap cache time = 0 + idmap negative cache time = 0 idmap config * : backend = autorid idmap config * : range = 1000000-1999999 idmap config * : rangesize = 100000 @@ -2104,6 +2106,7 @@ force_user:x:$gid_force_user: $ret{SMBD_TEST_LOG_POS} = 0; $ret{SERVERCONFFILE} = $conffile; $ret{CONFIGURATION} ="-s $conffile"; + $ret{LOCK_DIR} = $lockdir; $ret{SERVER} = $server; $ret{USERNAME} = $unix_name; $ret{USERID} = $unix_uid; diff --git a/source3/script/tests/test_net_tdb.sh b/source3/script/tests/test_net_tdb.sh new file mode 100755 index 0000000..731cad3 --- /dev/null +++ b/source3/script/tests/test_net_tdb.sh @@ -0,0 +1,99 @@ +#!/bin/sh +# +# Test 'net tdb' command. +# +# Verify that the command returns the correct information in the +# expected format. The 'dump' option is tested, but the output is not +# checked, since the internal data structure could change in the +# future. +# +# Copyright (C) 2017 Christof Schmitt + +if [ $# -lt 7 ]; then +cat <<EOF +Usage: $0 SMBCLIENT SERVER SHARE USER PASS CONFIGURATION LOCALPATH LOCKDIR +EOF +exit 1; +fi + +SMBCLIENT=$1 +SERVER=$2 +SHARE=$3 +USER=$4 +PASS=$5 +CONFIGURATION=$6 +LOCALPATH=$7 +LOCKDIR=$8 + +FILENAME=net_tdb_testfile + +failed=0 + +incdir=`dirname $0`/../../../testprogs/blackbox +. $incdir/subunit.sh + +touch $LOCALPATH/$FILENAME + +printf "open %s\n"'!sleep 10'"\n" ${FILENAME} | \ + $SMBCLIENT //$SERVER/$SHARE -U$USER%$PASS & +SMBCLIENTPID=$! + +# Give smbclient a chance to open the file +sleep 1 + +testit "Looking for record key of open file" \ + $BINDIR/tdbtool $LOCKDIR/locking.tdb hexkeys || \ + failed=$(expr $failed + 1) + +# The assumption here is that only one file is open, so only one +# record can exist in the database. + +# Output of 'tdbtool hexkeys' is in this format: +#[000] 01 FD 00 00 00 00 00 00 56 02 5C 00 00 00 00 00 ....... V.\.... +#[010] 00 00 00 00 00 00 00 00 ....... +# Select only the hex data, remove space and join every thing together +key=0x$($BINDIR/tdbtool $LOCKDIR/locking.tdb hexkeys | \ + grep '\[' | cut -c 7-56 | sed -e 's/ //g' | tr -d '\n') + +testit "Looking for open file in locking.tdb" \ + $BINDIR/net $CONFIGURATION tdb locking $key || \ + failed=$(expr $failed + 1) +out=$($BINDIR/net $CONFIGURATION tdb locking $key) + +out=$($BINDIR/net $CONFIGURATION tdb locking $key | \ + grep 'Share path: ' | sed -e 's/Share path: \+//') +testit "Verify pathname in output" \ + test "$out" = "$LOCALPATH" || \ + failed=$(expr $failed + 1) + +out=$($BINDIR/net $CONFIGURATION tdb locking $key | \ + grep 'Name:' | sed -e 's/Name: \+//') +testit "Verify filename in output" \ + test "$out" = "$FILENAME" || \ + failed=$(expr $failed + 1) + +out=$($BINDIR/net $CONFIGURATION tdb locking $key | \ + grep 'Number of share modes:' | \ + sed -e 's/Number of share modes: \+//') +testit "Verify number of share modes in output" \ + test "$out" = "1" || \ + failed=$(expr $failed + 1) + +testit "Complete record dump" \ + $BINDIR/net $CONFIGURATION tdb locking $key dump || \ + failed=$(expr $failed + 1) + +$BINDIR/net $CONFIGURATION tdb locking $key dump | grep -q $FILENAME +RC=$? +testit "Verify filename in dump output" \ + test $RC = 0 || \ + failed=$(expr $failed + 1) +$BINDIR/net $CONFIGURATION tdb locking $key dump | grep -q $LOCALPATH +RC=$? +testit "Verify share path in dump output" \ + test $RC = 0 || \ + failed=$(expr $failed + 1) + +kill $SMBCLIENTPID + +testok $0 $failed diff --git a/source3/selftest/tests.py b/source3/selftest/tests.py index b4dc417..5f707c0 100755 --- a/source3/selftest/tests.py +++ b/source3/selftest/tests.py @@ -400,7 +400,17 @@ for t in tests: plansmbtorture4testsuite(t, "nt4_dc", '//$SERVER_IP/write-list-tmp -U$USERNAME%$PASSWORD') plansmbtorture4testsuite(t, "ad_dc", '//$SERVER/tmp -U$USERNAME%$PASSWORD') elif t == "idmap.rfc2307": - plantestsuite(t, "ad_member_rfc2307", [os.path.join(samba3srcdir, "../nsswitch/tests/test_idmap_rfc2307.sh"), '$DOMAIN', 'Administrator', '2000000', 'Guest', '2000001', '"Domain Users"', '2000002', 'DnsAdmins', '2000003', 'ou=idmap,dc=samba,dc=example,dc=com', '$DC_SERVER', '$DC_USERNAME', '$DC_PASSWORD']) + plantestsuite(t, "ad_member_rfc2307", + [os.path.join(samba3srcdir, + "../nsswitch/tests/test_idmap_rfc2307.sh"), + '$DOMAIN', + 'Administrator', '2000000', + 'Guest', '2000001', + '"Domain Users"', '2000002', + 'DnsAdmins', '2000003', + '2000005', '35', + 'ou=idmap,dc=samba,dc=example,dc=com', + '$DC_SERVER', '$DC_USERNAME', '$DC_PASSWORD']) elif t == "idmap.alloc": plantestsuite(t, "ad_member_rfc2307", [os.path.join(samba3srcdir, "../nsswitch/tests/test_idmap_nss.sh"), '$DOMAIN']) elif t == "idmap.rid": @@ -507,6 +517,11 @@ plantestsuite("samba3.blackbox.sharesec", "simpleserver:local", [os.path.join(samba3srcdir, "script/tests/test_sharesec.sh"), configuration, os.path.join(bindir(), "sharesec"), "tmp"]) +plantestsuite("samba3.blackbox.net_tdb", "simpleserver:local", + [ os.path.join(samba3srcdir, "script/tests/test_net_tdb.sh"), + smbclient3, '$SERVER', 'tmp', '$USERNAME', '$PASSWORD', + configuration, '$LOCAL_PATH', '$LOCK_DIR' ]) + 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", diff --git a/source3/utils/net.c b/source3/utils/net.c index beb8760..34884f0 100644 --- a/source3/utils/net.c +++ b/source3/utils/net.c @@ -751,6 +751,14 @@ static struct functable net_func[] = { "'net notify' commands.") }, + { "tdb", + net_tdb, + NET_TRANSPORT_LOCAL, + N_("Show information from tdb records"), + N_(" Use 'net help tdb' to get more information about " + "'net tdb' commands.") + }, + #ifdef WITH_FAKE_KASERVER { "afs", net_afs, diff --git a/source3/utils/net_proto.h b/source3/utils/net_proto.h index 093aa4b..f0ae538 100644 --- a/source3/utils/net_proto.h +++ b/source3/utils/net_proto.h @@ -462,4 +462,7 @@ int net_rpc_trust(struct net_context *c, int argc, const char **argv); int net_rpc_conf(struct net_context *c, int argc, const char **argv); int net_notify(struct net_context *c, int argc, const char **argv); + +int net_tdb(struct net_context *c, int argc, const char **argv); + #endif /* _NET_PROTO_H_ */ diff --git a/source3/utils/net_tdb.c b/source3/utils/net_tdb.c new file mode 100644 index 0000000..a03cc0e --- /dev/null +++ b/source3/utils/net_tdb.c @@ -0,0 +1,120 @@ +/* + * Samba Unix/Linux client library + * net tdb commands to query tdb record information + * Copyright (C) 2016, 2017 Christof Schmitt <c...@samba.org> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by -- Samba Shared Repository