summaryrefslogtreecommitdiffstats
path: root/testprogs
diff options
context:
space:
mode:
Diffstat (limited to 'testprogs')
-rwxr-xr-xtestprogs/blackbox/b15464-testcase.sh21
-rwxr-xr-xtestprogs/blackbox/bogus.sh28
-rw-r--r--testprogs/blackbox/common-links.sh211
-rwxr-xr-xtestprogs/blackbox/common_test_fns.inc155
-rwxr-xr-xtestprogs/blackbox/dbcheck-links.sh1003
-rwxr-xr-xtestprogs/blackbox/dbcheck-oldrelease.sh547
-rwxr-xr-xtestprogs/blackbox/dbcheck.sh72
-rwxr-xr-xtestprogs/blackbox/demote-saveddb.sh77
-rwxr-xr-xtestprogs/blackbox/dfree.sh8
-rwxr-xr-xtestprogs/blackbox/dom_parse.sh27
-rwxr-xr-xtestprogs/blackbox/functionalprep.sh183
-rwxr-xr-xtestprogs/blackbox/join_ldapcmp.sh51
-rwxr-xr-xtestprogs/blackbox/ldapcmp_restoredc.sh73
-rwxr-xr-xtestprogs/blackbox/nsstest.sh22
-rwxr-xr-xtestprogs/blackbox/renamedc.sh103
-rwxr-xr-xtestprogs/blackbox/runtime-links.sh82
-rwxr-xr-xtestprogs/blackbox/schemaupgrade.sh131
-rwxr-xr-xtestprogs/blackbox/subunit.sh212
-rwxr-xr-xtestprogs/blackbox/test_alias_membership.sh194
-rwxr-xr-xtestprogs/blackbox/test_chgdcpass.sh115
-rwxr-xr-xtestprogs/blackbox/test_client_etypes.sh82
-rwxr-xr-xtestprogs/blackbox/test_client_kerberos.sh286
-rwxr-xr-xtestprogs/blackbox/test_kinit.sh555
-rwxr-xr-xtestprogs/blackbox/test_kinit_export_keytab.sh263
-rwxr-xr-xtestprogs/blackbox/test_kinit_trusts.sh247
-rwxr-xr-xtestprogs/blackbox/test_kpasswd_heimdal.sh245
-rwxr-xr-xtestprogs/blackbox/test_kpasswd_mit.sh224
-rwxr-xr-xtestprogs/blackbox/test_ktpass.sh38
-rwxr-xr-xtestprogs/blackbox/test_ldap_tls_reload.sh64
-rwxr-xr-xtestprogs/blackbox/test_ldb.sh230
-rwxr-xr-xtestprogs/blackbox/test_ldb_simple.sh40
-rwxr-xr-xtestprogs/blackbox/test_net_ads.sh364
-rwxr-xr-xtestprogs/blackbox/test_net_ads_dns.sh195
-rwxr-xr-xtestprogs/blackbox/test_net_ads_fips.sh43
-rwxr-xr-xtestprogs/blackbox/test_net_ads_search_server.sh37
-rwxr-xr-xtestprogs/blackbox/test_net_offline.sh162
-rwxr-xr-xtestprogs/blackbox/test_net_rpc_user.sh56
-rwxr-xr-xtestprogs/blackbox/test_offline_logon.sh43
-rwxr-xr-xtestprogs/blackbox/test_old_enctypes.sh61
-rwxr-xr-xtestprogs/blackbox/test_password_settings.sh251
-rwxr-xr-xtestprogs/blackbox/test_pdbtest.sh116
-rwxr-xr-xtestprogs/blackbox/test_pkinit_pac.sh61
-rwxr-xr-xtestprogs/blackbox/test_pkinit_simple.sh331
-rwxr-xr-xtestprogs/blackbox/test_primary_group.sh93
-rwxr-xr-xtestprogs/blackbox/test_rpcclient_schannel.sh94
-rwxr-xr-xtestprogs/blackbox/test_s4u_heimdal.sh90
-rwxr-xr-xtestprogs/blackbox/test_samba-tool_ntacl.sh264
-rwxr-xr-xtestprogs/blackbox/test_samba_upgradedns.sh36
-rwxr-xr-xtestprogs/blackbox/test_smbtorture_test_names.sh43
-rwxr-xr-xtestprogs/blackbox/test_special_group.sh58
-rwxr-xr-xtestprogs/blackbox/test_trust_ntlm.sh205
-rwxr-xr-xtestprogs/blackbox/test_trust_token.sh91
-rwxr-xr-xtestprogs/blackbox/test_trust_user_account.sh58
-rwxr-xr-xtestprogs/blackbox/test_trust_utils.sh144
-rwxr-xr-xtestprogs/blackbox/test_weak_crypto.sh51
-rwxr-xr-xtestprogs/blackbox/test_weak_crypto_server.sh64
-rwxr-xr-xtestprogs/blackbox/test_weak_disable_ntlmssp_ldap.sh41
-rwxr-xr-xtestprogs/blackbox/test_wintest.sh43
-rwxr-xr-xtestprogs/blackbox/tfork.sh15
-rwxr-xr-xtestprogs/blackbox/tombstones-expunge.sh246
-rwxr-xr-xtestprogs/blackbox/upgradeprovision-oldrelease.sh234
-rw-r--r--testprogs/blackbox/wintest/wintest.conf7
-rw-r--r--testprogs/win32/midltests/Makefile16
-rw-r--r--testprogs/win32/midltests/Makefile.simple27
-rw-r--r--testprogs/win32/midltests/Makefile.tcp22
-rw-r--r--testprogs/win32/midltests/invalid/README.txt3
-rw-r--r--testprogs/win32/midltests/invalid/midltests_pipe_struct_union_01.idl279
-rw-r--r--testprogs/win32/midltests/invalid/midltests_pipe_struct_union_01.txt17
-rw-r--r--testprogs/win32/midltests/midltests.acf6
-rw-r--r--testprogs/win32/midltests/midltests.idl51
-rw-r--r--testprogs/win32/midltests/midltests_c_m.c2
-rw-r--r--testprogs/win32/midltests/midltests_marshall.c125
-rw-r--r--testprogs/win32/midltests/midltests_marshall.h19
-rw-r--r--testprogs/win32/midltests/midltests_s_m.c2
-rw-r--r--testprogs/win32/midltests/midltests_simple.c42
-rw-r--r--testprogs/win32/midltests/midltests_tcp.c646
-rw-r--r--testprogs/win32/midltests/todo/midltests-array-range.idl39
-rw-r--r--testprogs/win32/midltests/todo/midltests-pipe-02.idl153
-rw-r--r--testprogs/win32/midltests/todo/midltests-pipe-03-hyper.idl205
-rw-r--r--testprogs/win32/midltests/todo/midltests-pipe-04-struct.idl272
-rwxr-xr-xtestprogs/win32/midltests/todo/midltests-pipe-first.idl233
-rw-r--r--testprogs/win32/midltests/todo/midltests-pipe-sync-ndr32-downgrade-02.idl296
-rw-r--r--testprogs/win32/midltests/todo/midltests-string-in-out-ref.idl33
-rwxr-xr-xtestprogs/win32/midltests/todo/midltests-transmit-as.idl59
-rwxr-xr-xtestprogs/win32/midltests/todo/midltests_pointer_default.idl20
-rw-r--r--testprogs/win32/midltests/utils.c32
-rw-r--r--testprogs/win32/midltests/valid/README.txt6
-rw-r--r--testprogs/win32/midltests/valid/midltests-pipe-sync-ndr32-downgrade-01.idl296
-rw-r--r--testprogs/win32/midltests/valid/midltests-pipe-sync-ndr32-downgrade-01.txt138
-rw-r--r--testprogs/win32/midltests/valid/midltests-pipe-sync-ndr32-downgrade-02.idl300
-rw-r--r--testprogs/win32/midltests/valid/midltests-pipe-sync-ndr32-downgrade-02.txt3266
-rw-r--r--testprogs/win32/midltests/valid/midltests_DRS_EXTENSIONS.idl64
-rw-r--r--testprogs/win32/midltests/valid/midltests_DRS_EXTENSIONS.out43
-rw-r--r--testprogs/win32/midltests/valid/midltests_fixed_size_in_array_01.idl29
-rw-r--r--testprogs/win32/midltests/valid/midltests_fixed_size_in_array_01.txt6
-rw-r--r--testprogs/win32/midltests/valid/midltests_strings_array_01.err.txt13
-rw-r--r--testprogs/win32/midltests/valid/midltests_strings_array_01.idl44
-rw-r--r--testprogs/win32/midltests/valid/midltests_strings_array_02.idl44
-rw-r--r--testprogs/win32/midltests/valid/midltests_strings_array_02.txt9
-rw-r--r--testprogs/win32/midltests/valid/midltests_union_align_01.idl42
-rw-r--r--testprogs/win32/midltests/valid/midltests_union_align_01.txt24
-rw-r--r--testprogs/win32/midltests/valid/midltests_union_align_02.idl61
-rw-r--r--testprogs/win32/midltests/valid/midltests_union_align_02.txt37
-rw-r--r--testprogs/win32/midltests/valid/midltests_union_align_03.idl64
-rw-r--r--testprogs/win32/midltests/valid/midltests_union_align_03.txt37
-rw-r--r--testprogs/win32/midltests/valid/midltests_union_align_04.idl64
-rw-r--r--testprogs/win32/midltests/valid/midltests_union_align_04.txt37
-rw-r--r--testprogs/win32/midltests/valid/midltests_union_align_05.idl61
-rw-r--r--testprogs/win32/midltests/valid/midltests_union_align_05.txt37
-rw-r--r--testprogs/win32/midltests/valid/midltests_union_align_06.idl61
-rw-r--r--testprogs/win32/midltests/valid/midltests_union_align_06.txt37
-rw-r--r--testprogs/win32/midltests/valid/midltests_union_align_07.idl61
-rw-r--r--testprogs/win32/midltests/valid/midltests_union_align_07.txt38
-rw-r--r--testprogs/win32/midltests/valid/midltests_union_align_08.idl68
-rw-r--r--testprogs/win32/midltests/valid/midltests_union_align_08.txt129
-rw-r--r--testprogs/win32/midltests/valid/midltests_union_align_09.idl69
-rw-r--r--testprogs/win32/midltests/valid/midltests_union_align_09.txt129
-rw-r--r--testprogs/win32/midltests/valid/midltests_union_align_10.idl71
-rw-r--r--testprogs/win32/midltests/valid/midltests_union_align_10.txt129
-rw-r--r--testprogs/win32/midltests/valid/midltests_union_align_11.idl70
-rw-r--r--testprogs/win32/midltests/valid/midltests_union_align_11.txt129
-rw-r--r--testprogs/win32/midltests/valid/midltests_union_align_12.idl70
-rw-r--r--testprogs/win32/midltests/valid/midltests_union_align_12.txt129
-rw-r--r--testprogs/win32/midltests/valid/midltests_union_align_13.idl71
-rw-r--r--testprogs/win32/midltests/valid/midltests_union_align_13.txt129
-rw-r--r--testprogs/win32/midltests/valid/midltests_union_align_14.idl71
-rw-r--r--testprogs/win32/midltests/valid/midltests_union_align_14.txt131
-rw-r--r--testprogs/win32/midltests/valid/midltests_union_align_15.idl72
-rw-r--r--testprogs/win32/midltests/valid/midltests_union_align_15.txt131
-rw-r--r--testprogs/win32/midltests/valid/midltests_union_align_16.idl93
-rw-r--r--testprogs/win32/midltests/valid/midltests_union_align_16.txt137
-rw-r--r--testprogs/win32/midltests/valid/midltests_union_align_17.idl94
-rw-r--r--testprogs/win32/midltests/valid/midltests_union_align_17.txt137
-rw-r--r--testprogs/win32/midltests/valid/midltests_union_align_18.idl93
-rw-r--r--testprogs/win32/midltests/valid/midltests_union_align_18.txt137
-rw-r--r--testprogs/win32/midltests/valid/midltests_union_align_19.idl90
-rw-r--r--testprogs/win32/midltests/valid/midltests_union_align_19.txt137
-rw-r--r--testprogs/win32/midltests/valid/midltests_union_align_20.idl91
-rw-r--r--testprogs/win32/midltests/valid/midltests_union_align_20.txt137
-rw-r--r--testprogs/win32/midltests/valid/midltests_v1_enum_01.idl56
-rw-r--r--testprogs/win32/midltests/valid/midltests_v1_enum_01.txt37
-rwxr-xr-xtestprogs/win32/npecho/GNUmakefile24
-rwxr-xr-xtestprogs/win32/npecho/NMakefile26
-rwxr-xr-xtestprogs/win32/npecho/npecho_client.c50
-rwxr-xr-xtestprogs/win32/npecho/npecho_client2.c117
-rwxr-xr-xtestprogs/win32/npecho/npecho_server2.c76
-rwxr-xr-xtestprogs/win32/prepare_dcpromo/GNUmakefile21
-rwxr-xr-xtestprogs/win32/prepare_dcpromo/NMakefile16
-rwxr-xr-xtestprogs/win32/prepare_dcpromo/prepare_dcpromo.c1074
-rw-r--r--testprogs/win32/rpcecho/Makefile23
-rw-r--r--testprogs/win32/rpcecho/README46
-rw-r--r--testprogs/win32/rpcecho/client.c367
-rw-r--r--testprogs/win32/rpcecho/rpcecho.acf26
-rw-r--r--testprogs/win32/rpcecho/rpcecho.idl146
-rw-r--r--testprogs/win32/rpcecho/server.c208
-rw-r--r--testprogs/win32/rpcecho/utils.c32
-rw-r--r--testprogs/win32/spoolss/GNUmakefile23
-rw-r--r--testprogs/win32/spoolss/NMakefile43
-rw-r--r--testprogs/win32/spoolss/README.win3265
-rw-r--r--testprogs/win32/spoolss/error.c137
-rw-r--r--testprogs/win32/spoolss/error.h36
-rw-r--r--testprogs/win32/spoolss/printlib.c1386
-rw-r--r--testprogs/win32/spoolss/printlib_proto.h67
-rw-r--r--testprogs/win32/spoolss/string.h15
-rw-r--r--testprogs/win32/spoolss/testspoolss.c1842
-rw-r--r--testprogs/win32/spoolss/testspoolss.h51
-rw-r--r--testprogs/win32/spoolss/testspoolss.sln20
-rw-r--r--testprogs/win32/spoolss/testspoolss.vcproj224
-rw-r--r--testprogs/win32/spoolss/torture.c106
-rw-r--r--testprogs/win32/spoolss/torture.h92
-rw-r--r--testprogs/win32/spoolss/torture_proto.h32
-rw-r--r--testprogs/win32/testmailslot/GNUmakefile16
-rw-r--r--testprogs/win32/testmailslot/NMakefile13
-rw-r--r--testprogs/win32/testmailslot/testmailslot.c80
-rw-r--r--testprogs/win32/vs2010-metze.cmd24
-rwxr-xr-xtestprogs/win32/wmi/echoprocessor.vbs10
176 files changed, 26075 insertions, 0 deletions
diff --git a/testprogs/blackbox/b15464-testcase.sh b/testprogs/blackbox/b15464-testcase.sh
new file mode 100755
index 0000000..b0c8826
--- /dev/null
+++ b/testprogs/blackbox/b15464-testcase.sh
@@ -0,0 +1,21 @@
+#!/bin/sh
+# Blackbox wrapper for bug 15464
+# Copyright (C) 2023 Stefan Metzmacher
+
+if [ $# -lt 2 ]; then
+ cat <<EOF
+Usage: b15464-testcase.sh B15464_TESTCASE LIBNSS_WINBIND
+EOF
+ exit 1
+fi
+
+b15464_testcase=$1
+libnss_winbind=$2
+shift 2
+failed=0
+
+. $(dirname $0)/subunit.sh
+
+testit "run b15464-testcase" $VALGRIND $b15464_testcase $libnss_winbind || failed=$(expr $failed + 1)
+
+testok $0 $failed
diff --git a/testprogs/blackbox/bogus.sh b/testprogs/blackbox/bogus.sh
new file mode 100755
index 0000000..2fa1107
--- /dev/null
+++ b/testprogs/blackbox/bogus.sh
@@ -0,0 +1,28 @@
+#!/bin/sh
+
+if [ $# -lt 1 ]; then
+ cat <<EOF
+Usage: bogus.sh SERVER SHARE USER PASSWORD DC_USER DC_PASSWORD SMBCLIENT
+EOF
+ exit 1
+fi
+
+. $(dirname $0)/subunit.sh
+
+SERVER=$1
+SHARE=$2
+USER=$3
+PWD=$4
+DC_USER=$5
+DC_PWD=$6
+smbclient=$7
+shift 7
+
+TEST_USER=bogus_testuser
+TEST_PWD=bogus_pass3#@
+net="$BINDIR/net"
+testit_expect_failure "smbclient" $smbclient "//$SERVER/$SHARE" -W POUET -U$DC_USER%$DC_PWD -c "dir" || failed=$(expr $failed + 1)
+testit "net.user.add" $net rpc user add $TEST_USER $TEST_PWD -W $SERVER -U$SERVER\\$USER%$PWD -S $SERVER
+testit "smbclient" $smbclient "//$SERVER/$SHARE" -W POUET -U$TEST_USER%$TEST_PWD -c "dir" || failed=$(expr $failed + 1)
+testit "net.user.delete" $net rpc user delete $TEST_USER -W $SERVER -U$SERVER\\$USER%$PWD -S $SERVER
+exit $failed
diff --git a/testprogs/blackbox/common-links.sh b/testprogs/blackbox/common-links.sh
new file mode 100644
index 0000000..281b0d9
--- /dev/null
+++ b/testprogs/blackbox/common-links.sh
@@ -0,0 +1,211 @@
+release_dir=$SRCDIR_ABS/source4/selftest/provisions/$RELEASE
+
+ldbadd=$(system_or_builddir_binary ldbadd "${BINDIR}")
+ldbmodify=$(system_or_builddir_binary ldbmodify "${BINDIR}")
+ldbdel=$(system_or_builddir_binary ldbdel "${BINDIR}")
+ldbsearch=$(system_or_builddir_binary ldbsearch "${BINDIR}")
+ldbrename=$(system_or_builddir_binary ldbrename "${BINDIR}")
+samba_tdbrestore=$(system_or_builddir_binary tdbrestore "${BINDIR}")
+
+samba_undump="$SRCDIR_ABS/source4/selftest/provisions/undump.sh"
+
+undump()
+{
+ $samba_undump $release_dir $PREFIX_ABS/$RELEASE $samba_tdbrestore
+}
+
+add_dangling_link()
+{
+ ldif=$release_dir/add-dangling-forwardlink-user.ldif
+ TZ=UTC $ldbadd -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb $ldif
+ if [ "$?" != "0" ]; then
+ return 1
+ fi
+
+ ldif=$release_dir/add-initially-normal-link.ldif
+ TZ=UTC $ldbmodify -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb $ldif
+ if [ "$?" != "0" ]; then
+ return 1
+ fi
+
+ ldif=$release_dir/delete-only-backlink.ldif
+ TZ=UTC $ldbmodify -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb.d/DC%3DRELEASE-4-5-0-PRE1,DC%3DSAMBA,DC%3DCORP.ldb $ldif
+ if [ "$?" != "0" ]; then
+ return 1
+ fi
+}
+
+add_dangling_backlink()
+{
+ ldif=$release_dir/add-dangling-backlink-user.ldif
+ TZ=UTC $ldbadd -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb $ldif
+ if [ "$?" != "0" ]; then
+ return 1
+ fi
+
+ ldif=$release_dir/add-dangling-backlink.ldif
+ TZ=UTC $ldbmodify -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb.d/DC%3DRELEASE-4-5-0-PRE1,DC%3DSAMBA,DC%3DCORP.ldb $ldif
+ if [ "$?" != "0" ]; then
+ return 1
+ fi
+}
+
+add_deleted_dangling_backlink()
+{
+ ldif=$release_dir/add-deleted-backlink-user.ldif
+ TZ=UTC $ldbadd -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb $ldif
+ if [ "$?" != "0" ]; then
+ return 1
+ fi
+
+ ldif=$release_dir/add-deleted-backlink.ldif
+ TZ=UTC $ldbmodify -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb.d/DC%3DRELEASE-4-5-0-PRE1,DC%3DSAMBA,DC%3DCORP.ldb $ldif
+ if [ "$?" != "0" ]; then
+ return 1
+ fi
+}
+
+add_deleted_target_backlink()
+{
+ ldif=$release_dir/add-deleted-target-backlink-user.ldif
+ TZ=UTC $ldbadd -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb $ldif
+ if [ "$?" != "0" ]; then
+ return 1
+ fi
+
+ ldif=$release_dir/add-deleted-target-backlink.ldif
+ TZ=UTC $ldbmodify -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb.d/DC%3DRELEASE-4-5-0-PRE1,DC%3DSAMBA,DC%3DCORP.ldb $ldif
+ if [ "$?" != "0" ]; then
+ return 1
+ fi
+}
+
+revive_links_on_deleted_group()
+{
+ ldif=$release_dir/revive-links-on-deleted-group.ldif
+ TZ=UTC $ldbmodify -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb.d/DC%3DRELEASE-4-5-0-PRE1,DC%3DSAMBA,DC%3DCORP.ldb $ldif
+ if [ "$?" != "0" ]; then
+ return 1
+ fi
+}
+
+revive_backlink_on_deleted_group()
+{
+ ldif=$release_dir/revive-backlink-on-deleted-group.ldif
+ TZ=UTC $ldbmodify -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb.d/DC%3DRELEASE-4-5-0-PRE1,DC%3DSAMBA,DC%3DCORP.ldb $ldif
+ if [ "$?" != "0" ]; then
+ return 1
+ fi
+}
+
+add_deleted_target_link()
+{
+ ldif=$release_dir/add-dangling-deleted-link.ldif
+ TZ=UTC $ldbmodify -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb.d/DC%3DRELEASE-4-5-0-PRE1,DC%3DSAMBA,DC%3DCORP.ldb $ldif
+ if [ "$?" != "0" ]; then
+ return 1
+ fi
+}
+
+add_two_more_users()
+{
+ ldif=$release_dir/add-two-more-users.ldif
+ TZ=UTC $ldbadd -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb $ldif
+ if [ "$?" != "0" ]; then
+ return 1
+ fi
+}
+
+add_four_more_links()
+{
+ ldif=$release_dir/add-four-more-links.ldif
+ TZ=UTC $ldbmodify -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb $ldif
+ if [ "$?" != "0" ]; then
+ return 1
+ fi
+}
+
+remove_one_link()
+{
+ ldif=$release_dir/remove-one-more-link.ldif
+ TZ=UTC $ldbmodify -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb $ldif
+ if [ "$?" != "0" ]; then
+ return 1
+ fi
+}
+
+remove_one_user()
+{
+ ldif=$release_dir/remove-one-more-user.ldif
+ TZ=UTC $ldbmodify -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb $ldif
+ if [ "$?" != "0" ]; then
+ return 1
+ fi
+}
+
+move_one_user()
+{
+ TZ=UTC $ldbrename -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb 'cn=user1,cn=users,DC=release-4-5-0-pre1,DC=samba,DC=corp' 'cn=user1x,cn=users,DC=release-4-5-0-pre1,DC=samba,DC=corp'
+ if [ "$?" != "0" ]; then
+ return 1
+ fi
+}
+
+dangling_one_way_dn()
+{
+ ldif=$release_dir/dangling-one-way-dn.ldif
+ TZ=UTC $ldbmodify -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb $ldif
+ if [ "$?" != "0" ]; then
+ return 1
+ fi
+}
+
+deleted_one_way_dn()
+{
+ ldif=$release_dir/deleted-one-way-dn.ldif
+ TZ=UTC $ldbmodify -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb $ldif
+ if [ "$?" != "0" ]; then
+ return 1
+ fi
+}
+
+dangling_one_way_link()
+{
+ ldif=$release_dir/dangling-one-way-link.ldif
+ TZ=UTC $ldbmodify -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb.d/CN%3DCONFIGURATION,DC%3DRELEASE-4-5-0-PRE1,DC%3DSAMBA,DC%3DCORP.ldb $ldif
+ if [ "$?" != "0" ]; then
+ return 1
+ fi
+}
+
+add_dangling_multi_valued()
+{
+ # multi1 - All 4 backlinks
+ # multi2 - Missing all 4 backlinks
+ # multi3 - Missing 2 backlinks
+ # Administrator - Has 2 too many backlinks
+ # multi5 - Has 2 backlinks but no forward links
+ ldif=$release_dir/add-dangling-multilink-users.ldif
+ TZ=UTC $ldbadd -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb $ldif
+ if [ "$?" != "0" ]; then
+ return 1
+ fi
+
+ ldif=$release_dir/add-initially-normal-multilink.ldif
+ TZ=UTC $ldbmodify -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb $ldif
+ if [ "$?" != "0" ]; then
+ return 1
+ fi
+
+ ldif=$release_dir/delete-only-multi-backlink.ldif
+ TZ=UTC $ldbmodify -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb.d/DC%3DRELEASE-4-5-0-PRE1,DC%3DSAMBA,DC%3DCORP.ldb $ldif
+ if [ "$?" != "0" ]; then
+ return 1
+ fi
+
+ ldif=$release_dir/add-dangling-multi-backlink.ldif
+ TZ=UTC $ldbmodify -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb.d/DC%3DRELEASE-4-5-0-PRE1,DC%3DSAMBA,DC%3DCORP.ldb $ldif
+ if [ "$?" != "0" ]; then
+ return 1
+ fi
+}
diff --git a/testprogs/blackbox/common_test_fns.inc b/testprogs/blackbox/common_test_fns.inc
new file mode 100755
index 0000000..df8fee0
--- /dev/null
+++ b/testprogs/blackbox/common_test_fns.inc
@@ -0,0 +1,155 @@
+# Common tests
+# Pulled out of existing tests to prevent duplication.
+#
+test_smbclient()
+{
+ name="$1"
+ cmd="$2"
+ unc="$3"
+ shift
+ shift
+ shift
+ subunit_start_test "$name"
+ output=$($VALGRIND $smbclient $CONFIGURATION "$unc" -c "$cmd" "$@" 2>&1)
+ status=$?
+ if [ x$status = x0 ]; then
+ subunit_pass_test "$name"
+ else
+ printf '%s' "$output" | subunit_fail_test "$name"
+ fi
+ return $status
+}
+
+test_smbclient_expect_failure()
+{
+ name="$1"
+ cmd="$2"
+ unc="$3"
+ shift
+ shift
+ shift
+ subunit_start_test "$name"
+ output=$($VALGRIND $smbclient $CONFIGURATION "$unc" -c "$cmd" "$@" 2>&1)
+ status=$?
+ if [ x$status = x0 ]; then
+ printf '%s' "$output" | subunit_fail_test "$name"
+ return 1
+ else
+ subunit_pass_test "$name"
+ return 0
+ fi
+}
+
+test_rpcclient_grep()
+{
+ name="$1"
+ cmd="$2"
+ srv="$3"
+ grep="$4"
+ shift
+ shift
+ shift
+ shift
+ subunit_start_test "$name"
+ output=$($VALGRIND $rpcclient $CONFIGURATION "$srv" -c "$cmd" "$@" 2>&1)
+ status=$?
+ if [ x$status != x0 ]; then
+ printf '%s' "$output" | subunit_fail_test "$name"
+ return $status
+ fi
+ printf '%s' "$output" | grep -q "$grep"
+ gstatus=$?
+ if [ x$gstatus = x0 ]; then
+ subunit_pass_test "$name"
+ else
+ printf '%s' "$output" | subunit_fail_test "$name"
+ fi
+ return $gstatus
+}
+
+test_rpcclient_expect_failure_grep()
+{
+ name="$1"
+ cmd="$2"
+ srv="$3"
+ grep="$4"
+ shift
+ shift
+ shift
+ shift
+ subunit_start_test "$name"
+ output=$($VALGRIND $rpcclient $CONFIGURATION "$srv" -c "$cmd" "$@" 2>&1)
+ status=$?
+ if [ x$status = x0 ]; then
+ printf '%s' "$output" | subunit_fail_test "$name"
+ return 1
+ fi
+ printf '%s' "$output" | grep -q "$grep"
+ gstatus=$?
+ if [ x$gstatus = x0 ]; then
+ subunit_pass_test "$name"
+ else
+ printf '%s' "$output" | subunit_fail_test "$name"
+ fi
+ return $gstatus
+}
+
+kerberos_kinit()
+{
+ kinit_tool="${1}"
+ principal="${2}"
+ password="${3}"
+ shift 3
+ kbase=$(basename ${kinit_tool})
+ if [ "${kbase}" = "samba4kinit" ]; then
+ kpassfile=$(mktemp)
+ echo $password >${kpassfile}
+ $kinit_tool -c ${KRB5CCNAME} --password-file=${kpassfile} "$@" $principal
+ status=$?
+ rm -f ${kpassfile}
+ else
+ echo $password | $kinit_tool "$@" $principal
+ status=$?
+ fi
+ return $status
+}
+
+remove_directory()
+{
+ local xdir=${1}
+ shift
+
+ if [ "$xdir" = "/" ] || [ ! -d "$xdir" ] || [ -z "$(ls -A "$xdir")" ]; then
+ return
+ fi
+
+ rm -rf "$xdir"
+}
+
+# This function should be used to either use a system tool or one of our
+# build dir if available.
+#
+# Examples:
+#
+# system_or_builddir_binary ldbsearch ${BUILDDIR}
+# system_or_builddir_binary kinit ${BUILDDIR} samba4kinit
+#
+system_or_builddir_binary()
+{
+ _bin_name="${1}"
+ _build_dir="${2}"
+ _alt_bin_name="${3}"
+
+ _bin="$(command -v ${_bin_name})"
+ _bin_build_path="${_build_dir}/${_bin_name}"
+
+ if [ -n "${_alt_bin_name}" ]; then
+ _bin_build_path="${_build_dir}/${_alt_bin_name}"
+ fi
+
+ if [ -x "${_bin_build_path}" ]; then
+ _bin="${_bin_build_path}"
+ fi
+
+ echo "${_bin}"
+}
diff --git a/testprogs/blackbox/dbcheck-links.sh b/testprogs/blackbox/dbcheck-links.sh
new file mode 100755
index 0000000..63ad8db
--- /dev/null
+++ b/testprogs/blackbox/dbcheck-links.sh
@@ -0,0 +1,1003 @@
+#!/bin/sh
+
+if [ $# -lt 1 ]; then
+ cat <<EOF
+Usage: dbcheck-links.sh PREFIX RELEASE
+EOF
+ exit 1
+fi
+
+PREFIX_ABS="$1"
+RELEASE="$2"
+shift 2
+
+. $(dirname $0)/subunit.sh
+
+. $(dirname $0)/common_test_fns.inc
+. $(dirname $0)/common-links.sh
+
+failed=0
+
+if [ ! -x $samba_undump ] || [ ! -d $release_dir ]; then
+ subunit_start_test $RELEASE
+ subunit_skip_test $RELEASE <<EOF
+no test provision
+EOF
+
+ subunit_start_test "tombstones_expunge"
+ subunit_skip_test "tombstones_expunge" <<EOF
+no test provision
+EOF
+
+ exit 0
+fi
+
+dbcheck()
+{
+ tmpfile=$PREFIX_ABS/$RELEASE/expected-dbcheck-link-output${1}.txt.tmp
+ tmpldif1=$PREFIX_ABS/$RELEASE/expected-dbcheck-output${1}2.txt.tmp1
+
+ TZ=UTC $ldbsearch -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb --scope=base -b '' | grep highestCommittedUSN >$tmpldif1
+
+ $PYTHON $BINDIR/samba-tool dbcheck -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb $3 --fix --yes >$tmpfile
+ if [ "$?" != "$2" ]; then
+ return 1
+ fi
+ sort $tmpfile | grep -v "^INFO:" >$tmpfile.sorted
+ sort $release_dir/expected-dbcheck-link-output${1}.txt >$tmpfile.expected
+ diff -u $tmpfile.sorted $tmpfile.expected
+ if [ "$?" != "0" ]; then
+ return 1
+ fi
+
+ tmpldif2=$PREFIX_ABS/$RELEASE/expected-dbcheck-output${1}2.txt.tmp2
+ TZ=UTC $ldbsearch -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb --scope=base -b '' | grep highestCommittedUSN >$tmpldif2
+
+ diff -u $tmpldif1 $tmpldif2
+ if [ "$?" != "0" ]; then
+ return 1
+ fi
+}
+
+dbcheck_acl_reset()
+{
+ $PYTHON $BINDIR/samba-tool dbcheck -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb --cross-ncs --fix --yes --attrs=nTSecurityDescriptor
+}
+
+dbcheck_acl_clean()
+{
+ $PYTHON $BINDIR/samba-tool dbcheck -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb --cross-ncs --attrs=nTSecurityDescriptor
+}
+
+dbcheck_dangling()
+{
+ dbcheck "" "1" "--selftest-check-expired-tombstones"
+ return $?
+}
+
+dbcheck_one_way()
+{
+ dbcheck "_one_way" "0" "CN=Configuration,DC=release-4-5-0-pre1,DC=samba,DC=corp --selftest-check-expired-tombstones"
+ return $?
+}
+
+dbcheck_clean()
+{
+ tmpldif1=$PREFIX_ABS/$RELEASE/expected-dbcheck-output2.txt.tmp1
+
+ TZ=UTC $ldbsearch -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb --scope=base -b '' | grep highestCommittedUSN >$tmpldif1
+
+ $PYTHON $BINDIR/samba-tool dbcheck -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb
+ if [ "$?" != "0" ]; then
+ return 1
+ fi
+ tmpldif2=$PREFIX_ABS/$RELEASE/expected-dbcheck-output2.txt.tmp2
+ TZ=UTC $ldbsearch -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb --scope=base -b '' | grep highestCommittedUSN >$tmpldif2
+
+ diff -u $tmpldif1 $tmpldif2
+ if [ "$?" != "0" ]; then
+ return 1
+ fi
+}
+
+check_expected_after_links()
+{
+ tmpldif=$PREFIX_ABS/$RELEASE/expected-links-after-link-dbcheck.ldif.tmp
+ TZ=UTC $ldbsearch -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb '(|(cn=swimmers)(cn=leaders)(cn=helpers))' --scope=sub -b DC=release-4-5-0-pre1,DC=samba,DC=corp --show-deleted --sorted member >$tmpldif
+ diff -u $tmpldif $release_dir/expected-links-after-link-dbcheck.ldif
+ if [ "$?" != "0" ]; then
+ return 1
+ fi
+}
+
+check_expected_after_deleted_links()
+{
+ tmpldif=$PREFIX_ABS/$RELEASE/expected-deleted-links-after-link-dbcheck.ldif.tmp
+ TZ=UTC $ldbsearch -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb '(|(cn=swimmers)(cn=leaders)(cn=helpers))' --scope=sub -b DC=release-4-5-0-pre1,DC=samba,DC=corp --show-deleted --reveal --sorted member >$tmpldif
+ diff -u $tmpldif $release_dir/expected-deleted-links-after-link-dbcheck.ldif
+ if [ "$?" != "0" ]; then
+ return 1
+ fi
+}
+
+check_expected_after_objects()
+{
+ tmpldif=$PREFIX_ABS/$RELEASE/expected-objects-after-link-dbcheck.ldif.tmp
+ TZ=UTC $ldbsearch -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb '(|(samaccountname=fred)(samaccountname=ddg)(samaccountname=usg)(samaccountname=user1)(samaccountname=user1x)(samaccountname=user2))' --scope=sub -b DC=release-4-5-0-pre1,DC=samba,DC=corp --show-deleted --reveal --sorted samAccountName | grep sAMAccountName >$tmpldif
+ diff -u $tmpldif $release_dir/expected-objects-after-link-dbcheck.ldif
+ if [ "$?" != "0" ]; then
+ return 1
+ fi
+}
+
+duplicate_member()
+{
+ # We use an existing group so we have a stable GUID in the
+ # dbcheck output
+ LDIF1=$(TZ=UTC $ldbsearch -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb -b 'CN=Enterprise Admins,CN=users,DC=release-4-5-0-pre1,DC=samba,DC=corp' --scope=base --reveal --extended-dn member)
+ DN=$(echo "${LDIF1}" | grep '^dn: ')
+ MSG=$(echo "${LDIF1}" | grep -v '^dn: ' | grep -v '^#' | grep -v '^$')
+ ldif=$PREFIX_ABS/${RELEASE}/duplicate-member-multi.ldif
+ {
+ echo "${DN}"
+ echo "changetype: modify"
+ echo "replace: member"
+ echo "${MSG}"
+ echo "${MSG}" | sed -e 's!RMD_LOCAL_USN=[1-9][0-9]*!RMD_LOCAL_USN=0!'
+ } >$ldif
+
+ TZ=UTC $ldbmodify -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb.d/DC%3DRELEASE-4-5-0-PRE1,DC%3DSAMBA,DC%3DCORP.ldb $ldif
+ if [ "$?" != "0" ]; then
+ return 1
+ fi
+}
+
+dbcheck_duplicate_member()
+{
+ dbcheck "_duplicate_member" "1" "--selftest-check-expired-tombstones"
+ return $?
+}
+
+check_expected_after_duplicate_links()
+{
+ tmpldif=$PREFIX_ABS/$RELEASE/expected-duplicates-after-link-dbcheck.ldif.tmp
+ TZ=UTC $ldbsearch -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb '(|(cn=administrator)(cn=enterprise admins))' --scope=sub -b DC=release-4-5-0-pre1,DC=samba,DC=corp --show-deleted --sorted memberOf member >$tmpldif
+ diff -u $tmpldif $release_dir/expected-duplicates-after-link-dbcheck.ldif
+ if [ "$?" != "0" ]; then
+ return 1
+ fi
+}
+
+missing_link_sid_corruption()
+{
+ # Step1: add user "missingsidu1"
+ #
+ ldif=$PREFIX_ABS/${RELEASE}/missing_link_sid_corruption1.ldif
+ cat >$ldif <<EOF
+dn: CN=missingsidu1,CN=users,DC=release-4-5-0-pre1,DC=samba,DC=corp
+changetype: add
+objectclass: user
+samaccountname: missingsidu1
+objectGUID: 0da8f25e-d110-11e8-80b7-3c970ec68461
+objectSid: S-1-5-21-4177067393-1453636373-93818738-771
+EOF
+
+ out=$(TZ=UTC $ldbmodify -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb --relax $ldif)
+ if [ "$?" != "0" ]; then
+ echo "ldbmodify returned:\n$out"
+ return 1
+ fi
+
+ # Step2: add user "missingsidu2"
+ #
+ ldif=$PREFIX_ABS/${RELEASE}/missing_link_sid_corruption2.ldif
+ cat >$ldif <<EOF
+dn: CN=missingsidu2,CN=users,DC=release-4-5-0-pre1,DC=samba,DC=corp
+changetype: add
+objectclass: user
+samaccountname: missingsidu2
+objectGUID: 66eb8f52-d110-11e8-ab9b-3c970ec68461
+objectSid: S-1-5-21-4177067393-1453636373-93818738-772
+EOF
+
+ out=$(TZ=UTC $ldbmodify -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb --relax $ldif)
+ if [ "$?" != "0" ]; then
+ echo "ldbmodify returned:\n$out"
+ return 1
+ fi
+
+ # Step3: add group "missingsidg3" and add users as members
+ #
+ ldif=$PREFIX_ABS/${RELEASE}/missing_link_sid_corruption3.ldif
+ cat >$ldif <<EOF
+dn: CN=missingsidg3,CN=users,DC=release-4-5-0-pre1,DC=samba,DC=corp
+changetype: add
+objectclass: group
+samaccountname: missingsidg3
+objectGUID: fd992424-d114-11e8-bb36-3c970ec68461
+objectSid: S-1-5-21-4177067393-1453636373-93818738-773
+member: CN=missingsidu1,CN=users,DC=release-4-5-0-pre1,DC=samba,DC=corp
+member: CN=missingsidu2,CN=users,DC=release-4-5-0-pre1,DC=samba,DC=corp
+EOF
+
+ out=$(TZ=UTC $ldbmodify -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb --relax $ldif)
+ if [ "$?" != "0" ]; then
+ echo "ldbmodify returned:\n$out"
+ return 1
+ fi
+
+ # Step4: remove one user again, so that we have one deleted link
+ #
+ ldif=$PREFIX_ABS/${RELEASE}/missing_link_sid_corruption4.ldif
+ cat >$ldif <<EOF
+dn: CN=missingsidg3,CN=users,DC=release-4-5-0-pre1,DC=samba,DC=corp
+changetype: modify
+delete: member
+member: CN=missingsidu1,CN=users,DC=release-4-5-0-pre1,DC=samba,DC=corp
+EOF
+
+ out=$(TZ=UTC $ldbmodify -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb --relax $ldif)
+ if [ "$?" != "0" ]; then
+ echo "ldbmodify returned:\n$out"
+ return 1
+ fi
+
+ #
+ # Step5: remove the SIDS from the links
+ #
+ LDIF1=$(TZ=UTC $ldbsearch -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb -b 'CN=missingsidg3,CN=users,DC=release-4-5-0-pre1,DC=samba,DC=corp' --scope=base --reveal --extended-dn --show-binary member)
+ DN=$(echo "${LDIF1}" | grep '^dn: ')
+ MSG=$(echo "${LDIF1}" | grep -v '^dn: ' | grep -v '^#' | grep -v '^$')
+ ldif=$PREFIX_ABS/${RELEASE}/missing_link_sid_corruption5.ldif
+ {
+ echo "${DN}"
+ echo "changetype: modify"
+ echo "replace: member"
+ #echo "${MSG}"
+ echo "${MSG}" | sed \
+ -e 's!<SID=S-1-5-21-4177067393-1453636373-93818738-771>;!!g' \
+ -e 's!<SID=S-1-5-21-4177067393-1453636373-93818738-772>;!!g' \
+ -e 's!RMD_ADDTIME=[1-9][0-9]*!RMD_ADDTIME=123456789000000000!g' \
+ -e 's!RMD_CHANGETIME=[1-9][0-9]*!RMD_CHANGETIME=123456789000000000!g' |
+ cat
+ } >$ldif
+
+ out=$(TZ=UTC $ldbmodify -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb.d/DC%3DRELEASE-4-5-0-PRE1,DC%3DSAMBA,DC%3DCORP.ldb $ldif)
+ if [ "$?" != "0" ]; then
+ echo "ldbmodify returned:\n$out"
+ return 1
+ fi
+
+ return 0
+}
+
+dbcheck_missing_link_sid_corruption()
+{
+ dbcheck "-missing-link-sid-corruption" "1" "--selftest-check-expired-tombstones"
+ return $?
+}
+
+add_lost_deleted_user1()
+{
+ ldif=$PREFIX_ABS/${RELEASE}/add_lost_deleted_user1.ldif
+ cat >$ldif <<EOF
+dn: CN=fred\0ADEL:2301a64c-1234-5678-851e-12d4a711cfb4,OU=removed,DC=release-4-5-0-pre1,DC=samba,DC=corp
+objectClass: top
+objectClass: person
+objectClass: organizationalPerson
+objectClass: user
+instanceType: 4
+whenCreated: 20160629043638.0Z
+uSNCreated: 3740
+objectGUID: 2301a64c-1234-5678-851e-12d4a711cfb4
+objectSid: S-1-5-21-4177067393-1453636373-93818738-1011
+sAMAccountName: fred
+userAccountControl: 512
+isDeleted: TRUE
+lastKnownParent: <GUID=f28216e9-1234-5678-8b2d-6bb229563b62>;OU=removed,DC=rel
+ ease-4-5-0-pre1,DC=samba,DC=corp
+isRecycled: TRUE
+cn:: ZnJlZApERUw6MjMwMWE2NGMtMTIzNC01Njc4LTg1MWUtMTJkNGE3MTFjZmI0
+name:: ZnJlZApERUw6MjMwMWE2NGMtMTIzNC01Njc4LTg1MWUtMTJkNGE3MTFjZmI0
+replPropertyMetaData:: AQAAAAAAAAAXAAAAAAAAAAAAAAABAAAAVuGDDQMAAACjlkROuH+XT4o
+ z0jjbi14tnA4AAAAAAACcDgAAAAAAAAMAAAACAAAAV+GDDQMAAACjlkROuH+XT4oz0jjbi14tog4A
+ AAAAAACiDgAAAAAAAAEAAgABAAAAVuGDDQMAAACjlkROuH+XT4oz0jjbi14tnA4AAAAAAACcDgAAA
+ AAAAAIAAgABAAAAVuGDDQMAAACjlkROuH+XT4oz0jjbi14tnA4AAAAAAACcDgAAAAAAADAAAgABAA
+ AAV+GDDQMAAACjlkROuH+XT4oz0jjbi14tog4AAAAAAACiDgAAAAAAABkBAgABAAAAVuGDDQMAAAC
+ jlkROuH+XT4oz0jjbi14tnA4AAAAAAACcDgAAAAAAAAEACQACAAAAV+GDDQMAAACjlkROuH+XT4oz
+ 0jjbi14tog4AAAAAAACiDgAAAAAAAAgACQADAAAAVuGDDQMAAACjlkROuH+XT4oz0jjbi14tng4AA
+ AAAAACeDgAAAAAAABAACQACAAAAV+GDDQMAAACjlkROuH+XT4oz0jjbi14tog4AAAAAAACiDgAAAA
+ AAABkACQACAAAAV+GDDQMAAACjlkROuH+XT4oz0jjbi14tog4AAAAAAACiDgAAAAAAAFoACQABAAA
+ AVuGDDQMAAACjlkROuH+XT4oz0jjbi14tnQ4AAAAAAACdDgAAAAAAAF4ACQABAAAAVuGDDQMAAACj
+ lkROuH+XT4oz0jjbi14tnQ4AAAAAAACdDgAAAAAAAGAACQADAAAAV+GDDQMAAACjlkROuH+XT4oz0
+ jjbi14tog4AAAAAAACiDgAAAAAAAGIACQACAAAAV+GDDQMAAACjlkROuH+XT4oz0jjbi14tog4AAA
+ AAAACiDgAAAAAAAH0ACQABAAAAVuGDDQMAAACjlkROuH+XT4oz0jjbi14tnQ4AAAAAAACdDgAAAAA
+ AAJIACQABAAAAVuGDDQMAAACjlkROuH+XT4oz0jjbi14tnA4AAAAAAACcDgAAAAAAAJ8ACQACAAAA
+ V+GDDQMAAACjlkROuH+XT4oz0jjbi14tog4AAAAAAACiDgAAAAAAAN0ACQABAAAAVuGDDQMAAACjl
+ kROuH+XT4oz0jjbi14tnA4AAAAAAACcDgAAAAAAAC4BCQACAAAAV+GDDQMAAACjlkROuH+XT4oz0j
+ jbi14tog4AAAAAAACiDgAAAAAAAJACCQACAAAAV+GDDQMAAACjlkROuH+XT4oz0jjbi14tog4AAAA
+ AAACiDgAAAAAAAA0DCQABAAAAV+GDDQMAAACjlkROuH+XT4oz0jjbi14tog4AAAAAAACiDgAAAAAA
+ AA4DCQACAAAAV+GDDQMAAACjlkROuH+XT4oz0jjbi14tog4AAAAAAACiDgAAAAAAAAoICQABAAAAV
+ +GDDQMAAACjlkROuH+XT4oz0jjbi14tog4AAAAAAACiDgAAAAAAAA==
+whenChanged: 20160629043639.0Z
+uSNChanged: 3746
+nTSecurityDescriptor:: AQAXjBQAAAAwAAAATAAAAMQAAAABBQAAAAAABRUAAACB/fj4FbukVnK
+ PlwUAAgAAAQUAAAAAAAUVAAAAgf34+BW7pFZyj5cFAAIAAAQAeAACAAAAB1o4ACAAAAADAAAAvjsO
+ 8/Cf0RG2AwAA+ANnwaV6lr/mDdARooUAqgAwSeIBAQAAAAAAAQAAAAAHWjgAIAAAAAMAAAC/Ow7z8
+ J/REbYDAAD4A2fBpXqWv+YN0BGihQCqADBJ4gEBAAAAAAABAAAAAAQA1AcsAAAAAAAkAP8BDwABBQ
+ AAAAAABRUAAACB/fj4FbukVnKPlwUAAgAAAAAUAP8BDwABAQAAAAAABRIAAAAAABgA/wEPAAECAAA
+ AAAAFIAAAACQCAAAAABQAlAACAAEBAAAAAAAFCgAAAAUAKAAAAQAAAQAAAFMacqsvHtARmBkAqgBA
+ UpsBAQAAAAAABQoAAAAFACgAAAEAAAEAAABUGnKrLx7QEZgZAKoAQFKbAQEAAAAAAAUKAAAABQAoA
+ AABAAABAAAAVhpyqy8e0BGYGQCqAEBSmwEBAAAAAAAFCgAAAAUAKAAwAAAAAQAAAIa4tXdKlNERrr
+ 0AAPgDZ8EBAQAAAAAABQoAAAAFACgAMAAAAAEAAACylVfkVZTREa69AAD4A2fBAQEAAAAAAAUKAAA
+ ABQAoADAAAAABAAAAs5VX5FWU0RGuvQAA+ANnwQEBAAAAAAAFCgAAAAUAOAAQAAAAAQAAAPiIcAPh
+ CtIRtCIAoMlo+TkBBQAAAAAABRUAAACB/fj4FbukVnKPlwUpAgAABQA4ABAAAAABAAAAAEIWTMAg0
+ BGnaACqAG4FKQEFAAAAAAAFFQAAAIH9+PgVu6RWco+XBSkCAAAFADgAEAAAAAEAAABAwgq8qXnQEZ
+ AgAMBPwtTPAQUAAAAAAAUVAAAAgf34+BW7pFZyj5cFKQIAAAAAFAAAAAIAAQEAAAAAAAULAAAABQA
+ oABAAAAABAAAAQi+6WaJ50BGQIADAT8LTzwEBAAAAAAAFCwAAAAUAKAAQAAAAAQAAAIa4tXdKlNER
+ rr0AAPgDZ8EBAQAAAAAABQsAAAAFACgAEAAAAAEAAACzlVfkVZTREa69AAD4A2fBAQEAAAAAAAULA
+ AAABQAoABAAAAABAAAAVAGN5Pi80RGHAgDAT7lgUAEBAAAAAAAFCwAAAAUAKAAAAQAAAQAAAFMacq
+ svHtARmBkAqgBAUpsBAQAAAAAAAQAAAAAFADgAEAAAAAEAAAAQICBfpXnQEZAgAMBPwtTPAQUAAAA
+ AAAUVAAAAgf34+BW7pFZyj5cFKQIAAAUAOAAwAAAAAQAAAH96lr/mDdARooUAqgAwSeIBBQAAAAAA
+ BRUAAACB/fj4FbukVnKPlwUFAgAABQAsABAAAAABAAAAHbGpRq5gWkC36P+KWNRW0gECAAAAAAAFI
+ AAAADACAAAFACwAMAAAAAEAAAAcmrZtIpTREa69AAD4A2fBAQIAAAAAAAUgAAAAMQIAAAUALAAwAA
+ AAAQAAAGK8BVjJvShEpeKFag9MGF4BAgAAAAAABSAAAAAxAgAABRo8ABAAAAADAAAAAEIWTMAg0BG
+ naACqAG4FKRTMKEg3FLxFmwetbwFeXygBAgAAAAAABSAAAAAqAgAABRI8ABAAAAADAAAAAEIWTMAg
+ 0BGnaACqAG4FKbp6lr/mDdARooUAqgAwSeIBAgAAAAAABSAAAAAqAgAABRo8ABAAAAADAAAAECAgX
+ 6V50BGQIADAT8LUzxTMKEg3FLxFmwetbwFeXygBAgAAAAAABSAAAAAqAgAABRI8ABAAAAADAAAAEC
+ AgX6V50BGQIADAT8LUz7p6lr/mDdARooUAqgAwSeIBAgAAAAAABSAAAAAqAgAABRo8ABAAAAADAAA
+ AQMIKvKl50BGQIADAT8LUzxTMKEg3FLxFmwetbwFeXygBAgAAAAAABSAAAAAqAgAABRI8ABAAAAAD
+ AAAAQMIKvKl50BGQIADAT8LUz7p6lr/mDdARooUAqgAwSeIBAgAAAAAABSAAAAAqAgAABRo8ABAAA
+ AADAAAAQi+6WaJ50BGQIADAT8LTzxTMKEg3FLxFmwetbwFeXygBAgAAAAAABSAAAAAqAgAABRI8AB
+ AAAAADAAAAQi+6WaJ50BGQIADAT8LTz7p6lr/mDdARooUAqgAwSeIBAgAAAAAABSAAAAAqAgAABRo
+ 8ABAAAAADAAAA+IhwA+EK0hG0IgCgyWj5ORTMKEg3FLxFmwetbwFeXygBAgAAAAAABSAAAAAqAgAA
+ BRI8ABAAAAADAAAA+IhwA+EK0hG0IgCgyWj5Obp6lr/mDdARooUAqgAwSeIBAgAAAAAABSAAAAAqA
+ gAABRo4ABAAAAADAAAAbZ7Gt8cs0hGFTgCgyYP2CIZ6lr/mDdARooUAqgAwSeIBAQAAAAAABQkAAA
+ AFGjgAEAAAAAMAAABtnsa3xyzSEYVOAKDJg/YInHqWv+YN0BGihQCqADBJ4gEBAAAAAAAFCQAAAAU
+ SOAAQAAAAAwAAAG2exrfHLNIRhU4AoMmD9gi6epa/5g3QEaKFAKoAMEniAQEAAAAAAAUJAAAABRos
+ AJQAAgACAAAAFMwoSDcUvEWbB61vAV5fKAECAAAAAAAFIAAAACoCAAAFGiwAlAACAAIAAACcepa/5
+ g3QEaKFAKoAMEniAQIAAAAAAAUgAAAAKgIAAAUSLACUAAIAAgAAALp6lr/mDdARooUAqgAwSeIBAg
+ AAAAAABSAAAAAqAgAABRIoADABAAABAAAA3kfmkW/ZcEuVV9Y/9PPM2AEBAAAAAAAFCgAAAAASJAD
+ /AQ8AAQUAAAAAAAUVAAAAgf34+BW7pFZyj5cFBwIAAAASGAAEAAAAAQIAAAAAAAUgAAAAKgIAAAAS
+ GAC9AQ8AAQIAAAAAAAUgAAAAIAIAAA==
+EOF
+
+ out=$(TZ=UTC $ldbadd -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb.d/DC%3DRELEASE-4-5-0-PRE1,DC%3DSAMBA,DC%3DCORP.ldb $ldif)
+ if [ "$?" != "0" ]; then
+ echo "ldbadd returned:\n$out"
+ return 1
+ fi
+
+ return 0
+}
+
+dbcheck_lost_deleted_user1()
+{
+ dbcheck "-lost-deleted-user1" "1" "--selftest-check-expired-tombstones"
+ return $?
+}
+
+remove_lost_deleted_user1()
+{
+ out=$(TZ=UTC $ldbdel -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb "<GUID=2301a64c-1234-5678-851e-12d4a711cfb4>" --show-recycled --relax)
+ if [ "$?" != "0" ]; then
+ echo "ldbdel returned:\n$out"
+ return 1
+ fi
+
+ return 0
+}
+
+add_lost_deleted_user2()
+{
+ ldif=$PREFIX_ABS/${RELEASE}/add_lost_deleted_user2.ldif
+ cat >$ldif <<EOF
+dn: CN=fred\0ADEL:2301a64c-8765-4321-851e-12d4a711cfb4,CN=LostAndFound,DC=release-4-5-0-pre1,DC=samba,DC=corp
+objectClass: top
+objectClass: person
+objectClass: organizationalPerson
+objectClass: user
+instanceType: 4
+whenCreated: 20160629043638.0Z
+uSNCreated: 3740
+objectGUID: 2301a64c-8765-4321-851e-12d4a711cfb4
+objectSid: S-1-5-21-4177067393-1453636373-93818738-1001
+sAMAccountName: fred
+userAccountControl: 512
+isDeleted: TRUE
+lastKnownParent: OU=removed,DC=release-4-5-0-pre1,DC=samba,DC=corp
+isRecycled: TRUE
+cn:: ZnJlZApERUw6MjMwMWE2NGMtODc2NS00MzIxLTg1MWUtMTJkNGE3MTFjZmI0
+name:: ZnJlZApERUw6MjMwMWE2NGMtODc2NS00MzIxLTg1MWUtMTJkNGE3MTFjZmI0
+replPropertyMetaData:: AQAAAAAAAAAXAAAAAAAAAAAAAAABAAAAVuGDDQMAAACjlkROuH+XT4o
+ z0jjbi14tnA4AAAAAAACcDgAAAAAAAAMAAAACAAAAV+GDDQMAAACjlkROuH+XT4oz0jjbi14tog4A
+ AAAAAACiDgAAAAAAAAEAAgABAAAAVuGDDQMAAACjlkROuH+XT4oz0jjbi14tnA4AAAAAAACcDgAAA
+ AAAAAIAAgABAAAAVuGDDQMAAACjlkROuH+XT4oz0jjbi14tnA4AAAAAAACcDgAAAAAAADAAAgABAA
+ AAV+GDDQMAAACjlkROuH+XT4oz0jjbi14tog4AAAAAAACiDgAAAAAAABkBAgABAAAAVuGDDQMAAAC
+ jlkROuH+XT4oz0jjbi14tnA4AAAAAAACcDgAAAAAAAAEACQAEAAAAePOWEgMAAACjlkROuH+XT4oz
+ 0jjbi14tvA4AAAAAAAC8DgAAAAAAAAgACQADAAAAVuGDDQMAAACjlkROuH+XT4oz0jjbi14tng4AA
+ AAAAACeDgAAAAAAABAACQACAAAAV+GDDQMAAACjlkROuH+XT4oz0jjbi14tog4AAAAAAACiDgAAAA
+ AAABkACQACAAAAV+GDDQMAAACjlkROuH+XT4oz0jjbi14tog4AAAAAAACiDgAAAAAAAFoACQABAAA
+ AVuGDDQMAAACjlkROuH+XT4oz0jjbi14tnQ4AAAAAAACdDgAAAAAAAF4ACQABAAAAVuGDDQMAAACj
+ lkROuH+XT4oz0jjbi14tnQ4AAAAAAACdDgAAAAAAAGAACQADAAAAV+GDDQMAAACjlkROuH+XT4oz0
+ jjbi14tog4AAAAAAACiDgAAAAAAAGIACQACAAAAV+GDDQMAAACjlkROuH+XT4oz0jjbi14tog4AAA
+ AAAACiDgAAAAAAAH0ACQABAAAAVuGDDQMAAACjlkROuH+XT4oz0jjbi14tnQ4AAAAAAACdDgAAAAA
+ AAJIACQABAAAAVuGDDQMAAACjlkROuH+XT4oz0jjbi14tnA4AAAAAAACcDgAAAAAAAJ8ACQACAAAA
+ V+GDDQMAAACjlkROuH+XT4oz0jjbi14tog4AAAAAAACiDgAAAAAAAN0ACQABAAAAVuGDDQMAAACjl
+ kROuH+XT4oz0jjbi14tnA4AAAAAAACcDgAAAAAAAC4BCQACAAAAV+GDDQMAAACjlkROuH+XT4oz0j
+ jbi14tog4AAAAAAACiDgAAAAAAAJACCQACAAAAV+GDDQMAAACjlkROuH+XT4oz0jjbi14tog4AAAA
+ AAACiDgAAAAAAAA0DCQADAAAAePOWEgMAAACjlkROuH+XT4oz0jjbi14tvQ4AAAAAAAC9DgAAAAAA
+ AA4DCQACAAAAV+GDDQMAAACjlkROuH+XT4oz0jjbi14tog4AAAAAAACiDgAAAAAAAAoICQABAAAAV
+ +GDDQMAAACjlkROuH+XT4oz0jjbi14tog4AAAAAAACiDgAAAAAAAA==
+whenChanged: 20160629043639.0Z
+uSNChanged: 3746
+nTSecurityDescriptor:: AQAXjBQAAAAwAAAATAAAAMQAAAABBQAAAAAABRUAAACB/fj4FbukVnK
+ PlwUAAgAAAQUAAAAAAAUVAAAAgf34+BW7pFZyj5cFAAIAAAQAeAACAAAAB1o4ACAAAAADAAAAvjsO
+ 8/Cf0RG2AwAA+ANnwaV6lr/mDdARooUAqgAwSeIBAQAAAAAAAQAAAAAHWjgAIAAAAAMAAAC/Ow7z8
+ J/REbYDAAD4A2fBpXqWv+YN0BGihQCqADBJ4gEBAAAAAAABAAAAAAQA1AcsAAAAAAAkAP8BDwABBQ
+ AAAAAABRUAAACB/fj4FbukVnKPlwUAAgAAAAAUAP8BDwABAQAAAAAABRIAAAAAABgA/wEPAAECAAA
+ AAAAFIAAAACQCAAAAABQAlAACAAEBAAAAAAAFCgAAAAUAKAAAAQAAAQAAAFMacqsvHtARmBkAqgBA
+ UpsBAQAAAAAABQoAAAAFACgAAAEAAAEAAABUGnKrLx7QEZgZAKoAQFKbAQEAAAAAAAUKAAAABQAoA
+ AABAAABAAAAVhpyqy8e0BGYGQCqAEBSmwEBAAAAAAAFCgAAAAUAKAAwAAAAAQAAAIa4tXdKlNERrr
+ 0AAPgDZ8EBAQAAAAAABQoAAAAFACgAMAAAAAEAAACylVfkVZTREa69AAD4A2fBAQEAAAAAAAUKAAA
+ ABQAoADAAAAABAAAAs5VX5FWU0RGuvQAA+ANnwQEBAAAAAAAFCgAAAAUAOAAQAAAAAQAAAPiIcAPh
+ CtIRtCIAoMlo+TkBBQAAAAAABRUAAACB/fj4FbukVnKPlwUpAgAABQA4ABAAAAABAAAAAEIWTMAg0
+ BGnaACqAG4FKQEFAAAAAAAFFQAAAIH9+PgVu6RWco+XBSkCAAAFADgAEAAAAAEAAABAwgq8qXnQEZ
+ AgAMBPwtTPAQUAAAAAAAUVAAAAgf34+BW7pFZyj5cFKQIAAAAAFAAAAAIAAQEAAAAAAAULAAAABQA
+ oABAAAAABAAAAQi+6WaJ50BGQIADAT8LTzwEBAAAAAAAFCwAAAAUAKAAQAAAAAQAAAIa4tXdKlNER
+ rr0AAPgDZ8EBAQAAAAAABQsAAAAFACgAEAAAAAEAAACzlVfkVZTREa69AAD4A2fBAQEAAAAAAAULA
+ AAABQAoABAAAAABAAAAVAGN5Pi80RGHAgDAT7lgUAEBAAAAAAAFCwAAAAUAKAAAAQAAAQAAAFMacq
+ svHtARmBkAqgBAUpsBAQAAAAAAAQAAAAAFADgAEAAAAAEAAAAQICBfpXnQEZAgAMBPwtTPAQUAAAA
+ AAAUVAAAAgf34+BW7pFZyj5cFKQIAAAUAOAAwAAAAAQAAAH96lr/mDdARooUAqgAwSeIBBQAAAAAA
+ BRUAAACB/fj4FbukVnKPlwUFAgAABQAsABAAAAABAAAAHbGpRq5gWkC36P+KWNRW0gECAAAAAAAFI
+ AAAADACAAAFACwAMAAAAAEAAAAcmrZtIpTREa69AAD4A2fBAQIAAAAAAAUgAAAAMQIAAAUALAAwAA
+ AAAQAAAGK8BVjJvShEpeKFag9MGF4BAgAAAAAABSAAAAAxAgAABRo8ABAAAAADAAAAAEIWTMAg0BG
+ naACqAG4FKRTMKEg3FLxFmwetbwFeXygBAgAAAAAABSAAAAAqAgAABRI8ABAAAAADAAAAAEIWTMAg
+ 0BGnaACqAG4FKbp6lr/mDdARooUAqgAwSeIBAgAAAAAABSAAAAAqAgAABRo8ABAAAAADAAAAECAgX
+ 6V50BGQIADAT8LUzxTMKEg3FLxFmwetbwFeXygBAgAAAAAABSAAAAAqAgAABRI8ABAAAAADAAAAEC
+ AgX6V50BGQIADAT8LUz7p6lr/mDdARooUAqgAwSeIBAgAAAAAABSAAAAAqAgAABRo8ABAAAAADAAA
+ AQMIKvKl50BGQIADAT8LUzxTMKEg3FLxFmwetbwFeXygBAgAAAAAABSAAAAAqAgAABRI8ABAAAAAD
+ AAAAQMIKvKl50BGQIADAT8LUz7p6lr/mDdARooUAqgAwSeIBAgAAAAAABSAAAAAqAgAABRo8ABAAA
+ AADAAAAQi+6WaJ50BGQIADAT8LTzxTMKEg3FLxFmwetbwFeXygBAgAAAAAABSAAAAAqAgAABRI8AB
+ AAAAADAAAAQi+6WaJ50BGQIADAT8LTz7p6lr/mDdARooUAqgAwSeIBAgAAAAAABSAAAAAqAgAABRo
+ 8ABAAAAADAAAA+IhwA+EK0hG0IgCgyWj5ORTMKEg3FLxFmwetbwFeXygBAgAAAAAABSAAAAAqAgAA
+ BRI8ABAAAAADAAAA+IhwA+EK0hG0IgCgyWj5Obp6lr/mDdARooUAqgAwSeIBAgAAAAAABSAAAAAqA
+ gAABRo4ABAAAAADAAAAbZ7Gt8cs0hGFTgCgyYP2CIZ6lr/mDdARooUAqgAwSeIBAQAAAAAABQkAAA
+ AFGjgAEAAAAAMAAABtnsa3xyzSEYVOAKDJg/YInHqWv+YN0BGihQCqADBJ4gEBAAAAAAAFCQAAAAU
+ SOAAQAAAAAwAAAG2exrfHLNIRhU4AoMmD9gi6epa/5g3QEaKFAKoAMEniAQEAAAAAAAUJAAAABRos
+ AJQAAgACAAAAFMwoSDcUvEWbB61vAV5fKAECAAAAAAAFIAAAACoCAAAFGiwAlAACAAIAAACcepa/5
+ g3QEaKFAKoAMEniAQIAAAAAAAUgAAAAKgIAAAUSLACUAAIAAgAAALp6lr/mDdARooUAqgAwSeIBAg
+ AAAAAABSAAAAAqAgAABRIoADABAAABAAAA3kfmkW/ZcEuVV9Y/9PPM2AEBAAAAAAAFCgAAAAASJAD
+ /AQ8AAQUAAAAAAAUVAAAAgf34+BW7pFZyj5cFBwIAAAASGAAEAAAAAQIAAAAAAAUgAAAAKgIAAAAS
+ GAC9AQ8AAQIAAAAAAAUgAAAAIAIAAA==
+EOF
+
+ out=$(TZ=UTC $ldbadd -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb.d/DC%3DRELEASE-4-5-0-PRE1,DC%3DSAMBA,DC%3DCORP.ldb $ldif)
+ if [ "$?" != "0" ]; then
+ echo "ldbadd returned:\n$out"
+ return 1
+ fi
+
+ return 0
+}
+
+dbcheck_lost_deleted_user2()
+{
+ dbcheck "-lost-deleted-user2" "1" "--selftest-check-expired-tombstones"
+ return $?
+}
+
+add_lost_deleted_user3()
+{
+ ldif=$PREFIX_ABS/${RELEASE}/add_lost_deleted_user3.ldif
+ cat >$ldif <<EOF
+dn: CN=fred\0ADEL:2301a64c-1122-5566-851e-12d4a711cfb4,OU=removed,DC=release-4-5-0-pre1,DC=samba,DC=corp
+objectClass: top
+objectClass: person
+objectClass: organizationalPerson
+objectClass: user
+instanceType: 4
+whenCreated: 20160629043638.0Z
+uSNCreated: 3740
+objectGUID: 2301a64c-1122-5566-851e-12d4a711cfb4
+objectSid: S-1-5-21-4177067393-1453636373-93818738-1010
+sAMAccountName: fred
+userAccountControl: 512
+isDeleted: TRUE
+lastKnownParent: <GUID=f28216e9-1234-5678-8b2d-6bb229563b62>;OU=removed,DC=rel
+ ease-4-5-0-pre1,DC=samba,DC=corp
+isRecycled: TRUE
+cn:: ZnJlZApERUw6MjMwMWE2NGMtMTEyMi01NTY2LTg1MWUtMTJkNGE3MTFjZmI0
+name:: ZnJlZApERUw6MjMwMWE2NGMtMTEyMi01NTY2LTg1MWUtMTJkNGE3MTFjZmI0
+replPropertyMetaData:: AQAAAAAAAAAXAAAAAAAAAAAAAAABAAAAVuGDDQMAAACjlkROuH+XT4o
+ z0jjbi14tnA4AAAAAAACcDgAAAAAAAAMAAAACAAAAV+GDDQMAAACjlkROuH+XT4oz0jjbi14tog4A
+ AAAAAACiDgAAAAAAAAEAAgABAAAAVuGDDQMAAACjlkROuH+XT4oz0jjbi14tnA4AAAAAAACcDgAAA
+ AAAAAIAAgABAAAAVuGDDQMAAACjlkROuH+XT4oz0jjbi14tnA4AAAAAAACcDgAAAAAAADAAAgABAA
+ AAV+GDDQMAAACjlkROuH+XT4oz0jjbi14tog4AAAAAAACiDgAAAAAAABkBAgABAAAAVuGDDQMAAAC
+ jlkROuH+XT4oz0jjbi14tnA4AAAAAAACcDgAAAAAAAAEACQACAAAAV+GDDQMAAACjlkROuH+XT4oz
+ 0jjbi14tog4AAAAAAACiDgAAAAAAAAgACQADAAAAVuGDDQMAAACjlkROuH+XT4oz0jjbi14tng4AA
+ AAAAACeDgAAAAAAABAACQACAAAAV+GDDQMAAACjlkROuH+XT4oz0jjbi14tog4AAAAAAACiDgAAAA
+ AAABkACQACAAAAV+GDDQMAAACjlkROuH+XT4oz0jjbi14tog4AAAAAAACiDgAAAAAAAFoACQABAAA
+ AVuGDDQMAAACjlkROuH+XT4oz0jjbi14tnQ4AAAAAAACdDgAAAAAAAF4ACQABAAAAVuGDDQMAAACj
+ lkROuH+XT4oz0jjbi14tnQ4AAAAAAACdDgAAAAAAAGAACQADAAAAV+GDDQMAAACjlkROuH+XT4oz0
+ jjbi14tog4AAAAAAACiDgAAAAAAAGIACQACAAAAV+GDDQMAAACjlkROuH+XT4oz0jjbi14tog4AAA
+ AAAACiDgAAAAAAAH0ACQABAAAAVuGDDQMAAACjlkROuH+XT4oz0jjbi14tnQ4AAAAAAACdDgAAAAA
+ AAJIACQABAAAAVuGDDQMAAACjlkROuH+XT4oz0jjbi14tnA4AAAAAAACcDgAAAAAAAJ8ACQACAAAA
+ V+GDDQMAAACjlkROuH+XT4oz0jjbi14tog4AAAAAAACiDgAAAAAAAN0ACQABAAAAVuGDDQMAAACjl
+ kROuH+XT4oz0jjbi14tnA4AAAAAAACcDgAAAAAAAC4BCQACAAAAV+GDDQMAAACjlkROuH+XT4oz0j
+ jbi14tog4AAAAAAACiDgAAAAAAAJACCQACAAAAV+GDDQMAAACjlkROuH+XT4oz0jjbi14tog4AAAA
+ AAACiDgAAAAAAAA0DCQABAAAAV+GDDQMAAACjlkROuH+XT4oz0jjbi14tog4AAAAAAACiDgAAAAAA
+ AA4DCQACAAAAV+GDDQMAAACjlkROuH+XT4oz0jjbi14tog4AAAAAAACiDgAAAAAAAAoICQABAAAAV
+ +GDDQMAAACjlkROuH+XT4oz0jjbi14tog4AAAAAAACiDgAAAAAAAA==
+whenChanged: 20160629043639.0Z
+uSNChanged: 3746
+nTSecurityDescriptor:: AQAXjBQAAAAwAAAATAAAAMQAAAABBQAAAAAABRUAAACB/fj4FbukVnK
+ PlwUAAgAAAQUAAAAAAAUVAAAAgf34+BW7pFZyj5cFAAIAAAQAeAACAAAAB1o4ACAAAAADAAAAvjsO
+ 8/Cf0RG2AwAA+ANnwaV6lr/mDdARooUAqgAwSeIBAQAAAAAAAQAAAAAHWjgAIAAAAAMAAAC/Ow7z8
+ J/REbYDAAD4A2fBpXqWv+YN0BGihQCqADBJ4gEBAAAAAAABAAAAAAQA1AcsAAAAAAAkAP8BDwABBQ
+ AAAAAABRUAAACB/fj4FbukVnKPlwUAAgAAAAAUAP8BDwABAQAAAAAABRIAAAAAABgA/wEPAAECAAA
+ AAAAFIAAAACQCAAAAABQAlAACAAEBAAAAAAAFCgAAAAUAKAAAAQAAAQAAAFMacqsvHtARmBkAqgBA
+ UpsBAQAAAAAABQoAAAAFACgAAAEAAAEAAABUGnKrLx7QEZgZAKoAQFKbAQEAAAAAAAUKAAAABQAoA
+ AABAAABAAAAVhpyqy8e0BGYGQCqAEBSmwEBAAAAAAAFCgAAAAUAKAAwAAAAAQAAAIa4tXdKlNERrr
+ 0AAPgDZ8EBAQAAAAAABQoAAAAFACgAMAAAAAEAAACylVfkVZTREa69AAD4A2fBAQEAAAAAAAUKAAA
+ ABQAoADAAAAABAAAAs5VX5FWU0RGuvQAA+ANnwQEBAAAAAAAFCgAAAAUAOAAQAAAAAQAAAPiIcAPh
+ CtIRtCIAoMlo+TkBBQAAAAAABRUAAACB/fj4FbukVnKPlwUpAgAABQA4ABAAAAABAAAAAEIWTMAg0
+ BGnaACqAG4FKQEFAAAAAAAFFQAAAIH9+PgVu6RWco+XBSkCAAAFADgAEAAAAAEAAABAwgq8qXnQEZ
+ AgAMBPwtTPAQUAAAAAAAUVAAAAgf34+BW7pFZyj5cFKQIAAAAAFAAAAAIAAQEAAAAAAAULAAAABQA
+ oABAAAAABAAAAQi+6WaJ50BGQIADAT8LTzwEBAAAAAAAFCwAAAAUAKAAQAAAAAQAAAIa4tXdKlNER
+ rr0AAPgDZ8EBAQAAAAAABQsAAAAFACgAEAAAAAEAAACzlVfkVZTREa69AAD4A2fBAQEAAAAAAAULA
+ AAABQAoABAAAAABAAAAVAGN5Pi80RGHAgDAT7lgUAEBAAAAAAAFCwAAAAUAKAAAAQAAAQAAAFMacq
+ svHtARmBkAqgBAUpsBAQAAAAAAAQAAAAAFADgAEAAAAAEAAAAQICBfpXnQEZAgAMBPwtTPAQUAAAA
+ AAAUVAAAAgf34+BW7pFZyj5cFKQIAAAUAOAAwAAAAAQAAAH96lr/mDdARooUAqgAwSeIBBQAAAAAA
+ BRUAAACB/fj4FbukVnKPlwUFAgAABQAsABAAAAABAAAAHbGpRq5gWkC36P+KWNRW0gECAAAAAAAFI
+ AAAADACAAAFACwAMAAAAAEAAAAcmrZtIpTREa69AAD4A2fBAQIAAAAAAAUgAAAAMQIAAAUALAAwAA
+ AAAQAAAGK8BVjJvShEpeKFag9MGF4BAgAAAAAABSAAAAAxAgAABRo8ABAAAAADAAAAAEIWTMAg0BG
+ naACqAG4FKRTMKEg3FLxFmwetbwFeXygBAgAAAAAABSAAAAAqAgAABRI8ABAAAAADAAAAAEIWTMAg
+ 0BGnaACqAG4FKbp6lr/mDdARooUAqgAwSeIBAgAAAAAABSAAAAAqAgAABRo8ABAAAAADAAAAECAgX
+ 6V50BGQIADAT8LUzxTMKEg3FLxFmwetbwFeXygBAgAAAAAABSAAAAAqAgAABRI8ABAAAAADAAAAEC
+ AgX6V50BGQIADAT8LUz7p6lr/mDdARooUAqgAwSeIBAgAAAAAABSAAAAAqAgAABRo8ABAAAAADAAA
+ AQMIKvKl50BGQIADAT8LUzxTMKEg3FLxFmwetbwFeXygBAgAAAAAABSAAAAAqAgAABRI8ABAAAAAD
+ AAAAQMIKvKl50BGQIADAT8LUz7p6lr/mDdARooUAqgAwSeIBAgAAAAAABSAAAAAqAgAABRo8ABAAA
+ AADAAAAQi+6WaJ50BGQIADAT8LTzxTMKEg3FLxFmwetbwFeXygBAgAAAAAABSAAAAAqAgAABRI8AB
+ AAAAADAAAAQi+6WaJ50BGQIADAT8LTz7p6lr/mDdARooUAqgAwSeIBAgAAAAAABSAAAAAqAgAABRo
+ 8ABAAAAADAAAA+IhwA+EK0hG0IgCgyWj5ORTMKEg3FLxFmwetbwFeXygBAgAAAAAABSAAAAAqAgAA
+ BRI8ABAAAAADAAAA+IhwA+EK0hG0IgCgyWj5Obp6lr/mDdARooUAqgAwSeIBAgAAAAAABSAAAAAqA
+ gAABRo4ABAAAAADAAAAbZ7Gt8cs0hGFTgCgyYP2CIZ6lr/mDdARooUAqgAwSeIBAQAAAAAABQkAAA
+ AFGjgAEAAAAAMAAABtnsa3xyzSEYVOAKDJg/YInHqWv+YN0BGihQCqADBJ4gEBAAAAAAAFCQAAAAU
+ SOAAQAAAAAwAAAG2exrfHLNIRhU4AoMmD9gi6epa/5g3QEaKFAKoAMEniAQEAAAAAAAUJAAAABRos
+ AJQAAgACAAAAFMwoSDcUvEWbB61vAV5fKAECAAAAAAAFIAAAACoCAAAFGiwAlAACAAIAAACcepa/5
+ g3QEaKFAKoAMEniAQIAAAAAAAUgAAAAKgIAAAUSLACUAAIAAgAAALp6lr/mDdARooUAqgAwSeIBAg
+ AAAAAABSAAAAAqAgAABRIoADABAAABAAAA3kfmkW/ZcEuVV9Y/9PPM2AEBAAAAAAAFCgAAAAASJAD
+ /AQ8AAQUAAAAAAAUVAAAAgf34+BW7pFZyj5cFBwIAAAASGAAEAAAAAQIAAAAAAAUgAAAAKgIAAAAS
+ GAC9AQ8AAQIAAAAAAAUgAAAAIAIAAA==
+EOF
+
+ out=$(TZ=UTC $ldbadd -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb.d/DC%3DRELEASE-4-5-0-PRE1,DC%3DSAMBA,DC%3DCORP.ldb $ldif)
+ if [ "$?" != "0" ]; then
+ echo "ldbadd returned:\n$out"
+ return 1
+ fi
+
+ return 0
+}
+
+dbcheck_lost_deleted_user3()
+{
+ # here we don't pass --selftest-check-expired-tombstones
+ # as we want to test the default
+ dbcheck "-lost-deleted-user3" "0" ""
+ return $?
+}
+
+remove_lost_deleted_user3()
+{
+ out=$(TZ=UTC $ldbdel -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb "<GUID=2301a64c-1122-5566-851e-12d4a711cfb4>" --show-recycled --relax)
+ if [ "$?" != "0" ]; then
+ echo "ldbdel returned:\n$out"
+ return 1
+ fi
+
+ return 0
+}
+
+forward_link_corruption()
+{
+ #
+ # Step1: add a duplicate forward link from
+ # "CN=Enterprise Admins" to "CN=Administrator"
+ #
+ LDIF1=$(TZ=UTC $ldbsearch -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb -b 'CN=Enterprise Admins,CN=users,DC=release-4-5-0-pre1,DC=samba,DC=corp' --scope=base --reveal --extended-dn member)
+ DN=$(echo "${LDIF1}" | grep '^dn: ')
+ MSG=$(echo "${LDIF1}" | grep -v '^dn: ' | grep -v '^#' | grep -v '^$')
+ ldif=$PREFIX_ABS/${RELEASE}/forward_link_corruption1.ldif
+ {
+ echo "${DN}"
+ echo "changetype: modify"
+ echo "replace: member"
+ echo "${MSG}"
+ echo "${MSG}" | sed -e 's!RMD_LOCAL_USN=[1-9][0-9]*!RMD_LOCAL_USN=0!'
+ } >$ldif
+
+ out=$(TZ=UTC $ldbmodify -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb.d/DC%3DRELEASE-4-5-0-PRE1,DC%3DSAMBA,DC%3DCORP.ldb $ldif)
+ if [ "$?" != "0" ]; then
+ echo "ldbmodify returned:\n$out"
+ return 1
+ fi
+
+ #
+ # Step2: add user "dangling"
+ #
+ ldif=$PREFIX_ABS/${RELEASE}/forward_link_corruption2.ldif
+ cat >$ldif <<EOF
+dn: CN=dangling,CN=users,DC=release-4-5-0-pre1,DC=samba,DC=corp
+changetype: add
+objectclass: user
+samaccountname: dangling
+objectGUID: fd8a04ac-cea0-4921-b1a6-c173e1155c22
+EOF
+
+ out=$(TZ=UTC $ldbmodify -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb --relax $ldif)
+ if [ "$?" != "0" ]; then
+ echo "ldbmodify returned:\n$out"
+ return 1
+ fi
+
+ #
+ # Step3: add a dangling backlink from
+ # "CN=dangling" to "CN=Enterprise Admins"
+ #
+ ldif=$PREFIX_ABS/${RELEASE}/forward_link_corruption3.ldif
+ {
+ echo "dn: CN=dangling,CN=users,DC=release-4-5-0-pre1,DC=samba,DC=corp"
+ echo "changetype: modify"
+ echo "add: memberOf"
+ echo "memberOf: <GUID=304ad703-468b-465e-9787-470b3dfd7d75>;<SID=S-1-5-21-4177067393-1453636373-93818738-519>;CN=Enterprise Admins,CN=Users,DC=release-4-5-0-pre1,DC=samba,DC=corp"
+ } >$ldif
+
+ out=$(TZ=UTC $ldbmodify -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb.d/DC%3DRELEASE-4-5-0-PRE1,DC%3DSAMBA,DC%3DCORP.ldb $ldif)
+ if [ "$?" != "0" ]; then
+ echo "ldbmodify returned:\n$out"
+ return 1
+ fi
+}
+
+dbcheck_forward_link_corruption()
+{
+ dbcheck "-forward-link-corruption" "1" "--selftest-check-expired-tombstones"
+ return $?
+}
+
+check_expected_after_dbcheck_forward_link_corruption()
+{
+ tmpldif=$PREFIX_ABS/$RELEASE/expected-after-dbcheck-forward-link-corruption.ldif.tmp
+ TZ=UTC $ldbsearch -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb '(|(cn=dangling)(cn=enterprise admins))' --scope=sub -b DC=release-4-5-0-pre1,DC=samba,DC=corp --show-deleted --sorted memberOf member >$tmpldif
+ diff -u $tmpldif $release_dir/expected-after-dbcheck-forward-link-corruption.ldif
+ if [ "$?" != "0" ]; then
+ return 1
+ fi
+}
+
+oneway_link_corruption()
+{
+ #
+ # Step1: add OU "dangling-ou"
+ #
+ ldif=$PREFIX_ABS/${RELEASE}/oneway_link_corruption.ldif
+ cat >$ldif <<EOF
+dn: OU=dangling-ou,DC=release-4-5-0-pre1,DC=samba,DC=corp
+changetype: add
+objectclass: organizationalUnit
+objectGUID: 20600e7c-92bb-492e-9552-f3ed7f8a2cad
+EOF
+
+ out=$(TZ=UTC $ldbmodify -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb --relax $ldif)
+ if [ "$?" != "0" ]; then
+ echo "ldbmodify returned:\n$out"
+ return 1
+ fi
+
+ #
+ # Step2: add msExchConfigurationContainer "dangling-msexch"
+ #
+ ldif=$PREFIX_ABS/${RELEASE}/oneway_link_corruption2.ldif
+ cat >$ldif <<EOF
+dn: OU=dangling-from,DC=release-4-5-0-pre1,DC=samba,DC=corp
+changetype: add
+objectclass: organizationalUnit
+seeAlso: OU=dangling-ou,DC=release-4-5-0-pre1,DC=samba,DC=corp
+EOF
+
+ out=$(TZ=UTC $ldbmodify -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb $ldif)
+ if [ "$?" != "0" ]; then
+ echo "ldbmodify returned:\n$out"
+ return 1
+ fi
+
+ #
+ # Step3: rename dangling-ou to dangling-ou2
+ #
+ # Because this is a one-way link we don't fix it at runtime
+ #
+ out=$(TZ=UTC $ldbrename -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb OU=dangling-ou,DC=release-4-5-0-pre1,DC=samba,DC=corp OU=dangling-ou2,DC=release-4-5-0-pre1,DC=samba,DC=corp)
+ if [ "$?" != "0" ]; then
+ echo "ldbmodify returned:\n$out"
+ return 1
+ fi
+}
+
+dbcheck_oneway_link_corruption()
+{
+ dbcheck "-oneway-link-corruption" "0" "--selftest-check-expired-tombstones"
+ return $?
+}
+
+check_expected_after_dbcheck_oneway_link_corruption()
+{
+ tmpldif=$PREFIX_ABS/$RELEASE/expected-after-dbcheck-oneway-link-corruption.ldif.tmp
+ TZ=UTC $ldbsearch -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb '(|(ou=dangling-ou)(ou=dangling-ou2)(ou=dangling-from))' --scope=sub -b DC=release-4-5-0-pre1,DC=samba,DC=corp --show-deleted --sorted seeAlso >$tmpldif
+ diff -u $tmpldif $release_dir/expected-after-dbcheck-oneway-link-corruption.ldif
+ if [ "$?" != "0" ]; then
+ return 1
+ fi
+}
+
+dbcheck_dangling_multi_valued()
+{
+
+ $PYTHON $BINDIR/samba-tool dbcheck -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb --selftest-check-expired-tombstones --fix --yes
+ if [ "$?" != "1" ]; then
+ return 1
+ fi
+}
+
+dangling_multi_valued_check_missing()
+{
+ WORDS=$(TZ=UTC $ldbsearch -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb '(samaccountname=dangling-multi2)' --scope=sub -b DC=release-4-5-0-pre1,DC=samba,DC=corp --show-deleted --reveal --sorted msDS-RevealedDSAs | grep msDS-RevealedDSAs | wc -l)
+ if [ $WORDS -ne 4 ]; then
+ echo Got only $WORDS links for dangling-multi2
+ return 1
+ fi
+ WORDS=$(TZ=UTC $ldbsearch -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb '(samaccountname=dangling-multi3)' --scope=sub -b DC=release-4-5-0-pre1,DC=samba,DC=corp --show-deleted --reveal --sorted msDS-RevealedDSAs | grep msDS-RevealedDSAs | wc -l)
+ if [ $WORDS -ne 4 ]; then
+ echo Got only $WORDS links for dangling-multi3
+ return 1
+ fi
+}
+
+dangling_multi_valued_check_equal_or_too_many()
+{
+ WORDS=$(TZ=UTC $ldbsearch -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb '(samaccountname=dangling-multi1)' --scope=sub -b DC=release-4-5-0-pre1,DC=samba,DC=corp --show-deleted --reveal --sorted msDS-RevealedDSAs | grep msDS-RevealedDSAs | wc -l)
+ if [ $WORDS -ne 4 ]; then
+ echo Got $WORDS links for dangling-multi1
+ return 1
+ fi
+
+ WORDS=$(TZ=UTC $ldbsearch -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb '(samaccountname=dangling-multi5)' --scope=sub -b DC=release-4-5-0-pre1,DC=samba,DC=corp --show-deleted --reveal --sorted msDS-RevealedDSAs | grep msDS-RevealedDSAs | wc -l)
+
+ if [ $WORDS -ne 0 ]; then
+ echo Got $WORDS links for dangling-multi5
+ return 1
+ fi
+
+ WORDS=$(TZ=UTC $ldbsearch -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb '(samaccountname=Administrator)' --scope=sub -b DC=release-4-5-0-pre1,DC=samba,DC=corp --show-deleted --reveal --sorted msDS-RevealedDSAs | grep msDS-RevealedDSAs | wc -l)
+
+ if [ $WORDS -ne 2 ]; then
+ echo Got $WORDS links for Administrator
+ return 1
+ fi
+}
+
+dangling_link_does_not_prevent_delete()
+{
+
+ #
+ # Step1: add user "dangling"
+ #
+ ldif=$PREFIX_ABS/${RELEASE}/backlink_can_be_vanished1.ldif
+ dn='CN=dangling-for-vanish,CN=users,DC=release-4-5-0-pre1,DC=samba,DC=corp'
+ cat >$ldif <<EOF
+dn: $dn
+changetype: add
+objectclass: user
+samaccountname: dangling-v
+objectGUID: fd8a04ac-cea0-4921-b1a6-c173e1155c23
+EOF
+
+ out=$(TZ=UTC $ldbmodify -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb --relax $ldif)
+ if [ "$?" != "0" ]; then
+ echo "ldbmodify returned:\n$out"
+ return 1
+ fi
+
+ #
+ # Step2: add a dangling backlink from
+ # "CN=dangling-for-vanish" to "CN=Enterprise Admins"
+ #
+ ldif=$PREFIX_ABS/${RELEASE}/backlink_can_be_vanished2.ldif
+ {
+ echo "dn: $dn"
+ echo "changetype: modify"
+ echo "add: memberOf"
+ echo "memberOf: <GUID=304ad703-468b-465e-9787-470b3dfd7d75>;<SID=S-1-5-21-4177067393-1453636373-93818738-519>;CN=Enterprise Admins,CN=Users,DC=release-4-5-0-pre1,DC=samba,DC=corp"
+ } >$ldif
+
+ out=$(TZ=UTC $ldbmodify -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb.d/DC%3DRELEASE-4-5-0-PRE1,DC%3DSAMBA,DC%3DCORP.ldb $ldif)
+ if [ "$?" != "0" ]; then
+ echo "ldbmodify returned:\n$out"
+ return 1
+ fi
+
+ out=$(TZ=UTC $ldbdel -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb "$dn")
+ if [ "$?" != "0" ]; then
+ echo "ldbdel returned:\n$out"
+ return 1
+ fi
+}
+
+dangling_link_to_unknown_does_not_prevent_delete()
+{
+
+ #
+ # Step1: add user "dangling"
+ #
+ ldif=$PREFIX_ABS/${RELEASE}/backlink_can_be_vanished1.ldif
+ dn='CN=dangling-for-vanish,CN=users,DC=release-4-5-0-pre1,DC=samba,DC=corp'
+ cat >$ldif <<EOF
+dn: $dn
+changetype: add
+objectclass: user
+samaccountname: dangling-v
+objectGUID: a4090081-ac2a-410c-8924-b255375160e8
+EOF
+
+ out=$(TZ=UTC $ldbmodify -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb --relax $ldif)
+ if [ "$?" != "0" ]; then
+ echo "ldbmodify returned:\n$out"
+ return 1
+ fi
+
+ #
+ # Step2: add a dangling backlink from
+ # "CN=dangling-for-vanish" to "CN=NOT Enterprise Admins"
+ #
+ ldif=$PREFIX_ABS/${RELEASE}/backlink_can_be_vanished2.ldif
+ {
+ echo "dn: $dn"
+ echo "changetype: modify"
+ echo "add: memberOf"
+ echo "memberOf: <GUID=09a47bff-0227-44e1-a8e4-63f9e726515d>;<SID=S-1-5-21-4177067393-1453636373-93818738-588>;CN=NOT Enterprise Admins,CN=Users,DC=release-4-5-0-pre1,DC=samba,DC=corp"
+ } >$ldif
+
+ out=$(TZ=UTC $ldbmodify -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb.d/DC%3DRELEASE-4-5-0-PRE1,DC%3DSAMBA,DC%3DCORP.ldb $ldif)
+ if [ "$?" != "0" ]; then
+ echo "ldbmodify returned:\n$out"
+ return 1
+ fi
+
+ out=$(TZ=UTC $ldbdel -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb "$dn")
+ if [ "$?" != "0" ]; then
+ echo "ldbdel returned:\n$out"
+ return 1
+ fi
+}
+
+dangling_link_to_known_and_unknown_does_not_prevent_delete()
+{
+
+ #
+ # Step1: add user "dangling"
+ #
+ ldif=$PREFIX_ABS/${RELEASE}/backlink_can_be_vanished1.ldif
+ dn='CN=dangling-for-vanish,CN=users,DC=release-4-5-0-pre1,DC=samba,DC=corp'
+ cat >$ldif <<EOF
+dn: $dn
+changetype: add
+objectclass: user
+samaccountname: dangling-v
+objectGUID: 2882ffb1-31c3-485e-a7fc-184dfafc32d4
+EOF
+
+ out=$(TZ=UTC $ldbmodify -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb --relax $ldif)
+ if [ "$?" != "0" ]; then
+ echo "ldbmodify returned:\n$out"
+ return 1
+ fi
+
+ #
+ # Step2: add a dangling backlink from
+ # "CN=dangling-for-vanish" to "CN=Enterprise Admins",
+ # "CN=dangling-for-vanish" to "CN=NOT Enterprise Admins" and
+ # back to ourselves
+ #
+ ldif=$PREFIX_ABS/${RELEASE}/backlink_can_be_vanished2.ldif
+ {
+ echo "dn: $dn"
+ echo "changetype: modify"
+ echo "add: memberOf"
+ echo "memberOf: <GUID=304ad703-468b-465e-9787-470b3dfd7d75>;<SID=S-1-5-21-4177067393-1453636373-93818738-519>;CN=Enterprise Admins,CN=Users,DC=release-4-5-0-pre1,DC=samba,DC=corp"
+ echo "memberOf: <GUID=09a47bff-0227-44e1-a8e4-63f9e726515d>;<SID=S-1-5-21-4177067393-1453636373-93818738-588>;CN=NOT Enterprise Admins,CN=Users,DC=release-4-5-0-pre1,DC=samba,DC=corp"
+ echo "memberOf: <GUID=2882ffb1-31c3-485e-a7fc-184dfafc32d4>;CN=dangling-for-vanish,CN=users,DC=release-4-5-0-pre1,DC=samba,DC=corp"
+ } >$ldif
+
+ out=$(TZ=UTC $ldbmodify -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb.d/DC%3DRELEASE-4-5-0-PRE1,DC%3DSAMBA,DC%3DCORP.ldb $ldif)
+ if [ "$?" != "0" ]; then
+ echo "ldbmodify returned:\n$out"
+ return 1
+ fi
+
+ out=$(TZ=UTC $ldbdel -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb "$dn")
+ if [ "$?" != "0" ]; then
+ echo "ldbdel returned:\n$out"
+ return 1
+ fi
+}
+
+remove_directory $PREFIX_ABS/${RELEASE}
+
+testit $RELEASE undump || failed=$(expr $failed + 1)
+testit_expect_failure "dbcheck_acl_reset" dbcheck_acl_reset || failed=$(expr $failed + 1)
+testit "dbcheck_acl_clean" dbcheck_acl_clean || failed=$(expr $failed + 1)
+testit "add_two_more_users" add_two_more_users || failed=$(expr $failed + 1)
+testit "add_four_more_links" add_four_more_links || failed=$(expr $failed + 1)
+testit "remove_one_link" remove_one_link || failed=$(expr $failed + 1)
+testit "remove_one_user" remove_one_user || failed=$(expr $failed + 1)
+testit "move_one_user" move_one_user || failed=$(expr $failed + 1)
+testit "add_dangling_link" add_dangling_link || failed=$(expr $failed + 1)
+testit "add_dangling_backlink" add_dangling_backlink || failed=$(expr $failed + 1)
+testit "add_deleted_dangling_backlink" add_deleted_dangling_backlink || failed=$(expr $failed + 1)
+testit "revive_links_on_deleted_group" revive_links_on_deleted_group || failed=$(expr $failed + 1)
+testit "revive_backlink_on_deleted_group" revive_backlink_on_deleted_group || failed=$(expr $failed + 1)
+testit "add_deleted_target_link" add_deleted_target_link || failed=$(expr $failed + 1)
+testit "add_deleted_target_backlink" add_deleted_target_backlink || failed=$(expr $failed + 1)
+testit "dbcheck_dangling" dbcheck_dangling || failed=$(expr $failed + 1)
+testit "dbcheck_clean" dbcheck_clean || failed=$(expr $failed + 1)
+testit "check_expected_after_deleted_links" check_expected_after_deleted_links || failed=$(expr $failed + 1)
+testit "check_expected_after_links" check_expected_after_links || failed=$(expr $failed + 1)
+testit "check_expected_after_objects" check_expected_after_objects || failed=$(expr $failed + 1)
+testit "duplicate_member" duplicate_member || failed=$(expr $failed + 1)
+testit "dbcheck_duplicate_member" dbcheck_duplicate_member || failed=$(expr $failed + 1)
+testit "check_expected_after_duplicate_links" check_expected_after_duplicate_links || failed=$(expr $failed + 1)
+testit "duplicate_clean" dbcheck_clean || failed=$(expr $failed + 1)
+testit "forward_link_corruption" forward_link_corruption || failed=$(expr $failed + 1)
+testit "dbcheck_forward_link_corruption" dbcheck_forward_link_corruption || failed=$(expr $failed + 1)
+testit "check_expected_after_dbcheck_forward_link_corruption" check_expected_after_dbcheck_forward_link_corruption || failed=$(expr $failed + 1)
+testit "forward_link_corruption_clean" dbcheck_clean || failed=$(expr $failed + 1)
+testit "oneway_link_corruption" oneway_link_corruption || failed=$(expr $failed + 1)
+testit "dbcheck_oneway_link_corruption" dbcheck_oneway_link_corruption || failed=$(expr $failed + 1)
+testit "check_expected_after_dbcheck_oneway_link_corruption" check_expected_after_dbcheck_oneway_link_corruption || failed=$(expr $failed + 1)
+testit "oneway_link_corruption_clean" dbcheck_clean || failed=$(expr $failed + 1)
+testit "dangling_one_way_link" dangling_one_way_link || failed=$(expr $failed + 1)
+testit "dbcheck_one_way" dbcheck_one_way || failed=$(expr $failed + 1)
+testit "dbcheck_clean2" dbcheck_clean || failed=$(expr $failed + 1)
+testit "missing_link_sid_corruption" missing_link_sid_corruption || failed=$(expr $failed + 1)
+testit "dbcheck_missing_link_sid_corruption" dbcheck_missing_link_sid_corruption || failed=$(expr $failed + 1)
+testit "missing_link_sid_clean" dbcheck_clean || failed=$(expr $failed + 1)
+testit "add_lost_deleted_user1" add_lost_deleted_user1 || failed=$(expr $failed + 1)
+testit "dbcheck_lost_deleted_user1" dbcheck_lost_deleted_user1 || failed=$(expr $failed + 1)
+testit "lost_deleted_user1_clean_A" dbcheck_clean || failed=$(expr $failed + 1)
+testit "remove_lost_deleted_user1" remove_lost_deleted_user1 || failed=$(expr $failed + 1)
+testit "lost_deleted_user1_clean_B" dbcheck_clean || failed=$(expr $failed + 1)
+testit "add_lost_deleted_user2" add_lost_deleted_user2 || failed=$(expr $failed + 1)
+testit "dbcheck_lost_deleted_user2" dbcheck_lost_deleted_user2 || failed=$(expr $failed + 1)
+testit "lost_deleted_user2_clean" dbcheck_clean || failed=$(expr $failed + 1)
+testit "add_lost_deleted_user3" add_lost_deleted_user3 || failed=$(expr $failed + 1)
+testit "dbcheck_lost_deleted_user3" dbcheck_lost_deleted_user3 || failed=$(expr $failed + 1)
+testit "lost_deleted_user3_clean_A" dbcheck_clean || failed=$(expr $failed + 1)
+testit "remove_lost_deleted_user3" remove_lost_deleted_user3 || failed=$(expr $failed + 1)
+testit "lost_deleted_user3_clean_B" dbcheck_clean || failed=$(expr $failed + 1)
+testit "dangling_one_way_dn" dangling_one_way_dn || failed=$(expr $failed + 1)
+testit "deleted_one_way_dn" deleted_one_way_dn || failed=$(expr $failed + 1)
+testit "dbcheck_clean3" dbcheck_clean || failed=$(expr $failed + 1)
+testit "add_dangling_multi_valued" add_dangling_multi_valued || failed=$(expr $failed + 1)
+testit "dbcheck_dangling_multi_valued" dbcheck_dangling_multi_valued || failed=$(expr $failed + 1)
+testit "dangling_multi_valued_check_missing" dangling_multi_valued_check_missing || failed=$(expr $failed + 1)
+testit "dangling_multi_valued_check_equal_or_too_many" dangling_multi_valued_check_equal_or_too_many || failed=$(expr $failed + 1)
+# Currently this cannot pass
+testit "dbcheck_dangling_multi_valued_clean" dbcheck_clean || failed=$(expr $failed + 1)
+testit "dangling_link_does_not_prevent_delete" dangling_link_does_not_prevent_delete || failed=$(expr $failed + 1)
+testit "dangling_link_to_unknown_does_not_prevent_delete" dangling_link_to_unknown_does_not_prevent_delete || failed=$(expr $failed + 1)
+testit "dangling_link_to_known_and_unknown_does_not_prevent_delete" dangling_link_to_known_and_unknown_does_not_prevent_delete || failed=$(expr $failed + 1)
+
+remove_directory $PREFIX_ABS/${RELEASE}
+
+exit $failed
diff --git a/testprogs/blackbox/dbcheck-oldrelease.sh b/testprogs/blackbox/dbcheck-oldrelease.sh
new file mode 100755
index 0000000..73f7ec4
--- /dev/null
+++ b/testprogs/blackbox/dbcheck-oldrelease.sh
@@ -0,0 +1,547 @@
+#!/bin/sh
+
+if [ $# -lt 1 ]; then
+ cat <<EOF
+Usage: dbcheck-oldrelease.sh PREFIX RELEASE
+EOF
+ exit 1
+fi
+
+PREFIX_ABS="$1"
+RELEASE="$2"
+shift 2
+
+failed=0
+
+. $(dirname $0)/subunit.sh
+. $(dirname $0)/common_test_fns.inc
+
+release_dir=$(dirname $0)/../../source4/selftest/provisions/$RELEASE
+
+ldbadd=$(system_or_builddir_binary ldbadd "${BINDIR}")
+ldbmodify=$(system_or_builddir_binary ldbmodify "${BINDIR}")
+ldbdel=$(system_or_builddir_binary ldbdel "${BINDIR}")
+ldbsearch=$(system_or_builddir_binary ldbsearch "${BINDIR}")
+ldbrename=$(system_or_builddir_binary ldbrename "${BINDIR}")
+samba_tdbrestore=$(system_or_builddir_binary tdbrestore "${BINDIR}")
+
+samba_undump="$SRCDIR_ABS/source4/selftest/provisions/undump.sh"
+if [ ! -x $samba_undump ] || [ ! -d $release_dir ]; then
+ subunit_start_test $RELEASE
+ subunit_skip_test $RELEASE <<EOF
+no test provision
+EOF
+
+ subunit_start_test "reindex"
+ subunit_skip_test "reindex" <<EOF
+no test provision
+EOF
+ subunit_start_test check_expected_before_values
+ subunit_skip_test check_expected_before_values <<EOF
+no test provision
+EOF
+ subunit_start_test "dbcheck"
+ subunit_skip_test "dbcheck" <<EOF
+no test provision
+EOF
+ subunit_start_test "dbcheck_clean"
+ subunit_skip_test "dbcheck_clean" <<EOF
+no test provision
+EOF
+ subunit_start_test check_expected_after_values
+ subunit_skip_test check_expected_after_values <<EOF
+no test provision
+EOF
+ subunit_start_test "dbcheck_acl_reset"
+ subunit_skip_test "dbcheck_acl_reset" <<EOF
+no test provision
+EOF
+ subunit_start_test "dbcheck_clean_acl_reset"
+ subunit_skip_test "dbcheck_clean_acl_reset" <<EOF
+no test provision
+EOF
+ subunit_start_test add_userparameters0
+ subunit_skip_test add_userparameters0 <<EOF
+no test provision
+EOF
+
+ subunit_start_test add_userparameters1
+ subunit_skip_test add_userparameters1 <<EOF
+no test provision
+EOF
+
+ subunit_start_test add_userparameters2
+ subunit_skip_test add_userparameters2 <<EOF
+no test provision
+EOF
+
+ subunit_start_test add_userparameters3
+ subunit_skip_test add_userparameters3 <<EOF
+no test provision
+EOF
+
+ subunit_start_test check_expected_before_values
+ subunit_skip_test check_expected_before_values <<EOF
+no test provision
+EOF
+
+ subunit_start_test "dbcheck2"
+ subunit_skip_test "dbcheck2" <<EOF
+no test provision
+EOF
+
+ subunit_start_test "referenceprovision"
+ subunit_skip_test "referenceprovision" <<EOF
+no test provision
+EOF
+ subunit_start_test "ldapcmp"
+ subunit_skip_test "ldapcmp" <<EOF
+no test provision
+EOF
+ subunit_start_test "ldapcmp_sd"
+ subunit_skip_test "ldapcmp_sd" <<EOF
+no test provision
+EOF
+
+ exit 0
+fi
+
+undump()
+{
+ $samba_undump $release_dir $PREFIX_ABS/$RELEASE $samba_tdbrestore
+}
+
+add_userparameters0()
+{
+ if [ x$RELEASE = x"release-4-1-0rc3" ]; then
+ $ldbmodify -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb <<EOF
+dn: cn=localdc,cn=domain controllers,dc=release-4-1-0rc3,dc=samba,dc=corp
+changetype: modify
+replace: userParameters
+userParameters:: IAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgAC
+ AAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAUAAQABoACAAB
+ AEMAdAB4AEMAZgBnAFAAcgBlAHMAZQBuAHQANTUxZTBiYjAYAAgAAQBDAHQAeABDAGYAZw
+ BGAGwAYQBnAHMAMQAwMGUwMDAxMBYACAABAEMAdAB4AEMAYQBsAGwAYgBhAGMAawAwMDAw
+ MDAwMBIACAABAEMAdAB4AFMAaABhAGQAbwB3ADAxMDAwMDAwKAAIAAEAQwB0AHgATQBhAH
+ gAQwBvAG4AbgBlAGMAdABpAG8AbgBUAGkAbQBlADAwMDAwMDAwLgAIAAEAQwB0AHgATQBh
+ AHgARABpAHMAYwBvAG4AbgBlAGMAdABpAG8AbgBUAGkAbQBlADAwMDAwMDAwHAAIAAEAQw
+ B0AHgATQBhAHgASQBkAGwAZQBUAGkAbQBlADAwMDAwMDAwIgAIAAEAQwB0AHgASwBlAHkA
+ YgBvAGEAcgBkAEwAYQB5AG8AdQB0ADAwMDAwMDAwKgACAAEAQwB0AHgATQBpAG4ARQBuAG
+ MAcgB5AHAAdABpAG8AbgBMAGUAdgBlAGwAMDAgAAIAAQBDAHQAeABXAG8AcgBrAEQAaQBy
+ AGUAYwB0AG8AcgB5ADAwIAACAAEAQwB0AHgATgBXAEwAbwBnAG8AbgBTAGUAcgB2AGUAcg
+ AwMBgAJAABAEMAdAB4AFcARgBIAG8AbQBlAEQAaQByADVjNWM3MzYxNzQ3NTcyNmU2NTVj
+ NzAyZTYyNjk2NDZmNmUwMCIABgABAEMAdAB4AFcARgBIAG8AbQBlAEQAaQByAEQAcgBpAH
+ YAZQA1MDNhMDAgADoAAQBDAHQAeABXAEYAUAByAG8AZgBpAGwAZQBQAGEAdABoADVjNWM3
+ MzYxNzQ3NTcyNmU2NTVjNzA3MjZmNjY2OTZjNjU3NDczNjU1YzcwMmU2MjY5NjQ2ZjZlMD
+ AiAAIAAQBDAHQAeABJAG4AaQB0AGkAYQBsAFAAcgBvAGcAcgBhAG0AMDAiAAIAAQBDAHQA
+ eABDAGEAbABsAGIAYQBjAGsATgB1AG0AYgBlAHIAMDA=
+-
+EOF
+ fi
+}
+add_userparameters1()
+{
+ if [ x$RELEASE = x"release-4-1-0rc3" ]; then
+ $ldbmodify -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb <<EOF
+dn: cn=administrator,cn=users,dc=release-4-1-0rc3,dc=samba,dc=corp
+changetype: modify
+replace: userParameters
+userParameters: IAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgAC
+ AAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAUAAQABoACAAB
+ AEMAdAB4AEMAZgBnAFAAcgBlAHMAZQBuAHQANTUxZTBiYjAYAAgAAQBDAHQAeABDAGYAZw
+ BGAGwAYQBnAHMAMQAwMGUwMDAxMBYACAABAEMAdAB4AEMAYQBsAGwAYgBhAGMAawAwMDAw
+ MDAwMBIACAABAEMAdAB4AFMAaABhAGQAbwB3ADAxMDAwMDAwKAAIAAEAQwB0AHgATQBhAH
+ gAQwBvAG4AbgBlAGMAdABpAG8AbgBUAGkAbQBlADAwMDAwMDAwLgAIAAEAQwB0AHgATQBh
+ AHgARABpAHMAYwBvAG4AbgBlAGMAdABpAG8AbgBUAGkAbQBlADAwMDAwMDAwHAAIAAEAQw
+ B0AHgATQBhAHgASQBkAGwAZQBUAGkAbQBlADAwMDAwMDAwIgAIAAEAQwB0AHgASwBlAHkA
+ YgBvAGEAcgBkAEwAYQB5AG8AdQB0ADAwMDAwMDAwKgACAAEAQwB0AHgATQBpAG4ARQBuAG
+ MAcgB5AHAAdABpAG8AbgBMAGUAdgBlAGwAMDAgAAIAAQBDAHQAeABXAG8AcgBrAEQAaQBy
+ AGUAYwB0AG8AcgB5ADAwIAACAAEAQwB0AHgATgBXAEwAbwBnAG8AbgBTAGUAcgB2AGUAcg
+ AwMBgAJAABAEMAdAB4AFcARgBIAG8AbQBlAEQAaQByADVjNWM3MzYxNzQ3NTcyNmU2NTVj
+ NzAyZTYyNjk2NDZmNmUwMCIABgABAEMAdAB4AFcARgBIAG8AbQBlAEQAaQByAEQAcgBpAH
+ YAZQA1MDNhMDAgADoAAQBDAHQAeABXAEYAUAByAG8AZgBpAGwAZQBQAGEAdABoADVjNWM3
+ MzYxNzQ3NTcyNmU2NTVjNzA3MjZmNjY2OTZjNjU3NDczNjU1YzcwMmU2MjY5NjQ2ZjZlMD
+ AiAAIAAQBDAHQAeABJAG4AaQB0AGkAYQBsAFAAcgBvAGcAcgBhAG0AMDAiAAIAAQBDAHQA
+ eABDAGEAbABsAGIAYQBjAGsATgB1AG0AYgBlAHIAMDA=
+-
+EOF
+ fi
+}
+add_userparameters2()
+{
+ if [ x$RELEASE = x"release-4-1-0rc3" ]; then
+ $ldbmodify -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb <<EOF
+dn: cn=krbtgt,cn=users,dc=release-4-1-0rc3,dc=samba,dc=corp
+changetype: modify
+replace: userParameters
+userParameters:: Q3R4Q2ZnUHJlc2VudCAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgI
+ CAgUAsaCAFDdHhDZmdQcmVzZW5045S15pSx5oiw44GiIAIBQ3R4V0ZQcm9maWxlUGF0aOOAsBgCAU
+ N0eFdGSG9tZURpcuOAsCICAUN0eFdGSG9tZURpckRyaXZl44CwEggBQ3R4U2hhZG9344Sw44Cw44C
+ w44CwLggBQ3R4TWF4RGlzY29ubmVjdGlvblRpbWXjgaXjjLnjkLDjgLAoCAFDdHhNYXhDb25uZWN0
+ aW9uVGltZeOAtOOct+aIseOAsBwIAUN0eE1heElkbGVUaW1l44Gj45yy46Sw44CwIAIBQ3R4V29ya
+ 0RpcmVjdG9yeeOAsBgIAUN0eENmZ0ZsYWdzMeOAsOOBpuOYsuOAuCICAUN0eEluaXRpYWxQcm9ncm
+ Ft44Cw
+-
+EOF
+ fi
+}
+
+add_userparameters3()
+{
+ if [ x$RELEASE = x"release-4-1-0rc3" ]; then
+ $ldbmodify -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb <<EOF
+dn: cn=guest,cn=users,dc=release-4-1-0rc3,dc=samba,dc=corp
+changetype: modify
+replace: userParameters
+userParameters:: QwAAAHQAAAB4AAAAQwAAAGYAAABnAAAAUAAAAHIAAABlAAAAcwAAAGUAAABuA
+ AAAdAAAACAAAAAgAAAAIAAAACAAAAAgAAAAIAAAACAAAAAgAAAAIAAAACAAAAAgAAAAIAAAACAAAA
+ AgAAAAIAAAACAAAAAgAAAAIAAAACAAAAAgAAAAIAAAACAAAAAgAAAAIAAAACAAAAAgAAAAIAAAACA
+ AAAAgAAAAIAAAACAAAAAgAAAAIAAAACAAAAAgAAAAUAAAAAsAAAAaAAAACAAAAAEAAABDAAAAdAAA
+ AHgAAABDAAAAZgAAAGcAAABQAAAAcgAAAGUAAABzAAAAZQAAAG4AAAB0AAAANQA1ADEAZQAwAGIAY
+ gAwACAAAAACAAAAAQAAAEMAAAB0AAAAeAAAAFcAAABGAAAAUAAAAHIAAABvAAAAZgAAAGkAAABsAA
+ AAZQAAAFAAAABhAAAAdAAAAGgAAAAwADAAGAAAAAIAAAABAAAAQwAAAHQAAAB4AAAAVwAAAEYAAAB
+ IAAAAbwAAAG0AAABlAAAARAAAAGkAAAByAAAAMAAwACIAAAACAAAAAQAAAEMAAAB0AAAAeAAAAFcA
+ AABGAAAASAAAAG8AAABtAAAAZQAAAEQAAABpAAAAcgAAAEQAAAByAAAAaQAAAHYAAABlAAAAMAAwA
+ BIAAAAIAAAAAQAAAEMAAAB0AAAAeAAAAFMAAABoAAAAYQAAAGQAAABvAAAAdwAAADAAMQAwADAAMA
+ AwADAAMAAuAAAACAAAAAEAAABDAAAAdAAAAHgAAABNAAAAYQAAAHgAAABEAAAAaQAAAHMAAABjAAA
+ AbwAAAG4AAABuAAAAZQAAAGMAAAB0AAAAaQAAAG8AAABuAAAAVAAAAGkAAABtAAAAZQAAAGUAMAA5
+ ADMAMAA0ADAAMAAoAAAACAAAAAEAAABDAAAAdAAAAHgAAABNAAAAYQAAAHgAAABDAAAAbwAAAG4AA
+ ABuAAAAZQAAAGMAAAB0AAAAaQAAAG8AAABuAAAAVAAAAGkAAABtAAAAZQAAADQAMAA3ADcAMQBiAD
+ AAMAAcAAAACAAAAAEAAABDAAAAdAAAAHgAAABNAAAAYQAAAHgAAABJAAAAZAAAAGwAAABlAAAAVAA
+ AAGkAAABtAAAAZQAAAGMAMAAyADcAMAA5ADAAMAAgAAAAAgAAAAEAAABDAAAAdAAAAHgAAABXAAAA
+ bwAAAHIAAABrAAAARAAAAGkAAAByAAAAZQAAAGMAAAB0AAAAbwAAAHIAAAB5AAAAMAAwABgAAAAIA
+ AAAAQAAAEMAAAB0AAAAeAAAAEMAAABmAAAAZwAAAEYAAABsAAAAYQAAAGcAAABzAAAAMQAAADAAMA
+ BmADAAMgA2ADgAMAAiAAAAAgAAAAEAAABDAAAAdAAAAHgAAABJAAAAbgAAAGkAAAB0AAAAaQAAAGE
+ AAABsAAAAUAAAAHIAAABvAAAAZwAAAHIAAABhAAAAbQAAADAAMAA=
+-
+EOF
+ fi
+}
+
+check_expected_userparameters()
+{
+ if [ x$RELEASE = x"release-4-1-0rc3" ]; then
+ tmpldif=$PREFIX_ABS/$RELEASE/expected-userParameters-after-dbcheck.ldif.tmp
+ TZ=UTC $ldbsearch -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb userParameters=* --scope=sub -b DC=release-4-1-0rc3,DC=samba,DC=corp userParameters --sorted | grep -v \# >$tmpldif
+ diff -u $tmpldif $release_dir/expected-userParameters-after-dbcheck.ldif
+ if [ "$?" != "0" ]; then
+ return 1
+ fi
+ fi
+ return 0
+}
+
+reindex()
+{
+ $PYTHON $BINDIR/samba-tool dbcheck --reindex -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb "$@"
+}
+
+do_current_version_mod()
+{
+ if [ x$RELEASE = x"release-4-1-0rc3" ]; then
+ # Confirm (in combination with the ldbsearch below) that
+ # changing the attribute with current Samba fixes it, and that
+ # a fixed attriute isn't unfixed by dbcheck.
+ tmpldif=$release_dir/sudoers2-mod.ldif
+ $ldbmodify -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb $tmpldif
+ fi
+ return 0
+}
+
+check_expected_before_values()
+{
+ if [ x$RELEASE = x"release-4-1-0rc3" ]; then
+ tmpldif=$PREFIX_ABS/$RELEASE/expected-replpropertymetadata-before-dbcheck.ldif.tmp
+ TZ=UTC $ldbsearch -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb cn=ops_run_anything --scope=one -b OU=SUDOers,DC=release-4-1-0rc3,DC=samba,DC=corp \* replpropertymetadata --sorted --show-binary >$tmpldif
+ diff -u $tmpldif $release_dir/expected-replpropertymetadata-before-dbcheck.ldif
+ if [ "$?" != "0" ]; then
+ return 1
+ fi
+
+ TZ=UTC $ldbsearch -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb cn=ops_run_anything2 --scope=one -b OU=SUDOers,DC=release-4-1-0rc3,DC=samba,DC=corp \* replpropertymetadata --sorted --show-binary | grep -v originating_change_time | grep -v whenChanged >$tmpldif
+
+ # Here we remove originating_change_time and whenChanged as
+ # these are time-dependent, caused by the ldbmodify above.
+
+ diff -u $tmpldif $release_dir/expected-replpropertymetadata-before-dbcheck2.ldif
+ if [ "$?" != "0" ]; then
+ return 1
+ fi
+
+ TZ=UTC $ldbsearch -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb cn=ops_run_anything3 --scope=one -b OU=SUDOers,DC=release-4-1-0rc3,DC=samba,DC=corp \* replpropertymetadata --sorted --show-binary >$tmpldif
+ diff -u $tmpldif $release_dir/expected-replpropertymetadata-before-dbcheck3.ldif
+ if [ "$?" != "0" ]; then
+ return 1
+ fi
+ elif [ x$RELEASE = x"release-4-5-0-pre1" ]; then
+ tmpldif=$PREFIX_ABS/$RELEASE/rootdse-version.initial.txt.tmp
+ TZ=UTC $ldbsearch -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb --scope=base -b '' | grep highestCommittedUSN >$tmpldif
+ diff -u $tmpldif $release_dir/rootdse-version.initial.txt
+ if [ "$?" != "0" ]; then
+ return 1
+ fi
+ fi
+ return 0
+}
+
+# This should 'fail', because it returns the number of modified records
+dbcheck_objectclass()
+{
+ if [ x$RELEASE = x"release-4-1-6-partial-object" ]; then
+ $PYTHON $BINDIR/samba-tool dbcheck --selftest-check-expired-tombstones --cross-ncs --fix --yes -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb --attrs=objectclass "$@"
+ else
+ return 1
+ fi
+}
+
+# This should 'fail', because it returns the number of wrong records, which it must if we did not skip the deleted objects
+dbcheck_deleted_objects()
+{
+ if [ x$RELEASE = x"alpha13" ]; then
+ basedn=$($ldbsearch -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb --scope base -b "" defaultNamingContext | grep -i defaultNamingContext | cut -d\ -f 2)
+
+ $PYTHON $BINDIR/samba-tool dbcheck -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb "cn=deleted objects,$basedn" --scope base "$@"
+ else
+ return 1
+ fi
+}
+
+# This should 'fail', because it returns the number of modified records
+dbcheck()
+{
+ $PYTHON $BINDIR/samba-tool dbcheck --selftest-check-expired-tombstones --cross-ncs --fix --yes -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb "$@"
+}
+
+check_expected_after_values()
+{
+ if [ x$RELEASE = x"release-4-1-0rc3" ]; then
+ tmpldif=$PREFIX_ABS/$RELEASE/expected-replpropertymetadata-after-dbcheck.ldif.tmp
+ TZ=UTC $ldbsearch -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb cn=ops_run_anything --scope=one -b OU=SUDOers,DC=release-4-1-0rc3,DC=samba,DC=corp \* replpropertymetadata --sorted --show-binary >$tmpldif
+ diff -u $tmpldif $release_dir/expected-replpropertymetadata-after-dbcheck.ldif
+ if [ "$?" != "0" ]; then
+ return 1
+ fi
+ TZ=UTC $ldbsearch -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb cn=ops_run_anything2 --scope=one -b OU=SUDOers,DC=release-4-1-0rc3,DC=samba,DC=corp \* replpropertymetadata --sorted --show-binary | grep -v originating_change_time | grep -v whenChanged >$tmpldif
+ diff -u $tmpldif $release_dir/expected-replpropertymetadata-after-dbcheck2.ldif
+ if [ "$?" != "0" ]; then
+ return 1
+ fi
+ TZ=UTC $ldbsearch -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb cn=ops_run_anything3 --scope=one -b OU=SUDOers,DC=release-4-1-0rc3,DC=samba,DC=corp \* replpropertymetadata --sorted --show-binary >$tmpldif
+ diff -u $tmpldif $release_dir/expected-replpropertymetadata-after-dbcheck3.ldif
+ if [ "$?" != "0" ]; then
+ return 1
+ fi
+ # Check DomainDNS partition for replica locations
+ tmpldif=$PREFIX_ABS/$RELEASE/expected-replica-locations-after-dbcheck.ldif.tmp
+ $ldbsearch -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb cn=49a69498-9a85-48af-9be4-aa0b3e0054f9 --scope=one -b CN=Partitions,CN=Configuration,DC=release-4-1-0rc3,DC=samba,DC=corp msDS-NC-Replica-Locations >$tmpldif
+ diff -u $tmpldif $release_dir/expected-replica-locations-after-dbcheck.ldif
+ if [ "$?" != "0" ]; then
+ return 1
+ fi
+ # Check ForestDNS partition for replica locations
+ $ldbsearch -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb cn=7d2a15af-c0d4-487c-847e-e036292bcc65 --scope=one -b CN=Partitions,CN=Configuration,DC=release-4-1-0rc3,DC=samba,DC=corp msDS-NC-Replica-Locations >$tmpldif
+ diff -u $tmpldif $release_dir/expected-replica-locations-after-dbcheck2.ldif
+ if [ "$?" != "0" ]; then
+ return 1
+ fi
+ elif [ x$RELEASE = x"release-4-5-0-pre1" ]; then
+ echo $RELEASE checking after values
+ tmpldif=$PREFIX_ABS/$RELEASE/expected-links-after-dbcheck.ldif.tmp
+ $ldbsearch -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb --show-recycled --show-deleted --show-deactivated-link --reveal member memberOf lastKnownParent objectCategory lastKnownParent wellKnownObjects legacyExchangeDN sAMAccountType uSNChanged --sorted >$tmpldif
+ diff -u $tmpldif $release_dir/expected-links-after-dbcheck.ldif
+ if [ "$?" != "0" ]; then
+ return 1
+ fi
+
+ # If in the future dbcheck has to make a change recorded in replPropertyMetadata,
+ # this test will fail and can be removed.
+ tmpversion=$PREFIX_ABS/$RELEASE/rootdse-version.final.txt.tmp
+ TZ=UTC $ldbsearch -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb --scope=base -b '' | grep highestCommittedUSN >$tmpversion
+ diff -u $tmpversion $release_dir/rootdse-version.final.txt
+ if [ "$?" != "0" ]; then
+ return 1
+ fi
+ fi
+ return 0
+}
+
+check_forced_duplicate_values()
+{
+ if [ x$RELEASE = x"release-4-1-0rc3" ]; then
+ ldif=$release_dir/forced-duplicate-value-for-dbcheck.ldif
+ TZ=UTC $ldbmodify -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb.d/DC%3DRELEASE-4-1-0RC3,DC%3DSAMBA,DC%3DCORP.ldb $ldif
+ if [ "$?" != "0" ]; then
+ return 1
+ fi
+ else
+ return 0
+ fi
+}
+
+# This should 'fail', because it returns the number of modified records
+dbcheck_after_dup()
+{
+ if [ x$RELEASE = x"release-4-1-0rc3" ]; then
+ $PYTHON $BINDIR/samba-tool dbcheck --selftest-check-expired-tombstones --fix --yes -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb cn=administrator,cn=users,DC=release-4-1-0rc3,DC=samba,DC=corp "$@"
+ else
+ return 1
+ fi
+}
+
+check_expected_after_dup_values()
+{
+ if [ x$RELEASE = x"release-4-1-0rc3" ]; then
+ tmpldif=$PREFIX_ABS/$RELEASE/expected-otherphone-after-dbcheck.ldif.tmp
+ TZ=UTC $ldbsearch -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb cn=administrator --scope=base -b cn=administrator,cn=users,DC=release-4-1-0rc3,DC=samba,DC=corp otherHomePhone --sorted --show-binary | grep -v \# | sort >$tmpldif
+ diff -u $tmpldif $release_dir/expected-otherphone-after-dbcheck.ldif
+ if [ "$?" != "0" ]; then
+ return 1
+ fi
+ fi
+ return 0
+}
+
+# But having fixed it all up, this should pass
+dbcheck_clean()
+{
+ $PYTHON $BINDIR/samba-tool dbcheck --cross-ncs -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb "$@"
+}
+
+# This should 'fail', because it returns the number of modified records.
+# We need to run this against all versions without adprep 2016 (before Samba 4.19)
+dbcheck_acl_reset()
+{
+ $PYTHON $BINDIR/samba-tool dbcheck --reset-well-known-acls --cross-ncs --fix --yes -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb "$@"
+}
+# But having fixed it all up, this should pass.
+# We don't need to run this against 4.1.0rc3
+dbcheck_acl_reset_clean()
+{
+ if [ x$RELEASE != x"release-4-1-0rc3" ]; then
+ $PYTHON $BINDIR/samba-tool dbcheck --reset-well-known-acls --cross-ncs -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb "$@"
+ fi
+}
+
+# This should 'fail', because it returns the number of modified records
+dbcheck2()
+{
+ if [ x$RELEASE = x"release-4-1-0rc3" ]; then
+ $PYTHON $BINDIR/samba-tool dbcheck --selftest-check-expired-tombstones --cross-ncs --fix --yes -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb "$@"
+ else
+ exit 1
+ fi
+}
+# But having fixed it all up, this should pass
+dbcheck_clean2()
+{
+ if [ x$RELEASE = x"release-4-1-0rc3" ]; then
+ $PYTHON $BINDIR/samba-tool dbcheck --selftest-check-expired-tombstones --cross-ncs -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb "$@"
+ fi
+}
+
+rm_deleted_objects()
+{
+ if [ x$RELEASE = x"release-4-1-0rc3" ]; then
+ TZ=UTC $ldbdel -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb.d/DC%3DRELEASE-4-1-0RC3,DC%3DSAMBA,DC%3DCORP.ldb 'CN=Deleted Objects,DC=RELEASE-4-1-0RC3,DC=SAMBA,DC=CORP'
+ if [ "$?" != "0" ]; then
+ return 1
+ fi
+ else
+ return 0
+ fi
+}
+# This should 'fail', because it returns the number of modified records
+dbcheck3()
+{
+ if [ x$RELEASE = x"release-4-1-0rc3" ]; then
+ $PYTHON $BINDIR/samba-tool dbcheck --selftest-check-expired-tombstones --cross-ncs --fix --yes -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb "$@"
+ else
+ exit 1
+ fi
+}
+# But having fixed it all up, this should pass
+dbcheck_clean3()
+{
+ if [ x$RELEASE = x"release-4-1-0rc3" ]; then
+ $PYTHON $BINDIR/samba-tool dbcheck --selftest-check-expired-tombstones --cross-ncs -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb "$@"
+ fi
+}
+
+check_expected_after_deleted_objects()
+{
+ if [ x$RELEASE = x"release-4-1-0rc3" ]; then
+ tmpldif=$PREFIX_ABS/$RELEASE/expected-deleted_objects-after-dbcheck.ldif.tmp
+ TZ=UTC $ldbsearch -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb cn=deleted\ objects --scope=base -b cn=deleted\ objects,DC=release-4-1-0rc3,DC=samba,DC=corp objectClass description isDeleted isCriticalSystemObject objectGUID showInAdvancedViewOnly systemFlags --sorted --show-binary --show-deleted | grep -v \# | sort >$tmpldif
+ diff -u $tmpldif $release_dir/expected-deleted_objects-after-dbcheck.ldif
+ if [ "$?" != "0" ]; then
+ return 1
+ fi
+ fi
+ return 0
+}
+
+referenceprovision()
+{
+ if [ x$RELEASE = x"release-4-0-0" ]; then
+ $PYTHON $BINDIR/samba-tool domain provision --server-role="dc" --domain=SAMBA --host-name=ares --realm=${RELEASE}.samba.corp --targetdir=$PREFIX_ABS/${RELEASE}_reference --use-ntvfs --host-ip=127.0.0.1 --host-ip6=::1 --function-level=2003 --base-schema=2008_R2_old
+
+ # on top of this, also apply 2008R2 changes we accidentally missed in the past
+ $PYTHON $BINDIR/samba-tool domain schemaupgrade -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb --ldf-file=samba-4.7-missing-for-schema45.ldif,fix-forest-rev.ldf
+ fi
+}
+
+ldapcmp()
+{
+ if [ x$RELEASE = x"release-4-0-0" ]; then
+ $PYTHON $BINDIR/samba-tool ldapcmp tdb://$PREFIX_ABS/${RELEASE}_reference/private/sam.ldb tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb --two --skip-missing-dn --filter=dnsRecord,displayName,msDS-SupportedEncryptionTypes,servicePrincipalName
+ fi
+}
+
+ldapcmp_sd()
+{
+ if [ x$RELEASE = x"release-4-0-0" ]; then
+ $PYTHON $BINDIR/samba-tool ldapcmp tdb://$PREFIX_ABS/${RELEASE}_reference/private/sam.ldb tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb --two --sd --skip-missing-dn --filter=servicePrincipalName
+ fi
+}
+
+remove_directory $PREFIX_ABS/${RELEASE}_reference
+
+testit $RELEASE undump || failed=$(expr $failed + 1)
+testit "reindex" reindex || failed=$(expr $failed + 1)
+testit "current_version_mod" do_current_version_mod || failed=$(expr $failed + 1)
+testit "check_expected_before_values" check_expected_before_values || failed=$(expr $failed + 1)
+testit_expect_failure "dbcheck_deleted_objects" dbcheck_deleted_objects || failed=$(expr $failed + 1)
+testit_expect_failure "dbcheck_objectclass" dbcheck_objectclass || failed=$(expr $failed + 1)
+testit_expect_failure "dbcheck" dbcheck || failed=$(expr $failed + 1)
+testit "check_expected_after_values" check_expected_after_values || failed=$(expr $failed + 1)
+testit "check_forced_duplicate_values" check_forced_duplicate_values || failed=$(expr $failed + 1)
+testit_expect_failure "dbcheck_after_dup" dbcheck_after_dup || failed=$(expr $failed + 1)
+testit "check_expected_after_dup_values" check_expected_after_dup_values || failed=$(expr $failed + 1)
+testit "dbcheck_clean" dbcheck_clean || failed=$(expr $failed + 1)
+testit_expect_failure "dbcheck_acl_reset" dbcheck_acl_reset || failed=$(expr $failed + 1)
+testit "dbcheck_acl_reset_clean" dbcheck_acl_reset_clean || failed=$(expr $failed + 1)
+testit "add_userparameters0" add_userparameters1 || failed=$(expr $failed + 1)
+testit "add_userparameters1" add_userparameters1 || failed=$(expr $failed + 1)
+testit "add_userparameters2" add_userparameters2 || failed=$(expr $failed + 1)
+testit "add_userparameters3" add_userparameters3 || failed=$(expr $failed + 1)
+testit_expect_failure "dbcheck2" dbcheck2 || failed=$(expr $failed + 1)
+testit "dbcheck_clean2" dbcheck_clean2 || failed=$(expr $failed + 1)
+testit "check_expected_userparameters" check_expected_userparameters || failed=$(expr $failed + 1)
+testit "rm_deleted_objects" rm_deleted_objects || failed=$(expr $failed + 1)
+# We must re-index again because rm_deleted_objects went behind
+# the back of the main sam.ldb.
+testit "reindex2" reindex || failed=$(expr $failed + 1)
+testit_expect_failure "dbcheck3" dbcheck3 || failed=$(expr $failed + 1)
+testit "dbcheck_clean3" dbcheck_clean3 || failed=$(expr $failed + 1)
+testit "check_expected_after_deleted_objects" check_expected_after_deleted_objects || failed=$(expr $failed + 1)
+testit "referenceprovision" referenceprovision || failed=$(expr $failed + 1)
+testit "ldapcmp" ldapcmp || failed=$(expr $failed + 1)
+testit "ldapcmp_sd" ldapcmp_sd || failed=$(expr $failed + 1)
+
+if [ -d $PREFIX_ABS/${RELEASE} ]; then
+ rm -fr $PREFIX_ABS/${RELEASE}
+fi
+
+remove_directory $PREFIX_ABS/${RELEASE}_reference
+
+exit $failed
diff --git a/testprogs/blackbox/dbcheck.sh b/testprogs/blackbox/dbcheck.sh
new file mode 100755
index 0000000..0869a2b
--- /dev/null
+++ b/testprogs/blackbox/dbcheck.sh
@@ -0,0 +1,72 @@
+#!/bin/sh
+
+if [ $# -lt 1 ]; then
+ cat <<EOF
+Usage: dbcheck.sh PREFIX
+EOF
+ exit 1
+fi
+
+PREFIX="$1"
+shift 1
+ARGS=$@
+
+. $(dirname $0)/subunit.sh
+
+dbcheck()
+{
+ $PYTHON $BINDIR/samba-tool dbcheck --cross-ncs $ARGS
+}
+
+# This list of attributes can be freely extended
+dbcheck_fix_one_way_links()
+{
+ $PYTHON $BINDIR/samba-tool dbcheck --quiet --fix --yes fix_all_old_dn_string_component_mismatch --attrs="lastKnownParent defaultObjectCategory fromServer rIDSetReferences" --cross-ncs $ARGS
+}
+
+# This list of attributes can be freely extended
+dbcheck_fix_stale_links()
+{
+ $PYTHON $BINDIR/samba-tool dbcheck --quiet --fix --yes remove_plausible_deleted_DN_links --attrs="member msDS-NC-Replica-Locations msDS-NC-RO-Replica-Locations msDS-RevealOnDemandGroup msDS-NeverRevealGroup msDS-RevealedUsers" --cross-ncs $ARGS
+}
+
+# This list of attributes can be freely extended
+dbcheck_fix_crosspartition_backlinks()
+{
+ # we may not know the target yet when we receive a cross-partition link,
+ # which can result in a missing backlink
+ $PYTHON $BINDIR/samba-tool dbcheck --quiet --fix --yes fix_all_missing_backlinks --attrs="serverReference" --cross-ncs $ARGS
+}
+
+# This test shows that this does not do anything to a current
+# provision (that would be a bug)
+dbcheck_reset_well_known_acls()
+{
+ $PYTHON $BINDIR/samba-tool dbcheck --cross-ncs --reset-well-known-acls $ARGS
+}
+
+reindex()
+{
+ $PYTHON $BINDIR/samba-tool dbcheck --reindex $ARGS
+}
+
+fixed_attrs()
+{
+ $PYTHON $BINDIR/samba-tool dbcheck --attrs=cn $ARGS
+}
+
+force_modules()
+{
+ $PYTHON $BINDIR/samba-tool dbcheck --force-modules $ARGS
+}
+
+dbcheck_fix_one_way_links
+dbcheck_fix_stale_links
+dbcheck_fix_crosspartition_backlinks
+testit "dbcheck" dbcheck || failed=$(expr $failed + 1)
+testit "reindex" reindex || failed=$(expr $failed + 1)
+testit "fixed_attrs" fixed_attrs || failed=$(expr $failed + 1)
+testit "force_modules" force_modules || failed=$(expr $failed + 1)
+testit "reset_well_known_acls" dbcheck_reset_well_known_acls || failed=$(expr $failed + 1)
+
+exit $failed
diff --git a/testprogs/blackbox/demote-saveddb.sh b/testprogs/blackbox/demote-saveddb.sh
new file mode 100755
index 0000000..4af9e97
--- /dev/null
+++ b/testprogs/blackbox/demote-saveddb.sh
@@ -0,0 +1,77 @@
+#!/bin/sh
+
+if [ $# -lt 1 ]; then
+ cat <<EOF
+Usage: demote-saveddb.sh PREFIX RELEASE
+EOF
+ exit 1
+fi
+
+PREFIX_ABS="$1"
+shift 1
+
+failed=0
+
+. $(dirname $0)/subunit.sh
+. $(dirname $0)/common_test_fns.inc
+
+samba_tree_dir="$SRCDIR_ABS/source4/selftest/provisions/multi-dc-samba-master-c596ac6"
+
+samba_tdbrestore=$(system_or_builddir_binary tdbrestore "${BINDIR}")
+
+# The undump script and the provision data is not part of release tarballs,
+# skip the tests in this case!
+samba_undump="$SRCDIR_ABS/source4/selftest/provisions/undump.sh"
+if [ ! -x $samba_undump ] || [ ! -d $samba_tree_dir ]; then
+ subunit_start_test "undump"
+ subunit_skip_test "undump" <<EOF
+EOF
+
+ subunit_start_test "undump"
+ subunit_skip_test "undump" <<EOF
+Skipping tests - no provision!
+EOF
+
+ subunit_start_test "demote-q-0-0"
+ subunit_skip_test "demote-q-0-0" <<EOF
+Skipping tests - no provision!
+EOF
+ subunit_start_test "demote-q-0-1"
+ subunit_skip_test "demote-q-0-1" <<EOF
+Skipping tests - no provision!
+EOF
+ subunit_start_test "demote-q-1-0"
+ subunit_skip_test "demote-q-1-0" <<EOF
+Skipping tests - no provision!
+EOF
+ subunit_start_test "demote-q-1-1"
+ subunit_skip_test "demote-q-1-1" <<EOF
+Skipping tests - no provision!
+EOF
+
+ exit 0
+fi
+
+undump()
+{
+ $SRCDIR_ABS/source4/selftest/provisions/undump.sh $samba_tree_dir $PREFIX_ABS $samba_tdbrestore
+}
+
+demote()
+{
+ $PYTHON $BINDIR/samba-tool domain demote -H tdb://$PREFIX_ABS/private/sam.ldb --remove-other-dead-server=$1
+}
+
+remove_directory $PREFIX_ABS
+
+testit "undump" undump || failed=$(expr $failed + 1)
+testit "demote-q-0-0" demote "q-0-0" || failed=$(expr $failed + 1)
+# The database was copied of q-0-1 so this will fail
+# as we can't remove our own name
+testit_expect_failure "demote-q-0-1" demote "q-0-1" || failed=$(expr $failed + 1)
+testit "demote-q-1-0" demote "q-1-0" || failed=$(expr $failed + 1)
+testit "demote-q-1-1" demote "q-1-1" || failed=$(expr $failed + 1)
+
+remove_directory $PREFIX_ABS
+
+exit $failed
diff --git a/testprogs/blackbox/dfree.sh b/testprogs/blackbox/dfree.sh
new file mode 100755
index 0000000..893bc59
--- /dev/null
+++ b/testprogs/blackbox/dfree.sh
@@ -0,0 +1,8 @@
+#!/bin/sh
+if [ "$1" = "." ]; then
+ echo "1000 10 2048"
+elif [ "$1" = "subdir1" ]; then
+ echo "2000 20 4096"
+else
+ echo "4000 40 8192"
+fi
diff --git a/testprogs/blackbox/dom_parse.sh b/testprogs/blackbox/dom_parse.sh
new file mode 100755
index 0000000..8a22ce2
--- /dev/null
+++ b/testprogs/blackbox/dom_parse.sh
@@ -0,0 +1,27 @@
+#!/bin/sh
+# Blackbox wrapper for nsstest
+# Copyright (C) 2006-2007 Jelmer Vernooij <jelmer@samba.org>
+# Copyright (C) 2006-2008 Andrew Bartlett <abartlet@samba.org>
+
+if [ $# -lt 2 ]; then
+ cat <<EOF
+Usage: dom_parse.sh [id|getent] $USER
+EOF
+ exit 1
+fi
+
+USER=$2
+CMD=$1
+EXTRA=""
+shift 2
+failed=0
+
+. $(dirname $0)/subunit.sh
+
+if [ "$CMD" = "getent" ]; then
+ EXTRA="passwd"
+fi
+
+testit "samba4.winbind.dom_name_parse.cmd.$CMD" $CMD $EXTRA $USER || failed=$(expr $failed + 1)
+
+exit $failed
diff --git a/testprogs/blackbox/functionalprep.sh b/testprogs/blackbox/functionalprep.sh
new file mode 100755
index 0000000..94099f4
--- /dev/null
+++ b/testprogs/blackbox/functionalprep.sh
@@ -0,0 +1,183 @@
+#!/bin/sh
+
+if [ $# -lt 1 ]; then
+ cat <<EOF
+Usage: $0 PREFIX
+EOF
+ exit 1
+fi
+
+PREFIX_ABS="$1"
+shift 1
+
+failed=0
+
+. $(dirname $0)/subunit.sh
+. $(dirname $0)/common_test_fns.inc
+
+RELEASE="release-4-8-0-pre1"
+release_dir="$SRCDIR_ABS/source4/selftest/provisions/$RELEASE"
+
+OLD_RELEASE="release-4-1-0rc3"
+old_release_dir="$SRCDIR_ABS/source4/selftest/provisions/$OLD_RELEASE"
+
+samba_tdbrestore=$(system_or_builddir_binary tdbrestore "${BINDIR}")
+
+samba_undump="$SRCDIR_ABS/source4/selftest/provisions/undump.sh"
+
+if [ ! -x $samba_undump ] || [ ! -d $release_dir ] || [ ! -d $old_release_dir ]; then
+ subunit_start_test $RELEASE
+ subunit_skip_test $RELEASE <<EOF
+no test provision
+EOF
+
+ subunit_start_test "functional_prep"
+ subunit_skip_test "functional_prep" <<EOF
+no test provision
+EOF
+
+ subunit_start_test "functional_prep_old"
+ subunit_skip_test "functional_prep_old" <<EOF
+no test provision
+EOF
+
+ exit 0
+fi
+
+cleanup_output_directories()
+{
+ remove_directory $PREFIX_ABS/2012R2_schema
+ remove_directory $PREFIX_ABS/2019_schema
+ remove_directory $PREFIX_ABS/$RELEASE
+ remove_directory $PREFIX_ABS/$OLD_RELEASE
+}
+
+undump()
+{
+ $samba_undump $release_dir $PREFIX_ABS/$RELEASE $samba_tdbrestore
+}
+
+undump_old()
+{
+ $samba_undump $old_release_dir $PREFIX_ABS/$OLD_RELEASE $samba_tdbrestore
+}
+
+PROVISION_OPTS="--use-ntvfs --host-ip6=::1 --host-ip=127.0.0.1"
+
+provision_schema_2019_prep_skip()
+{
+ $PYTHON $BINDIR/samba-tool domain provision $PROVISION_OPTS --domain=REALM --realm=REALM.COM --targetdir=$PREFIX_ABS/2019_schema --base-schema=2019 --adprep-level=SKIP --host-name=FLPREP
+}
+
+provision_2012r2()
+{
+ $PYTHON $BINDIR/samba-tool domain provision $PROVISION_OPTS --domain=REALM --realm=REALM.COM --targetdir=$PREFIX_ABS/2012R2_schema --base-schema=2012_R2 --host-name=FLPREP
+}
+
+ldapcmp_ignore()
+{
+ # At some point we will need to ignore, but right now, it should be perfect
+ IGNORE_ATTRS=$1
+ $PYTHON $BINDIR/samba-tool ldapcmp tdb://$PREFIX_ABS/$2/private/sam.ldb tdb://$PREFIX_ABS/$3/private/sam.ldb --two --skip-missing-dn --filter msDS-SupportedEncryptionTypes,servicePrincipalName
+}
+
+ldapcmp()
+{
+ # Our functional prep doesn't set these values as they were not provided
+ # These are XML schema based enumerations which are used for claims
+ ldapcmp_ignore "msDS-ClaimPossibleValues" "$RELEASE" "2012R2_schema"
+}
+
+functional_prep_2016()
+{
+ $PYTHON $BINDIR/samba-tool domain functionalprep -H tdb://$PREFIX_ABS/2019_schema/private/sam.ldb --function-level=2016
+}
+
+level_raise_2012R2()
+{
+ $PYTHON $BINDIR/samba-tool domain level raise \
+ -H tdb://$PREFIX_ABS/2019_schema/private/sam.ldb \
+ --option="ad dc functional level = 2012_R2" \
+ --domain-level=2012_R2 --forest-level=2012_R2
+}
+
+level_raise_2016()
+{
+ $PYTHON $BINDIR/samba-tool domain level raise \
+ -H tdb://$PREFIX_ABS/2019_schema/private/sam.ldb \
+ --option="ad dc functional level = 2016" \
+ --domain-level=2016 --forest-level=2016
+}
+
+functional_prep_2012R2()
+{
+ $PYTHON $BINDIR/samba-tool domain functionalprep -H tdb://$PREFIX_ABS/2012R2_schema/private/sam.ldb --function-level=2012_R2
+}
+
+functional_prep_2012R2_old()
+{
+ $PYTHON $BINDIR/samba-tool domain functionalprep -H tdb://$PREFIX_ABS/$OLD_RELEASE/private/sam.ldb --function-level=2012_R2
+}
+
+functional_prep_2016_old()
+{
+ $PYTHON $BINDIR/samba-tool domain functionalprep -H tdb://$PREFIX_ABS/$OLD_RELEASE/private/sam.ldb --function-level=2016
+}
+
+steal_roles()
+{
+ # Must steal schema master and infrastructure roles first
+ $PYTHON $BINDIR/samba-tool fsmo seize --role=schema -H tdb://$PREFIX_ABS/$OLD_RELEASE/private/sam.ldb --force
+ $PYTHON $BINDIR/samba-tool fsmo seize --role=infrastructure -H tdb://$PREFIX_ABS/$OLD_RELEASE/private/sam.ldb --force
+}
+
+schema_upgrade_2012R2_old()
+{
+ $PYTHON $BINDIR/samba-tool domain schemaupgrade -H tdb://$PREFIX_ABS/$OLD_RELEASE/private/sam.ldb --schema=2012_R2
+}
+
+schema_upgrade_2019_old()
+{
+ $PYTHON $BINDIR/samba-tool domain schemaupgrade -H tdb://$PREFIX_ABS/$OLD_RELEASE/private/sam.ldb --schema=2019
+}
+
+# double-check we cleaned up from the last test run
+cleanup_output_directories
+
+testit $RELEASE undump || failed=$(expr $failed + 1)
+
+# Provision a DC based on 2012R2 schema
+testit "provision_2012R2_schema" provision_2012r2 || failed=$(expr $failed + 1)
+
+# Perform functional prep up to 2012 R2 level
+testit "functional_prep_2012R2" functional_prep_2012R2 || failed=$(expr $failed + 1)
+
+# check that the databases are now the same
+testit "check_databases_same" ldapcmp || failed=$(expr $failed + 1)
+
+testit $OLD_RELEASE undump_old || failed=$(expr $failed + 1)
+
+testit "steal_roles" steal_roles || failed=$(expr $failed + 1)
+
+testit "schema_upgrade_2012R2_old" schema_upgrade_2012R2_old || failed=$(expr $failed + 1)
+testit "functional_prep_2012R2_old" functional_prep_2012R2_old || failed=$(expr $failed + 1)
+
+testit "schema_upgrade_2019_old" schema_upgrade_2019_old || failed=$(expr $failed + 1)
+testit "functional_prep_2016_old" functional_prep_2016_old || failed=$(expr $failed + 1)
+
+cleanup_output_directories
+
+# Provision a DC based on 2019 schema
+testit "provision_schema_2019_prep_skip" provision_schema_2019_prep_skip || failed=$(expr $failed + 1)
+
+# Perform functional prep up to 2016 level
+testit "functional_prep_2016" functional_prep_2016 || failed=$(expr $failed + 1)
+
+# raise the levels to 2012_R2
+testit "level_raise_2012R2" level_raise_2012R2 || failed=$(expr $failed + 1)
+# raise the levels to 2016
+testit "level_raise_2016" level_raise_2016 || failed=$(expr $failed + 1)
+
+cleanup_output_directories
+
+exit $failed
diff --git a/testprogs/blackbox/join_ldapcmp.sh b/testprogs/blackbox/join_ldapcmp.sh
new file mode 100755
index 0000000..3e5b264
--- /dev/null
+++ b/testprogs/blackbox/join_ldapcmp.sh
@@ -0,0 +1,51 @@
+#!/bin/sh
+# Does a join against the testenv's DC and then runs ldapcmp on the resulting DB
+
+. $(dirname $0)/subunit.sh
+
+TARGET_DIR="$PREFIX_ABS/join_$SERVER"
+
+cleanup_output_dir()
+{
+ if [ -d $TARGET_DIR ]; then
+ rm -fr $TARGET_DIR
+ fi
+}
+
+SAMBA_TOOL="$PYTHON $BINDIR/samba-tool"
+
+join_dc()
+{
+ JOIN_ARGS="--targetdir=$TARGET_DIR --server=$SERVER -U$USERNAME%$PASSWORD"
+ $SAMBA_TOOL domain join $REALM dc $JOIN_ARGS --option="netbios name = TESTJOINDC"
+}
+
+demote_joined_dc()
+{
+ DEMOTE_ARGS="--remove-other-dead-server=TESTJOINDC --server=$SERVER -U$USERNAME%$PASSWORD"
+ $SAMBA_TOOL domain demote $DEMOTE_ARGS
+}
+
+ldapcmp_result()
+{
+ DB1_PATH="tdb://$PREFIX_ABS/$SERVER/private/sam.ldb"
+ DB2_PATH="tdb://$TARGET_DIR/private/sam.ldb"
+
+ # interSiteTopologyGenerator gets periodically updated. With the restored
+ # testenvs, it can sometimes point to the old/deleted DC object still
+ $SAMBA_TOOL ldapcmp $DB1_PATH $DB2_PATH --filter=interSiteTopologyGenerator
+}
+
+cleanup_output_dir
+
+# check that we can join this DC
+testit "check_dc_join" join_dc
+
+# check resulting DB matches server DC
+testit "new_db_matches" ldapcmp_result
+
+testit "demote_joined_dc" demote_joined_dc
+
+cleanup_output_dir
+
+exit $failed
diff --git a/testprogs/blackbox/ldapcmp_restoredc.sh b/testprogs/blackbox/ldapcmp_restoredc.sh
new file mode 100755
index 0000000..508b017
--- /dev/null
+++ b/testprogs/blackbox/ldapcmp_restoredc.sh
@@ -0,0 +1,73 @@
+#!/bin/sh
+# Does an ldapcmp between a newly restored testenv and the original testenv it
+# was based on
+
+if [ $# -lt 2 ]; then
+ cat <<EOF
+Usage: $0 ORIG_DC_PREFIX RESTORED_DC_PREFIX
+EOF
+ exit 1
+fi
+
+ORIG_DC_PREFIX_ABS="$1"
+RESTORED_DC_PREFIX_ABS="$2"
+shift 2
+
+. $(dirname $0)/subunit.sh
+. "$(dirname "${0}")/common_test_fns.inc"
+
+ldbsearch=$(system_or_builddir_binary ldbsearch "${BINDIR}")
+
+basedn()
+{
+ SAMDB_PATH=$1
+ ${ldbsearch} -H $SAMDB_PATH --basedn='' --scope=base defaultNamingContext | grep defaultNamingContext | awk '{print $2}'
+}
+
+ldapcmp_with_orig()
+{
+
+ DB1_PATH="tdb://$ORIG_DC_PREFIX_ABS/private/sam.ldb"
+ DB2_PATH="tdb://$RESTORED_DC_PREFIX_ABS/private/sam.ldb"
+
+ # check if the 2 DCs are in different domains
+ DC1_BASEDN=$(basedn $DB1_PATH)
+ DC2_BASEDN=$(basedn $DB2_PATH)
+ BASE_DN_OPTS=""
+
+ # if necessary, pass extra args to ldapcmp to handle the difference in base DNs
+ if [ "$DC1_BASEDN" != "$DC2_BASEDN" ]; then
+ BASE_DN_OPTS="--base=$DC1_BASEDN --base2=$DC2_BASEDN"
+ fi
+
+ # the restored DC will remove DNS entries for the old DC(s)
+ IGNORE_ATTRS="dnsRecord,dNSTombstoned"
+
+ # DC2 joined DC1, so it will have different DRS info
+ IGNORE_ATTRS="$IGNORE_ATTRS,msDS-NC-Replica-Locations,msDS-HasInstantiatedNCs"
+ IGNORE_ATTRS="$IGNORE_ATTRS,interSiteTopologyGenerator"
+
+ # there's a servicePrincipalName that uses the objectGUID of the DC's NTDS
+ # Settings that will differ between the two DCs
+ IGNORE_ATTRS="$IGNORE_ATTRS,servicePrincipalName"
+
+ # the restore changes the new DC's password twice
+ IGNORE_ATTRS="$IGNORE_ATTRS,lastLogonTimestamp"
+
+ # The RID pools get bumped during the restore process
+ IGNORE_ATTRS="$IGNORE_ATTRS,rIDAllocationPool,rIDAvailablePool"
+
+ # these are just differences between provisioning a domain and joining a DC
+ IGNORE_ATTRS="$IGNORE_ATTRS,localPolicyFlags,operatingSystem,displayName"
+
+ # the restored DC may use a different side compared to the original DC
+ IGNORE_ATTRS="$IGNORE_ATTRS,serverReferenceBL,msDS-IsDomainFor"
+
+ LDAPCMP_CMD="$PYTHON $BINDIR/samba-tool ldapcmp"
+ $LDAPCMP_CMD $DB1_PATH $DB2_PATH --two --skip-missing-dn --filter=$IGNORE_ATTRS $BASE_DN_OPTS
+}
+
+# check that the restored testenv DC basically matches the original
+testit "orig_dc_matches" ldapcmp_with_orig
+
+exit $failed
diff --git a/testprogs/blackbox/nsstest.sh b/testprogs/blackbox/nsstest.sh
new file mode 100755
index 0000000..6bf6705
--- /dev/null
+++ b/testprogs/blackbox/nsstest.sh
@@ -0,0 +1,22 @@
+#!/bin/sh
+# Blackbox wrapper for nsstest
+# Copyright (C) 2006-2007 Jelmer Vernooij <jelmer@samba.org>
+# Copyright (C) 2006-2008 Andrew Bartlett <abartlet@samba.org>
+
+if [ $# -lt 2 ]; then
+ cat <<EOF
+Usage: nsstest.sh NSSTEST LIBNSS_WINBIND
+EOF
+ exit 1
+fi
+
+nsstest=$1
+libnss_winbind=$2
+shift 2
+failed=0
+
+. $(dirname $0)/subunit.sh
+
+testit "run nsstest" $VALGRIND $nsstest $libnss_winbind || failed=$(expr $failed + 1)
+
+exit $failed
diff --git a/testprogs/blackbox/renamedc.sh b/testprogs/blackbox/renamedc.sh
new file mode 100755
index 0000000..fc32cad
--- /dev/null
+++ b/testprogs/blackbox/renamedc.sh
@@ -0,0 +1,103 @@
+#!/bin/sh
+
+if [ $# -lt 1 ]; then
+ cat <<EOF
+Usage: renamedc.sh PREFIX
+EOF
+ exit 1
+fi
+
+PREFIX="$1"
+shift 1
+
+. $(dirname $0)/subunit.sh
+. "$(dirname "${0}")/common_test_fns.inc"
+
+ldbsearch=$(system_or_builddir_binary ldbsearch "${BINDIR}")
+
+if [ ! -d $PREFIX/renamedc_test ]; then
+ mkdir -p $PREFIX/renamedc_test
+fi
+
+testprovision()
+{
+ $PYTHON $BINDIR/samba-tool domain provision --host-name=bar --domain=FOO --realm=foo.example.com --targetdir="$PREFIX/renamedc_test" --server-role="dc" --use-ntvfs
+}
+
+testrenamedc()
+{
+ $PYTHON $SRCDIR/source4/scripting/bin/renamedc \
+ --oldname="BAR" \
+ --newname="RAYMONBAR" \
+ --configfile=$PREFIX/renamedc_test/etc/smb.conf
+}
+
+confirmrenamedc()
+{
+ $ldbsearch -H $PREFIX/renamedc_test/private/sam.ldb --scope=base -b 'cn=RAYMONBAR,ou=domain controllers,dc=foo,dc=example,dc=com'
+}
+
+confirmrenamedc_server()
+{
+ $ldbsearch -H $PREFIX/renamedc_test/private/sam.ldb --scope=base -b 'cn=RAYMONBAR,CN=Servers,CN=Default-First-Site-Name,CN=Sites,CN=configuration,dc=foo,dc=example,dc=com'
+}
+
+confirmrenamedc_sAMAccountName()
+{
+ $ldbsearch -H $PREFIX/renamedc_test/private/sam.ldb --scope=base -b 'cn=RAYMONBAR,ou=domain controllers,dc=foo,dc=example,dc=com' sAMAccountName | grep 'sAMAccountName: RAYMONBAR\$'
+}
+
+confirmrenamedc_dNSHostName()
+{
+ $ldbsearch -H $PREFIX/renamedc_test/private/sam.ldb --scope=base -b 'cn=RAYMONBAR,ou=domain controllers,dc=foo,dc=example,dc=com' dNSHostName | grep 'dNSHostName: RAYMONBAR.foo.example.com'
+}
+
+confirmrenamedc_rootdse_dnsHostName()
+{
+ $ldbsearch -H $PREFIX/renamedc_test/private/sam.ldb --scope=base -b '' dNSHostName | grep 'dnsHostName: RAYMONBAR.foo.example.com'
+}
+
+confirmrenamedc_rootdse_dsServiceName()
+{
+ $ldbsearch -H $PREFIX/renamedc_test/private/sam.ldb --show-binary --scope=base -b '' dsServiceName | grep 'dsServiceName: CN=NTDS Settings,CN=RAYMONBAR,CN=Servers,CN=Default-First-Site-Name,CN=Sites,CN=Configuration,DC=foo,DC=example,DC=com'
+}
+
+testrenamedc2()
+{
+ $PYTHON $SRCDIR/source4/scripting/bin/renamedc \
+ --oldname="RAYMONBAR" \
+ --newname="BAR" \
+ --configfile=$PREFIX/renamedc_test/etc/smb.conf
+}
+
+dbcheck_fix()
+{
+ # Unlike most calls to dbcheck --fix, this will not trigger an error, as
+ # we do not flag an error count for this old DN string case.
+ $PYTHON $BINDIR/samba-tool dbcheck --cross-ncs --configfile=$PREFIX/renamedc_test/etc/smb.conf --fix \
+ --quiet --yes fix_all_old_dn_string_component_mismatch \
+ --attrs="fsmoRoleOwner interSiteTopologyGenerator msDS-NC-Replica-Locations"
+}
+
+dbcheck()
+{
+ $PYTHON $BINDIR/samba-tool dbcheck --cross-ncs --configfile=$PREFIX/renamedc_test/etc/smb.conf
+}
+
+testit "renameprovision" testprovision || failed=$(expr $failed + 1)
+testit "renamedc" testrenamedc || failed=$(expr $failed + 1)
+testit "confirmrenamedc" confirmrenamedc || failed=$(expr $failed + 1)
+testit "confirmrenamedc_server" confirmrenamedc_server || failed=$(expr $failed + 1)
+testit "confirmrenamedc_sAMAccountName" confirmrenamedc_sAMAccountName || failed=$(expr $failed + 1)
+testit "confirmrenamedc_dNSHostName" confirmrenamedc_dNSHostName || failed=$(expr $failed + 1)
+testit "confirmrenamedc_rootdse_dnsHostName" confirmrenamedc_rootdse_dnsHostName || failed=$(expr $failed + 1)
+testit "confirmrenamedc_rootdse_dsServiceName" confirmrenamedc_rootdse_dsServiceName || failed=$(expr $failed + 1)
+testit "dbcheck_fix" dbcheck_fix || failed=$(expr $failed + 1)
+testit "dbcheck" dbcheck || failed=$(expr $failed + 1)
+testit "renamedc2" testrenamedc2 || failed=$(expr $failed + 1)
+
+if [ $failed -eq 0 ]; then
+ rm -rf $PREFIX/renamedc_test
+fi
+
+exit $failed
diff --git a/testprogs/blackbox/runtime-links.sh b/testprogs/blackbox/runtime-links.sh
new file mode 100755
index 0000000..9cb49e4
--- /dev/null
+++ b/testprogs/blackbox/runtime-links.sh
@@ -0,0 +1,82 @@
+#!/bin/sh
+
+if [ $# -lt 1 ]; then
+ cat <<EOF
+Usage: runtime-links.sh PREFIX RELEASE
+EOF
+ exit 1
+fi
+
+PREFIX_ABS="$1"
+RELEASE="$2"
+shift 2
+
+failed=0
+
+. $(dirname $0)/subunit.sh
+
+. $(dirname $0)/common_test_fns.inc
+. $(dirname $0)/common-links.sh
+
+
+if [ ! -x $samba_undump ] || [ ! -d $release_dir ]; then
+ subunit_start_test $RELEASE
+ subunit_skip_test $RELEASE <<EOF
+no test provision
+EOF
+
+ subunit_start_test "tombstones_expunge"
+ subunit_skip_test "tombstones_expunge" <<EOF
+no test provision
+EOF
+
+ exit 0
+fi
+
+delete_member_of_deleted_group()
+{
+ TZ=UTC $ldbdel -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb 'CN=User1 UT. Tester,CN=Users,DC=release-4-5-0-pre1,DC=samba,DC=corp'
+ if [ "$?" != "0" ]; then
+ return 1
+ fi
+}
+
+delete_backlink_memberof_deleted_group()
+{
+ TZ=UTC $ldbdel -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb 'CN=User UT. Tester,CN=Users,DC=release-4-5-0-pre1,DC=samba,DC=corp'
+ if [ "$?" != "0" ]; then
+ return 1
+ fi
+}
+
+delete_dangling_backlink_memberof_group()
+{
+ TZ=UTC $ldbdel -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb 'CN=dangling-back,CN=Users,DC=release-4-5-0-pre1,DC=samba,DC=corp'
+ if [ "$?" != "0" ]; then
+ return 1
+ fi
+}
+
+remove_directory $PREFIX_ABS/${RELEASE}
+
+testit $RELEASE undump || failed=$(expr $failed + 1)
+testit "add_dangling_link" add_dangling_link || failed=$(expr $failed + 1)
+testit "add_dangling_backlink" add_dangling_backlink || failed=$(expr $failed + 1)
+testit "add_deleted_dangling_backlink" add_deleted_dangling_backlink || failed=$(expr $failed + 1)
+testit "revive_links_on_deleted_group" revive_links_on_deleted_group || failed=$(expr $failed + 1)
+testit "revive_backlink_on_deleted_group" revive_backlink_on_deleted_group || failed=$(expr $failed + 1)
+testit "add_deleted_target_link" add_deleted_target_link || failed=$(expr $failed + 1)
+testit "add_deleted_target_backlink" add_deleted_target_backlink || failed=$(expr $failed + 1)
+testit "dangling_one_way_link" dangling_one_way_link || failed=$(expr $failed + 1)
+testit "dangling_one_way_dn" dangling_one_way_dn || failed=$(expr $failed + 1)
+testit "deleted_one_way_dn" deleted_one_way_dn || failed=$(expr $failed + 1)
+testit "add_dangling_multi_valued" add_dangling_multi_valued || failed=$(expr $failed + 1)
+
+#Now things are set up, work with the DB
+testit "delete_member_of_deleted_group" delete_member_of_deleted_group || failed=$(expr $failed + 1)
+testit "delete_backlink_memberof_deleted_group" delete_backlink_memberof_deleted_group || failed=$(expr $failed + 1)
+testit "delete_dangling_backlink_memberof_group" delete_dangling_backlink_memberof_group || failed=$(expr $failed + 1)
+
+remove_directory $PREFIX_ABS/${RELEASE}
+
+exit $failed
diff --git a/testprogs/blackbox/schemaupgrade.sh b/testprogs/blackbox/schemaupgrade.sh
new file mode 100755
index 0000000..236a0bb
--- /dev/null
+++ b/testprogs/blackbox/schemaupgrade.sh
@@ -0,0 +1,131 @@
+#!/bin/sh
+
+if [ $# -lt 1 ]; then
+ cat <<EOF
+Usage: $0 PREFIX
+EOF
+ exit 1
+fi
+
+PREFIX_ABS="$1"
+shift 1
+
+. $(dirname $0)/subunit.sh
+
+cleanup_output_directories()
+{
+ if [ -d $PREFIX_ABS/2012R2_schema ]; then
+ rm -fr $PREFIX_ABS/2012R2_schema
+ fi
+
+ if [ -d $PREFIX_ABS/2008R2_schema ]; then
+ rm -fr $PREFIX_ABS/2008R2_schema
+ fi
+}
+
+PROVISION_OPTS="--use-ntvfs --host-ip6=::1 --host-ip=127.0.0.1"
+
+provision_2012r2()
+{
+ $PYTHON $BINDIR/samba-tool domain provision $PROVISION_OPTS --domain=SAMBA --realm=w2012r2.samba.corp --targetdir=$PREFIX_ABS/2012R2_schema --base-schema=2012_R2 --adprep-level=SKIP
+}
+
+provision_2008r2()
+{
+ $PYTHON $BINDIR/samba-tool domain provision $PROVISION_OPTS --domain=SAMBA --realm=w2008r2.samba.corp --targetdir=$PREFIX_ABS/2008R2_schema --base-schema=2008_R2
+}
+
+provision_2008r2_old()
+{
+ $PYTHON $BINDIR/samba-tool domain provision $PROVISION_OPTS --domain=SAMBA --realm=w2008r2.samba.corp --targetdir=$PREFIX_ABS/2008R2_old_schema --base-schema=2008_R2_old
+}
+
+ldapcmp_ignore()
+{
+
+ IGNORE_ATTRS=$1
+
+ # there's discrepancies between the SDDL strings in the adprep LDIF files
+ # vs the 2012 schema, where one source will have ACE rights repeated, e.g.
+ # "LOLO" in adprep vs "LO" in the schema
+ IGNORE_ATTRS="$IGNORE_ATTRS,defaultSecurityDescriptor"
+
+ # the adprep LDIF files updates these attributes for the DisplaySpecifiers
+ # objects, but we don't have the 2012 DisplaySpecifiers documentation...
+ IGNORE_ATTRS="$IGNORE_ATTRS,adminContextMenu,adminPropertyPages"
+
+ $PYTHON $BINDIR/samba-tool ldapcmp tdb://$PREFIX_ABS/$2_schema/private/sam.ldb tdb://$PREFIX_ABS/$3_schema/private/sam.ldb --two --filter=$IGNORE_ATTRS --skip-missing-dn
+}
+
+ldapcmp_old()
+{
+ # the original 2008 schema we received from Microsoft was missing
+ # descriptions and display names. This has been fixed up in the current
+ # Microsoft schemas
+ IGNORE_ATTRS="adminDescription,description,adminDisplayName,displayName"
+
+ # we didn't get showInAdvancedViewOnly right on Samba
+ IGNORE_ATTRS="$IGNORE_ATTRS,showInAdvancedViewOnly"
+
+ ldapcmp_ignore "$IGNORE_ATTRS" "2008R2_old" "2012R2"
+}
+
+ldapcmp()
+{
+ # The adminDescription and adminDisplayName have been editorially
+ # corrected in the 2012R2 schema but not in the adprep files.
+ ldapcmp_ignore "adminDescription,adminDisplayName" "2008R2" "2012R2"
+}
+
+ldapcmp_2008R2_2008R2_old()
+{
+ # the original 2008 schema we received from Microsoft was missing
+ # descriptions and display names. This has been fixed up in the current
+ # Microsoft schemas
+ IGNORE_ATTRS="adminDescription,description,adminDisplayName,displayName"
+
+ # we didn't get showInAdvancedViewOnly right on Samba
+ IGNORE_ATTRS="$IGNORE_ATTRS,showInAdvancedViewOnly"
+
+ ldapcmp_ignore $IGNORE_ATTRS "2008R2" "2008R2_old"
+}
+
+schema_upgrade()
+{
+ $PYTHON $BINDIR/samba-tool domain schemaupgrade -H tdb://$PREFIX_ABS/2008R2_schema/private/sam.ldb --schema=2012_R2
+}
+
+schema_upgrade_old()
+{
+ $PYTHON $BINDIR/samba-tool domain schemaupgrade -H tdb://$PREFIX_ABS/2008R2_old_schema/private/sam.ldb --schema=2012_R2
+}
+
+# double-check we cleaned up from the last test run
+cleanup_output_directories
+
+# Provision 2 DCs, one based on the 2008R2 schema and one using 2012R2
+testit "provision_2008R2_schema" provision_2008r2
+testit "provision_2008R2_old_schema" provision_2008r2_old
+testit "provision_2012R2_schema" provision_2012r2
+
+# we expect the 2 schemas to be different
+testit_expect_failure "expect_schema_differences" ldapcmp
+
+# check that the 2 schemas are now the same, ignoring Samba bugs
+testit "check_2008R2_2008R2_schemas_same" ldapcmp_2008R2_2008R2_old
+
+# upgrade the 2008 schema to 2012
+testit "schema_upgrade" schema_upgrade
+
+# check that the 2 schemas are now the same
+testit "check_schemas_same" ldapcmp
+
+# upgrade the 2008 schema to 2012
+testit "schema_upgrade_old" schema_upgrade_old
+
+# check that the 2 schemas are now the same, ignoring Samba bugs
+testit "check_schemas_same_old" ldapcmp_old
+
+cleanup_output_directories
+
+exit $failed
diff --git a/testprogs/blackbox/subunit.sh b/testprogs/blackbox/subunit.sh
new file mode 100755
index 0000000..0c27775
--- /dev/null
+++ b/testprogs/blackbox/subunit.sh
@@ -0,0 +1,212 @@
+#
+# subunit.sh: shell functions to report test status via the subunit protocol.
+# Copyright (C) 2006 Robert Collins <robertc@robertcollins.net>
+# Copyright (C) 2008 Jelmer Vernooij <jelmer@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
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+
+timestamp()
+{
+ # mark the start time. With Gnu date, you get nanoseconds from %N
+ # (here truncated to microseconds with %6N), but not on BSDs,
+ # Solaris, etc, which will apparently leave either %N or N at the end.
+ date -u +'time: %Y-%m-%d %H:%M:%S.%6NZ' | sed 's/\..*NZ$/.000000Z/'
+}
+
+subunit_start_test()
+{
+ # emit the current protocol start-marker for test $1
+ timestamp
+ printf 'test: %s\n' "$1"
+}
+
+subunit_pass_test()
+{
+ # emit the current protocol test passed marker for test $1
+ timestamp
+ printf 'success: %s\n' "$1"
+}
+
+# This is just a hack as we have some broken scripts
+# which use "exit $failed", without initializing failed.
+failed=0
+
+subunit_fail_test()
+{
+ # emit the current protocol fail-marker for test $1, and emit stdin as
+ # the error text.
+ # we use stdin because the failure message can be arbitrarily long, and this
+ # makes it convenient to write in scripts (using <<END syntax.
+ timestamp
+ printf 'failure: %s [\n' "$1"
+ cat -
+ printf '\n]\n'
+}
+
+subunit_error_test()
+{
+ # emit the current protocol error-marker for test $1, and emit stdin as
+ # the error text.
+ # we use stdin because the failure message can be arbitrarily long, and this
+ # makes it convenient to write in scripts (using <<END syntax.
+ timestamp
+ printf 'error: %s [\n' "$1"
+ cat -
+ printf '\n]\n'
+}
+
+subunit_skip_test()
+{
+ # emit the current protocol skip-marker for test $1, and emit stdin as
+ # the error text.
+ # we use stdin because the failure message can be arbitrarily long, and this
+ # makes it convenient to write in scripts (using <<END syntax.
+ printf 'skip: %s [\n' "$1"
+ cat -
+ printf '\n]\n'
+}
+
+testit()
+{
+ name="$1"
+ shift
+ cmdline="$*"
+ subunit_start_test "$name"
+ output=$($cmdline 2>&1)
+ status=$?
+ if [ ${status} -eq 0 ]; then
+ subunit_pass_test "$name"
+ else
+ echo "$output" | subunit_fail_test "$name"
+ fi
+ return $status
+}
+
+# This returns 0 if the command gave success and the grep value was found
+# all other cases return != 0
+testit_grep()
+{
+ name="$1"
+ shift
+ grep="$1"
+ shift
+ cmdline="$*"
+ subunit_start_test "$name"
+ output=$($cmdline 2>&1)
+ status=$?
+ if [ ${status} -ne 0 ]; then
+ printf '%s' "$output" | subunit_fail_test "$name"
+ return $status
+ fi
+ printf '%s' "$output" | grep -q "$grep"
+ gstatus=$?
+ if [ ${gstatus} -eq 0 ]; then
+ subunit_pass_test "$name"
+ else
+ printf 'GREP: "%s" not found in output:\n%s' "$grep" "$output" | subunit_fail_test "$name"
+ fi
+ return $gstatus
+}
+
+# This returns 0 if the command gave success and the grep value was found
+# num times all other cases return != 0
+testit_grep_count()
+{
+ name="$1"
+ shift
+ grep="$1"
+ shift
+ num="$1"
+ shift
+ cmdline="$*"
+ subunit_start_test "$name"
+ output=$($cmdline 2>&1)
+ status=$?
+ if [ ${status} -ne 0 ]; then
+ printf '%s' "$output" | subunit_fail_test "$name"
+ return $status
+ fi
+ found=$(printf '%s' "$output" | grep -c "$grep")
+ if [ "${found}" -eq "$num" ]; then
+ subunit_pass_test "$name"
+ else
+ printf 'GREP: "%s" found "%d" times, expected "%d" in output:\n%s'\
+ "$grep" "$found" "$num" "$output" |
+ subunit_fail_test "$name"
+ return 1
+ fi
+ return 0
+}
+
+testit_expect_failure()
+{
+ name="$1"
+ shift
+ cmdline="$*"
+ subunit_start_test "$name"
+ output=$($cmdline 2>&1)
+ status=$?
+ if [ ${status} = 0 ]; then
+ echo "$output" | subunit_fail_test "$name"
+ return 1
+ else
+ subunit_pass_test "$name"
+ return 0
+ fi
+}
+
+# This returns 0 if the command gave a failure and the grep value was found
+# all other cases return != 0
+testit_expect_failure_grep()
+{
+ name="$1"
+ shift
+ grep="$1"
+ shift
+ cmdline="$*"
+ subunit_start_test "$name"
+ output=$($cmdline 2>&1)
+ status=$?
+ if [ ${status} -eq 0 ]; then
+ printf '%s' "$output" | subunit_fail_test "$name"
+ return 1
+ fi
+ printf '%s' "$output" | grep -q "$grep"
+ gstatus=$?
+ if [ ${gstatus} -eq 0 ]; then
+ subunit_pass_test "$name"
+ else
+ printf 'GREP: "%s" not found in output:\n%s' "$grep" "$output" | subunit_fail_test "$name"
+ return 1
+ fi
+ return 0
+}
+
+testok()
+{
+ name=$(basename $1)
+ failed=$2
+
+ exit $failed
+}
+
+# work out the top level source directory
+if [ -d source4 ]; then
+ SRCDIR="."
+else
+ SRCDIR=".."
+fi
+export SRCDIR
diff --git a/testprogs/blackbox/test_alias_membership.sh b/testprogs/blackbox/test_alias_membership.sh
new file mode 100755
index 0000000..510940a
--- /dev/null
+++ b/testprogs/blackbox/test_alias_membership.sh
@@ -0,0 +1,194 @@
+#!/bin/bash
+
+if [ $# -lt 1 ]; then
+ cat <<EOF
+Usage: test_alias_membership.sh PREFIX
+EOF
+ exit 1
+fi
+
+PREFIX=$1
+ADDC_CONFIGFILE="$PREFIX/ad_dc/etc/smb.conf"
+shift 5
+failed=0
+
+. "$(dirname "$0")/subunit.sh"
+. "$(dirname "$0")/common_test_fns.inc"
+
+net_tool="${BINDIR}/net"
+wbinfo="${BINDIR}/wbinfo"
+
+# Create the following membership structure and test if exactly the 9 users
+# are listed as members of the alias A1.
+#
+# A1
+# |- A1U1
+# |- A1U2
+# |
+# |- G1
+# | |- G1U1
+# | |- G1U2
+# |
+# |- G2
+# | |- G2U1
+# | |- G2U2
+# | |
+# | |- G3
+# | |- G3U1
+# | |- G3U2
+# |
+# |- LG1
+# |- user1
+#
+#
+# Local entities:
+#
+# Alias: A1
+# Group: LG1
+# User: user1 (no need to create, already available)
+#
+# Domain entities:
+#
+# Group: ADDOMAIN/G1 ADDOMAIN/G2 ADDOMAIN/G3
+# User: ADDOMAIN/A1U1 ADDOMAIN/A1U2
+# ADDOMAIN/G1U1 ADDOMAIN/G1U2
+# ADDOMAIN/G2U1 ADDOMAIN/G2U2
+# ADDOMAIN/G3U1 ADDOMAIN/G3U2
+
+
+LOCALPREFIX="IDMAPRIDMEMBER"
+
+function create_group() {
+ _group_name="${1}"
+ GNUPGHOME="${PREFIX}/ad_dc/gnupg" "${PYTHON}" "${BINDIR}/samba-tool" \
+ group add "${_group_name}" --configfile="${ADDC_CONFIGFILE}"
+ _ret=$?
+ if [ ${_ret} -ne 0 ]; then
+ echo "Failed to create group ${_group_name}"
+ return 1
+ fi
+ return 0
+}
+
+function delete_group() {
+ _group_name="${1}"
+ GNUPGHOME="${PREFIX}/ad_dc/gnupg" "${PYTHON}" "${BINDIR}/samba-tool" \
+ group delete "${_group_name}" --configfile="${ADDC_CONFIGFILE}"
+ _ret=$?
+ if [ ${_ret} -ne 0 ]; then
+ echo "Failed to delete group ${_group_name}"
+ return 1
+ fi
+ return 0
+}
+
+function create_user() {
+ _user_name="${1}"
+ _password="${2}"
+ GNUPGHOME="${PREFIX}/ad_dc/gnupg" "${PYTHON}" "${BINDIR}/samba-tool" \
+ user create "${_user_name}" "${_password}" \
+ --configfile="${ADDC_CONFIGFILE}"
+ _ret=$?
+ if [ ${_ret} -ne 0 ]; then
+ echo "Failed to create user ${_user_name}"
+ return 1
+ fi
+ return 0
+}
+
+function delete_user() {
+ _user_name="${1}"
+ GNUPGHOME="${PREFIX}/ad_dc/gnupg" "${PYTHON}" "${BINDIR}/samba-tool" \
+ user delete "${_user_name}" --configfile="${ADDC_CONFIGFILE}"
+ _ret=$?
+ if [ ${_ret} -ne 0 ]; then
+ echo "Failed to delete user ${_user_name}"
+ return 1
+ fi
+ return 0
+}
+
+for G in G1 G2 G3
+do
+ testit "create group '$G'" create_group "${G}" || failed=$((failed + 1))
+done
+
+for U in G1U1 G1U2 G2U1 G2U2 G3U1 G3U2 A1U1 A1U2
+do
+ testit "create user '$U'" create_user "${U}" Passw0rd.7 || failed=$((failed + 1))
+done
+
+while read -a line
+do
+ group=${line[0]}
+ member=${line[1]}
+ testit "add member '$member' to group '$group'" "$PYTHON" "$BINDIR/samba-tool" group addmembers --configfile="$ADDC_CONFIGFILE" "$group" "$member" || failed=$((failed + 1))
+done <<___MEMBERS
+G1 G1U1
+G1 G1U2
+G2 G2U1
+G2 G2U2
+G2 G3
+G3 G3U1
+G3 G3U2
+___MEMBERS
+
+testit "net sam createlocalgroup A1" "$VALGRIND" "$net_tool" sam createlocalgroup A1 || failed=$((failed + 1))
+testit "net createdomaingroup LG1" "$VALGRIND" "$net_tool" sam createdomaingroup LG1 || failed=$((failed + 1))
+testit "net sam addmem user1 to LG1" "$VALGRIND" "$net_tool" sam addmem LG1 "${LOCALPREFIX}\user1" || failed=$((failed + 1))
+
+for M in "ADDOMAIN\A1U1" "ADDOMAIN\A1U2" "ADDOMAIN\G1" "ADDOMAIN\G2" "${LOCALPREFIX}\LG1"
+do
+ testit "net sam addmem $M to A1" "$VALGRIND" "$net_tool" sam addmem A1 "$M" || failed=$((failed + 1))
+done
+
+# do not use testit_grep (that would call 9 times wbinfo) but use grep on the
+# stored output
+a1_alias=$( "$wbinfo" --group-info A1 )
+
+for U in ADDOMAIN/a1u1 "${LOCALPREFIX}/user1" ADDOMAIN/g1u1 ADDOMAIN/g1u2 ADDOMAIN/g2u1 ADDOMAIN/g2u2 ADDOMAIN/g3u1 ADDOMAIN/g3u2 ADDOMAIN/a1u2;
+do
+ count=$(echo "$a1_alias" | grep -c "$U")
+ testit "User $U is in alias" test "$count" -eq 1 || failed=$((failed + 1))
+done
+
+# check that there are exactly 8 commas separating the 9 users
+count=$(echo "$a1_alias" | grep -o , | wc -l)
+testit "There are 9 users" test "$count" -eq 8 || failed=$((failed + 1))
+
+# cleanup
+
+for M in "ADDOMAIN\A1U1" "ADDOMAIN\A1U2" "ADDOMAIN\G1" "ADDOMAIN\G2" "${LOCALPREFIX}\LG1"
+do
+ testit "net sam delmem $M from A1" "$VALGRIND" "$net_tool" sam delmem A1 "$M" || failed=$((failed + 1))
+done
+testit "net sam delmem user1 from LG1" "$VALGRIND" "$net_tool" sam delmem LG1 "${LOCALPREFIX}\user1" || failed=$((failed + 1))
+testit "net sam deletelocalgroup A1" "$VALGRIND" "$net_tool" sam deletelocalgroup A1 || failed=$((failed + 1))
+testit "net sam deletedomaingroup LG1" "$VALGRIND" "$net_tool" sam deletedomaingroup LG1 || failed=$((failed + 1))
+
+while read -a line
+do
+ group=${line[0]}
+ member=${line[1]}
+ testit "del member '$member' from group '$group'" "$PYTHON" "$BINDIR/samba-tool" group removemembers --configfile="$ADDC_CONFIGFILE" "$group" "$member" || failed=$((failed + 1))
+done <<___MEMBERS
+G1 G1U1
+G1 G1U2
+G2 G2U1
+G2 G2U2
+G2 G3
+G3 G3U1
+G3 G3U2
+___MEMBERS
+
+for G in G1 G2 G3
+do
+ testit "delete group '$G'" delete_group "${G}" || failed=$((failed + 1))
+done
+
+for U in G1U1 G1U2 G2U1 G2U2 G3U1 G3U2 A1U1 A1U2
+do
+ testit "delete user '$U'" delete_user "${U}" || failed=$((failed + 1))
+done
+
+exit $failed
diff --git a/testprogs/blackbox/test_chgdcpass.sh b/testprogs/blackbox/test_chgdcpass.sh
new file mode 100755
index 0000000..ad1894e
--- /dev/null
+++ b/testprogs/blackbox/test_chgdcpass.sh
@@ -0,0 +1,115 @@
+#!/bin/sh
+# Blackbox tests for kinit and kerberos integration with smbclient etc
+# Copyright (C) 2006-2007 Jelmer Vernooij <jelmer@samba.org>
+# Copyright (C) 2006-2008 Andrew Bartlett <abartlet@samba.org>
+
+if [ $# -lt 4 ]; then
+ cat <<EOF
+Usage: test_chgdcpass.sh SERVER USERNAME REALM DOMAIN PREFIX ENCTYPE PROVDIR SMBCLIENT
+EOF
+ exit 1
+fi
+
+SERVER=$1
+USERNAME=$2
+REALM=$3
+DOMAIN=$4
+PREFIX=$5
+ENCTYPE=$6
+PROVDIR=$7
+smbclient=$8
+shift 8
+failed=0
+
+samba4bindir="$BINDIR"
+samba4srcdir="$SRCDIR/source4"
+
+samba4kinit_binary=kinit
+heimdal=0
+if test -x $BINDIR/samba4kinit; then
+ heimdal=1
+ samba4kinit_binary=bin/samba4kinit
+fi
+
+machineaccountccache="$samba4srcdir/scripting/bin/machineaccountccache"
+
+unc="//$SERVER/tmp"
+
+. $(dirname $0)/subunit.sh
+. $(dirname $0)/common_test_fns.inc
+
+test_drs()
+{
+ function="$1"
+ name="$2"
+ shift
+ shift
+ echo "test: $name"
+ echo $VALGRIND $PYTHON $samba4bindir/samba-tool drs $function $SERVER -k yes "$@"
+ $VALGRIND $PYTHON $samba4bindir/samba-tool drs $function $SERVER -k yes "$@"
+ status=$?
+ if [ x$status = x0 ]; then
+ echo "success: $name"
+ else
+ echo "failure: $name"
+ fi
+ return $status
+}
+
+enctype="-e $ENCTYPE"
+
+KRB5CCNAME="$PREFIX/tmpccache"
+samba4kinit="$samba4kinit_binary -c $KRB5CCNAME"
+export KRB5CCNAME
+rm -f $KRB5CCNAME
+
+if [ $heimdal -eq 1 ]; then
+ testit "kinit with keytab" $samba4kinit $enctype -t $PROVDIR/private/secrets.keytab --use-keytab $USERNAME || failed=$(expr $failed + 1)
+else
+ testit "kinit with keytab" $samba4kinit -k -t $PROVDIR/private/secrets.keytab $USERNAME || failed=$(expr $failed + 1)
+fi
+
+#This is important because it puts the ticket for the old KVNO and password into a local ccache
+test_smbclient "Test login with kerberos ccache before password change" 'ls' "$unc" --use-krb5-ccache=$KRB5CCNAME || failed=$(expr $failed + 1)
+
+#check that drs bind works before we change the password (prime the ccache)
+test_drs bind "Test drs bind with with kerberos ccache" || failed=$(expr $failed + 1)
+
+#check that drs options works before we change the password (prime the ccache)
+test_drs options "Test drs options with with kerberos ccache" || failed=$(expr $failed + 1)
+
+testit "change dc password" $PYTHON $samba4srcdir/scripting/devel/chgtdcpass --configfile=$PROVDIR/etc/smb.conf || failed=$(expr $failed + 1)
+
+#This is important because it shows that the old ticket remains valid (as it must) for incoming connections after the DC password is changed
+test_smbclient "Test login with kerberos ccache after password change" 'ls' "$unc" --use-krb5-ccache=$KRB5CCNAME || failed=$(expr $failed + 1)
+
+#check that drs bind works after we change the password
+test_drs bind "Test drs bind with new password" || failed=$(expr $failed + 1)
+
+#check that drs options works after we change the password
+test_drs options "Test drs options with new password" || failed=$(expr $failed + 1)
+
+testit "change dc password (2nd time)" $PYTHON $samba4srcdir/scripting/devel/chgtdcpass --configfile=$PROVDIR/etc/smb.conf || failed=$(expr $failed + 1)
+
+# This is important because it shows that the old ticket is discarded if the server rejects it (as it must) after the password was changed twice in succession.
+# This also ensures we handle the case where the domain is re-provisioned etc
+test_smbclient "Test login with kerberos ccache after 2nd password change" 'ls' "$unc" --use-krb5-ccache=$KRB5CCNAME || failed=$(expr $failed + 1)
+
+#check that drs bind works after we change the password a 2nd time
+test_drs bind "Test drs bind after 2nd password change" || failed=$(expr $failed + 1)
+
+#check that drs options works after we change the password a 2nd time
+test_drs options "Test drs options after 2nd password change" || failed=$(expr $failed + 1)
+
+#This confirms that the DC password is valid for a kinit too
+if [ $heimdal -eq 1 ]; then
+ testit "kinit with keytab" $samba4kinit $enctype -t $PROVDIR/private/secrets.keytab --use-keytab $USERNAME || failed=$(expr $failed + 1)
+else
+ testit "kinit with keytab" $samba4kinit -k -t $PROVDIR/private/secrets.keytab $USERNAME || failed=$(expr $failed + 1)
+fi
+test_smbclient "Test login with kerberos ccache with fresh kinit" 'ls' "$unc" --use-krb5-ccache=$KRB5CCNAME || failed=$(expr $failed + 1)
+
+rm -f $KRB5CCNAME
+
+rm -f $PREFIX/tmpccache tmpccfile tmppassfile tmpuserpassfile tmpuserccache
+exit $failed
diff --git a/testprogs/blackbox/test_client_etypes.sh b/testprogs/blackbox/test_client_etypes.sh
new file mode 100755
index 0000000..0389cb3
--- /dev/null
+++ b/testprogs/blackbox/test_client_etypes.sh
@@ -0,0 +1,82 @@
+if [ $# -lt 6 ]; then
+ cat <<EOF
+Usage: test_client_etypes.sh DC_SERVER DC_USERNAME DC_PASSWORD PREFIX_ABS ETYPE_CONF EXPECTED
+EOF
+ exit 1
+fi
+
+DC_SERVER=$1
+DC_USERNAME=$2
+DC_PASSWORD=$3
+BASEDIR=$4
+ETYPE_CONF=$5
+EXPECTED_ETYPES="$6"
+
+# Load test functions
+. $(dirname $0)/subunit.sh
+
+KRB5CCNAME_PATH="$PREFIX/test_client_etypes_krb5ccname"
+rm -f $KRB5CCNAME_PATH
+
+KRB5CCNAME="FILE:$KRB5CCNAME_PATH"
+export KRB5CCNAME
+
+#requires tshark and sha1sum
+if ! which tshark >/dev/null 2>&1 || ! which sha1sum >/dev/null 2>&1; then
+ subunit_start_test "client encryption types"
+ subunit_skip_test "client encryption types" <<EOF
+Skipping tests - tshark or sha1sum not installed
+EOF
+ exit 0
+fi
+
+HOSTNAME=$(dd if=/dev/urandom bs=1 count=32 2>/dev/null | sha1sum | cut -b 1-10)
+
+RUNDIR=$(pwd)
+cd $BASEDIR
+WORKDIR=$(mktemp -d -p .)
+WORKDIR=$(basename $WORKDIR)
+cp -a client/* $WORKDIR/
+sed -ri "s@(dir|directory) = (.*)/client/@\1 = \2/$WORKDIR/@" $WORKDIR/client.conf
+sed -ri "s/netbios name = .*/netbios name = $HOSTNAME/" $WORKDIR/client.conf
+rm -f $WORKDIR/private/secrets.tdb
+cd $RUNDIR
+
+failed=0
+
+net_tool="$BINDIR/net --configfile=$BASEDIR/$WORKDIR/client.conf --option=security=ads --option=kerberosencryptiontypes=$ETYPE_CONF"
+pcap_file=$BASEDIR/$WORKDIR/test.pcap
+
+export SOCKET_WRAPPER_PCAP_FILE=$pcap_file
+testit "join" $VALGRIND $net_tool ads join -U$DC_USERNAME%$DC_PASSWORD --use-kerberos=required || failed=$(expr $failed + 1)
+
+testit "testjoin" $VALGRIND $net_tool ads testjoin -P --use-kerberos=required || failed=$(expr $failed + 1)
+
+#The leave command does not use the locally-generated
+#krb5.conf
+export SOCKET_WRAPPER_PCAP_FILE=
+testit "leave" $VALGRIND $net_tool ads leave -U$DC_USERNAME%$DC_PASSWORD || failed=$(expr $failed + 1)
+
+#
+# Older versions of tshark do not support -Y option,
+# They use -R which cannot be used with recent versions...
+#
+if ! tshark -r $pcap_file -nVY "kerberos" >/dev/null 2>&1; then
+ subunit_start_test "client encryption types"
+ subunit_skip_test "client encryption types" <<EOF
+Skipping tests - old version of tshark detected
+EOF
+ exit 0
+fi
+
+actual_types="$(tshark -r $pcap_file -nVY "kerberos" |
+ sed -rn -e 's/[[:space:]]*ENCTYPE:.*\(([^\)]*)\)$/\1/p' \
+ -e 's/[[:space:]]*Encryption type:.*\(([^\)]*)\)$/\1/p' |
+ sort -u | tr '\n' '_' | sed s/_$//)"
+
+testit "verify types" test "x$actual_types" = "x$EXPECTED_ETYPES" || failed=$(expr $failed + 1)
+
+rm -rf $BASEDIR/$WORKDIR
+rm -f $KRB5CCNAME_PATH
+
+exit $failed
diff --git a/testprogs/blackbox/test_client_kerberos.sh b/testprogs/blackbox/test_client_kerberos.sh
new file mode 100755
index 0000000..54554ea
--- /dev/null
+++ b/testprogs/blackbox/test_client_kerberos.sh
@@ -0,0 +1,286 @@
+#!/bin/sh
+# Blackbox tests for kerberos client options
+# Copyright (c) 2019 Andreas Schneider <asn@samba.org>
+
+if [ $# -lt 6 ]; then
+ cat <<EOF
+Usage: test_client_kerberos.sh DOMAIN REALM USERNAME PASSWORD SERVER PREFIX CONFIGURATION
+EOF
+ exit 1
+fi
+
+DOMAIN=$1
+REALM=$2
+USERNAME=$3
+PASSWORD=$4
+SERVER=$5
+PREFIX=$6
+CONFIGURATION=$7
+shift 7
+
+failed=0
+
+. $(dirname $0)/subunit.sh
+. $(dirname $0)/common_test_fns.inc
+
+samba_bindir="$BINDIR"
+samba_rpcclient="$samba_bindir/rpcclient"
+samba_smbclient="$samba_bindir/smbclient"
+samba_smbtorture="$samba_bindir/smbtorture"
+
+samba_kinit=$(system_or_builddir_binary kinit "${BINDIR}" samba4kinit)
+samba_kdestroy=$(system_or_builddir_binary kdestroy "${BINDIR}" samba4kdestroy)
+
+test_rpc_getusername()
+{
+ eval echo "$cmd"
+ out=$(eval $cmd)
+ ret=$?
+ if [ $ret -ne 0 ]; then
+ echo "Failed to connect! Error: $ret"
+ echo "$out"
+ return 1
+ fi
+
+ echo "$out" | grep -q "Account Name: $USERNAME, Authority Name: $DOMAIN"
+ ret=$?
+ if [ $ret -ne 0 ]; then
+ echo "Incorrect account/authority name! Error: $ret"
+ echo "$out"
+ return 1
+ fi
+
+ return 0
+}
+
+test_smbclient()
+{
+ eval echo "$cmd"
+ out=$(eval $cmd)
+ ret=$?
+ if [ $ret -ne 0 ]; then
+ echo "Failed to connect! Error: $ret"
+ echo "$out"
+ fi
+
+ return $ret
+}
+
+test_smbclient_kerberos()
+{
+ eval echo "$cmd -d5"
+ out=$(eval $cmd)
+ ret=$?
+ if [ $ret -ne 0 ]; then
+ echo "Failed to connect! Error: $ret"
+ echo "$out"
+ return 1
+ fi
+
+ echo "$out" | grep "Doing init for" >/dev/null 2>&1
+ ret=$?
+ if [ $ret -eq 0 ]; then
+ echo "Kinit failed for smbclient"
+ echo "$out"
+ return 1
+ fi
+
+ return 0
+}
+
+KRB5CCNAME_PATH="$PREFIX/ccache_client_kerberos"
+KRB5CCNAME="FILE:$KRB5CCNAME_PATH"
+export KRB5CCNAME
+
+### RPCCLIENT (legacy)
+cmd='$samba_rpcclient ncacn_np:${SERVER} -U${USERNAME}%${PASSWORD} --configfile=${CONFIGURATION} -c getusername 2>&1'
+testit "test rpcclient legacy ntlm" \
+ test_rpc_getusername ||
+ failed=$(expr $failed + 1)
+
+cmd='echo ${PASSWORD} | USER=${USERNAME} $samba_rpcclient ncacn_np:${SERVER} --configfile=${CONFIGURATION} -c getusername 2>&1'
+testit "test rpcclient legacy ntlm interactive" \
+ test_rpc_getusername ||
+ failed=$(expr $failed + 1)
+
+cmd='echo ${PASSWORD} | $samba_rpcclient ncacn_np:${SERVER} -U${USERNAME} --configfile=${CONFIGURATION} -c getusername 2>&1'
+testit "test rpcclient legacy ntlm interactive with -U" \
+ test_rpc_getusername ||
+ failed=$(expr $failed + 1)
+
+cmd='$samba_rpcclient ncacn_np:${SERVER} -U${USERNAME}%${PASSWORD} -k --configfile=${CONFIGURATION} -c getusername 2>&1'
+testit "test rpcclient legacy kerberos" \
+ test_rpc_getusername ||
+ failed=$(expr $failed + 1)
+
+cmd='echo ${PASSWORD} | $samba_rpcclient ncacn_np:${SERVER} -U${USERNAME} -k --configfile=${CONFIGURATION} -c getusername 2>&1'
+testit_expect_failure "test rpcclient legacy kerberos interactive (negative test)" \
+ test_rpc_getusername ||
+ failed=$(expr $failed + 1)
+
+kerberos_kinit $samba_kinit ${USERNAME}@${REALM} ${PASSWORD}
+cmd='$samba_rpcclient ncacn_np:${SERVER} -k --configfile=${CONFIGURATION} -c getusername 2>&1'
+testit "test rpcclient legacy kerberos ccache" \
+ test_rpc_getusername ||
+ failed=$(expr $failed + 1)
+$samba_kdestroy
+
+### RPCCLIENT
+cmd='$samba_rpcclient ncacn_np:${SERVER} -U${USERNAME}%${PASSWORD} --use-kerberos=disabled --configfile=${CONFIGURATION} -c getusername 2>&1'
+testit "test rpcclient ntlm" \
+ test_rpc_getusername ||
+ failed=$(expr $failed + 1)
+
+cmd='echo ${PASSWORD} | USER=${USERNAME} $samba_rpcclient ncacn_np:${SERVER} --use-kerberos=disabled --configfile=${CONFIGURATION} -c getusername 2>&1'
+testit "test rpcclient ntlm interactive" \
+ test_rpc_getusername ||
+ failed=$(expr $failed + 1)
+
+cmd='echo ${PASSWORD} | $samba_rpcclient ncacn_np:${SERVER} -U${USERNAME} --use-kerberos=disabled --configfile=${CONFIGURATION} -c getusername 2>&1'
+testit "test rpcclient ntlm interactive with -U" \
+ test_rpc_getusername ||
+ failed=$(expr $failed + 1)
+
+cmd='$samba_rpcclient ncacn_np:${SERVER} -U${USERNAME}%${PASSWORD} --use-kerberos=required --configfile=${CONFIGURATION} -c getusername 2>&1'
+testit "test rpcclient kerberos" \
+ test_rpc_getusername ||
+ failed=$(expr $failed + 1)
+
+cmd='echo ${PASSWORD} | $samba_rpcclient ncacn_np:${SERVER} -U${USERNAME} --use-krb5-ccache=$KRB5CCNAME --configfile=${CONFIGURATION} -c getusername 2>&1'
+testit_expect_failure "test rpcclient kerberos interactive (negative test)" \
+ test_rpc_getusername ||
+ failed=$(expr $failed + 1)
+
+kerberos_kinit $samba_kinit ${USERNAME}@${REALM} ${PASSWORD}
+cmd='$samba_rpcclient ncacn_np:${SERVER} --use-krb5-ccache=$KRB5CCNAME --configfile=${CONFIGURATION} -c getusername 2>&1'
+testit "test rpcclient kerberos ccache" \
+ test_rpc_getusername ||
+ failed=$(expr $failed + 1)
+$samba_kdestroy
+
+### SMBTORTURE (legacy)
+
+cmd='$samba_smbtorture -U${USERNAME}%${PASSWORD} --configfile=${CONFIGURATION} --maximum-runtime=30 --basedir=$PREFIX --option=torture:progress=no --target=samba4 ncacn_np:${SERVER} rpc.lsa-getuser 2>&1'
+testit "test smbtorture legacy default" \
+ test_rpc_getusername ||
+ failed=$(expr $failed + 1)
+
+cmd='$samba_smbtorture -U${USERNAME}%${PASSWORD} -k no --configfile=${CONFIGURATION} --maximum-runtime=30 --basedir=$PREFIX --option=torture:progress=no --target=samba4 ncacn_np:${SERVER} rpc.lsa-getuser 2>&1'
+testit "test smbtorture legacy ntlm (kerberos=no)" \
+ test_rpc_getusername ||
+ failed=$(expr $failed + 1)
+
+cmd='$samba_smbtorture -U${USERNAME}%${PASSWORD} -k yes --configfile=${CONFIGURATION} --maximum-runtime=30 --basedir=$PREFIX --option=torture:progress=no --target=samba4 ncacn_np:${SERVER} rpc.lsa-getuser 2>&1'
+testit "test smbtorture legacy kerberos=yes" \
+ test_rpc_getusername ||
+ failed=$(expr $failed + 1)
+
+kerberos_kinit $samba_kinit ${USERNAME}@${REALM} ${PASSWORD}
+cmd='$samba_smbtorture -k yes --configfile=${CONFIGURATION} --maximum-runtime=30 --basedir=$PREFIX --option=torture:progress=no --target=samba4 ncacn_np:${SERVER} rpc.lsa-getuser 2>&1'
+testit "test smbtorture legacy kerberos=yes ccache" \
+ test_rpc_getusername ||
+ failed=$(expr $failed + 1)
+$samba_kdestroy
+
+kerberos_kinit $samba_kinit ${USERNAME}@${REALM} ${PASSWORD}
+cmd='$samba_smbtorture -k no --configfile=${CONFIGURATION} --maximum-runtime=30 --basedir=$PREFIX --option=torture:progress=no --target=samba4 ncacn_np:${SERVER} rpc.lsa-getuser 2>&1'
+testit_expect_failure "test smbtorture legacy kerberos=no ccache (negative test)" \
+ test_rpc_getusername ||
+ failed=$(expr $failed + 1)
+$samba_kdestroy
+
+### SMBTORTURE
+
+cmd='$samba_smbtorture -U${USERNAME}%${PASSWORD} --configfile=${CONFIGURATION} --maximum-runtime=30 --basedir=$PREFIX --option=torture:progress=no --target=samba4 ncacn_np:${SERVER} rpc.lsa-getuser 2>&1'
+testit "test smbtorture default" \
+ test_rpc_getusername ||
+ failed=$(expr $failed + 1)
+
+cmd='$samba_smbtorture -U${USERNAME}%${PASSWORD} --use-kerberos=disabled --configfile=${CONFIGURATION} --maximum-runtime=30 --basedir=$PREFIX --option=torture:progress=no --target=samba4 ncacn_np:${SERVER} rpc.lsa-getuser 2>&1'
+testit "test smbtorture ntlm (kerberos=no)" \
+ test_rpc_getusername ||
+ failed=$(expr $failed + 1)
+
+cmd='$samba_smbtorture -U${USERNAME}%${PASSWORD} --use-kerberos=required --configfile=${CONFIGURATION} --maximum-runtime=30 --basedir=$PREFIX --option=torture:progress=no --target=samba4 ncacn_np:${SERVER} rpc.lsa-getuser 2>&1'
+testit "test smbtorture kerberos=yes" \
+ test_rpc_getusername ||
+ failed=$(expr $failed + 1)
+
+kerberos_kinit $samba_kinit ${USERNAME}@${REALM} ${PASSWORD}
+cmd='$samba_smbtorture --use-krb5-ccache=$KRB5CCNAME --configfile=${CONFIGURATION} --maximum-runtime=30 --basedir=$PREFIX --option=torture:progress=no --target=samba4 ncacn_np:${SERVER} rpc.lsa-getuser 2>&1'
+testit "test smbtorture kerberos=yes ccache" \
+ test_rpc_getusername ||
+ failed=$(expr $failed + 1)
+$samba_kdestroy
+
+kerberos_kinit $samba_kinit ${USERNAME}@${REALM} ${PASSWORD}
+cmd='$samba_smbtorture --use-kerbers=required --configfile=${CONFIGURATION} --maximum-runtime=30 --basedir=$PREFIX --option=torture:progress=no --target=samba4 ncacn_np:${SERVER} rpc.lsa-getuser 2>&1'
+testit_expect_failure "test smbtorture kerberos=no ccache (negative test)" \
+ test_rpc_getusername ||
+ failed=$(expr $failed + 1)
+$samba_kdestroy
+
+### SMBCLIENT (legacy)
+cmd='$samba_smbclient //${SERVER}/tmp -W ${DOMAIN} -U${USERNAME}%${PASSWORD} --configfile=${CONFIGURATION} -c "ls; quit"'
+testit "test smbclient legacy ntlm" \
+ test_smbclient ||
+ failed=$(expr $failed + 1)
+
+cmd='echo ${PASSWORD} | USER=$USERNAME $samba_smbclient //${SERVER}/tmp -W ${DOMAIN} --configfile=${CONFIGURATION} -c "ls; quit"'
+testit "test smbclient legacy ntlm interactive" \
+ test_smbclient ||
+ failed=$(expr $failed + 1)
+
+cmd='echo ${PASSWORD} | $samba_smbclient //${SERVER}/tmp -W ${DOMAIN} -U${USERNAME} --configfile=${CONFIGURATION} -c "ls; quit"'
+testit "test smbclient legacy ntlm interactive with -U" \
+ test_smbclient ||
+ failed=$(expr $failed + 1)
+
+cmd='$samba_smbclient //${SERVER}/tmp -W ${DOMAIN} -U${USERNAME}%${PASSWORD} -k --configfile=${CONFIGURATION} -c "ls; quit"'
+testit "test smbclient legacy kerberos" \
+ test_smbclient ||
+ failed=$(expr $failed + 1)
+
+kerberos_kinit $samba_kinit ${USERNAME}@${REALM} ${PASSWORD}
+cmd='$samba_smbclient //${SERVER}/tmp -W ${DOMAIN} -k --configfile=${CONFIGURATION} -c "ls; quit"'
+testit "test smbclient legacy kerberos ccache" \
+ test_smbclient ||
+ failed=$(expr $failed + 1)
+$samba_kdestroy
+
+### SMBCLIENT tests for --use-kerberos=desired|required|disabled
+cmd='$samba_smbclient //${SERVER}/tmp -W ${DOMAIN} -U${USERNAME}%${PASSWORD} --use-kerberos=disabled --configfile=${CONFIGURATION} -c "ls; quit"'
+testit "test smbclient ntlm" \
+ test_smbclient ||
+ failed=$(expr $failed + 1)
+
+cmd='echo ${PASSWORD} | USER=$USERNAME $samba_smbclient //${SERVER}/tmp -W ${DOMAIN} --use-kerberos=disabled --configfile=${CONFIGURATION} -c "ls; quit"'
+testit "test smbclient ntlm interactive" \
+ test_smbclient ||
+ failed=$(expr $failed + 1)
+
+cmd='echo ${PASSWORD} | $samba_smbclient //${SERVER}/tmp -W ${DOMAIN} -U${USERNAME} --use-kerberos=disabled --configfile=${CONFIGURATION} -c "ls; quit"'
+testit "test smbclient ntlm interactive with -U" \
+ test_smbclient ||
+ failed=$(expr $failed + 1)
+
+cmd='$samba_smbclient //${SERVER}/tmp -W ${DOMAIN} -U${USERNAME}%${PASSWORD} --use-kerberos=desired --configfile=${CONFIGURATION} -c "ls; quit"'
+testit "test smbclient kerberos=desired" \
+ test_smbclient_kerberos ||
+ failed=$(expr $failed + 1)
+
+cmd='$samba_smbclient //${SERVER}/tmp -W ${DOMAIN} -U${USERNAME}%${PASSWORD} --use-kerberos=required --configfile=${CONFIGURATION} -c "ls; quit"'
+testit "test smbclient kerberos=required" \
+ test_smbclient_kerberos ||
+ failed=$(expr $failed + 1)
+
+kerberos_kinit $samba_kinit ${USERNAME}@${REALM} ${PASSWORD}
+cmd='$samba_smbclient //${SERVER}/tmp --use-krb5-ccache=$KRB5CCNAME --configfile=${CONFIGURATION} -c "ls; quit"'
+testit "test smbclient kerberos=required ccache" \
+ test_smbclient ||
+ failed=$(expr $failed + 1)
+$samba_kdestroy
+
+rm -rf $KRB5CCNAME_PATH
+
+exit $failed
diff --git a/testprogs/blackbox/test_kinit.sh b/testprogs/blackbox/test_kinit.sh
new file mode 100755
index 0000000..d9fb6c4
--- /dev/null
+++ b/testprogs/blackbox/test_kinit.sh
@@ -0,0 +1,555 @@
+#!/bin/sh
+# Blackbox tests for kinit and kerberos integration with smbclient etc
+# Copyright (c) Andreas Schneider <asn@samba.org>
+# Copyright (C) 2006-2007 Jelmer Vernooij <jelmer@samba.org>
+# Copyright (C) 2006-2008 Andrew Bartlett <abartlet@samba.org>
+
+if [ $# -lt 8 ]; then
+ cat <<EOF
+Usage: test_kinit.sh SERVER USERNAME PASSWORD REALM DOMAIN PREFIX SMBCLIENT CONFIGURATION
+EOF
+ exit 1
+fi
+
+SERVER=$1
+USERNAME=$2
+PASSWORD=$3
+REALM=$4
+DOMAIN=$5
+PREFIX=$6
+smbclient=$7
+CONFIGURATION="${8}"
+shift 8
+failed=0
+
+. "$(dirname "${0}")/subunit.sh"
+. "$(dirname "${0}")/common_test_fns.inc"
+
+samba_bindir="$BINDIR"
+samba_srcdir="$SRCDIR/source4"
+samba_kinit=$(system_or_builddir_binary kinit "${BINDIR}" samba4kinit)
+samba_kpasswd=$(system_or_builddir_binary kpasswd "${BINDIR}" samba4kpasswd)
+samba_kvno=$(system_or_builddir_binary kvno "${BINDIR}" samba4kvno)
+
+samba_tool="${samba_bindir}/samba-tool"
+samba_texpect="${samba_bindir}/texpect"
+
+samba_enableaccount="${samba_tool} user enable"
+machineaccountccache="${samba_srcdir}/scripting/bin/machineaccountccache"
+
+ldbmodify=$(system_or_builddir_binary ldbmodify "${BINDIR}")
+ldbsearch=$(system_or_builddir_binary ldbsearch "${BINDIR}")
+
+kbase="$(basename "${samba_kinit}")"
+if [ "${kbase}" = "samba4kinit" ]; then
+ # HEIMDAL
+ OPTION_RENEWABLE="--renewable"
+ OPTION_RENEW_TICKET="--renew"
+ OPTION_ENTERPRISE_NAME="--enterprise"
+ OPTION_CANONICALIZATION=""
+ OPTION_WINDOWS="--windows"
+ OPTION_SERVICE="-S"
+else
+ # MIT
+ OPTION_RENEWABLE="-r 1h"
+ OPTION_RENEW_TICKET="-R"
+ OPTION_ENTERPRISE_NAME="-E"
+ OPTION_CANONICALIZATION="-C"
+ OPTION_WINDOWS=""
+ OPTION_SERVICE="-S"
+fi
+
+TEST_USER="$(mktemp -u kinittest-XXXXXX)"
+UNC="//${SERVER}/tmp"
+
+ADMIN_LDBMODIFY_CONFIG="-H ldap://${SERVER} -U${USERNAME}%${PASSWORD}"
+export ADMIN_LDBMODIFY_CONFIG
+
+KRB5CCNAME_PATH="${PREFIX}/tmpccache"
+KRB5CCNAME="FILE:${KRB5CCNAME_PATH}"
+export KRB5CCNAME
+rm -rf "${KRB5CCNAME_PATH}"
+
+testit "reset password policies beside of minimum password age of 0 days" \
+ "${VALGRIND}" "${PYTHON}" "${samba_tool}" domain passwordsettings set \
+ "${ADMIN_LDBMODIFY_CONFIG}" \
+ --complexity=default \
+ --history-length=default \
+ --min-pwd-length=default \
+ --min-pwd-age=0 \
+ --max-pwd-age=default || \
+ failed=$((failed + 1))
+
+###########################################################
+### Test kinit defaults
+###########################################################
+
+testit "kinit with password (initial)" \
+ kerberos_kinit "${samba_kinit}" "${USERNAME}@${REALM}" "${PASSWORD}" \
+ "${OPTION_RENEWABLE}" || \
+ failed=$((failed + 1))
+test_smbclient "Test login with user kerberos ccache" \
+ "ls" "${UNC}" --use-krb5-ccache="${KRB5CCNAME}" || \
+ failed=$((failed + 1))
+
+testit "kinit renew ticket (initial)" \
+ "${samba_kinit}" ${OPTION_RENEW_TICKET} || \
+ failed=$((failed + 1))
+
+test_smbclient "Test login with kerberos ccache (initial)" \
+ "ls" "${UNC}" --use-krb5-ccache="${KRB5CCNAME}" || \
+ failed=$((failed + 1))
+
+rm -f "${KRB5CCNAME_PATH}"
+
+###########################################################
+### Test kinit with enterprise principal
+###########################################################
+
+testit "kinit with password (enterprise style)" \
+ kerberos_kinit "${samba_kinit}" \
+ "${USERNAME}@${REALM}" "${PASSWORD}" "${OPTION_ENTERPRISE_NAME}" \
+ "${OPTION_RENEWABLE}" || \
+ failed=$((failed + 1))
+
+test_smbclient "Test login with user kerberos ccache (enterprise style)" \
+ "ls" "${UNC}" --use-krb5-ccache="${KRB5CCNAME}" || \
+ failed=$((failed + 1))
+
+testit "kinit renew ticket (enterprise style)" \
+ "${samba_kinit}" ${OPTION_RENEW_TICKET} || \
+ failed=$((failed + 1))
+
+test_smbclient "Test login with kerberos ccache (enterprise style)" \
+ "ls" "${UNC}" --use-krb5-ccache="${KRB5CCNAME}" || \
+ failed=$((failed + 1))
+
+rm -f "${KRB5CCNAME_PATH}"
+
+###########################################################
+### Tests with kinit windows
+###########################################################
+
+# HEIMDAL ONLY
+if [ "${kbase}" = "samba4kinit" ]; then
+ testit "kinit with password (windows style)" \
+ kerberos_kinit "${samba_kinit}" \
+ "${USERNAME}@${REALM}" "${PASSWORD}" \
+ "${OPTION_RENEWABLE}" "${OPTION_WINDOWS}" || \
+ failed=$((failed + 1))
+
+ test_smbclient "Test login with kerberos ccache (windows style)" \
+ "ls" "${UNC}" --use-krb5-ccache="${KRB5CCNAME}" || \
+ failed=$((failed + 1))
+
+ testit "kinit renew ticket (windows style)" \
+ "${samba_kinit}" ${OPTION_RENEW_TICKET} || \
+ failed=$((failed + 1))
+
+ test_smbclient "Test login with kerberos ccache (windows style)" \
+ "ls" "${UNC}" --use-krb5-ccache="${KRB5CCNAME}" || \
+ failed=$((failed + 1))
+
+ rm -f "${KRB5CCNAME_PATH}"
+fi # HEIMDAL ONLY
+
+###########################################################
+### Tests with kinit default again
+###########################################################
+
+testit "kinit with password (default)" \
+ kerberos_kinit "${samba_kinit}" "${USERNAME}@${REALM}" "${PASSWORD}" || \
+ failed=$((failed + 1))
+
+testit "check time with kerberos ccache (default)" \
+ "${VALGRIND}" "${PYTHON}" "${samba_tool}" time "${SERVER}" \
+ "${CONFIGURATION}" --use-krb5-ccache="${KRB5CCNAME}" "$@" || \
+ failed=$((failed + 1))
+
+USERPASS="testPass@12%"
+
+testit "add user with kerberos ccache" \
+ "${VALGRIND}" "${PYTHON}" "${samba_tool}" user create \
+ "${TEST_USER}" "${USERPASS}" \
+ "${CONFIGURATION}" --use-krb5-ccache="${KRB5CCNAME}" "$@" || \
+ failed=$((failed + 1))
+
+echo "Getting defaultNamingContext"
+BASEDN=$(${ldbsearch} --basedn='' -H "ldap://${SERVER}" --scope=base \
+ DUMMY=x defaultNamingContext | awk '/defaultNamingContext/ {print $2}')
+
+
+TEST_UPN="$(mktemp -u test-XXXXXX)@${REALM}"
+cat >"${PREFIX}/tmpldbmodify" <<EOF
+dn: cn=${TEST_USER},cn=users,${BASEDN}
+changetype: modify
+add: servicePrincipalName
+servicePrincipalName: host/${TEST_USER}
+replace: userPrincipalName
+userPrincipalName: ${TEST_UPN}
+EOF
+
+testit "modify servicePrincipalName and userPrincpalName" \
+ "${VALGRIND}" "${ldbmodify}" -H "ldap://${SERVER}" "${PREFIX}/tmpldbmodify" \
+ --use-krb5-ccache="${KRB5CCNAME}" "$@" || \
+ failed=$((failed + 1))
+
+testit "set user password with kerberos ccache" \
+ "${VALGRIND}" "${PYTHON}" "${samba_tool}" user setpassword "${TEST_USER}" \
+ --newpassword="${USERPASS}" "${CONFIGURATION}" \
+ --use-krb5-ccache="${KRB5CCNAME}" "$@" || \
+ failed=$((failed + 1))
+
+testit "enable user with kerberos cache" \
+ "${VALGRIND}" "${PYTHON}" "${samba_enableaccount}" "${TEST_USER}" \
+ -H "ldap://$SERVER" --use-krb5-ccache="${KRB5CCNAME}" "$@" || \
+ failed=$((failed + 1))
+
+testit "kinit with new user password" \
+ kerberos_kinit "${samba_kinit}" "${TEST_USER}" "${USERPASS}" || \
+ failed=$((failed + 1))
+
+test_smbclient "Test login with new user kerberos ccache" \
+ "ls" "${UNC}" --use-krb5-ccache="${KRB5CCNAME}" || \
+ failed=$((failed + 1))
+
+rm -f "${KRB5CCNAME_PATH}"
+
+###########################################################
+### Test kinit after changing password with samba-tool
+###########################################################
+
+NEW_USERPASS="testPaSS@34%"
+testit "change user password with 'samba-tool user password' (rpc)" \
+ "${VALGRIND}" "${PYTHON}" "${samba_tool}" user password \
+ -W"${DOMAIN}" -U"${TEST_USER}%${USERPASS}" "${CONFIGURATION}" \
+ --newpassword="${NEW_USERPASS}" \
+ --use-kerberos=off "$@" || \
+ failed=$((failed + 1))
+
+testit "kinit with user password (after rpc password change)" \
+ kerberos_kinit "${samba_kinit}" \
+ "${TEST_USER}@${REALM}" "${NEW_USERPASS}" || \
+ failed=$((failed + 1))
+
+test_smbclient "Test login with user kerberos (after rpc password change)" \
+ "ls" "${UNC}" --use-krb5-ccache="${KRB5CCNAME}" || \
+ failed=$((failed + 1))
+
+USERPASS="${NEW_USERPASS}"
+
+rm -f "${KRB5CCNAME_PATH}"
+
+###########################################################
+### Test kinit with UPN
+###########################################################
+
+testit "kinit with new (NT-Principal style) using UPN" \
+ kerberos_kinit "${samba_kinit}" "${TEST_UPN}" "${USERPASS}" || \
+ failed=$((failed + 1))
+
+test_smbclient "Test login with user kerberos ccache from NT UPN" \
+ "ls" "${UNC}" --use-krb5-ccache="${KRB5CCNAME}" || \
+ failed=$((failed + 1))
+
+rm -f "${KRB5CCNAME_PATH}"
+
+testit "kinit with new (enterprise style) using UPN" \
+ kerberos_kinit "${samba_kinit}" "${TEST_UPN}" "${USERPASS}" \
+ ${OPTION_ENTERPRISE_NAME} || \
+ failed=$((failed + 1))
+
+test_smbclient "Test login with user kerberos ccache from enterprise UPN" \
+ "ls" "${UNC}" --use-krb5-ccache="${KRB5CCNAME}" || \
+ failed=$((failed + 1))
+
+rm -f "${KRB5CCNAME_PATH}"
+
+# HEIMDAL ONLY
+if [ "${kbase}" = "samba4kinit" ]; then
+ testit "kinit with new (windows style) using UPN" \
+ kerberos_kinit "${samba_kinit}" "${TEST_UPN}" "${USERPASS}" \
+ ${OPTION_WINDOWS} || \
+ failed=$((failed + 1))
+
+ test_smbclient "Test login with user kerberos ccache with (windows style) UPN" \
+ "ls" "${UNC}" --use-krb5-ccache="${KRB5CCNAME}" || \
+ failed=$((failed + 1))
+
+ rm -f "${KRB5CCNAME_PATH}"
+fi # HEIMDAL ONLY
+
+###########################################################
+### Tests with SPN
+###########################################################
+
+DNSDOMAIN=$(echo "${REALM}" | tr '[:upper:]' '[:lower:]')
+testit "kinit with password (SPN)" \
+ kerberos_kinit "${samba_kinit}" \
+ "http/testupnspn.${DNSDOMAIN}" "${PASSWORD}" || \
+ failed=$((failed + 1))
+
+test_smbclient "Test login with kerberos ccache (SPN)" \
+ "ls" "${UNC}" --use-krb5-ccache="${KRB5CCNAME}" || \
+ failed=$((failed + 1))
+
+rm -f "${KRB5CCNAME_PATH}"
+
+###########################################################
+### Test kinit with canonicalization
+###########################################################
+
+upperusername=$(echo "${USERNAME}" | tr '[:lower:]' '[:upper:]')
+testit "kinit with canonicalize and service" \
+ kerberos_kinit "${samba_kinit}" "${upperusername}@${REALM}" "${PASSWORD}" \
+ ${OPTION_CANONICALIZATION} \
+ ${OPTION_SERVICE} "kadmin/changepw@${REALM}" || \
+ failed=$((failed + 1))
+
+rm -f "${KRB5CCNAME_PATH}"
+
+###########################################################
+### Test kinit with user credentials and changed realm
+###########################################################
+
+testit "kinit with password (default)" \
+ kerberos_kinit "${samba_kinit}" "${USERNAME}@${REALM}" "${PASSWORD}" || \
+ failed=$((failed + 1))
+
+cat >"${PREFIX}/tmpldbmodify" <<EOF
+dn: cn=${TEST_USER},cn=users,$BASEDN
+changetype: modify
+replace: userPrincipalName
+userPrincipalName: ${TEST_UPN}.org
+EOF
+
+testit "modify userPrincipalName to be a different domain" \
+ "${VALGRIND}" "${ldbmodify}" "${ADMIN_LDBMODIFY_CONFIG}" \
+ "${PREFIX}/tmpldbmodify" "${PREFIX}/tmpldbmodify" \
+ --use-krb5-ccache="${KRB5CCNAME}" "$@" || \
+ failed=$((failed + 1))
+
+testit "kinit with new (enterprise style) using UPN" \
+ kerberos_kinit "${samba_kinit}" "${TEST_UPN}.org" "${USERPASS}" \
+ ${OPTION_ENTERPRISE_NAME} || failed=$((failed + 1))
+
+test_smbclient "Test login with user kerberos ccache from enterprise UPN" \
+ "ls" "${UNC}" \
+ --use-krb5-ccache="${KRB5CCNAME}" || \
+ failed=$((failed + 1))
+
+rm -f "${KRB5CCNAME_PATH}"
+
+###########################################################
+### Test password change with kpasswd
+###########################################################
+
+testit "kinit with user password" \
+ kerberos_kinit "${samba_kinit}" "${TEST_USER}@$REALM" "${USERPASS}" || \
+ failed=$((failed + 1))
+
+test_smbclient "Test login with user kerberos ccache" \
+ "ls" "${UNC}" --use-krb5-ccache="${KRB5CCNAME}" || \
+ failed=$((failed + 1))
+
+NEWUSERPASS=testPaSS@56%
+
+if [ "${kbase}" = "samba4kinit" ]; then
+ # HEIMDAL
+ cat >"${PREFIX}/tmpkpasswdscript" <<EOF
+expect Password
+password ${USERPASS}\n
+expect New password
+send ${NEWUSERPASS}\n
+expect Verify password
+send ${NEWUSERPASS}\n
+expect Success
+EOF
+
+else
+ # MIT
+ cat >"${PREFIX}/tmpkpasswdscript" <<EOF
+expect Password for
+password ${USERPASS}\n
+expect Enter new password
+send ${NEWUSERPASS}\n
+expect Enter it again
+send ${NEWUSERPASS}\n
+expect Password changed
+EOF
+fi
+
+testit "change user password with kpasswd" \
+ "${samba_texpect}" "${PREFIX}/tmpkpasswdscript" \
+ "${samba_kpasswd}" "${TEST_USER}@$REALM" || \
+ failed=$((failed + 1))
+
+rm -f "${KRB5CCNAME_PATH}"
+
+USERPASS="${NEWUSERPASS}"
+
+testit "kinit with user password (after kpasswd)" \
+ kerberos_kinit "${samba_kinit}" \
+ "${TEST_USER}@${REALM}" "${USERPASS}" || \
+ failed=$((failed + 1))
+
+test_smbclient "Test login with user kerberos ccache (after kpasswd)" \
+ "ls" "${UNC}" --use-krb5-ccache="${KRB5CCNAME}" || \
+ failed=$((failed + 1))
+
+rm -f "${KRB5CCNAME_PATH}"
+
+###########################################################
+### TODO Test set password with kpasswd
+###########################################################
+
+# This is not implemented in kpasswd
+
+###########################################################
+### Test password expiry
+###########################################################
+
+ cat >"${PREFIX}/tmpldbmodify" <<EOF
+dn: cn=${TEST_USER},cn=users,${BASEDN}
+changetype: modify
+replace: pwdLastSet
+pwdLastSet: 0
+EOF
+
+ NEWUSERPASS=testPaSS@78%
+
+ testit "modify pwdLastSet" \
+ "${VALGRIND}" "${ldbmodify}" "${ADMIN_LDBMODIFY_CONFIG}" \
+ "${PREFIX}/tmpldbmodify" "${PREFIX}/tmpldbmodify" \
+ --use-krb5-ccache="${KRB5CCNAME}" "$@" || \
+ failed=$((failed + 1))
+
+if [ "${kbase}" = "samba4kinit" ]; then
+ # HEIMDAL branch
+ cat >"${PREFIX}/tmpkinituserpassscript" <<EOF
+expect ${TEST_USER}@$REALM's Password
+send ${USERPASS}\n
+expect Password has expired
+expect New password
+send ${NEWUSERPASS}\n
+expect Repeat new password
+send ${NEWUSERPASS}\n
+EOF
+else
+ # MIT branch
+ cat >"${PREFIX}/tmpkinituserpassscript" <<EOF
+expect Password for
+send ${USERPASS}\n
+expect Password expired. You must change it now.
+expect Enter new password
+send ${NEWUSERPASS}\n
+expect Enter it again
+send ${NEWUSERPASS}\n
+EOF
+
+fi # END MIT ONLY
+
+testit "kinit with user password for expired password" \
+ "${samba_texpect}" "$PREFIX/tmpkinituserpassscript" \
+ "${samba_kinit}" "${TEST_USER}@$REALM" || \
+ failed=$((failed + 1))
+
+test_smbclient "Test login with user kerberos ccache" \
+ "ls" "${UNC}" --use-krb5-ccache="${KRB5CCNAME}" || \
+ failed=$((failed + 1))
+
+USERPASS="${NEWUSERPASS}"
+
+testit "kinit with user password" \
+ kerberos_kinit "${samba_kinit}" \
+ "${TEST_USER}@${REALM}" "${USERPASS}" || \
+ failed=$((failed + 1))
+
+test_smbclient "Test login with user kerberos ccache" \
+ "ls" "${UNC}" --use-krb5-ccache="${KRB5CCNAME}" || \
+ failed=$((failed + 1))
+
+###########################################################
+### Test login with lowercase realm
+###########################################################
+
+KRB5CCNAME_PATH="$PREFIX/tmpccache"
+KRB5CCNAME="FILE:$KRB5CCNAME_PATH"
+export KRB5CCNAME
+
+rm -rf "${KRB5CCNAME_PATH}"
+
+testit "kinit with user password" \
+ kerberos_kinit "${samba_kinit}" "${TEST_USER}@${REALM}" "${USERPASS}" || \
+ failed=$((failed + 1))
+
+lowerrealm=$(echo "${REALM}" | tr '[:upper:]' '[:lower:]')
+test_smbclient "Test login with user kerberos lowercase realm" \
+ "ls" "${UNC}" --use-kerberos=required \
+ -U"${TEST_USER}@${lowerrealm}%${NEWUSERPASS}" || \
+ failed=$((failed + 1))
+
+test_smbclient "Test login with user kerberos lowercase realm 2" \
+ "ls" "${UNC}" --use-kerberos=required \
+ -U"${TEST_USER}@${REALM}%${NEWUSERPASS}" --realm="${lowerrealm}" || \
+ failed=$((failed + 1))
+
+testit "del user with kerberos ccache" \
+ "${VALGRIND}" "${PYTHON}" "${samba_tool}" user delete \
+ "${TEST_USER}" "${CONFIGURATION}" \
+ --use-krb5-ccache="${KRB5CCNAME}" "$@" || \
+ failed=$((failed + 1))
+
+###########################################################
+### Test login with machine account
+###########################################################
+
+rm -f "${KRB5CCNAME_PATH}"
+
+testit "kinit with machineaccountccache script" \
+ "${PYTHON}" "${machineaccountccache}" "${CONFIGURATION}" \
+ "${KRB5CCNAME}" || \
+ failed=$((failed + 1))
+
+test_smbclient "Test machine account login with kerberos ccache" \
+ "ls" "${UNC}" --use-krb5-ccache="${KRB5CCNAME}" || \
+ failed=$((failed + 1))
+
+testit "reset password policies" \
+ "${VALGRIND}" "${PYTHON}" "${samba_tool}" domain passwordsettings set \
+ "${ADMIN_LDBMODIFY_CONFIG}" \
+ --complexity=default \
+ --history-length=default \
+ --min-pwd-length=default \
+ --min-pwd-age=default \
+ --max-pwd-age=default || \
+ failed=$((failed + 1))
+
+###########################################################
+### Test basic s4u2self request
+###########################################################
+
+# MIT ONLY
+if [ "${kbase}" = "kinit" ]; then
+
+# Use previous acquired machine creds to request a ticket for self.
+# We expect it to fail for now.
+MACHINE_ACCOUNT="$(hostname -s | tr '[:lower:]' '[:upper:]')\$@${REALM}"
+
+${samba_kvno} -U"${MACHINE_ACCOUNT}" "${MACHINE_ACCOUNT}"
+
+# But we expect the KDC to be up and running still
+testit "kinit with machineaccountccache after s4u2self" \
+ "${machineaccountccache}" "${CONFIGURATION}" "${KRB5CCNAME}" || \
+ failed=$((failed + 1))
+
+fi # END MIT ONLY
+
+### Cleanup
+
+rm -f "${KRB5CCNAME_PATH}"
+rm -f "${PREFIX}/tmpkinituserpassscript"
+rm -f "${PREFIX}/tmpkinitscript"
+rm -f "${PREFIX}/tmpkpasswdscript"
+
+exit $failed
diff --git a/testprogs/blackbox/test_kinit_export_keytab.sh b/testprogs/blackbox/test_kinit_export_keytab.sh
new file mode 100755
index 0000000..e520a1c
--- /dev/null
+++ b/testprogs/blackbox/test_kinit_export_keytab.sh
@@ -0,0 +1,263 @@
+#!/bin/sh
+#
+# Blackbox tests for an exported keytab with kinit
+#
+# Copyright (C) 2006-2007 Jelmer Vernooij <jelmer@samba.org>
+# Copyright (C) 2006-2008 Andrew Bartlett <abartlet@samba.org>
+# Copyright (C) Andreas Schneider <asn@cryptomilk.org>
+
+if [ $# -lt 7 ]; then
+ cat <<EOF
+Usage: test_kinit_export_keytab.sh SERVER USERNAME REALM DOMAIN PREFIX SMBCLIENT CONFIGURATION
+EOF
+ exit 1
+fi
+
+SERVER=$1
+USERNAME=$2
+REALM=$3
+DOMAIN=$4
+PREFIX=$5
+smbclient=$6
+CONFIGURATION=${7}
+shift 7
+failed=0
+
+. "$(dirname "${0}")/subunit.sh"
+. "$(dirname "${0}")/common_test_fns.inc"
+
+samba_bindir="${BINDIR}"
+samba_tool="$samba_bindir/samba-tool"
+samba_newuser="$samba_tool user create"
+samba_ktutil="${BINDIR}/samba4ktutil"
+
+samba_kinit=$(system_or_builddir_binary kinit "${BINDIR}" samba4kinit)
+
+DNSDOMAIN=$(echo "${REALM}" | tr '[:upper:]' '[:lower:]')
+SERVER_FQDN="${SERVER}.$(echo "${REALM}" | tr '[:upper:]' '[:lower:]')"
+SMBCLIENT_UNC="//${SERVER}/tmp"
+
+TEST_USER="$(mktemp -u keytabtest-XXXXXX)"
+TEST_PASSWORD=testPaSS@01%
+
+EXPECTED_NKEYS=3
+# MIT
+kbase="$(basename "${samba_kinit}")"
+if [ "${kbase}" != "samba4kinit" ]; then
+ krb5_version="$(krb5-config --version | cut -d ' ' -f 4)"
+ krb5_major_version="$(echo "${krb5_version}" | awk -F. '{ print $1; }')"
+ krb5_minor_version="$(echo "${krb5_version}" | awk -F. '{ print $2; }')"
+
+ # MIT Kerberos < 1.18 has support for DES keys
+ if [ "${krb5_major_version}" -eq 1 ] && [ "${krb5_minor_version}" -lt 18 ]; then
+ EXPECTED_NKEYS=5
+ fi
+fi # MIT
+
+if [ "${kbase}" = "samba4kinit" ]; then
+ # HEIMDAL
+ OPTION_RENEWABLE="--renewable"
+ OPTION_RENEW_TICKET="--renew"
+ OPTION_ENTERPRISE_NAME="--enterprise"
+ OPTION_CANONICALIZATION=""
+ OPTION_WINDOWS="--windows"
+ OPTION_SERVICE="-S"
+ OPTION_USE_KEYTAB="-k"
+ OPTION_KEYTAB_FILENAME="-t"
+
+ KEYTAB_GREP="[aes|arcfour]"
+else
+ # MIT
+ OPTION_RENEWABLE="-r 1h"
+ OPTION_RENEW_TICKET="-R"
+ OPTION_ENTERPRISE_NAME="-E"
+ OPTION_CANONICALIZATION="-C"
+ OPTION_WINDOWS=""
+ OPTION_SERVICE="-S"
+ OPTION_USE_KEYTAB="-k"
+ OPTION_KEYTAB_FILENAME="-t"
+
+ KEYTAB_GREP="[DES|AES|ArcFour]"
+fi
+
+test_keytab()
+{
+ testname="$1"
+ keytab="$2"
+ principal="$3"
+ expected_nkeys="$4"
+
+ subunit_start_test "$testname"
+
+ if [ ! -r "${keytab}" ]; then
+ echo "Could not read keytab: ${keytab}" | \
+ subunit_fail_test "${testname}"
+ return 1
+ fi
+
+ output=$($VALGRIND "${samba_ktutil}" "${keytab}" 2>&1)
+ status=$?
+ if [ ${status} -ne 0 ]; then
+ echo "${output}" | subunit_fail_test "${testname}"
+ return $status
+ fi
+
+ NKEYS=$(echo "${output}" | grep -i "${principal}" | \
+ grep -c -e "${KEYTAB_GREP}")
+ if [ "${NKEYS}" -ne "${expected_nkeys}" ]; then
+ echo "Unexpected number of keys passed ${NKEYS} != ${expected_nkeys}" | \
+ subunit_fail_test "${testname}"
+ return 1
+ fi
+
+ subunit_pass_test "${testname}"
+ return 0
+}
+
+testit "create local user ${TEST_USER}" \
+ "${VALGRIND}" "${PYTHON}" "${samba_newuser}" "${TEST_USER}" "${TEST_PASSWORD}" \
+ "${CONFIGURATION}" "$@" || \
+ failed=$((failed + 1))
+
+testit "dump keytab from domain" \
+ "${VALGRIND}" "${PYTHON}" "${samba_tool}" domain exportkeytab \
+ "${PREFIX}/tmpkeytab-all" \
+ "${CONFIGURATION}" "$@" || \
+ failed=$((failed + 1))
+
+test_keytab "read keytab from domain" \
+ "${PREFIX}/tmpkeytab-all" "${SERVER}\\\$" "${EXPECTED_NKEYS}" || \
+ failed=$((failed + 1))
+
+testit "dump keytab from domain (2nd time)" \
+ "${VALGRIND}" "${PYTHON}" "${samba_tool}" domain exportkeytab \
+ "${PREFIX}/tmpkeytab-all" "${CONFIGURATION}" "$@" || \
+ failed=$((failed + 1))
+
+test_keytab "read keytab from domain (2nd time)" \
+ "${PREFIX}/tmpkeytab-all" "${SERVER}\\\$" "${EXPECTED_NKEYS}" || \
+ failed=$((failed + 1))
+
+testit "dump keytab from domain for cifs service principal" \
+ "${VALGRIND}" "${PYTHON}" "${samba_tool}" domain exportkeytab \
+ "${PREFIX}/tmpkeytab-server" --principal="cifs/$SERVER_FQDN" \
+ "${CONFIGURATION}" "$@" || \
+ failed=$((failed + 1))
+
+test_keytab "read keytab from domain for cifs service principal" \
+ "${PREFIX}/tmpkeytab-server" "cifs/${SERVER_FQDN}" \
+ "${EXPECTED_NKEYS}" || \
+ failed=$((failed + 1))
+
+testit "dump keytab from domain for cifs service principal (2nd time)" \
+ "${VALGRIND}" "${PYTHON}" "${samba_tool}" domain exportkeytab \
+ "$PREFIX/tmpkeytab-server" --principal="cifs/$SERVER_FQDN" \
+ "${CONFIGURATION}" "$@" || \
+ failed=$((failed + 1))
+
+test_keytab "read keytab from domain for cifs service principal (2nd time)" \
+ "${PREFIX}/tmpkeytab-server" "cifs/${SERVER_FQDN}" \
+ "${EXPECTED_NKEYS}" || \
+ failed=$((failed + 1))
+
+testit "dump keytab from domain for user principal" \
+ "${VALGRIND}" "${PYTHON}" "${samba_tool}" domain exportkeytab \
+ "${PREFIX}/tmpkeytab-user-princ" --principal="${TEST_USER}" \
+ "${CONFIGURATION}" "$@" || \
+ failed=$((failed + 1))
+
+test_keytab "read keytab from domain for user principal" \
+ "${PREFIX}/tmpkeytab-user-princ" "${TEST_USER}@${REALM}" \
+ "${EXPECTED_NKEYS}" || \
+ failed=$((failed + 1))
+
+testit "dump keytab from domain for user principal (2nd time)" \
+ "${VALGRIND}" "${PYTHON}" "${samba_tool}" domain exportkeytab \
+ "${PREFIX}/tmpkeytab-user-princ-2" --principal="${TEST_USER}@${REALM}" \
+ "${CONFIGURATION}" "$@" || \
+ failed=$((failed + 1))
+
+test_keytab "read keytab from domain for user principal (2nd time)" \
+ "${PREFIX}/tmpkeytab-user-princ-2" "${TEST_USER}@${REALM}" \
+ "${EXPECTED_NKEYS}" || \
+ failed=$((failed + 1))
+
+testit "dump keytab from domain for user principal with SPN as UPN" \
+ "${VALGRIND}" "${PYTHON}" "${samba_tool}" domain exportkeytab \
+ "${PREFIX}/tmpkeytab-spn-upn" \
+ --principal="http/testupnspn.${DNSDOMAIN}" "${CONFIGURATION}" "$@" || \
+ failed=$((failed + 1))
+
+test_keytab "read keytab from domain for user principal with SPN as UPN" \
+ "${PREFIX}/tmpkeytab-spn-upn" "http/testupnspn.${DNSDOMAIN}@${REALM}" \
+ "${EXPECTED_NKEYS}"
+
+KRB5CCNAME_PATH="${PREFIX}/tmpuserccache"
+KRB5CCNAME="FILE:${PREFIX}/tmpuserccache"
+export KRB5CCNAME
+
+testit "kinit with keytab as user" \
+ "${VALGRIND}" "${samba_kinit}" \
+ "${OPTION_USE_KEYTAB}" \
+ "${OPTION_KEYTAB_FILENAME}" "${PREFIX}/tmpkeytab-all" \
+ "${TEST_USER}@${REALM}" || \
+ failed=$((failed + 1))
+
+test_smbclient "Test login with user kerberos ccache" \
+ "ls" "${SMBCLIENT_UNC}" --use-krb5-ccache="${KRB5CCNAME}" || \
+ failed=$((failed + 1))
+
+testit "kinit with keytab as user (one princ)" \
+ "${VALGRIND}" "$samba_kinit" \
+ "${OPTION_USE_KEYTAB}" \
+ "${OPTION_KEYTAB_FILENAME}" "${PREFIX}/tmpkeytab-user-princ" \
+ "${TEST_USER}@$REALM" || \
+ failed=$((failed + 1))
+
+test_smbclient "Test login with user kerberos ccache (one princ)" \
+ "ls" "${SMBCLIENT_UNC}" --use-krb5-ccache="${KRB5CCNAME}" || \
+ failed=$((failed + 1))
+
+rm -f "${KRB5CCNAME_PATH}"
+
+KRB5CCNAME_PATH="${PREFIX}/tmpadminccache"
+KRB5CCNAME="FILE:${PREFIX}/tmpadminccache"
+export KRB5CCNAME
+
+testit "kinit with keytab as ${USERNAME}" \
+ "${VALGRIND}" "${samba_kinit}" \
+ "${OPTION_USE_KEYTAB}" \
+ "${OPTION_KEYTAB_FILENAME}" "${PREFIX}/tmpkeytab-all" \
+ "${USERNAME}@${REALM}" || \
+ failed=$((failed + 1))
+
+rm -f "${KRB5CCNAME_PATH}"
+
+KRB5CCNAME_PATH="${PREFIX}/tmpserverccache"
+KRB5CCNAME="FILE:${PREFIX}/tmpserverccache"
+export KRB5CCNAME
+
+testit "kinit with SPN from keytab" \
+ "${VALGRIND}" "${samba_kinit}" \
+ "${OPTION_USE_KEYTAB}" \
+ "${OPTION_KEYTAB_FILENAME}" "${PREFIX}/tmpkeytab-spn-upn" \
+ "http/testupnspn.${DNSDOMAIN}" || \
+ failed=$((failed + 1))
+
+# cleanup
+testit "delete user ${TEST_USER}" \
+ "${VALGRIND}" "${PYTHON}" "${samba_tool}" user delete "${TEST_USER}" \
+ --use-krb5-ccache="${KRB5CCNAME}" "${CONFIGURATION}" "$@" || \
+ failed=$((failed + 1))
+
+rm -f "${KRB5CCNAME_PATH}"
+rm -f "${PREFIX}/tmpadminccache" \
+ "${PREFIX}/tmpuserccache" \
+ "${PREFIX}/tmpkeytab" \
+ "${PREFIX}/tmpkeytab-user-princ" \
+ "${PREFIX}/tmpkeytab-user-princ-2" \
+ "${PREFIX}/tmpkeytab-server" \
+ "${PREFIX}/tmpkeytab-spn-upn" \
+ "${PREFIX}/tmpkeytab-all"
+
+exit $failed
diff --git a/testprogs/blackbox/test_kinit_trusts.sh b/testprogs/blackbox/test_kinit_trusts.sh
new file mode 100755
index 0000000..e76d81b
--- /dev/null
+++ b/testprogs/blackbox/test_kinit_trusts.sh
@@ -0,0 +1,247 @@
+#!/bin/sh
+# Blackbox tests for kinit and trust validation
+# Copyright (c) 2015 Stefan Metzmacher <metze@samba.org>
+# Copyright (c) Andreas Schneider <asn@samba.org>
+
+if [ $# -lt 13 ]; then
+ cat <<EOF
+Usage: test_kinit_trusts.sh SERVER USERNAME PASSWORD REALM DOMAIN TRUST_USERNAME TRUST_PASSWORD TRUST_REALM TRUST_DOMAIN PREFIX TYPE CONFIGURATION
+EOF
+ exit 1
+fi
+
+SERVER=${1}
+USERNAME=${2}
+PASSWORD=${3}
+REALM=${4}
+DOMAIN=${5}
+shift 5
+TRUST_SERVER=${1}
+TRUST_USERNAME=${2}
+TRUST_PASSWORD=${3}
+TRUST_REALM=${4}
+TRUST_DOMAIN=${5}
+shift 5
+PREFIX=${1}
+TYPE=${2}
+CONFIGURATION="${3}"
+shift 3
+
+failed=0
+
+. "$(dirname "${0}")/subunit.sh"
+. "$(dirname "${0}")/common_test_fns.inc"
+
+samba_bindir="$BINDIR"
+samba_kinit=$(system_or_builddir_binary kinit "${BINDIR}" samba4kinit)
+
+samba_tool="${samba_bindir}/samba-tool"
+
+smbclient="${samba_bindir}/smbclient"
+wbinfo="${samba_bindir}/wbinfo"
+
+ldbsearch=$(system_or_builddir_binary ldbsearch "${BINDIR}")
+
+SMBCLIENT_UNC="//$SERVER.$REALM/tmp"
+
+kbase="$(basename "${samba_kinit}")"
+if [ "${kbase}" = "samba4kinit" ]; then
+ # HEIMDAL
+ OPTION_LIFETIME_2M="--lifetime=2m"
+ OPTION_RENEWABLE="--renewable"
+ OPTION_RENEW_TICKET="--renew"
+ OPTION_ENTERPRISE_NAME="--enterprise"
+ OPTION_CANONICALIZATION=""
+ OPTION_WINDOWS="--windows"
+ OPTION_SERVICE="-S"
+else
+ # MIT
+ OPTION_LIFETIME_2M="-l 2m"
+ OPTION_RENEWABLE="-r 1h"
+ OPTION_RENEW_TICKET="-R"
+ OPTION_ENTERPRISE_NAME="-E"
+ OPTION_CANONICALIZATION="-C"
+ OPTION_WINDOWS=""
+ OPTION_SERVICE="-S"
+fi
+
+KRB5CCNAME_PATH="$PREFIX/test_kinit_trusts_ccache"
+KRB5CCNAME="FILE:$KRB5CCNAME_PATH"
+export KRB5CCNAME
+rm -f "${KRB5CCNAME_PATH}"
+
+###########################################################
+### Test incoming trust direction
+###########################################################
+
+testit "kinit with password" \
+ kerberos_kinit "${samba_kinit}" \
+ "$TRUST_USERNAME@$TRUST_REALM" "${TRUST_PASSWORD}" || \
+ failed=$((failed + 1))
+
+test_smbclient "Test login with kerberos ccache" \
+ "ls" "${SMBCLIENT_UNC}" --use-krb5-ccache="${KRB5CCNAME}" || \
+ failed=$((failed + 1))
+
+rm -f "${KRB5CCNAME_PATH}"
+
+###########################################################
+### Test with 2min lifetime
+###########################################################
+
+# CVE-2022-2031 - test for short-lived ticket across an incoming trust
+#
+# We ensure that the KDC does not reject a TGS-REQ with our short-lived TGT
+# over an incoming trust.
+#
+# BUG: https://bugzilla.samba.org/show_bug.cgi?id=15047
+if [ "${kbase}" = "samba4kinit" ]; then
+ # HEIMDAL ONLY
+ testit "kinit with password (lifetime 2min)" \
+ kerberos_kinit "${samba_kinit}" \
+ "${TRUST_USERNAME}@${TRUST_REALM}" "${TRUST_PASSWORD}" \
+ "${OPTION_SERVICE}" "krbtgt/${REALM}@${TRUST_REALM}" \
+ "${OPTION_LIFETIME_2M}" || \
+ failed=$((failed + 1))
+
+ test_smbclient "Test login with kerberos ccache (lifetime 2min)" \
+ "ls" "${SMBCLIENT_UNC}" --use-krb5-ccache="${KRB5CCNAME}" || \
+ failed=$((failed + 1))
+fi
+
+rm -f "${KRB5CCNAME_PATH}"
+
+###########################################################
+### Test with smbclient4 to check gensec_gssapi works
+###########################################################
+
+testit "kinit with password (smbclient4)" \
+ kerberos_kinit "${samba_kinit}" \
+ "${TRUST_USERNAME}@${TRUST_REALM}" "${TRUST_PASSWORD}" || \
+ failed=$((failed + 1))
+
+smbclient="${samba_bindir}/smbclient4"
+test_smbclient "Test login with user kerberos ccache (smbclient4)" \
+ 'ls' "$unc" --use-krb5-ccache="${KRB5CCNAME}" -d10 || \
+ failed=$((failed + 1))
+smbclient="${samba_bindir}/smbclient"
+
+rm -f "${KRB5CCNAME_PATH}"
+
+###########################################################
+### Test incoming trust direction (enterprise)
+###########################################################
+
+testit "kinit with password (enterprise)" \
+ kerberos_kinit "${samba_kinit}" \
+ "$TRUST_USERNAME@$TRUST_REALM" "${TRUST_PASSWORD}" \
+ "${OPTION_ENTERPRISE_NAME}" || \
+ failed=$((failed + 1))
+
+test_smbclient "Test login with user kerberos ccache (enterprise)" \
+ "ls" "${SMBCLIENT_UNC}" --use-krb5-ccache="${KRB5CCNAME}" || \
+ failed=$((failed + 1))
+
+
+rm -f "${KRB5CCNAME_PATH}"
+
+if [ "${TYPE}" = "forest" ]; then
+ testit "kinit with password (enterprise UPN)" \
+ kerberos_kinit "${samba_kinit}" \
+ "testdenied_upn@${TRUST_REALM}.upn" "${TRUST_PASSWORD}" \
+ "${OPTION_ENTERPRISE_NAME}" || \
+ failed=$((failed + 1))
+
+ test_smbclient "Test login with user kerberos ccache (enterprise UPN)" \
+ "ls" "${SMBCLIENT_UNC}" --use-krb5-ccache="${KRB5CCNAME}" || \
+ failed=$((failed + 1))
+
+ rm -f "${KRB5CCNAME_PATH}"
+fi
+
+testit "kinit with password (enterprise)" \
+ kerberos_kinit "${samba_kinit}" \
+ "${TRUST_USERNAME}@${TRUST_REALM}" "${TRUST_PASSWORD}" \
+ "${OPTION_ENTERPRISE_NAME}" "${OPTION_RENEWABLE}" || \
+ failed=$((failed + 1))
+
+test_smbclient "Test login with kerberos ccache (enterprise)" \
+ "ls" "${SMBCLIENT_UNC}" --use-krb5-ccache="${KRB5CCNAME}" || \
+ failed=$((failed + 1))
+
+testit "kinit renew ticket (enterprise)" \
+ "${samba_kinit}" ${OPTION_RENEW_TICKET} \
+ || failed=$((failed + 1))
+
+test_smbclient "Test login with kerberos ccache (enterprise)" \
+ "ls" "${SMBCLIENT_UNC}" --use-krb5-ccache="${KRB5CCNAME}" || \
+ failed=$((failed + 1))
+
+testit "check time with kerberos ccache" \
+ "${VALGRIND}" "${samba_tool}" time "${SERVER}.${REALM}" \
+ "${CONFIGURATION}" --use-krb5-ccache="${KRB5CCNAME}" "$@" || \
+ failed=$((failed + 1))
+
+rm -f "${KRB5CCNAME_PATH}"
+
+###########################################################
+### Test with password authentication
+###########################################################
+
+lowerrealm="$(echo "${TRUST_REALM}" | tr '[:upper:]' '[:lower:]')"
+test_smbclient "Test login with user kerberos lowercase realm" \
+ "ls" "${SMBCLIENT_UNC}" \
+ -U"${TRUST_USERNAME}@${lowerrealm}%${TRUST_PASSWORD}" \
+ --use-kerberos=required || \
+ failed=$((failed + 1))
+
+test_smbclient "Test login with user kerberos lowercase realm 2" \
+ "ls" "${SMBCLIENT_UNC}" \
+ -U"${TRUST_USERNAME}@${TRUST_REALM}%${TRUST_PASSWORD}" \
+ --realm="${lowerrealm}" \
+ --use-kerberos=required || \
+ failed=$((failed + 1))
+
+###########################################################
+### Test outgoing trust direction
+###########################################################
+
+SMBCLIENT_UNC="//$TRUST_SERVER.$TRUST_REALM/tmp"
+
+test_smbclient "Test user login with the first outgoing secret" \
+ "ls" "${SMBCLIENT_UNC}" \
+ --use-kerberos=required \
+ -U"${USERNAME}@${REALM}%${PASSWORD}" || \
+ failed=$((failed + 1))
+
+testit_expect_failure "setpassword should not work" \
+ "${VALGRIND}" "${samba_tool}" user setpassword "${TRUST_DOMAIN}\$" \
+ --random-password "${CONFIGURATION}" || \
+ failed=$((failed + 1))
+
+testit "wbinfo ping dc" \
+ "${VALGRIND}" "${wbinfo}" \
+ --ping-dc --domain="${TRUST_DOMAIN}" || \
+ failed=$((failed + 1))
+
+testit "wbinfo change outgoing trust pw" \
+ "${VALGRIND}" "${wbinfo}" \
+ --change-secret --domain="${TRUST_DOMAIN}" || \
+ failed=$((failed + 1))
+
+testit "wbinfo check outgoing trust pw" \
+ "${VALGRIND}" "${wbinfo}" \
+ --check-secret --domain="${TRUST_DOMAIN}" || \
+ failed=$((failed + 1))
+
+test_smbclient "Test user login with the changed outgoing secret" \
+ "ls" "${SMBCLIENT_UNC}" \
+ --use-kerberos=required \
+ -U"${USERNAME}@${REALM}%${PASSWORD}" || \
+ failed=$((failed + 1))
+
+### Cleanup
+
+rm -f "${KRB5CCNAME_PATH}"
+
+exit $failed
diff --git a/testprogs/blackbox/test_kpasswd_heimdal.sh b/testprogs/blackbox/test_kpasswd_heimdal.sh
new file mode 100755
index 0000000..6a19763
--- /dev/null
+++ b/testprogs/blackbox/test_kpasswd_heimdal.sh
@@ -0,0 +1,245 @@
+#!/bin/sh
+# Blackbox tests for chainging passwords with kinit and kpasswd
+#
+# Copyright (C) 2006-2007 Jelmer Vernooij <jelmer@samba.org>
+# Copyright (C) 2006-2008 Andrew Bartlett <abartlet@samba.org>
+# Copyright (C) 2016 Andreas Schneider <asn@samba.org>
+
+if [ $# -lt 7 ]; then
+ cat <<EOF
+Usage: test_kpasswd_heimdal.sh SERVER USERNAME PASSWORD REALM DOMAIN PREFIX SMBCLIENT CONFIGURATION
+EOF
+ exit 1
+fi
+
+SERVER=$1
+USERNAME=$2
+PASSWORD=$3
+REALM=$4
+DOMAIN=$5
+PREFIX=$6
+CONFIGURATION=${7}
+shift 7
+failed=0
+
+samba_bindir="$BINDIR"
+
+smbclient="$samba_bindir/smbclient"
+samba_kinit=$samba_bindir/samba4kinit
+samba_kpasswd=$samba_bindir/samba4kpasswd
+
+mit_kpasswd="$(command -v kpasswd)"
+
+samba_tool="$samba_bindir/samba-tool"
+net_tool="$samba_bindir/net ${CONFIGURATION}"
+texpect="$samba_bindir/texpect"
+
+newuser="$samba_tool user create"
+SMB_UNC="//$SERVER/tmp"
+
+. $(dirname $0)/subunit.sh
+. $(dirname $0)/common_test_fns.inc
+
+do_kinit()
+{
+ principal="$1"
+ password="$2"
+ shift
+ shift
+ kerberos_kinit "$samba_kinit" "$principal" "$password" "$@"
+}
+
+testit "reset password policies beside of minimum password age of 0 days" \
+ $VALGRIND $PYTHON $samba_tool domain passwordsettings set "${CONFIGURATION}" --complexity=default --history-length=default --min-pwd-length=default --min-pwd-age=0 --max-pwd-age=default || failed=$(expr $failed + 1)
+
+TEST_USERNAME="$(mktemp -u alice-XXXXXX)"
+TEST_PRINCIPAL="$TEST_USERNAME@$REALM"
+TEST_PASSWORD="testPaSS@00%"
+TEST_PASSWORD_NEW="testPaSS@01%"
+TEST_PASSWORD_SHORT="secret"
+TEST_PASSWORD_WEAK="Supersecret"
+
+testit "create user locally" \
+ $VALGRIND $PYTHON $newuser "${CONFIGURATION}" $TEST_USERNAME $TEST_PASSWORD || failed=$(expr $failed + 1)
+
+KRB5CCNAME="$PREFIX/tmpuserccache"
+export KRB5CCNAME
+
+testit "kinit with user password" \
+ do_kinit $TEST_PRINCIPAL $TEST_PASSWORD || failed=$(expr $failed + 1)
+
+test_smbclient "Test login with user kerberos ccache" \
+ "ls" "$SMB_UNC" --use-krb5-ccache=${KRB5CCNAME} || failed=$(expr $failed + 1)
+
+testit "change user password with 'samba-tool user password' (unforced)" \
+ $VALGRIND $PYTHON $samba_tool user password "${CONFIGURATION}" -W$DOMAIN -U$TEST_USERNAME%$TEST_PASSWORD --use-kerberos=off --newpassword=$TEST_PASSWORD_NEW || failed=$(expr $failed + 1)
+
+TEST_PASSWORD_OLD=$TEST_PASSWORD
+TEST_PASSWORD=$TEST_PASSWORD_NEW
+TEST_PASSWORD_NEW="testPaSS@02%"
+
+testit "kinit with user password" \
+ do_kinit $TEST_PRINCIPAL $TEST_PASSWORD || failed=$(expr $failed + 1)
+
+test_smbclient "Test login with user kerberos ccache" \
+ "ls" "$SMB_UNC" --use-krb5-ccache=${KRB5CCNAME} || failed=$(expr $failed + 1)
+
+###########################################################
+### check that a short password is rejected
+###########################################################
+
+cat >$PREFIX/tmpkpasswdscript <<EOF
+expect Password
+password ${TEST_PASSWORD}\n
+expect New password
+send ${TEST_PASSWORD_SHORT}\n
+expect Verify password
+send ${TEST_PASSWORD_SHORT}\n
+expect Password too short
+EOF
+
+testit "kpasswd check short user password" \
+ $texpect $PREFIX/tmpkpasswdscript $samba_kpasswd $TEST_PRINCIPAL || failed=$(expr $failed + 1)
+
+###########################################################
+### check that a weak password is rejected
+###########################################################
+
+echo "check that a short password is rejected"
+cat >$PREFIX/tmpkpasswdscript <<EOF
+expect Password
+password ${TEST_PASSWORD}\n
+expect New password
+send $TEST_PASSWORD_WEAK\n
+expect Verify password
+send $TEST_PASSWORD_WEAK\n
+expect Password does not meet complexity requirements
+EOF
+
+testit "kpasswd check weak user password" \
+ $texpect $PREFIX/tmpkpasswdscript $samba_kpasswd $TEST_PRINCIPAL || failed=$(expr $failed + 1)
+
+###########################################################
+### check that a strong password is accepted
+###########################################################
+
+cat >$PREFIX/tmpkpasswdscript <<EOF
+expect Password
+password ${TEST_PASSWORD}\n
+expect New password
+send ${TEST_PASSWORD_NEW}\n
+expect Verify password
+send ${TEST_PASSWORD_NEW}\n
+expect Success
+EOF
+
+testit "kpasswd change user password" \
+ $texpect $PREFIX/tmpkpasswdscript $samba_kpasswd $TEST_PRINCIPAL || failed=$(expr $failed + 1)
+
+TEST_PASSWORD=$TEST_PASSWORD_NEW
+TEST_PASSWORD_NEW="testPaSS@03%"
+
+###########################################################
+### CVE-2022-2031
+###########################################################
+
+if [ -n "${mit_kpasswd}" ]; then
+ cat > "${PREFIX}/tmpkpasswdscript" <<EOF
+expect Password for ${TEST_PRINCIPAL}
+password ${TEST_PASSWORD}\n
+expect Enter new password
+send ${TEST_PASSWORD_NEW}\n
+expect Enter it again
+send ${TEST_PASSWORD_NEW}\n
+expect Password changed.
+EOF
+
+ SAVE_KRB5_CONFIG="${KRB5_CONFIG}"
+ KRB5_CONFIG="${PREFIX}/tmpkrb5.conf"
+ export KRB5_CONFIG
+ sed -e 's/\[libdefaults\]/[libdefaults]\n canonicalize = yes/' \
+ "${SAVE_KRB5_CONFIG}" > "${KRB5_CONFIG}"
+ testit "MIT kpasswd change user password" \
+ "${texpect}" "${PREFIX}/tmpkpasswdscript" "${mit_kpasswd}" \
+ "${TEST_PRINCIPAL}" ||
+ failed=$((failed + 1))
+ KRB5_CONFIG="${SAVE_KRB5_CONFIG}"
+ export KRB5_CONFIG
+fi
+
+TEST_PASSWORD="${TEST_PASSWORD_NEW}"
+TEST_PASSWORD_NEW="testPaSS@03force%"
+
+###########################################################
+### Force password change at login
+###########################################################
+
+testit "set password on user locally" \
+ $VALGRIND $PYTHON $samba_tool user setpassword $TEST_USERNAME "${CONFIGURATION}" --newpassword=$TEST_PASSWORD_NEW --must-change-at-next-login || failed=$(expr $failed + 1)
+
+TEST_PASSWORD=$TEST_PASSWORD_NEW
+TEST_PASSWORD_NEW="testPaSS@04%"
+
+rm -f $PREFIX/tmpuserccache
+
+cat >$PREFIX/tmpkinitscript <<EOF
+expect Password
+password ${TEST_PASSWORD}\n
+expect Changing password
+expect New password
+send ${TEST_PASSWORD_NEW}\n
+expect Repeat new password
+send ${TEST_PASSWORD_NEW}\n
+expect Success
+EOF
+
+testit "kinit and change user password" \
+ $texpect $PREFIX/tmpkinitscript $samba_kinit $TEST_PRINCIPAL || failed=$(expr $failed + 1)
+
+TEST_PASSWORD=$TEST_PASSWORD_NEW
+TEST_PASSWORD_NEW="testPaSS@07%"
+
+test_smbclient "Test login with user (kerberos)" \
+ "ls" "$SMB_UNC" -k yes -U$TEST_PRINCIPAL%$TEST_PASSWORD || failed=$(expr $failed + 1)
+
+###########################################################
+### Test kpasswd service via 'net ads password'
+###########################################################
+
+# NOTE: This works with heimdal because the krb5_set_password function tries
+# set_password call first and falls back to change_password if it doesn't
+# succeed.
+testit "change user password with 'net ads password', admin: $DOMAIN/$TEST_USERNAME, target: $TEST_PRINCIPAL" \
+ $VALGRIND $net_tool ads password -W$DOMAIN -U$TEST_PRINCIPAL%$TEST_PASSWORD $TEST_PRINCIPAL "$TEST_PASSWORD_NEW" || failed=$(expr $failed + 1)
+
+TEST_PASSWORD=$TEST_PASSWORD_NEW
+TEST_PASSWORD_NEW="testPaSS@08%"
+
+test_smbclient "Test login with smbclient (ntlm)" \
+ "ls" "$SMB_UNC" -k no -U$TEST_PRINCIPAL%$TEST_PASSWORD || failed=$(expr $failed + 1)
+
+###########################################################
+### Test kpasswd service via 'net ads password' as admin
+###########################################################
+
+testit "set user password with 'net ads password', admin: $DOMAIN/$USERNAME, target: $TEST_PRINCIPAL" \
+ $VALGRIND $net_tool ads password -W$DOMAIN -U$USERNAME@$REALM%$PASSWORD $TEST_PRINCIPAL "$TEST_PASSWORD_NEW" || failed=$(expr $failed + 1)
+
+TEST_PASSWORD=$TEST_PASSWORD_NEW
+TEST_PASSWORD_NEW="testPaSS@07%"
+
+test_smbclient "Test login with smbclient (ntlm)" \
+ "ls" "$SMB_UNC" -k no -U$TEST_PRINCIPAL%$TEST_PASSWORD || failed=$(expr $failed + 1)
+
+###########################################################
+### Cleanup
+###########################################################
+
+testit "reset password policies" \
+ $VALGRIND $PYTHON $samba_tool domain passwordsettings set "${CONFIGURATION}" --complexity=default --history-length=default --min-pwd-length=default --min-pwd-age=default --max-pwd-age=default || failed=$(expr $failed + 1)
+
+testit "delete user" \
+ $VALGRIND $PYTHON $samba_tool user delete $TEST_USERNAME -U"$USERNAME%$PASSWORD" "${CONFIGURATION}" -k no || failed=$(expr $failed + 1)
+
+rm -f $PREFIX/tmpuserccache $PREFIX/tmpkpasswdscript $PREFIX/tmpkinitscript
+exit $failed
diff --git a/testprogs/blackbox/test_kpasswd_mit.sh b/testprogs/blackbox/test_kpasswd_mit.sh
new file mode 100755
index 0000000..de22018
--- /dev/null
+++ b/testprogs/blackbox/test_kpasswd_mit.sh
@@ -0,0 +1,224 @@
+#!/bin/sh
+# Blackbox tests for chainging passwords with kinit and kpasswd
+#
+# Copyright (c) 2006-2007 Jelmer Vernooij <jelmer@samba.org>
+# Copyright (c) 2006-2008 Andrew Bartlett <abartlet@samba.org>
+# Copyright (c) 2016 Andreas Schneider <asn@samba.org>
+
+if [ $# -lt 7 ]; then
+ cat <<EOF
+Usage: test_kpasswd_mit.sh SERVER USERNAME PASSWORD REALM DOMAIN PREFIX CONFIGURATION
+EOF
+ exit 1
+fi
+
+SERVER=$1
+USERNAME=$2
+PASSWORD=$3
+REALM=$4
+DOMAIN=$5
+PREFIX=$6
+CONFIGURATION=${7}
+shift 7
+failed=0
+
+samba_bindir="$BINDIR"
+
+samba_kinit=kinit
+samba_kpasswd=kpasswd
+
+smbclient="$samba_bindir/smbclient"
+samba_tool="$samba_bindir/samba-tool"
+net_tool="$samba_bindir/net ${CONFIGURATION}"
+texpect="$samba_bindir/texpect"
+
+newuser="$samba_tool user create ${CONFIGURATION}"
+SMB_UNC="//$SERVER/tmp"
+
+. $(dirname $0)/subunit.sh
+. $(dirname $0)/common_test_fns.inc
+
+do_kinit()
+{
+ principal="$1"
+ password="$2"
+ shift
+ shift
+ echo $password | $samba_kinit $principal
+}
+
+testit "reset password policies beside of minimum password age of 0 days" \
+ $VALGRIND $PYTHON $samba_tool domain passwordsettings set "${CONFIGURATION}" --complexity=default --history-length=default --min-pwd-length=default --min-pwd-age=0 --max-pwd-age=default || failed=$(expr $failed + 1)
+
+TEST_USERNAME="$(mktemp -u samson-XXXXXX)"
+TEST_PASSWORD="testPaSS@00%"
+TEST_PASSWORD_NEW="testPaSS@01%"
+TEST_PASSWORD_SHORT="secret"
+TEST_PASSWORD_WEAK="Supersecret"
+TEST_PRINCIPAL="$TEST_USERNAME@$REALM"
+
+testit "create user locally" \
+ $VALGRIND $PYTHON $newuser "${CONFIGURATION}" $TEST_USERNAME $TEST_PASSWORD || failed=$(expr $failed + 1)
+
+KRB5CCNAME="$PREFIX/tmpuserccache"
+export KRB5CCNAME
+
+testit "kinit with user password" \
+ do_kinit $TEST_PRINCIPAL $TEST_PASSWORD || failed=$(expr $failed + 1)
+
+test_smbclient "Test login with user kerberos ccache" \
+ "ls" "$SMB_UNC" --use-krb5-ccache=$KRB5CCNAME || failed=$(expr $failed + 1)
+
+testit "change user password with 'samba-tool user password' (unforced)" \
+ $VALGRIND $PYTHON $samba_tool user password -W$DOMAIN -U$TEST_USERNAME%$TEST_PASSWORD --use-kerberos=off --newpassword=$TEST_PASSWORD_NEW || failed=$(expr $failed + 1)
+
+TEST_PASSWORD_OLD=$TEST_PASSWORD
+TEST_PASSWORD=$TEST_PASSWORD_NEW
+TEST_PASSWORD_NEW="testPaSS@02%"
+
+testit "kinit with user password" \
+ do_kinit $TEST_PRINCIPAL $TEST_PASSWORD || failed=$(expr $failed + 1)
+
+test_smbclient "Test login with user kerberos ccache" \
+ "ls" "$SMB_UNC" --use-krb5-ccache=$KRB5CCNAME || failed=$(expr $failed + 1)
+
+###########################################################
+### check that a password mismatch is detected
+###########################################################
+
+cat >$PREFIX/tmpkpasswdscript <<EOF
+expect Password for $TEST_PRINCIPAL
+password ${TEST_PASSWORD}\n
+expect Enter new password
+send ${TEST_PASSWORD_WEAK}\n
+expect Enter it again
+send ${TEST_PASSWORD_NEW}\n
+expect kpasswd: Password mismatch while reading password
+EOF
+
+testit_expect_failure "kpasswd check password mismatch" \
+ $texpect $PREFIX/tmpkpasswdscript $samba_kpasswd $TEST_PRINCIPAL || failed=$(expr $failed + 1)
+
+###########################################################
+### check that a short password is rejected
+###########################################################
+
+cat >$PREFIX/tmpkpasswdscript <<EOF
+expect Password for $TEST_PRINCIPAL
+password ${TEST_PASSWORD}\n
+expect Enter new password
+send ${TEST_PASSWORD_SHORT}\n
+expect Enter it again
+send ${TEST_PASSWORD_SHORT}\n
+expect Password change rejected: Password too short, password must be at least 7 characters long
+EOF
+
+testit_expect_failure "kpasswd check short user password" \
+ $texpect $PREFIX/tmpkpasswdscript $samba_kpasswd $TEST_PRINCIPAL || failed=$(expr $failed + 1)
+
+###########################################################
+### check that a weak password is rejected
+###########################################################
+
+cat >$PREFIX/tmpkpasswdscript <<EOF
+expect Password for $TEST_PRINCIPAL
+password ${TEST_PASSWORD}\n
+expect Enter new password
+send ${TEST_PASSWORD_WEAK}\n
+expect Enter it again
+send ${TEST_PASSWORD_WEAK}\n
+expect Password change rejected: Password does not meet complexity requirement
+EOF
+
+testit_expect_failure "kpasswd check weak user password" \
+ $texpect $PREFIX/tmpkpasswdscript $samba_kpasswd $TEST_PRINCIPAL || failed=$(expr $failed + 1)
+
+###########################################################
+### check that a strong password is accepted
+###########################################################
+
+cat >$PREFIX/tmpkpasswdscript <<EOF
+expect Password for $TEST_PRINCIPAL
+password ${TEST_PASSWORD}\n
+expect Enter new password
+send ${TEST_PASSWORD_NEW}\n
+expect Enter it again
+send ${TEST_PASSWORD_NEW}\n
+expect Password changed.
+EOF
+
+testit "kpasswd change user password" \
+ $texpect $PREFIX/tmpkpasswdscript $samba_kpasswd $TEST_PRINCIPAL || failed=$(expr $failed + 1)
+
+TEST_PASSWORD=$TEST_PASSWORD_NEW
+TEST_PASSWORD_NEW="testPaSS@03%"
+
+test_smbclient "Test login with user kerberos" 'ls' "$SMB_UNC" --use-kerberos=required -U$TEST_PRINCIPAL%$TEST_PASSWORD || failed=$(expr $failed + 1)
+
+###########################################################
+### Force password change at login
+###########################################################
+
+testit "set password on user locally" \
+ $VALGRIND $PYTHON $samba_tool user setpassword $TEST_USERNAME "${CONFIGURATION}" --newpassword=$TEST_PASSWORD_NEW --must-change-at-next-login || failed=$(expr $failed + 1)
+
+TEST_PASSWORD=$TEST_PASSWORD_NEW
+TEST_PASSWORD_NEW="testPaSS@04%"
+
+cat >$PREFIX/tmpkinitscript <<EOF
+expect Password for $TEST_PRINCIPAL
+password ${TEST_PASSWORD}\n
+expect Password expired
+expect Enter new password
+send ${TEST_PASSWORD_NEW}\n
+expect Enter it again
+send ${TEST_PASSWORD_NEW}\n
+EOF
+
+testit "kinit and change user password" \
+ $texpect $PREFIX/tmpkinitscript $samba_kinit $TEST_PRINCIPAL || failed=$(expr $failed + 1)
+
+TEST_PASSWORD=$TEST_PASSWORD_NEW
+TEST_PASSWORD_NEW="testPaSS@05%"
+
+test_smbclient "Test login with user kerberos" \
+ "ls" "$SMB_UNC" --use-kerberos=required -U$TEST_PRINCIPAL%$TEST_PASSWORD || failed=$(expr $failed + 1)
+
+###########################################################
+### Test kpasswd service via 'net ads password'
+###########################################################
+
+testit "change user password with 'net ads password', admin: $DOMAIN/$TEST_USERNAME, target: $TEST_PRINCIPAL" \
+ $VALGRIND $net_tool ads password -W$DOMAIN -U$TEST_PRINCIPAL%$TEST_PASSWORD $TEST_PRINCIPAL "$TEST_PASSWORD_NEW" || failed=$(expr $failed + 1)
+
+#TEST_PASSWORD=$TEST_PASSWORD_NEW
+#TEST_PASSWORD_NEW="testPaSS@06%"
+
+#test_smbclient "Test login with smbclient (ntlm)" \
+# "ls" "$SMB_UNC" --use-kerberos=disabled -U$TEST_PRINCIPAL%$TEST_PASSWORD || failed=`expr $failed + 1`
+
+###########################################################
+### Test kpasswd service via 'net ads password' as admin
+###########################################################
+
+testit "set user password with 'net ads password', admin: $DOMAIN/$USERNAME, target: $TEST_PRINCIPAL" \
+ $VALGRIND $net_tool ads password -W$DOMAIN -U$USERNAME@$REALM%$PASSWORD $TEST_PRINCIPAL "$TEST_PASSWORD_NEW" || failed=$(expr $failed + 1)
+
+TEST_PASSWORD=$TEST_PASSWORD_NEW
+TEST_PASSWORD_NEW="testPaSS@07%"
+
+test_smbclient "Test login with smbclient (ntlm)" \
+ "ls" "$SMB_UNC" --use-kerberos=disabled -U$TEST_PRINCIPAL%$TEST_PASSWORD || failed=$(expr $failed + 1)
+
+###########################################################
+### Cleanup
+###########################################################
+
+testit "reset password policies" \
+ $VALGRIND $PYTHON $samba_tool domain passwordsettings set "${CONFIGURATION}" --complexity=default --history-length=default --min-pwd-length=default --min-pwd-age=default --max-pwd-age=default || failed=$(expr $failed + 1)
+
+testit "delete user" \
+ $VALGRIND $PYTHON $samba_tool user delete $TEST_USERNAME -U"$USERNAME%$PASSWORD" "${CONFIGURATION}" --use-kerberos=off || failed=$(expr $failed + 1)
+
+rm -f $PREFIX/tmpuserccache $PREFIX/tmpkpasswdscript $PREFIX/tmpkinitscript
+exit $failed
diff --git a/testprogs/blackbox/test_ktpass.sh b/testprogs/blackbox/test_ktpass.sh
new file mode 100755
index 0000000..719d42f
--- /dev/null
+++ b/testprogs/blackbox/test_ktpass.sh
@@ -0,0 +1,38 @@
+#!/bin/sh
+
+if [ $# -lt 1 ]; then
+ cat <<EOF
+Usage: test_ktpass.sh PREFIX
+EOF
+ exit 1
+fi
+
+PREFIX="$1"
+shift 1
+
+. $(dirname $0)/subunit.sh
+
+samba_tool="$BINDIR/samba-tool"
+samba4bindir="$BINDIR"
+samba4srcdir="$SRCDIR/source4"
+samba4kinit_binary=$(system_or_builddir_binary kinit "${BINDIR}" samba4kinit)
+
+CONFIG="--configfile=$PREFIX/etc/smb.conf"
+
+TESTUSER="ktpassUser"
+
+testit "user create" $PYTHON $samba_tool user create $CONFIG $TESTUSER testp@ssw0Rd || failed=$(expr $failed + 1)
+
+KRB5CCNAME="$PREFIX/tmpccache"
+samba4kinit="$samba4kinit_binary -c $KRB5CCNAME"
+export KRB5CCNAME
+echo "testp@ssw0Rd" >$PREFIX/tmppassfile
+testit "kinit with passwd" $samba4kinit -e arcfour-hmac-md5 --password-file=$PREFIX/tmppassfile $TESTUSER@SAMBA.EXAMPLE.COM || failed=$(expr $failed + 1)
+testit "ktpass" $samba4srcdir/scripting/bin/ktpass.sh --host LOCALDC --out $PREFIX/testuser.kt --princ $TESTUSER --pass "testp@ssw0Rd" --path-to-ldbsearch=$BINDIR/bin || failed=$(expr $failed + 1)
+
+rm -f $KRB5CCNAME
+
+testit "kinit with keytab" $samba4kinit -e arcfour-hmac-md5 --use-keytab -t $PREFIX/testuser.kt $TESTUSER@SAMBA.EXAMPLE.COM || failed=$(expr $failed + 1)
+
+rm -f $PREFIX/tmpccache $PREFIX/testuser.kt
+exit $failed
diff --git a/testprogs/blackbox/test_ldap_tls_reload.sh b/testprogs/blackbox/test_ldap_tls_reload.sh
new file mode 100755
index 0000000..d0c9af1
--- /dev/null
+++ b/testprogs/blackbox/test_ldap_tls_reload.sh
@@ -0,0 +1,64 @@
+#!/bin/bash
+#
+
+if [ $# -ne 3 ]; then
+ cat <<EOF
+Usage: test_ldap_tls_reload.sh PREFIX TLSDIR SERVER
+EOF
+ exit 1
+fi
+
+PREFIX=$1
+TLSDIR=$2
+SERVER=$3
+
+. $(dirname $0)/subunit.sh
+. "$(dirname "${0}")/common_test_fns.inc"
+
+ldbsearch="${VALGRIND} $(system_or_builddir_binary ldbsearch "${BINDIR}")"
+smbcontrol="${VALGRIND} ${BINDIR}/smbcontrol"
+
+rm -rf "$PREFIX/ldap_tls_reload"
+
+store_cert() {
+ FILE=$1
+ gnutls-cli --save-cert="$FILE" --no-ca-verification --verify-hostname=$SERVER --port 636 $SERVER < /dev/null
+ return $?
+}
+
+delete_certs() {
+ ls "${TLSDIR}/"*.pem
+ rm -v "${TLSDIR}/ca.pem" "${TLSDIR}/cert.pem" "${TLSDIR}/key.pem"
+ return $?
+}
+
+reload_certs() {
+ $smbcontrol ldap_server reload-certs
+ return $?
+}
+
+testit "mkdir $PREFIX/ldap_tls_reload" mkdir $PREFIX/ldap_tls_reload || failed=$(expr $failed + 1)
+
+testit "currentTime 1" $ldbsearch --basedn='' -H ldaps://$SERVER --scope=base currentTime || failed=$(expr $failed + 1)
+
+testit "store cert output 1a" store_cert $PREFIX/ldap_tls_reload/cert1a.pem || failed=$(expr $failed + 1)
+
+testit "delete certs" delete_certs || failed=$(expr $failed + 1)
+
+testit "store cert output 1b" store_cert $PREFIX/ldap_tls_reload/cert1b.pem || failed=$(expr $failed + 1)
+
+testit "check cert1a == cert1b" cmp $PREFIX/ldap_tls_reload/cert1a.pem $PREFIX/ldap_tls_reload/cert1b.pem || failed=$(expr $failed + 1)
+
+testit "reload certs " reload_certs || failed=$(expr $failed + 1)
+
+testit "sleep 10" sleep 10 || failed=$(expr $failed + 1)
+
+testit "store cert output 2" store_cert $PREFIX/ldap_tls_reload/cert2.pem || failed=$(expr $failed + 1)
+
+testit_expect_failure "check cert1a != cert2" cmp $PREFIX/ldap_tls_reload/cert1a.pem $PREFIX/ldap_tls_reload/cert2.pem || failed=$(expr $failed + 1)
+
+testit "currentTime 2" $ldbsearch $CONFIGURATION --basedn='' -H ldaps://$SERVER --scope=base currentTime || failed=$(expr $failed + 1)
+
+rm -rf "$PREFIX/ldap_tls_reload"
+
+testok $0 $failed
diff --git a/testprogs/blackbox/test_ldb.sh b/testprogs/blackbox/test_ldb.sh
new file mode 100755
index 0000000..e35d66e
--- /dev/null
+++ b/testprogs/blackbox/test_ldb.sh
@@ -0,0 +1,230 @@
+#!/bin/sh
+
+if [ $# -lt 2 ]; then
+ cat <<EOF
+Usage: test_ldb.sh PROTOCOL SERVER [OPTIONS]
+EOF
+ exit 1
+fi
+
+p=$1
+SERVER=$2
+PREFIX=$3
+shift 2
+options="$*"
+
+. $(dirname $0)/subunit.sh
+. "$(dirname "${0}")/common_test_fns.inc"
+
+check()
+{
+ name="$1"
+ shift
+ cmdline="$*"
+ echo "test: $name"
+ $cmdline
+ status=$?
+ if [ x$status = x0 ]; then
+ echo "success: $name"
+ else
+ echo "failure: $name"
+ failed=$(expr $failed + 1)
+ fi
+ return $status
+}
+
+ldbsearch="${VALGRIND} $(system_or_builddir_binary ldbsearch "${BINDIR}")"
+
+check "RootDSE" $ldbsearch $CONFIGURATION $options --basedn='' -H $p://$SERVER --scope=base DUMMY=x dnsHostName highestCommittedUSN || failed=$(expr $failed + 1)
+check "RootDSE (full)" $ldbsearch $CONFIGURATION $options --basedn='' -H $p://$SERVER --scope=base '(objectClass=*)' || failed=$(expr $failed + 1)
+check "RootDSE (extended)" $ldbsearch $CONFIGURATION $options --basedn='' -H $p://$SERVER --scope=base '(objectClass=*)' --extended-dn || failed=$(expr $failed + 1)
+if [ x$p = x"ldaps" ]; then
+ testit_expect_failure "RootDSE over SSLv3 should fail" $ldbsearch $CONFIGURATION $options --basedn='' -H $p://$SERVER --scope=base DUMMY=x dnsHostName highestCommittedUSN --option='tlspriority=NONE:+VERS-SSL3.0:+MAC-ALL:+CIPHER-ALL:+RSA:+SIGN-ALL:+COMP-NULL' || failed=$(expr $failed + 1)
+fi
+
+echo "Getting defaultNamingContext"
+BASEDN=$($ldbsearch $CONFIGURATION $options --basedn='' -H $p://$SERVER --scope=base DUMMY=x defaultNamingContext | grep defaultNamingContext | awk '{print $2}')
+echo "BASEDN is $BASEDN"
+
+check "Listing Users" $ldbsearch $options $CONFIGURATION -H $p://$SERVER '(objectclass=user)' sAMAccountName || failed=$(expr $failed + 1)
+
+check "Listing Users (sorted)" $ldbsearch -S $options $CONFIGURATION -H $p://$SERVER '(objectclass=user)' sAMAccountName || failed=$(expr $failed + 1)
+
+check "Listing Groups" $ldbsearch $options $CONFIGURATION -H $p://$SERVER '(objectclass=group)' sAMAccountName || failed=$(expr $failed + 1)
+
+nentries=$($ldbsearch $options -H $p://$SERVER $CONFIGURATION '(|(|(&(!(groupType:1.2.840.113556.1.4.803:=1))(groupType:1.2.840.113556.1.4.803:=2147483648)(groupType:1.2.840.113556.1.4.804:=10))(samAccountType=805306368))(samAccountType=805306369))' sAMAccountName | grep sAMAccountName | wc -l)
+echo "Found $nentries entries"
+if [ $nentries -lt 10 ]; then
+ echo "Should have found at least 10 entries"
+ failed=$(expr $failed + 1)
+fi
+
+echo "Check rootDSE for Controls"
+nentries=$($ldbsearch $options $CONFIGURATION -H $p://$SERVER --scope=base -b "" '(objectclass=*)' | grep -i supportedControl | wc -l)
+if [ $nentries -lt 4 ]; then
+ echo "Should have found at least 4 entries"
+ failed=$(expr $failed + 1)
+fi
+
+echo "Test Paged Results Control"
+nentries=$($ldbsearch $options $CONFIGURATION -H $p://$SERVER --controls=paged_results:1:5 '(objectclass=user)' | grep sAMAccountName | wc -l)
+if [ $nentries -lt 1 ]; then
+ echo "Paged Results Control test returned 0 items"
+ failed=$(expr $failed + 1)
+fi
+
+echo "Test Server Sort Control"
+nentries=$($ldbsearch $options $CONFIGURATION -H $p://$SERVER --controls=server_sort:1:0:sAMAccountName '(objectclass=user)' | grep sAMAccountName | wc -l)
+if [ $nentries -lt 1 ]; then
+ echo "Server Sort Control test returned 0 items"
+ failed=$(expr $failed + 1)
+fi
+
+echo "Test Extended DN Control"
+nentries=$($ldbsearch $options $CONFIGURATION -H $p://$SERVER --controls=extended_dn:1 '(objectclass=user)' | grep sAMAccountName | wc -l)
+if [ $nentries -lt 1 ]; then
+ echo "Extended DN Control test returned 0 items"
+ failed=$(expr $failed + 1)
+fi
+nentries=$($ldbsearch $options $CONFIGURATION -H $p://$SERVER --controls=extended_dn:1:0 '(objectclass=user)' | grep sAMAccountName | wc -l)
+if [ $nentries -lt 1 ]; then
+ echo "Extended DN Control test returned 0 items"
+ failed=$(expr $failed + 1)
+fi
+nentries=$($ldbsearch $options $CONFIGURATION -H $p://$SERVER --controls=extended_dn:1:1 '(objectclass=user)' | grep sAMAccountName | wc -l)
+if [ $nentries -lt 1 ]; then
+ echo "Extended DN Control test returned 0 items"
+ failed=$(expr $failed + 1)
+fi
+
+echo "Test Domain scope Control"
+nentries=$($ldbsearch $options $CONFIGURATION -H $p://$SERVER --controls=domain_scope:1 '(objectclass=user)' | grep sAMAccountName | wc -l)
+if [ $nentries -lt 1 ]; then
+ echo "Extended Domain scope Control test returned 0 items"
+ failed=$(expr $failed + 1)
+fi
+
+echo "Test Attribute Scope Query Control"
+nentries=$($ldbsearch $options $CONFIGURATION -H $p://$SERVER --controls=asq:1:member --scope=base -b "CN=Administrators,CN=Builtin,$BASEDN" | grep sAMAccountName | wc -l)
+if [ $nentries -lt 1 ]; then
+ echo "Attribute Scope Query test returned 0 items"
+ failed=$(expr $failed + 1)
+fi
+
+echo "Test Search Options Control"
+nentries=$($ldbsearch $options $CONFIGURATION -H $p://$SERVER --controls=search_options:1:2 '(objectclass=crossRef)' | grep crossRef | wc -l)
+if [ $nentries -lt 1 ]; then
+ echo "Search Options Control Query test returned 0 items"
+ failed=$(expr $failed + 1)
+fi
+
+echo "Test Search Options Control with Domain Scope Control"
+nentries=$($ldbsearch $options $CONFIGURATION -H $p://$SERVER --controls=search_options:1:2,domain_scope:1 '(objectclass=crossRef)' | grep crossRef | wc -l)
+if [ $nentries -lt 1 ]; then
+ echo "Search Options Control Query test returned 0 items"
+ failed=$(expr $failed + 1)
+fi
+
+wellknown_object_test()
+(
+ guid=$1
+ object=$2
+ failed=0
+
+ basedns="<WKGUID=${guid},${BASEDN}> <wkGuId=${guid},${BASEDN}>"
+ for dn in ${basedns}; do
+ echo "Test ${dn} => ${object}"
+ r=$($ldbsearch $options $CONFIGURATION -H $p://$SERVER '(objectClass=*)' -b "${dn}" | grep 'dn: ')
+ n=$(echo "${r}" | grep 'dn: ' | wc -l)
+ c=$(echo "${r}" | grep "${object}" | wc -l)
+
+ if [ $n -lt 1 ]; then
+ echo "Object not found by WKGUID"
+ failed=$(expr $failed + 1)
+ continue
+ fi
+ if [ $c -lt 1 ]; then
+ echo "Wrong object found by WKGUID: [${r}]"
+ failed=$(expr $failed + 1)
+ continue
+ fi
+ done
+
+ return $failed
+)
+
+wellknown_object_test 22B70C67D56E4EFB91E9300FCA3DC1AA ForeignSecurityPrincipals
+st=$?
+if [ x"$st" != x"0" ]; then
+ failed=$(expr $failed + $st)
+fi
+wellknown_object_test 2FBAC1870ADE11D297C400C04FD8D5CD Infrastructure
+st=$?
+if [ x"$st" != x"0" ]; then
+ failed=$(expr $failed + $st)
+fi
+wellknown_object_test AB1D30F3768811D1ADED00C04FD8D5CD System
+st=$?
+if [ x"$st" != x"0" ]; then
+ failed=$(expr $failed + $st)
+fi
+wellknown_object_test A361B2FFFFD211D1AA4B00C04FD7D83A Domain Controllers
+st=$?
+if [ x"$st" != x"0" ]; then
+ failed=$(expr $failed + $st)
+fi
+wellknown_object_test AA312825768811D1ADED00C04FD8D5CD Computers
+st=$?
+if [ x"$st" != x"0" ]; then
+ failed=$(expr $failed + $st)
+fi
+wellknown_object_test A9D1CA15768811D1ADED00C04FD8D5CD Users
+st=$?
+if [ x"$st" != x"0" ]; then
+ failed=$(expr $failed + $st)
+fi
+
+echo "Getting HEX GUID/SID of $BASEDN"
+HEXDN=$($ldbsearch $CONFIGURATION $options -b "$BASEDN" -H $p://$SERVER --scope=base "(objectClass=*)" --controls=extended_dn:1:0 distinguishedName | grep 'distinguishedName: ' | cut -d ' ' -f2-)
+HEXGUID=$(echo "$HEXDN" | cut -d ';' -f1)
+echo "HEXGUID[$HEXGUID]"
+
+echo "Getting STR GUID/SID of $BASEDN"
+STRDN=$($ldbsearch $CONFIGURATION $options -b "$BASEDN" -H $p://$SERVER --scope=base "(objectClass=*)" --controls=extended_dn:1:1 distinguishedName | grep 'distinguishedName: ' | cut -d ' ' -f2-)
+echo "STRDN: $STRDN"
+STRGUID=$(echo "$STRDN" | cut -d ';' -f1)
+echo "STRGUID[$STRGUID]"
+
+echo "Getting STR GUID/SID of $BASEDN"
+STRDN=$($ldbsearch $CONFIGURATION $options -b "$BASEDN" -H $p://$SERVER --scope=base "(objectClass=*)" --controls=extended_dn:1:1 | grep 'dn: ' | cut -d ' ' -f2-)
+echo "STRDN: $STRDN"
+STRSID=$(echo "$STRDN" | cut -d ';' -f2)
+echo "STRSID[$STRSID]"
+
+SPECIALDNS="$HEXGUID $STRGUID $STRSID"
+for SPDN in $SPECIALDNS; do
+ echo "Search for $SPDN"
+ nentries=$($ldbsearch $options $CONFIGURATION -H $p://$SERVER --scope=base -b "$SPDN" '(objectClass=*)' | grep "dn: $BASEDN" | wc -l)
+ if [ $nentries -lt 1 ]; then
+ echo "Special search returned 0 items"
+ failed=$(expr $failed + 1)
+ fi
+done
+
+echo "Search using OIDs instead of names"
+nentries1=$($ldbsearch $options $CONFIGURATION -H $p://$SERVER '(objectClass=user)' name | grep "^name: " | wc -l)
+nentries2=$($ldbsearch $options $CONFIGURATION -H $p://$SERVER '(2.5.4.0=1.2.840.113556.1.5.9)' name | grep "^name: " | wc -l)
+if [ $nentries1 -lt 1 ]; then
+ echo "Error: Searching user via (objectClass=user): '$nentries1' < 1"
+ failed=$(expr $failed + 1)
+fi
+if [ $nentries2 -lt 1 ]; then
+ echo "Error: Searching user via (2.5.4.0=1.2.840.113556.1.5.9) '$nentries2' < 1"
+ failed=$(expr $failed + 1)
+fi
+if [ x"$nentries1" != x"$nentries2" ]; then
+ echo "Error: Searching user with OIDS[$nentries1] doesn't return the same as STRINGS[$nentries2]"
+ failed=$(expr $failed + 1)
+fi
+
+exit $failed
diff --git a/testprogs/blackbox/test_ldb_simple.sh b/testprogs/blackbox/test_ldb_simple.sh
new file mode 100755
index 0000000..5f5f9b8
--- /dev/null
+++ b/testprogs/blackbox/test_ldb_simple.sh
@@ -0,0 +1,40 @@
+#!/bin/sh
+
+if [ $# -lt 2 ]; then
+ cat <<EOF
+Usage: test_ldb_simple.sh PROTOCOL SERVER [OPTIONS]
+EOF
+ exit 1
+fi
+
+p=$1
+SERVER=$2
+PREFIX=$3
+shift 2
+options="$*"
+
+. $(dirname $0)/subunit.sh
+. "$(dirname "${0}")/common_test_fns.inc"
+
+check()
+{
+ name="$1"
+ shift
+ cmdline="$*"
+ echo "test: $name"
+ $cmdline
+ status=$?
+ if [ x$status = x0 ]; then
+ echo "success: $name"
+ else
+ echo "failure: $name"
+ failed=$(expr $failed + 1)
+ fi
+ return $status
+}
+
+ldbsearch="${VALGRIND} $(system_or_builddir_binary ldbsearch "${BINDIR}")"
+
+check "currentTime" $ldbsearch $CONFIGURATION $options --basedn='' -H $p://$SERVER --scope=base currentTime || failed=$(expr $failed + 1)
+
+exit $failed
diff --git a/testprogs/blackbox/test_net_ads.sh b/testprogs/blackbox/test_net_ads.sh
new file mode 100755
index 0000000..7de064d
--- /dev/null
+++ b/testprogs/blackbox/test_net_ads.sh
@@ -0,0 +1,364 @@
+if [ $# -lt 4 ]; then
+ cat <<EOF
+Usage: test_net_ads.sh DC_SERVER DC_USERNAME DC_PASSWORD BASEDIR
+EOF
+ exit 1
+fi
+
+DC_SERVER=$1
+DC_USERNAME=$2
+DC_PASSWORD=$3
+BASEDIR=$4
+
+HOSTNAME=$(dd if=/dev/urandom bs=1 count=32 2>/dev/null | sha1sum | cut -b 1-10)
+
+RUNDIR=$(pwd)
+cd $BASEDIR
+WORKDIR=$(mktemp -d -p .)
+WORKDIR=$(basename $WORKDIR)
+cp -a client/* $WORKDIR/
+sed -ri "s@(dir|directory) = (.*)/client/@\1 = \2/$WORKDIR/@" $WORKDIR/client.conf
+sed -ri "s/netbios name = .*/netbios name = $HOSTNAME/" $WORKDIR/client.conf
+rm -f $WORKDIR/private/secrets.tdb
+cd $RUNDIR
+
+failed=0
+
+net_tool="$BINDIR/net --configfile=$BASEDIR/$WORKDIR/client.conf --option=security=ads"
+
+# Load test functions
+. $(dirname $0)/subunit.sh
+. "$(dirname "${0}")/common_test_fns.inc"
+
+ldbadd=$(system_or_builddir_binary ldbadd "${BINDIR}")
+ldbmodify=$(system_or_builddir_binary ldbmodify "${BINDIR}")
+ldbdel=$(system_or_builddir_binary ldbdel "${BINDIR}")
+ldbsearch=$(system_or_builddir_binary ldbsearch "${BINDIR}")
+
+testit "join" $VALGRIND $net_tool ads join -U$DC_USERNAME%$DC_PASSWORD || failed=$(expr $failed + 1)
+
+workgroup=$(awk '/workgroup =/ { print $NR }' "${BASEDIR}/${WORKDIR}/client.conf")
+testit "local krb5.conf created" \
+ test -r \
+ "${BASEDIR}/${WORKDIR}/lockdir/smb_krb5/krb5.conf.${workgroup}" ||
+ failed=$((failed + 1))
+
+testit "testjoin" $VALGRIND $net_tool ads testjoin -P --use-kerberos=required || failed=$(expr $failed + 1)
+
+netbios=$(grep "netbios name" $BASEDIR/$WORKDIR/client.conf | cut -f2 -d= | awk '{$1=$1};1')
+
+testit "test setspn list $netbios" $VALGRIND $net_tool ads setspn list $netbios -U$DC_USERNAME%$DC_PASSWORD || failed=$(expr $failed + 1)
+spn="foo"
+testit_expect_failure "test setspn add illegal windows spn ($spn)" $VALGRIND $net_tool ads setspn add $spn -U$DC_USERNAME%$DC_PASSWORD || failed=$(expr $failed + 1)
+
+spn="foo/somehost.domain.com"
+testit "test setspn add ($spn)" $VALGRIND $net_tool ads setspn add $spn -U$DC_USERNAME%$DC_PASSWORD || failed=$(expr $failed + 1)
+
+found=$($net_tool ads setspn list -U$DC_USERNAME%$DC_PASSWORD | grep $spn | wc -l)
+testit "test setspn list shows the newly added spn ($spn)" test $found -eq 1 || failed=$(expr $failed + 1)
+
+up_spn=$(echo $spn | tr '[:lower:]' '[:upper:]')
+testit_expect_failure "test setspn add existing (case-insensitive) spn ($spn)" $VALGRIND $net_tool ads setspn add $up_spn -U$DC_USERNAME%$DC_PASSWORD || failed=$(expr $failed + 1)
+
+testit "test setspn delete existing (case-insensitive) ($spn)" $VALGRIND $net_tool ads setspn delete $spn -U$DC_USERNAME%$DC_PASSWORD || failed=$(expr $failed + 1)
+
+found=$($net_tool ads setspn list -U$DC_USERNAME%$DC_PASSWORD | grep $spn | wc -l)
+testit "test setspn list shows the newly deleted spn ($spn) is gone" test $found -eq 0 || failed=$(expr $failed + 1)
+
+testit "changetrustpw" $VALGRIND $net_tool ads changetrustpw || failed=$(expr $failed + 1)
+
+testit "leave" $VALGRIND $net_tool ads leave -U$DC_USERNAME%$DC_PASSWORD || failed=$(expr $failed + 1)
+
+# Test with kerberos method = secrets and keytab
+dedicated_keytab_file="$BASEDIR/$WORKDIR/test_net_ads_dedicated_krb5.keytab"
+testit "join (dedicated keytab)" $VALGRIND $net_tool ads join -U$DC_USERNAME%$DC_PASSWORD --option="kerberosmethod=dedicatedkeytab" --option="dedicatedkeytabfile=$dedicated_keytab_file" || failed=$(expr $failed + 1)
+
+testit "testjoin (dedicated keytab)" $VALGRIND $net_tool ads testjoin -P --use-kerberos=required || failed=$(expr $failed + 1)
+
+netbios=$(grep "netbios name" $BASEDIR/$WORKDIR/client.conf | cut -f2 -d= | awk '{$1=$1};1')
+uc_netbios=$(echo $netbios | tr '[:lower:]' '[:upper:]')
+lc_realm=$(echo $REALM | tr '[:upper:]' '[:lower:]')
+fqdn="$netbios.$lc_realm"
+
+krb_princ="primary/instance@$REALM"
+testit "test (dedicated keytab) add a fully qualified krb5 principal" $VALGRIND $net_tool ads keytab add $krb_princ -U$DC_USERNAME%$DC_PASSWORD --option="kerberosmethod=dedicatedkeytab" --option="dedicatedkeytabfile=$dedicated_keytab_file" || failed=$(expr $failed + 1)
+
+found=$($net_tool ads keytab list -U$DC_USERNAME%$DC_PASSWORD --option="kerberosmethod=dedicatedkeytab" --option="dedicatedkeytabfile=$dedicated_keytab_file" | grep $krb_princ | wc -l)
+
+testit "test (dedicated keytab) at least one fully qualified krb5 principal that was added is present in keytab" test $found -gt 1 || failed=$(expr $failed + 1)
+
+machinename="machine123"
+testit "test (dedicated keytab) add a kerberos principal created from machinename to keytab" $VALGRIND $net_tool ads keytab add $machinename'$' -U$DC_USERNAME%$DC_PASSWORD --option="kerberosmethod=dedicatedkeytab" --option="dedicatedkeytabfile=$dedicated_keytab_file" || failed=$(expr $failed + 1)
+search_str="$machinename\$@$REALM"
+found=$($net_tool ads keytab list -U$DC_USERNAME%$DC_PASSWORD --option="kerberosmethod=dedicatedkeytab" --option="dedicatedkeytabfile=$dedicated_keytab_file" | grep $search_str | wc -l)
+testit "test (dedicated keytab) at least one krb5 principal created from $machinename added is present in keytab" test $found -gt 1 || failed=$(expr $failed + 1)
+
+service="nfs"
+testit "test (dedicated keytab) add a $service service to keytab" $VALGRIND $net_tool ads keytab add $service -U$DC_USERNAME%$DC_PASSWORD --option="kerberosmethod=dedicatedkeytab" --option="dedicatedkeytabfile=$dedicated_keytab_file" || failed=$(expr $failed + 1)
+
+search_str="$service/$fqdn@$REALM"
+found=$($net_tool ads keytab list -U$DC_USERNAME%$DC_PASSWORD --option="kerberosmethod=dedicatedkeytab" --option="dedicatedkeytabfile=$dedicated_keytab_file" | grep $search_str | wc -l)
+testit "test (dedicated keytab) at least one (long form) krb5 principal created from service added is present in keytab" test $found -gt 1 || failed=$(expr $failed + 1)
+
+search_str="$service/$uc_netbios@$REALM"
+found=$($net_tool ads keytab list -U$DC_USERNAME%$DC_PASSWORD --option="kerberosmethod=dedicatedkeytab" --option="dedicatedkeytabfile=$dedicated_keytab_file" | grep $search_str | wc -l)
+testit "test (dedicated keytab) at least one (shorter form) krb5 principal created from service added is present in keytab" test $found -gt 1 || failed=$(expr $failed + 1)
+
+spn_service="random_srv"
+spn_host="somehost.subdomain.domain"
+spn_port="12345"
+
+windows_spn="$spn_service/$spn_host"
+testit "test (dedicated keytab) add a $windows_spn windows style SPN to keytab" $VALGRIND $net_tool ads keytab add $windows_spn -U$DC_USERNAME%$DC_PASSWORD --option="kerberosmethod=dedicatedkeytab" --option="dedicatedkeytabfile=$dedicated_keytab_file" || failed=$(expr $failed + 1)
+
+search_str="$spn_service/$spn_host@$REALM"
+found=$($net_tool ads keytab list -U$DC_USERNAME%$DC_PASSWORD --option="kerberosmethod=dedicatedkeytab" --option="dedicatedkeytabfile=$dedicated_keytab_file" | grep $search_str | wc -l)
+testit "test (dedicated keytab) at least one krb5 principal created from windown SPN added is present in keytab" test $found -gt 1 || failed=$(expr $failed + 1)
+
+windows_spn="$spn_service/$spn_host:$spn_port"
+testit "test (dedicated keytab) add a $windows_spn windows style SPN to keytab" $VALGRIND $net_tool ads keytab add $windows_spn -U$DC_USERNAME%$DC_PASSWORD --option="kerberosmethod=dedicatedkeytab" --option="dedicatedkeytabfile=$dedicated_keytab_file" || failed=$(expr $failed + 1)
+
+search_str="$spn_service/$spn_host@$REALM"
+found=$($net_tool ads keytab list -U$DC_USERNAME%$DC_PASSWORD --option="kerberosmethod=dedicatedkeytab" --option="dedicatedkeytabfile=$dedicated_keytab_file" | grep $search_str | wc -l)
+testit "test (dedicated keytab) at least one krb5 principal created from windown SPN (with port) added is present in keytab" test $found -gt 1 || failed=$(expr $failed + 1)
+
+# keytab add shouldn't have written spn to AD
+found=$($net_tool ads setspn list -U$DC_USERNAME%$DC_PASSWORD | grep $service | wc -l)
+testit "test (dedicated keytab) spn is not written to AD (using keytab add)" test $found -eq 0 || failed=$(expr $failed + 1)
+
+ad_service="writetoad"
+testit "test (dedicated keytab) add a $ad_service service to keytab (using add_update_ads" $VALGRIND $net_tool ads keytab add_update_ads $ad_service -U$DC_USERNAME%$DC_PASSWORD --option="kerberosmethod=dedicatedkeytab" --option="dedicatedkeytabfile=$dedicated_keytab_file" || failed=$(expr $failed + 1)
+
+found=$($net_tool ads setspn list -U$DC_USERNAME%$DC_PASSWORD | grep $ad_service | wc -l)
+testit "test (dedicated keytab) spn is written to AD (using keytab add_update_ads)" test $found -eq 2 || failed=$(expr $failed + 1)
+
+# test existence in keytab of service (previously added) pulled from SPN post
+# 'keytab create' is now present in keytab file
+testit "test (dedicated keytab) keytab created succeeds" $VALGRIND $net_tool ads keytab create -U$DC_USERNAME%$DC_PASSWORD --option="kerberosmethod=dedicatedkeytab" --option="dedicatedkeytabfile=$dedicated_keytab_file" || failed=$(expr $failed + 1)
+found=$($net_tool ads keytab list -U$DC_USERNAME%$DC_PASSWORD --option="kerberosmethod=dedicatedkeytab" --option="dedicatedkeytabfile=$dedicated_keytab_file" | grep $ad_service | wc -l)
+testit "test (dedicated keytab) spn service that exists in AD (created via add_update_ads) is added to keytab file" test $found -gt 1 || failed=$(expr $failed + 1)
+
+found_ad=$($net_tool ads setspn list -U$DC_USERNAME%$DC_PASSWORD | grep $service | wc -l)
+found_keytab=$($net_tool ads keytab list -U$DC_USERNAME%$DC_PASSWORD --option="kerberosmethod=dedicatedkeytab" --option="dedicatedkeytabfile=$dedicated_keytab_file" | grep $service | wc -l)
+# test after create that a spn that exists in the keytab but shouldn't
+# be written to the AD.
+testit "test spn service doesn't exist in AD but is present in keytab file after keytab create" test $found_ad -eq 0 -a $found_keytab -gt 1 || failed=$(expr $failed + 1)
+
+# SPN parser is very basic but does detect some illegal combination
+
+windows_spn="$spn_service/$spn_host:"
+testit_expect_failure "test (dedicated keytab) fail to parse windows spn with missing port" $VALGRIND $net_tool ads keytab add $windows_spn -U$DC_USERNAME%$DC_PASSWORD --option="kerberosmethod=dedicatedkeytab" --option="dedicatedkeytabfile=$dedicated_keytab_file" || failed=$(expr $failed + 1)
+
+windows_spn="$spn_service/$spn_host/"
+testit_expect_failure "test (dedicated keytab) fail to parse windows spn with missing servicename" $VALGRIND $net_tool ads keytab add $windows_spn -U$DC_USERNAME%$DC_PASSWORD --option="kerberosmethod=dedicatedkeytab" --option="dedicatedkeytabfile=$dedicated_keytab_file" || failed=$(expr $failed + 1)
+
+# now delete the keytab entries again...
+
+krb_princ="primary/instance@$REALM"
+testit "test (dedicated keytab) delete a fully qualified krb5 principal" $VALGRIND $net_tool ads keytab delete $krb_princ -U$DC_USERNAME%$DC_PASSWORD --option="kerberosmethod=dedicatedkeytab" --option="dedicatedkeytabfile=$dedicated_keytab_file" || failed=$(expr $failed + 1)
+
+found=`$net_tool ads keytab list -U$DC_USERNAME%$DC_PASSWORD --option="kerberosmethod=dedicatedkeytab" --option="dedicatedkeytabfile=$dedicated_keytab_file" | grep $krb_princ | wc -l`
+
+testit "test (dedicated keytab) fully qualified krb5 principal was deleted and is no longer present in keytab" test $found -eq 0 || failed=$(expr $failed + 1)
+
+machinename="machine123"
+testit "test (dedicated keytab) delete a kerberos principle created from machinename from keytab" $VALGRIND $net_tool ads keytab delete $machinename'$' -U$DC_USERNAME%$DC_PASSWORD --option="kerberosmethod=dedicatedkeytab" --option="dedicatedkeytabfile=$dedicated_keytab_file" || failed=$(expr $failed + 1)
+search_str="$machinename\$@$REALM"
+found=`$net_tool ads keytab list -U$DC_USERNAME%$DC_PASSWORD --option="kerberosmethod=dedicatedkeytab" --option="dedicatedkeytabfile=$dedicated_keytab_file" | grep $search_str | wc -l`
+testit "test (dedicated keytab) krb5 principal created from $machinename was deleted and is no longer present in keytab" test $found -eq 0 || failed=$(expr $failed + 1)
+
+service="nfs"
+testit "test (dedicated keytab) delete a $service service to keytab" $VALGRIND $net_tool ads keytab delete $service -U$DC_USERNAME%$DC_PASSWORD --option="kerberosmethod=dedicatedkeytab" --option="dedicatedkeytabfile=$dedicated_keytab_file" || failed=$(expr $failed + 1)
+
+search_str="$service"
+found=`$net_tool ads keytab list -U$DC_USERNAME%$DC_PASSWORD --option="kerberosmethod=dedicatedkeytab" --option="dedicatedkeytabfile=$dedicated_keytab_file" | grep $search_str | wc -l`
+testit "test (dedicated keytab) krb5 principal created from service was deleted and is no longer present in keytab" test $found -eq 0 || failed=$(expr $failed + 1)
+
+spn_service="random_srv"
+spn_host="somehost.subdomain.domain"
+spn_port="12345"
+
+windows_spn="$spn_service/$spn_host"
+testit "test (dedicated keytab) delete a $windows_spn windows style SPN from keytab" $VALGRIND $net_tool ads keytab delete $windows_spn -U$DC_USERNAME%$DC_PASSWORD --option="kerberosmethod=dedicatedkeytab" --option="dedicatedkeytabfile=$dedicated_keytab_file" || failed=$(expr $failed + 1)
+
+search_str="$spn_service/$spn_host@$REALM"
+found=`$net_tool ads keytab list -U$DC_USERNAME%$DC_PASSWORD --option="kerberosmethod=dedicatedkeytab" --option="dedicatedkeytabfile=$dedicated_keytab_file" | grep $search_str | wc -l`
+testit "test (dedicated keytab) krb5 principal created from windown SPN was deleted and is no longer present in keytab" test $found -eq 0 || failed=$(expr $failed + 1)
+
+windows_spn="$spn_service/$spn_host:$spn_port"
+testit "test (dedicated keytab) delete a $windows_spn windows style SPN to keytab" $VALGRIND $net_tool ads keytab delete $windows_spn -U$DC_USERNAME%$DC_PASSWORD --option="kerberosmethod=dedicatedkeytab" --option="dedicatedkeytabfile=$dedicated_keytab_file" || failed=$(expr $failed + 1)
+
+search_str="$spn_service/$spn_host@$REALM"
+found=`$net_tool ads keytab list -U$DC_USERNAME%$DC_PASSWORD --option="kerberosmethod=dedicatedkeytab" --option="dedicatedkeytabfile=$dedicated_keytab_file" | grep $search_str | wc -l`
+testit "test (dedicated keytab) krb5 principal created from windown SPN (with port) was deleted and is no longer present in keytab" test $found -eq 0 || failed=$(expr $failed + 1)
+
+# keytab add shouldn't have written spn to AD
+found=$($net_tool ads setspn list -U$DC_USERNAME%$DC_PASSWORD | grep $service | wc -l)
+testit "test (dedicated keytab) spn is not written to AD (using keytab add)" test $found -eq 0 || failed=$(expr $failed + 1)
+
+ad_service="writetoad"
+testit "test (dedicated keytab) delete a $ad_service service from keytab (used add_update_ads)" $VALGRIND $net_tool ads keytab delete $ad_service -U$DC_USERNAME%$DC_PASSWORD --option="kerberosmethod=dedicatedkeytab" --option="dedicatedkeytabfile=$dedicated_keytab_file" || failed=$(expr $failed + 1)
+
+search_str="$ad_service"
+found=`$net_tool ads keytab list -U$DC_USERNAME%$DC_PASSWORD --option="kerberosmethod=dedicatedkeytab" --option="dedicatedkeytabfile=$dedicated_keytab_file" | grep $search_str | wc -l`
+testit "test (dedicated keytab) spn is written to AD (using keytab add_update_ads) was deleted and is no longer present in keytab" test $found -eq 0 || failed=$(expr $failed + 1)
+# still in ad
+found=$($net_tool ads setspn list -U$DC_USERNAME%$DC_PASSWORD | grep $ad_service | wc -l)
+testit "test (dedicated keytab) spn is written to AD (using keytab add_update_ads) is still in ad after deletion from keytab" test $found -eq 2 || failed=$(expr $failed + 1)
+
+testit "changetrustpw (dedicated keytab)" $VALGRIND $net_tool ads changetrustpw || failed=$(expr $failed + 1)
+
+testit "leave (dedicated keytab)" $VALGRIND $net_tool ads leave -U$DC_USERNAME%$DC_PASSWORD || failed=$(expr $failed + 1)
+
+# if there is no keytab, try and create it
+if [ ! -f $dedicated_keytab_file ]; then
+ if [ $(command -v ktutil) ] >/dev/null; then
+ printf "addent -password -p $DC_USERNAME@$REALM -k 1 -e rc4-hmac\n$DC_PASSWORD\nwkt $dedicated_keytab_file\n" | ktutil
+ fi
+fi
+
+if [ -f $dedicated_keytab_file ]; then
+ testit "keytab list (dedicated keytab)" $VALGRIND $net_tool ads keytab list --option="kerberosmethod=dedicatedkeytab" --option="dedicatedkeytabfile=$dedicated_keytab_file" || failed=$(expr $failed + 1)
+ testit "keytab list keytab specified on cmdline" $VALGRIND $net_tool ads keytab list $dedicated_keytab_file || failed=$(expr $failed + 1)
+fi
+
+rm -f $dedicated_keytab_file
+
+testit_expect_failure "testjoin(not joined)" $VALGRIND $net_tool ads testjoin -P --use-kerberos=required || failed=$(expr $failed + 1)
+
+testit "join+kerberos" $VALGRIND $net_tool ads join -U$DC_USERNAME%$DC_PASSWORD --use-kerberos=required || failed=$(expr $failed + 1)
+
+testit "testjoin" $VALGRIND $net_tool ads testjoin -P --use-kerberos=required || failed=$(expr $failed + 1)
+
+testit "leave+kerberos" $VALGRIND $net_tool ads leave -U$DC_USERNAME%$DC_PASSWORD --use-kerberos=required || failed=$(expr $failed + 1)
+
+testit_expect_failure "testjoin(not joined)" $VALGRIND $net_tool ads testjoin -P --use-kerberos=required || failed=$(expr $failed + 1)
+
+testit "join+server" $VALGRIND $net_tool ads join -U$DC_USERNAME%$DC_PASSWORD -S$DC_SERVER || failed=$(expr $failed + 1)
+
+testit "leave+server" $VALGRIND $net_tool ads leave -U$DC_USERNAME%$DC_PASSWORD -S$DC_SERVER || failed=$(expr $failed + 1)
+
+testit_expect_failure "join+invalid_server" $VALGRIND $net_tool ads join -U$DC_USERNAME%$DC_PASSWORD -SINVALID || failed=$(expr $failed + 1)
+
+testit "join+server" $VALGRIND $net_tool ads join -U$DC_USERNAME%$DC_PASSWORD || failed=$(expr $failed + 1)
+
+testit_expect_failure "leave+invalid_server" $VALGRIND $net_tool ads leave -U$DC_USERNAME%$DC_PASSWORD -SINVALID || failed=$(expr $failed + 1)
+
+testit "testjoin user+password" $VALGRIND $net_tool ads testjoin -U$DC_USERNAME%$DC_PASSWORD || failed=$(expr $failed + 1)
+
+testit "leave+keep_account" $VALGRIND $net_tool ads leave -U$DC_USERNAME%$DC_PASSWORD --keep-account || failed=$(expr $failed + 1)
+
+base_dn="DC=addom,DC=samba,DC=example,DC=com"
+computers_dn="CN=Computers,$base_dn"
+testit "ldb check for existence of machine account" $ldbsearch -U$DC_USERNAME%$DC_PASSWORD -H ldap://$SERVER.$REALM --scope=base -b "cn=$HOSTNAME,$computers_dn" || failed=$(expr $failed + 1)
+
+dns_alias1="${netbios}_alias1.other.${lc_realm}"
+dns_alias2="${netbios}_alias2.other2.${lc_realm}"
+testit "join" $VALGRIND $net_tool --option=additionaldnshostnames=$dns_alias1,$dns_alias2 ads join -U$DC_USERNAME%$DC_PASSWORD || failed=$(expr $failed + 1)
+
+testit "testjoin" $VALGRIND $net_tool ads testjoin || failed=$(expr $failed + 1)
+
+testit_grep "check dNSHostName" $fqdn $VALGRIND $net_tool ads search -P samaccountname=$netbios\$ dNSHostName || failed=$(expr $failed + 1)
+testit_grep "check SPN" ${uc_netbios}.${lc_realm} $VALGRIND $net_tool ads search -P samaccountname=$netbios\$ servicePrincipalName || failed=$(expr $failed + 1)
+
+testit_grep "dns alias SPN" $dns_alias1 $VALGRIND $net_tool ads search -P samaccountname=$netbios\$ servicePrincipalName || failed=$(expr $failed + 1)
+testit_grep "dns alias SPN" $dns_alias2 $VALGRIND $net_tool ads search -P samaccountname=$netbios\$ servicePrincipalName || failed=$(expr $failed + 1)
+
+testit_grep "dns alias addl" $dns_alias1 $VALGRIND $net_tool ads search -P samaccountname=$netbios\$ msDS-AdditionalDnsHostName || failed=$(expr $failed + 1)
+testit_grep "dns alias addl" $dns_alias2 $VALGRIND $net_tool ads search -P samaccountname=$netbios\$ msDS-AdditionalDnsHostName || failed=$(expr $failed + 1)
+
+# Test binary msDS-AdditionalDnsHostName like ones added by Windows DC
+short_alias_file="$BASEDIR/$WORKDIR/short_alias_file"
+printf 'short_alias\0$' >$short_alias_file
+cat >$BASEDIR/$WORKDIR/tmpldbmodify <<EOF
+dn: CN=$HOSTNAME,$computers_dn
+changetype: modify
+add: msDS-AdditionalDnsHostName
+msDS-AdditionalDnsHostName:< file://$short_alias_file
+EOF
+
+testit "add binary msDS-AdditionalDnsHostName" $VALGRIND $ldbmodify -k yes -U$DC_USERNAME%$DC_PASSWORD -H ldap://$SERVER.$REALM $BASEDIR/$WORKDIR/tmpldbmodify || failed=$(expr $failed + 1)
+
+testit_grep "addl short alias" short_alias $ldbsearch --show-binary -U$DC_USERNAME%$DC_PASSWORD -H ldap://$SERVER.$REALM --scope=base -b "CN=$HOSTNAME,CN=Computers,$base_dn" msDS-AdditionalDnsHostName || failed=$(expr $failed + 1)
+
+rm -f $BASEDIR/$WORKDIR/tmpldbmodify $short_alias_file
+
+dedicated_keytab_file="$BASEDIR/$WORKDIR/test_dns_aliases_dedicated_krb5.keytab"
+
+testit "dns alias create_keytab" $VALGRIND $net_tool ads keytab create --option="kerberosmethod=dedicatedkeytab" --option="dedicatedkeytabfile=$dedicated_keytab_file" || failed=$(expr $failed + 1)
+
+testit_grep "dns alias1 check keytab" "host/${dns_alias1}@$REALM" $net_tool ads keytab list --option="kerberosmethod=dedicatedkeytab" --option="dedicatedkeytabfile=$dedicated_keytab_file" || failed=$(expr $failed + 1)
+testit_grep "dns alias2 check keytab" "host/${dns_alias2}@$REALM" $net_tool ads keytab list --option="kerberosmethod=dedicatedkeytab" --option="dedicatedkeytabfile=$dedicated_keytab_file" || failed=$(expr $failed + 1)
+testit_grep "addl short check keytab" "host/short_alias@$REALM" $net_tool ads keytab list --option="kerberosmethod=dedicatedkeytab" --option="dedicatedkeytabfile=$dedicated_keytab_file" || failed=$(expr $failed + 1)
+
+rm -f $dedicated_keytab_file
+
+##Goodbye...
+testit "leave" $VALGRIND $net_tool ads leave -U$DC_USERNAME%$DC_PASSWORD || failed=$(expr $failed + 1)
+
+# netbios aliases tests
+testit "join nb_alias" $VALGRIND $net_tool --option=netbiosaliases=nb_alias1,nb_alias2 ads join -U$DC_USERNAME%$DC_PASSWORD || failed=$(expr $failed + 1)
+
+testit "testjoin nb_alias" $VALGRIND $net_tool ads testjoin || failed=$(expr $failed + 1)
+
+testit_grep "nb_alias check dNSHostName" $fqdn $VALGRIND $net_tool ads search -P samaccountname=$netbios\$ dNSHostName || failed=$(expr $failed + 1)
+testit_grep "nb_alias check main SPN" ${uc_netbios}.${lc_realm} $VALGRIND $net_tool ads search -P samaccountname=$netbios\$ servicePrincipalName || failed=$(expr $failed + 1)
+
+testit_grep "nb_alias1 SPN" nb_alias1 $VALGRIND $net_tool ads search -P samaccountname=$netbios\$ servicePrincipalName || failed=$(expr $failed + 1)
+testit_grep "nb_alias2 SPN" nb_alias2 $VALGRIND $net_tool ads search -P samaccountname=$netbios\$ servicePrincipalName || failed=$(expr $failed + 1)
+
+##Goodbye...
+testit "leave" $VALGRIND $net_tool ads leave -U$DC_USERNAME%$DC_PASSWORD || failed=$(expr $failed + 1)
+
+#
+# Test createcomputer option of 'net ads join'
+#
+testit "Create OU=Servers,$base_dn" $VALGRIND $ldbadd -U$DC_USERNAME%$DC_PASSWORD -H ldap://$SERVER <<EOF
+dn: OU=Servers,$base_dn
+objectClass: organizationalUnit
+EOF
+
+testit "join+createcomputer" $VALGRIND $net_tool ads join -U$DC_USERNAME%$DC_PASSWORD createcomputer=Servers || failed=$(expr $failed + 1)
+
+testit "ldb check for existence of machine account in OU=Servers" $ldbsearch -U$DC_USERNAME%$DC_PASSWORD -H ldap://$SERVER.$REALM --scope=base -b "cn=$HOSTNAME,OU=Servers,$base_dn" || failed=$(expr $failed + 1)
+
+## Goodbye...
+testit "leave+createcomputer" $VALGRIND $net_tool ads leave -U$DC_USERNAME%$DC_PASSWORD || failed=$(expr $failed + 1)
+
+testit "Remove OU=Servers" $VALGRIND $ldbdel -U$DC_USERNAME%$DC_PASSWORD -H ldap://$SERVER "OU=Servers,$base_dn"
+
+#
+# Test createupn option of 'net ads join'
+#
+testit "join+createupn" $VALGRIND $net_tool ads join -U$DC_USERNAME%$DC_PASSWORD createupn="host/test-$HOSTNAME@$REALM" || failed=$(expr $failed + 1)
+
+testit_grep "checkupn" "userPrincipalName: host/test-$HOSTNAME@$REALM" $ldbsearch -U$DC_USERNAME%$DC_PASSWORD -H ldap://$SERVER.$REALM --scope=base -b "CN=$HOSTNAME,CN=Computers,$base_dn" || failed=$(expr $failed + 1)
+
+dedicated_keytab_file="$BASEDIR/$WORKDIR/test_net_create_dedicated_krb5.keytab"
+
+testit "create_keytab" $VALGRIND $net_tool ads keytab create --option="kerberosmethod=dedicatedkeytab" --option="dedicatedkeytabfile=$dedicated_keytab_file" || failed=$(expr $failed + 1)
+
+testit_grep "checkupn+keytab" "host/test-$HOSTNAME@$REALM" $net_tool ads keytab list --option="kerberosmethod=dedicatedkeytab" --option="dedicatedkeytabfile=$dedicated_keytab_file" || failed=$(expr $failed + 1)
+
+rm -f $dedicated_keytab_file
+
+testit "leave+createupn" $VALGRIND $net_tool ads leave -U$DC_USERNAME%$DC_PASSWORD || failed=$(expr $failed + 1)
+
+#
+# Test dnshostname option of 'net ads join'
+#
+testit "join+dnshostname" $VALGRIND $net_tool ads join -U$DC_USERNAME%$DC_PASSWORD dnshostname="alt.hostname.$HOSTNAME" || failed=$(expr $failed + 1)
+
+testit_grep "check dnshostname opt" "dNSHostName: alt.hostname.$HOSTNAME" $ldbsearch -U$DC_USERNAME%$DC_PASSWORD -H ldap://$SERVER.$REALM --scope=base -b "CN=$HOSTNAME,CN=Computers,$base_dn" || failed=$(expr $failed + 1)
+
+testit "create_keytab+dnshostname" $VALGRIND $net_tool ads keytab create --option="kerberosmethod=dedicatedkeytab" --option="dedicatedkeytabfile=$dedicated_keytab_file" || failed=$(expr $failed + 1)
+
+testit_grep "check dnshostname+keytab" "host/alt.hostname.$HOSTNAME@$REALM" $net_tool ads keytab list --option="kerberosmethod=dedicatedkeytab" --option="dedicatedkeytabfile=$dedicated_keytab_file" || failed=$(expr $failed + 1)
+
+rm -f $dedicated_keytab_file
+
+testit "leave+dnshostname" $VALGRIND $net_tool ads leave -U$DC_USERNAME%$DC_PASSWORD || failed=$(expr $failed + 1)
+
+rm -rf $BASEDIR/$WORKDIR
+
+exit $failed
diff --git a/testprogs/blackbox/test_net_ads_dns.sh b/testprogs/blackbox/test_net_ads_dns.sh
new file mode 100755
index 0000000..20f917a
--- /dev/null
+++ b/testprogs/blackbox/test_net_ads_dns.sh
@@ -0,0 +1,195 @@
+#!/bin/sh
+# Blackbox tests for net ads dns register etc.
+# Copyright (C) 2006-2007 Jelmer Vernooij <jelmer@samba.org>
+# Copyright (C) 2006-2008 Andrew Bartlett <abartlet@samba.org>
+
+if [ $# -lt 6 ]; then
+ cat <<EOF
+Usage: test_net_ads_dns.sh SERVER DC_USERNAME DC_PASSWORD REALM USER PASS
+EOF
+ exit 1
+fi
+
+SERVER=$1
+DC_USERNAME=$2
+DC_PASSWORD=$3
+REALM=$4
+USERNAME=$5
+PASSWORD=$6
+shift 6
+failed=0
+
+samba4bindir="$BINDIR"
+
+samba_tool="$samba4bindir/samba-tool"
+net_tool="$samba4bindir/net"
+smbpasswd="$samba4bindir/smbpasswd"
+texpect="$samba4bindir/texpect"
+
+newuser="$samba_tool user create"
+groupaddmem="$samba_tool group addmembers"
+
+. $(dirname $0)/subunit.sh
+. "$(dirname "${0}")/common_test_fns.inc"
+
+ldbmodify=$(system_or_builddir_binary ldbmodify "${BINDIR}")
+ldbsearch=$(system_or_builddir_binary ldbsearch "${BINDIR}")
+
+IPADDRESS=10.1.4.111
+IP6ADDRESS=fd00:1a1a::1:5ee:bad:c0de
+IPADDRMAC=10.1.4.124
+UNPRIVIP=10.1.4.130
+ADMINNAME=testname.$$
+MACHINENAME=membername.$$
+UNPRIVNAME=unprivname.$$
+UNPRIVUSER=unprivuser.$$
+UNPRIVPASS=UnPrivPass1
+
+# These tests check that privileged users can add DNS names and that
+# unprivileged users cannot do so.
+echo "Starting ..."
+
+testit "admin user should be able to add a DNS entry $ADMINNAME.$REALM $IPADDRESS $IP6ADDRESS" \
+ $VALGRIND $net_tool ads dns register $ADMINNAME.$REALM $IPADDRESS $IP6ADDRESS -U$DC_USERNAME%$DC_PASSWORD ||
+ failed=$(expr $failed + 1)
+
+testit_grep_count \
+ "We should be able to see the new name $ADMINNAME.$REALM $IPADDRESS" \
+ "$IPADDRESS" \
+ 1 \
+ dig @$SERVER +short -t a $ADMINNAME.$REALM ||
+ failed=$(expr $failed + 1)
+testit_grep_count \
+ "We should be able to see the new name $ADMINNAME.$REALM $IP6ADDRESS" \
+ "$IP6ADDRESS" \
+ 1 \
+ dig @$SERVER +short -t aaaa $ADMINNAME.$REALM ||
+ failed=$(expr $failed + 1)
+
+testit "We should be able to unregister the name $ADMINNAME.$REALM" \
+ $VALGRIND $net_tool ads dns unregister $ADMINNAME.$REALM -U$DC_USERNAME%$DC_PASSWORD ||
+ failed=$(expr $failed + 1)
+
+testit_grep_count \
+ "The name $ADMINNAME.$REALM $IPADDRESS should not be there any longer" \
+ "$IPADDRESS" \
+ 0 \
+ dig @$SERVER +short -t a $ADMINNAME.$REALM ||
+ failed=$(expr $failed + 1)
+
+testit_grep_count \
+ "The name $ADMINNAME.$REALM $IP6ADDRESS should not be there any longer" \
+ "$IP6ADDRESS" \
+ 0 \
+ dig @$SERVER +short -t aaaa $ADMINNAME.$REALM ||
+ failed=$(expr $failed + 1)
+
+# prime the kpasswd server, see "git blame" for an explanation
+$VALGRIND $net_tool user add $UNPRIVUSER $UNPRIVPASS -U$DC_USERNAME%$DC_PASSWORD
+$VALGRIND $net_tool user delete $UNPRIVUSER -U$DC_USERNAME%$DC_PASSWORD
+
+# This should be an expect_failure test ...
+testit "Adding an unprivileged user" $VALGRIND $net_tool user add $UNPRIVUSER $UNPRIVPASS -U$DC_USERNAME%$DC_PASSWORD || failed=$(expr $failed + 1)
+
+BASEDN=$($VALGRIND $ldbsearch -U$DC_USERNAME%$DC_PASSWORD -H ldap://$SERVER.$REALM -b '' --scope=base defaultNamingContext | grep defaultNamingContext | sed -e 's!^defaultNamingContext: !!')
+
+LDIF="dn: CN=$UNPRIVUSER,CN=users,${BASEDN}+changetype: modify+replace: userAccountControl+userAccountControl: 512"
+
+echo $LDIF | tr '+' '\n' | $VALGRIND $ldbmodify -U$DC_USERNAME%$DC_PASSWORD -H ldap://$SERVER.$REALM -i
+STATUS=$?
+
+testit "We should have enabled the account" test $STATUS -eq 0 || failed=$(expr $failed + 1)
+
+#Unprivileged users should be able to add new names
+testit "Unprivileged users should be able to add new names" $net_tool ads dns register $UNPRIVNAME.$REALM $UNPRIVIP -U$UNPRIVUSER%$UNPRIVPASS || failed=$(expr $failed + 1)
+
+# This should work as well
+testit "machine account should be able to add a DNS entry net ads dns register $MACHINENAME.$REALM $IPADDRMAC -P" \
+ $net_tool ads dns register $MACHINENAME.$REALM $IPADDRMAC -P ||
+ failed=$(expr $failed + 1)
+
+testit_grep_count \
+ "We should be able to see the new name $MACHINENAME.$REALM" \
+ "$IPADDRMAC" \
+ 1 \
+ dig @$SERVER +short -t a $MACHINENAME.$REALM ||
+ failed=$(expr $failed + 1)
+
+#Unprivileged users should not be able to overwrite other's names
+testit_expect_failure \
+ "Unprivileged users should not be able to modify existing names" \
+ $net_tool ads dns register $MACHINENAME.$REALM $UNPRIVIP -U$UNPRIVUSER%$UNPRIVPASS ||
+ failed=$(expr $failed + 1)
+
+testit "We should be able to unregister the name $UNPRIVNAME.$REALM $IPADDRESS" \
+ $VALGRIND $net_tool ads dns unregister $UNPRIVNAME.$REALM -U$UNPRIVUSER%$UNPRIVPASS ||
+ failed=$(expr $failed + 1)
+testit "We should be able to unregister the name $MACHINENAME.$REALM $IPADDRESS" \
+ $VALGRIND $net_tool ads dns unregister $MACHINENAME.$REALM -P ||
+ failed=$(expr $failed + 1)
+
+# Remove the unprivileged user, which is not required anymore
+$VALGRIND $net_tool user delete $UNPRIVUSER -U$DC_USERNAME%$DC_PASSWORD
+
+testit_grep_count \
+ "The name $UNPRIVNAME.$REALM ($IPADDRESS) should not be there any longer" \
+ "$IPADDRESS" \
+ 0 \
+ dig @$SERVER +short -t a $UNPRIVNAME.$REALM ||
+ failed=$(expr $failed + 1)
+testit_grep_count \
+ "The name $UNPRIVNAME.$REALM ($IP6ADDRESS) should not be there any longer" \
+ "$IP6ADDRESS" \
+ 0 \
+ dig @$SERVER +short -t aaaa $UNPRIVNAME.$REALM ||
+ failed=$(expr $failed + 1)
+testit_grep_count \
+ "The name $MACHINENAME.$REALM ($IPADDRESS) should not be there any longer" \
+ "$IPADDRESS" \
+ 0 \
+ dig @$SERVER +short -t a $MACHINENAME.$REALM ||
+ failed=$(expr $failed + 1)
+testit_grep_count \
+ "The name $MACHINENAME.$REALM ($IP6ADDRESS) should not be there any longer" \
+ "$IP6ADDRESS" \
+ 0 \
+ dig @$SERVER +short -t aaaa $MACHINENAME.$REALM ||
+ failed=$(expr $failed + 1)
+
+# Tests with --dns-ttl option
+testit "net ads dns register with default TTL" \
+ $net_tool ads dns register $MACHINENAME.$REALM $IPADDRMAC -P ||
+ failed=$(expr $failed + 1)
+TTL=$(dig @$SERVER.$REALM +noall +ttlid +answer -t A $MACHINENAME.$REALM |
+ awk '{ print $2 }')
+testit "Verify default TTL of 3600 seconds" \
+ test "$TTL" = "3600" ||
+ failed=$(expr $failed + 1)
+
+testit "Update record with TTL of 60 seconds" \
+ $net_tool ads dns register --dns-ttl 60 --force $MACHINENAME.$REALM $IPADDRMAC -P ||
+ failed=$(expr $failed + 1)
+TTL=$(dig @$SERVER.$REALM +noall +ttlid +answer -t A $MACHINENAME.$REALM |
+ awk '{ print $2 }')
+testit "Verify new TTL of 60 seconds" \
+ test "$TTL" = "60" ||
+ failed=$(expr $failed + 1)
+
+testit "We should be able to unregister the name $MACHINENAME.$REALM $IPADDRESS" \
+ $VALGRIND $net_tool ads dns unregister $MACHINENAME.$REALM -P ||
+ failed=$(expr $failed + 1)
+
+testit_grep_count \
+ "The name $MACHINENAME.$REALM ($IPADDRESS) should not be there any longer" \
+ "$IPADDRESS" \
+ 0 \
+ dig @$SERVER.$REALM +short -t A $MACHINENAME.$REALM ||
+ failed=$(expr $failed + 1)
+testit_grep_count \
+ "The name $MACHINENAME.$REALM ($IP6ADDRESS) should not be there any longer" \
+ "$IP6ADDRESS" \
+ 0 \
+ dig @$SERVER.$REALM +short -t AAAA $MACHINENAME.$REALM ||
+ failed=$(expr $failed + 1)
+
+testok $0 $failed
diff --git a/testprogs/blackbox/test_net_ads_fips.sh b/testprogs/blackbox/test_net_ads_fips.sh
new file mode 100755
index 0000000..8d21e73
--- /dev/null
+++ b/testprogs/blackbox/test_net_ads_fips.sh
@@ -0,0 +1,43 @@
+if [ $# -lt 4 ]; then
+ cat <<EOF
+Usage: test_net_ads_fips.sh DC_SERVER DC_USERNAME DC_PASSWORD PREFIX_ABS
+EOF
+ exit 1
+fi
+
+DC_SERVER=$1
+DC_USERNAME=$2
+DC_PASSWORD=$3
+BASEDIR=$4
+
+HOSTNAME=$(dd if=/dev/urandom bs=1 count=32 2>/dev/null | sha1sum | cut -b 1-10)
+
+RUNDIR=$(pwd)
+cd $BASEDIR
+WORKDIR=$(mktemp -d -p .)
+WORKDIR=$(basename $WORKDIR)
+cp -a client/* $WORKDIR/
+sed -ri "s@(dir|directory) = (.*)/client/@\1 = \2/$WORKDIR/@" $WORKDIR/client.conf
+sed -ri "s/netbios name = .*/netbios name = $HOSTNAME/" $WORKDIR/client.conf
+rm -f $WORKDIR/private/secrets.tdb
+cd $RUNDIR
+
+failed=0
+
+net_tool="$BINDIR/net --configfile=$BASEDIR/$WORKDIR/client.conf --option=security=ads"
+
+# Load test functions
+. $(dirname $0)/subunit.sh
+
+# This make sure we are able to join AD in FIPS mode with Kerberos (NTLM doesn't work in FIPS mode).
+testit "join" $VALGRIND $net_tool ads join --use-kerberos=required -U$DC_USERNAME%$DC_PASSWORD || failed=$(expr $failed + 1)
+
+testit "testjoin" $VALGRIND $net_tool ads testjoin -P --use-kerberos=required || failed=$(expr $failed + 1)
+
+testit "changetrustpw" $VALGRIND $net_tool ads changetrustpw || failed=$(expr $failed + 1)
+
+testit "leave" $VALGRIND $net_tool ads leave --use-kerberos=required -U$DC_USERNAME%$DC_PASSWORD || failed=$(expr $failed + 1)
+
+rm -rf $BASEDIR/$WORKDIR
+
+exit $failed
diff --git a/testprogs/blackbox/test_net_ads_search_server.sh b/testprogs/blackbox/test_net_ads_search_server.sh
new file mode 100755
index 0000000..f8350c9
--- /dev/null
+++ b/testprogs/blackbox/test_net_ads_search_server.sh
@@ -0,0 +1,37 @@
+#!/bin/sh
+
+if [ $# -lt 2 ]; then
+cat <<EOF
+Usage: $0 SERVER REALM
+EOF
+exit 1;
+fi
+
+SERVER=$1
+REALM=$2
+shift 2
+
+failed=0
+. `dirname $0`/subunit.sh
+
+samba_net="$BINDIR/net"
+
+DN=$(echo "${REALM}" | tr '[:upper:]' '[:lower:]' | sed -e 's!^!DC=!' -e 's!\.!,DC=!g')
+testit_grep_count \
+ "net_ads_search.ntlmssp" \
+ "distinguishedName: ${DN}" \
+ 1 \
+ $samba_net ads search --use-kerberos=off -P \
+ --server "${SERVER}.${REALM}" \
+ '(objectClass=domain)' distinguishedName || \
+ failed=$((failed + 1))
+testit_grep_count \
+ "net_ads_search.krb5" \
+ "distinguishedName: ${DN}" \
+ 1 \
+ $samba_net ads search --use-kerberos=required -P \
+ --server "${SERVER}.${REALM}" \
+ '(objectClass=domain)' distinguishedName || \
+ failed=$((failed + 1))
+
+exit $failed
diff --git a/testprogs/blackbox/test_net_offline.sh b/testprogs/blackbox/test_net_offline.sh
new file mode 100755
index 0000000..d885b33
--- /dev/null
+++ b/testprogs/blackbox/test_net_offline.sh
@@ -0,0 +1,162 @@
+if [ $# -lt 4 ]; then
+ cat <<EOF
+Usage: test_net_offline.sh DC_SERVER DC_USERNAME DC_PASSWORD PREFIX_ABS
+EOF
+ exit 1
+fi
+
+DC_SERVER=$1
+DC_USERNAME=$2
+DC_PASSWORD=$3
+BASEDIR=$4
+
+HOSTNAME=$(dd if=/dev/urandom bs=1 count=32 2>/dev/null | sha1sum | cut -b 1-10)
+
+RUNDIR=$(pwd)
+cd $BASEDIR
+WORKDIR=$(mktemp -d -p .)
+WORKDIR=$(basename $WORKDIR)
+ODJFILE="$BASEDIR/$WORKDIR/odj_provision.txt"
+
+cp -a client/* $WORKDIR/
+sed -ri "s@(dir|directory) = (.*)/client/@\1 = \2/$WORKDIR/@" $WORKDIR/client.conf
+sed -ri "s/netbios name = .*/netbios name = $HOSTNAME/" $WORKDIR/client.conf
+rm -f $WORKDIR/private/secrets.tdb
+cd $RUNDIR
+
+failed=0
+
+net_tool="$BINDIR/net --configfile=$BASEDIR/$WORKDIR/client.conf --option=security=ads"
+samba_texpect="$BINDIR/texpect"
+
+# Load test functions
+. $(dirname $0)/subunit.sh
+
+netbios=$(grep "netbios name" $BASEDIR/$WORKDIR/client.conf | cut -f2 -d= | awk '{$1=$1};1')
+
+# 1. Test w/o dcname
+
+testit "provision without dcname" $VALGRIND $net_tool offlinejoin provision domain=$REALM machine_name=$netbios savefile=$ODJFILE -U$DC_USERNAME%$DC_PASSWORD || failed=$(expr $failed + 1)
+
+testit "requestodj" $VALGRIND $net_tool offlinejoin requestodj loadfile=$ODJFILE || failed=$(expr $failed + 1)
+
+testit "testjoin" $VALGRIND $net_tool ads testjoin -P --use-kerberos=required || failed=$(expr $failed + 1)
+
+rm -f $ODJFILE
+
+testit "leave" $VALGRIND $net_tool ads leave -U$DC_USERNAME%$DC_PASSWORD || failed=$(expr $failed + 1)
+
+# 2. Test with dcname
+
+testit "provision with dcname" $VALGRIND $net_tool offlinejoin provision domain=$REALM machine_name=$netbios savefile=$ODJFILE dcname=$DC_SERVER -U$DC_USERNAME%$DC_PASSWORD || failed=$(expr $failed + 1)
+
+testit "requestodj" $VALGRIND $net_tool offlinejoin requestodj loadfile=$ODJFILE || failed=$(expr $failed + 1)
+
+testit "testjoin" $VALGRIND $net_tool ads testjoin -P --use-kerberos=required || failed=$(expr $failed + 1)
+
+rm -f $ODJFILE
+
+testit "leave" $VALGRIND $net_tool ads leave -U$DC_USERNAME%$DC_PASSWORD || failed=$(expr $failed + 1)
+
+# 3. Test with defpwd
+
+testit "provision with dcname and default password" $VALGRIND $net_tool offlinejoin provision domain=$REALM machine_name=$netbios savefile=$ODJFILE dcname=$DC_SERVER defpwd -U$DC_USERNAME%$DC_PASSWORD || failed=$(expr $failed + 1)
+
+testit "requestodj" $VALGRIND $net_tool offlinejoin requestodj loadfile=$ODJFILE || failed=$(expr $failed + 1)
+
+testit "testjoin" $VALGRIND $net_tool ads testjoin -P --use-kerberos=required || failed=$(expr $failed + 1)
+
+rm -f $ODJFILE
+
+testit "leave" $VALGRIND $net_tool ads leave -U$DC_USERNAME%$DC_PASSWORD || failed=$(expr $failed + 1)
+
+test_compose_odj() {
+ local mode=$1
+ local composeargv=()
+
+ # Retrieve the necessary information to compose the ODJ blob
+ # The machine needs to be correctly joined at this point
+ local netbios_domain_name=$($net_tool ads lookup | awk -F': ' '/^Pre-Win2k Domain/ {print $2}')
+ local domain_sid=$($net_tool getdomainsid | awk -F': ' "/^SID for domain $netbios_domain_name/ {print \$2}")
+ local domain_guid=$($net_tool ads lookup | awk -F': ' '/^GUID/ {print $2}')
+ local forest_name=$($net_tool ads lookup | awk -F': ' '/^Forest/ {print $2}')
+ local dc_name=$($net_tool ads info | awk -F': ' '/^LDAP server name/ {print $2}')
+ local dc_address=$($net_tool ads info | awk -F': ' '/^LDAP server:/ {print $2}')
+ local ret=1
+ local out=""
+
+ composeargv=( \
+ "domain_sid=${domain_sid}" \
+ "domain_guid=${domain_guid}" \
+ "forest_name=${forest_name}" \
+ "-S ${dc_name}" \
+ "-I ${dc_address}" \
+ "savefile=${ODJFILE}"
+ )
+ case $mode in
+ machacct)
+ cmd='$net_tool offlinejoin composeodj ${composeargv[@]} -P 2>&1'
+ out=$(eval $cmd)
+ ret=$?
+ ;;
+ stdinfd)
+ cmd='echo ${netbios} | $net_tool offlinejoin composeodj ${composeargv[@]} -U${netbios^^}\$ 2>&1'
+ out=$(PASSWD_FD=0 eval $cmd)
+ ret=$?
+ ;;
+ callback)
+ tmpfile=$BASEDIR/$WORKDIR/composeodj_password_script
+ cat >$tmpfile <<EOF
+expect Password for [${netbios_domain_name^^}\\${netbios^^}\$]:
+send $netbios\n
+EOF
+ cmd='$samba_texpect -v $tmpfile $net_tool offlinejoin composeodj ${composeargv[@]} 2>&1'
+ out=$(eval $cmd)
+ ret=$?
+ rm -f $tmpfile
+ ;;
+ *)
+ out="Unknown mode '$mode'"
+ ;;
+ esac
+
+ if [ $ret -ne 0 ]; then
+ echo "Failed to compose ODJ blob: $out"
+ return 1
+ fi
+}
+
+# 4. Test composeodj
+
+modes=("machacct" "stdinfd" "callback")
+for mode in "${modes[@]}"; do
+
+ defpwd="defpwd"
+ if [ "$mode" == "machacct" ]; then
+ defpwd=""
+ fi
+
+ testit "provision[$mode]" $VALGRIND $net_tool offlinejoin provision domain=$REALM machine_name=$netbios savefile=$ODJFILE $defpwd -U$DC_USERNAME%$DC_PASSWORD || failed=$(expr $failed + 1)
+
+ testit "requestodj [$mode]" $VALGRIND $net_tool offlinejoin requestodj loadfile=$ODJFILE || failed=$(expr $failed + 1)
+
+ testit "testjoin [$mode]" $VALGRIND $net_tool ads testjoin -P --use-kerberos=required || failed=$(expr $failed + 1)
+
+ testit "removeodjblob [$mode]" rm $ODJFILE || failed=$(expr $failed + 1)
+
+ testit "composeodj [$mode]" test_compose_odj $mode || failed=$(expr $failed + 1)
+
+ testit "removesecretsdb [$mode]" rm $BASEDIR/$WORKDIR/private/secrets.tdb || failed=$(expr $failed + 1)
+
+ testit "requestodj [$mode]" $VALGRIND $net_tool offlinejoin requestodj loadfile=$ODJFILE || failed=$(expr $failed + 1)
+
+ testit "removeodjblob [$mode]" rm $ODJFILE || failed=$(expr $failed + 1)
+
+ testit "testjoin [$mode]" $VALGRIND $net_tool ads testjoin -P --use-kerberos=required || failed=$(expr $failed + 1)
+
+ testit "leave [$mode]" $VALGRIND $net_tool ads leave -U$DC_USERNAME%$DC_PASSWORD || failed=$(expr $failed + 1)
+done
+
+rm -rf $BASEDIR/$WORKDIR
+
+exit $failed
diff --git a/testprogs/blackbox/test_net_rpc_user.sh b/testprogs/blackbox/test_net_rpc_user.sh
new file mode 100755
index 0000000..4d6fe75
--- /dev/null
+++ b/testprogs/blackbox/test_net_rpc_user.sh
@@ -0,0 +1,56 @@
+#!/bin/sh
+# Blackbox tests for 'net rpc'
+#
+# Copyright (c) 2017 Andreas Schneider <asn@samba.org>
+
+if [ $# -lt 4 ]; then
+ cat <<EOF
+Usage: test_net_rpc_user.sh SERVER ADMIN_ACCOUNT ADMIN_PASSWORD ADMIN_DOMAIN
+EOF
+ exit 1
+fi
+
+SERVER=$1
+ADMIN_ACCOUNT=$2
+ADMIN_PASSWORD=$3
+ADMIN_DOMAIN=$4
+shift 4
+
+failed=0
+samba_bindir="$BINDIR"
+
+samba_tool="$samba_bindir/samba-tool"
+net_tool="$samba_bindir/net"
+
+TEST_USERNAME="$(mktemp -u samson-XXXXXX)"
+TEST_PASSWORD="Passw0rd~01"
+
+newuser="$samba_tool user create"
+
+. $(dirname $0)/subunit.sh
+. $(dirname $0)/common_test_fns.inc
+
+###########################################################
+### Setup
+###########################################################
+
+testit "net rpc user add" \
+ $VALGRIND $net_tool rpc user add $TEST_USERNAME $TEST_PASSWORD -U$ADMIN_ACCOUNT%$ADMIN_PASSWORD -S $SERVER || failed=$(expr $failed + 1)
+
+###########################################################
+### Tests
+###########################################################
+
+TEST_PASSWORD_NEW="Passw0rd~02"
+
+testit "net rpc user password" \
+ $VALGRIND $net_tool rpc user password $TEST_USERNAME $TEST_PASSWORD_NEW -U$ADMIN_ACCOUNT%$ADMIN_PASSWORD -S $SERVER || failed=$(expr $failed + 1)
+
+###########################################################
+### Teardown
+###########################################################
+
+testit "net rpc user delete" \
+ $VALGRIND $net_tool rpc user delete $TEST_USERNAME -U$ADMIN_ACCOUNT%$ADMIN_PASSWORD -S $SERVER || failed=$(expr $failed + 1)
+
+exit $failed
diff --git a/testprogs/blackbox/test_offline_logon.sh b/testprogs/blackbox/test_offline_logon.sh
new file mode 100755
index 0000000..84da8a4
--- /dev/null
+++ b/testprogs/blackbox/test_offline_logon.sh
@@ -0,0 +1,43 @@
+#!/bin/sh
+# Blackbox tests for winbind offline logon support
+# Copyright (c) 2021 Andreas Schneider <asn@samba.org>
+
+if [ $# -lt 9 ]; then
+ cat <<EOF
+Usage: test_offline_logon.sh DOMAIN CACHED_USER_NAME_1 CACHED_USER_PASS_1 CACHED_USER_NAME_2 CACHED_USER_PASS_2 ONLINE_USER_NAME_1 ONLINE_USER_PASS_1 ONLINE_USER_NAME_2 ONLINE_USER_PASS_2
+EOF
+ exit 1
+fi
+
+DOMAIN=$1
+CACHED_USER_NAME_1=$2
+CACHED_USER_PASS_1=$3
+CACHED_USER_NAME_2=$4
+CACHED_USER_PASS_2=$5
+ONLINE_USER_NAME_1=$6
+ONLINE_USER_PASS_1=$7
+ONLINE_USER_NAME_2=$8
+ONLINE_USER_PASS_2=$9
+shift 9
+
+. $(dirname $0)/subunit.sh
+
+samba_bindir="$BINDIR"
+wbinfo="$samba_bindir/wbinfo"
+
+# Check that the DC is offline
+testit_expect_failure "wbinfo.ping-dc" $VALGRIND $wbinfo --ping-dc || failed=$(expr $failed + 1)
+
+# We should have cached credentials for alice and bob
+# --pam-logon sets always the WBFLAG_PAM_CACHED_LOGIN flag
+testit "wbinfo.pam_logon_$CACHED_USER_NAME_1" $VALGRIND $wbinfo --pam-logon=$DOMAIN/$CACHED_USER_NAME_1%$CACHED_USER_PASS_1 || failed=$(expr $failed + 1)
+testit "wbinfo.kerberos_logon_$CACHED_USER_NAME_1" $VALGRIND $wbinfo --krb5auth=$DOMAIN/$CACHED_USER_NAME_2%$CACHED_USER_PASS_2 || failed=$(expr $failed + 1)
+
+testit "wbinfo.pam_logon_$CACHED_USER_NAME_2" $VALGRIND $wbinfo --pam-logon=$DOMAIN/$CACHED_USER_NAME_2%$CACHED_USER_PASS_2 || failed=$(expr $failed + 1)
+testit "wbinfo.kerberos_logon_$CACHED_USER_NAME_2" $VALGRIND $wbinfo --krb5auth=$DOMAIN/$CACHED_USER_NAME_2%$CACHED_USER_PASS_2 || failed=$(expr $failed + 1)
+
+# We should not be able to auth with jane or joe
+testit_expect_failure "wbinfo.pam_logon_$ONLINE_USER_NAME_1" $VALGRIND $wbinfo --pam-logon=$DOMAIN/$ONLINE_USER_NAME_1%$ONLINE_USER_PASS_1 || failed=$(expr $failed + 1)
+testit_expect_failure "wbinfo.pam_logon_$ONLINE_USER_NAME_2" $VALGRIND $wbinfo --pam-logon=$DOMAIN/$ONLINE_USER_NAME_2%$ONLINE_USER_PASS_2 || failed=$(expr $failed + 1)
+
+exit $failed
diff --git a/testprogs/blackbox/test_old_enctypes.sh b/testprogs/blackbox/test_old_enctypes.sh
new file mode 100755
index 0000000..822e329
--- /dev/null
+++ b/testprogs/blackbox/test_old_enctypes.sh
@@ -0,0 +1,61 @@
+#!/bin/bash
+
+if [ $# -lt 5 ]; then
+ cat <<EOF
+Usage: test_old_enctypes.sh SERVER USERNAME PASSWORD NETBIOSNAME PREFIX_ABS
+EOF
+ exit 1
+fi
+
+SERVER=$1
+USERNAME=$2
+PASSWORD=$3
+NETBIOSNAME=$4
+PREFIX_ABS=$5
+shift 5
+failed=0
+
+samba4bindir="$BINDIR"
+samba4srcdir="$SRCDIR/source4"
+
+samba_tool="$samba4bindir/samba-tool"
+
+. $(dirname $0)/subunit.sh
+. $(dirname $0)/common_test_fns.inc
+
+ldbmodify=$(system_or_builddir_binary ldbmodify "${BINDIR}")
+ldbsearch=$(system_or_builddir_binary ldbsearch "${BINDIR}")
+
+out="${PREFIX_ABS}/tmpldbsearch.out"
+$ldbsearch -H ldap://$SERVER -U$USERNAME%$PASSWORD -d0 sAMAccountName="$NETBIOSNAME\$" dn msDS-SupportedEncryptionTypes >$out
+testit_grep "find my dn" msDS-SupportedEncryptionTypes cat $out || failed=$(expr $failed + 1)
+
+my_dn=$(cat $out | sed -n 's/^dn: //p')
+my_encs=$(cat $out | sed -n 's/^msDS-SupportedEncryptionTypes: //p')
+my_test_encs=$(expr $my_encs + 3)
+
+ldif="${PREFIX_ABS}/tmpldbmodify.ldif"
+
+cat >$ldif <<EOF
+dn: $my_dn
+changetype: modify
+replace: msDS-SupportedEncryptionTypes
+msDS-SupportedEncryptionTypes: $my_test_encs
+EOF
+
+testit "Change msDS-SupportedEncryptionTypes to $my_test_encs" $VALGRIND $ldbmodify -H ldap://$SERVER -U$USERNAME%$PASSWORD -d0 <$ldif || failed=$(expr $failed + 1)
+kt=${PREFIX_ABS}/tmp_host_out_keytab
+testit "Export keytab while old enctypes are supported" $samba_tool domain exportkeytab --principal=$NETBIOSNAME\$ $kt
+
+cat >$ldif <<EOF
+dn: $my_dn
+changetype: modify
+replace: msDS-SupportedEncryptionTypes
+msDS-SupportedEncryptionTypes: $my_encs
+EOF
+
+testit "Change msDS-SupportedEncryptionTypes back to $my_encs" $VALGRIND $ldbmodify -H ldap://$SERVER -U$USERNAME%$PASSWORD -d0 <$ldif || failed=$(expr $failed + 1)
+
+rm -rf $kt $out $ldif
+
+exit $failed
diff --git a/testprogs/blackbox/test_password_settings.sh b/testprogs/blackbox/test_password_settings.sh
new file mode 100755
index 0000000..b3b23f6
--- /dev/null
+++ b/testprogs/blackbox/test_password_settings.sh
@@ -0,0 +1,251 @@
+#!/bin/sh
+# Blackbox tests for different password settings
+#
+# Copyright (c) 2006-2007 Jelmer Vernooij <jelmer@samba.org>
+# Copyright (c) 2006-2008 Andrew Bartlett <abartlet@samba.org>
+# Copyright (c) 2016 Andreas Schneider <asn@samba.org>
+
+if [ $# -lt 7 ]; then
+ cat <<EOF
+Usage: test_passwords_settings.sh SERVER USERNAME PASSWORD REALM DOMAIN PREFIX CONFIGURATION
+EOF
+ exit 1
+fi
+
+SERVER=$1
+USERNAME=$2
+PASSWORD=$3
+REALM=$4
+DOMAIN=$5
+PREFIX=$6
+CONFIGURATION=${7}
+shift 7
+failed=0
+
+samba_bindir="$BINDIR"
+
+smbclient="$samba_bindir/smbclient"
+samba_tool="$samba_bindir/samba-tool"
+smbpasswd="$samba_bindir/smbpasswd"
+texpect="$samba_bindir/texpect"
+
+newuser="$samba_tool user create"
+SMB_UNC="//$SERVER/tmp"
+
+. $(dirname $0)/subunit.sh
+. $(dirname $0)/common_test_fns.inc
+
+samba_kinit=$(system_or_builddir_binary kinit "${BINDIR}" samba4kinit)
+
+do_kinit()
+{
+ principal="$1"
+ password="$2"
+ shift
+ shift
+ kerberos_kinit "$samba_kinit" "$principal" "$password" "$@"
+}
+
+test_smbpasswd()
+{
+ user=$1
+ newpass=$2
+ _config="$(echo "${CONFIGURATION}" | cut -d '=' -f 2)"
+
+ tmpfile=$PREFIX/smbpasswd_change_password_script
+ cat >$tmpfile <<EOF
+expect New SMB password:
+send ${newpass}\n
+expect Retype new SMB password:
+send ${newpass}\n
+EOF
+
+ cmd='UID_WRAPPER_INITIAL_RUID=0 UID_WRAPPER_INITIAL_EUID=0 $texpect $tmpfile $smbpasswd -L -c ${_config} $user'
+ eval echo "$cmd"
+ out=$(eval $cmd)
+ ret=$?
+ rm -f $tmpfile
+
+ if [ $ret -ne 0 ]; then
+ echo "Failed to change user password $user"
+ return 1
+ fi
+}
+
+testit "reset password policies beside of minimum password age of 0 days" \
+ $VALGRIND $PYTHON $samba_tool domain passwordsettings set \
+ "${CONFIGURATION}" --complexity=default --history-length=default --min-pwd-length=default --min-pwd-age=0 --max-pwd-age=default || failed=$(expr $failed + 1)
+
+TEST_USERNAME="$(mktemp -u alice-XXXXXX)"
+TEST_PASSWORD="testPaSS@00%"
+TEST_PASSWORD_NEW="testPaSS@01%"
+TEST_PASSWORD_NON_ASCII="Täst123"
+TEST_PASSWORD_SHORT="secret"
+TEST_PASSWORD_WEAK="Supersecret"
+TEST_PRINCIPAL="$TEST_USERNAME@$REALM"
+
+testit "create user locally" \
+ $VALGRIND $PYTHON $newuser $TEST_USERNAME $TEST_PASSWORD \
+ "${CONFIGURATION}" || failed=$(expr $failed + 1)
+
+###########################################################
+### Test normal operation as user
+###########################################################
+
+KRB5CCNAME_PATH="$PREFIX/test_password_settings_krb5ccache"
+rm -f $KRB5CCNAME_PATH
+
+KRB5CCNAME="FILE:$KRB5CCNAME_PATH"
+export KRB5CCNAME
+
+testit "kinit with user password" \
+ do_kinit $TEST_PRINCIPAL $TEST_PASSWORD || failed=$(expr $failed + 1)
+
+test_smbclient "Test login with user kerberos ccache" \
+ "ls" "$SMB_UNC" --use-krb5-ccache=$KRB5CCNAME || failed=$(expr $failed + 1)
+
+rm -f $KRB5CCNAME_PATH
+
+###########################################################
+### Change the users password
+###########################################################
+
+testit "change user password with 'samba-tool user password' (unforced)" \
+ $VALGRIND $PYTHON $samba_tool user password "${CONFIGURATION}" -W$DOMAIN -U$TEST_USERNAME%$TEST_PASSWORD -k no --newpassword=$TEST_PASSWORD_NEW || failed=$(expr $failed + 1)
+
+TEST_PASSWORD_OLD=$TEST_PASSWORD
+TEST_PASSWORD=$TEST_PASSWORD_NEW
+TEST_PASSWORD_NEW="testPaSS@02%"
+
+testit "kinit with user password" \
+ do_kinit $TEST_PRINCIPAL $TEST_PASSWORD || failed=$(expr $failed + 1)
+
+test_smbclient "Test login with user kerberos ccache" \
+ "ls" "$SMB_UNC" --use-krb5-ccache=$KRB5CCNAME || failed=$(expr $failed + 1)
+
+###########################################################
+### Change the users password
+###########################################################
+
+testit "change user (non-ascii) password with 'samba-tool user password' (unforced)" \
+ $VALGRIND $PYTHON $samba_tool user password "${CONFIGURATION}" -W$DOMAIN -U$TEST_USERNAME%$TEST_PASSWORD -k no --newpassword=$TEST_PASSWORD_NON_ASCII || failed=$(expr $failed + 1)
+
+TEST_PASSWORD_OLD=$TEST_PASSWORD_NEW
+TEST_PASSWORD=$TEST_PASSWORD_NON_ASCII
+
+testit "kinit with user password" \
+ do_kinit $TEST_PRINCIPAL $TEST_PASSWORD || failed=$(expr $failed + 1)
+
+test_smbclient "Test login with user kerberos ccache" \
+ "ls" "$SMB_UNC" --use-krb5-ccache=$KRB5CCNAME || failed=$(expr $failed + 1)
+
+#
+# These tests demonstrate that a credential cache in the environment does not
+# override a username/password, even an incorrect one, on the command line
+#
+
+testit_expect_failure "Test login with user kerberos ccache, but wrong password specified" \
+ $VALGRIND $smbclient //$SERVER/tmp -c 'ls' --use-krb5-ccache=$KRB5CCNAME -U$TEST_PRINCIPAL%invalidpass || failed=$(expr $failed + 1)
+testit_expect_failure "Test login with user kerberos ccache, but old password specified" \
+ $VALGRIND $smbclient //$SERVER/tmp -c 'ls' --use-krb5-ccache=$KRB5CCNAME -U$TEST_PRINCIPAL%$TEST_PASSWORD_OLD || failed=$(expr $failed + 1)
+
+rm -f $KRB5CCNAME_PATH
+
+###########################################################
+### Set the password with smbpasswd
+###########################################################
+
+testit "set user password with smbpasswd" \
+ test_smbpasswd $TEST_USERNAME $TEST_PASSWORD_NEW ||
+ failed=$(expr $failed + 1)
+
+TEST_PASSWORD=$TEST_PASSWORD_NEW
+TEST_PASSWORD_NEW="testPaSS@03%"
+
+test_smbclient "Test login with user (ntlm)" \
+ "ls" "$SMB_UNC" --use-kerberos=disabled -U$TEST_PRINCIPAL%$TEST_PASSWORD || failed=$(expr $failed + 1)
+
+testit "set password on user locally" $VALGRIND $PYTHON $samba_tool user setpassword $TEST_USERNAME "${CONFIGURATION}" --newpassword=$TEST_PASSWORD_NEW --must-change-at-next-login || failed=$(expr $failed + 1)
+
+TEST_PASSWORD=$TEST_PASSWORD_NEW
+TEST_PASSWORD_NEW="testPaSS@04%"
+
+test_smbclient_expect_failure "Test login with user (NT_STATUS_PASSWORD_MUST_CHANGE)" \
+ "ls" "$SMB_UNC" --use-kerberos=disabled -U$TEST_PRINCIPAL%$TEST_PASSWORD || failed=$(expr $failed + 1)
+
+testit "change user password with 'samba-tool user password' (after must change flag set)" \
+ $VALGRIND $PYTHON $samba_tool user password "${CONFIGURATION}" -W$DOMAIN -U$DOMAIN/$TEST_USERNAME%$TEST_PASSWORD -k no --newpassword=$TEST_PASSWORD_NEW || failed=$(expr $failed + 1)
+
+TEST_PASSWORD=$TEST_PASSWORD_NEW
+TEST_PASSWORD_NEW="testPaSS@05%"
+
+test_smbclient "Test login with user kerberos" 'ls' "$SMB_UNC" --use-kerberos=required -U$TEST_PRINCIPAL%$TEST_PASSWORD || failed=$(expr $failed + 1)
+
+rm -f $KRB5CCNAME_PATH
+
+cat >$PREFIX/tmpsmbpasswdscript <<EOF
+expect Old SMB password:
+password ${TEST_PASSWORD}\n
+expect New SMB password:
+send ${TEST_PASSWORD_NEW}\n
+expect Retype new SMB password:
+send ${TEST_PASSWORD_NEW}\n
+EOF
+
+config="$(echo "${CONFIGURATION}" | cut -d '=' -f 2)"
+testit "change user password with smbpasswd (after must change flag set)" \
+ $texpect $PREFIX/tmpsmbpasswdscript $smbpasswd -r $SERVER -c ${config} -U $TEST_USERNAME || failed=$(expr $failed + 1)
+
+TEST_PASSWORD=$TEST_PASSWORD_NEW
+TEST_PASSWORD_NEW="testPaSS@06%"
+
+test_smbclient "Test login with user kerberos" \
+ "ls" "$SMB_UNC" --use-kerberos=required -U$TEST_PRINCIPAL%$TEST_PASSWORD || failed=$(expr $failed + 1)
+
+rm -f $KRB5CCNAME_PATH
+
+testit_expect_failure "try to set a non-complex password (command should not succeed)" \
+ $VALGRIND $PYTHON $samba_tool user password "${CONFIGURATION}" -W$DOMAIN "-U$DOMAIN/$TEST_USERNAME%$TEST_PASSWORD" -k no --newpassword="$TEST_PASSWORD_WEAK" || failed=$(expr $failed + 1)
+
+testit "allow non-complex passwords" \
+ $VALGRIND $PYTHON $samba_tool domain passwordsettings set "${CONFIGURATION}" --complexity=off || failed=$(expr $failed + 1)
+
+testit "try to set a non-complex password (command should succeed)" \
+ $VALGRIND $PYTHON $samba_tool user password "${CONFIGURATION}" -W$DOMAIN "-U$DOMAIN/$TEST_USERNAME%$TEST_PASSWORD" -k no --newpassword="$TEST_PASSWORD_WEAK" || failed=$(expr $failed + 1)
+
+TEST_PASSWORD=$TEST_PASSWORD_WEAK
+
+test_smbclient "test login with non-complex password" \
+ "ls" "$SMB_UNC" --use-kerberos=disabled -U$TEST_PRINCIPAL%$TEST_PASSWORD || failed=$(expr $failed + 1)
+
+testit_expect_failure "try to set a short password (command should not succeed)" \
+ $VALGRIND $PYTHON $samba_tool user password "${CONFIGURATION}" -W$DOMAIN "-U$DOMAIN/$TEST_USERNAME%$TEST_PASSWORD" -k no --newpassword="$TEST_PASSWORD_SHORT" || failed=$(expr $failed + 1)
+
+testit "allow short passwords (length 1)" \
+ $VALGRIND $PYTHON $samba_tool domain passwordsettings set "${CONFIGURATION}" --min-pwd-length=1 || failed=$(expr $failed + 1)
+
+testit "try to set a short password (command should succeed)" \
+ $VALGRIND $PYTHON $samba_tool user password "${CONFIGURATION}" -W$DOMAIN "-U$DOMAIN/$TEST_USERNAME%$TEST_PASSWORD" -k no --newpassword="$TEST_PASSWORD_SHORT" || failed=$(expr $failed + 1)
+
+TEST_PASSWORD=$TEST_PASSWORD_SHORT
+TEST_PASSWORD_NEW="testPaSS@07%"
+
+testit "require minimum password age of 1 day" \
+ $VALGRIND $PYTHON $samba_tool domain passwordsettings set "${CONFIGURATION}" --min-pwd-age=1 || failed=$(expr $failed + 1)
+
+testit "show password settings" \
+ $VALGRIND $PYTHON $samba_tool domain passwordsettings show "${CONFIGURATION}" || failed=$(expr $failed + 1)
+
+testit_expect_failure "try to change password too quickly (command should not succeed)" \
+ $VALGRIND $PYTHON $samba_tool user password "${CONFIGURATION}" -W$DOMAIN "-U$DOMAIN/$TEST_USERNAME%$TEST_PASSWORD" -k no --newpassword="$TEST_PASSWORD_NEW" || failed=$(expr $failed + 1)
+
+testit "reset password policies" \
+ $VALGRIND $PYTHON $samba_tool domain passwordsettings set "${CONFIGURATION}" --complexity=default --history-length=default --min-pwd-length=default --min-pwd-age=default --max-pwd-age=default || failed=$(expr $failed + 1)
+
+testit "delete user $TEST_USERNAME" \
+ $VALGRIND $PYTHON $samba_tool user delete $TEST_USERNAME -U"$USERNAME%$PASSWORD" "${CONFIGURATION}" -k no || failed=$(expr $failed + 1)
+
+rm -f $PREFIX/tmpuserpassfile $PREFIX/tmpsmbpasswdscript
+rm -f $KRB5CCNAME_PATH
+
+exit $failed
diff --git a/testprogs/blackbox/test_pdbtest.sh b/testprogs/blackbox/test_pdbtest.sh
new file mode 100755
index 0000000..2f4fad7
--- /dev/null
+++ b/testprogs/blackbox/test_pdbtest.sh
@@ -0,0 +1,116 @@
+#!/bin/sh
+# Blackbox tests for pdbtest
+# Copyright (C) 2006-2007 Jelmer Vernooij <jelmer@samba.org>
+# Copyright (C) 2006-2012 Andrew Bartlett <abartlet@samba.org>
+
+if [ $# -lt 2 ]; then
+ cat <<EOF
+Usage: test_pdbtest.sh SERVER PREFIX USER SMBCLIENT SMB_CONF
+EOF
+ exit 1
+fi
+
+SERVER=$1
+PREFIX=$2
+USER=$3
+smbclient=$4
+SMB_CONF=$5
+shift 5
+failed=0
+
+samba4bindir="$BINDIR"
+pdbtest="$samba4bindir/pdbtest"
+pdbedit="$samba4bindir/pdbedit"
+net="$samba4bindir/net"
+smbpasswd="$samba4bindir/smbpasswd"
+texpect="$samba4bindir/texpect"
+unc="//$SERVER/tmp"
+
+. $(dirname $0)/subunit.sh
+. $(dirname $0)/common_test_fns.inc
+
+test_smbpasswd()
+{
+ user=$1
+ newpass=$2
+
+ echo "set password with smbpasswd"
+ tmpfile=$PREFIX/smbpasswd_change_password_script
+ cat >$tmpfile <<EOF
+expect New SMB password:
+send ${newpass}\n
+expect Retype new SMB password:
+send ${newpass}\n
+EOF
+
+ cmd='UID_WRAPPER_INITIAL_RUID=0 UID_WRAPPER_INITIAL_EUID=0 $texpect $tmpfile $smbpasswd -L $user -c $SMB_CONF'
+ eval echo "$cmd"
+ out=$(eval $cmd)
+ ret=$?
+ rm -f $tmpfile
+
+ if [ $ret -ne 0 ]; then
+ echo "Failed to change user password $user"
+ return 1
+ fi
+}
+
+testit "pdbtest" $VALGRIND $BINDIR/pdbtest -u $USER "$@" || failed=$(expr $failed + 1)
+
+NEWUSERPASS=testPaSS@01%
+
+echo "set password with pdbedit"
+cat >$PREFIX/tmpsmbpasswdscript <<EOF
+expect new password:
+send ${NEWUSERPASS}\n
+expect retype new password:
+send ${NEWUSERPASS}\n
+EOF
+
+testit "create user with pdbedit" $texpect $PREFIX/tmpsmbpasswdscript $VALGRIND $pdbedit --configfile=$SMB_CONF -a $USER --account-desc="pdbedit-test-user" "$@" || failed=$(expr $failed + 1)
+USERPASS=$NEWUSERPASS
+
+test_smbclient "Test login with user (ntlm)" 'ls' "$unc" -U$USER%$NEWUSERPASS "$@" || failed=$(expr $failed + 1)
+
+testit "modify user" $VALGRIND $pdbedit --configfile=$SMB_CONF --modify $USER --drive="D:" "$@" || failed=$(expr $failed + 1)
+
+test_smbclient "Test login with user (ntlm)" 'ls' "$unc" -U$USER%$NEWUSERPASS "$@" || failed=$(expr $failed + 1)
+
+NEWUSERPASS=testPaSS@02%
+
+testit "set user password with smbpasswd" \
+ test_smbpasswd $USER $NEWUSERPASS ||
+ failed=$(expr $failed + 1)
+
+USERPASS=$NEWUSERPASS
+
+test_smbclient "Test login with user (ntlm)" 'ls' "$unc" -U$USER%$NEWUSERPASS "$@" || failed=$(expr $failed + 1)
+
+testit "modify user - disabled" $VALGRIND $net sam set disabled $USER yes "$@" || failed=$(expr $failed + 1)
+
+testit_expect_failure "Test login with disabled suer" $VALGRIND $smbclient //$SERVER/tmp -c 'ls' -U$USER@%$USERPASS || failed=$(expr $failed + 1)
+
+testit "modify user - enabled" $VALGRIND $net sam set disabled $USER no "$@" || failed=$(expr $failed + 1)
+
+test_smbclient "Test login with re-enabled user (ntlm)" 'ls' "$unc" -U$USER%$NEWUSERPASS || failed=$(expr $failed + 1)
+
+testit "modify user - must change password now" $VALGRIND $net sam set pwdmustchangenow $USER yes "$@" || failed=$(expr $failed + 1)
+
+testit_expect_failure "Test login with expired password" $VALGRIND $smbclient //$SERVER/tmp -c 'ls' -U$USER@%$USERPASS || failed=$(expr $failed + 1)
+
+testit "modify user - disable password expiry" $VALGRIND $net sam set pwnoexp $USER yes "$@" || failed=$(expr $failed + 1)
+
+test_smbclient "Test login with no expiry (ntlm)" 'ls' "$unc" -U$USER%$NEWUSERPASS || failed=$(expr $failed + 1)
+
+NEWUSERPASS=testPaSS@03%
+NEWUSERHASH=062519096c45739c1938800f80906731
+
+testit "Set user password with password hash" $VALGRIND $pdbedit --configfile=$SMB_CONF -u $USER --set-nt-hash $NEWUSERHASH "$@" || failed=$(expr $failed + 1)
+
+test_smbclient "Test login with new password (from hash)" 'ls' "$unc" -U$USER%$NEWUSERPASS || failed=$(expr $failed + 1)
+
+testit "del user" $VALGRIND $pdbedit --configfile=$SMB_CONF -x $USER "$@" || failed=$(expr $failed + 1)
+
+rm $PREFIX/tmpsmbpasswdscript
+
+exit $failed
diff --git a/testprogs/blackbox/test_pkinit_pac.sh b/testprogs/blackbox/test_pkinit_pac.sh
new file mode 100755
index 0000000..1f94ece
--- /dev/null
+++ b/testprogs/blackbox/test_pkinit_pac.sh
@@ -0,0 +1,61 @@
+#!/bin/sh
+# Blackbox tests for pkinit and pac verification
+#
+# Copyright (C) 2006-2008 Stefan Metzmacher
+# Copyright (C) 2022 Andreas Schneider
+
+if [ $# -lt 6 ]; then
+ cat <<EOF
+Usage: test_pkinit_pac.sh SERVER USERNAME PASSWORD REALM DOMAIN PREFIX
+EOF
+ exit 1
+fi
+
+SERVER=$1
+USERNAME=$2
+PASSWORD=$3
+REALM=$4
+DOMAIN=$5
+PREFIX=$6
+shift 6
+failed=0
+
+samba_bindir="$BINDIR"
+
+samba_smbtorture="${samba_bindir}/smbtorture --basedir=$SELFTEST_TMPDIR"
+
+. "$(dirname "$0")"/subunit.sh
+. "$(dirname "$0")"/common_test_fns.inc
+
+samba_kinit=$(system_or_builddir_binary kinit "${BINDIR}" samba4kinit)
+
+KRB5CCNAME_PATH="$PREFIX/tmpccache"
+rm -f "${KRB5CCNAME_PATH}"
+KRB5CCNAME="FILE:$KRB5CCNAME_PATH"
+export KRB5CCNAME
+
+USER_PRINCIPAL_NAME="$(echo "${USERNAME}@${REALM}" | tr "[:upper:]" "[:lower:]")"
+
+kbase="$(basename "${samba_kinit}")"
+if [ "${kbase}" = "samba4kinit" ]; then
+ # HEIMDAL
+ X509_USER_IDENTITY="--pk-user=FILE:${PREFIX}/pkinit/USER-${USER_PRINCIPAL_NAME}-cert.pem,${PREFIX}/pkinit/USER-${USER_PRINCIPAL_NAME}-private-key.pem"
+ OPTION_RENEWABLE="--renewable"
+else
+ X509_USER_IDENTITY="-X X509_user_identity=FILE:${PREFIX}/pkinit/USER-${USER_PRINCIPAL_NAME}-cert.pem,${PREFIX}/pkinit/USER-${USER_PRINCIPAL_NAME}-private-key.pem"
+ OPTION_RENEWABLE="-r 1h"
+fi
+OPTION_REQUEST_PAC="--request-pac"
+
+testit "STEP1 kinit with pkinit (name specified)" \
+ "${samba_kinit}" "${OPTION_REQUEST_PAC}" "${OPTION_RENEWABLE}" \
+ "${X509_USER_IDENTITY}" "${USERNAME}@${REALM}" ||
+ failed=$((failed + 1))
+testit "STEP1 remote.pac verification" \
+ "${samba_smbtorture}" ncacn_np:"${SERVER}" rpc.pac \
+ --workgroup="${DOMAIN}" -U"${USERNAME}%${PASSWORD}" \
+ --option=torture:pkinit_ccache="${KRB5CCNAME}" ||
+ failed=$((failed + 1))
+
+rm -f "${KRB5CCNAME_PATH}"
+exit ${failed}
diff --git a/testprogs/blackbox/test_pkinit_simple.sh b/testprogs/blackbox/test_pkinit_simple.sh
new file mode 100755
index 0000000..629bfad
--- /dev/null
+++ b/testprogs/blackbox/test_pkinit_simple.sh
@@ -0,0 +1,331 @@
+#!/bin/sh
+# Blackbox tests for kinit and kerberos integration with smbclient etc
+#
+# Copyright (C) 2006-2007 Jelmer Vernooij <jelmer@samba.org>
+# Copyright (C) 2006-2008 Andrew Bartlett <abartlet@samba.org>
+# Copyright (C) 2022 Andreas Schneider <asn@samba.org>
+
+if [ $# -lt 7 ]; then
+ cat <<EOF
+Usage: test_pkinit_simple.sh SERVER USERNAME PASSWORD REALM DOMAIN PREFIX SMBCLIENT
+EOF
+ exit 1
+fi
+
+SERVER="${1}"
+USERNAME="${2}"
+PASSWORD="${3}"
+REALM="${4}"
+DOMAIN="${5}"
+PREFIX="${6}"
+smbclient="${7}"
+shift 7
+failed=0
+
+samba_bindir="${BINDIR}"
+
+samba_tool="${PYTHON} ${samba_bindir}/samba-tool"
+wbinfo="${samba_bindir}/wbinfo"
+
+. "$(dirname "$0")"/subunit.sh
+. "$(dirname "$0")"/common_test_fns.inc
+
+samba_kinit=$(system_or_builddir_binary kinit "${BINDIR}" samba4kinit)
+
+unc="//${SERVER}/tmp"
+
+KRB5CCNAME_PATH="$PREFIX/tmpccache"
+rm -f "${KRB5CCNAME_PATH}"
+KRB5CCNAME="FILE:$KRB5CCNAME_PATH"
+export KRB5CCNAME
+
+USER_PRINCIPAL_NAME="$(echo "${USERNAME}@${REALM}" | tr "[:upper:]" "[:lower:]")"
+
+kbase="$(basename "${samba_kinit}")"
+if [ "${kbase}" = "samba4kinit" ]; then
+ # HEIMDAL
+ X509_USER_IDENTITY="--pk-user=FILE:${PREFIX}/pkinit/USER-${USER_PRINCIPAL_NAME}-cert.pem,${PREFIX}/pkinit/USER-${USER_PRINCIPAL_NAME}-private-key.pem"
+ OPTION_RENEWABLE="--renewable"
+ OPTION_RENEW_TICKET="--renew"
+ OPTION_ENTERPRISE_NAME="--enterprise"
+else
+ # MIT
+ X509_USER_IDENTITY="-X X509_user_identity=FILE:${PREFIX}/pkinit/USER-${USER_PRINCIPAL_NAME}-cert.pem,${PREFIX}/pkinit/USER-${USER_PRINCIPAL_NAME}-private-key.pem"
+ OPTION_RENEWABLE="-r 1h"
+ OPTION_RENEW_TICKET="-R"
+ OPTION_ENTERPRISE_NAME="-E"
+fi
+OPTION_REQUEST_PAC="--request-pac"
+
+# STEP0:
+# Now we set the UF_SMARTCARD_REQUIRED bit
+# This means we have a normal enabled account *without* a known password
+testit "STEP0 samba-tool user create ${USERNAME} --smartcard-required" \
+ "${samba_tool}" user create "${USERNAME}" --smartcard-required ||
+ failed=$((failed + 1))
+
+testit_expect_failure "STEP1 kinit with password" \
+ kerberos_kinit "${samba_kinit}" "${USERNAME}@${REALM}" "${PASSWORD}" \
+ "${OPTION_REQUEST_PAC}" ||
+ failed=$((failed + 1))
+testit_expect_failure "STEP1 Test login with NTLM" \
+ "${smbclient}" "${unc}" -c 'ls' "-U${USERNAME}%${PASSWORD}" ||
+ failed=$((failed + 1))
+testit_expect_failure "STEP1 Test wbinfo with password" \
+ "${wbinfo}" "--authenticate=$DOMAIN/$USERNAME%$PASSWORD" ||
+ failed=$((failed + 1))
+
+testit "STEP1 kinit with pkinit (name specified: ${USERNAME})" \
+ "${samba_kinit}" "${OPTION_REQUEST_PAC}" "${OPTION_RENEWABLE}" \
+ "${X509_USER_IDENTITY}" "${USERNAME}@${REALM}" ||
+ failed=$((failed + 1))
+
+testit "STEP1 kinit renew ticket (name specified)" \
+ "${samba_kinit}" "${OPTION_REQUEST_PAC}" "${OPTION_RENEW_TICKET}" ||
+ failed=$((failed + 1))
+test_smbclient "STEP1 Test login with kerberos ccache (name specified)" \
+ 'ls' "$unc" --use-krb5-ccache="${KRB5CCNAME}" ||
+ failed=$((failed + 1))
+
+# OK
+testit_expect_failure "STEP1 kinit with pkinit (wrong name specified)" \
+ "${samba_kinit}" "${OPTION_REQUEST_PAC}" "${OPTION_RENEWABLE}" \
+ "${X509_USER_IDENTITY}" "not${USERNAME}@${REALM}" ||
+ failed=$((failed + 1))
+
+testit_expect_failure "STEP1 kinit with pkinit (wrong name specified 2)" \
+ "${samba_kinit}" "${OPTION_REQUEST_PAC}" "${OPTION_RENEWABLE}" \
+ "${X509_USER_IDENTITY}" "${SERVER}@${REALM}" ||
+ failed=$((failed + 1))
+
+testit "STEP1 kinit with pkinit (enterprise name specified)" \
+ "${samba_kinit}" "${OPTION_REQUEST_PAC}" "${OPTION_RENEWABLE}" \
+ "${X509_USER_IDENTITY}" "${OPTION_ENTERPRISE_NAME}" \
+ "${USERNAME}@${REALM}" ||
+ failed=$((failed + 1))
+testit "STEP1 kinit renew ticket (enterprise name specified)" \
+ "${samba_kinit}" "${OPTION_REQUEST_PAC}" "${OPTION_RENEW_TICKET}" ||
+ failed=$((failed + 1))
+test_smbclient "STEP1 Test login with kerberos ccache (enterprise name specified)" \
+ 'ls' "${unc}" --use-krb5-ccache="${KRB5CCNAME}" ||
+ failed=$((failed + 1))
+testit_expect_failure "STEP1 kinit with pkinit (wrong enterprise name specified)" \
+ "${samba_kinit}" "${OPTION_REQUEST_PAC}" "${OPTION_RENEWABLE}" \
+ "${X509_USER_IDENTITY}" "${OPTION_ENTERPRISE_NAME}" \
+ "not${USERNAME}@${REALM}" ||
+ failed=$((failed + 1))
+testit_expect_failure "STEP1 kinit with pkinit (wrong enterprise name specified 2)" \
+ "${samba_kinit}" "${OPTION_REQUEST_PAC}" "${OPTION_RENEWABLE}" \
+ "${X509_USER_IDENTITY}" "${OPTION_ENTERPRISE_NAME}" \
+ "${SERVER}@${REALM}" ||
+ failed=$((failed + 1))
+
+testit "STEP1 kinit with pkinit (enterprise name in cert)" \
+ "${samba_kinit}" "${OPTION_REQUEST_PAC}" "${OPTION_RENEWABLE}" \
+ "${X509_USER_IDENTITY}" "${OPTION_ENTERPRISE_NAME}" ||
+ failed=$((failed + 1))
+testit "STEP1 kinit renew ticket (enterprise name in cert)" \
+ "${samba_kinit}" "${OPTION_REQUEST_PAC}" "${OPTION_RENEW_TICKET}" ||
+ failed=$((failed + 1))
+test_smbclient "STEP1 Test login with kerberos ccache (enterprise name in cert)" \
+ 'ls' "${unc}" --use-krb5-ccache="${KRB5CCNAME}" ||
+ failed=$((failed + 1))
+
+# STEP2:
+# We still have UF_SMARTCARD_REQUIRED, but with a known password
+testit "STEP2 samba-tool user setpassword ${USERNAME} --newpassword" \
+ "${samba_tool}" user setpassword "${USERNAME}" \
+ --newpassword="${PASSWORD}" ||
+ failed=$((failed + 1))
+
+testit_expect_failure "STEP2 kinit with password" \
+ kerberos_kinit "${samba_kinit}" "${USERNAME}@${REALM}" "${PASSWORD}" \
+ "${OPTION_REQUEST_PAC}" ||
+ failed=$((failed + 1))
+test_smbclient "STEP2 Test login with NTLM" \
+ 'ls' "$unc" -U"${USERNAME}%${PASSWORD}" ||
+ failed=$((failed + 1))
+testit_expect_failure "STEP2 Test wbinfo with password" \
+ "${wbinfo}" --authenticate="${DOMAIN}/${USERNAME}%${PASSWORD}" ||
+ failed=$((failed + 1))
+
+testit "STEP2 kinit with pkinit (name specified) " \
+ "${samba_kinit}" "${OPTION_REQUEST_PAC}" "${OPTION_RENEWABLE}" \
+ "${X509_USER_IDENTITY}" "${USERNAME}@${REALM}" ||
+ failed=$((failed + 1))
+testit "STEP2 kinit renew ticket (name specified)" \
+ "${samba_kinit}" "${OPTION_REQUEST_PAC}" "${OPTION_RENEW_TICKET}" ||
+ failed=$((failed + 1))
+test_smbclient "STEP2 Test login with kerberos ccache (name specified)" \
+ 'ls' "$unc" --use-krb5-ccache="${KRB5CCNAME}" ||
+ failed=$((failed + 1))
+
+testit "STEP2 kinit with pkinit (enterprise name specified)" \
+ "${samba_kinit}" "${OPTION_REQUEST_PAC}" "${OPTION_RENEWABLE}" \
+ "${X509_USER_IDENTITY}" "${OPTION_ENTERPRISE_NAME}" \
+ "${USERNAME}@${REALM}" ||
+ failed=$((failed + 1))
+testit "STEP2 kinit renew ticket (enterprise name specified)" \
+ "${samba_kinit}" "${OPTION_REQUEST_PAC}" "${OPTION_RENEW_TICKET}" ||
+ failed=$((failed + 1))
+test_smbclient "STEP2 Test login with kerberos ccache (enterprise name specified)" \
+ 'ls' "$unc" --use-krb5-ccache="${KRB5CCNAME}" ||
+ failed=$((failed + 1))
+
+testit "STEP2 kinit with pkinit (enterprise name in cert)" \
+ "${samba_kinit}" "${OPTION_REQUEST_PAC}" "${OPTION_RENEWABLE}" \
+ "${X509_USER_IDENTITY}" "${OPTION_ENTERPRISE_NAME}" ||
+ failed=$((failed + 1))
+testit "STEP2 kinit renew ticket (enterprise name in cert)" \
+ "${samba_kinit}" "${OPTION_REQUEST_PAC}" "${OPTION_RENEW_TICKET}" ||
+ failed=$((failed + 1))
+test_smbclient "STEP2 Test login with kerberos ccache (enterprise name in cert)" \
+ 'ls' "$unc" --use-krb5-ccache="${KRB5CCNAME}" ||
+ failed=$((failed + 1))
+
+# STEP3:
+# The account is a normal account without the UF_SMARTCARD_REQUIRED bit set
+testit "STEP3 samba-tool user setpassword ${USERNAME} --clear-smartcard-required" \
+ "${samba_tool}" user setpassword "${USERNAME}" \
+ --newpassword="${PASSWORD}" --clear-smartcard-required ||
+ failed=$((failed + 1))
+
+testit "STEP3 kinit with password" \
+ kerberos_kinit "${samba_kinit}" "${USERNAME}@${REALM}" "${PASSWORD}" \
+ "${OPTION_REQUEST_PAC}" ||
+ failed=$((failed + 1))
+test_smbclient "STEP3 Test login with user kerberos ccache" \
+ 'ls' "$unc" --use-krb5-ccache="${KRB5CCNAME}" ||
+ failed=$((failed + 1))
+test_smbclient "STEP3 Test login with NTLM" \
+ 'ls' "$unc" -U"${USERNAME}%${PASSWORD}" ||
+ failed=$((failed + 1))
+testit "STEP3 Test wbinfo with password" \
+ "${wbinfo}" --authenticate="${DOMAIN}/${USERNAME}%${PASSWORD}" ||
+ failed=$((failed + 1))
+
+testit "STEP3 kinit with pkinit (name specified) " \
+ "${samba_kinit}" "${OPTION_REQUEST_PAC}" "${OPTION_RENEWABLE}" \
+ "${X509_USER_IDENTITY}" "${USERNAME}@${REALM}" ||
+ failed=$((failed + 1))
+testit "STEP3 kinit renew ticket (name specified)" \
+ "${samba_kinit}" "${OPTION_REQUEST_PAC}" "${OPTION_RENEW_TICKET}" ||
+ failed=$((failed + 1))
+test_smbclient "STEP3 Test login with kerberos ccache (name specified)" \
+ 'ls' "${unc}" --use-krb5-ccache="${KRB5CCNAME}" ||
+ failed=$((failed + 1))
+
+testit "STEP3 kinit with pkinit (enterprise name specified)" \
+ "${samba_kinit}" "${OPTION_REQUEST_PAC}" "${OPTION_RENEWABLE}" \
+ "${X509_USER_IDENTITY}" "${OPTION_ENTERPRISE_NAME}" \
+ "${USERNAME}@${REALM}" ||
+ failed=$((failed + 1))
+testit "STEP3 kinit renew ticket (enterprise name specified)" \
+ "${samba_kinit}" "${OPTION_REQUEST_PAC}" "${OPTION_RENEW_TICKET}" ||
+ failed=$((failed + 1))
+test_smbclient "STEP3 Test login with kerberos ccache (enterprise name specified)" \
+ 'ls' "${unc}" --use-krb5-ccache="${KRB5CCNAME}" ||
+ failed=$((failed + 1))
+
+testit "STEP3 kinit with pkinit (enterprise name in cert)" \
+ "${samba_kinit}" "${OPTION_REQUEST_PAC}" "${OPTION_RENEWABLE}" \
+ "${X509_USER_IDENTITY}" "${OPTION_ENTERPRISE_NAME}" ||
+ failed=$((failed + 1))
+testit "STEP3 kinit renew ticket (enterprise name in cert)" \
+ "${samba_kinit}" "${OPTION_REQUEST_PAC}" "${OPTION_RENEW_TICKET}" ||
+ failed=$((failed + 1))
+test_smbclient "STEP3 Test login with kerberos ccache (enterprise name in cert)" \
+ 'ls' "${unc}" --use-krb5-ccache="${KRB5CCNAME}" ||
+ failed=$((failed + 1))
+
+# STEP4:
+# Now we set the UF_SMARTCARD_REQUIRED bit
+# This means we have a normal enabled account *without* a known password
+testit "STEP4 samba-tool user setpassword $USERNAME --smartcard-required" \
+ "${samba_tool}" user setpassword "${USERNAME}" --smartcard-required ||
+ failed=$((failed + 1))
+
+testit_expect_failure "STEP4 kinit with password" \
+ kerberos_kinit "${samba_kinit}" "${USERNAME}@${REALM}" "${PASSWORD}" \
+ "${OPTION_REQUEST_PAC}" ||
+ failed=$((failed + 1))
+testit_expect_failure "STEP4 Test login with NTLM" \
+ "${smbclient}" "${unc}" -c 'ls' -U"${USERNAME}%${PASSWORD}" ||
+ failed=$((failed + 1))
+testit_expect_failure "STEP4 Test wbinfo with password" \
+ "${wbinfo}" --authenticate="${DOMAIN}/${USERNAME}%${PASSWORD}" ||
+ failed=$((failed + 1))
+
+testit "STEP4 kinit with pkinit (name specified)" \
+ "${samba_kinit}" "${OPTION_REQUEST_PAC}" "${OPTION_RENEWABLE}" \
+ "${X509_USER_IDENTITY}" "${USERNAME}@${REALM}" ||
+ failed=$((failed + 1))
+testit "STEP4 kinit renew ticket (name specified)" \
+ "${samba_kinit}" "${OPTION_REQUEST_PAC}" "${OPTION_RENEW_TICKET}" ||
+ failed=$((failed + 1))
+test_smbclient "STEP4 Test login with kerberos ccache (name specified)" \
+ 'ls' "$unc" --use-krb5-ccache="${KRB5CCNAME}" ||
+ failed=$((failed + 1))
+
+testit "STEP4 kinit with pkinit (enterprise name specified)" \
+ "${samba_kinit}" "${OPTION_REQUEST_PAC}" "${OPTION_RENEWABLE}" \
+ "${X509_USER_IDENTITY}" "${OPTION_ENTERPRISE_NAME}" \
+ "${USERNAME}@${REALM}" ||
+ failed=$((failed + 1))
+testit "STEP4 kinit renew ticket (enterprise name specified)" \
+ "${samba_kinit}" "${OPTION_REQUEST_PAC}" "${OPTION_RENEW_TICKET}" ||
+ failed=$((failed + 1))
+test_smbclient "STEP4 Test login with kerberos ccache (enterprise name specified)" \
+ 'ls' "${unc}" --use-krb5-ccache="${KRB5CCNAME}" ||
+ failed=$((failed + 1))
+
+testit "STEP4 kinit with pkinit (enterprise name in cert)" \
+ "${samba_kinit}" "${OPTION_REQUEST_PAC}" "${OPTION_RENEWABLE}" \
+ "${X509_USER_IDENTITY}" "${OPTION_ENTERPRISE_NAME}" ||
+ failed=$((failed + 1))
+testit "STEP4 kinit renew ticket (enterprise name in cert)" \
+ "${samba_kinit}" "${OPTION_REQUEST_PAC}" "${OPTION_RENEW_TICKET}" ||
+ failed=$((failed + 1))
+test_smbclient "STEP4 Test login with kerberos ccache (enterprise name in cert)" \
+ 'ls' "${unc}" --use-krb5-ccache="${KRB5CCNAME}" ||
+ failed=$((failed + 1))
+
+# STEP5:
+# disable the account
+testit "STEP5 samba-tool user disable $USERNAME" \
+ "${samba_tool}" user disable "${USERNAME}" ||
+ failed=$((failed + 1))
+
+testit_expect_failure "STEP5 kinit with password" \
+ kerberos_kinit "${samba_kinit}" "${USERNAME}@${REALM}" "${PASSWORD}" \
+ "${OPTION_REQUEST_PAC}" ||
+ failed=$((failed + 1))
+testit_expect_failure "STEP5 Test login with NTLM" \
+ "${smbclient}" "${unc}" -c 'ls' -U"${USERNAME}%${PASSWORD}" ||
+ failed=$((failed + 1))
+testit_expect_failure "STEP5 Test wbinfo with password" \
+ "${wbinfo}" --authenticate="${DOMAIN}/${USERNAME}%${PASSWORD}" ||
+ failed=$((failed + 1))
+
+testit_expect_failure "STEP5 kinit with pkinit (name specified)" \
+ "${samba_kinit}" "${OPTION_REQUEST_PAC}" "${OPTION_RENEWABLE}" \
+ "${X509_USER_IDENTITY}" "${USERNAME}@${REALM}" ||
+ failed=$((failed + 1))
+testit_expect_failure "STEP5 kinit with pkinit (enterprise name specified)" \
+ "${samba_kinit}" "${OPTION_REQUEST_PAC}" "${OPTION_RENEWABLE}" \
+ "${X509_USER_IDENTITY}" "${OPTION_ENTERPRISE_NAME}" \
+ "${USERNAME}@${REALM}" ||
+ failed=$((failed + 1))
+testit_expect_failure "STEP5 kinit with pkinit (enterprise name in cert)" \
+ "${samba_kinit}" "${OPTION_REQUEST_PAC}" "${OPTION_RENEWABLE}" \
+ "${X509_USER_IDENTITY}" "${OPTION_ENTERPRISE_NAME}" ||
+ failed=$((failed + 1))
+
+# STEP6:
+# cleanup
+testit "STEP6 samba-tool user delete ${USERNAME}" \
+ "${samba_tool}" user delete "${USERNAME}" ||
+ failed=$((failed + 1))
+
+rm -f "${KRB5CCNAME_PATH}"
+exit ${failed}
diff --git a/testprogs/blackbox/test_primary_group.sh b/testprogs/blackbox/test_primary_group.sh
new file mode 100755
index 0000000..74a1ad5
--- /dev/null
+++ b/testprogs/blackbox/test_primary_group.sh
@@ -0,0 +1,93 @@
+#!/bin/bash
+
+if [ $# -lt 5 ]; then
+ cat <<EOF
+Usage: test_primary_group.sh SERVER USERNAME PASSWORD DOMAIN PREFIX_ABS
+EOF
+ exit 1
+fi
+
+SERVER=$1
+USERNAME=$2
+PASSWORD=$3
+DOMAIN=$4
+PREFIX_ABS=$5
+shift 5
+failed=0
+
+TMPDIR="$PREFIX_ABS/$(basename $0)"
+export TMPDIR
+
+. $(dirname $0)/subunit.sh
+. $(dirname $0)/common_test_fns.inc
+
+ldbmodify=$(system_or_builddir_binary ldbmodify "${BINDIR}")
+ldbsearch=$(system_or_builddir_binary ldbsearch "${BINDIR}")
+
+TZ=UTC
+export TZ
+
+N=$(date +%H%M%S)
+
+testuser="testuser$N"
+testgroup="testgroup$N"
+
+echo "testuser: $testuser"
+echo "testgroup: $testgroup"
+
+testit "mkdir -p '${TMPDIR}'" mkdir -p ${TMPDIR} || failed=$(expr $failed + 1)
+
+testit "create '$testuser'" $VALGRIND $PYTHON $BINDIR/samba-tool user create "$testuser" Password.1 || failed=$(expr $failed + 1)
+testit "add '$testgroup'" $VALGRIND $PYTHON $BINDIR/samba-tool group add "$testgroup" || failed=$(expr $failed + 1)
+testit "addmembers '$testgroup' '$testuser'" $VALGRIND $PYTHON $BINDIR/samba-tool group addmembers "$testgroup" "$testuser" || failed=$(expr $failed + 1)
+
+testit "search1" ${ldbsearch} -H ldap://$SERVER_IP -U$USERNAME%$PASSWORD -d0 sAMAccountName="$testgroup" objectSid || failed=$(expr $failed + 1)
+ldif="${TMPDIR}/search1.ldif"
+${ldbsearch} -H ldap://$SERVER_IP -U$USERNAME%$PASSWORD -d0 sAMAccountName=$testgroup objectSid >$ldif
+rid=$(cat $ldif | sed -n 's/^objectSid: S-1-5-21-.*-.*-.*-//p')
+
+testit "search2" ${ldbsearch} -H ldap://$SERVER_IP -U$USERNAME%$PASSWORD -d0 sAMAccountName="$testuser" dn || failed=$(expr $failed + 1)
+ldif="${TMPDIR}/search2.ldif"
+${ldbsearch} -H ldap://$SERVER_IP -U$USERNAME%$PASSWORD -d0 sAMAccountName=$testuser dn >$ldif
+user_dn=$(cat $ldif | sed -n 's/^dn: //p')
+
+ldif="${TMPDIR}/modify1.ldif"
+cat >$ldif <<EOF
+dn: $user_dn
+changetype: modify
+replace: primaryGroupID
+primaryGroupID: $rid
+EOF
+testit "Change primaryGroupID to $rid" ${ldbmodify} -H ldap://$SERVER_IP -U$USERNAME%$PASSWORD -d0 --verbose <$ldif || failed=$(expr $failed + 1)
+
+testit "dbcheck run1" $VALGRIND $PYTHON $BINDIR/samba-tool dbcheck --attrs=member || failed=$(expr $failed + 1)
+
+ldif="${TMPDIR}/modify2.ldif"
+cat >$ldif <<EOF
+dn: $user_dn
+changetype: modify
+replace: primaryGroupID
+primaryGroupID: 513
+EOF
+testit "Change primaryGroupID to 513" ${ldbmodify} -H ldap://$SERVER_IP -U$USERNAME%$PASSWORD -d0 <$ldif || failed=$(expr $failed + 1)
+
+testit "dbcheck run2" $VALGRIND $PYTHON $BINDIR/samba-tool dbcheck --attrs=member || failed=$(expr $failed + 1)
+
+testit "delete '$testuser'" $VALGRIND $PYTHON $BINDIR/samba-tool user delete "$testuser" || failed=$(expr $failed + 1)
+testit "delete '$testgroup'" $VALGRIND $PYTHON $BINDIR/samba-tool group delete "$testgroup" || failed=$(expr $failed + 1)
+
+#
+# As we don't support phantom objects and virtual backlinks
+# the deletion of the user prior to the group causes dangling links,
+# which are detected like this:
+#
+# WARNING: target DN is deleted for member in object
+#
+# Specifically, this happens because after the member link is
+# deactivated the memberOf is gone, and so there is no way to find the
+# now redundant forward link to clean it up.
+#
+testit_expect_failure "dbcheck run3" $VALGRIND $PYTHON $BINDIR/samba-tool dbcheck --attrs=member --fix --yes || failed=$(expr $failed + 1)
+testit "dbcheck run4" $VALGRIND $PYTHON $BINDIR/samba-tool dbcheck --attrs=member || failed=$(expr $failed + 1)
+
+exit $failed
diff --git a/testprogs/blackbox/test_rpcclient_schannel.sh b/testprogs/blackbox/test_rpcclient_schannel.sh
new file mode 100755
index 0000000..798d235
--- /dev/null
+++ b/testprogs/blackbox/test_rpcclient_schannel.sh
@@ -0,0 +1,94 @@
+#!/bin/bash
+# Blackbox tests rpcclient with schannel
+# Copyright (c) 2021 Andreas Schneider <asn@samba.org>
+
+if [ $# -lt 8 ]; then
+ cat <<EOF
+Usage: test_rpcclient_schannel.sh DOMAIN REALM USERNAME PASSWORD SERVER PREFIX CONFIGURATION TESTENV
+EOF
+ exit 1
+fi
+
+DOMAIN=$1
+REALM=$2
+USERNAME=$3
+PASSWORD=$4
+SERVER=$5
+PREFIX=$6
+CONFIGURATION=$7
+TESTENV=$8
+shift 8
+
+failed=0
+
+samba_subunit_dir=$(dirname "$0")
+. "${samba_subunit_dir}/subunit.sh"
+. "${samba_subunit_dir}/common_test_fns.inc"
+
+samba_bindir="${BINDIR}"
+samba_rpcclient="${samba_bindir}/rpcclient"
+
+test_rpc_getusername()
+{
+ cmd="$samba_rpcclient ncacn_np:${SERVER}[schannel] --machine-pass --configfile=${CONFIGURATION} -c getusername 2>&1"
+ out=$(eval "$cmd")
+ ret=$?
+ if [ $ret -ne 0 ]; then
+ echo "Failed to connect! Error: $ret"
+ echo "$out"
+ return 1
+ fi
+
+ echo "$out" | grep -q "Account Name: ANONYMOUS LOGON, Authority Name: NT AUTHORITY"
+ ret=$?
+ if [ $ret -ne 0 ]; then
+ echo "Incorrect account/authority name! Error: $ret"
+ echo "$out"
+ return 1
+ fi
+
+ return 0
+}
+
+test_rpc_lookupsids()
+{
+ cmd="$samba_rpcclient ncacn_ip_tcp:${SERVER}[schannel] --machine-pass --configfile=${CONFIGURATION} -c 'lookupsids3 S-1-1-0' 2>&1"
+ out=$(eval "$cmd")
+ ret=$?
+ if [ $ret -ne 0 ]; then
+ echo "Failed to connect! Error: $ret"
+ echo "$out"
+ return 1
+ fi
+
+ echo "$out" | grep -q "S-1-1-0 Everyone"
+ ret=$?
+ if [ $ret -ne 0 ]; then
+ echo "Incorrect account/authority name! Error: $ret"
+ echo "$out"
+ return 1
+ fi
+
+ return 0
+}
+
+testit "ncacn_np.getusername" \
+ test_rpc_getusername ||
+ failed=$((failed + 1))
+
+if [[ "$TESTENV" == "ad_member_fips"* ]]; then
+ unset GNUTLS_FORCE_FIPS_MODE
+
+ testit "ncacn_np.getusername.fips" \
+ test_rpc_getusername ||
+ failed=$((failed + 1))
+
+ GNUTLS_FORCE_FIPS_MODE=1
+ export GNUTLS_FORCE_FIPS_MODE
+fi
+
+testit "ncacn_ip_tcp.lookupsids" \
+ test_rpc_lookupsids ||
+ failed=$((failed + 1))
+
+exit ${failed}
diff --git a/testprogs/blackbox/test_s4u_heimdal.sh b/testprogs/blackbox/test_s4u_heimdal.sh
new file mode 100755
index 0000000..a3b2dbb
--- /dev/null
+++ b/testprogs/blackbox/test_s4u_heimdal.sh
@@ -0,0 +1,90 @@
+#!/bin/sh
+
+if [ $# -lt 5 ]; then
+ cat <<EOF
+Usage: test_s4u_heimdal.sh SERVER USERNAME PASSWORD REALM DOMAIN TRUST_SERVER TRUST_USERNAME TRUST_PASSWORD TRUST_REALM TRUST_DOMAIN PREFIX
+EOF
+ exit 1
+fi
+
+SERVER=$1
+USERNAME=$2
+PASSWORD=$3
+REALM=$4
+DOMAIN=$5
+TRUST_SERVER=$6
+TRUST_USERNAME=$7
+TRUST_PASSWORD=$8
+TRUST_REALM=$9
+TRUST_DOMAIN=${10}
+PREFIX=${11}
+shift 11
+failed=0
+
+samba_tool="$VALGRIND $PYTHON $BINDIR/samba-tool"
+
+samba4kinit_binary=kinit
+if test -x $BINDIR/samba4kinit; then
+ samba4kinit_binary=$BINDIR/samba4kinit
+fi
+
+samba4kgetcred=kgetcred
+if test -x $BINDIR/samba4kgetcred; then
+ samba4kgetcred=$BINDIR/samba4kgetcred
+fi
+
+. $(dirname $0)/subunit.sh
+. $(dirname $0)/common_test_fns.inc
+
+ocache="$PREFIX/tmpoutcache"
+KRB5CCNAME_PATH="$PREFIX/tmpccache"
+KRB5CCNAME="FILE:$KRB5CCNAME_PATH"
+samba4kinit="$samba4kinit_binary -c $KRB5CCNAME"
+export KRB5CCNAME
+rm -rf $KRB5CCNAME_PATH
+
+princ=test_impersonate_princ
+impersonator=test_impersonator.$REALM
+target="CIFS/$SERVER.$REALM"
+
+testit "add impersonator principal" $samba_tool user add $impersonator $PASSWORD || failed=$(expr $failed + 1)
+testit "become a service" $samba_tool spn add "HOST/$impersonator" $impersonator || failed=$(expr $failed + 1)
+
+testit "set TrustedToAuthForDelegation" $samba_tool delegation for-any-protocol $impersonator on || failed=$(expr $failed + 1)
+testit "add msDS-AllowedToDelegateTo" $samba_tool delegation add-service $impersonator $target || failed=$(expr $failed + 1)
+
+testit "add a new principal" $samba_tool user add $princ --random-password || failed=$(expr $failed + 1)
+testit "set not-delegated flag" $samba_tool user sensitive $princ on || failed=$(expr $failed + 1)
+
+echo $PASSWORD >$PREFIX/tmppassfile
+testit "kinit impersonator" $samba4kinit -f --password-file=$PREFIX/tmppassfile $impersonator || failed=$(expr $failed + 1)
+
+testit "test S4U2Self with normal user" $samba4kgetcred --out-cache=$ocache --forwardable --impersonate=${USERNAME} $impersonator || failed=$(expr $failed + 1)
+testit "test S4U2Proxy with normal user" $samba4kgetcred --out-cache=$ocache --delegation-credential-cache=${ocache} $target || failed=$(expr $failed + 1)
+
+testit "test S4U2Self with sensitive user" $samba4kgetcred --out-cache=$ocache --forwardable --impersonate=$princ $impersonator || failed=$(expr $failed + 1)
+testit_expect_failure "test S4U2Proxy with sensitive user" $samba4kgetcred --out-cache=$ocache --delegation-credential-cache=${ocache} $target || failed=$(expr $failed + 1)
+
+rm -f $ocache
+testit "unset not-delegated flag" $samba_tool user sensitive $princ off || failed=$(expr $failed + 1)
+
+testit "test S4U2Self after unsetting ND flag" $samba4kgetcred --out-cache=$ocache --forwardable --impersonate=$princ $impersonator || failed=$(expr $failed + 1)
+testit "test S4U2Proxy after unsetting ND flag" $samba4kgetcred --out-cache=$ocache --delegation-credential-cache=${ocache} $target || failed=$(expr $failed + 1)
+
+testit "kinit user cache" $samba4kinit -c $ocache -f --password-file=$PREFIX/tmppassfile $USERNAME || failed=$(expr $failed + 1)
+testit "get a ticket to impersonator" $samba4kgetcred -c $ocache --forwardable $impersonator || failed=$(expr $failed + 1)
+testit "test S4U2Proxy evidence ticket obtained by TGS" $samba4kgetcred --out-cache=$ocache --delegation-credential-cache=${ocache} $target || failed=$(expr $failed + 1)
+
+echo $TRUST_PASSWORD >$PREFIX/tmppassfile
+testit "kinit trust user cache" $samba4kinit -c $ocache -f --password-file=$PREFIX/tmppassfile $TRUST_USERNAME@$TRUST_REALM || failed=$(expr $failed + 1)
+testit "get a ticket to impersonator for trust user" $samba4kgetcred -c $ocache --forwardable $impersonator || failed=$(expr $failed + 1)
+testit "test S4U2Proxy evidence ticket obtained by TGS of trust user" $samba4kgetcred --out-cache=$ocache --delegation-credential-cache=${ocache} $target || failed=$(expr $failed + 1)
+
+echo $PASSWORD >$PREFIX/tmppassfile
+testit "set not-delegated on impersonator" $samba_tool user sensitive $impersonator on || failed=$(expr $failed + 1)
+testit "kinit user cache again" $samba4kinit -c $ocache -f --password-file=$PREFIX/tmppassfile $USERNAME || failed=$(expr $failed + 1)
+testit "get a ticket to sensitive impersonator" $samba4kgetcred -c $ocache --forwardable $impersonator || failed=$(expr $failed + 1)
+testit_expect_failure "test S4U2Proxy using received ticket" $samba4kgetcred --out-cache=$ocache --delegation-credential-cache=${ocache} $target || failed=$(expr $failed + 1)
+
+rm -f $ocache $PREFIX/tmpccache $PREFIX/tmppassfile
+exit $failed
diff --git a/testprogs/blackbox/test_samba-tool_ntacl.sh b/testprogs/blackbox/test_samba-tool_ntacl.sh
new file mode 100755
index 0000000..1571b1a
--- /dev/null
+++ b/testprogs/blackbox/test_samba-tool_ntacl.sh
@@ -0,0 +1,264 @@
+#!/bin/sh
+# Blackbox tests for samba-tool ntacl get/set on member server
+# Copyright (C) 2018 Björn Baumbach <bb@sernet.de>
+
+if [ $# -ne 3 ]; then
+ echo "Usage: test_samba-tool_ntacl.sh PREFIX DOMSID CONFIGURATION"
+ exit 1
+fi
+
+set -u
+set -e
+
+PREFIX=$1
+domain_sid=$2
+CONFIGURATION=$3
+
+failed=0
+
+samba4bindir="$BINDIR"
+samba_tool="$samba4bindir/samba-tool"
+
+testdirtop="$PREFIX/ntacl_testdirtop"
+testfile="$testdirtop/testfile"
+testdir1="$testdirtop/dir1"
+testdir1f="$testdirtop/dir1/file"
+testdir1l="$testdirtop/dir1/symlink"
+
+# acl from samba_tool/ntacl.py tests
+acl="O:DAG:DUD:P(A;OICI;FA;;;DA)(A;OICI;FA;;;EA)(A;OICIIO;FA;;;CO)(A;OICI;FA;;;DA)(A;OICI;FA;;;SY)(A;OICI;0x001200a9;;;AU)(A;OICI;0x001200a9;;;ED)S:AI(OU;CIIDSA;WP;f30e3bbe-9ff0-11d1-b603-0000f80367c1;bf967aa5-0de6-11d0-a285-00aa003049e2;WD)(OU;CIIDSA;WP;f30e3bbf-9ff0-11d1-b603-0000f80367c1;bf967aa5-0de6-11d0-a285-00aa003049e2;WD)"
+new_acl="O:S-1-5-21-2212615479-2695158682-2101375468-512G:S-1-5-21-2212615479-2695158682-2101375468-513D:P(A;OICI;FA;;;S-1-5-21-2212615479-2695158682-2101375468-512)(A;OICI;FA;;;S-1-5-21-2212615479-2695158682-2101375468-519)(A;OICIIO;FA;;;CO)(A;OICI;FA;;;S-1-5-21-2212615479-2695158682-2101375468-512)(A;OICI;FA;;;SY)(A;OICI;0x001200a9;;;AU)(A;OICI;0x001200a9;;;ED)S:AI(OU;CIIDSA;WP;f30e3bbe-9ff0-11d1-b603-0000f80367c1;bf967aa5-0de6-11d0-a285-00aa003049e2;WD)(OU;CIIDSA;WP;f30e3bbf-9ff0-11d1-b603-0000f80367c1;bf967aa5-0de6-11d0-a285-00aa003049e2;WD)"
+new_domain_sid="S-1-5-21-2212615479-2695158682-2101375468"
+
+acl_without_padding=$(echo -n "$acl" | perl -p -e 's/0x00/0x/g')
+new_acl_without_padding=$(echo -n "$new_acl" | perl -p -e 's/0x00/0x/g')
+
+. $(dirname $0)/subunit.sh
+
+test_get_acl()
+{
+ testfile="$1"
+ exptextedacl="$2"
+ shift 2
+
+ retacl=$($PYTHON $samba_tool ntacl get "$testfile" --as-sddl "$@") || return $?
+
+ test "$retacl" = "$exptextedacl"
+}
+
+test_set_acl()
+{
+ testfile="$1"
+ acl="$2"
+ shift 2
+
+ $PYTHON $samba_tool ntacl set "$acl" "$testfile" "$@"
+}
+
+test_get_acl_ntvfs()
+{
+ testfile="$1"
+ exptextedacl="$2"
+
+ retacl=$($PYTHON $samba_tool ntacl get "$testfile" --as-sddl --use-ntvfs --xattr-backend=tdb $CONFIGURATION) || return $?
+
+ test "$retacl" = "$exptextedacl"
+}
+
+test_set_acl_ntvfs()
+{
+ testfile="$1"
+ acl="$2"
+
+ $PYTHON $samba_tool ntacl set "$acl" "$testfile" --use-ntvfs --xattr-backend=tdb $CONFIGURATION
+}
+
+test_changedomsid()
+{
+ testfile="$1"
+ shift 1
+
+ $PYTHON $samba_tool ntacl changedomsid \
+ "$domain_sid" "$new_domain_sid" "$testfile" \
+ --service=tmp \
+ $CONFIGURATION "$@"
+}
+
+test_changedomsid_ntvfs()
+{
+ testfile="$1"
+
+ $PYTHON $samba_tool ntacl changedomsid \
+ "$domain_sid" "$new_domain_sid" "$testfile" \
+ --use-ntvfs \
+ --xattr-backend=tdb \
+ $CONFIGURATION
+
+ retacl=$($PYTHON $samba_tool ntacl get \
+ "$testfile" \
+ --as-sddl \
+ --xattr-backend=tdb \
+ --use-ntvfs \
+ $CONFIGURATION) || return $?
+ test "$retacl" = "$new_acl_without_padding"
+}
+
+# work around include error - s4-loadparm does not allow missing include files
+#
+# Unable to load file /home/bbaumba/src/git/samba/st/ad_member/lib/server.conf
+# File "bin/python/samba/netcmd/__init__.py", line 183, in _run
+# return self.run(*args, **kwargs)
+# File "bin/python/samba/netcmd/ntacl.py", line 175, in run
+# lp = sambaopts.get_loadparm()
+# File "bin/python/samba/getopt.py", line 92, in get_loadparm
+# self._lp.load(os.getenv("SMB_CONF_PATH"))
+# Processing section "[global]"
+touch "$(dirname $SMB_CONF_PATH)/error_inject.conf"
+touch "$(dirname $SMB_CONF_PATH)/delay_inject.conf"
+
+mkdir "$testdirtop"
+touch "$testfile"
+mkdir "$testdir1"
+touch "$testdir1f"
+ln -s "$testfile" "$testdir1l"
+
+testit "set_ntacl" test_set_acl "$testfile" "$acl" || failed=$(expr $failed + 1)
+
+testit "get_ntacl" test_get_acl "$testfile" "$acl_without_padding" || failed=$(expr $failed + 1)
+
+testit "changedomsid" test_changedomsid "$testfile" || failed=$(expr $failed + 1)
+testit "get_ntacl_after_changedomsid" \
+ test_get_acl "$testfile" "$new_acl_without_padding" \
+ --service=tmp \
+ $CONFIGURATION \
+ || failed=$(expr $failed + 1)
+
+testit "set_ntacl_ntvfs" test_set_acl_ntvfs "$testfile" "$acl" || failed=$(expr $failed + 1)
+testit "get_ntacl_ntvfs" test_get_acl_ntvfs "$testfile" "$acl_without_padding" || \
+ failed=$(expr $failed + 1)
+
+testit "changedomsid_ntvfs" test_changedomsid_ntvfs "$testfile" || failed=$(expr $failed + 1)
+
+testit_grep "set_ntacl_recursive1 testdirtop" \
+ "ignored symlink: $testdirtop" \
+ test_set_acl "$testdirtop" "$acl" --recursive || failed=$(expr $failed + 1)
+testit "get_ntacl_after_set_recursive1 testdirtop" \
+ test_get_acl "$testdirtop" "$acl_without_padding" \
+ --service=tmp \
+ $CONFIGURATION \
+ || failed=$(expr $failed + 1)
+testit "get_ntacl_after_set_recursive1 testfile" \
+ test_get_acl "$testfile" "$acl_without_padding" \
+ --service=tmp \
+ $CONFIGURATION \
+ || failed=$(expr $failed + 1)
+testit "get_ntacl_after_set_recursive1 testdir1" \
+ test_get_acl "$testdir1" "$acl_without_padding" \
+ --service=tmp \
+ $CONFIGURATION \
+ || failed=$(expr $failed + 1)
+testit "get_ntacl_after_set_recursive1 testdir1f" \
+ test_get_acl "$testdir1f" "$acl_without_padding" \
+ --service=tmp \
+ $CONFIGURATION \
+ || failed=$(expr $failed + 1)
+
+testit_grep "changedomsid_recursive1 testdir1" \
+ "ignored symlink: $testdir1l" \
+ test_changedomsid "$testdir1" --recursive || failed=$(expr $failed + 1)
+testit "get_ntacl_after_changedomsid_recursive1 testdirtop" \
+ test_get_acl "$testdirtop" "$acl_without_padding" \
+ --service=tmp \
+ $CONFIGURATION \
+ || failed=$(expr $failed + 1)
+testit "get_ntacl_after_changedomsid_recursive1 testfile" \
+ test_get_acl "$testfile" "$acl_without_padding" \
+ --service=tmp \
+ $CONFIGURATION \
+ || failed=$(expr $failed + 1)
+testit "get_ntacl_after_changedomsid_recursive1 testdir1" \
+ test_get_acl "$testdir1" "$new_acl_without_padding" \
+ --service=tmp \
+ $CONFIGURATION \
+ || failed=$(expr $failed + 1)
+testit "get_ntacl_after_changedomsid_recursive1 testdir1f" \
+ test_get_acl "$testdir1f" "$new_acl_without_padding" \
+ --service=tmp \
+ $CONFIGURATION \
+ || failed=$(expr $failed + 1)
+
+testit_grep "changedomsid_recursive2 testdirtop" \
+ "ignored symlink: $testdir1l" \
+ test_changedomsid "$testdirtop" --recursive || failed=$(expr $failed + 1)
+testit "get_ntacl_after_changedomsid_recursive2 testdirtop" \
+ test_get_acl "$testdirtop" "$new_acl_without_padding" \
+ --service=tmp \
+ $CONFIGURATION \
+ || failed=$(expr $failed + 1)
+testit "get_ntacl_after_changedomsid_recursive2 testfile" \
+ test_get_acl "$testfile" "$new_acl_without_padding" \
+ --service=tmp \
+ $CONFIGURATION \
+ || failed=$(expr $failed + 1)
+testit "get_ntacl_after_changedomsid_recursive2 testdir1" \
+ test_get_acl "$testdir1" "$new_acl_without_padding" \
+ --service=tmp \
+ $CONFIGURATION \
+ || failed=$(expr $failed + 1)
+testit "get_ntacl_after_changedomsid_recursive2 testdir1f" \
+ test_get_acl "$testdir1f" "$new_acl_without_padding" \
+ --service=tmp \
+ $CONFIGURATION \
+ || failed=$(expr $failed + 1)
+
+testit_grep "set_ntacl_recursive2 testdir1" \
+ "ignored symlink: $testdir1l" \
+ test_set_acl "$testdir1" "$acl" --recursive || failed=$(expr $failed + 1)
+testit "get_ntacl_after_set_recursive2 testdirtop" \
+ test_get_acl "$testdirtop" "$new_acl_without_padding" \
+ --service=tmp \
+ $CONFIGURATION \
+ || failed=$(expr $failed + 1)
+testit "get_ntacl_after_set_recursive2 testfile" \
+ test_get_acl "$testfile" "$new_acl_without_padding" \
+ --service=tmp \
+ $CONFIGURATION \
+ || failed=$(expr $failed + 1)
+testit "get_ntacl_after_set_recursive2 testdir1" \
+ test_get_acl "$testdir1" "$acl_without_padding" \
+ --service=tmp \
+ $CONFIGURATION \
+ || failed=$(expr $failed + 1)
+testit "get_ntacl_after_set_recursive2 testdir1f" \
+ test_get_acl "$testdir1f" "$acl_without_padding" \
+ --service=tmp \
+ $CONFIGURATION \
+ || failed=$(expr $failed + 1)
+
+testit_grep "set_ntacl_recursive3 testdir1" \
+ "symlink: $testdir1l" \
+ test_set_acl "$testdir1" "$acl" --recursive --follow-symlinks --verbose || failed=$(expr $failed + 1)
+testit "get_ntacl_after_set_recursive3 testdirtop" \
+ test_get_acl "$testdirtop" "$new_acl_without_padding" \
+ --service=tmp \
+ $CONFIGURATION \
+ || failed=$(expr $failed + 1)
+testit "get_ntacl_after_set_recursive3 testfile" \
+ test_get_acl "$testfile" "$acl_without_padding" \
+ --service=tmp \
+ $CONFIGURATION \
+ || failed=$(expr $failed + 1)
+testit "get_ntacl_after_set_recursive3 testdir1" \
+ test_get_acl "$testdir1" "$acl_without_padding" \
+ --service=tmp \
+ $CONFIGURATION \
+ || failed=$(expr $failed + 1)
+testit "get_ntacl_after_set_recursive3 testdir1f" \
+ test_get_acl "$testdir1f" "$acl_without_padding" \
+ --service=tmp \
+ $CONFIGURATION \
+ || failed=$(expr $failed + 1)
+
+rm -rf "$testdirtop"
+
+exit $failed
diff --git a/testprogs/blackbox/test_samba_upgradedns.sh b/testprogs/blackbox/test_samba_upgradedns.sh
new file mode 100755
index 0000000..388249d
--- /dev/null
+++ b/testprogs/blackbox/test_samba_upgradedns.sh
@@ -0,0 +1,36 @@
+#!/bin/sh
+# Blackbox tests for the samba_upgradedns
+# Copyright (C) 2006-2007 Jelmer Vernooij <jelmer@samba.org>
+# Copyright (C) 2006-2012 Andrew Bartlett <abartlet@samba.org>
+
+if [ $# -lt 4 ]; then
+ cat <<EOF
+Usage: test_samba_upgradedns.sh SERVER REALM PREFIX PROVDIR
+EOF
+ exit 1
+fi
+
+SERVER=$1
+REALM=$2
+PREFIX=$3
+PROVDIR=$4
+shift 4
+failed=0
+
+samba4bindir="$BINDIR"
+samba4srcdir="$SRCDIR/source4"
+
+. $(dirname $0)/subunit.sh
+
+testit "run samba_upgradedns converting to bind9 DLZ" $PYTHON $samba4srcdir/scripting/bin/samba_upgradedns --dns-backend=BIND9_DLZ --configfile=$PROVDIR/etc/smb.conf || failed=$(expr $failed + 1)
+testit "check that dns.keytab is present" test -f $PROVDIR/bind-dns/dns.keytab
+
+testit "run samba_upgradedns converting to internal" $PYTHON $samba4srcdir/scripting/bin/samba_upgradedns --dns-backend=SAMBA_INTERNAL --configfile=$PROVDIR/etc/smb.conf || failed=$(expr $failed + 1)
+
+testit "run samba_upgradedns converting to internal (2nd time)" $PYTHON $samba4srcdir/scripting/bin/samba_upgradedns --dns-backend=SAMBA_INTERNAL --configfile=$PROVDIR/etc/smb.conf || failed=$(expr $failed + 1)
+
+testit "run samba_upgradedns converting to bind9 DLZ (2nd time)" $PYTHON $samba4srcdir/scripting/bin/samba_upgradedns --dns-backend=BIND9_DLZ --configfile=$PROVDIR/etc/smb.conf || failed=$(expr $failed + 1)
+
+testit "run samba_upgradedns converting to bind9 DLZ (3rd time)" $PYTHON $samba4srcdir/scripting/bin/samba_upgradedns --dns-backend=BIND9_DLZ --configfile=$PROVDIR/etc/smb.conf || failed=$(expr $failed + 1)
+
+exit $failed
diff --git a/testprogs/blackbox/test_smbtorture_test_names.sh b/testprogs/blackbox/test_smbtorture_test_names.sh
new file mode 100755
index 0000000..19c747d
--- /dev/null
+++ b/testprogs/blackbox/test_smbtorture_test_names.sh
@@ -0,0 +1,43 @@
+#!/bin/sh
+
+#Tests if the --fullname parameter passed to smbtorture is working as expected.
+
+if [ $# -ne 1 ]; then
+ cat <<EOF
+Usage: test_smbtorture_test_names.sh SMBTORTURE
+EOF
+ exit 1
+fi
+
+SMBTORTURE="$1 //a/b"
+
+. $(dirname $0)/subunit.sh
+
+failed=0
+
+testit_grep "with_shortname local.smbtorture.level1.level2.level3.always_pass" \
+ '^success: always_pass$' \
+ $SMBTORTURE local.smbtorture.level1.level2.level3.always_pass || failed=$(expr $failed + 1)
+testit_grep "with_shortname local.smbtorture.level1.level2.level3" \
+ '^success: always_pass$' \
+ $SMBTORTURE local.smbtorture.level1.level2.level3 || failed=$(expr $failed + 1)
+testit_grep "with_shortname local.smbtorture.level1.level2" \
+ '^success: level3.always_pass$' \
+ $SMBTORTURE local.smbtorture.level1.level2 || failed=$(expr $failed + 1)
+testit_grep "with_shortname local.smbtorture.level1" \
+ '^success: level2.level3.always_pass$' \
+ $SMBTORTURE local.smbtorture.level1 || failed=$(expr $failed + 1)
+testit_grep "with_fullname local.smbtorture.level1.level2.level3.always_pass" \
+ '^success: local.smbtorture.level1.level2.level3.always_pass$' \
+ $SMBTORTURE --fullname local.smbtorture.level1.level2.level3.always_pass || failed=$(expr $failed + 1)
+testit_grep "with_fullname local.smbtorture.level1.level2.level3" \
+ '^success: local.smbtorture.level1.level2.level3.always_pass$' \
+ $SMBTORTURE --fullname local.smbtorture.level1.level2.level3 || failed=$(expr $failed + 1)
+testit_grep "with_fullname local.smbtorture.level1.level2" \
+ '^success: local.smbtorture.level1.level2.level3.always_pass$' \
+ $SMBTORTURE --fullname local.smbtorture.level1.level2 || failed=$(expr $failed + 1)
+testit_grep "with_fullname local.smbtorture.level1" \
+ '^success: local.smbtorture.level1.level2.level3.always_pass$' \
+ $SMBTORTURE --fullname local.smbtorture.level1 || failed=$(expr $failed + 1)
+
+testok $0 $failed
diff --git a/testprogs/blackbox/test_special_group.sh b/testprogs/blackbox/test_special_group.sh
new file mode 100755
index 0000000..f0e8698
--- /dev/null
+++ b/testprogs/blackbox/test_special_group.sh
@@ -0,0 +1,58 @@
+#!/bin/sh
+
+if [ $# -lt 1 ]; then
+ cat <<EOF
+Usage: $0 PREFIX
+EOF
+ exit 1
+fi
+
+PREFIX_ABS="$1"
+shift 1
+
+failed=0
+
+. $(dirname $0)/subunit.sh
+. $(dirname $0)/common_test_fns.inc
+
+OLD_RELEASE="release-4-5-0-pre1"
+old_release_dir="$SRCDIR_ABS/source4/selftest/provisions/$OLD_RELEASE"
+
+samba_tdbrestore=$(system_or_builddir_binary tdbrestore "${BINDIR}")
+
+samba_undump="$SRCDIR_ABS/source4/selftest/provisions/undump.sh"
+if [ ! -x "${samba_undump}" ]; then
+ subunit_start_test "special group"
+ subunit_skip_test "special group" <<EOF
+Skipping tests - undump.sh is not available in release tarballs
+EOF
+ exit 0
+fi
+
+cleanup_output_directories()
+{
+ remove_directory $PREFIX_ABS/$OLD_RELEASE
+}
+
+undump_old()
+{
+ $samba_undump $old_release_dir $PREFIX_ABS/$OLD_RELEASE $samba_tdbrestore
+}
+
+add_special_group()
+{
+ $PYTHON $BINDIR/samba-tool group add 'protected users' --special -H tdb://$PREFIX_ABS/$OLD_RELEASE/private/sam.ldb
+}
+
+# double-check we cleaned up from the last test run
+cleanup_output_directories
+
+testit $OLD_RELEASE undump_old || failed=$(expr $failed + 1)
+
+testit "add_special_group" add_special_group || failed=$(expr $failed + 1)
+
+testit_expect_failure_grep "add_duplicate_special_group" "Failed to add group.*already exists" add_special_group || failed=$(expr $failed + 1)
+
+cleanup_output_directories
+
+testok $0 $failed
diff --git a/testprogs/blackbox/test_trust_ntlm.sh b/testprogs/blackbox/test_trust_ntlm.sh
new file mode 100755
index 0000000..0220c82
--- /dev/null
+++ b/testprogs/blackbox/test_trust_ntlm.sh
@@ -0,0 +1,205 @@
+#!/bin/sh
+# Copyright (C) 2017 Stefan Metzmacher <metze@samba.org>
+
+if [ $# -lt 12 ]; then
+ cat <<EOF
+Usage: $# test_trust_ntlm.sh SERVER USERNAME PASSWORD REALM DOMAIN TRUST_USERNAME TRUST_PASSWORD TRUST_REALM TRUST_DOMAIN TYPE UNTRUSTED TRUST_ERROR
+EOF
+ exit 1
+fi
+
+SERVER=$1
+USERNAME=$2
+PASSWORD=$3
+REALM=$4
+DOMAIN=$5
+shift 5
+TRUST_USERNAME=$1
+TRUST_PASSWORD=$2
+TRUST_REALM=$3
+TRUST_DOMAIN=$4
+shift 4
+TYPE=$1
+UNTRUSTED=$2
+TRUST_ERROR=$3
+shift 3
+failed=0
+
+samba4bindir="$BINDIR"
+
+rpcclient="$samba4bindir/rpcclient"
+smbclient="$samba4bindir/smbclient"
+wbinfo="$samba4bindir/wbinfo"
+
+unc="//$SERVER/tmp"
+
+. $(dirname $0)/subunit.sh
+. $(dirname $0)/common_test_fns.inc
+
+DNAME="$DOMAIN"
+NAME="$DNAME\\$USERNAME"
+WBNAME="$DNAME/$USERNAME"
+CREDS="$NAME%$PASSWORD"
+WBCREDS="$WBNAME%$PASSWORD"
+EXPCREDS="Account Name: $USERNAME, Authority Name: $DOMAIN"
+EXPSID="(User: 1)"
+EXPDSID="(Domain: 3)"
+test_rpcclient_grep "Test01 rpcclient getusername with $CREDS" getusername "$SERVER" "$EXPCREDS" -U$CREDS || failed=$(expr $failed + 1)
+test_smbclient "Test01 smbclient with $CREDS" 'ls' "$unc" -U$CREDS || failed=$(expr $failed + 1)
+testit "Test01 wbinfo -a with $WBCREDS" $VALGRIND $wbinfo -a $WBCREDS || failed=$(expr $failed + 1)
+test_rpcclient_grep "Test01 rpcclient lookupnames with $NAME" "lookupnames_level 1 '$NAME'" "$SERVER" "$EXPSID" -U$CREDS || failed=$(expr $failed + 1)
+testit "Test01 wbinfo -n with $WBNAME" $VALGRIND $wbinfo -n "$WBNAME" || failed=$(expr $failed + 1)
+test_rpcclient_grep "Test01 rpcclient lookupnames with $DNAME" "lookupnames_level 1 '$DNAME'" "$SERVER" "$EXPDSID" -U$CREDS || failed=$(expr $failed + 1)
+
+DNAME="$REALM"
+NAME="$DNAME\\$USERNAME"
+WBNAME="$DNAME/$USERNAME"
+CREDS="$NAME%$PASSWORD"
+WBCREDS="$WBNAME%$PASSWORD"
+EXPCREDS="Account Name: $USERNAME, Authority Name: $DOMAIN"
+EXPSID="(User: 1)"
+EXPDSID="(Domain: 3)"
+test_rpcclient_grep "Test02 rpcclient getusername with $CREDS" getusername "$SERVER" "$EXPCREDS" -U$CREDS || failed=$(expr $failed + 1)
+test_smbclient "Test02 smbclient with $CREDS" 'ls' "$unc" -U$CREDS || failed=$(expr $failed + 1)
+testit "Test02 wbinfo -a with $WBCREDS" $VALGRIND $wbinfo -a $WBCREDS || failed=$(expr $failed + 1)
+test_rpcclient_grep "Test02 rpcclient lookupnames with $NAME" "lookupnames_level 1 '$NAME'" "$SERVER" "$EXPSID" -U$CREDS || failed=$(expr $failed + 1)
+testit "Test02 wbinfo -n with $WBNAME" $VALGRIND $wbinfo -n "$WBNAME" || failed=$(expr $failed + 1)
+test_rpcclient_grep "Test02 rpcclient lookupnames with $DNAME" "lookupnames_level 1 '$DNAME'" "$SERVER" "$EXPDSID" -U$CREDS || failed=$(expr $failed + 1)
+
+CREDS="$USERNAME@$DOMAIN%$PASSWORD"
+WBCREDS="$USERNAME@$DOMAIN%$PASSWORD"
+if [ x"$TYPE" = x"member" ]; then
+ EXPFAIL="NT_STATUS_LOGON_FAILURE"
+ # rpcclient doesn't handle -Uuser@domain yet
+ #test_rpcclient_expect_failure_grep "Fail03 rpcclient getusername with $CREDS" getusername "$SERVER" "$EXPFAIL" -U$CREDS || failed=`expr $failed + 1`
+ test_smbclient_expect_failure "Fail03 smbclient with $CREDS" 'ls' "$unc" -U$CREDS || failed=$(expr $failed + 1)
+ # winbindd doesn't handle user@domain yet
+ #testit_expect_failure "Fail03 wbinfo -a with $WBCREDS" $VALGRIND $wbinfo -a $WBCREDS || failed=`expr $failed + 1`
+else
+ EXPCREDS="Account Name: $USERNAME, Authority Name: $DOMAIN"
+ # rpcclient doesn't handle -Uuser@domain yet
+ #test_rpcclient_grep "Test03 rpcclient getusername with $CREDS" getusername "$SERVER" "$EXPCREDS" -U$CREDS || failed=`expr $failed + 1`
+ test_smbclient "Test03 smbclient with $CREDS" 'ls' "$unc" -U$CREDS || failed=$(expr $failed + 1)
+ # winbindd doesn't handle user@domain yet
+ #testit "Test03 wbinfo -a with $WBCREDS" $VALGRIND $wbinfo -a $WBCREDS || failed=`expr $failed + 1`
+fi
+
+CREDS="$USERNAME@$REALM%$PASSWORD"
+WBCREDS="$USERNAME@$REALM%$PASSWORD"
+if [ x"$TYPE" = x"member" ]; then
+ EXPFAIL="NT_STATUS_LOGON_FAILURE"
+ # rpcclient doesn't handle -Uuser@domain yet
+ #test_rpcclient_expect_failure_grep "Fail04 rpcclient getusername with $CREDS" getusername "$SERVER" "$EXPFAIL" -U$CREDS || failed=`expr $failed + 1`
+ test_smbclient_expect_failure "Fail04 smbclient with $CREDS" 'ls' "$unc" -U$CREDS || failed=$(expr $failed + 1)
+ # winbindd doesn't handle user@domain yet
+ #testit_expect_failure "Fail04 wbinfo -a with $WBCREDS" $VALGRIND $wbinfo -a $WBCREDS || failed=`expr $failed + 1`
+else
+ EXPCREDS="Account Name: $USERNAME, Authority Name: $DOMAIN"
+ # rpcclient doesn't handle -Uuser@domain yet
+ #test_rpcclient_grep "Test04 rpcclient getusername with $CREDS" getusername "$SERVER" "$EXPCREDS" -U$CREDS || failed=`expr $failed + 1`
+ test_smbclient "Test04 smbclient with $CREDS" 'ls' "$unc" -U$CREDS || failed=$(expr $failed + 1)
+ # winbindd doesn't handle user@domain yet
+ #testit "Test04 wbinfo -a with $WBCREDS" $VALGRIND $wbinfo -a $WBCREDS || failed=`expr $failed + 1`
+fi
+
+DNAME="UNKNOWNDOMAIN"
+NAME="$DNAME\\$USERNAME"
+WBNAME="$DNAME/$USERNAME"
+CREDS="$NAME%$PASSWORD"
+WBCREDS="$WBNAME%$PASSWORD"
+EXPCREDS="Account Name: $USERNAME, Authority Name: $DOMAIN"
+EXPSID="NT_STATUS_NONE_MAPPED"
+EXPDSID="NT_STATUS_NONE_MAPPED"
+test_rpcclient_grep "Test05 rpcclient getusername with $CREDS" getusername "$SERVER" "$EXPCREDS" -U$CREDS || failed=$(expr $failed + 1)
+test_smbclient "Test05 smbclient with $CREDS" 'ls' "$unc" -U$CREDS || failed=$(expr $failed + 1)
+testit_expect_failure "Fail05 wbinfo -a with $WBCREDS" $VALGRIND $wbinfo -a $WBCREDS || failed=$(expr $failed + 1)
+test_rpcclient_expect_failure_grep "Test05 rpcclient lookupnames with $NAME" "lookupnames_level 1 '$NAME'" "$SERVER" "$EXPSID" -U$CREDS || failed=$(expr $failed + 1)
+testit_expect_failure "Test05 wbinfo -n with $WBNAME" $VALGRIND $wbinfo -n "$WBNAME" || failed=$(expr $failed + 1)
+test_rpcclient_expect_failure_grep "Test05 rpcclient lookupnames with $DNAME" "lookupnames_level 1 '$DNAME'" "$SERVER" "$EXPDSID" -U$CREDS || failed=$(expr $failed + 1)
+
+CREDS="$TRUST_DOMAIN\\$USERNAME%$PASSWORD"
+WBCREDS="$TRUST_DOMAIN/$USERNAME%$PASSWORD"
+EXPFAIL="$TRUST_ERROR"
+test_rpcclient_expect_failure_grep "Fail06 rpcclient getusername with $CREDS" getusername "$SERVER" "$EXPFAIL" -U$CREDS || failed=$(expr $failed + 1)
+test_smbclient_expect_failure "Fail06 smbclient with $CREDS" 'ls' "$unc" -U$CREDS || failed=$(expr $failed + 1)
+testit_expect_failure "Fail06 wbinfo -a with $WBCREDS" $VALGRIND $wbinfo -a $WBCREDS || failed=$(expr $failed + 1)
+
+DNAME="$TRUST_DOMAIN"
+NAME="$DNAME\\$TRUST_USERNAME"
+WBNAME="$DNAME/$TRUST_USERNAME"
+CREDS="$NAME%$TRUST_PASSWORD"
+WBCREDS="$WBNAME%$TRUST_PASSWORD"
+EXPCREDS="Account Name: $TRUST_USERNAME, Authority Name: $TRUST_DOMAIN"
+EXPSID="(User: 1)"
+EXPDSID="(Domain: 3)"
+test_rpcclient_grep "Test07 rpcclient getusername with $CREDS" getusername "$SERVER" "$EXPCREDS" -U$CREDS || failed=$(expr $failed + 1)
+test_smbclient "Test07 smbclient with $CREDS" 'ls' "$unc" -U$CREDS || failed=$(expr $failed + 1)
+testit "Test07 wbinfo -a with $WBCREDS" $VALGRIND $wbinfo -a $WBCREDS || failed=$(expr $failed + 1)
+test_rpcclient_grep "Test07 rpcclient lookupnames with $NAME" "lookupnames_level 1 '$NAME'" "$SERVER" "$EXPSID" -U$CREDS || failed=$(expr $failed + 1)
+testit "Test07 wbinfo -n with $WBNAME" $VALGRIND $wbinfo -n "$WBNAME" || failed=$(expr $failed + 1)
+test_rpcclient_grep "Test07 rpcclient lookupnames with $DNAME" "lookupnames_level 1 '$DNAME'" "$SERVER" "$EXPDSID" -U$CREDS || failed=$(expr $failed + 1)
+
+DNAME="$TRUST_REALM"
+NAME="$DNAME\\$TRUST_USERNAME"
+WBNAME="$DNAME/$TRUST_USERNAME"
+CREDS="$NAME%$TRUST_PASSWORD"
+WBCREDS="$WBNAME%$TRUST_PASSWORD"
+EXPCREDS="Account Name: $TRUST_USERNAME, Authority Name: $TRUST_DOMAIN"
+EXPSID="(User: 1)"
+EXPDSID="(Domain: 3)"
+test_rpcclient_grep "Test08 rpcclient getusername with $CREDS" getusername "$SERVER" "$EXPCREDS" -U$CREDS || failed=$(expr $failed + 1)
+test_smbclient "Test08 smbclient with $CREDS" 'ls' "$unc" -U$CREDS || failed=$(expr $failed + 1)
+testit "Test08 wbinfo -a with $WBCREDS" $VALGRIND $wbinfo -a $WBCREDS || failed=$(expr $failed + 1)
+test_rpcclient_grep "Test08 rpcclient lookupnames with $NAME" "lookupnames_level 1 '$NAME'" "$SERVER" "$EXPSID" -U$CREDS || failed=$(expr $failed + 1)
+testit "Test08 wbinfo -n with $WBNAME" $VALGRIND $wbinfo -n "$WBNAME" || failed=$(expr $failed + 1)
+test_rpcclient_grep "Test08 rpcclient lookupnames with $DNAME" "lookupnames_level 1 '$DNAME'" "$SERVER" "$EXPDSID" -U$CREDS || failed=$(expr $failed + 1)
+
+CREDS="$TRUST_USERNAME@$TRUST_DOMAIN%$TRUST_PASSWORD"
+WBCREDS="$TRUST_USERNAME@$TRUST_DOMAIN%$TRUST_PASSWORD"
+if [ x"$TRUST_REALM" = x"$TRUST_DOMAIN" ]; then
+ # NT4 domain
+ EXPFAIL="NT_STATUS_LOGON_FAILURE"
+ # rpcclient doesn't handle -Uuser@domain yet
+ #test_rpcclient_expect_failure_grep "Fail09 rpcclient getusername with $CREDS" getusername "$SERVER" "$EXPFAIL" -U$CREDS || failed=`expr $failed + 1`
+ test_smbclient_expect_failure "Fail09 smbclient with $CREDS" 'ls' "$unc" -U$CREDS || failed=$(expr $failed + 1)
+ # winbindd doesn't handle user@domain yet
+ #testit_expect_failure "Fail09 wbinfo -a with $WBCREDS" $VALGRIND $wbinfo -a $WBCREDS || failed=`expr $failed + 1`
+else
+ EXPCREDS="Account Name: $TRUST_USERNAME, Authority Name: $TRUST_DOMAIN"
+ # rpcclient doesn't handle -Uuser@domain yet
+ #test_rpcclient_grep "Test09 rpcclient getusername with $CREDS" getusername "$SERVER" "$EXPCREDS" -U$CREDS || failed=`expr $failed + 1`
+ test_smbclient "Test09 smbclient with $CREDS" 'ls' "$unc" -U$CREDS || failed=$(expr $failed + 1)
+ # winbindd doesn't handle user@domain yet
+ #testit "Test09 wbinfo -a with $WBCREDS" $VALGRIND $wbinfo -a $WBCREDS || failed=`expr $failed + 1`
+fi
+
+CREDS="$TRUST_USERNAME@$TRUST_REALM%$TRUST_PASSWORD"
+WBCREDS="$TRUST_USERNAME@$TRUST_REALM%$TRUST_PASSWORD"
+if [ x"$TRUST_REALM" = x"$TRUST_DOMAIN" ]; then
+ # NT4 domain
+ EXPFAIL="NT_STATUS_LOGON_FAILURE"
+ # rpcclient doesn't handle -Uuser@domain yet
+ #test_rpcclient_expect_failure_grep "Fail10 rpcclient getusername with $CREDS" getusername "$SERVER" "$EXPFAIL" -U$CREDS || failed=`expr $failed + 1`
+ test_smbclient_expect_failure "Fail10 smbclient with $CREDS" 'ls' "$unc" -U$CREDS || failed=$(expr $failed + 1)
+ # winbindd doesn't handle user@domain yet
+ #testit_expect_failure "Fail10 wbinfo -a with $WBCREDS" $VALGRIND $wbinfo -a $WBCREDS || failed=`expr $failed + 1`
+else
+ EXPCREDS="Account Name: $TRUST_USERNAME, Authority Name: $TRUST_DOMAIN"
+ # rpcclient doesn't handle -Uuser@domain yet, maybe smbclient for now?
+ #test_rpcclient_grep "Test10 rpcclient getusername with $CREDS" getusername "$SERVER" "$EXPCREDS" -U$CREDS || failed=`expr $failed + 1`
+ test_smbclient "Test10 smbclient with $CREDS" 'ls' "$unc" -U$CREDS || failed=$(expr $failed + 1)
+ # winbindd doesn't handle user@domain yet
+ #testit "Test10 wbinfo -a with $WBCREDS" $VALGRIND $wbinfo -a $WBCREDS || failed=`expr $failed + 1`
+fi
+
+lowerrealm=$(echo $TRUST_REALM | tr '[A-Z]' '[a-z]')
+
+#if test x$TYPE = x"forest"; then
+#
+#fi
+#
+#if test x$UNTRUSTED = x"yes"; then
+#
+#fi
+
+exit $failed
diff --git a/testprogs/blackbox/test_trust_token.sh b/testprogs/blackbox/test_trust_token.sh
new file mode 100755
index 0000000..075c032
--- /dev/null
+++ b/testprogs/blackbox/test_trust_token.sh
@@ -0,0 +1,91 @@
+#!/bin/bash
+# Copyright (C) 2017 Stefan Metzmacher <metze@samba.org>
+
+if [ $# -lt 12 ]; then
+ cat <<EOF
+Usage: $# test_trust_token.sh SERVER USERNAME PASSWORD REALM DOMAIN DOMSID TRUST_USERNAME TRUST_PASSWORD TRUST_REALM TRUST_DOMAIN TRUST_DOMSID TYPE
+EOF
+ exit 1
+fi
+
+SERVER=$1
+shift 1
+USERNAME=$1
+PASSWORD=$2
+REALM=$3
+DOMAIN=$4
+DOMSID=$5
+shift 5
+TRUST_USERNAME=$1
+TRUST_PASSWORD=$2
+TRUST_REALM=$3
+TRUST_DOMAIN=$4
+TRUST_DOMSID=$5
+shift 5
+TYPE=$1
+shift 1
+failed=0
+
+. $(dirname $0)/subunit.sh
+. $(dirname $0)/common_test_fns.inc
+
+ldbsearch=$(system_or_builddir_binary ldbsearch "${BINDIR}")
+
+test_token()
+{
+ auth_args="${1}"
+ auth_sid="${2-}"
+
+ out=$($VALGRIND $ldbsearch -H ldap://$SERVER.$REALM -U$TRUST_REALM\\$TRUST_USERNAME%$TRUST_PASSWORD -b '' --scope=base -k ${auth_args} tokenGroups 2>&1)
+ ret=$?
+ test x"$ret" = x"0" || {
+ echo "$out"
+ return 1
+ }
+
+ trust_sids=$(echo "$out" | grep '^tokenGroups' | grep "${TRUST_DOMSID}-" | wc -l)
+ test "$trust_sids" -ge "2" || {
+ echo "$out"
+ echo "Less than 2 sids from $TRUST_DOMAIN $TRUST_DOMSID"
+ return 1
+ }
+
+ domain_sids=$(echo "$out" | grep '^tokenGroups' | grep "${DOMSID}-" | wc -l)
+ test "$domain_sids" -ge "1" || {
+ echo "$out"
+ echo "Less than 1 sid from $DOMAIN $DOMSID"
+ return 1
+ }
+
+ builtin_sids=$(echo "$out" | grep '^tokenGroups' | grep "S-1-5-32-" | wc -l)
+ test "$builtin_sids" -ge "1" || {
+ echo "$out"
+ echo "Less than 1 sid from BUILTIN S-1-5-32"
+ return 1
+ }
+
+ #
+ # The following should always be present
+ #
+ # SID_WORLD(S-1-1-0)
+ # SID_NT_NETWORK(S-1-5-2)
+ # SID_NT_AUTHENTICATED_USERS(S-1-5-11)
+ #
+ required_sids="S-1-1-0 S-1-5-2 S-1-5-11 ${auth_sid}"
+ for sid in $required_sids; do
+ found=$(echo "$out" | grep "^tokenGroups: ${sid}$" | wc -l)
+ test x"$found" = x"1" || {
+ echo "$out"
+ echo "SID: ${sid} not found"
+ return 1
+ }
+ done
+
+ return 0
+}
+
+testit "Test token with kerberos" test_token "yes" "" || failed=$(expr $failed + 1)
+# Check that SID_NT_NTLM_AUTHENTICATION(S-1-5-64-10) is added for NTLMSSP
+testit "Test token with NTLMSSP" test_token "no" "S-1-5-64-10" || failed=$(expr $failed + 1)
+
+exit $failed
diff --git a/testprogs/blackbox/test_trust_user_account.sh b/testprogs/blackbox/test_trust_user_account.sh
new file mode 100755
index 0000000..94a3aa3
--- /dev/null
+++ b/testprogs/blackbox/test_trust_user_account.sh
@@ -0,0 +1,58 @@
+#!/bin/sh
+
+if [ $# -lt 1 ]; then
+ cat <<EOF
+Usage: test_trust_user_account.sh PREFIX OUR_REALM OUR_FLAT REMOTE_REALM REMOTE_FLAT
+EOF
+ exit 1
+fi
+
+PREFIX="$1"
+OUR_REALM="$2"
+OUR_FLAT="$3"
+REMOTE_REALM="$4"
+REMOTE_FLAT="$5"
+shift 5
+
+. $(dirname $0)/subunit.sh
+
+samba_tool="$BINDIR/samba-tool"
+samba4bindir="$BINDIR"
+samba4srcdir="$SRCDIR/source4"
+samba4kinit_binary="kinit -k"
+if test -x $BINDIR/samba4kinit; then
+ samba4kinit_binary="$BINDIR/samba4kinit --use-keytab"
+fi
+
+KEYTAB="$PREFIX/tmptda.keytab"
+
+KRB5_TRACE=/dev/stderr
+export KRB5_TRACE
+
+testit "retrieve keytab for TDA of $REMOTE_REALM" $PYTHON $samba_tool domain exportkeytab $KEYTAB $CONFIGURATION --principal "$REMOTE_FLAT\$@$OUR_REALM" || failed=$(expr $failed + 1)
+
+KRB5CCNAME="$PREFIX/tmptda.ccache"
+samba4kinit="$samba4kinit_binary -c $KRB5CCNAME"
+export KRB5CCNAME
+
+rm -f $KRB5CCNAME
+
+EXPECTED_SALT="${OUR_REALM}krbtgt${REMOTE_FLAT}"
+#
+# Note the \$ is for the end of line in grep
+#
+# There must be no trailing '$' in the SALT string itself,
+# it's removed from the sAMAccountName value (which includes the trailing '$')
+# before construting the salt!
+#
+# Otherwise this would be:
+# "^virtualKerberosSalt: ${EXPECTED_SALT}\\\$\$"
+#
+EXPECTED_GREP="^virtualKerberosSalt: ${EXPECTED_SALT}\$"
+testit_grep "get virtualKerberosSalt for TDA of $REMOTE_FLAT\$" "$EXPECTED_GREP" $PYTHON $samba_tool user getpassword "$REMOTE_FLAT\$" $CONFIGURATION --attributes=virtualKerberosSalt || failed=$(expr $failed + 1)
+
+testit "kinit with keytab for TDA of $REMOTE_REALM" $samba4kinit -t $KEYTAB "$REMOTE_FLAT\$@$OUR_REALM" || failed=$(expr $failed + 1)
+
+rm -f $KRB5CCNAME $KEYTAB
+
+exit $failed
diff --git a/testprogs/blackbox/test_trust_utils.sh b/testprogs/blackbox/test_trust_utils.sh
new file mode 100755
index 0000000..3bd375a
--- /dev/null
+++ b/testprogs/blackbox/test_trust_utils.sh
@@ -0,0 +1,144 @@
+#!/bin/sh
+# Copyright (C) 2015 Stefan Metzmacher <metze@samba.org>
+
+if [ $# -lt 12 ]; then
+ cat <<EOF
+Usage: $# test_trust_utils.sh SERVER USERNAME PASSWORD REALM DOMAIN TRUST_USERNAME TRUST_PASSWORD TRUST_REALM TRUST_DOMAIN PREFIX TYPE
+EOF
+ exit 1
+fi
+
+SERVER=$1
+USERNAME=$2
+PASSWORD=$3
+REALM=$4
+DOMAIN=$5
+shift 5
+TRUST_SERVER=$1
+TRUST_USERNAME=$2
+TRUST_PASSWORD=$3
+TRUST_REALM=$4
+TRUST_DOMAIN=$5
+shift 5
+PREFIX=$1
+TYPE=$2
+shift 2
+failed=0
+
+samba4bindir="$BINDIR"
+
+samba_tool="$samba4bindir/samba-tool"
+
+. $(dirname $0)/subunit.sh
+
+CREDS="${DOMAIN}\\${USERNAME}%${PASSWORD}"
+TRUST_CREDS_DOMAIN="${TRUST_DOMAIN}\\${TRUST_USERNAME}%${TRUST_PASSWORD}"
+TRUST_SERVER_CREDS_DOMAIN_ARGS="--local-dc-ipaddress ${TRUST_SERVER} --local-dc-username ${TRUST_CREDS_DOMAIN}"
+
+TRUST_CREDS_REALM="${TRUST_REALM}\\${TRUST_USERNAME}%${TRUST_PASSWORD}"
+TRUST_SERVER_CREDS_REALM_ARGS="--local-dc-ipaddress ${TRUST_SERVER} --local-dc-username ${TRUST_CREDS_REALM}"
+
+list="$VALGRIND $PYTHON $samba_tool domain trust list"
+testit "list domains default" $list || failed=$(expr $failed + 1)
+
+# Show that the domain name and realm work
+testit "list domains reverse (DOMAIN)" $list ${TRUST_SERVER_CREDS_DOMAIN_ARGS} || failed=$(expr $failed + 1)
+testit "list domains reverse (REALM)" $list ${TRUST_SERVER_CREDS_REALM_ARGS} || failed=$(expr $failed + 1)
+
+show="$VALGRIND $PYTHON $samba_tool domain trust show"
+testit "show domains default realm" $show ${TRUST_REALM} || failed=$(expr $failed + 1)
+testit "show domains reverse realm" $show ${REALM} ${TRUST_SERVER_CREDS_DOMAIN_ARGS} || failed=$(expr $failed + 1)
+testit "show domains default netbios" $show ${TRUST_DOMAIN} || failed=$(expr $failed + 1)
+testit "show domains reverse netbios" $show ${DOMAIN} ${TRUST_SERVER_CREDS_DOMAIN_ARGS} || failed=$(expr $failed + 1)
+
+validate="$VALGRIND $PYTHON $samba_tool domain trust validate"
+testit "validate trust default both" $validate ${TRUST_REALM} -U${TRUST_CREDS_DOMAIN} || failed=$(expr $failed + 1)
+testit "validate trust default local" $validate ${TRUST_REALM} --validate-location=local || failed=$(expr $failed + 1)
+testit "validate trust reverse both" $validate ${REALM} ${TRUST_SERVER_CREDS_DOMAIN_ARGS} -U${CREDS} || failed=$(expr $failed + 1)
+testit "validate trust reverse local" $validate ${REALM} ${TRUST_SERVER_CREDS_DOMAIN_ARGS} --validate-location=local || failed=$(expr $failed + 1)
+
+namespaces="$VALGRIND $PYTHON $samba_tool domain trust namespaces"
+testit "namespaces own default" $namespaces || failed=$(expr $failed + 1)
+testit "namespaces own reverse" $namespaces ${TRUST_SERVER_CREDS_DOMAIN_ARGS} || failed=$(expr $failed + 1)
+
+DOMSID=$($namespaces | grep LocalDomain | sed -e 's!.*SID\[\(.*\)\].*!\1!')
+#testit_expect_failure "namespaces domsid default" echo ${DOMSID} || failed=`expr $failed + 1`
+
+TRUST_DOMSID=$($namespaces ${TRUST_SERVER_CREDS_DOMAIN_ARGS} | grep LocalDomain | sed -e 's!.*SID\[\(.*\)\].*!\1!')
+#testit_expect_failure "namespaces domsid reverse" echo ${TRUST_DOMSID} || failed=`expr $failed + 1`
+
+if test x$TYPE = x"forest"; then
+ testit "namespaces trust default realm 1" $namespaces ${TRUST_REALM} || failed=$(expr $failed + 1)
+ testit "namespaces trust reverse realm 1" $namespaces ${REALM} ${TRUST_SERVER_CREDS_DOMAIN_ARGS} || failed=$(expr $failed + 1)
+
+ testit "namespaces trust default domain 1" $namespaces ${TRUST_DOMAIN} || failed=$(expr $failed + 1)
+ testit "namespaces trust reverse domain 1" $namespaces ${DOMAIN} ${TRUST_SERVER_CREDS_DOMAIN_ARGS} || failed=$(expr $failed + 1)
+
+ testit "namespaces own default add-upn-suffix 1" $namespaces --add-upn-suffix=default.test_trust_utils.example.com || failed=$(expr $failed + 1)
+ testit "namespaces own reverse add-upn-suffix 1" $namespaces ${TRUST_SERVER_CREDS_DOMAIN_ARGS} --add-upn-suffix=reverse.test_trust_utils.example.com || failed=$(expr $failed + 1)
+
+ testit "namespaces own default add-upn-suffix 2" $namespaces --add-upn-suffix=${TRUST_REALM} || failed=$(expr $failed + 1)
+ testit "namespaces own reverse add-upn-suffix 2" $namespaces ${TRUST_SERVER_CREDS_DOMAIN_ARGS} --add-upn-suffix=${REALM} || failed=$(expr $failed + 1)
+
+ testit "namespaces own default add-spn-suffix 1" $namespaces --add-spn-suffix=spn.test_trust_utils.example.com || failed=$(expr $failed + 1)
+ testit "namespaces own reverse add-spn-suffix 1" $namespaces ${TRUST_SERVER_CREDS_DOMAIN_ARGS} --add-spn-suffix=spn.test_trust_utils.example.com || failed=$(expr $failed + 1)
+
+ testit "namespaces trust default check 1" $namespaces ${TRUST_REALM} --refresh=check || failed=$(expr $failed + 1)
+ testit "namespaces trust reverse check 1" $namespaces ${REALM} ${TRUST_SERVER_CREDS_DOMAIN_ARGS} --refresh=check || failed=$(expr $failed + 1)
+
+ testit "namespaces trust default store 1" $namespaces ${TRUST_REALM} --refresh=store || failed=$(expr $failed + 1)
+ testit "namespaces trust reverse store 1" $namespaces ${REALM} ${TRUST_SERVER_CREDS_DOMAIN_ARGS} --refresh=store || failed=$(expr $failed + 1)
+
+ testit "namespaces trust default enable-tln 1" $namespaces ${TRUST_REALM} --enable-tln=reverse.test_trust_utils.example.com || failed=$(expr $failed + 1)
+ testit "namespaces trust reverse enable-tln 1" $namespaces ${REALM} ${TRUST_SERVER_CREDS_DOMAIN_ARGS} --enable-tln=default.test_trust_utils.example.com || failed=$(expr $failed + 1)
+
+ testit "namespaces trust default enable-tln 2" $namespaces ${TRUST_REALM} --enable-tln=spn.test_trust_utils.example.com || failed=$(expr $failed + 1)
+ testit "namespaces trust reverse enable-tln 2" $namespaces ${REALM} ${TRUST_SERVER_CREDS_DOMAIN_ARGS} --enable-tln=spn.test_trust_utils.example.com || failed=$(expr $failed + 1)
+
+ testit "namespaces trust default enable-tln 3" $namespaces ${TRUST_REALM} --enable-tln=${TRUST_REALM} || failed=$(expr $failed + 1)
+ testit "namespaces trust reverse enable-tln 3" $namespaces ${REALM} ${TRUST_SERVER_CREDS_DOMAIN_ARGS} --enable-tln=${REALM} || failed=$(expr $failed + 1)
+
+ testit "namespaces trust default disable-nb 1" $namespaces ${TRUST_REALM} --disable-nb=${TRUST_DOMAIN} || failed=$(expr $failed + 1)
+ testit "namespaces trust reverse disable-nb 1" $namespaces ${REALM} ${TRUST_SERVER_CREDS_DOMAIN_ARGS} --disable-nb=${DOMAIN} || failed=$(expr $failed + 1)
+
+ testit "namespaces trust default disable-sid 1" $namespaces ${TRUST_REALM} --disable-sid=${TRUST_DOMSID} || failed=$(expr $failed + 1)
+ testit "namespaces trust reverse disable-sid 1" $namespaces ${REALM} ${TRUST_SERVER_CREDS_DOMAIN_ARGS} --disable-sid=${DOMSID} || failed=$(expr $failed + 1)
+
+ testit "namespaces trust default disable-tln 1" $namespaces ${TRUST_REALM} --disable-tln=reverse.test_trust_utils.example.com || failed=$(expr $failed + 1)
+ testit "namespaces trust reverse disable-tln 1" $namespaces ${REALM} ${TRUST_SERVER_CREDS_DOMAIN_ARGS} --disable-tln=default.test_trust_utils.example.com || failed=$(expr $failed + 1)
+
+ testit "namespaces trust default add-tln-ex 1" $namespaces ${TRUST_REALM} --add-tln-ex=exclude.${TRUST_REALM} || failed=$(expr $failed + 1)
+ testit "namespaces trust reverse add-tln-ex 1" $namespaces ${REALM} ${TRUST_SERVER_CREDS_DOMAIN_ARGS} --add-tln-ex=exclude.${REALM} || failed=$(expr $failed + 1)
+
+ testit "namespaces trust default add-tln-ex 2" $namespaces ${TRUST_REALM} --add-tln-ex=sub.exclude.${TRUST_REALM} || failed=$(expr $failed + 1)
+ testit "namespaces trust reverse add-tln-ex 2" $namespaces ${REALM} ${TRUST_SERVER_CREDS_DOMAIN_ARGS} --add-tln-ex=sub.exclude.${REALM} || failed=$(expr $failed + 1)
+
+ testit "namespaces trust default realm 2" $namespaces ${TRUST_REALM} || failed=$(expr $failed + 1)
+ testit "namespaces trust reverse realm 2" $namespaces ${REALM} ${TRUST_SERVER_CREDS_DOMAIN_ARGS} || failed=$(expr $failed + 1)
+
+ testit "namespaces trust default delete-tln-ex 1" $namespaces ${TRUST_REALM} --delete-tln-ex=exclude.${TRUST_REALM} || failed=$(expr $failed + 1)
+ testit "namespaces trust reverse delete-tln-ex 1" $namespaces ${REALM} ${TRUST_SERVER_CREDS_DOMAIN_ARGS} --delete-tln-ex=exclude.${REALM} || failed=$(expr $failed + 1)
+
+ testit "namespaces trust default delete-tln-ex 2" $namespaces ${TRUST_REALM} --delete-tln-ex=sub.exclude.${TRUST_REALM} || failed=$(expr $failed + 1)
+ testit "namespaces trust reverse delete-tln-ex 2" $namespaces ${REALM} ${TRUST_SERVER_CREDS_DOMAIN_ARGS} --delete-tln-ex=sub.exclude.${REALM} || failed=$(expr $failed + 1)
+
+ testit "namespaces own default delete-upn-suffix 1" $namespaces --delete-upn-suffix=default.test_trust_utils.example.com || failed=$(expr $failed + 1)
+ testit "namespaces own reverse delete-upn-suffix 1" $namespaces ${TRUST_SERVER_CREDS_DOMAIN_ARGS} --delete-upn-suffix=reverse.test_trust_utils.example.com || failed=$(expr $failed + 1)
+
+ testit "namespaces own default delete-upn-suffix 2" $namespaces --delete-upn-suffix=${TRUST_REALM} || failed=$(expr $failed + 1)
+ testit "namespaces own reverse delete-upn-suffix 2" $namespaces ${TRUST_SERVER_CREDS_DOMAIN_ARGS} --delete-upn-suffix=${REALM} || failed=$(expr $failed + 1)
+
+ testit "namespaces own default delete-spn-suffix 1" $namespaces --delete-spn-suffix=spn.test_trust_utils.example.com || failed=$(expr $failed + 1)
+ testit "namespaces own reverse delete-spn-suffix 1" $namespaces ${TRUST_SERVER_CREDS_DOMAIN_ARGS} --delete-spn-suffix=spn.test_trust_utils.example.com || failed=$(expr $failed + 1)
+
+ testit "namespaces trust default enable-nb 1" $namespaces ${TRUST_REALM} --enable-nb=${TRUST_DOMAIN} || failed=$(expr $failed + 1)
+ testit "namespaces trust reverse enable-nb 1" $namespaces ${REALM} ${TRUST_SERVER_CREDS_DOMAIN_ARGS} --enable-nb=${DOMAIN} || failed=$(expr $failed + 1)
+
+ testit "namespaces trust default enable-sid 1" $namespaces ${TRUST_REALM} --enable-sid=${TRUST_DOMSID} || failed=$(expr $failed + 1)
+ testit "namespaces trust reverse enable-sid 1" $namespaces ${REALM} ${TRUST_SERVER_CREDS_DOMAIN_ARGS} --enable-sid=${DOMSID} || failed=$(expr $failed + 1)
+
+ testit "namespaces trust default reset final" $namespaces ${TRUST_REALM} --refresh=store --enable-all || failed=$(expr $failed + 1)
+ testit "namespaces trust reverse reset final" $namespaces ${REALM} ${TRUST_SERVER_CREDS_DOMAIN_ARGS} --refresh=store --enable-all || failed=$(expr $failed + 1)
+fi
+
+exit $failed
diff --git a/testprogs/blackbox/test_weak_crypto.sh b/testprogs/blackbox/test_weak_crypto.sh
new file mode 100755
index 0000000..e938bb0
--- /dev/null
+++ b/testprogs/blackbox/test_weak_crypto.sh
@@ -0,0 +1,51 @@
+#!/bin/sh
+
+#
+# Blackbox tests for weak crypto
+# Copyright (c) 2020 Andreas Schneider <asn@samba.org>
+#
+
+if [ $# -lt 6 ]; then
+ cat <<EOF
+Usage: $0 SERVER USERNAME PASSWORD REALM DOMAIN PREFIX
+EOF
+ exit 1
+fi
+
+SERVER=$1
+USERNAME=$2
+PASSWORD=$3
+REALM=$4
+DOMAIN=$5
+PREFIX=$6
+shift 6
+
+failed=0
+. $(dirname $0)/subunit.sh
+
+samba_bindir="$BINDIR"
+samba_testparm="$BINDIR/testparm"
+samba_rpcclient="$samba_bindir/rpcclient"
+
+opt="--option=gensec:gse_krb5=no -U${USERNAME}%${PASSWORD}"
+
+unset GNUTLS_FORCE_FIPS_MODE
+
+# Checks that testparm reports: Weak crypto is allowed
+testit_grep "testparm" "Weak crypto is allowed" $samba_testparm --suppress-prompt $SMB_CONF_PATH 2>&1 || failed=$(expr $failed + 1)
+
+# We should be allowed to use NTLM for connecting
+testit "rpclient.ntlm" $samba_rpcclient ncacn_np:$SERVER $opt -c "getusername" || failed=$(expr $failed + 1)
+
+GNUTLS_FORCE_FIPS_MODE=1
+export GNUTLS_FORCE_FIPS_MODE
+
+# Checks that testparm reports: Weak crypto is disallowed
+testit_grep "testparm" "Weak crypto is disallowed" $samba_testparm --suppress-prompt $SMB_CONF_PATH 2>&1 || failed=$(expr $failed + 1)
+
+# We should not be allowed to use NTLM for connecting
+testit_expect_failure "rpclient.ntlm" $samba_rpcclient ncacn_np:$SERVER $opt -c "getusername" || failed=$(expr $failed + 1)
+
+unset GNUTLS_FORCE_FIPS_MODE
+
+exit $failed
diff --git a/testprogs/blackbox/test_weak_crypto_server.sh b/testprogs/blackbox/test_weak_crypto_server.sh
new file mode 100755
index 0000000..963861b
--- /dev/null
+++ b/testprogs/blackbox/test_weak_crypto_server.sh
@@ -0,0 +1,64 @@
+#!/bin/sh
+
+#
+# Blackbox tests for weak crypto
+# Copyright (c) 2020 Andreas Schneider <asn@samba.org>
+#
+
+if [ $# -lt 7 ]; then
+ cat <<EOF
+Usage: $0 SERVER USERNAME PASSWORD REALM DOMAIN PREFIX
+EOF
+ exit 1
+fi
+
+SERVER=$1
+USERNAME=$2
+PASSWORD=$3
+REALM=$4
+DOMAIN=$5
+PREFIX=$6
+CONFIGURATION=$7
+shift 7
+
+failed=0
+. $(dirname $0)/subunit.sh
+
+samba_bindir="$BINDIR"
+samba_testparm="$BINDIR/testparm"
+samba_rpcclient="$samba_bindir/rpcclient"
+
+# remove the --configfile=
+configuration="${CONFIGURATION##*=}"
+
+test_weak_crypto_allowed()
+{
+ local testparm_stderr_output_path="$PREFIX/testparm_stderr_output"
+
+ $samba_testparm --suppress-prompt $configuration 2>$testparm_stderr_output_path >/dev/null
+
+ grep "Weak crypto is allowed" $testparm_stderr_output_path >/dev/null 2>&1
+ if [ $ret -ne 0 ]; then
+ echo "Invalid crypto state:"
+ cat $testparm_stderr_output_path
+ rm -f $testparm_stderr_output_path
+ return 1
+ fi
+
+ rm -f $testparm_stderr_output_path
+
+ return 0
+}
+
+unset GNUTLS_FORCE_FIPS_MODE
+
+# Checks that testparm reports: Weak crypto is disallowed
+testit "testparm-weak-crypto" test_weak_crypto_allowed || failed=$(expr $failed + 1)
+
+# We should not be allowed to use NTLM for connecting
+testit_expect_failure "rpclient.ntlm" $samba_rpcclient ncacn_np:${SERVER_IP}[ntlm] -U$USERNAME%$PASSWORD -c "getusername" || failed=$(expr $failed + 1)
+
+GNUTLS_FORCE_FIPS_MODE=1
+export GNUTLS_FORCE_FIPS_MODE
+
+exit $failed
diff --git a/testprogs/blackbox/test_weak_disable_ntlmssp_ldap.sh b/testprogs/blackbox/test_weak_disable_ntlmssp_ldap.sh
new file mode 100755
index 0000000..d2f1c8f
--- /dev/null
+++ b/testprogs/blackbox/test_weak_disable_ntlmssp_ldap.sh
@@ -0,0 +1,41 @@
+#!/bin/sh
+# Blackbox tests for diabing NTLMSSP for ldap client connections
+# Copyright (c) 2022 Pavel Filipenský <pfilipen@redhat.com>
+
+if [ $# -lt 2 ]; then
+ cat <<EOF
+Usage: $0 USERNAME PASSWORD
+EOF
+ exit 1
+fi
+
+USERNAME=$1
+PASSWORD=$2
+shift 2
+
+failed=0
+. $(dirname $0)/subunit.sh
+
+samba_testparm="$BINDIR/testparm"
+samba_net="$BINDIR/net"
+
+unset GNUTLS_FORCE_FIPS_MODE
+
+# Checks that testparm reports: Weak crypto is allowed
+testit_grep "testparm" "Weak crypto is allowed" $samba_testparm --suppress-prompt $SMB_CONF_PATH 2>&1 || failed=$(expr $failed + 1)
+
+# We should be allowed to use NTLM for connecting
+testit "net_ads_search.ntlm" $samba_net ads search --use-kerberos=off '(objectCategory=group)' sAMAccountName -U${USERNAME}%${PASSWORD} || failed=$(expr $failed + 1)
+
+GNUTLS_FORCE_FIPS_MODE=1
+export GNUTLS_FORCE_FIPS_MODE
+
+# Checks that testparm reports: Weak crypto is disallowed
+testit_grep "testparm" "Weak crypto is disallowed" $samba_testparm --suppress-prompt $SMB_CONF_PATH 2>&1 || failed=$(expr $failed + 1)
+
+# We should not be allowed to use NTLM for connecting
+testit_expect_failure_grep "net_ads_search.ntlm" "We can't fallback to NTLMSSP, weak crypto is disallowed." $samba_net ads search --use-kerberos=off -d10 '(objectCategory=group)' sAMAccountName -U${USERNAME}%${PASSWORD} || failed=$(expr $failed + 1)
+
+unset GNUTLS_FORCE_FIPS_MODE
+
+testok $0 $failed
diff --git a/testprogs/blackbox/test_wintest.sh b/testprogs/blackbox/test_wintest.sh
new file mode 100755
index 0000000..1015a1e
--- /dev/null
+++ b/testprogs/blackbox/test_wintest.sh
@@ -0,0 +1,43 @@
+#!/bin/sh
+# Blackbox tests for testing against windows machines
+# Copyright (C) 2008 Jim McDonough
+
+testwithconf()
+{
+ # define test variables, startup/shutdown scripts
+ . $1
+ shift 1
+
+ if [ -n "$WINTEST_STARTUP" ]; then
+ . $WINTEST_STARTUP
+ fi
+
+ testit "smbtorture" $smbtorture //$SERVER/$SHARE RAW-OPEN -W "$DOMAIN" -U"$USERNAME%$PASSWORD" "$@" || failed=$(expr $failed + 1)
+
+ if [ -n "$WINTEST_SHUTDOWN" ]; then
+ . $WINTEST_SHUTDOWN
+ fi
+}
+
+# main
+# skip without WINTEST_CONF_DIR
+if [ -z "$WINTEST_CONF_DIR" ]; then
+ exit 0
+fi
+
+unset SOCKET_WRAPPER_DIR
+
+failed=0
+
+basedir=$(pwd)
+
+samba4bindir=$(dirname $0)/../../source4/bin
+smbtorture=$samba4bindir/smbtorture
+
+. $(dirname $0)/subunit.sh
+
+for wintest_conf in $WINTEST_CONF_DIR/*.conf; do
+ testwithconf "$wintest_conf" "$@"
+done
+
+exit $failed
diff --git a/testprogs/blackbox/tfork.sh b/testprogs/blackbox/tfork.sh
new file mode 100755
index 0000000..0f75a8c
--- /dev/null
+++ b/testprogs/blackbox/tfork.sh
@@ -0,0 +1,15 @@
+#!/bin/sh
+
+sleep 1
+
+echo stdout >&1
+echo $1 >&1
+echo stderror >&2
+
+# close stdout and stderror, but don't exit yet
+exec 1>&-
+exec 2>&-
+
+sleep 1
+
+exit 0
diff --git a/testprogs/blackbox/tombstones-expunge.sh b/testprogs/blackbox/tombstones-expunge.sh
new file mode 100755
index 0000000..a1a6d02
--- /dev/null
+++ b/testprogs/blackbox/tombstones-expunge.sh
@@ -0,0 +1,246 @@
+#!/bin/sh
+
+if [ $# -lt 1 ]; then
+ cat <<EOF
+Usage: tombstones-expunge.sh PREFIX RELEASE
+EOF
+ exit 1
+fi
+
+PREFIX_ABS="$1"
+RELEASE="$2"
+shift 2
+
+failed=0
+
+. $(dirname $0)/subunit.sh
+. $(dirname $0)/common_test_fns.inc
+
+release_dir="$SRCDIR_ABS/source4/selftest/provisions/$RELEASE"
+
+ldbadd=$(system_or_builddir_binary ldbadd "${BINDIR}")
+ldbmodify=$(system_or_builddir_binary ldbmodify "${BINDIR}")
+ldbsearch=$(system_or_builddir_binary ldbsearch "${BINDIR}")
+samba_tdbrestore=$(system_or_builddir_binary tdbrestore "${BINDIR}")
+
+samba_undump="$SRCDIR_ABS/source4/selftest/provisions/undump.sh"
+if [ ! -x $samba_undump ] || [ ! -d $release_dir ]; then
+ subunit_start_test $RELEASE
+ subunit_skip_test $RELEASE <<EOF
+no test provision
+EOF
+
+ subunit_start_test "tombstones_expunge"
+ subunit_skip_test "tombstones_expunge" <<EOF
+no test provision
+EOF
+
+ exit 0
+fi
+
+undump()
+{
+ $samba_undump $release_dir $PREFIX_ABS/$RELEASE $samba_tdbrestore
+}
+
+tombstones_expunge()
+{
+ tmpfile=$PREFIX_ABS/$RELEASE/expected-expunge-output.txt.tmp
+ tmpldif1=$PREFIX_ABS/$RELEASE/expected-expunge-output2.txt.tmp1
+
+ TZ=UTC $ldbsearch -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb --scope=base -b '' | grep highestCommittedUSN >$tmpldif1
+
+ $PYTHON $BINDIR/samba-tool domain tombstones expunge -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb --current-time=2016-07-30 --tombstone-lifetime=4 >$tmpfile
+ if [ "$?" != "0" ]; then
+ return 1
+ fi
+ diff -u $tmpfile $release_dir/expected-expunge-output.txt
+ if [ "$?" != "0" ]; then
+ return 1
+ fi
+
+ tmpldif2=$PREFIX_ABS/$RELEASE/expected-expunge-output2.txt.tmp2
+ TZ=UTC $ldbsearch -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb --scope=base -b '' | grep highestCommittedUSN >$tmpldif2
+
+ diff -u $tmpldif1 $tmpldif2
+ if [ "$?" != "0" ]; then
+ return 1
+ fi
+}
+
+add_dangling_link()
+{
+ ldif=$release_dir/add-dangling-link.ldif
+ TZ=UTC $ldbmodify -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb.d/DC%3DRELEASE-4-5-0-PRE1,DC%3DSAMBA,DC%3DCORP.ldb $ldif
+ if [ "$?" != "0" ]; then
+ return 1
+ fi
+}
+
+add_two_more_users()
+{
+ ldif=$release_dir/add-two-more-users.ldif
+ TZ=UTC $ldbadd -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb $ldif
+ if [ "$?" != "0" ]; then
+ return 1
+ fi
+}
+
+add_four_more_links()
+{
+ ldif=$release_dir/add-four-more-links.ldif
+ TZ=UTC $ldbmodify -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb $ldif
+ if [ "$?" != "0" ]; then
+ return 1
+ fi
+}
+
+add_unsorted_links()
+{
+ ldif=$release_dir/add-unsorted-links-step1.ldif
+ TZ=UTC $ldbmodify -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb $ldif --relax
+ if [ "$?" != "0" ]; then
+ return 1
+ fi
+ ldif=$release_dir/add-unsorted-links-step2.ldif
+ TZ=UTC $ldbmodify -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb.d/DC%3DRELEASE-4-5-0-PRE1,DC%3DSAMBA,DC%3DCORP.ldb $ldif
+ if [ "$?" != "0" ]; then
+ return 1
+ fi
+}
+
+remove_one_link()
+{
+ ldif=$release_dir/remove-one-more-link.ldif
+ TZ=UTC $ldbmodify -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb $ldif
+ if [ "$?" != "0" ]; then
+ return 1
+ fi
+}
+
+remove_one_user()
+{
+ ldif=$release_dir/remove-one-more-user.ldif
+ TZ=UTC $ldbmodify -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb $ldif
+ if [ "$?" != "0" ]; then
+ return 1
+ fi
+}
+
+check_match_rule_links()
+{
+ tmpldif=$PREFIX_ABS/$RELEASE/expected-match-rule-links.ldif.tmp
+ TZ=UTC $ldbsearch -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb '(member:1.3.6.1.4.1.7165.4.5.2:=131139216000000000)' --scope=sub -b DC=release-4-5-0-pre1,DC=samba,DC=corp --show-deleted --reveal --sorted no_attrs >$tmpldif
+ diff -u $tmpldif $release_dir/expected-match-rule-links.ldif
+ if [ "$?" != "0" ]; then
+ return 1
+ fi
+}
+
+check_match_rule_links_negative()
+{
+ $ldbsearch -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb '(member:1.3.6.1.4.1.7165.4.5.2:=-131139216000000000)' --scope=sub -b DC=release-4-5-0-pre1,DC=samba,DC=corp --show-deleted --reveal --sorted member
+}
+
+check_match_rule_links_overflow()
+{
+ $ldbsearch -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb '(member:1.3.6.1.4.1.7165.4.5.2:=18446744073709551617)' --scope=sub -b DC=release-4-5-0-pre1,DC=samba,DC=corp --show-deleted --reveal --sorted member
+}
+
+check_match_rule_links_null()
+{
+ $ldbsearch -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb '(member:1.3.6.1.4.1.7165.4.5.2:=18446744\073709551617)' --scope=sub -b DC=release-4-5-0-pre1,DC=samba,DC=corp --show-deleted --reveal --sorted member
+}
+
+check_match_rule_links_hex()
+{
+ $ldbsearch -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb '(member:1.3.6.1.4.1.7165.4.5.2:=abcd)' --scope=sub -b DC=release-4-5-0-pre1,DC=samba,DC=corp --show-deleted --reveal --sorted member
+}
+
+check_match_rule_links_hex2()
+{
+ $ldbsearch -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb '(member:1.3.6.1.4.1.7165.4.5.2:=0xabcd)' --scope=sub -b DC=release-4-5-0-pre1,DC=samba,DC=corp --show-deleted --reveal --sorted member
+}
+
+check_match_rule_links_decimal()
+{
+ $ldbsearch -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb '(member:1.3.6.1.4.1.7165.4.5.2:=131139216000000000.00)' --scope=sub -b DC=release-4-5-0-pre1,DC=samba,DC=corp --show-deleted --reveal --sorted member
+}
+
+check_match_rule_links_backlink()
+{
+ $ldbsearch -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb '(memberOf:1.3.6.1.4.1.7165.4.5.2:=131139216000000000)' --scope=sub -b DC=release-4-5-0-pre1,DC=samba,DC=corp --show-deleted --reveal --sorted memberOf
+}
+
+check_match_rule_links_notlink()
+{
+ $ldbsearch -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb '(samAccountName:1.3.6.1.4.1.7165.4.5.2:=131139216000000000)' --scope=sub -b DC=release-4-5-0-pre1,DC=samba,DC=corp --show-deleted --reveal --sorted samAccountName
+}
+
+check_expected_after_links()
+{
+ tmpldif=$PREFIX_ABS/$RELEASE/expected-links-after-expunge.ldif.tmp
+ TZ=UTC $ldbsearch -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb '(|(cn=swimmers)(cn=leaders)(cn=helpers))' --scope=sub -b DC=release-4-5-0-pre1,DC=samba,DC=corp --show-deleted --sorted member >$tmpldif
+ diff -u $tmpldif $release_dir/expected-links-after-expunge.ldif
+ if [ "$?" != "0" ]; then
+ return 1
+ fi
+}
+
+check_expected_after_deleted_links()
+{
+ tmpldif=$PREFIX_ABS/$RELEASE/expected-deleted-links-after-expunge.ldif.tmp
+ TZ=UTC $ldbsearch -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb '(|(cn=swimmers)(cn=leaders)(cn=helpers))' --scope=sub -b DC=release-4-5-0-pre1,DC=samba,DC=corp --show-deleted --reveal --sorted member >$tmpldif
+ diff -u $tmpldif $release_dir/expected-deleted-links-after-expunge.ldif
+ if [ "$?" != "0" ]; then
+ return 1
+ fi
+}
+
+check_expected_after_objects()
+{
+ tmpldif=$PREFIX_ABS/$RELEASE/expected-objects-after-expunge.ldif.tmp
+ TZ=UTC $ldbsearch -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb '(|(samaccountname=fred)(samaccountname=ddg)(samaccountname=usg)(samaccountname=user1)(samaccountname=user2))' --scope=sub -b DC=release-4-5-0-pre1,DC=samba,DC=corp --show-deleted --reveal --sorted samAccountName | grep sAMAccountName >$tmpldif
+ diff -u $tmpldif $release_dir/expected-objects-after-expunge.ldif
+ if [ "$?" != "0" ]; then
+ return 1
+ fi
+}
+
+check_expected_unsorted_links()
+{
+ tmpldif=$PREFIX_ABS/$RELEASE/expected-unsorted-links-after-expunge.ldif.tmp
+ TZ=UTC $ldbsearch -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb '(name=unsorted-g)' --scope=sub -b DC=release-4-5-0-pre1,DC=samba,DC=corp --show-deleted --reveal --sorted member >$tmpldif
+ diff -u $tmpldif $release_dir/expected-unsorted-links-after-expunge.ldif
+ if [ "$?" != "0" ]; then
+ return 1
+ fi
+}
+
+remove_directory $PREFIX_ABS/${RELEASE}
+
+testit $RELEASE undump || failed=$(expr $failed + 1)
+testit "add_two_more_users" add_two_more_users || failed=$(expr $failed + 1)
+testit "add_four_more_links" add_four_more_links || failed=$(expr $failed + 1)
+testit "add_dangling_link" add_dangling_link || failed=$(expr $failed + 1)
+testit "remove_one_link" remove_one_link || failed=$(expr $failed + 1)
+testit "remove_one_user" remove_one_user || failed=$(expr $failed + 1)
+testit "check_match_rule_links" check_match_rule_links || failed=$(expr $failed + 1)
+testit_expect_failure "check_match_rule_links_negative" check_match_rule_links_negative || failed=$(expr $failed + 1)
+testit_expect_failure "check_match_rule_links_overflow" check_match_rule_links_overflow || failed=$(expr $failed + 1)
+testit_expect_failure "check_match_rule_links_null" check_match_rule_links_null || failed=$(expr $failed + 1)
+testit_expect_failure "check_match_rule_links_hex" check_match_rule_links_hex || failed=$(expr $failed + 1)
+testit_expect_failure "check_match_rule_links_hex2" check_match_rule_links_hex2 || failed=$(expr $failed + 1)
+testit_expect_failure "check_match_rule_links_decimal" check_match_rule_links_decimal || failed=$(expr $failed + 1)
+testit_expect_failure "check_match_rule_links_backlink" check_match_rule_links_backlink || failed=$(expr $failed + 1)
+testit_expect_failure "check_match_rule_links_notlink" check_match_rule_links_notlink || failed=$(expr $failed + 1)
+testit "add_unsorted_links" add_unsorted_links || failed=$(expr $failed + 1)
+testit "tombstones_expunge" tombstones_expunge || failed=$(expr $failed + 1)
+testit "check_expected_after_deleted_links" check_expected_after_deleted_links || failed=$(expr $failed + 1)
+testit "check_expected_after_links" check_expected_after_links || failed=$(expr $failed + 1)
+testit "check_expected_after_objects" check_expected_after_objects || failed=$(expr $failed + 1)
+testit "check_expected_unsorted_links" check_expected_unsorted_links || failed=$(expr $failed + 1)
+
+remove_directory $PREFIX_ABS/${RELEASE}
+
+exit $failed
diff --git a/testprogs/blackbox/upgradeprovision-oldrelease.sh b/testprogs/blackbox/upgradeprovision-oldrelease.sh
new file mode 100755
index 0000000..e8267ea
--- /dev/null
+++ b/testprogs/blackbox/upgradeprovision-oldrelease.sh
@@ -0,0 +1,234 @@
+#!/bin/sh
+
+if [ $# -lt 1 ]; then
+ cat <<EOF
+Usage: upgradeprovision-oldrelease.sh PREFIX RELEASE
+EOF
+ exit 1
+fi
+
+PREFIX_ABS="$1"
+RELEASE="$2"
+shift 2
+
+failed=0
+
+. $(dirname $0)/subunit.sh
+. $(dirname $0)/common_test_fns.inc
+
+release_dir="$SRCDIR_ABS/source4/selftest/provisions/${RELEASE}"
+
+ldbdel=$(system_or_builddir_binary ldbdel "${BINDIR}")
+samba_tdbrestore=$(system_or_builddir_binary tdbrestore "${BINDIR}")
+
+samba_undump="$SRCDIR_ABS/source4/selftest/provisions/undump.sh"
+if [ ! -x $samba_undump ] || [ ! -d $release_dir ]; then
+ subunit_start_test "${RELEASE}"
+ subunit_skip_test "${RELEASE}" <<EOF
+no test provision
+EOF
+
+ subunit_start_test "remove_dns_user"
+ subunit_skip_test "remove_dns_user" <<EOF
+no test provision
+EOF
+
+ subunit_start_test "upgradeprovision"
+ subunit_skip_test "upgradeprovision" <<EOF
+no test provision
+EOF
+ subunit_start_test "upgradeprovision_full"
+ subunit_skip_test "upgradeprovision_full" <<EOF
+no test provision
+EOF
+ subunit_start_test "reindex"
+ subunit_skip_test "reindex" <<EOF
+no test provision
+EOF
+ subunit_start_test "dbcheck"
+ subunit_skip_test "dbcheck" <<EOF
+no test provision
+EOF
+ subunit_start_test "dbcheck_clean"
+ subunit_skip_test "dbcheck_clean" <<EOF
+no test provision
+EOF
+ # So far, only releases before 4.0.0rc6 need a dbcheck if upgradeprovision has already been run
+ if [ x$RELEASE != x"release-4-0-0" ]; then
+ subunit_start_test "dbcheck_full"
+ subunit_skip_test "dbcheck_full" <<EOF
+no test provision
+EOF
+ fi
+ subunit_start_test "dbcheck_full_clean"
+ subunit_skip_test "dbcheck_full_clean" <<EOF
+no test provision
+EOF
+ subunit_start_test "dbcheck_full_clean_well_known_acls"
+ subunit_skip_test "dbcheck_full_clean_well_known_acls" <<EOF
+no test provision
+EOF
+ subunit_start_test "samba_dnsupgrade"
+ subunit_skip_test "samba_dnsupgrade" <<EOF
+no test provision
+EOF
+ subunit_start_test "referenceprovision"
+ subunit_skip_test "referenceprovision" <<EOF
+no test provision
+EOF
+ subunit_start_test "ldapcmp"
+ subunit_skip_test "ldapcmp" <<EOF
+no test provision
+EOF
+ subunit_start_test "ldapcmp_full"
+ subunit_skip_test "ldapcmp_full" <<EOF
+no test provision
+EOF
+ subunit_start_test "ldapcmp_sd"
+ subunit_skip_test "ldapcmp_sd" <<EOF
+no test provision
+EOF
+ subunit_start_test "ldapcmp_full_sd"
+ subunit_skip_test "ldapcmp_full_sd" <<EOF
+no test provision
+EOF
+
+ exit 0
+fi
+
+undump()
+{
+ $samba_undump $release_dir $PREFIX_ABS/${RELEASE}_upgrade $samba_tdbrestore
+ $samba_undump $release_dir $PREFIX_ABS/${RELEASE}_upgrade_full $samba_tdbrestore
+
+ cp -a $release_dir/private/*.keytab $PREFIX_ABS/${RELEASE}_upgrade/private/
+ cp -a $release_dir/sysvol $PREFIX_ABS/${RELEASE}_upgrade/
+ mkdir $PREFIX_ABS/${RELEASE}_upgrade/etc/
+ sed -e "s|@@PREFIX@@|$PREFIX_ABS/${RELEASE}_upgrade|g" $release_dir/etc/smb.conf.template \
+ >$PREFIX_ABS/${RELEASE}_upgrade/etc/smb.conf
+
+ cp -a $release_dir/private/*.keytab $PREFIX_ABS/${RELEASE}_upgrade_full/private/
+ cp -a $release_dir/sysvol $PREFIX_ABS/${RELEASE}_upgrade_full/
+ mkdir $PREFIX_ABS/${RELEASE}_upgrade_full/etc/
+ sed -e "s|@@PREFIX@@|$PREFIX_ABS/${RELEASE}_upgrade_full|g" $release_dir/etc/smb.conf.template \
+ >$PREFIX_ABS/${RELEASE}_upgrade_full/etc/smb.conf
+}
+
+remove_dns_user()
+{
+ if [ x$RELEASE != x"release-4-0-0" ]; then
+ # This is done, because otherwise the upgrdeprovision will not run without --full
+ ${ldbdel} -H tdb://$PREFIX_ABS/${RELEASE}_upgrade/private/sam.ldb cn=dns,cn=users,dc=${RELEASE},dc=samba,dc=corp
+ fi
+}
+
+reindex()
+{
+ $PYTHON $BINDIR/samba-tool dbcheck --reindex -H tdb://$PREFIX_ABS/${RELEASE}_upgrade/private/sam.ldb "$@"
+}
+
+# This should 'fail', because it returns the number of modified records
+dbcheck()
+{
+ $PYTHON $BINDIR/samba-tool dbcheck --cross-ncs --fix --yes -H tdb://$PREFIX_ABS/${RELEASE}_upgrade/private/sam.ldb "$@"
+}
+
+dbcheck_clean()
+{
+ $PYTHON $BINDIR/samba-tool dbcheck --cross-ncs -H tdb://$PREFIX_ABS/${RELEASE}_upgrade/private/sam.ldb "$@"
+}
+
+# This should 'fail', because it returns the number of modified records
+dbcheck_full()
+{
+ $PYTHON $BINDIR/samba-tool dbcheck --cross-ncs --fix --yes -H tdb://$PREFIX_ABS/${RELEASE}_upgrade_full/private/sam.ldb "$@"
+}
+
+dbcheck_full_clean()
+{
+ $PYTHON $BINDIR/samba-tool dbcheck --cross-ncs -H tdb://$PREFIX_ABS/${RELEASE}_upgrade_full/private/sam.ldb "$@"
+}
+
+# This checks that after the upgrade, the well known ACLs are correct, so this reset should not want to do anything
+dbcheck_full_clean_well_known_acls()
+{
+ $PYTHON $BINDIR/samba-tool dbcheck --reset-well-known-acls --cross-ncs -H tdb://$PREFIX_ABS/${RELEASE}_upgrade_full/private/sam.ldb "$@"
+}
+
+upgradeprovision()
+{
+ # bring the really old Samba schema in line with a more recent 2008R2 schema
+ $PYTHON $BINDIR/samba_upgradeprovision --configfile="$PREFIX_ABS/${RELEASE}_upgrade/etc/smb.conf" --debugchange
+
+ # on top of this, also apply 2008R2 changes we accidentally missed in the past
+ $PYTHON $BINDIR/samba-tool domain schemaupgrade -H tdb://$PREFIX_ABS/${RELEASE}_upgrade/private/sam.ldb --ldf-file=samba-4.7-missing-for-schema45.ldif,fix-forest-rev.ldf
+
+ # add missing domain prep for 2008R2
+ $PYTHON $BINDIR/samba-tool domain functionalprep -H tdb://$PREFIX_ABS/${RELEASE}_upgrade/private/sam.ldb --domain --function-level 2008_R2
+}
+
+upgradeprovision_full()
+{
+ # add missing domain prep for 2008R2
+ $PYTHON $BINDIR/samba-tool domain functionalprep -H tdb://$PREFIX_ABS/${RELEASE}_upgrade_full/private/sam.ldb --domain --function-level 2008_R2
+
+ $PYTHON $BINDIR/samba_upgradeprovision --configfile="$PREFIX_ABS/${RELEASE}_upgrade_full/etc/smb.conf" --full --debugchange
+}
+
+samba_upgradedns()
+{
+ $PYTHON $BINDIR/samba_upgradedns --dns-backend=SAMBA_INTERNAL --configfile="$PREFIX_ABS/${RELEASE}_upgrade_full/etc/smb.conf"
+}
+
+referenceprovision()
+{
+ $PYTHON $BINDIR/samba-tool domain provision --server-role="dc" --domain=SAMBA --host-name=ares --realm=${RELEASE}.samba.corp --targetdir=$PREFIX_ABS/${RELEASE}_upgrade_reference --use-ntvfs --host-ip=127.0.0.1 --host-ip6=::1 --function-level=2003 --base-schema=2008_R2_old
+}
+
+ldapcmp()
+{
+ if [ x$RELEASE != x"alpha13" ]; then
+ $PYTHON $BINDIR/samba-tool ldapcmp tdb://$PREFIX_ABS/${RELEASE}_upgrade_reference/private/sam.ldb tdb://$PREFIX_ABS/${RELEASE}_upgrade/private/sam.ldb --two --skip-missing-dn --filter=dnsRecord,displayName,msDS-SupportedEncryptionTypes,servicePrincipalName
+ fi
+}
+
+ldapcmp_full()
+{
+ $PYTHON $BINDIR/samba-tool ldapcmp tdb://$PREFIX_ABS/${RELEASE}_upgrade_reference/private/sam.ldb tdb://$PREFIX_ABS/${RELEASE}_upgrade_full/private/sam.ldb --two --filter=dNSProperty,dnsRecord,cn,displayName,versionNumber,systemFlags,msDS-HasInstantiatedNCs,servicePrincipalName --skip-missing-dn
+}
+
+ldapcmp_sd()
+{
+ $PYTHON $BINDIR/samba-tool ldapcmp tdb://$PREFIX_ABS/${RELEASE}_upgrade_reference/private/sam.ldb tdb://$PREFIX_ABS/${RELEASE}_upgrade/private/sam.ldb --two --sd --skip-missing-dn
+}
+
+ldapcmp_full_sd()
+{
+ $PYTHON $BINDIR/samba-tool ldapcmp tdb://$PREFIX_ABS/${RELEASE}_upgrade_reference/private/sam.ldb tdb://$PREFIX_ABS/${RELEASE}_upgrade_full/private/sam.ldb --two --sd --skip-missing-dn
+}
+
+remove_directory $PREFIX_ABS/${RELEASE}_upgrade
+remove_directory $PREFIX_ABS/${RELEASE}_upgrade_full
+remove_directory $PREFIX_ABS/${RELEASE}_upgrade_reference
+
+testit $RELEASE undump || failed=$(expr $failed + 1)
+testit "remove_dns_user" remove_dns_user || failed=$(expr $failed + 1)
+testit "upgradeprovision" upgradeprovision || failed=$(expr $failed + 1)
+testit "upgradeprovision_full" upgradeprovision_full || failed=$(expr $failed + 1)
+testit "reindex" reindex || failed=$(expr $failed + 1)
+testit_expect_failure "dbcheck" dbcheck || failed=$(expr $failed + 1)
+testit_expect_failure "dbcheck_full" dbcheck_full || failed=$(expr $failed + 1)
+testit "dbcheck_clean" dbcheck_clean || failed=$(expr $failed + 1)
+testit "dbcheck_full_clean" dbcheck_full_clean || failed=$(expr $failed + 1)
+testit "dbcheck_full_clean_well_known_acls" dbcheck_full_clean_well_known_acls || failed=$(expr $failed + 1)
+testit "referenceprovision" referenceprovision || failed=$(expr $failed + 1)
+testit "samba_upgradedns" samba_upgradedns || failed=$(expr $failed + 1)
+testit "ldapcmp" ldapcmp || failed=$(expr $failed + 1)
+testit "ldapcmp_sd" ldapcmp_sd || failed=$(expr $failed + 1)
+testit "ldapcmp_full_sd" ldapcmp_full_sd || failed=$(expr $failed + 1)
+
+remove_directory $PREFIX_ABS/${RELEASE}_upgrade
+remove_directory $PREFIX_ABS/${RELEASE}_upgrade_full
+remove_directory $PREFIX_ABS/${RELEASE}_upgrade_reference
+
+exit $failed
diff --git a/testprogs/blackbox/wintest/wintest.conf b/testprogs/blackbox/wintest/wintest.conf
new file mode 100644
index 0000000..d140366
--- /dev/null
+++ b/testprogs/blackbox/wintest/wintest.conf
@@ -0,0 +1,7 @@
+#export WINTEST_STARTUP="/tmp/startup client"
+#export WINTEST_SHUTDOWN=/tmp/shutdown client"
+export DOMAIN="client"
+export USERNAME="administrator"
+export PASSWORD="samba"
+export SERVER="192.168.213.161"
+export SHARE="c\$" \ No newline at end of file
diff --git a/testprogs/win32/midltests/Makefile b/testprogs/win32/midltests/Makefile
new file mode 100644
index 0000000..ded98e9
--- /dev/null
+++ b/testprogs/win32/midltests/Makefile
@@ -0,0 +1,16 @@
+
+all:
+ @echo "nmake targets:"
+ @echo " clean"
+ @echo " simple"
+ @echo " tcp"
+
+clean:
+ @call nmake /f Makefile.simple /A /NOLOGO clean
+ @call nmake /f Makefile.tcp /A /NOLOGO clean
+
+simple:
+ @call nmake /f Makefile.simple /A /NOLOGO all
+
+tcp:
+ @call nmake /f Makefile.tcp /A /NOLOGO all
diff --git a/testprogs/win32/midltests/Makefile.simple b/testprogs/win32/midltests/Makefile.simple
new file mode 100644
index 0000000..ec4a542
--- /dev/null
+++ b/testprogs/win32/midltests/Makefile.simple
@@ -0,0 +1,27 @@
+INCLUDES=-I
+CFLAGS=$(INCLUDES) -Zi -D_WIN32_WINNT=0x502
+LIBS=rpcrt4.lib
+
+all: midltests_simple.exe
+
+clean:
+ del *~ *.obj *.exe midltests.h midltests_s.c midltests_c.c
+
+#MIDL_ARGS=/target NT50
+MIDL_ARGS=/Os /prefix client cli_ /prefix server srv_ /prefix switch swi_
+midltests.h midltests_s.c midltests_c.c: midltests.idl midltests.acf
+ midl $(MIDL_ARGS) /acf midltests.acf midltests.idl
+
+MIDLTESTS_OBJ = midltests_simple.obj midltests_s_m.obj midltests_c_m.obj midltests_marshall.obj utils.obj
+midltests_simple.exe: $(MIDLTESTS_OBJ)
+ $(CC) -o midltests_simple.exe $(MIDLTESTS_OBJ) $(LIBS)
+
+midltests_simple.obj: midltests.h midltests.idl
+midltests_c_m.c: midltests_c.c
+midltests_s_m.c: midltests_s.c
+
+midltests_simple.obj: midltests.h midltests.idl midltests_simple.c
+midltests_s_m.obj: midltests_marshall.h midltests_s.c midltests_s_m.c
+midltests_c_m.obj: midltests_marshall.h midltests_c.c midltests_c_m.c
+midltests_marshall.obj: midltests.h midltests_marshall.c
+utils.obj: midltests.h utils.c
diff --git a/testprogs/win32/midltests/Makefile.tcp b/testprogs/win32/midltests/Makefile.tcp
new file mode 100644
index 0000000..19c1f11
--- /dev/null
+++ b/testprogs/win32/midltests/Makefile.tcp
@@ -0,0 +1,22 @@
+INCLUDES=-I
+CFLAGS=$(INCLUDES) -Zi -D_WIN32_WINNT=0x610
+LIBS=rpcrt4.lib ws2_32.lib
+
+all: midltests_tcp.exe
+
+clean:
+ del *~ *.obj *.exe midltests.h midltests_s.c midltests_c.c
+
+MIDL_ARGS=/target NT60 /prefix client cli_ /prefix server srv_ /prefix switch swi_
+midltests.h midltests_s.c midltests_c.c: midltests.idl midltests.acf
+ midl $(MIDL_ARGS) /acf midltests.acf midltests.idl
+
+MIDLTESTS_OBJ = midltests_tcp.obj midltests_s.obj midltests_c.obj midltests_marshall.obj utils.obj
+midltests_tcp.exe: $(MIDLTESTS_OBJ)
+ $(CC) -o midltests_tcp.exe $(MIDLTESTS_OBJ) $(LIBS)
+
+midltests_tcp.obj: midltests.h midltests.idl
+
+midltests_tcp.obj: midltests.h midltests.idl midltests_tcp.c
+midltests_marshall.obj: midltests.h midltests_marshall.c
+utils.obj: midltests.h utils.c
diff --git a/testprogs/win32/midltests/invalid/README.txt b/testprogs/win32/midltests/invalid/README.txt
new file mode 100644
index 0000000..f10cc15
--- /dev/null
+++ b/testprogs/win32/midltests/invalid/README.txt
@@ -0,0 +1,3 @@
+This directory contains IDL files which give errors,
+when they're compiled as midltests.idl.
+
diff --git a/testprogs/win32/midltests/invalid/midltests_pipe_struct_union_01.idl b/testprogs/win32/midltests/invalid/midltests_pipe_struct_union_01.idl
new file mode 100644
index 0000000..517806b
--- /dev/null
+++ b/testprogs/win32/midltests/invalid/midltests_pipe_struct_union_01.idl
@@ -0,0 +1,279 @@
+#ifndef MIDLTESTS_C_CODE
+
+[
+ uuid("225b9fcb-eb3d-497b-8b0b-591f049a2507"),
+ pointer_default(unique)
+]
+interface midltests
+{
+ typedef pipe char pipe_char;
+ typedef pipe hyper pipe_hyper;
+ typedef struct {
+ long l;
+ short s;
+ [switch_is(l)] union {
+ [case(0)];
+ [case(1)] char c;
+ [case(2)] short s;
+ [case(4)] long l;
+ [case(8)] hyper h;
+ } u;
+ } structtype;
+ typedef pipe structtype pipe_structtype;
+
+ struct msg {
+ long l;
+ [size_is(l)] char *m;
+ };
+
+ long midltests_fn(
+ [out,ref] struct msg *out1,
+ [out,ref] pipe_structtype *outp,
+ [in,ref] pipe_structtype *inp,
+ [in] struct msg in1
+ );
+
+ long midltests_ping( [in] struct msg in1);
+
+}
+
+#elif MIDLTESTS_C_CODE
+
+struct pipe_char_state {
+ const char *name;
+ unsigned long count;
+ unsigned long sleep;
+};
+
+void pipe_char_pull(
+ char * _state,
+ unsigned char * buf,
+ unsigned long esize,
+ unsigned long * ecount)
+{
+ struct pipe_char_state *state = (struct pipe_char_state *)_state;
+
+ printf("pull1:%s: esize[%u] ecount[%u]\n",
+ state->name, esize, *ecount);
+ *ecount = state->count--;
+ if (*ecount > esize) {
+ *ecount = esize;
+ }
+ memset(buf, 0xDD, *ecount * sizeof(*buf));
+ printf("pull2:%s: esize[%u] ecount[%u]\n",
+ state->name, esize, *ecount);
+}
+
+void pipe_char_push(
+ char * _state,
+ unsigned char * buf,
+ unsigned long ecount)
+{
+ struct pipe_char_state *state = (struct pipe_char_state *)_state;
+
+ printf("push:%s: ecount[%u]\n",
+ state->name, ecount);
+}
+
+void pipe_char_alloc(
+ char * _state,
+ unsigned long bsize,
+ unsigned char * * buf,
+ unsigned long * bcount)
+{
+ struct pipe_char_state *state = (struct pipe_char_state *)_state;
+
+ printf("alloc1:%s: bsize[%u], bcount[%u]\n",
+ state->name, bsize, *bcount);
+ *bcount = bsize / sizeof(**buf);
+ *buf = malloc(*bcount * sizeof(**buf));
+ printf("alloc2:%s: bsize[%u], bcount[%u]\n",
+ state->name, bsize, *bcount);
+}
+
+struct pipe_hyper_state {
+ const char *name;
+ unsigned long count;
+ unsigned long sleep;
+};
+
+void pipe_hyper_pull(
+ char * _state,
+ hyper * buf,
+ unsigned long esize,
+ unsigned long * ecount)
+{
+ struct pipe_hyper_state *state = (struct pipe_hyper_state *)_state;
+
+ printf("pull1:%s: esize[%u] ecount[%u]\n",
+ state->name, esize, *ecount);
+ *ecount = state->count--;
+ if (*ecount > esize) {
+ *ecount = esize;
+ }
+ memset(buf, 0xDD, *ecount * sizeof(*buf));
+ printf("pull2:%s: esize[%u] ecount[%u]\n",
+ state->name, esize, *ecount);
+}
+
+void pipe_hyper_push(
+ char * _state,
+ hyper * buf,
+ unsigned long ecount)
+{
+ struct pipe_hyper_state *state = (struct pipe_hyper_state *)_state;
+
+ printf("push:%s: ecount[%u]\n",
+ state->name, ecount);
+}
+
+void pipe_hyper_alloc(
+ char * _state,
+ unsigned long bsize,
+ hyper * * buf,
+ unsigned long * bcount)
+{
+ struct pipe_hyper_state *state = (struct pipe_hyper_state *)_state;
+
+ printf("alloc1:%s: bsize[%u], bcount[%u]\n",
+ state->name, bsize, *bcount);
+ *bcount = bsize / sizeof(**buf);
+ *buf = malloc(*bcount * sizeof(**buf));
+ printf("alloc2:%s: bsize[%u], bcount[%u]\n",
+ state->name, bsize, *bcount);
+}
+struct pipe_structtype_state {
+ const char *name;
+ unsigned long count;
+ unsigned long sleep;
+};
+
+void pipe_structtype_pull(
+ char * _state,
+ structtype * buf,
+ unsigned long esize,
+ unsigned long * ecount)
+{
+ struct pipe_structtype_state *state = (struct pipe_structtype_state *)_state;
+
+ printf("pull1:%s: esize[%u] ecount[%u]\n",
+ state->name, esize, *ecount);
+ *ecount = state->count--;
+ if (*ecount > esize) {
+ *ecount = esize;
+ }
+ memset(buf, 0xDD, *ecount * sizeof(*buf));
+ printf("pull2:%s: esize[%u] ecount[%u]\n",
+ state->name, esize, *ecount);
+}
+
+void pipe_structtype_push(
+ char * _state,
+ structtype * buf,
+ unsigned long ecount)
+{
+ struct pipe_structtype_state *state = (struct pipe_structtype_state *)_state;
+
+ printf("push:%s: ecount[%u]\n",
+ state->name, ecount);
+}
+
+void pipe_structtype_alloc(
+ char * _state,
+ unsigned long bsize,
+ structtype * * buf,
+ unsigned long * bcount)
+{
+ struct pipe_structtype_state *state = (struct pipe_structtype_state *)_state;
+
+ printf("alloc1:%s: bsize[%u], bcount[%u]\n",
+ state->name, bsize, *bcount);
+ *bcount = bsize / sizeof(**buf);
+ *buf = malloc(*bcount * sizeof(**buf));
+ printf("alloc2:%s: bsize[%u], bcount[%u]\n",
+ state->name, bsize, *bcount);
+}
+static void midltests(void)
+{
+ struct msg out1;
+ unsigned char out1b[3];
+ struct pipe_structtype_state outs;
+ pipe_structtype outp;
+ struct pipe_structtype_state ins;
+ pipe_structtype inp;
+ struct msg in1;
+ unsigned char in1b[3];
+
+ in1.l = sizeof(in1b);
+ memset(&in1b, 0xAA, sizeof(in1b));
+ in1.m = in1b;
+
+ memset(&outs, 0, sizeof(outs));
+ outs.name = "outp";
+ memset(&outp, 0, sizeof(outp));
+ outp.pull = pipe_structtype_pull;
+ outp.push = pipe_structtype_push;
+ outp.alloc = pipe_structtype_alloc;
+ outp.state = (char *)&outs;
+
+ memset(&ins, 0, sizeof(ins));
+ ins.name = "inp";
+ ins.count = 1;
+ memset(&inp, 0, sizeof(inp));
+ inp.pull = pipe_structtype_pull;
+ inp.push = pipe_structtype_push;
+ inp.alloc = pipe_structtype_alloc;
+ inp.state = (char *)&ins;
+
+ out1.l = sizeof(out1b);
+ memset(&out1b, 0xFF, sizeof(out1b));
+ out1.m = out1b;
+
+ cli_midltests_ping(in1);
+ cli_midltests_fn(&out1, outp, inp, in1);
+}
+
+long srv_midltests_fn(
+ /* [ref][out] */ struct msg *out1,
+ /* [out] */ pipe_structtype outp,
+ /* [in] */ pipe_structtype inp,
+ /* [in] */ struct msg in1)
+{
+ structtype inb[500];
+ unsigned long inb_len = 0;
+ structtype *outb = NULL;
+ unsigned long outb_size = 0;
+ unsigned long outb_len = 0;
+
+ printf("srv_midltests_fn: Start\n");
+
+ do {
+ inp.pull(inp.state, inb, sizeof(inb), &inb_len);
+ printf("pull inp_len[%u]\n", inb_len);
+ } while (inb_len > 0);
+
+ outb_size = 5;
+ do {
+ outp.alloc(outp.state, outb_size, &outb, &outb_len);
+ memset(outb, 0xCC, outb_len * sizeof(*outb));
+ outp.push(outp.state, outb, outb_len);
+ printf("push outb_len[%u]\n", outb_len);
+ //Sleep(1000);
+ outb_size--;
+ } while (outb_len > 0);
+
+ out1->l = 3;
+ out1->m = (unsigned char *)malloc(out1->l);
+ memset(out1->m, 0xBB, out1->l);
+ printf("srv_midltests_fn: End\n");
+ return 0x65757254;
+}
+
+long srv_midltests_ping(
+ /* [in] */ struct msg in1)
+{
+ printf("srv_midltests_fn: Start\n");
+ printf("srv_midltests_fn: End\n");
+ return 0x65757254;
+}
+#endif
diff --git a/testprogs/win32/midltests/invalid/midltests_pipe_struct_union_01.txt b/testprogs/win32/midltests/invalid/midltests_pipe_struct_union_01.txt
new file mode 100644
index 0000000..46f8de5
--- /dev/null
+++ b/testprogs/win32/midltests/invalid/midltests_pipe_struct_union_01.txt
@@ -0,0 +1,17 @@
+
+Microsoft (R) Program Maintenance Utility Version 10.00.30319.01
+Copyright (C) Microsoft Corporation. All rights reserved.
+
+ midl /target NT60 /prefix client cli_ /prefix server srv_ /prefix switch swi_ /acf midltests.acf midltests.idl
+Microsoft (R) 32b/64b MIDL Compiler Version 7.00.0555
+Copyright (c) Microsoft Corporation. All rights reserved.
+64 bit Processing .\midltests.idl
+midltests.idl
+64 bit Processing .\midltests.acf
+midltests.acf
+.\midltests.idl(34) : error MIDL2028 : feature not implemented : pipes can't contain unions [ Type 'pipe_structtype' ( Parameter 'outp' ) ]
+.\midltests.idl(34) : error MIDL2028 : feature not implemented : pipes can't contain unions [ Type 'pipe_structtype' ( Parameter 'inp' ) ]
+NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\bin\x64\midl.EXE"' : return code '0x8a6'
+Stop.
+NMAKE : fatal error U1077: 'call' : return code '0x2'
+Stop.
diff --git a/testprogs/win32/midltests/midltests.acf b/testprogs/win32/midltests/midltests.acf
new file mode 100644
index 0000000..a04bb5d
--- /dev/null
+++ b/testprogs/win32/midltests/midltests.acf
@@ -0,0 +1,6 @@
+[
+ implicit_handle (handle_t midltests_IfHandle)
+]
+interface midltests
+{
+}
diff --git a/testprogs/win32/midltests/midltests.idl b/testprogs/win32/midltests/midltests.idl
new file mode 100644
index 0000000..0c0bbf8
--- /dev/null
+++ b/testprogs/win32/midltests/midltests.idl
@@ -0,0 +1,51 @@
+#ifndef MIDLTESTS_C_CODE
+
+/*
+ * For midltests_tcp.exe you may want to
+ * redirect the traffic via rinetd
+ * with a /etc/rinetd.conf like this:
+ *
+ * 172.31.9.1 5032 172.31.9.8 5032
+ * 172.31.9.1 5064 172.31.9.8 5064
+ *
+ * This is useful to watch the traffic with
+ * a network sniffer.
+ */
+/*
+cpp_quote("#define LISTEN_IP \"0.0.0.0\"")
+cpp_quote("#define FORWARD_IP \"127.0.0.1\"")
+cpp_quote("#define CONNECT_IP \"172.31.9.1\"")
+*/
+
+/*
+ * With midltests_tcp.exe NDR64 is enforced by default.
+ * For testing it might be needed to allow downgrades
+ * to NDR32. This is needed when you use 'pipe'.
+ */
+//cpp_quote("#define DONOT_FORCE_NDR64 1")
+
+[
+ uuid("225b9fcb-eb3d-497b-8b0b-591f049a2507"),
+ pointer_default(unique)
+]
+interface midltests
+{
+ long midltests_fn(
+ );
+}
+
+#elif MIDLTESTS_C_CODE
+
+static void midltests(void)
+{
+ cli_midltests_fn();
+}
+
+long srv_midltests_fn(void)
+{
+ printf("srv_midltests_fn: Start\n");
+ printf("srv_midltests_fn: End\n");
+ return 0x65757254;
+}
+
+#endif
diff --git a/testprogs/win32/midltests/midltests_c_m.c b/testprogs/win32/midltests/midltests_c_m.c
new file mode 100644
index 0000000..facf735
--- /dev/null
+++ b/testprogs/win32/midltests/midltests_c_m.c
@@ -0,0 +1,2 @@
+#include "midltests_marshall.h"
+#include "midltests_c.c"
diff --git a/testprogs/win32/midltests/midltests_marshall.c b/testprogs/win32/midltests/midltests_marshall.c
new file mode 100644
index 0000000..f0fc78a
--- /dev/null
+++ b/testprogs/win32/midltests/midltests_marshall.c
@@ -0,0 +1,125 @@
+/*
+ MIDLTESTS client.
+
+ Copyright (C) Stefan Metzmacher 2008
+
+ 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
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <ctype.h>
+#include "midltests.h"
+
+#define MIN(a,b) ((a)<(b)?(a):(b))
+static void print_asc(const unsigned char *buf,int len)
+{
+ int i;
+ for (i=0;i<len;i++)
+ printf("%c", isprint(buf[i])?buf[i]:'.');
+}
+
+void dump_data(const unsigned char *buf1,int len)
+{
+ const unsigned char *buf = (const unsigned char *)buf1;
+ int i=0;
+ if (len<=0) return;
+
+ printf("[%03X] ",i);
+ for (i=0;i<len;) {
+ printf("%02X ",(int)buf[i]);
+ i++;
+ if (i%8 == 0) printf(" ");
+ if (i%16 == 0) {
+ print_asc(&buf[i-16],8); printf(" ");
+ print_asc(&buf[i-8],8); printf("\n");
+ if (i<len) printf("[%03X] ",i);
+ }
+ }
+ if (i%16) {
+ int n;
+ n = 16 - (i%16);
+ printf(" ");
+ if (n>8) printf(" ");
+ while (n--) printf(" ");
+ n = MIN(8,i%16);
+ print_asc(&buf[i-(i%16)],n); printf( " " );
+ n = (i%16) - n;
+ if (n>0) print_asc(&buf[i-n],n);
+ printf("\n");
+ }
+}
+
+#if _WIN32_WINNT < 0x600
+
+void NdrGetBufferMarshall(PMIDL_STUB_MESSAGE stubmsg, unsigned long len, RPC_BINDING_HANDLE hnd)
+{
+ stubmsg->RpcMsg->Buffer = HeapAlloc(GetProcessHeap(), 0, len);
+ memset(stubmsg->RpcMsg->Buffer, 0xef, len);
+ stubmsg->RpcMsg->BufferLength = len;
+ stubmsg->Buffer = stubmsg->RpcMsg->Buffer;
+ stubmsg->BufferLength = stubmsg->RpcMsg->BufferLength;
+ stubmsg->fBufferValid = TRUE;
+}
+
+void __RPC_STUB midltests_midltests_fn(PRPC_MESSAGE _pRpcMessage);
+
+void NdrSendReceiveMarshall(PMIDL_STUB_MESSAGE StubMsg, unsigned char *buffer)
+{
+ unsigned long DataRepresentation;
+
+ StubMsg->RpcMsg->BufferLength = buffer - (unsigned char *)StubMsg->RpcMsg->Buffer;
+
+ printf("[in] Buffer[%d/%d]\n",
+ StubMsg->RpcMsg->BufferLength, StubMsg->BufferLength);
+ dump_data(StubMsg->RpcMsg->Buffer, StubMsg->RpcMsg->BufferLength);
+
+ DataRepresentation = StubMsg->RpcMsg->DataRepresentation;
+ StubMsg->RpcMsg->DataRepresentation = NDR_LOCAL_DATA_REPRESENTATION;
+ midltests_midltests_fn(StubMsg->RpcMsg);
+ StubMsg->RpcMsg->DataRepresentation = DataRepresentation;
+
+ StubMsg->BufferLength = StubMsg->RpcMsg->BufferLength;
+ StubMsg->BufferStart = StubMsg->RpcMsg->Buffer;
+ StubMsg->BufferEnd = StubMsg->BufferStart + StubMsg->BufferLength;
+ StubMsg->Buffer = StubMsg->BufferStart;
+
+ printf("[out] Buffer[%d]\n",
+ StubMsg->RpcMsg->BufferLength);
+ dump_data(StubMsg->RpcMsg->Buffer, StubMsg->RpcMsg->BufferLength);
+}
+
+void NdrServerInitializeNewMarshall(PRPC_MESSAGE pRpcMsg,
+ PMIDL_STUB_MESSAGE pStubMsg,
+ PMIDL_STUB_DESC pStubDesc)
+{
+ memset(pStubMsg, 0, sizeof(*pStubMsg));
+ pStubMsg->RpcMsg = pRpcMsg;
+ pStubMsg->Buffer = pStubMsg->BufferStart = pRpcMsg->Buffer;
+ pStubMsg->BufferEnd = pStubMsg->Buffer + pRpcMsg->BufferLength;
+ pStubMsg->BufferLength = pRpcMsg->BufferLength;
+ pStubMsg->pfnAllocate = pStubDesc->pfnAllocate;
+ pStubMsg->pfnFree = pStubDesc->pfnFree;
+ pStubMsg->StubDesc = pStubDesc;
+ pStubMsg->dwDestContext = MSHCTX_DIFFERENTMACHINE;
+}
+
+RPC_STATUS WINAPI I_RpcGetBufferMarshall(PRPC_MESSAGE RpcMsg)
+{
+ RpcMsg->Buffer = HeapAlloc(GetProcessHeap(), 0, RpcMsg->BufferLength);
+ memset(RpcMsg->Buffer, 0xcd, RpcMsg->BufferLength);
+ return 0;
+}
+
+#endif /* _WIN32_WINNT < 0x600 */
diff --git a/testprogs/win32/midltests/midltests_marshall.h b/testprogs/win32/midltests/midltests_marshall.h
new file mode 100644
index 0000000..8bb59b9
--- /dev/null
+++ b/testprogs/win32/midltests/midltests_marshall.h
@@ -0,0 +1,19 @@
+#include "rpc.h"
+#include "rpcndr.h"
+
+void dump_data(const unsigned char *buf1,int len);
+
+#if _WIN32_WINNT < 0x600
+#define NdrSendReceive NdrSendReceiveMarshall
+void NdrSendReceiveMarshall(PMIDL_STUB_MESSAGE stubmsg, unsigned char *buffer);
+#define NdrGetBuffer NdrGetBufferMarshall
+void NdrGetBufferMarshall(PMIDL_STUB_MESSAGE stubmsg, unsigned long len, RPC_BINDING_HANDLE hnd);
+#define NdrServerInitializeNew NdrServerInitializeNewMarshall
+void NdrServerInitializeNewMarshall(PRPC_MESSAGE pRpcMsg,
+ PMIDL_STUB_MESSAGE pStubMsg,
+ PMIDL_STUB_DESC pStubDesc);
+#define I_RpcGetBuffer I_RpcGetBufferMarshall
+RPC_STATUS WINAPI I_RpcGetBufferMarshall(PRPC_MESSAGE pMsg);
+
+#endif /* _WIN32_WINNT < 0x600 */
+
diff --git a/testprogs/win32/midltests/midltests_s_m.c b/testprogs/win32/midltests/midltests_s_m.c
new file mode 100644
index 0000000..7e0862d
--- /dev/null
+++ b/testprogs/win32/midltests/midltests_s_m.c
@@ -0,0 +1,2 @@
+#include "midltests_marshall.h"
+#include "midltests_s.c"
diff --git a/testprogs/win32/midltests/midltests_simple.c b/testprogs/win32/midltests/midltests_simple.c
new file mode 100644
index 0000000..61d4ce0
--- /dev/null
+++ b/testprogs/win32/midltests/midltests_simple.c
@@ -0,0 +1,42 @@
+/*
+ MIDLTESTS client.
+
+ Copyright (C) Stefan Metzmacher 2008
+
+ 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
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <ctype.h>
+#include "midltests.h"
+
+#define MIDLTESTS_C_CODE 1
+#include "midltests.idl"
+
+int main(int argc, char **argv)
+{
+ int ret;
+
+ midltests_IfHandle = NULL;
+
+ RpcTryExcept {
+ midltests();
+ } RpcExcept(1) {
+ ret = RpcExceptionCode();
+ printf("Runtime error 0x%x\n", ret);
+ } RpcEndExcept
+
+ return ret;
+}
diff --git a/testprogs/win32/midltests/midltests_tcp.c b/testprogs/win32/midltests/midltests_tcp.c
new file mode 100644
index 0000000..3046f6d
--- /dev/null
+++ b/testprogs/win32/midltests/midltests_tcp.c
@@ -0,0 +1,646 @@
+/*
+ MIDLTESTS client.
+
+ Copyright (C) Stefan Metzmacher 2008
+
+ 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
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <ctype.h>
+#include <winsock.h>
+#include "midltests.h"
+
+#ifndef _M_AMD64
+#error "please run 'vcvarsall.bat amd64' -midltests_tcp needs 64-bit support!"
+#endif
+
+#define MIDLTESTS_C_CODE 1
+#include "midltests.idl"
+
+#ifndef LISTEN_IP
+#define LISTEN_IP "127.0.0.1"
+#endif
+
+#ifndef FORWARD_IP
+#define FORWARD_IP "127.0.0.1"
+#endif
+
+#ifndef CONNECT_IP
+#define CONNECT_IP "127.0.0.1"
+#endif
+
+struct NDRTcpThreadCtx;
+
+struct NDRProxyThreadCtx {
+ const struct NDRTcpThreadCtx *ctx;
+ SOCKET InSocket;
+ SOCKET OutSocket;
+ DWORD dwThreadId;
+ HANDLE hThread;
+};
+
+struct NDRTcpThreadCtx {
+ const char *name;
+ short listen_port;
+ short client_port;
+ BOOL ndr64;
+ BOOL stop;
+};
+
+struct dcerpc_header {
+ BYTE rpc_vers; /* RPC version */
+ BYTE rpc_vers_minor; /* Minor version */
+ BYTE ptype; /* Packet type */
+ BYTE pfc_flags; /* Fragmentation flags */
+ BYTE drep[4]; /* NDR data representation */
+ short frag_length; /* Total length of fragment */
+ short auth_length; /* authenticator length */
+ DWORD call_id; /* Call identifier */
+};
+
+static void dump_packet(const char *ctx, const char *direction,
+ const unsigned char *buf, int len)
+{
+ struct dcerpc_header *hdr = (struct dcerpc_header *)buf;
+
+ if (len < sizeof(struct dcerpc_header)) {
+ printf("%s:%s: invalid dcerpc pdu len(%d)\n",
+ ctx, direction, len);
+ fflush(stdout);
+ return;
+ }
+
+ if (hdr->rpc_vers != 5 || hdr->rpc_vers_minor != 0) {
+ printf("%s:%s: invalid dcerpc pdu len(%d) ver:%d min:%d\n",
+ ctx, direction, len,
+ hdr->rpc_vers, hdr->rpc_vers_minor);
+ fflush(stdout);
+ return;
+ }
+
+ if (hdr->frag_length != len) {
+ printf("%s:%s: invalid dcerpc pdu len(%d) should be (%d)\n",
+ ctx, direction, len, hdr->frag_length);
+ fflush(stdout);
+ return;
+ }
+
+
+ switch (hdr->ptype) {
+ case 0: /* request */
+ printf("%s:%s: ptype[request] flen[%d] plen[%d] ahint[%d]\n\n",
+ ctx, direction, hdr->frag_length,
+ len - 24, *(DWORD *)(&buf[0x10]));
+ dump_data(buf + 24, len - 24);
+ printf("\n");
+ fflush(stdout);
+ break;
+
+ case 2: /* response */
+ printf("\n%s:%s: ptype[response] flen[%d] plen[%d] ahint[%d]\n\n",
+ ctx, direction, hdr->frag_length,
+ len - 24, *(DWORD *)(&buf[0x10]));
+ dump_data(buf + 24, len - 24);
+ printf("\n");
+ fflush(stdout);
+ break;
+
+ case 11: /* bind */
+#if 0
+ printf("%s:%s: ptype[bind] flen[%d] call[%d] contexts[%d]\n\n"
+ ctx, direction, hdr->frag_length, hdr->call_id,
+ buf[24]);
+ dump_data(buf + 24, len - 24);
+ printf("\n");
+ fflush(stdout);
+#endif
+ break;
+
+ case 12: /* bind ack */
+#if 0
+ printf("%s:%s: ptype[bind_ack] flen[%d] call[%d]\n\n",
+ ctx, direction, hdr->frag_length, hdr->call_id);
+ fflush(stdout);
+#endif
+ break;
+
+ case 14: /* alter_req */
+#if 1
+ printf("%s:%s: ptype[alter_req] flen[%d] call[%d] contexts[%d]\n\n",
+ ctx, direction, hdr->frag_length, hdr->call_id,
+ buf[24]);
+ //dump_data(buf + 24, len - 24);
+ printf("\n");
+ fflush(stdout);
+#endif
+ break;
+
+ case 15: /* alter_ack */
+#if 1
+ printf("%s:%s: ptype[alter_ack] flen[%d] call[%d]\n\n",
+ ctx, direction, hdr->frag_length, hdr->call_id);
+ fflush(stdout);
+#endif
+ break;
+
+ default:
+ printf("%s:%s: ptype[%d] flen[%d] call[%d]\n\n",
+ ctx, direction, hdr->ptype, hdr->frag_length, hdr->call_id);
+ fflush(stdout);
+ break;
+ }
+}
+
+static void change_packet(const char *ctx, BOOL ndr64,
+ unsigned char *buf, int len)
+{
+ struct dcerpc_header *hdr = (struct dcerpc_header *)buf;
+ BOOL is_ndr64 = FALSE;
+ const unsigned char ndr64_buf[] = {
+ 0x33, 0x05, 0x71, 0x71, 0xBA, 0xBE, 0x37, 0x49,
+ 0x83, 0x19, 0xB5, 0xDB, 0xEF, 0x9C, 0xCC, 0x36
+ };
+
+ if (len < sizeof(struct dcerpc_header)) {
+ printf("%s: invalid dcerpc pdu len(%d)\n",
+ ctx, len);
+ fflush(stdout);
+ return;
+ }
+
+ if (hdr->rpc_vers != 5 || hdr->rpc_vers_minor != 0) {
+ printf("%s: invalid dcerpc pdu len(%d) ver:%d min:%d\n",
+ ctx, len,
+ hdr->rpc_vers, hdr->rpc_vers_minor);
+ fflush(stdout);
+ return;
+ }
+
+ if (hdr->frag_length != len) {
+ printf("%s: invalid dcerpc pdu len(%d) should be (%d)\n",
+ ctx, len, hdr->frag_length);
+ fflush(stdout);
+ return;
+ }
+
+ switch (hdr->ptype) {
+ case 11: /* bind */
+ case 14: /* alter_req */
+
+ if (buf[24] >= 2) {
+ int ret;
+
+ ret = memcmp(&buf[0x60], ndr64_buf, 16);
+ if (ret == 0) {
+ is_ndr64 = TRUE;
+ }
+ }
+
+ if (is_ndr64 && !ndr64) {
+ buf[24+0x48] = 0xFF;
+ memset(&buf[0x60], 0xFF, 16);
+ printf("%s: disable NDR64\n\n", ctx);
+ } else if (!is_ndr64 && ndr64) {
+ printf("\n%s: got NDR32 downgrade\n\n", ctx);
+#ifndef DONOT_FORCE_NDR64
+ printf("\n\tERROR!!!\n\n");
+ memset(&buf[0x34], 0xFF, 16);
+ printf("You may need to run 'vcvarsall.bat amd64' before 'nmake tcp'\n");
+#endif
+ printf("\n");
+ } else if (is_ndr64) {
+ printf("%s: got NDR64\n\n", ctx);
+ } else {
+ printf("%s: got NDR32\n\n", ctx);
+ }
+ //printf("%s: bind with %u pres\n", ctx, buf[24]);
+ fflush(stdout);
+ break;
+ }
+}
+
+static int sock_pending(SOCKET s)
+{
+ int ret, error;
+ int value = 0;
+ int len;
+
+ ret = ioctlsocket(s, FIONREAD, &value);
+ if (ret == -1) {
+ return ret;
+ }
+
+ if (ret != 0) {
+ /* this should not be reached */
+ return -1;
+ }
+
+ if (value != 0) {
+ return value;
+ }
+
+ error = 0;
+ len = sizeof(error);
+
+ /*
+ * if no data is available check if the socket is in error state. For
+ * dgram sockets it's the way to return ICMP error messages of
+ * connected sockets to the caller.
+ */
+ ret = getsockopt(s, SOL_SOCKET, SO_ERROR, (char *)&error, &len);
+ if (ret == -1) {
+ return ret;
+ }
+ if (error != 0) {
+ return -1;
+ }
+ return 0;
+}
+
+DWORD WINAPI NDRProxyThread(LPVOID lpParameter)
+{
+ struct NDRProxyThreadCtx *p = (struct NDRProxyThreadCtx *)lpParameter;
+
+ while (!p->ctx->stop) {
+ int r, s;
+ int ret = -1;
+ BYTE buf[5840];
+
+ Sleep(250);
+
+ ret = sock_pending(p->InSocket);
+ if (ret == 0) {
+ goto out;
+ }
+
+ r = recv(p->InSocket, buf, sizeof(buf), 0);
+ if (r <= 0) {
+ ret = WSAGetLastError();
+ printf("%s: recv(in) failed[%d][%d]\n", p->ctx->name, r, ret);
+ fflush(stdout);
+ goto stop;
+ }
+
+ change_packet(p->ctx->name, p->ctx->ndr64, buf, r);
+ fflush(stdout);
+
+ dump_packet(p->ctx->name, "in => out", buf, r);
+ fflush(stdout);
+
+out:
+ s = send(p->OutSocket, buf, r, 0);
+ if (s <= 0) {
+ ret = WSAGetLastError();
+ printf("%s: send(out) failed[%d][%d]\n", p->ctx->name, s, ret);
+ fflush(stdout);
+ goto stop;
+ }
+
+ ret = sock_pending(p->OutSocket);
+ if (ret == 0) {
+ goto next;
+ }
+
+ r = recv(p->OutSocket, buf, sizeof(buf), 0);
+ if (r <= 0) {
+ ret = WSAGetLastError();
+ printf("%s: recv(out) failed[%d][%d]\n", p->ctx->name, r, ret);
+ fflush(stdout);
+ goto stop;
+ }
+
+ dump_packet(p->ctx->name, "out => in", buf, r);
+ fflush(stdout);
+
+ s = send(p->InSocket, buf, r, 0);
+ if (s <= 0) {
+ ret = WSAGetLastError();
+ printf("%s: send(in) failed[%d][%d]\n", p->ctx->name, s, ret);
+ fflush(stdout);
+ goto stop;
+ }
+next:
+ continue;
+ }
+stop:
+ closesocket(p->InSocket);
+ closesocket(p->OutSocket);
+
+ printf("NDRTcpThread[%s] stop\n", p->ctx->name);
+ fflush(stdout);
+ return 0;
+}
+
+DWORD WINAPI NDRTcpThread(LPVOID lpParameter)
+{
+ struct NDRTcpThreadCtx *ctx = (struct NDRTcpThreadCtx *)lpParameter;
+ int ret = -1;
+ SOCKET ListenSocket;
+ struct sockaddr_in saServer;
+ struct sockaddr_in saClient;
+
+ //printf("NDRTcpThread[%s] start\n", ctx->name);
+ fflush(stdout);
+
+ ListenSocket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
+ if (ListenSocket == INVALID_SOCKET) {
+ ret = WSAGetLastError();
+ printf("socket() failed[%d][%d]\n", ListenSocket, ret);
+ fflush(stdout);
+ goto failed;
+ }
+
+ saServer.sin_family = AF_INET;
+ saServer.sin_addr.s_addr = inet_addr(LISTEN_IP);
+ saServer.sin_port = htons(ctx->listen_port);
+
+ saClient.sin_family = AF_INET;
+ saClient.sin_addr.s_addr = inet_addr(FORWARD_IP);
+ saClient.sin_port = htons(ctx->client_port);
+
+ ret = bind(ListenSocket, (SOCKADDR*)&saServer, sizeof(saServer));
+ if (ret == SOCKET_ERROR) {
+ ret = WSAGetLastError();
+ printf("bind() failed[%d]\n", ret);
+ fflush(stdout);
+ goto failed;
+ }
+
+ ret = listen(ListenSocket, 10);
+ if (ret == SOCKET_ERROR) {
+ ret = WSAGetLastError();
+ printf("listen() failed[%d]\n", ret);
+ fflush(stdout);
+ goto failed;
+ }
+
+ while (!ctx->stop) {
+ struct sockaddr_in sa;
+ int sa_len = sizeof(sa);
+ struct NDRProxyThreadCtx *p = malloc(sizeof(*p));
+ p->ctx = ctx;
+
+ p->InSocket = accept(ListenSocket, (SOCKADDR *)&sa, &sa_len);
+ if (p->InSocket == INVALID_SOCKET) {
+ ret = WSAGetLastError();
+ printf("%s: accept() failed[%d][%d]\n", p->ctx->name, p->InSocket, ret);
+ fflush(stdout);
+ continue;
+ }
+
+ p->OutSocket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
+ if (p->OutSocket == INVALID_SOCKET) {
+ ret = WSAGetLastError();
+ printf("%s: socket(out) failed[%d][%d]\n", p->ctx->name, p->OutSocket, ret);
+ fflush(stdout);
+ closesocket(p->InSocket);
+ continue;
+ }
+
+ ret = connect(p->OutSocket, (SOCKADDR*)&saClient, sizeof(saClient));
+ if (ret == SOCKET_ERROR) {
+ ret = WSAGetLastError();
+ printf("%s: connect() failed[%d]\n", p->ctx->name, ret);
+ fflush(stdout);
+ closesocket(p->InSocket);
+ closesocket(p->OutSocket);
+ continue;
+ }
+
+ p->hThread = CreateThread(
+ NULL, // default security attributes
+ 0, // use default stack size
+ NDRProxyThread, // thread function name
+ p, // argument to thread function
+ 0, // use default creation flags
+ &p->dwThreadId);// returns the thread identifier
+ if (p->hThread == NULL) {
+ printf("failed to create thread ndr32\n");
+ fflush(stdout);
+ return -1;
+ }
+ }
+
+ //printf("NDRTcpThread[%s] stop\n", ctx->name);
+ fflush(stdout);
+ return 0;
+failed:
+ printf("NDRTcpThread[%s] failed[%d]\n", ctx->name, ret);
+ fflush(stdout);
+ return ret;
+}
+
+struct NDRRpcThreadCtx {
+ const char *name;
+ short listen_port;
+};
+
+DWORD WINAPI NDRRpcThread(LPVOID lpParameter)
+{
+ struct NDRRpcThreadCtx *ctx = (struct NDRRpcThreadCtx *)lpParameter;
+ int ret = -1;
+ RPC_STATUS status;
+ RPC_BINDING_VECTOR *pBindingVector;
+
+#define RPC_MIN_CALLS 1
+#define RPC_MAX_CALLS 20
+
+ //printf("NDRRpcThread[%s] start\n", ctx->name);
+ fflush(stdout);
+ status = RpcServerUseProtseqEp("ncacn_ip_tcp", RPC_MAX_CALLS, "5055", NULL);
+ if (status) {
+ printf("Failed to register ncacn_ip_tcp endpoint\n");
+ fflush(stdout);
+ return status;
+ }
+
+ status = RpcServerInqBindings(&pBindingVector);
+ if (status) {
+ printf("Failed RpcServerInqBindings\n");
+ fflush(stdout);
+ return status;
+ }
+
+#if 0
+ status = RpcEpRegister(srv_midltests_v0_0_s_ifspec, pBindingVector, NULL, "midltests server");
+ if (status) {
+ printf("Failed RpcEpRegister\n");
+ fflush(stdout);
+ return status;
+ }
+#endif
+ status = RpcServerRegisterIf(srv_midltests_v0_0_s_ifspec, NULL, NULL);
+ if (status) {
+ printf("Failed to register interface\n");
+ fflush(stdout);
+ return status;
+ }
+
+ status = RpcServerListen(RPC_MIN_CALLS, RPC_MAX_CALLS, FALSE);
+ if (status) {
+ printf("RpcServerListen returned error %d\n", status);
+ fflush(stdout);
+ return status;
+ }
+
+ printf("NDRRpcThread[%s] stop\n", ctx->name);
+ fflush(stdout);
+ return 0;
+failed:
+ printf("NDRRpcThread[%s] failed[%d]\n", ctx->name, ret);
+ fflush(stdout);
+ return ret;
+}
+
+int main(int argc, char **argv)
+{
+ int ret;
+ struct NDRTcpThreadCtx ctx_ndr32;
+ struct NDRTcpThreadCtx ctx_ndr64;
+ struct NDRRpcThreadCtx ctx_rpc;
+ DWORD dwThreadIdArray[3];
+ HANDLE hThreadArray[3];
+ WORD wVersionRequested = MAKEWORD(2, 2);
+ WSADATA wsaData;
+ char *binding;
+ RPC_STATUS status;
+
+ ret = WSAStartup(wVersionRequested, &wsaData);
+ if (ret != 0) {
+ printf("WSAStartup failed with error: %d\n", ret);
+ fflush(stdout);
+ return -1;
+ }
+
+ ctx_ndr32.name = "ndr32";
+ ctx_ndr32.listen_port = 5032;
+ ctx_ndr32.client_port = 5055;
+ ctx_ndr32.ndr64 = FALSE;
+ ctx_ndr32.stop = FALSE;
+ hThreadArray[0] = CreateThread(
+ NULL, // default security attributes
+ 0, // use default stack size
+ NDRTcpThread, // thread function name
+ &ctx_ndr32, // argument to thread function
+ 0, // use default creation flags
+ &dwThreadIdArray[0]); // returns the thread identifier
+ if (hThreadArray[0] == NULL) {
+ printf("failed to create thread ndr32\n");
+ fflush(stdout);
+ return -1;
+ }
+
+ ctx_ndr64.name = "ndr64";
+ ctx_ndr64.listen_port = 5064;
+ ctx_ndr64.client_port = 5055;
+ ctx_ndr64.ndr64 = TRUE;
+ ctx_ndr64.stop = FALSE;
+ hThreadArray[1] = CreateThread(
+ NULL, // default security attributes
+ 0, // use default stack size
+ NDRTcpThread, // thread function name
+ &ctx_ndr64, // argument to thread function
+ 0, // use default creation flags
+ &dwThreadIdArray[1]); // returns the thread identifier
+ if (hThreadArray[1] == NULL) {
+ printf("failed to create thread ndr64\n");
+ fflush(stdout);
+ return -1;
+ }
+
+ ctx_rpc.name = "rpc";
+ ctx_rpc.listen_port = 5050;
+ hThreadArray[2] = CreateThread(
+ NULL, // default security attributes
+ 0, // use default stack size
+ NDRRpcThread, // thread function name
+ &ctx_rpc, // argument to thread function
+ 0, // use default creation flags
+ &dwThreadIdArray[2]); // returns the thread identifier
+ if (hThreadArray[2] == NULL) {
+ printf("failed to create thread rpc\n");
+ fflush(stdout);
+ return -1;
+ }
+
+ printf("Wait for setup of server threads\n");
+ fflush(stdout);
+ ret = WaitForMultipleObjects(3, hThreadArray, TRUE, 3000);
+ if (ret == WAIT_TIMEOUT) {
+ /* OK */
+ } else {
+ printf("Failed to setup of server threads %d:%d\n",
+ ret, GetLastError());
+ fflush(stdout);
+ return -1;
+ }
+ ret = 0;
+
+ printf("\nTest NDR32\n\n");
+ fflush(stdout);
+ binding = "ncacn_ip_tcp:" CONNECT_IP "[5032]";
+ status = RpcBindingFromStringBinding(
+ binding,
+ &midltests_IfHandle);
+ if (status) {
+ printf("RpcBindingFromStringBinding returned %d\n", status);
+ fflush(stdout);
+ return status;
+ }
+
+ RpcTryExcept {
+ midltests();
+ } RpcExcept(1) {
+ ret = RpcExceptionCode();
+ printf("NDR32 Runtime error 0x%x\n", ret);
+ fflush(stdout);
+ } RpcEndExcept
+ ctx_ndr32.stop = TRUE;
+
+ Sleep(250);
+
+ printf("\nTest NDR64\n\n");
+ binding = "ncacn_ip_tcp:" CONNECT_IP "[5064]";
+ status = RpcBindingFromStringBinding(
+ binding,
+ &midltests_IfHandle);
+ if (status) {
+ printf("RpcBindingFromStringBinding returned %d\n", status);
+ fflush(stdout);
+ return status;
+ }
+
+ RpcTryExcept {
+ midltests();
+ } RpcExcept(1) {
+ ret = RpcExceptionCode();
+ printf("Runtime error 0x%x\n", ret);
+ fflush(stdout);
+ } RpcEndExcept
+ ctx_ndr64.stop = TRUE;
+
+ WaitForMultipleObjects(3, hThreadArray, TRUE, 2000);
+
+ if (ret == 0) {
+ printf("\nTest OK\n");
+ fflush(stdout);
+ } else {
+ printf("\nTest FAILED[%d]\n", ret);
+ fflush(stdout);
+ }
+
+ return ret;
+}
diff --git a/testprogs/win32/midltests/todo/midltests-array-range.idl b/testprogs/win32/midltests/todo/midltests-array-range.idl
new file mode 100644
index 0000000..1d60fd6
--- /dev/null
+++ b/testprogs/win32/midltests/todo/midltests-array-range.idl
@@ -0,0 +1,39 @@
+#ifndef MIDLTESTS_C_CODE
+
+[
+ uuid("225b9fcb-eb3d-497b-8b0b-591f049a2507"),
+ pointer_default(unique)
+]
+interface midltests
+{
+ long midltests_fn(
+ [out,ref] long *count,
+ [out,ref,size_is(,*count),range(0,1)] long **array,
+ [out,ref] long *error
+ );
+}
+
+#elif MIDLTESTS_C_CODE
+
+static void midltests(void)
+{
+ long count;
+ long *array;
+ long error;
+
+ cli_midltests_fn(&count, &array, &error);
+}
+
+long srv_midltests_fn(long *count, long **array, long *error)
+{
+ printf("srv_midltests_fn: Start\n");
+ *count=2;
+ *array=(long *)malloc((*count) * sizeof(long));
+ (*array)[0] = 7;
+ (*array)[1] = 7;
+ *error=0;
+ printf("srv_midltests_fn: End\n");
+ return 0x65757254;
+}
+
+#endif
diff --git a/testprogs/win32/midltests/todo/midltests-pipe-02.idl b/testprogs/win32/midltests/todo/midltests-pipe-02.idl
new file mode 100644
index 0000000..e6be283
--- /dev/null
+++ b/testprogs/win32/midltests/todo/midltests-pipe-02.idl
@@ -0,0 +1,153 @@
+#ifndef MIDLTESTS_C_CODE
+
+[
+ uuid("225b9fcb-eb3d-497b-8b0b-591f049a2507"),
+ pointer_default(unique)
+]
+interface midltests
+{
+ typedef pipe char pipe_char;
+
+ struct msg {
+ long l;
+ [size_is(l)] char *m;
+ };
+
+ long midltests_fn(
+ [out,ref] struct msg *out1,
+ [out] pipe_char outp,
+ [in] pipe_char inp,
+ [in] struct msg in1
+ );
+}
+
+#elif MIDLTESTS_C_CODE
+
+struct pipe_char_state {
+ const char *name;
+ unsigned long count;
+ unsigned long sleep;
+};
+
+void pipe_char_pull(
+ char * _state,
+ unsigned char * buf,
+ unsigned long esize,
+ unsigned long * ecount)
+{
+ struct pipe_char_state *state = (struct pipe_char_state *)_state;
+
+ printf("pull1:%s: esize[%u] ecount[%u]\n",
+ state->name, esize, *ecount);
+ *ecount = state->count--;
+ if (*ecount > esize) {
+ *ecount = esize;
+ }
+ memset(buf, 0xDD, *ecount);
+ printf("pull2:%s: esize[%u] ecount[%u]\n",
+ state->name, esize, *ecount);
+}
+
+void pipe_char_push(
+ char * _state,
+ unsigned char * buf,
+ unsigned long ecount)
+{
+ struct pipe_char_state *state = (struct pipe_char_state *)_state;
+
+ printf("push:%s: ecount[%u]\n",
+ state->name, ecount);
+}
+
+void pipe_char_alloc(
+ char * _state,
+ unsigned long bsize,
+ unsigned char * * buf,
+ unsigned long * bcount)
+{
+ struct pipe_char_state *state = (struct pipe_char_state *)_state;
+
+ printf("alloc1:%s: bsize[%u], bcount[%u]\n",
+ state->name, bsize, *bcount);
+ *bcount = bsize / sizeof(**buf);
+ *buf = malloc(*bcount * sizeof(**buf));
+ printf("alloc2:%s: bsize[%u], bcount[%u]\n",
+ state->name, bsize, *bcount);
+}
+
+static void midltests(void)
+{
+ struct msg out1;
+ unsigned char out1b[3];
+ struct pipe_char_state outs;
+ pipe_char outp;
+ struct pipe_char_state ins;
+ pipe_char inp;
+ struct msg in1;
+ unsigned char in1b[3];
+
+ in1.l = sizeof(in1b);
+ memset(&in1b, 0xAA, sizeof(in1b));
+ in1.m = in1b;
+
+ memset(&outs, 0, sizeof(outs));
+ outs.name = "outp";
+ memset(&outp, 0, sizeof(outp));
+ outp.pull = pipe_char_pull;
+ outp.push = pipe_char_push;
+ outp.alloc = pipe_char_alloc;
+ outp.state = (char *)&outs;
+
+ memset(&ins, 0, sizeof(ins));
+ ins.name = "inp";
+ ins.count = 1;
+ memset(&inp, 0, sizeof(inp));
+ inp.pull = pipe_char_pull;
+ inp.push = pipe_char_push;
+ inp.alloc = pipe_char_alloc;
+ inp.state = (char *)&ins;
+
+ out1.l = sizeof(out1b);
+ memset(&out1b, 0xFF, sizeof(out1b));
+ out1.m = out1b;
+
+ cli_midltests_fn(&out1, outp, inp, in1);
+}
+
+long srv_midltests_fn(
+ /* [ref][out] */ struct msg *out1,
+ /* [out] */ pipe_char outp,
+ /* [in] */ pipe_char inp,
+ /* [in] */ struct msg in1)
+{
+ char inb[500];
+ unsigned long inb_len = 0;
+ char *outb = NULL;
+ unsigned long outb_size = 0;
+ unsigned long outb_len = 0;
+
+ printf("srv_midltests_fn: Start\n");
+
+ do {
+ inp.pull(inp.state, inb, sizeof(inb), &inb_len);
+ printf("pull inp_len[%u]\n", inb_len);
+ } while (inb_len > 0);
+
+ outb_size = 5;
+ do {
+ outp.alloc(outp.state, outb_size, &outb, &outb_len);
+ memset(outb, 0xCC, outb_len);
+ outp.push(outp.state, outb, outb_len);
+ printf("push outb_len[%u]\n", outb_len);
+ //Sleep(1000);
+ outb_size--;
+ } while (outb_len > 0);
+
+ out1->l = 3;
+ out1->m = (unsigned char *)malloc(out1->l);
+ memset(out1->m, 0xBB, out1->l);
+ printf("srv_midltests_fn: End\n");
+ return 0x65757254;
+}
+
+#endif
diff --git a/testprogs/win32/midltests/todo/midltests-pipe-03-hyper.idl b/testprogs/win32/midltests/todo/midltests-pipe-03-hyper.idl
new file mode 100644
index 0000000..475aedd
--- /dev/null
+++ b/testprogs/win32/midltests/todo/midltests-pipe-03-hyper.idl
@@ -0,0 +1,205 @@
+#ifndef MIDLTESTS_C_CODE
+
+[
+ uuid("225b9fcb-eb3d-497b-8b0b-591f049a2507"),
+ pointer_default(unique)
+]
+interface midltests
+{
+ typedef pipe char pipe_char;
+ typedef pipe hyper pipe_hyper;
+
+ struct msg {
+ long l;
+ [size_is(l)] char *m;
+ };
+
+ long midltests_fn(
+ [out,ref] struct msg *out1,
+ [out] pipe_hyper outp,
+ [in] pipe_hyper inp,
+ [in] struct msg in1
+ );
+}
+
+#elif MIDLTESTS_C_CODE
+
+struct pipe_char_state {
+ const char *name;
+ unsigned long count;
+ unsigned long sleep;
+};
+
+void pipe_char_pull(
+ char * _state,
+ unsigned char * buf,
+ unsigned long esize,
+ unsigned long * ecount)
+{
+ struct pipe_char_state *state = (struct pipe_char_state *)_state;
+
+ printf("pull1:%s: esize[%u] ecount[%u]\n",
+ state->name, esize, *ecount);
+ *ecount = state->count--;
+ if (*ecount > esize) {
+ *ecount = esize;
+ }
+ memset(buf, 0xDD, *ecount * sizeof(*buf));
+ printf("pull2:%s: esize[%u] ecount[%u]\n",
+ state->name, esize, *ecount);
+}
+
+void pipe_char_push(
+ char * _state,
+ unsigned char * buf,
+ unsigned long ecount)
+{
+ struct pipe_char_state *state = (struct pipe_char_state *)_state;
+
+ printf("push:%s: ecount[%u]\n",
+ state->name, ecount);
+}
+
+void pipe_char_alloc(
+ char * _state,
+ unsigned long bsize,
+ unsigned char * * buf,
+ unsigned long * bcount)
+{
+ struct pipe_char_state *state = (struct pipe_char_state *)_state;
+
+ printf("alloc1:%s: bsize[%u], bcount[%u]\n",
+ state->name, bsize, *bcount);
+ *bcount = bsize / sizeof(**buf);
+ *buf = malloc(*bcount * sizeof(**buf));
+ printf("alloc2:%s: bsize[%u], bcount[%u]\n",
+ state->name, bsize, *bcount);
+}
+
+struct pipe_hyper_state {
+ const char *name;
+ unsigned long count;
+ unsigned long sleep;
+};
+
+void pipe_hyper_pull(
+ char * _state,
+ hyper * buf,
+ unsigned long esize,
+ unsigned long * ecount)
+{
+ struct pipe_hyper_state *state = (struct pipe_hyper_state *)_state;
+
+ printf("pull1:%s: esize[%u] ecount[%u]\n",
+ state->name, esize, *ecount);
+ *ecount = state->count--;
+ if (*ecount > esize) {
+ *ecount = esize;
+ }
+ memset(buf, 0xDD, *ecount * sizeof(*buf));
+ printf("pull2:%s: esize[%u] ecount[%u]\n",
+ state->name, esize, *ecount);
+}
+
+void pipe_hyper_push(
+ char * _state,
+ hyper * buf,
+ unsigned long ecount)
+{
+ struct pipe_hyper_state *state = (struct pipe_hyper_state *)_state;
+
+ printf("push:%s: ecount[%u]\n",
+ state->name, ecount);
+}
+
+void pipe_hyper_alloc(
+ char * _state,
+ unsigned long bsize,
+ hyper * * buf,
+ unsigned long * bcount)
+{
+ struct pipe_hyper_state *state = (struct pipe_hyper_state *)_state;
+
+ printf("alloc1:%s: bsize[%u], bcount[%u]\n",
+ state->name, bsize, *bcount);
+ *bcount = bsize / sizeof(**buf);
+ *buf = malloc(*bcount * sizeof(**buf));
+ printf("alloc2:%s: bsize[%u], bcount[%u]\n",
+ state->name, bsize, *bcount);
+}
+static void midltests(void)
+{
+ struct msg out1;
+ unsigned char out1b[3];
+ struct pipe_hyper_state outs;
+ pipe_hyper outp;
+ struct pipe_hyper_state ins;
+ pipe_hyper inp;
+ struct msg in1;
+ unsigned char in1b[3];
+
+ in1.l = sizeof(in1b);
+ memset(&in1b, 0xAA, sizeof(in1b));
+ in1.m = in1b;
+
+ memset(&outs, 0, sizeof(outs));
+ outs.name = "outp";
+ memset(&outp, 0, sizeof(outp));
+ outp.pull = pipe_hyper_pull;
+ outp.push = pipe_hyper_push;
+ outp.alloc = pipe_hyper_alloc;
+ outp.state = (char *)&outs;
+
+ memset(&ins, 0, sizeof(ins));
+ ins.name = "inp";
+ ins.count = 1;
+ memset(&inp, 0, sizeof(inp));
+ inp.pull = pipe_hyper_pull;
+ inp.push = pipe_hyper_push;
+ inp.alloc = pipe_hyper_alloc;
+ inp.state = (char *)&ins;
+
+ out1.l = sizeof(out1b);
+ memset(&out1b, 0xFF, sizeof(out1b));
+ out1.m = out1b;
+
+ cli_midltests_fn(&out1, outp, inp, in1);
+}
+
+long srv_midltests_fn(
+ /* [ref][out] */ struct msg *out1,
+ /* [out] */ pipe_hyper outp,
+ /* [in] */ pipe_hyper inp,
+ /* [in] */ struct msg in1)
+{
+ hyper inb[500];
+ unsigned long inb_len = 0;
+ hyper *outb = NULL;
+ unsigned long outb_size = 0;
+ unsigned long outb_len = 0;
+
+ printf("srv_midltests_fn: Start\n");
+
+ do {
+ inp.pull(inp.state, inb, sizeof(inb), &inb_len);
+ printf("pull inp_len[%u]\n", inb_len);
+ } while (inb_len > 0);
+
+ outb_size = 5;
+ do {
+ outp.alloc(outp.state, outb_size, &outb, &outb_len);
+ memset(outb, 0xCC, outb_len * sizeof(*outb));
+ outp.push(outp.state, outb, outb_len);
+ printf("push outb_len[%u]\n", outb_len);
+ //Sleep(1000);
+ outb_size--;
+ } while (outb_len > 0);
+
+ out1->l = 3;
+ out1->m = (unsigned char *)malloc(out1->l);
+ memset(out1->m, 0xBB, out1->l);
+ printf("srv_midltests_fn: End\n");
+ return 0x65757254;
+}
+
+#endif
diff --git a/testprogs/win32/midltests/todo/midltests-pipe-04-struct.idl b/testprogs/win32/midltests/todo/midltests-pipe-04-struct.idl
new file mode 100644
index 0000000..07921b8
--- /dev/null
+++ b/testprogs/win32/midltests/todo/midltests-pipe-04-struct.idl
@@ -0,0 +1,272 @@
+#ifndef MIDLTESTS_C_CODE
+
+[
+ uuid("225b9fcb-eb3d-497b-8b0b-591f049a2507"),
+ pointer_default(unique)
+]
+interface midltests
+{
+ typedef pipe char pipe_char;
+ typedef pipe hyper pipe_hyper;
+ typedef struct {
+ long l;
+ short s;
+ } structtype;
+ typedef pipe structtype pipe_structtype;
+
+ struct msg {
+ long l;
+ [size_is(l)] char *m;
+ };
+
+ long midltests_fn(
+ [out,ref] struct msg *out1,
+ [out] pipe_structtype outp,
+ [in] pipe_structtype inp,
+ [in] struct msg in1
+ );
+
+ long midltests_ping( [in] struct msg in1);
+
+}
+
+#elif MIDLTESTS_C_CODE
+
+struct pipe_char_state {
+ const char *name;
+ unsigned long count;
+ unsigned long sleep;
+};
+
+void pipe_char_pull(
+ char * _state,
+ unsigned char * buf,
+ unsigned long esize,
+ unsigned long * ecount)
+{
+ struct pipe_char_state *state = (struct pipe_char_state *)_state;
+
+ printf("pull1:%s: esize[%u] ecount[%u]\n",
+ state->name, esize, *ecount);
+ *ecount = state->count--;
+ if (*ecount > esize) {
+ *ecount = esize;
+ }
+ memset(buf, 0xDD, *ecount * sizeof(*buf));
+ printf("pull2:%s: esize[%u] ecount[%u]\n",
+ state->name, esize, *ecount);
+}
+
+void pipe_char_push(
+ char * _state,
+ unsigned char * buf,
+ unsigned long ecount)
+{
+ struct pipe_char_state *state = (struct pipe_char_state *)_state;
+
+ printf("push:%s: ecount[%u]\n",
+ state->name, ecount);
+}
+
+void pipe_char_alloc(
+ char * _state,
+ unsigned long bsize,
+ unsigned char * * buf,
+ unsigned long * bcount)
+{
+ struct pipe_char_state *state = (struct pipe_char_state *)_state;
+
+ printf("alloc1:%s: bsize[%u], bcount[%u]\n",
+ state->name, bsize, *bcount);
+ *bcount = bsize / sizeof(**buf);
+ *buf = malloc(*bcount * sizeof(**buf));
+ printf("alloc2:%s: bsize[%u], bcount[%u]\n",
+ state->name, bsize, *bcount);
+}
+
+struct pipe_hyper_state {
+ const char *name;
+ unsigned long count;
+ unsigned long sleep;
+};
+
+void pipe_hyper_pull(
+ char * _state,
+ hyper * buf,
+ unsigned long esize,
+ unsigned long * ecount)
+{
+ struct pipe_hyper_state *state = (struct pipe_hyper_state *)_state;
+
+ printf("pull1:%s: esize[%u] ecount[%u]\n",
+ state->name, esize, *ecount);
+ *ecount = state->count--;
+ if (*ecount > esize) {
+ *ecount = esize;
+ }
+ memset(buf, 0xDD, *ecount * sizeof(*buf));
+ printf("pull2:%s: esize[%u] ecount[%u]\n",
+ state->name, esize, *ecount);
+}
+
+void pipe_hyper_push(
+ char * _state,
+ hyper * buf,
+ unsigned long ecount)
+{
+ struct pipe_hyper_state *state = (struct pipe_hyper_state *)_state;
+
+ printf("push:%s: ecount[%u]\n",
+ state->name, ecount);
+}
+
+void pipe_hyper_alloc(
+ char * _state,
+ unsigned long bsize,
+ hyper * * buf,
+ unsigned long * bcount)
+{
+ struct pipe_hyper_state *state = (struct pipe_hyper_state *)_state;
+
+ printf("alloc1:%s: bsize[%u], bcount[%u]\n",
+ state->name, bsize, *bcount);
+ *bcount = bsize / sizeof(**buf);
+ *buf = malloc(*bcount * sizeof(**buf));
+ printf("alloc2:%s: bsize[%u], bcount[%u]\n",
+ state->name, bsize, *bcount);
+}
+struct pipe_structtype_state {
+ const char *name;
+ unsigned long count;
+ unsigned long sleep;
+};
+
+void pipe_structtype_pull(
+ char * _state,
+ structtype * buf,
+ unsigned long esize,
+ unsigned long * ecount)
+{
+ struct pipe_structtype_state *state = (struct pipe_structtype_state *)_state;
+
+ printf("pull1:%s: esize[%u] ecount[%u]\n",
+ state->name, esize, *ecount);
+ *ecount = state->count--;
+ if (*ecount > esize) {
+ *ecount = esize;
+ }
+ memset(buf, 0xDD, *ecount * sizeof(*buf));
+ printf("pull2:%s: esize[%u] ecount[%u]\n",
+ state->name, esize, *ecount);
+}
+
+void pipe_structtype_push(
+ char * _state,
+ structtype * buf,
+ unsigned long ecount)
+{
+ struct pipe_structtype_state *state = (struct pipe_structtype_state *)_state;
+
+ printf("push:%s: ecount[%u]\n",
+ state->name, ecount);
+}
+
+void pipe_structtype_alloc(
+ char * _state,
+ unsigned long bsize,
+ structtype * * buf,
+ unsigned long * bcount)
+{
+ struct pipe_structtype_state *state = (struct pipe_structtype_state *)_state;
+
+ printf("alloc1:%s: bsize[%u], bcount[%u]\n",
+ state->name, bsize, *bcount);
+ *bcount = bsize / sizeof(**buf);
+ *buf = malloc(*bcount * sizeof(**buf));
+ printf("alloc2:%s: bsize[%u], bcount[%u]\n",
+ state->name, bsize, *bcount);
+}
+static void midltests(void)
+{
+ struct msg out1;
+ unsigned char out1b[3];
+ struct pipe_structtype_state outs;
+ pipe_structtype outp;
+ struct pipe_structtype_state ins;
+ pipe_structtype inp;
+ struct msg in1;
+ unsigned char in1b[3];
+
+ in1.l = sizeof(in1b);
+ memset(&in1b, 0xAA, sizeof(in1b));
+ in1.m = in1b;
+
+ memset(&outs, 0, sizeof(outs));
+ outs.name = "outp";
+ memset(&outp, 0, sizeof(outp));
+ outp.pull = pipe_structtype_pull;
+ outp.push = pipe_structtype_push;
+ outp.alloc = pipe_structtype_alloc;
+ outp.state = (char *)&outs;
+
+ memset(&ins, 0, sizeof(ins));
+ ins.name = "inp";
+ ins.count = 1;
+ memset(&inp, 0, sizeof(inp));
+ inp.pull = pipe_structtype_pull;
+ inp.push = pipe_structtype_push;
+ inp.alloc = pipe_structtype_alloc;
+ inp.state = (char *)&ins;
+
+ out1.l = sizeof(out1b);
+ memset(&out1b, 0xFF, sizeof(out1b));
+ out1.m = out1b;
+
+ cli_midltests_ping(in1);
+ cli_midltests_fn(&out1, outp, inp, in1);
+}
+
+long srv_midltests_fn(
+ /* [ref][out] */ struct msg *out1,
+ /* [out] */ pipe_structtype outp,
+ /* [in] */ pipe_structtype inp,
+ /* [in] */ struct msg in1)
+{
+ structtype inb[500];
+ unsigned long inb_len = 0;
+ structtype *outb = NULL;
+ unsigned long outb_size = 0;
+ unsigned long outb_len = 0;
+
+ printf("srv_midltests_fn: Start\n");
+
+ do {
+ inp.pull(inp.state, inb, sizeof(inb), &inb_len);
+ printf("pull inp_len[%u]\n", inb_len);
+ } while (inb_len > 0);
+
+ outb_size = 5;
+ do {
+ outp.alloc(outp.state, outb_size, &outb, &outb_len);
+ memset(outb, 0xCC, outb_len * sizeof(*outb));
+ outp.push(outp.state, outb, outb_len);
+ printf("push outb_len[%u]\n", outb_len);
+ //Sleep(1000);
+ outb_size--;
+ } while (outb_len > 0);
+
+ out1->l = 3;
+ out1->m = (unsigned char *)malloc(out1->l);
+ memset(out1->m, 0xBB, out1->l);
+ printf("srv_midltests_fn: End\n");
+ return 0x65757254;
+}
+
+long srv_midltests_ping(
+ /* [in] */ struct msg in1)
+{
+ printf("srv_midltests_fn: Start\n");
+ printf("srv_midltests_fn: End\n");
+ return 0x65757254;
+}
+#endif
diff --git a/testprogs/win32/midltests/todo/midltests-pipe-first.idl b/testprogs/win32/midltests/todo/midltests-pipe-first.idl
new file mode 100755
index 0000000..ef28943
--- /dev/null
+++ b/testprogs/win32/midltests/todo/midltests-pipe-first.idl
@@ -0,0 +1,233 @@
+#ifndef MIDLTESTS_C_CODE
+[
+ uuid("225b9fcb-eb3d-497b-8b0b-591f049a2507"),
+ pointer_default(unique)
+]
+interface midltests
+{
+/* typedef struct st_wire {
+ long len;
+ //[size_is(len)] char data[*];
+ [size_is(l2)] char *d2;
+ long l2;
+ } st_wire_t;
+ struct st_local {
+ short s1;
+ short s2;
+ };
+ typedef [transmit_as(st_wire_t)] struct st_local st_local_t;
+
+ long midltests_fn(
+ [in] st_local_t st
+
+ );
+*/
+/* struct my_ace {
+ long ace1;
+ long ace2;
+ };
+ struct my_acl {
+ long revision;
+ long num_aces;
+ [size_is(num_aces)] struct my_ace *aces;
+ };
+ long midltests_fn(
+ [in,ref] struct my_acl *acl
+ );
+*/
+/* struct my_str {
+ long l1;
+ [string] wchar_t str[260+1];
+ long l2;
+ };
+ long midltests_fn(
+ [in,out,ref] struct my_str *str
+ );
+*/
+ long foo();
+ long midltests_fn(
+ [in] long size,
+ [out,ref,size_is(size),length_is(*length)] byte *bytes,
+ [out,ref] long *length
+ );
+
+ typedef pipe byte BYTE_PIPE;
+ typedef pipe long LONG_PIPE;
+
+ long midltests_fn_pipe(
+ [in] long count,
+ [out,ref] long *start_magic,
+ [out] BYTE_PIPE b,
+ [out, ref] long *mid_magic,
+ [out] LONG_PIPE l,
+ [out,ref] long *end_magic
+ );
+
+}
+#elif MIDLTESTS_C_CODE
+/*
+void __RPC_USER st_local_t_to_xmit(st_local_t *l, st_wire_t **w)
+{
+ *w = malloc(4+ sizeof(st_wire_t));
+ (*w)->len = sizeof(st_local_t);
+ //(*w)->data = malloc((*w)->len);
+ memcpy((*w)->data, l, sizeof(st_local_t));
+ //memset(*w, 0xcd, sizeof(st_wire_t));
+}
+
+void __RPC_USER st_local_t_from_xmit(st_wire_t *w, st_local_t *l)
+{
+ memcpy(l, w->data, sizeof(st_local_t));
+// memset(l, 0, sizeof(st_local_t));
+}
+
+void __RPC_USER st_local_t_free_inst(st_local_t *l)
+{
+
+}
+
+void __RPC_USER st_local_t_free_xmit(st_wire_t *w)
+{
+ //free(w->data);
+ free(w);
+}
+*/
+
+void __RPC_USER cli_push_b(char * state,
+ byte * buf,
+ unsigned long ecount)
+{
+ printf("cli_push_b ecount[%lu]\n", ecount);
+}
+
+void __RPC_USER cli_alloc_b(char * state,
+ unsigned long bsize,
+ byte * * buf,
+ unsigned long * bcount )
+{
+ printf("cli_alloc_b bsize[%lu]\n", bsize);
+ *buf = NULL;
+ *bcount = 0;
+}
+
+void __RPC_USER cli_push_l(char * state,
+ long * buf,
+ unsigned long ecount)
+{
+ printf("cli_push_l ecount[%lu]\n", ecount);
+}
+
+void __RPC_USER cli_alloc_l(char * state,
+ unsigned long bsize,
+ long * * buf,
+ unsigned long * bcount )
+{
+ printf("cli_alloc_l bsize[%lu]\n", bsize);
+ *buf = NULL;
+ *bcount = 0;
+}
+
+static void midltests()
+{
+/* st_local_t st;
+ st.s1 = 1;
+ st.s2 = 2;
+ cli_midltests_fn(st);
+*/
+/* struct my_acl acl;
+ struct my_ace aces[3];
+ aces[0].ace1 = 1;
+ aces[0].ace2 = 2;
+ aces[1].ace1 = 1;
+ aces[1].ace2 = 2;
+ aces[2].ace1 = 1;
+ aces[2].ace2 = 2;
+ acl.revision = 5;
+ acl.num_aces = 1;
+ acl.aces = aces;
+ cli_midltests_fn(&acl);
+*/
+/* struct my_str str;
+ memset(&str, 0, sizeof(str));
+ str.l1 = 1;
+ printf("here: %d\n", __LINE__);
+ //wcscpy(str.str, L'Hello World\0');
+ str.l2 = 2;
+ printf("here: %d\n", __LINE__);
+ cli_midltests_fn(&str);
+*/
+ byte buf[10];
+ long length = 0;
+ memset(buf, 0xdf, sizeof(buf));
+// cli_midltests_fn(sizeof(buf), buf, &length);
+
+/* long count = 2;
+ long start_magic;
+ BYTE_PIPE b;
+ long mid_magic;
+ LONG_PIPE l;
+ long end_magic;
+
+
+ memset(&b, 0, sizeof(b));
+ memset(&l, 0, sizeof(l));
+
+ b.alloc = cli_alloc_b;
+ b.push = cli_push_b;
+
+ l.alloc = cli_alloc_l;
+ l.push = cli_push_l;
+
+ printf("cli call start\n");
+ cli_midltests_fn(count,
+ &start_magic,
+ b,
+ &mid_magic,
+ l,
+ &end_magic);
+ printf("cli call end\n");
+*/
+}
+
+//long srv_midltests_fn(struct my_str *str)//struct my_acl *acl)//st_local_t st)
+//long srv_midltests_fn(long size, byte *bytes, long *length)
+#if 1
+long srv_midltests_fn(
+ /* [in] */ long count,
+ /* [ref][out] */ long *start_magic,
+ /* [out] */ BYTE_PIPE b,
+ /* [ref][out] */ long *mid_magic,
+ /* [out] */ LONG_PIPE l,
+ /* [ref][out] */ long *end_magic)
+#endif
+{
+/* byte bytes[10];
+ long longs[10];
+ int i;
+*/
+ printf("srv_midltests_fn: Start\n");
+ //printf("s1[%d] s2[%d]\n", st.s1, st.s2);
+ //printf(l1[%d] str[%s] l2[%d]\n", str->l1, str->str, str->l2);
+
+/* *start_magic = 0x01234567;
+ *mid_magic = 0x88888888;
+ *end_magic = 0xFEDCBA09;
+
+ memset(bytes, 0xBE, sizeof(bytes));
+ memset(longs, 0xAC, sizeof(longs));
+
+ for (i=0; i < count; i++) {
+ b.push(b.state, bytes, sizeof(bytes)/sizeof(bytes[0]));
+ }
+ b.push(b.state, NULL, 0);
+
+ for (i=0; i < count; i++) {
+ l.push(l.state, longs, sizeof(longs)/sizeof(longs[0]));
+ }
+ l.push(l.state, NULL, 0);
+*/
+ printf("srv_midltests_fn: End\n");
+ return 0x65757254;
+}
+
+#endif \ No newline at end of file
diff --git a/testprogs/win32/midltests/todo/midltests-pipe-sync-ndr32-downgrade-02.idl b/testprogs/win32/midltests/todo/midltests-pipe-sync-ndr32-downgrade-02.idl
new file mode 100644
index 0000000..760401e
--- /dev/null
+++ b/testprogs/win32/midltests/todo/midltests-pipe-sync-ndr32-downgrade-02.idl
@@ -0,0 +1,296 @@
+#ifndef MIDLTESTS_C_CODE
+
+/*
+ * For midltests_tcp.exe you may want to
+ * redirect the traffic via rinetd
+ * with a /etc/rinetd.conf like this:
+ *
+ * 172.31.9.1 5032 172.31.9.8 5032
+ * 172.31.9.1 5064 172.31.9.8 5064
+ *
+ * This is useful to watch the traffic with
+ * a network sniffer.
+ */
+
+cpp_quote("#define LISTEN_IP \"0.0.0.0\"")
+cpp_quote("#define FORWARD_IP \"127.0.0.1\"")
+cpp_quote("#define CONNECT_IP \"172.31.9.1\"")
+
+
+/*
+ * With midltests_tcp.exe NDR64 is enforced by default.
+ * For testing it might be needed to allow downgrades
+ * to NDR32. This is needed when you use 'pipe'.
+ */
+cpp_quote("#define DONOT_FORCE_NDR64 1")
+
+[
+ uuid("225b9fcb-eb3d-497b-8b0b-591f049a2507"),
+ pointer_default(unique)
+]
+interface midltests
+{
+ typedef pipe char pipe_char;
+ typedef pipe hyper pipe_hyper;
+ typedef struct {
+ long l;
+ short s;
+ } structtype;
+ typedef pipe structtype pipe_structtype;
+
+ struct msg {
+ long l;
+ [size_is(l)] char *m;
+ };
+
+ long midltests_fn(
+ [out,ref] struct msg *out1,
+ [out] pipe_structtype outp,
+ [in] pipe_structtype inp,
+ [in] struct msg in1
+ );
+
+ long midltests_ping( [in] struct msg in1);
+
+}
+
+#elif MIDLTESTS_C_CODE
+
+struct pipe_char_state {
+ const char *name;
+ unsigned long count;
+ unsigned long sleep;
+};
+
+void pipe_char_pull(
+ char * _state,
+ unsigned char * buf,
+ unsigned long esize,
+ unsigned long * ecount)
+{
+ struct pipe_char_state *state = (struct pipe_char_state *)_state;
+
+ printf("pull1:%s: esize[%u] ecount[%u]\n",
+ state->name, esize, *ecount);
+ *ecount = state->count--;
+ if (*ecount > esize) {
+ *ecount = esize;
+ }
+ memset(buf, 0xDD, *ecount * sizeof(*buf));
+ printf("pull2:%s: esize[%u] ecount[%u]\n",
+ state->name, esize, *ecount);
+}
+
+void pipe_char_push(
+ char * _state,
+ unsigned char * buf,
+ unsigned long ecount)
+{
+ struct pipe_char_state *state = (struct pipe_char_state *)_state;
+
+ printf("push:%s: ecount[%u]\n",
+ state->name, ecount);
+}
+
+void pipe_char_alloc(
+ char * _state,
+ unsigned long bsize,
+ unsigned char * * buf,
+ unsigned long * bcount)
+{
+ struct pipe_char_state *state = (struct pipe_char_state *)_state;
+
+ printf("alloc1:%s: bsize[%u], bcount[%u]\n",
+ state->name, bsize, *bcount);
+ *bcount = bsize / sizeof(**buf);
+ *buf = malloc(*bcount * sizeof(**buf));
+ printf("alloc2:%s: bsize[%u], bcount[%u]\n",
+ state->name, bsize, *bcount);
+}
+
+struct pipe_hyper_state {
+ const char *name;
+ unsigned long count;
+ unsigned long sleep;
+};
+
+void pipe_hyper_pull(
+ char * _state,
+ hyper * buf,
+ unsigned long esize,
+ unsigned long * ecount)
+{
+ struct pipe_hyper_state *state = (struct pipe_hyper_state *)_state;
+
+ printf("pull1:%s: esize[%u] ecount[%u]\n",
+ state->name, esize, *ecount);
+ *ecount = state->count--;
+ if (*ecount > esize) {
+ *ecount = esize;
+ }
+ memset(buf, 0xDD, *ecount * sizeof(*buf));
+ printf("pull2:%s: esize[%u] ecount[%u]\n",
+ state->name, esize, *ecount);
+}
+
+void pipe_hyper_push(
+ char * _state,
+ hyper * buf,
+ unsigned long ecount)
+{
+ struct pipe_hyper_state *state = (struct pipe_hyper_state *)_state;
+
+ printf("push:%s: ecount[%u]\n",
+ state->name, ecount);
+}
+
+void pipe_hyper_alloc(
+ char * _state,
+ unsigned long bsize,
+ hyper * * buf,
+ unsigned long * bcount)
+{
+ struct pipe_hyper_state *state = (struct pipe_hyper_state *)_state;
+
+ printf("alloc1:%s: bsize[%u], bcount[%u]\n",
+ state->name, bsize, *bcount);
+ *bcount = bsize / sizeof(**buf);
+ *buf = malloc(*bcount * sizeof(**buf));
+ printf("alloc2:%s: bsize[%u], bcount[%u]\n",
+ state->name, bsize, *bcount);
+}
+struct pipe_structtype_state {
+ const char *name;
+ unsigned long count;
+ unsigned long sleep;
+};
+
+void pipe_structtype_pull(
+ char * _state,
+ structtype * buf,
+ unsigned long esize,
+ unsigned long * ecount)
+{
+ struct pipe_structtype_state *state = (struct pipe_structtype_state *)_state;
+
+ printf("pull1:%s: esize[%u] ecount[%u]\n",
+ state->name, esize, *ecount);
+ *ecount = state->count--;
+ if (*ecount > esize) {
+ *ecount = esize;
+ }
+ memset(buf, 0xDD, *ecount * sizeof(*buf));
+ printf("pull2:%s: esize[%u] ecount[%u]\n",
+ state->name, esize, *ecount);
+}
+
+void pipe_structtype_push(
+ char * _state,
+ structtype * buf,
+ unsigned long ecount)
+{
+ struct pipe_structtype_state *state = (struct pipe_structtype_state *)_state;
+
+ printf("push:%s: ecount[%u]\n",
+ state->name, ecount);
+}
+
+void pipe_structtype_alloc(
+ char * _state,
+ unsigned long bsize,
+ structtype * * buf,
+ unsigned long * bcount)
+{
+ struct pipe_structtype_state *state = (struct pipe_structtype_state *)_state;
+
+ printf("alloc1:%s: bsize[%u], bcount[%u]\n",
+ state->name, bsize, *bcount);
+ *bcount = bsize / sizeof(**buf);
+ *buf = malloc(*bcount * sizeof(**buf));
+ printf("alloc2:%s: bsize[%u], bcount[%u]\n",
+ state->name, bsize, *bcount);
+}
+static void midltests(void)
+{
+ struct msg out1;
+ unsigned char out1b[3];
+ struct pipe_structtype_state outs;
+ pipe_structtype outp;
+ struct pipe_structtype_state ins;
+ pipe_structtype inp;
+ struct msg in1;
+ unsigned char in1b[5000];
+
+ in1.l = sizeof(in1b);
+ memset(&in1b, 0xAA, sizeof(in1b));
+ in1.m = in1b;
+
+ memset(&outs, 0, sizeof(outs));
+ outs.name = "outp";
+ memset(&outp, 0, sizeof(outp));
+ outp.pull = pipe_structtype_pull;
+ outp.push = pipe_structtype_push;
+ outp.alloc = pipe_structtype_alloc;
+ outp.state = (char *)&outs;
+
+ memset(&ins, 0, sizeof(ins));
+ ins.name = "inp";
+ ins.count = 100;
+ memset(&inp, 0, sizeof(inp));
+ inp.pull = pipe_structtype_pull;
+ inp.push = pipe_structtype_push;
+ inp.alloc = pipe_structtype_alloc;
+ inp.state = (char *)&ins;
+
+ out1.l = sizeof(out1b);
+ memset(&out1b, 0xFF, sizeof(out1b));
+ out1.m = out1b;
+
+ cli_midltests_ping(in1);
+ cli_midltests_fn(&out1, outp, inp, in1);
+}
+
+long srv_midltests_fn(
+ /* [ref][out] */ struct msg *out1,
+ /* [out] */ pipe_structtype outp,
+ /* [in] */ pipe_structtype inp,
+ /* [in] */ struct msg in1)
+{
+ structtype inb[500];
+ unsigned long inb_len = 0;
+ structtype *outb = NULL;
+ unsigned long outb_size = 0;
+ unsigned long outb_len = 0;
+
+ printf("srv_midltests_fn: Start\n");
+
+ do {
+ inp.pull(inp.state, inb, sizeof(inb), &inb_len);
+ printf("pull inp_len[%u]\n", inb_len);
+ } while (inb_len > 0);
+
+ outb_size = 5;
+ do {
+ outp.alloc(outp.state, outb_size, &outb, &outb_len);
+ memset(outb, 0xCC, outb_len * sizeof(*outb));
+ outp.push(outp.state, outb, outb_len);
+ printf("push outb_len[%u]\n", outb_len);
+ //Sleep(1000);
+ outb_size--;
+ } while (outb_len > 0);
+
+ out1->l = 3;
+ out1->m = (unsigned char *)malloc(out1->l);
+ memset(out1->m, 0xBB, out1->l);
+ printf("srv_midltests_fn: End\n");
+ return 0x65757254;
+}
+
+long srv_midltests_ping(
+ /* [in] */ struct msg in1)
+{
+ printf("srv_midltests_fn: Start\n");
+ printf("srv_midltests_fn: End\n");
+ return 0x65757254;
+}
+#endif
diff --git a/testprogs/win32/midltests/todo/midltests-string-in-out-ref.idl b/testprogs/win32/midltests/todo/midltests-string-in-out-ref.idl
new file mode 100644
index 0000000..4db6f96
--- /dev/null
+++ b/testprogs/win32/midltests/todo/midltests-string-in-out-ref.idl
@@ -0,0 +1,33 @@
+#ifndef MIDLTESTS_C_CODE
+
+[
+ uuid("225b9fcb-eb3d-497b-8b0b-591f049a2507"),
+ pointer_default(unique)
+]
+interface midltests
+{
+ long midltests_fn(
+ [in,out,ref,string] wchar_t *s
+ );
+}
+
+#elif MIDLTESTS_C_CODE
+
+static void midltests(void)
+{
+ wchar_t s[] = { 's', 'a', 'm', 'b', 'a', 0 };
+
+ cli_midltests_fn(s);
+}
+
+long srv_midltests_fn(wchar_t *s)
+{
+ printf("srv_midltests_fn: Start\n");
+ s[1] = 0;
+ s[2] = 'M';
+ s[5] = '4';
+ printf("srv_midltests_fn: End\n");
+ return 0x65757254;
+}
+
+#endif
diff --git a/testprogs/win32/midltests/todo/midltests-transmit-as.idl b/testprogs/win32/midltests/todo/midltests-transmit-as.idl
new file mode 100755
index 0000000..bf5bc3f
--- /dev/null
+++ b/testprogs/win32/midltests/todo/midltests-transmit-as.idl
@@ -0,0 +1,59 @@
+#ifndef MIDLTESTS_C_CODE
+[
+ uuid("225b9fcb-eb3d-497b-8b0b-591f049a2507"),
+ pointer_default(unique)
+]
+interface midltests
+{
+ typedef struct st_wire {
+ char data[20];
+ } st_wire_t;
+ struct st_local {
+ short s1;
+ short s2;
+ };
+ typedef [transmit_as(st_wire_t)] struct st_local st_local_t;
+
+ long midltests_fn(
+ [in] st_local_t st
+ );
+}
+#elif MIDLTESTS_C_CODE
+
+void __RPC_USER st_local_t_to_xmit(st_local_t *l, st_wire_t **w)
+{
+ *w = malloc(sizeof(st_wire_t));
+ memset(*w, 0xcd, sizeof(st_wire_t));
+}
+
+void __RPC_USER st_local_t_from_xmit(st_wire_t *w, st_local_t *l)
+{
+ memset(l, 0, sizeof(st_local_t));
+}
+
+void __RPC_USER st_local_t_free_inst(st_local_t *l)
+{
+
+}
+
+void __RPC_USER st_local_t_free_xmit(st_wire_t *w)
+{
+ free(w);
+}
+
+static void midltests()
+{
+ char s[64];
+ st_local_t st;
+ strcpy(s, "TestString");
+ cli_midltests_fn(st);
+}
+
+long srv_midltests_fn(st_local_t st)
+{
+ printf("srv_midltests_fn: Start\n");
+ printf("srv_midltests_fn: End\n");
+ return 0x65757254;
+}
+
+#endif \ No newline at end of file
diff --git a/testprogs/win32/midltests/todo/midltests_pointer_default.idl b/testprogs/win32/midltests/todo/midltests_pointer_default.idl
new file mode 100755
index 0000000..9e0c18f
--- /dev/null
+++ b/testprogs/win32/midltests/todo/midltests_pointer_default.idl
@@ -0,0 +1,20 @@
+[
+ uuid("225b9fcb-eb3d-497b-8b0b-591f049a2507"),
+ pointer_default(ptr)
+]
+interface midltests
+{
+ struct midltests_struct {
+ [ref] long ****p;
+ [ref] long **a;
+ [ref] long **b;
+ [ref] long **c;
+ };
+
+ void midltests_fn(
+ //[in] long size,
+ [in,out,ref] struct midltests_struct *s
+ //[in,ref,size_is(,size)] long ***array
+ );
+
+} \ No newline at end of file
diff --git a/testprogs/win32/midltests/utils.c b/testprogs/win32/midltests/utils.c
new file mode 100644
index 0000000..8c4833d
--- /dev/null
+++ b/testprogs/win32/midltests/utils.c
@@ -0,0 +1,32 @@
+/*
+ MIDLTESTS utility functions.
+
+ Copyright (C) Tim Potter 2003
+
+ 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
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#include "midltests.h"
+
+/* MIDL allocate and free functions */
+
+void __RPC_FAR *__RPC_USER midl_user_allocate(size_t len)
+{
+ return(malloc(len));
+}
+
+void __RPC_USER midl_user_free(void __RPC_FAR *ptr)
+{
+ free(ptr);
+}
diff --git a/testprogs/win32/midltests/valid/README.txt b/testprogs/win32/midltests/valid/README.txt
new file mode 100644
index 0000000..9208fae
--- /dev/null
+++ b/testprogs/win32/midltests/valid/README.txt
@@ -0,0 +1,6 @@
+This directory contains IDL files which demonstrate
+the relationship between IDL definitions and NDR representation.
+
+In order to test them, you can compile them as midltests.idl.
+
+Note: some examples trigger runtime errors.
diff --git a/testprogs/win32/midltests/valid/midltests-pipe-sync-ndr32-downgrade-01.idl b/testprogs/win32/midltests/valid/midltests-pipe-sync-ndr32-downgrade-01.idl
new file mode 100644
index 0000000..26ef939
--- /dev/null
+++ b/testprogs/win32/midltests/valid/midltests-pipe-sync-ndr32-downgrade-01.idl
@@ -0,0 +1,296 @@
+#ifndef MIDLTESTS_C_CODE
+
+/*
+ * For midltests_tcp.exe you may want to
+ * redirect the traffic via rinetd
+ * with a /etc/rinetd.conf like this:
+ *
+ * 172.31.9.1 5032 172.31.9.8 5032
+ * 172.31.9.1 5064 172.31.9.8 5064
+ *
+ * This is useful to watch the traffic with
+ * a network sniffer.
+ */
+/*
+cpp_quote("#define LISTEN_IP \"0.0.0.0\"")
+cpp_quote("#define FORWARD_IP \"127.0.0.1\"")
+cpp_quote("#define CONNECT_IP \"172.31.9.1\"")
+*/
+
+/*
+ * With midltests_tcp.exe NDR64 is enforced by default.
+ * For testing it might be needed to allow downgrades
+ * to NDR32. This is needed when you use 'pipe'.
+ */
+cpp_quote("#define DONOT_FORCE_NDR64 1")
+
+[
+ uuid("225b9fcb-eb3d-497b-8b0b-591f049a2507"),
+ pointer_default(unique)
+]
+interface midltests
+{
+ typedef pipe char pipe_char;
+ typedef pipe hyper pipe_hyper;
+ typedef struct {
+ long l;
+ short s;
+ } structtype;
+ typedef pipe structtype pipe_structtype;
+
+ struct msg {
+ long l;
+ [size_is(l)] char *m;
+ };
+
+ long midltests_fn(
+ [out,ref] struct msg *out1,
+ [out] pipe_structtype outp,
+ [in] pipe_structtype inp,
+ [in] struct msg in1
+ );
+
+ long midltests_ping( [in] struct msg in1);
+
+}
+
+#elif MIDLTESTS_C_CODE
+
+struct pipe_char_state {
+ const char *name;
+ unsigned long count;
+ unsigned long sleep;
+};
+
+void pipe_char_pull(
+ char * _state,
+ unsigned char * buf,
+ unsigned long esize,
+ unsigned long * ecount)
+{
+ struct pipe_char_state *state = (struct pipe_char_state *)_state;
+
+ printf("pull1:%s: esize[%u] ecount[%u]\n",
+ state->name, esize, *ecount);
+ *ecount = state->count--;
+ if (*ecount > esize) {
+ *ecount = esize;
+ }
+ memset(buf, 0xDD, *ecount * sizeof(*buf));
+ printf("pull2:%s: esize[%u] ecount[%u]\n",
+ state->name, esize, *ecount);
+}
+
+void pipe_char_push(
+ char * _state,
+ unsigned char * buf,
+ unsigned long ecount)
+{
+ struct pipe_char_state *state = (struct pipe_char_state *)_state;
+
+ printf("push:%s: ecount[%u]\n",
+ state->name, ecount);
+}
+
+void pipe_char_alloc(
+ char * _state,
+ unsigned long bsize,
+ unsigned char * * buf,
+ unsigned long * bcount)
+{
+ struct pipe_char_state *state = (struct pipe_char_state *)_state;
+
+ printf("alloc1:%s: bsize[%u], bcount[%u]\n",
+ state->name, bsize, *bcount);
+ *bcount = bsize / sizeof(**buf);
+ *buf = malloc(*bcount * sizeof(**buf));
+ printf("alloc2:%s: bsize[%u], bcount[%u]\n",
+ state->name, bsize, *bcount);
+}
+
+struct pipe_hyper_state {
+ const char *name;
+ unsigned long count;
+ unsigned long sleep;
+};
+
+void pipe_hyper_pull(
+ char * _state,
+ hyper * buf,
+ unsigned long esize,
+ unsigned long * ecount)
+{
+ struct pipe_hyper_state *state = (struct pipe_hyper_state *)_state;
+
+ printf("pull1:%s: esize[%u] ecount[%u]\n",
+ state->name, esize, *ecount);
+ *ecount = state->count--;
+ if (*ecount > esize) {
+ *ecount = esize;
+ }
+ memset(buf, 0xDD, *ecount * sizeof(*buf));
+ printf("pull2:%s: esize[%u] ecount[%u]\n",
+ state->name, esize, *ecount);
+}
+
+void pipe_hyper_push(
+ char * _state,
+ hyper * buf,
+ unsigned long ecount)
+{
+ struct pipe_hyper_state *state = (struct pipe_hyper_state *)_state;
+
+ printf("push:%s: ecount[%u]\n",
+ state->name, ecount);
+}
+
+void pipe_hyper_alloc(
+ char * _state,
+ unsigned long bsize,
+ hyper * * buf,
+ unsigned long * bcount)
+{
+ struct pipe_hyper_state *state = (struct pipe_hyper_state *)_state;
+
+ printf("alloc1:%s: bsize[%u], bcount[%u]\n",
+ state->name, bsize, *bcount);
+ *bcount = bsize / sizeof(**buf);
+ *buf = malloc(*bcount * sizeof(**buf));
+ printf("alloc2:%s: bsize[%u], bcount[%u]\n",
+ state->name, bsize, *bcount);
+}
+struct pipe_structtype_state {
+ const char *name;
+ unsigned long count;
+ unsigned long sleep;
+};
+
+void pipe_structtype_pull(
+ char * _state,
+ structtype * buf,
+ unsigned long esize,
+ unsigned long * ecount)
+{
+ struct pipe_structtype_state *state = (struct pipe_structtype_state *)_state;
+
+ printf("pull1:%s: esize[%u] ecount[%u]\n",
+ state->name, esize, *ecount);
+ *ecount = state->count--;
+ if (*ecount > esize) {
+ *ecount = esize;
+ }
+ memset(buf, 0xDD, *ecount * sizeof(*buf));
+ printf("pull2:%s: esize[%u] ecount[%u]\n",
+ state->name, esize, *ecount);
+}
+
+void pipe_structtype_push(
+ char * _state,
+ structtype * buf,
+ unsigned long ecount)
+{
+ struct pipe_structtype_state *state = (struct pipe_structtype_state *)_state;
+
+ printf("push:%s: ecount[%u]\n",
+ state->name, ecount);
+}
+
+void pipe_structtype_alloc(
+ char * _state,
+ unsigned long bsize,
+ structtype * * buf,
+ unsigned long * bcount)
+{
+ struct pipe_structtype_state *state = (struct pipe_structtype_state *)_state;
+
+ printf("alloc1:%s: bsize[%u], bcount[%u]\n",
+ state->name, bsize, *bcount);
+ *bcount = bsize / sizeof(**buf);
+ *buf = malloc(*bcount * sizeof(**buf));
+ printf("alloc2:%s: bsize[%u], bcount[%u]\n",
+ state->name, bsize, *bcount);
+}
+static void midltests(void)
+{
+ struct msg out1;
+ unsigned char out1b[3];
+ struct pipe_structtype_state outs;
+ pipe_structtype outp;
+ struct pipe_structtype_state ins;
+ pipe_structtype inp;
+ struct msg in1;
+ unsigned char in1b[3];
+
+ in1.l = sizeof(in1b);
+ memset(&in1b, 0xAA, sizeof(in1b));
+ in1.m = in1b;
+
+ memset(&outs, 0, sizeof(outs));
+ outs.name = "outp";
+ memset(&outp, 0, sizeof(outp));
+ outp.pull = pipe_structtype_pull;
+ outp.push = pipe_structtype_push;
+ outp.alloc = pipe_structtype_alloc;
+ outp.state = (char *)&outs;
+
+ memset(&ins, 0, sizeof(ins));
+ ins.name = "inp";
+ ins.count = 1;
+ memset(&inp, 0, sizeof(inp));
+ inp.pull = pipe_structtype_pull;
+ inp.push = pipe_structtype_push;
+ inp.alloc = pipe_structtype_alloc;
+ inp.state = (char *)&ins;
+
+ out1.l = sizeof(out1b);
+ memset(&out1b, 0xFF, sizeof(out1b));
+ out1.m = out1b;
+
+ cli_midltests_ping(in1);
+ cli_midltests_fn(&out1, outp, inp, in1);
+}
+
+long srv_midltests_fn(
+ /* [ref][out] */ struct msg *out1,
+ /* [out] */ pipe_structtype outp,
+ /* [in] */ pipe_structtype inp,
+ /* [in] */ struct msg in1)
+{
+ structtype inb[500];
+ unsigned long inb_len = 0;
+ structtype *outb = NULL;
+ unsigned long outb_size = 0;
+ unsigned long outb_len = 0;
+
+ printf("srv_midltests_fn: Start\n");
+
+ do {
+ inp.pull(inp.state, inb, sizeof(inb), &inb_len);
+ printf("pull inp_len[%u]\n", inb_len);
+ } while (inb_len > 0);
+
+ outb_size = 5;
+ do {
+ outp.alloc(outp.state, outb_size, &outb, &outb_len);
+ memset(outb, 0xCC, outb_len * sizeof(*outb));
+ outp.push(outp.state, outb, outb_len);
+ printf("push outb_len[%u]\n", outb_len);
+ //Sleep(1000);
+ outb_size--;
+ } while (outb_len > 0);
+
+ out1->l = 3;
+ out1->m = (unsigned char *)malloc(out1->l);
+ memset(out1->m, 0xBB, out1->l);
+ printf("srv_midltests_fn: End\n");
+ return 0x65757254;
+}
+
+long srv_midltests_ping(
+ /* [in] */ struct msg in1)
+{
+ printf("srv_midltests_fn: Start\n");
+ printf("srv_midltests_fn: End\n");
+ return 0x65757254;
+}
+#endif
diff --git a/testprogs/win32/midltests/valid/midltests-pipe-sync-ndr32-downgrade-01.txt b/testprogs/win32/midltests/valid/midltests-pipe-sync-ndr32-downgrade-01.txt
new file mode 100644
index 0000000..1c8d003
--- /dev/null
+++ b/testprogs/win32/midltests/valid/midltests-pipe-sync-ndr32-downgrade-01.txt
@@ -0,0 +1,138 @@
+Wait for setup of server threads
+
+Test NDR32
+
+ndr32: disable NDR64
+
+ndr32:in => out: ptype[request] flen[39] plen[15]
+
+[000] 03 00 00 00 00 00 02 00 03 00 00 00 AA AA AA ........ .......
+
+srv_midltests_fn: Start
+srv_midltests_fn: End
+
+ndr32:out => in: ptype[response] flen[28] plen[4]
+
+[000] 54 72 75 65 True
+
+ndr32: got NDR32
+
+alloc1:inp: bsize[5000], bcount[0]
+alloc2:inp: bsize[5000], bcount[625]
+pull1:inp: esize[78] ecount[78]
+pull2:inp: esize[78] ecount[1]
+alloc1:inp: bsize[5000], bcount[625]
+alloc2:inp: bsize[5000], bcount[625]
+pull1:inp: esize[78] ecount[78]
+pull2:inp: esize[78] ecount[0]
+ndr32:in => out: ptype[alter_req] flen[72] call[3] contexts[1]
+
+
+ndr32:out => in: ptype[alter_ack] flen[56] call[3]
+
+ndr32:in => out: ptype[request] flen[56] plen[32]
+
+[000] 03 00 00 00 00 00 02 00 03 00 00 00 AA AA AA 00 ........ ........
+[010] 01 00 00 00 DD DD DD DD DD DD 08 00 00 00 00 00 ........ ........
+
+srv_midltests_fn: Start
+pull inp_len[1]
+pull inp_len[0]
+push outb_len[5]
+push outb_len[4]
+push outb_len[3]
+push outb_len[2]
+push outb_len[1]
+push outb_len[0]
+srv_midltests_fn: End
+
+ndr32:out => in: ptype[response] flen[188] plen[164]
+
+[000] 05 00 00 00 CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[010] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[020] CC CC CC CC CC CC CC CC CC CC 00 00 04 00 00 00 ........ ........
+[030] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[040] CC CC CC CC CC CC CC CC CC CC CC CC CC CC 00 00 ........ ........
+[050] 03 00 00 00 CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[060] CC CC CC CC CC CC CC CC CC CC 00 00 02 00 00 00 ........ ........
+[070] CC CC CC CC CC CC CC CC CC CC CC CC CC CC 00 00 ........ ........
+[080] 01 00 00 00 CC CC CC CC CC CC 00 00 00 00 00 00 ........ ........
+[090] 03 00 00 00 00 00 02 00 03 00 00 00 BB BB BB 00 ........ ........
+[0A0] 54 72 75 65 True
+
+alloc1:outp: bsize[6664], bcount[1]
+alloc2:outp: bsize[6664], bcount[833]
+push:outp: ecount[15]
+push:outp: ecount[0]
+NDRTcpThread[ndr32] stop
+
+Test NDR64
+
+ndr64: got NDR64
+
+ndr64:in => out: ptype[request] flen[51] plen[27]
+
+[000] 03 00 00 00 00 00 00 00 00 00 02 00 00 00 00 00 ........ ........
+[010] 03 00 00 00 00 00 00 00 AA AA AA ........ ...
+
+srv_midltests_fn: Start
+srv_midltests_fn: End
+
+ndr64:out => in: ptype[response] flen[28] plen[4]
+
+[000] 54 72 75 65 True
+
+
+ndr64: got NDR32 downgrade
+
+
+alloc1:inp: bsize[5000], bcount[0]
+alloc2:inp: bsize[5000], bcount[625]
+pull1:inp: esize[78] ecount[78]
+pull2:inp: esize[78] ecount[1]
+alloc1:inp: bsize[5000], bcount[625]
+alloc2:inp: bsize[5000], bcount[625]
+pull1:inp: esize[78] ecount[78]
+pull2:inp: esize[78] ecount[0]
+ndr64:in => out: ptype[alter_req] flen[72] call[3] contexts[1]
+
+
+ndr64:out => in: ptype[alter_ack] flen[56] call[3]
+
+ndr64:in => out: ptype[request] flen[56] plen[32]
+
+[000] 03 00 00 00 00 00 02 00 03 00 00 00 AA AA AA 00 ........ ........
+[010] 01 00 00 00 DD DD DD DD DD DD 00 00 00 00 00 00 ........ ........
+
+srv_midltests_fn: Start
+pull inp_len[1]
+pull inp_len[0]
+push outb_len[5]
+push outb_len[4]
+push outb_len[3]
+push outb_len[2]
+push outb_len[1]
+push outb_len[0]
+srv_midltests_fn: End
+
+ndr64:out => in: ptype[response] flen[188] plen[164]
+
+[000] 05 00 00 00 CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[010] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[020] CC CC CC CC CC CC CC CC CC CC 00 00 04 00 00 00 ........ ........
+[030] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[040] CC CC CC CC CC CC CC CC CC CC CC CC CC CC 00 00 ........ ........
+[050] 03 00 00 00 CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[060] CC CC CC CC CC CC CC CC CC CC 00 00 02 00 00 00 ........ ........
+[070] CC CC CC CC CC CC CC CC CC CC CC CC CC CC 00 00 ........ ........
+[080] 01 00 00 00 CC CC CC CC CC CC 00 00 00 00 00 00 ........ ........
+[090] 03 00 00 00 00 00 02 00 03 00 00 00 BB BB BB 00 ........ ........
+[0A0] 54 72 75 65 True
+
+alloc1:outp: bsize[6664], bcount[1]
+alloc2:outp: bsize[6664], bcount[833]
+push:outp: ecount[15]
+push:outp: ecount[0]
+NDRTcpThread[ndr64] stop
+
+Test OK
diff --git a/testprogs/win32/midltests/valid/midltests-pipe-sync-ndr32-downgrade-02.idl b/testprogs/win32/midltests/valid/midltests-pipe-sync-ndr32-downgrade-02.idl
new file mode 100644
index 0000000..888ba79
--- /dev/null
+++ b/testprogs/win32/midltests/valid/midltests-pipe-sync-ndr32-downgrade-02.idl
@@ -0,0 +1,300 @@
+#ifndef MIDLTESTS_C_CODE
+
+/*
+ * For midltests_tcp.exe you may want to
+ * redirect the traffic via rinetd
+ * with a /etc/rinetd.conf like this:
+ *
+ * 172.31.9.1 5032 172.31.9.8 5032
+ * 172.31.9.1 5064 172.31.9.8 5064
+ *
+ * This is useful to watch the traffic with
+ * a network sniffer.
+ */
+/*
+cpp_quote("#define LISTEN_IP \"0.0.0.0\"")
+cpp_quote("#define FORWARD_IP \"127.0.0.1\"")
+cpp_quote("#define CONNECT_IP \"172.31.9.1\"")
+*/
+
+/*
+ * With midltests_tcp.exe NDR64 is enforced by default.
+ * For testing it might be needed to allow downgrades
+ * to NDR32. This is needed when you use 'pipe'.
+ */
+cpp_quote("#define DONOT_FORCE_NDR64 1")
+
+[
+ uuid("225b9fcb-eb3d-497b-8b0b-591f049a2507"),
+ pointer_default(unique)
+]
+interface midltests
+{
+ typedef pipe char pipe_char;
+ typedef pipe hyper pipe_hyper;
+ typedef struct {
+ long l;
+ short s;
+ } structtype;
+ typedef pipe structtype pipe_structtype;
+
+ struct msg {
+ long l;
+ [size_is(l)] char *m;
+ };
+
+ long midltests_fn(
+ [out,ref] struct msg *out1,
+ [out] pipe_structtype outp,
+ [in] pipe_structtype inp,
+ [in] struct msg in1
+ );
+
+ long midltests_ping( [in] struct msg in1);
+
+}
+
+#elif MIDLTESTS_C_CODE
+
+struct pipe_char_state {
+ const char *name;
+ unsigned long count;
+ unsigned long sleep;
+};
+
+void pipe_char_pull(
+ char * _state,
+ unsigned char * buf,
+ unsigned long esize,
+ unsigned long * ecount)
+{
+ struct pipe_char_state *state = (struct pipe_char_state *)_state;
+
+ printf("pull1:%s: esize[%u] ecount[%u]\n",
+ state->name, esize, *ecount);
+ *ecount = state->count--;
+ if (*ecount > esize) {
+ *ecount = esize;
+ }
+ memset(buf, 0xDD, *ecount * sizeof(*buf));
+ printf("pull2:%s: esize[%u] ecount[%u]\n",
+ state->name, esize, *ecount);
+}
+
+void pipe_char_push(
+ char * _state,
+ unsigned char * buf,
+ unsigned long ecount)
+{
+ struct pipe_char_state *state = (struct pipe_char_state *)_state;
+
+ printf("push:%s: ecount[%u]\n",
+ state->name, ecount);
+}
+
+void pipe_char_alloc(
+ char * _state,
+ unsigned long bsize,
+ unsigned char * * buf,
+ unsigned long * bcount)
+{
+ struct pipe_char_state *state = (struct pipe_char_state *)_state;
+
+ printf("alloc1:%s: bsize[%u], bcount[%u]\n",
+ state->name, bsize, *bcount);
+ *bcount = bsize / sizeof(**buf);
+ *buf = malloc(*bcount * sizeof(**buf));
+ printf("alloc2:%s: bsize[%u], bcount[%u]\n",
+ state->name, bsize, *bcount);
+}
+
+struct pipe_hyper_state {
+ const char *name;
+ unsigned long count;
+ unsigned long sleep;
+};
+
+void pipe_hyper_pull(
+ char * _state,
+ hyper * buf,
+ unsigned long esize,
+ unsigned long * ecount)
+{
+ struct pipe_hyper_state *state = (struct pipe_hyper_state *)_state;
+
+ printf("pull1:%s: esize[%u] ecount[%u]\n",
+ state->name, esize, *ecount);
+ *ecount = state->count--;
+ if (*ecount > esize) {
+ *ecount = esize;
+ }
+ memset(buf, 0xDD, *ecount * sizeof(*buf));
+ printf("pull2:%s: esize[%u] ecount[%u]\n",
+ state->name, esize, *ecount);
+}
+
+void pipe_hyper_push(
+ char * _state,
+ hyper * buf,
+ unsigned long ecount)
+{
+ struct pipe_hyper_state *state = (struct pipe_hyper_state *)_state;
+
+ printf("push:%s: ecount[%u]\n",
+ state->name, ecount);
+}
+
+void pipe_hyper_alloc(
+ char * _state,
+ unsigned long bsize,
+ hyper * * buf,
+ unsigned long * bcount)
+{
+ struct pipe_hyper_state *state = (struct pipe_hyper_state *)_state;
+
+ printf("alloc1:%s: bsize[%u], bcount[%u]\n",
+ state->name, bsize, *bcount);
+ *bcount = bsize / sizeof(**buf);
+ *buf = malloc(*bcount * sizeof(**buf));
+ printf("alloc2:%s: bsize[%u], bcount[%u]\n",
+ state->name, bsize, *bcount);
+}
+struct pipe_structtype_state {
+ const char *name;
+ unsigned long count;
+ unsigned long sleep;
+};
+
+void pipe_structtype_pull(
+ char * _state,
+ structtype * buf,
+ unsigned long esize,
+ unsigned long * ecount)
+{
+ struct pipe_structtype_state *state = (struct pipe_structtype_state *)_state;
+
+ printf("pull1:%s: esize[%u] ecount[%u]\n",
+ state->name, esize, *ecount);
+ *ecount = state->count--;
+ if (*ecount > esize) {
+ *ecount = esize;
+ }
+ memset(buf, 0xDD, *ecount * sizeof(*buf));
+ printf("pull2:%s: esize[%u] ecount[%u]\n",
+ state->name, esize, *ecount);
+}
+
+void pipe_structtype_push(
+ char * _state,
+ structtype * buf,
+ unsigned long ecount)
+{
+ struct pipe_structtype_state *state = (struct pipe_structtype_state *)_state;
+
+ printf("push:%s: ecount[%u]\n",
+ state->name, ecount);
+}
+
+void pipe_structtype_alloc(
+ char * _state,
+ unsigned long bsize,
+ structtype * * buf,
+ unsigned long * bcount)
+{
+ struct pipe_structtype_state *state = (struct pipe_structtype_state *)_state;
+
+ printf("alloc1:%s: bsize[%u], bcount[%u]\n",
+ state->name, bsize, *bcount);
+ *bcount = bsize / sizeof(**buf);
+ *buf = malloc(*bcount * sizeof(**buf));
+ printf("alloc2:%s: bsize[%u], bcount[%u]\n",
+ state->name, bsize, *bcount);
+}
+static void midltests(void)
+{
+ struct msg out1;
+ unsigned char out1b[3];
+ struct pipe_structtype_state outs;
+ pipe_structtype outp;
+ struct pipe_structtype_state ins;
+ pipe_structtype inp;
+ struct msg in1;
+ unsigned char in1b[3000];
+
+ in1.l = sizeof(in1b);
+ memset(&in1b, 0xAA, sizeof(in1b));
+ in1.m = in1b;
+
+ memset(&outs, 0, sizeof(outs));
+ outs.name = "outp";
+ memset(&outp, 0, sizeof(outp));
+ outp.pull = pipe_structtype_pull;
+ outp.push = pipe_structtype_push;
+ outp.alloc = pipe_structtype_alloc;
+ outp.state = (char *)&outs;
+
+ memset(&ins, 0, sizeof(ins));
+ ins.name = "inp";
+ ins.count = 35;
+ memset(&inp, 0, sizeof(inp));
+ inp.pull = pipe_structtype_pull;
+ inp.push = pipe_structtype_push;
+ inp.alloc = pipe_structtype_alloc;
+ inp.state = (char *)&ins;
+
+ out1.l = sizeof(out1b);
+ memset(&out1b, 0xFF, sizeof(out1b));
+ out1.m = out1b;
+
+ cli_midltests_ping(in1);
+ cli_midltests_fn(&out1, outp, inp, in1);
+}
+
+long srv_midltests_fn(
+ /* [ref][out] */ struct msg *out1,
+ /* [out] */ pipe_structtype outp,
+ /* [in] */ pipe_structtype inp,
+ /* [in] */ struct msg in1)
+{
+ structtype inb[2500];
+ unsigned long inb_len = 0;
+ structtype *outb = NULL;
+ unsigned long outb_size = 0;
+ unsigned long outb_len = 0;
+
+ printf("srv_midltests_fn: Start\n");
+ fflush(stdout);
+
+ do {
+ inp.pull(inp.state, inb, sizeof(inb), &inb_len);
+ printf("pull inp_len[%u]\n", inb_len);
+ fflush(stdout);
+ } while (inb_len > 0);
+
+ outb_size = 50;
+ do {
+ outp.alloc(outp.state, outb_size, &outb, &outb_len);
+ memset(outb, 0xCC, outb_len * sizeof(*outb));
+ printf("push outb_len[%u]\n", outb_len);
+ fflush(stdout);
+ outp.push(outp.state, outb, outb_len);
+ //Sleep(1000);
+ outb_size--;
+ } while (outb_len > 0);
+
+ out1->l = 3;
+ out1->m = (unsigned char *)malloc(out1->l);
+ memset(out1->m, 0xBB, out1->l);
+ printf("srv_midltests_fn: End\n");
+ fflush(stdout);
+ return 0x65757254;
+}
+
+long srv_midltests_ping(
+ /* [in] */ struct msg in1)
+{
+ printf("srv_midltests_fn: Start\n");
+ printf("srv_midltests_fn: End\n");
+ return 0x65757254;
+}
+#endif
diff --git a/testprogs/win32/midltests/valid/midltests-pipe-sync-ndr32-downgrade-02.txt b/testprogs/win32/midltests/valid/midltests-pipe-sync-ndr32-downgrade-02.txt
new file mode 100644
index 0000000..9ae037e
--- /dev/null
+++ b/testprogs/win32/midltests/valid/midltests-pipe-sync-ndr32-downgrade-02.txt
@@ -0,0 +1,3266 @@
+Wait for setup of server threads
+
+Test NDR32
+
+ndr32: disable NDR64
+
+ndr32:in => out: ptype[request] flen[3036] plen[3012] ahint[3012]
+
+[000] B8 0B 00 00 00 00 02 00 B8 0B 00 00 AA AA AA AA ........ ........
+[010] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[020] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[030] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[040] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[050] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[060] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[070] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[080] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[090] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[0A0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[0B0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[0C0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[0D0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[0E0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[0F0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[100] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[110] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[120] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[130] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[140] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[150] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[160] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[170] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[180] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[190] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[1A0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[1B0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[1C0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[1D0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[1E0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[1F0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[200] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[210] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[220] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[230] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[240] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[250] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[260] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[270] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[280] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[290] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[2A0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[2B0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[2C0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[2D0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[2E0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[2F0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[300] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[310] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[320] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[330] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[340] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[350] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[360] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[370] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[380] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[390] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[3A0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[3B0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[3C0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[3D0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[3E0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[3F0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[400] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[410] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[420] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[430] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[440] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[450] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[460] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[470] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[480] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[490] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[4A0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[4B0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[4C0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[4D0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[4E0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[4F0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[500] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[510] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[520] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[530] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[540] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[550] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[560] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[570] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[580] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[590] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[5A0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[5B0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[5C0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[5D0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[5E0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[5F0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[600] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[610] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[620] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[630] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[640] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[650] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[660] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[670] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[680] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[690] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[6A0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[6B0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[6C0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[6D0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[6E0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[6F0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[700] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[710] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[720] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[730] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[740] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[750] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[760] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[770] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[780] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[790] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[7A0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[7B0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[7C0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[7D0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[7E0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[7F0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[800] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[810] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[820] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[830] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[840] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[850] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[860] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[870] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[880] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[890] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[8A0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[8B0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[8C0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[8D0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[8E0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[8F0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[900] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[910] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[920] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[930] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[940] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[950] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[960] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[970] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[980] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[990] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[9A0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[9B0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[9C0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[9D0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[9E0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[9F0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[A00] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[A10] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[A20] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[A30] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[A40] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[A50] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[A60] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[A70] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[A80] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[A90] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[AA0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[AB0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[AC0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[AD0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[AE0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[AF0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[B00] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[B10] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[B20] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[B30] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[B40] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[B50] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[B60] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[B70] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[B80] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[B90] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[BA0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[BB0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[BC0] AA AA AA AA ....
+
+srv_midltests_fn: Start
+srv_midltests_fn: End
+
+ndr32:out => in: ptype[response] flen[28] plen[4] ahint[4]
+
+[000] 54 72 75 65 True
+
+ndr32: disable NDR64
+
+alloc1:inp: bsize[5000], bcount[0]
+alloc2:inp: bsize[5000], bcount[625]
+pull1:inp: esize[78] ecount[78]
+pull2:inp: esize[78] ecount[35]
+alloc1:inp: bsize[5000], bcount[625]
+alloc2:inp: bsize[5000], bcount[625]
+pull1:inp: esize[78] ecount[78]
+pull2:inp: esize[78] ecount[34]
+alloc1:inp: bsize[5000], bcount[625]
+alloc2:inp: bsize[5000], bcount[625]
+pull1:inp: esize[78] ecount[78]
+pull2:inp: esize[78] ecount[33]
+alloc1:inp: bsize[5000], bcount[625]
+alloc2:inp: bsize[5000], bcount[625]
+pull1:inp: esize[78] ecount[78]
+pull2:inp: esize[78] ecount[32]
+alloc1:inp: bsize[5000], bcount[625]
+alloc2:inp: bsize[5000], bcount[625]
+pull1:inp: esize[78] ecount[78]
+pull2:inp: esize[78] ecount[31]
+alloc1:inp: bsize[5000], bcount[625]
+alloc2:inp: bsize[5000], bcount[625]
+pull1:inp: esize[78] ecount[78]
+pull2:inp: esize[78] ecount[30]
+alloc1:inp: bsize[5000], bcount[625]
+alloc2:inp: bsize[5000], bcount[625]
+pull1:inp: esize[78] ecount[78]
+pull2:inp: esize[78] ecount[29]
+alloc1:inp: bsize[5000], bcount[625]
+alloc2:inp: bsize[5000], bcount[625]
+pull1:inp: esize[78] ecount[78]
+pull2:inp: esize[78] ecount[28]
+alloc1:inp: bsize[5000], bcount[625]
+alloc2:inp: bsize[5000], bcount[625]
+pull1:inp: esize[78] ecount[78]
+pull2:inp: esize[78] ecount[27]
+alloc1:inp: bsize[5000], bcount[625]
+alloc2:inp: bsize[5000], bcount[625]
+pull1:inp: esize[78] ecount[78]
+pull2:inp: esize[78] ecount[26]
+alloc1:inp: bsize[5000], bcount[625]
+alloc2:inp: bsize[5000], bcount[625]
+pull1:inp: esize[78] ecount[78]
+pull2:inp: esize[78] ecount[25]
+alloc1:inp: bsize[5000], bcount[625]
+alloc2:inp: bsize[5000], bcount[625]
+pull1:inp: esize[78] ecount[78]
+pull2:inp: esize[78] ecount[24]
+alloc1:inp: bsize[5000], bcount[625]
+alloc2:inp: bsize[5000], bcount[625]
+pull1:inp: esize[78] ecount[78]
+pull2:inp: esize[78] ecount[23]
+alloc1:inp: bsize[5000], bcount[625]
+alloc2:inp: bsize[5000], bcount[625]
+pull1:inp: esize[78] ecount[78]
+pull2:inp: esize[78] ecount[22]
+alloc1:inp: bsize[5000], bcount[625]
+alloc2:inp: bsize[5000], bcount[625]
+pull1:inp: esize[78] ecount[78]
+pull2:inp: esize[78] ecount[21]
+alloc1:inp: bsize[5000], bcount[625]
+alloc2:inp: bsize[5000], bcount[625]
+pull1:inp: esize[78] ecount[78]
+pull2:inp: esize[78] ecount[20]
+alloc1:inp: bsize[5000], bcount[625]
+alloc2:inp: bsize[5000], bcount[625]
+pull1:inp: esize[78] ecount[78]
+pull2:inp: esize[78] ecount[19]
+alloc1:inp: bsize[5000], bcount[625]
+alloc2:inp: bsize[5000], bcount[625]
+pull1:inp: esize[78] ecount[78]
+pull2:inp: esize[78] ecount[18]
+alloc1:inp: bsize[5000], bcount[625]
+alloc2:inp: bsize[5000], bcount[625]
+pull1:inp: esize[78] ecount[78]
+pull2:inp: esize[78] ecount[17]
+alloc1:inp: bsize[5000], bcount[625]
+alloc2:inp: bsize[5000], bcount[625]
+pull1:inp: esize[78] ecount[78]
+pull2:inp: esize[78] ecount[16]
+alloc1:inp: bsize[5000], bcount[625]
+alloc2:inp: bsize[5000], bcount[625]
+pull1:inp: esize[78] ecount[78]
+pull2:inp: esize[78] ecount[15]
+alloc1:inp: bsize[5000], bcount[625]
+alloc2:inp: bsize[5000], bcount[625]
+pull1:inp: esize[78] ecount[78]
+pull2:inp: esize[78] ecount[14]
+alloc1:inp: bsize[5000], bcount[625]
+alloc2:inp: bsize[5000], bcount[625]
+pull1:inp: esize[78] ecount[78]
+pull2:inp: esize[78] ecount[13]
+alloc1:inp: bsize[5000], bcount[625]
+alloc2:inp: bsize[5000], bcount[625]
+pull1:inp: esize[78] ecount[78]
+pull2:inp: esize[78] ecount[12]
+alloc1:inp: bsize[5000], bcount[625]
+alloc2:inp: bsize[5000], bcount[625]
+pull1:inp: esize[78] ecount[78]
+pull2:inp: esize[78] ecount[11]
+alloc1:inp: bsize[5000], bcount[625]
+alloc2:inp: bsize[5000], bcount[625]
+pull1:inp: esize[78] ecount[78]
+pull2:inp: esize[78] ecount[10]
+alloc1:inp: bsize[5000], bcount[625]
+alloc2:inp: bsize[5000], bcount[625]
+pull1:inp: esize[78] ecount[78]
+pull2:inp: esize[78] ecount[9]
+alloc1:inp: bsize[5000], bcount[625]
+alloc2:inp: bsize[5000], bcount[625]
+pull1:inp: esize[78] ecount[78]
+pull2:inp: esize[78] ecount[8]
+alloc1:inp: bsize[5000], bcount[625]
+alloc2:inp: bsize[5000], bcount[625]
+pull1:inp: esize[78] ecount[78]
+pull2:inp: esize[78] ecount[7]
+alloc1:inp: bsize[5000], bcount[625]
+alloc2:inp: bsize[5000], bcount[625]
+pull1:inp: esize[78] ecount[78]
+pull2:inp: esize[78] ecount[6]
+alloc1:inp: bsize[5000], bcount[625]
+alloc2:inp: bsize[5000], bcount[625]
+pull1:inp: esize[78] ecount[78]
+pull2:inp: esize[78] ecount[5]
+alloc1:inp: bsize[5000], bcount[625]
+alloc2:inp: bsize[5000], bcount[625]
+pull1:inp: esize[78] ecount[78]
+pull2:inp: esize[78] ecount[4]
+alloc1:inp: bsize[5000], bcount[625]
+alloc2:inp: bsize[5000], bcount[625]
+pull1:inp: esize[78] ecount[78]
+pull2:inp: esize[78] ecount[3]
+alloc1:inp: bsize[5000], bcount[625]
+alloc2:inp: bsize[5000], bcount[625]
+pull1:inp: esize[78] ecount[78]
+pull2:inp: esize[78] ecount[2]
+alloc1:inp: bsize[5000], bcount[625]
+alloc2:inp: bsize[5000], bcount[625]
+pull1:inp: esize[78] ecount[78]
+pull2:inp: esize[78] ecount[1]
+alloc1:inp: bsize[5000], bcount[625]
+alloc2:inp: bsize[5000], bcount[625]
+pull1:inp: esize[78] ecount[78]
+pull2:inp: esize[78] ecount[0]
+ndr32:in => out: ptype[request] flen[5840] plen[5816] ahint[3012]
+
+[000] B8 0B 00 00 00 00 02 00 B8 0B 00 00 AA AA AA AA ........ ........
+[010] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[020] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[030] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[040] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[050] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[060] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[070] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[080] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[090] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[0A0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[0B0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[0C0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[0D0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[0E0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[0F0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[100] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[110] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[120] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[130] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[140] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[150] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[160] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[170] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[180] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[190] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[1A0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[1B0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[1C0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[1D0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[1E0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[1F0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[200] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[210] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[220] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[230] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[240] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[250] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[260] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[270] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[280] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[290] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[2A0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[2B0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[2C0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[2D0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[2E0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[2F0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[300] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[310] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[320] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[330] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[340] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[350] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[360] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[370] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[380] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[390] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[3A0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[3B0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[3C0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[3D0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[3E0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[3F0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[400] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[410] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[420] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[430] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[440] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[450] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[460] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[470] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[480] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[490] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[4A0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[4B0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[4C0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[4D0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[4E0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[4F0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[500] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[510] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[520] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[530] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[540] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[550] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[560] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[570] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[580] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[590] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[5A0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[5B0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[5C0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[5D0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[5E0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[5F0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[600] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[610] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[620] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[630] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[640] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[650] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[660] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[670] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[680] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[690] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[6A0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[6B0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[6C0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[6D0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[6E0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[6F0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[700] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[710] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[720] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[730] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[740] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[750] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[760] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[770] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[780] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[790] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[7A0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[7B0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[7C0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[7D0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[7E0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[7F0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[800] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[810] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[820] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[830] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[840] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[850] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[860] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[870] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[880] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[890] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[8A0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[8B0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[8C0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[8D0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[8E0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[8F0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[900] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[910] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[920] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[930] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[940] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[950] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[960] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[970] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[980] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[990] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[9A0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[9B0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[9C0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[9D0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[9E0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[9F0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[A00] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[A10] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[A20] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[A30] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[A40] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[A50] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[A60] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[A70] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[A80] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[A90] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[AA0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[AB0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[AC0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[AD0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[AE0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[AF0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[B00] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[B10] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[B20] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[B30] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[B40] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[B50] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[B60] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[B70] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[B80] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[B90] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[BA0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[BB0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[BC0] AA AA AA AA 23 00 00 00 DD DD DD DD DD DD DD DD ....#... ........
+[BD0] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[BE0] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[BF0] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[C00] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[C10] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[C20] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[C30] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[C40] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[C50] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[C60] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[C70] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[C80] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[C90] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[CA0] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[CB0] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[CC0] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[CD0] DD DD DD DD DD DD DD DD DD DD DD DD DD DD 00 00 ........ ........
+[CE0] 22 00 00 00 DD DD DD DD DD DD DD DD DD DD DD DD "....... ........
+[CF0] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[D00] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[D10] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[D20] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[D30] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[D40] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[D50] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[D60] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[D70] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[D80] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[D90] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[DA0] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[DB0] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[DC0] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[DD0] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[DE0] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[DF0] DD DD 00 00 21 00 00 00 DD DD DD DD DD DD DD DD ....!... ........
+[E00] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[E10] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[E20] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[E30] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[E40] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[E50] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[E60] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[E70] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[E80] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[E90] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[EA0] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[EB0] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[EC0] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[ED0] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[EE0] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[EF0] DD DD DD DD DD DD DD DD DD DD DD DD DD DD 00 00 ........ ........
+[F00] 20 00 00 00 DD DD DD DD DD DD DD DD DD DD DD DD ....... ........
+[F10] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[F20] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[F30] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[F40] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[F50] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[F60] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[F70] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[F80] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[F90] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[FA0] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[FB0] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[FC0] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[FD0] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[FE0] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[FF0] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[1000] DD DD 00 00 1F 00 00 00 DD DD DD DD DD DD DD DD ........ ........
+[1010] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[1020] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[1030] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[1040] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[1050] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[1060] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[1070] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[1080] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[1090] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[10A0] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[10B0] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[10C0] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[10D0] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[10E0] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[10F0] DD DD DD DD DD DD DD DD DD DD DD DD DD DD 00 00 ........ ........
+[1100] 1E 00 00 00 DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[1110] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[1120] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[1130] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[1140] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[1150] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[1160] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[1170] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[1180] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[1190] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[11A0] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[11B0] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[11C0] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[11D0] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[11E0] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[11F0] DD DD 00 00 1D 00 00 00 DD DD DD DD DD DD DD DD ........ ........
+[1200] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[1210] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[1220] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[1230] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[1240] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[1250] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[1260] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[1270] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[1280] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[1290] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[12A0] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[12B0] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[12C0] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[12D0] DD DD DD DD DD DD DD DD DD DD DD DD DD DD 00 00 ........ ........
+[12E0] 1C 00 00 00 DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[12F0] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[1300] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[1310] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[1320] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[1330] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[1340] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[1350] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[1360] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[1370] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[1380] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[1390] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[13A0] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[13B0] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[13C0] DD DD 00 00 1B 00 00 00 DD DD DD DD DD DD DD DD ........ ........
+[13D0] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[13E0] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[13F0] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[1400] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[1410] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[1420] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[1430] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[1440] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[1450] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[1460] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[1470] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[1480] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[1490] DD DD DD DD DD DD DD DD DD DD DD DD DD DD 00 00 ........ ........
+[14A0] 1A 00 00 00 DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[14B0] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[14C0] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[14D0] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[14E0] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[14F0] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[1500] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[1510] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[1520] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[1530] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[1540] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[1550] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[1560] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[1570] DD DD 00 00 19 00 00 00 DD DD DD DD DD DD DD DD ........ ........
+[1580] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[1590] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[15A0] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[15B0] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[15C0] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[15D0] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[15E0] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[15F0] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[1600] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[1610] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[1620] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[1630] DD DD DD DD DD DD DD DD DD DD DD DD DD DD 00 00 ........ ........
+[1640] 18 00 00 00 DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[1650] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[1660] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[1670] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[1680] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[1690] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[16A0] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[16B0] DD DD DD DD DD DD DD DD ........
+
+srv_midltests_fn: Start
+pull inp_len[344]
+ndr32:in => out: ptype[request] flen[2404] plen[2380] ahint[2380]
+
+[000] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[010] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[020] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[030] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[040] DD DD DD DD DD DD DD DD DD DD 00 00 17 00 00 00 ........ ........
+[050] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[060] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[070] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[080] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[090] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[0A0] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[0B0] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[0C0] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[0D0] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[0E0] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[0F0] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[100] DD DD DD DD DD DD AA AA 16 00 00 00 DD DD DD DD ........ ........
+[110] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[120] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[130] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[140] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[150] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[160] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[170] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[180] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[190] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[1A0] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[1B0] DD DD DD DD DD DD DD DD DD DD AA AA 15 00 00 00 ........ ........
+[1C0] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[1D0] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[1E0] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[1F0] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[200] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[210] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[220] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[230] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[240] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[250] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[260] DD DD DD DD DD DD AA AA 14 00 00 00 DD DD DD DD ........ ........
+[270] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[280] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[290] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[2A0] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[2B0] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[2C0] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[2D0] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[2E0] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[2F0] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[300] DD DD DD DD DD DD DD DD DD DD AA AA 13 00 00 00 ........ ........
+[310] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[320] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[330] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[340] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[350] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[360] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[370] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[380] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[390] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[3A0] DD DD DD DD DD DD AA AA 12 00 00 00 DD DD DD DD ........ ........
+[3B0] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[3C0] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[3D0] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[3E0] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[3F0] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[400] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[410] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[420] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[430] DD DD DD DD DD DD DD DD DD DD AA AA 11 00 00 00 ........ ........
+[440] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[450] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[460] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[470] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[480] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[490] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[4A0] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[4B0] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[4C0] DD DD DD DD DD DD AA AA 10 00 00 00 DD DD DD DD ........ ........
+[4D0] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[4E0] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[4F0] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[500] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[510] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[520] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[530] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[540] DD DD DD DD DD DD DD DD DD DD AA AA 0F 00 00 00 ........ ........
+[550] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[560] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[570] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[580] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[590] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[5A0] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[5B0] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[5C0] DD DD DD DD DD DD AA AA 0E 00 00 00 DD DD DD DD ........ ........
+[5D0] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[5E0] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[5F0] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[600] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[610] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[620] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[630] DD DD DD DD DD DD DD DD DD DD AA AA 0D 00 00 00 ........ ........
+[640] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[650] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[660] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[670] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[680] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[690] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[6A0] DD DD DD DD DD DD AA AA 0C 00 00 00 DD DD DD DD ........ ........
+[6B0] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[6C0] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[6D0] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[6E0] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[6F0] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[700] DD DD DD DD DD DD DD DD DD DD AA AA 0B 00 00 00 ........ ........
+[710] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[720] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[730] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[740] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[750] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[760] DD DD DD DD DD DD AA AA 0A 00 00 00 DD DD DD DD ........ ........
+[770] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[780] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[790] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[7A0] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[7B0] DD DD DD DD DD DD DD DD DD DD AA AA 09 00 00 00 ........ ........
+[7C0] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[7D0] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[7E0] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[7F0] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[800] DD DD DD DD DD DD AA AA 08 00 00 00 DD DD DD DD ........ ........
+[810] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[820] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[830] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[840] DD DD DD DD DD DD DD DD DD DD AA AA 07 00 00 00 ........ ........
+[850] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[860] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[870] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[880] DD DD DD DD DD DD AA AA 06 00 00 00 DD DD DD DD ........ ........
+[890] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[8A0] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[8B0] DD DD DD DD DD DD DD DD DD DD AA AA 05 00 00 00 ........ ........
+[8C0] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[8D0] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[8E0] DD DD DD DD DD DD AA AA 04 00 00 00 DD DD DD DD ........ ........
+[8F0] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[900] DD DD DD DD DD DD DD DD DD DD AA AA 03 00 00 00 ........ ........
+[910] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[920] DD DD DD DD DD DD AA AA 02 00 00 00 DD DD DD DD ........ ........
+[930] DD DD DD DD DD DD DD DD DD DD AA AA 01 00 00 00 ........ ........
+[940] DD DD DD DD DD DD AA AA 00 00 00 00 ........ ....
+
+pull inp_len[286]
+pull inp_len[0]
+push outb_len[50]
+push outb_len[49]
+push outb_len[48]
+push outb_len[47]
+push outb_len[46]
+push outb_len[45]
+push outb_len[44]
+push outb_len[43]
+push outb_len[42]
+push outb_len[41]
+push outb_len[40]
+push outb_len[39]
+push outb_len[38]
+push outb_len[37]
+push outb_len[36]
+push outb_len[35]
+push outb_len[34]
+push outb_len[33]
+push outb_len[32]
+push outb_len[31]
+push outb_len[30]
+push outb_len[29]
+push outb_len[28]
+push outb_len[27]
+push outb_len[26]
+push outb_len[25]
+push outb_len[24]
+push outb_len[23]
+push outb_len[22]
+push outb_len[21]
+push outb_len[20]
+push outb_len[19]
+push outb_len[18]
+push outb_len[17]
+push outb_len[16]
+push outb_len[15]
+push outb_len[14]
+push outb_len[13]
+push outb_len[12]
+push outb_len[11]
+push outb_len[10]
+push outb_len[9]
+push outb_len[8]
+push outb_len[7]
+push outb_len[6]
+push outb_len[5]
+push outb_len[4]
+push outb_len[3]
+push outb_len[2]
+push outb_len[1]
+push outb_len[0]
+srv_midltests_fn: End
+
+ndr32:out => in: ptype[response] flen[5840] plen[5816] ahint[5816]
+
+[000] 32 00 00 00 CC CC CC CC CC CC CC CC CC CC CC CC 2....... ........
+[010] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[020] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[030] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[040] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[050] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[060] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[070] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[080] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[090] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[0A0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[0B0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[0C0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[0D0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[0E0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[0F0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[100] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[110] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[120] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[130] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[140] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[150] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[160] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[170] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[180] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[190] CC CC 00 00 31 00 00 00 CC CC CC CC CC CC CC CC ....1... ........
+[1A0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[1B0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[1C0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[1D0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[1E0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[1F0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[200] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[210] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[220] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[230] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[240] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[250] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[260] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[270] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[280] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[290] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[2A0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[2B0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[2C0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[2D0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[2E0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[2F0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[300] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[310] CC CC CC CC CC CC CC CC CC CC CC CC CC CC 00 00 ........ ........
+[320] 30 00 00 00 CC CC CC CC CC CC CC CC CC CC CC CC 0....... ........
+[330] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[340] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[350] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[360] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[370] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[380] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[390] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[3A0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[3B0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[3C0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[3D0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[3E0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[3F0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[400] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[410] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[420] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[430] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[440] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[450] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[460] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[470] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[480] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[490] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[4A0] CC CC 00 00 2F 00 00 00 CC CC CC CC CC CC CC CC ..../... ........
+[4B0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[4C0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[4D0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[4E0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[4F0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[500] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[510] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[520] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[530] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[540] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[550] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[560] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[570] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[580] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[590] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[5A0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[5B0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[5C0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[5D0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[5E0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[5F0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[600] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[610] CC CC CC CC CC CC CC CC CC CC CC CC CC CC 00 00 ........ ........
+[620] 2E 00 00 00 CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[630] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[640] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[650] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[660] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[670] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[680] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[690] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[6A0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[6B0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[6C0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[6D0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[6E0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[6F0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[700] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[710] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[720] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[730] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[740] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[750] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[760] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[770] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[780] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[790] CC CC 00 00 2D 00 00 00 CC CC CC CC CC CC CC CC ....-... ........
+[7A0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[7B0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[7C0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[7D0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[7E0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[7F0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[800] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[810] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[820] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[830] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[840] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[850] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[860] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[870] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[880] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[890] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[8A0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[8B0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[8C0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[8D0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[8E0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[8F0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC 00 00 ........ ........
+[900] 2C 00 00 00 CC CC CC CC CC CC CC CC CC CC CC CC ,....... ........
+[910] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[920] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[930] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[940] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[950] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[960] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[970] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[980] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[990] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[9A0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[9B0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[9C0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[9D0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[9E0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[9F0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[A00] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[A10] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[A20] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[A30] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[A40] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[A50] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[A60] CC CC 00 00 2B 00 00 00 CC CC CC CC CC CC CC CC ....+... ........
+[A70] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[A80] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[A90] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[AA0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[AB0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[AC0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[AD0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[AE0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[AF0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[B00] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[B10] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[B20] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[B30] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[B40] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[B50] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[B60] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[B70] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[B80] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[B90] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[BA0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[BB0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC 00 00 ........ ........
+[BC0] 2A 00 00 00 CC CC CC CC CC CC CC CC CC CC CC CC *....... ........
+[BD0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[BE0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[BF0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[C00] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[C10] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[C20] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[C30] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[C40] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[C50] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[C60] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[C70] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[C80] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[C90] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[CA0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[CB0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[CC0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[CD0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[CE0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[CF0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[D00] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[D10] CC CC 00 00 29 00 00 00 CC CC CC CC CC CC CC CC ....)... ........
+[D20] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[D30] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[D40] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[D50] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[D60] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[D70] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[D80] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[D90] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[DA0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[DB0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[DC0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[DD0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[DE0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[DF0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[E00] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[E10] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[E20] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[E30] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[E40] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[E50] CC CC CC CC CC CC CC CC CC CC CC CC CC CC 00 00 ........ ........
+[E60] 28 00 00 00 CC CC CC CC CC CC CC CC CC CC CC CC (....... ........
+[E70] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[E80] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[E90] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[EA0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[EB0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[EC0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[ED0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[EE0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[EF0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[F00] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[F10] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[F20] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[F30] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[F40] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[F50] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[F60] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[F70] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[F80] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[F90] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[FA0] CC CC 00 00 27 00 00 00 CC CC CC CC CC CC CC CC ....'... ........
+[FB0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[FC0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[FD0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[FE0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[FF0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[1000] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[1010] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[1020] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[1030] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[1040] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[1050] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[1060] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[1070] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[1080] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[1090] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[10A0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[10B0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[10C0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[10D0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC 00 00 ........ ........
+[10E0] 26 00 00 00 CC CC CC CC CC CC CC CC CC CC CC CC &....... ........
+[10F0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[1100] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[1110] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[1120] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[1130] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[1140] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[1150] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[1160] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[1170] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[1180] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[1190] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[11A0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[11B0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[11C0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[11D0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[11E0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[11F0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[1200] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[1210] CC CC 00 00 25 00 00 00 CC CC CC CC CC CC CC CC ....%... ........
+[1220] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[1230] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[1240] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[1250] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[1260] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[1270] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[1280] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[1290] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[12A0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[12B0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[12C0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[12D0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[12E0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[12F0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[1300] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[1310] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[1320] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[1330] CC CC CC CC CC CC CC CC CC CC CC CC CC CC 00 00 ........ ........
+[1340] 24 00 00 00 CC CC CC CC CC CC CC CC CC CC CC CC $....... ........
+[1350] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[1360] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[1370] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[1380] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[1390] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[13A0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[13B0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[13C0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[13D0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[13E0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[13F0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[1400] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[1410] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[1420] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[1430] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[1440] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[1450] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[1460] CC CC 00 00 23 00 00 00 CC CC CC CC CC CC CC CC ....#... ........
+[1470] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[1480] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[1490] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[14A0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[14B0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[14C0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[14D0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[14E0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[14F0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[1500] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[1510] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[1520] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[1530] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[1540] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[1550] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[1560] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[1570] CC CC CC CC CC CC CC CC CC CC CC CC CC CC 00 00 ........ ........
+[1580] 22 00 00 00 CC CC CC CC CC CC CC CC CC CC CC CC "....... ........
+[1590] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[15A0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[15B0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[15C0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[15D0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[15E0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[15F0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[1600] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[1610] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[1620] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[1630] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[1640] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[1650] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[1660] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[1670] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[1680] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[1690] CC CC 00 00 21 00 00 00 CC CC CC CC CC CC CC CC ....!... ........
+[16A0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[16B0] CC CC CC CC CC CC CC CC ........
+
+
+ndr32:out => in: ptype[response] flen[4632] plen[4608] ahint[4608]
+
+[000] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[010] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[020] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[030] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[040] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[050] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[060] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[070] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[080] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[090] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[0A0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[0B0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[0C0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[0D0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[0E0] CC CC CC CC CC CC 00 00 20 00 00 00 CC CC CC CC ........ .......
+[0F0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[100] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[110] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[120] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[130] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[140] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[150] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[160] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[170] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[180] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[190] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[1A0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[1B0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[1C0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[1D0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[1E0] CC CC CC CC CC CC CC CC CC CC CC CC 1F 00 00 00 ........ ........
+[1F0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[200] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[210] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[220] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[230] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[240] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[250] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[260] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[270] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[280] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[290] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[2A0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[2B0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[2C0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[2D0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[2E0] CC CC CC CC CC CC CC CC 1E 00 00 00 CC CC CC CC ........ ........
+[2F0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[300] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[310] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[320] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[330] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[340] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[350] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[360] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[370] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[380] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[390] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[3A0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[3B0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[3C0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[3D0] CC CC CC CC CC CC CC CC CC CC CC CC 1D 00 00 00 ........ ........
+[3E0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[3F0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[400] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[410] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[420] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[430] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[440] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[450] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[460] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[470] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[480] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[490] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[4A0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[4B0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[4C0] CC CC CC CC CC CC CC CC 1C 00 00 00 CC CC CC CC ........ ........
+[4D0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[4E0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[4F0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[500] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[510] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[520] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[530] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[540] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[550] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[560] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[570] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[580] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[590] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[5A0] CC CC CC CC CC CC CC CC CC CC CC CC 1B 00 00 00 ........ ........
+[5B0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[5C0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[5D0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[5E0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[5F0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[600] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[610] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[620] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[630] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[640] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[650] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[660] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[670] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[680] CC CC CC CC CC CC CC CC 1A 00 00 00 CC CC CC CC ........ ........
+[690] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[6A0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[6B0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[6C0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[6D0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[6E0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[6F0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[700] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[710] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[720] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[730] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[740] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[750] CC CC CC CC CC CC CC CC CC CC CC CC 19 00 00 00 ........ ........
+[760] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[770] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[780] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[790] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[7A0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[7B0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[7C0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[7D0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[7E0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[7F0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[800] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[810] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[820] CC CC CC CC CC CC CC CC 18 00 00 00 CC CC CC CC ........ ........
+[830] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[840] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[850] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[860] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[870] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[880] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[890] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[8A0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[8B0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[8C0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[8D0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[8E0] CC CC CC CC CC CC CC CC CC CC CC CC 17 00 00 00 ........ ........
+[8F0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[900] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[910] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[920] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[930] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[940] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[950] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[960] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[970] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[980] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[990] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[9A0] CC CC CC CC CC CC CC CC 16 00 00 00 CC CC CC CC ........ ........
+[9B0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[9C0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[9D0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[9E0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[9F0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[A00] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[A10] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[A20] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[A30] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[A40] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[A50] CC CC CC CC CC CC CC CC CC CC CC CC 15 00 00 00 ........ ........
+[A60] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[A70] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[A80] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[A90] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[AA0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[AB0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[AC0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[AD0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[AE0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[AF0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[B00] CC CC CC CC CC CC CC CC 14 00 00 00 CC CC CC CC ........ ........
+[B10] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[B20] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[B30] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[B40] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[B50] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[B60] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[B70] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[B80] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[B90] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[BA0] CC CC CC CC CC CC CC CC CC CC CC CC 13 00 00 00 ........ ........
+[BB0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[BC0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[BD0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[BE0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[BF0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[C00] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[C10] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[C20] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[C30] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[C40] CC CC CC CC CC CC CC CC 12 00 00 00 CC CC CC CC ........ ........
+[C50] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[C60] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[C70] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[C80] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[C90] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[CA0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[CB0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[CC0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[CD0] CC CC CC CC CC CC CC CC CC CC CC CC 11 00 00 00 ........ ........
+[CE0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[CF0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[D00] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[D10] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[D20] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[D30] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[D40] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[D50] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[D60] CC CC CC CC CC CC CC CC 10 00 00 00 CC CC CC CC ........ ........
+[D70] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[D80] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[D90] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[DA0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[DB0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[DC0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[DD0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[DE0] CC CC CC CC CC CC CC CC CC CC CC CC 0F 00 00 00 ........ ........
+[DF0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[E00] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[E10] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[E20] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[E30] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[E40] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[E50] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[E60] CC CC CC CC CC CC CC CC 0E 00 00 00 CC CC CC CC ........ ........
+[E70] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[E80] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[E90] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[EA0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[EB0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[EC0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[ED0] CC CC CC CC CC CC CC CC CC CC CC CC 0D 00 00 00 ........ ........
+[EE0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[EF0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[F00] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[F10] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[F20] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[F30] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[F40] CC CC CC CC CC CC CC CC 0C 00 00 00 CC CC CC CC ........ ........
+[F50] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[F60] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[F70] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[F80] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[F90] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[FA0] CC CC CC CC CC CC CC CC CC CC CC CC 0B 00 00 00 ........ ........
+[FB0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[FC0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[FD0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[FE0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[FF0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[1000] CC CC CC CC CC CC CC CC 0A 00 00 00 CC CC CC CC ........ ........
+[1010] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[1020] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[1030] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[1040] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[1050] CC CC CC CC CC CC CC CC CC CC CC CC 09 00 00 00 ........ ........
+[1060] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[1070] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[1080] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[1090] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[10A0] CC CC CC CC CC CC CC CC 08 00 00 00 CC CC CC CC ........ ........
+[10B0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[10C0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[10D0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[10E0] CC CC CC CC CC CC CC CC CC CC CC CC 07 00 00 00 ........ ........
+[10F0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[1100] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[1110] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[1120] CC CC CC CC CC CC CC CC 06 00 00 00 CC CC CC CC ........ ........
+[1130] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[1140] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[1150] CC CC CC CC CC CC CC CC CC CC CC CC 05 00 00 00 ........ ........
+[1160] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[1170] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[1180] CC CC CC CC CC CC CC CC 04 00 00 00 CC CC CC CC ........ ........
+[1190] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[11A0] CC CC CC CC CC CC CC CC CC CC CC CC 03 00 00 00 ........ ........
+[11B0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[11C0] CC CC CC CC CC CC CC CC 02 00 00 00 CC CC CC CC ........ ........
+[11D0] CC CC CC CC CC CC CC CC CC CC CC CC 01 00 00 00 ........ ........
+[11E0] CC CC CC CC CC CC CC CC 00 00 00 00 03 00 00 00 ........ ........
+[11F0] 00 00 02 00 03 00 00 00 BB BB BB 00 54 72 75 65 ........ ....True
+
+alloc1:outp: bsize[6664], bcount[1]
+alloc2:outp: bsize[6664], bcount[833]
+push:outp: ecount[104]
+alloc1:outp: bsize[6664], bcount[833]
+alloc2:outp: bsize[6664], bcount[833]
+push:outp: ecount[104]
+alloc1:outp: bsize[6664], bcount[833]
+alloc2:outp: bsize[6664], bcount[833]
+push:outp: ecount[104]
+alloc1:outp: bsize[6664], bcount[833]
+alloc2:outp: bsize[6664], bcount[833]
+push:outp: ecount[104]
+alloc1:outp: bsize[6664], bcount[833]
+alloc2:outp: bsize[6664], bcount[833]
+push:outp: ecount[104]
+alloc1:outp: bsize[6664], bcount[833]
+alloc2:outp: bsize[6664], bcount[833]
+push:outp: ecount[104]
+alloc1:outp: bsize[6664], bcount[833]
+alloc2:outp: bsize[6664], bcount[833]
+push:outp: ecount[104]
+alloc1:outp: bsize[6664], bcount[833]
+alloc2:outp: bsize[6664], bcount[833]
+push:outp: ecount[104]
+alloc1:outp: bsize[6664], bcount[833]
+alloc2:outp: bsize[6664], bcount[833]
+push:outp: ecount[104]
+alloc1:outp: bsize[6664], bcount[833]
+alloc2:outp: bsize[6664], bcount[833]
+push:outp: ecount[104]
+alloc1:outp: bsize[6664], bcount[833]
+alloc2:outp: bsize[6664], bcount[833]
+push:outp: ecount[104]
+alloc1:outp: bsize[6664], bcount[833]
+alloc2:outp: bsize[6664], bcount[833]
+push:outp: ecount[104]
+alloc1:outp: bsize[6664], bcount[833]
+alloc2:outp: bsize[6664], bcount[833]
+push:outp: ecount[27]
+push:outp: ecount[0]
+NDRTcpThread[ndr32] stop
+NDRTcpThread[ndr32] stop
+
+Test NDR64
+
+ndr64: got NDR64
+
+ndr64:in => out: ptype[request] flen[3048] plen[3024] ahint[3024]
+
+[000] B8 0B 00 00 00 00 00 00 00 00 02 00 00 00 00 00 ........ ........
+[010] B8 0B 00 00 00 00 00 00 AA AA AA AA AA AA AA AA ........ ........
+[020] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[030] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[040] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[050] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[060] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[070] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[080] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[090] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[0A0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[0B0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[0C0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[0D0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[0E0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[0F0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[100] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[110] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[120] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[130] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[140] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[150] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[160] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[170] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[180] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[190] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[1A0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[1B0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[1C0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[1D0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[1E0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[1F0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[200] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[210] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[220] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[230] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[240] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[250] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[260] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[270] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[280] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[290] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[2A0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[2B0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[2C0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[2D0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[2E0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[2F0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[300] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[310] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[320] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[330] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[340] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[350] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[360] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[370] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[380] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[390] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[3A0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[3B0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[3C0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[3D0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[3E0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[3F0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[400] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[410] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[420] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[430] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[440] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[450] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[460] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[470] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[480] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[490] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[4A0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[4B0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[4C0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[4D0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[4E0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[4F0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[500] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[510] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[520] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[530] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[540] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[550] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[560] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[570] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[580] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[590] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[5A0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[5B0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[5C0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[5D0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[5E0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[5F0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[600] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[610] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[620] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[630] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[640] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[650] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[660] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[670] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[680] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[690] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[6A0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[6B0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[6C0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[6D0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[6E0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[6F0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[700] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[710] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[720] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[730] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[740] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[750] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[760] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[770] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[780] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[790] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[7A0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[7B0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[7C0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[7D0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[7E0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[7F0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[800] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[810] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[820] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[830] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[840] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[850] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[860] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[870] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[880] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[890] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[8A0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[8B0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[8C0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[8D0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[8E0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[8F0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[900] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[910] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[920] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[930] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[940] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[950] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[960] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[970] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[980] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[990] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[9A0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[9B0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[9C0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[9D0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[9E0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[9F0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[A00] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[A10] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[A20] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[A30] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[A40] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[A50] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[A60] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[A70] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[A80] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[A90] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[AA0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[AB0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[AC0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[AD0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[AE0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[AF0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[B00] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[B10] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[B20] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[B30] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[B40] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[B50] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[B60] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[B70] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[B80] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[B90] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[BA0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[BB0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[BC0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+
+srv_midltests_fn: Start
+srv_midltests_fn: End
+
+ndr64:out => in: ptype[response] flen[28] plen[4] ahint[4]
+
+[000] 54 72 75 65 True
+
+ndr64: got NDR64
+
+alloc1:inp: bsize[5000], bcount[0]
+alloc2:inp: bsize[5000], bcount[625]
+pull1:inp: esize[78] ecount[78]
+pull2:inp: esize[78] ecount[35]
+alloc1:inp: bsize[5000], bcount[625]
+alloc2:inp: bsize[5000], bcount[625]
+pull1:inp: esize[78] ecount[78]
+pull2:inp: esize[78] ecount[34]
+alloc1:inp: bsize[5000], bcount[625]
+alloc2:inp: bsize[5000], bcount[625]
+pull1:inp: esize[78] ecount[78]
+pull2:inp: esize[78] ecount[33]
+alloc1:inp: bsize[5000], bcount[625]
+alloc2:inp: bsize[5000], bcount[625]
+pull1:inp: esize[78] ecount[78]
+pull2:inp: esize[78] ecount[32]
+alloc1:inp: bsize[5000], bcount[625]
+alloc2:inp: bsize[5000], bcount[625]
+pull1:inp: esize[78] ecount[78]
+pull2:inp: esize[78] ecount[31]
+alloc1:inp: bsize[5000], bcount[625]
+alloc2:inp: bsize[5000], bcount[625]
+pull1:inp: esize[78] ecount[78]
+pull2:inp: esize[78] ecount[30]
+alloc1:inp: bsize[5000], bcount[625]
+alloc2:inp: bsize[5000], bcount[625]
+pull1:inp: esize[78] ecount[78]
+pull2:inp: esize[78] ecount[29]
+alloc1:inp: bsize[5000], bcount[625]
+alloc2:inp: bsize[5000], bcount[625]
+pull1:inp: esize[78] ecount[78]
+pull2:inp: esize[78] ecount[28]
+alloc1:inp: bsize[5000], bcount[625]
+alloc2:inp: bsize[5000], bcount[625]
+pull1:inp: esize[78] ecount[78]
+pull2:inp: esize[78] ecount[27]
+alloc1:inp: bsize[5000], bcount[625]
+alloc2:inp: bsize[5000], bcount[625]
+pull1:inp: esize[78] ecount[78]
+pull2:inp: esize[78] ecount[26]
+alloc1:inp: bsize[5000], bcount[625]
+alloc2:inp: bsize[5000], bcount[625]
+pull1:inp: esize[78] ecount[78]
+pull2:inp: esize[78] ecount[25]
+alloc1:inp: bsize[5000], bcount[625]
+alloc2:inp: bsize[5000], bcount[625]
+pull1:inp: esize[78] ecount[78]
+pull2:inp: esize[78] ecount[24]
+alloc1:inp: bsize[5000], bcount[625]
+alloc2:inp: bsize[5000], bcount[625]
+pull1:inp: esize[78] ecount[78]
+pull2:inp: esize[78] ecount[23]
+alloc1:inp: bsize[5000], bcount[625]
+alloc2:inp: bsize[5000], bcount[625]
+pull1:inp: esize[78] ecount[78]
+pull2:inp: esize[78] ecount[22]
+alloc1:inp: bsize[5000], bcount[625]
+alloc2:inp: bsize[5000], bcount[625]
+pull1:inp: esize[78] ecount[78]
+pull2:inp: esize[78] ecount[21]
+alloc1:inp: bsize[5000], bcount[625]
+alloc2:inp: bsize[5000], bcount[625]
+pull1:inp: esize[78] ecount[78]
+pull2:inp: esize[78] ecount[20]
+alloc1:inp: bsize[5000], bcount[625]
+alloc2:inp: bsize[5000], bcount[625]
+pull1:inp: esize[78] ecount[78]
+pull2:inp: esize[78] ecount[19]
+alloc1:inp: bsize[5000], bcount[625]
+alloc2:inp: bsize[5000], bcount[625]
+pull1:inp: esize[78] ecount[78]
+pull2:inp: esize[78] ecount[18]
+alloc1:inp: bsize[5000], bcount[625]
+alloc2:inp: bsize[5000], bcount[625]
+pull1:inp: esize[78] ecount[78]
+pull2:inp: esize[78] ecount[17]
+alloc1:inp: bsize[5000], bcount[625]
+alloc2:inp: bsize[5000], bcount[625]
+pull1:inp: esize[78] ecount[78]
+pull2:inp: esize[78] ecount[16]
+alloc1:inp: bsize[5000], bcount[625]
+alloc2:inp: bsize[5000], bcount[625]
+pull1:inp: esize[78] ecount[78]
+pull2:inp: esize[78] ecount[15]
+alloc1:inp: bsize[5000], bcount[625]
+alloc2:inp: bsize[5000], bcount[625]
+pull1:inp: esize[78] ecount[78]
+pull2:inp: esize[78] ecount[14]
+alloc1:inp: bsize[5000], bcount[625]
+alloc2:inp: bsize[5000], bcount[625]
+pull1:inp: esize[78] ecount[78]
+pull2:inp: esize[78] ecount[13]
+alloc1:inp: bsize[5000], bcount[625]
+alloc2:inp: bsize[5000], bcount[625]
+pull1:inp: esize[78] ecount[78]
+pull2:inp: esize[78] ecount[12]
+alloc1:inp: bsize[5000], bcount[625]
+alloc2:inp: bsize[5000], bcount[625]
+pull1:inp: esize[78] ecount[78]
+pull2:inp: esize[78] ecount[11]
+alloc1:inp: bsize[5000], bcount[625]
+alloc2:inp: bsize[5000], bcount[625]
+pull1:inp: esize[78] ecount[78]
+pull2:inp: esize[78] ecount[10]
+alloc1:inp: bsize[5000], bcount[625]
+alloc2:inp: bsize[5000], bcount[625]
+pull1:inp: esize[78] ecount[78]
+pull2:inp: esize[78] ecount[9]
+alloc1:inp: bsize[5000], bcount[625]
+alloc2:inp: bsize[5000], bcount[625]
+pull1:inp: esize[78] ecount[78]
+pull2:inp: esize[78] ecount[8]
+alloc1:inp: bsize[5000], bcount[625]
+alloc2:inp: bsize[5000], bcount[625]
+pull1:inp: esize[78] ecount[78]
+pull2:inp: esize[78] ecount[7]
+alloc1:inp: bsize[5000], bcount[625]
+alloc2:inp: bsize[5000], bcount[625]
+pull1:inp: esize[78] ecount[78]
+pull2:inp: esize[78] ecount[6]
+alloc1:inp: bsize[5000], bcount[625]
+alloc2:inp: bsize[5000], bcount[625]
+pull1:inp: esize[78] ecount[78]
+pull2:inp: esize[78] ecount[5]
+alloc1:inp: bsize[5000], bcount[625]
+alloc2:inp: bsize[5000], bcount[625]
+pull1:inp: esize[78] ecount[78]
+pull2:inp: esize[78] ecount[4]
+alloc1:inp: bsize[5000], bcount[625]
+alloc2:inp: bsize[5000], bcount[625]
+pull1:inp: esize[78] ecount[78]
+pull2:inp: esize[78] ecount[3]
+alloc1:inp: bsize[5000], bcount[625]
+alloc2:inp: bsize[5000], bcount[625]
+pull1:inp: esize[78] ecount[78]
+pull2:inp: esize[78] ecount[2]
+alloc1:inp: bsize[5000], bcount[625]
+alloc2:inp: bsize[5000], bcount[625]
+pull1:inp: esize[78] ecount[78]
+pull2:inp: esize[78] ecount[1]
+alloc1:inp: bsize[5000], bcount[625]
+alloc2:inp: bsize[5000], bcount[625]
+pull1:inp: esize[78] ecount[78]
+pull2:inp: esize[78] ecount[0]
+
+ndr64: got NDR32 downgrade
+
+
+ndr64:in => out: ptype[alter_req] flen[72] call[3] contexts[1]
+
+
+ndr64:out => in: ptype[alter_ack] flen[56] call[3]
+
+ndr64:in => out: ptype[request] flen[5840] plen[5816] ahint[3012]
+
+[000] B8 0B 00 00 00 00 02 00 B8 0B 00 00 AA AA AA AA ........ ........
+[010] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[020] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[030] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[040] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[050] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[060] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[070] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[080] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[090] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[0A0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[0B0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[0C0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[0D0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[0E0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[0F0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[100] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[110] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[120] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[130] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[140] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[150] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[160] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[170] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[180] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[190] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[1A0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[1B0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[1C0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[1D0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[1E0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[1F0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[200] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[210] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[220] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[230] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[240] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[250] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[260] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[270] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[280] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[290] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[2A0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[2B0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[2C0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[2D0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[2E0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[2F0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[300] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[310] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[320] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[330] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[340] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[350] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[360] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[370] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[380] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[390] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[3A0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[3B0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[3C0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[3D0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[3E0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[3F0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[400] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[410] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[420] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[430] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[440] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[450] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[460] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[470] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[480] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[490] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[4A0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[4B0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[4C0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[4D0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[4E0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[4F0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[500] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[510] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[520] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[530] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[540] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[550] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[560] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[570] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[580] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[590] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[5A0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[5B0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[5C0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[5D0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[5E0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[5F0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[600] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[610] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[620] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[630] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[640] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[650] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[660] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[670] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[680] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[690] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[6A0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[6B0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[6C0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[6D0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[6E0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[6F0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[700] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[710] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[720] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[730] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[740] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[750] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[760] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[770] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[780] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[790] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[7A0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[7B0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[7C0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[7D0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[7E0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[7F0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[800] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[810] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[820] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[830] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[840] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[850] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[860] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[870] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[880] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[890] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[8A0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[8B0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[8C0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[8D0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[8E0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[8F0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[900] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[910] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[920] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[930] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[940] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[950] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[960] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[970] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[980] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[990] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[9A0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[9B0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[9C0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[9D0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[9E0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[9F0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[A00] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[A10] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[A20] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[A30] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[A40] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[A50] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[A60] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[A70] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[A80] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[A90] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[AA0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[AB0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[AC0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[AD0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[AE0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[AF0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[B00] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[B10] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[B20] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[B30] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[B40] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[B50] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[B60] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[B70] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[B80] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[B90] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[BA0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[BB0] AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA ........ ........
+[BC0] AA AA AA AA 23 00 00 00 DD DD DD DD DD DD DD DD ....#... ........
+[BD0] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[BE0] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[BF0] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[C00] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[C10] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[C20] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[C30] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[C40] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[C50] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[C60] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[C70] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[C80] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[C90] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[CA0] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[CB0] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[CC0] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[CD0] DD DD DD DD DD DD DD DD DD DD DD DD DD DD 00 00 ........ ........
+[CE0] 22 00 00 00 DD DD DD DD DD DD DD DD DD DD DD DD "....... ........
+[CF0] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[D00] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[D10] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[D20] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[D30] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[D40] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[D50] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[D60] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[D70] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[D80] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[D90] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[DA0] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[DB0] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[DC0] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[DD0] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[DE0] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[DF0] DD DD 00 00 21 00 00 00 DD DD DD DD DD DD DD DD ....!... ........
+[E00] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[E10] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[E20] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[E30] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[E40] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[E50] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[E60] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[E70] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[E80] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[E90] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[EA0] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[EB0] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[EC0] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[ED0] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[EE0] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[EF0] DD DD DD DD DD DD DD DD DD DD DD DD DD DD 00 00 ........ ........
+[F00] 20 00 00 00 DD DD DD DD DD DD DD DD DD DD DD DD ....... ........
+[F10] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[F20] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[F30] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[F40] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[F50] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[F60] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[F70] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[F80] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[F90] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[FA0] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[FB0] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[FC0] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[FD0] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[FE0] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[FF0] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[1000] DD DD 00 00 1F 00 00 00 DD DD DD DD DD DD DD DD ........ ........
+[1010] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[1020] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[1030] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[1040] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[1050] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[1060] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[1070] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[1080] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[1090] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[10A0] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[10B0] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[10C0] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[10D0] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[10E0] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[10F0] DD DD DD DD DD DD DD DD DD DD DD DD DD DD 00 00 ........ ........
+[1100] 1E 00 00 00 DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[1110] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[1120] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[1130] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[1140] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[1150] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[1160] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[1170] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[1180] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[1190] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[11A0] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[11B0] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[11C0] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[11D0] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[11E0] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[11F0] DD DD 00 00 1D 00 00 00 DD DD DD DD DD DD DD DD ........ ........
+[1200] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[1210] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[1220] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[1230] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[1240] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[1250] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[1260] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[1270] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[1280] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[1290] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[12A0] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[12B0] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[12C0] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[12D0] DD DD DD DD DD DD DD DD DD DD DD DD DD DD 00 00 ........ ........
+[12E0] 1C 00 00 00 DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[12F0] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[1300] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[1310] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[1320] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[1330] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[1340] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[1350] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[1360] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[1370] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[1380] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[1390] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[13A0] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[13B0] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[13C0] DD DD 00 00 1B 00 00 00 DD DD DD DD DD DD DD DD ........ ........
+[13D0] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[13E0] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[13F0] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[1400] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[1410] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[1420] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[1430] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[1440] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[1450] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[1460] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[1470] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[1480] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[1490] DD DD DD DD DD DD DD DD DD DD DD DD DD DD 00 00 ........ ........
+[14A0] 1A 00 00 00 DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[14B0] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[14C0] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[14D0] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[14E0] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[14F0] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[1500] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[1510] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[1520] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[1530] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[1540] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[1550] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[1560] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[1570] DD DD 00 00 19 00 00 00 DD DD DD DD DD DD DD DD ........ ........
+[1580] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[1590] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[15A0] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[15B0] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[15C0] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[15D0] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[15E0] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[15F0] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[1600] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[1610] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[1620] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[1630] DD DD DD DD DD DD DD DD DD DD DD DD DD DD 00 00 ........ ........
+[1640] 18 00 00 00 DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[1650] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[1660] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[1670] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[1680] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[1690] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[16A0] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[16B0] DD DD DD DD DD DD DD DD ........
+
+srv_midltests_fn: Start
+pull inp_len[344]
+ndr64:in => out: ptype[request] flen[2404] plen[2380] ahint[2380]
+
+[000] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[010] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[020] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[030] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[040] DD DD DD DD DD DD DD DD DD DD 00 00 17 00 00 00 ........ ........
+[050] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[060] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[070] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[080] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[090] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[0A0] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[0B0] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[0C0] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[0D0] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[0E0] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[0F0] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[100] DD DD DD DD DD DD AA AA 16 00 00 00 DD DD DD DD ........ ........
+[110] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[120] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[130] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[140] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[150] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[160] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[170] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[180] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[190] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[1A0] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[1B0] DD DD DD DD DD DD DD DD DD DD AA AA 15 00 00 00 ........ ........
+[1C0] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[1D0] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[1E0] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[1F0] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[200] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[210] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[220] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[230] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[240] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[250] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[260] DD DD DD DD DD DD AA AA 14 00 00 00 DD DD DD DD ........ ........
+[270] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[280] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[290] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[2A0] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[2B0] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[2C0] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[2D0] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[2E0] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[2F0] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[300] DD DD DD DD DD DD DD DD DD DD AA AA 13 00 00 00 ........ ........
+[310] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[320] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[330] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[340] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[350] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[360] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[370] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[380] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[390] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[3A0] DD DD DD DD DD DD AA AA 12 00 00 00 DD DD DD DD ........ ........
+[3B0] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[3C0] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[3D0] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[3E0] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[3F0] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[400] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[410] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[420] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[430] DD DD DD DD DD DD DD DD DD DD AA AA 11 00 00 00 ........ ........
+[440] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[450] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[460] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[470] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[480] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[490] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[4A0] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[4B0] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[4C0] DD DD DD DD DD DD AA AA 10 00 00 00 DD DD DD DD ........ ........
+[4D0] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[4E0] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[4F0] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[500] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[510] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[520] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[530] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[540] DD DD DD DD DD DD DD DD DD DD AA AA 0F 00 00 00 ........ ........
+[550] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[560] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[570] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[580] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[590] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[5A0] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[5B0] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[5C0] DD DD DD DD DD DD AA AA 0E 00 00 00 DD DD DD DD ........ ........
+[5D0] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[5E0] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[5F0] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[600] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[610] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[620] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[630] DD DD DD DD DD DD DD DD DD DD AA AA 0D 00 00 00 ........ ........
+[640] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[650] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[660] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[670] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[680] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[690] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[6A0] DD DD DD DD DD DD AA AA 0C 00 00 00 DD DD DD DD ........ ........
+[6B0] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[6C0] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[6D0] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[6E0] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[6F0] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[700] DD DD DD DD DD DD DD DD DD DD AA AA 0B 00 00 00 ........ ........
+[710] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[720] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[730] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[740] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[750] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[760] DD DD DD DD DD DD AA AA 0A 00 00 00 DD DD DD DD ........ ........
+[770] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[780] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[790] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[7A0] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[7B0] DD DD DD DD DD DD DD DD DD DD AA AA 09 00 00 00 ........ ........
+[7C0] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[7D0] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[7E0] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[7F0] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[800] DD DD DD DD DD DD AA AA 08 00 00 00 DD DD DD DD ........ ........
+[810] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[820] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[830] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[840] DD DD DD DD DD DD DD DD DD DD AA AA 07 00 00 00 ........ ........
+[850] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[860] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[870] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[880] DD DD DD DD DD DD AA AA 06 00 00 00 DD DD DD DD ........ ........
+[890] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[8A0] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[8B0] DD DD DD DD DD DD DD DD DD DD AA AA 05 00 00 00 ........ ........
+[8C0] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[8D0] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[8E0] DD DD DD DD DD DD AA AA 04 00 00 00 DD DD DD DD ........ ........
+[8F0] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[900] DD DD DD DD DD DD DD DD DD DD AA AA 03 00 00 00 ........ ........
+[910] DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD ........ ........
+[920] DD DD DD DD DD DD AA AA 02 00 00 00 DD DD DD DD ........ ........
+[930] DD DD DD DD DD DD DD DD DD DD AA AA 01 00 00 00 ........ ........
+[940] DD DD DD DD DD DD AA AA 00 00 00 00 ........ ....
+
+pull inp_len[286]
+pull inp_len[0]
+push outb_len[50]
+push outb_len[49]
+push outb_len[48]
+push outb_len[47]
+push outb_len[46]
+push outb_len[45]
+push outb_len[44]
+push outb_len[43]
+push outb_len[42]
+push outb_len[41]
+push outb_len[40]
+push outb_len[39]
+push outb_len[38]
+push outb_len[37]
+push outb_len[36]
+push outb_len[35]
+push outb_len[34]
+push outb_len[33]
+push outb_len[32]
+push outb_len[31]
+push outb_len[30]
+push outb_len[29]
+push outb_len[28]
+push outb_len[27]
+push outb_len[26]
+push outb_len[25]
+push outb_len[24]
+push outb_len[23]
+push outb_len[22]
+push outb_len[21]
+push outb_len[20]
+push outb_len[19]
+push outb_len[18]
+push outb_len[17]
+push outb_len[16]
+push outb_len[15]
+push outb_len[14]
+push outb_len[13]
+push outb_len[12]
+push outb_len[11]
+push outb_len[10]
+push outb_len[9]
+push outb_len[8]
+push outb_len[7]
+push outb_len[6]
+push outb_len[5]
+push outb_len[4]
+push outb_len[3]
+push outb_len[2]
+push outb_len[1]
+push outb_len[0]
+srv_midltests_fn: End
+
+ndr64:out => in: ptype[response] flen[5840] plen[5816] ahint[5816]
+
+[000] 32 00 00 00 CC CC CC CC CC CC CC CC CC CC CC CC 2....... ........
+[010] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[020] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[030] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[040] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[050] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[060] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[070] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[080] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[090] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[0A0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[0B0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[0C0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[0D0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[0E0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[0F0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[100] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[110] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[120] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[130] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[140] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[150] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[160] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[170] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[180] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[190] CC CC 00 00 31 00 00 00 CC CC CC CC CC CC CC CC ....1... ........
+[1A0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[1B0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[1C0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[1D0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[1E0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[1F0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[200] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[210] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[220] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[230] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[240] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[250] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[260] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[270] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[280] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[290] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[2A0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[2B0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[2C0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[2D0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[2E0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[2F0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[300] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[310] CC CC CC CC CC CC CC CC CC CC CC CC CC CC 00 00 ........ ........
+[320] 30 00 00 00 CC CC CC CC CC CC CC CC CC CC CC CC 0....... ........
+[330] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[340] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[350] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[360] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[370] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[380] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[390] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[3A0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[3B0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[3C0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[3D0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[3E0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[3F0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[400] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[410] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[420] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[430] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[440] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[450] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[460] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[470] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[480] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[490] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[4A0] CC CC 00 00 2F 00 00 00 CC CC CC CC CC CC CC CC ..../... ........
+[4B0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[4C0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[4D0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[4E0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[4F0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[500] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[510] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[520] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[530] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[540] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[550] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[560] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[570] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[580] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[590] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[5A0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[5B0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[5C0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[5D0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[5E0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[5F0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[600] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[610] CC CC CC CC CC CC CC CC CC CC CC CC CC CC 00 00 ........ ........
+[620] 2E 00 00 00 CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[630] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[640] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[650] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[660] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[670] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[680] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[690] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[6A0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[6B0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[6C0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[6D0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[6E0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[6F0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[700] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[710] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[720] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[730] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[740] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[750] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[760] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[770] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[780] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[790] CC CC 00 00 2D 00 00 00 CC CC CC CC CC CC CC CC ....-... ........
+[7A0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[7B0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[7C0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[7D0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[7E0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[7F0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[800] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[810] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[820] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[830] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[840] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[850] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[860] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[870] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[880] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[890] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[8A0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[8B0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[8C0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[8D0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[8E0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[8F0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC 00 00 ........ ........
+[900] 2C 00 00 00 CC CC CC CC CC CC CC CC CC CC CC CC ,....... ........
+[910] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[920] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[930] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[940] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[950] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[960] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[970] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[980] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[990] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[9A0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[9B0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[9C0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[9D0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[9E0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[9F0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[A00] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[A10] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[A20] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[A30] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[A40] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[A50] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[A60] CC CC 00 00 2B 00 00 00 CC CC CC CC CC CC CC CC ....+... ........
+[A70] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[A80] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[A90] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[AA0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[AB0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[AC0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[AD0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[AE0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[AF0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[B00] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[B10] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[B20] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[B30] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[B40] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[B50] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[B60] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[B70] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[B80] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[B90] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[BA0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[BB0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC 00 00 ........ ........
+[BC0] 2A 00 00 00 CC CC CC CC CC CC CC CC CC CC CC CC *....... ........
+[BD0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[BE0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[BF0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[C00] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[C10] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[C20] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[C30] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[C40] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[C50] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[C60] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[C70] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[C80] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[C90] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[CA0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[CB0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[CC0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[CD0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[CE0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[CF0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[D00] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[D10] CC CC 00 00 29 00 00 00 CC CC CC CC CC CC CC CC ....)... ........
+[D20] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[D30] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[D40] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[D50] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[D60] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[D70] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[D80] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[D90] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[DA0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[DB0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[DC0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[DD0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[DE0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[DF0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[E00] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[E10] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[E20] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[E30] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[E40] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[E50] CC CC CC CC CC CC CC CC CC CC CC CC CC CC 00 00 ........ ........
+[E60] 28 00 00 00 CC CC CC CC CC CC CC CC CC CC CC CC (....... ........
+[E70] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[E80] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[E90] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[EA0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[EB0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[EC0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[ED0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[EE0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[EF0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[F00] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[F10] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[F20] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[F30] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[F40] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[F50] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[F60] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[F70] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[F80] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[F90] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[FA0] CC CC 00 00 27 00 00 00 CC CC CC CC CC CC CC CC ....'... ........
+[FB0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[FC0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[FD0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[FE0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[FF0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[1000] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[1010] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[1020] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[1030] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[1040] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[1050] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[1060] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[1070] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[1080] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[1090] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[10A0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[10B0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[10C0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[10D0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC 00 00 ........ ........
+[10E0] 26 00 00 00 CC CC CC CC CC CC CC CC CC CC CC CC &....... ........
+[10F0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[1100] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[1110] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[1120] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[1130] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[1140] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[1150] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[1160] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[1170] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[1180] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[1190] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[11A0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[11B0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[11C0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[11D0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[11E0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[11F0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[1200] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[1210] CC CC 00 00 25 00 00 00 CC CC CC CC CC CC CC CC ....%... ........
+[1220] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[1230] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[1240] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[1250] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[1260] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[1270] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[1280] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[1290] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[12A0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[12B0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[12C0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[12D0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[12E0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[12F0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[1300] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[1310] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[1320] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[1330] CC CC CC CC CC CC CC CC CC CC CC CC CC CC 00 00 ........ ........
+[1340] 24 00 00 00 CC CC CC CC CC CC CC CC CC CC CC CC $....... ........
+[1350] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[1360] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[1370] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[1380] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[1390] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[13A0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[13B0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[13C0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[13D0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[13E0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[13F0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[1400] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[1410] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[1420] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[1430] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[1440] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[1450] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[1460] CC CC 00 00 23 00 00 00 CC CC CC CC CC CC CC CC ....#... ........
+[1470] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[1480] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[1490] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[14A0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[14B0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[14C0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[14D0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[14E0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[14F0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[1500] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[1510] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[1520] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[1530] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[1540] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[1550] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[1560] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[1570] CC CC CC CC CC CC CC CC CC CC CC CC CC CC 00 00 ........ ........
+[1580] 22 00 00 00 CC CC CC CC CC CC CC CC CC CC CC CC "....... ........
+[1590] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[15A0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[15B0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[15C0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[15D0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[15E0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[15F0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[1600] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[1610] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[1620] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[1630] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[1640] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[1650] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[1660] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[1670] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[1680] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[1690] CC CC 00 00 21 00 00 00 CC CC CC CC CC CC CC CC ....!... ........
+[16A0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[16B0] CC CC CC CC CC CC CC CC ........
+
+
+ndr64:out => in: ptype[response] flen[4632] plen[4608] ahint[4608]
+
+[000] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[010] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[020] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[030] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[040] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[050] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[060] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[070] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[080] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[090] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[0A0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[0B0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[0C0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[0D0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[0E0] CC CC CC CC CC CC 00 00 20 00 00 00 CC CC CC CC ........ .......
+[0F0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[100] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[110] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[120] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[130] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[140] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[150] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[160] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[170] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[180] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[190] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[1A0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[1B0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[1C0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[1D0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[1E0] CC CC CC CC CC CC CC CC CC CC CC CC 1F 00 00 00 ........ ........
+[1F0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[200] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[210] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[220] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[230] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[240] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[250] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[260] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[270] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[280] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[290] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[2A0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[2B0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[2C0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[2D0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[2E0] CC CC CC CC CC CC CC CC 1E 00 00 00 CC CC CC CC ........ ........
+[2F0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[300] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[310] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[320] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[330] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[340] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[350] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[360] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[370] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[380] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[390] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[3A0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[3B0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[3C0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[3D0] CC CC CC CC CC CC CC CC CC CC CC CC 1D 00 00 00 ........ ........
+[3E0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[3F0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[400] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[410] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[420] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[430] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[440] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[450] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[460] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[470] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[480] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[490] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[4A0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[4B0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[4C0] CC CC CC CC CC CC CC CC 1C 00 00 00 CC CC CC CC ........ ........
+[4D0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[4E0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[4F0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[500] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[510] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[520] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[530] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[540] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[550] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[560] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[570] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[580] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[590] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[5A0] CC CC CC CC CC CC CC CC CC CC CC CC 1B 00 00 00 ........ ........
+[5B0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[5C0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[5D0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[5E0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[5F0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[600] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[610] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[620] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[630] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[640] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[650] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[660] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[670] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[680] CC CC CC CC CC CC CC CC 1A 00 00 00 CC CC CC CC ........ ........
+[690] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[6A0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[6B0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[6C0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[6D0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[6E0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[6F0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[700] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[710] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[720] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[730] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[740] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[750] CC CC CC CC CC CC CC CC CC CC CC CC 19 00 00 00 ........ ........
+[760] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[770] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[780] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[790] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[7A0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[7B0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[7C0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[7D0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[7E0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[7F0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[800] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[810] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[820] CC CC CC CC CC CC CC CC 18 00 00 00 CC CC CC CC ........ ........
+[830] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[840] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[850] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[860] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[870] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[880] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[890] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[8A0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[8B0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[8C0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[8D0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[8E0] CC CC CC CC CC CC CC CC CC CC CC CC 17 00 00 00 ........ ........
+[8F0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[900] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[910] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[920] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[930] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[940] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[950] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[960] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[970] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[980] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[990] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[9A0] CC CC CC CC CC CC CC CC 16 00 00 00 CC CC CC CC ........ ........
+[9B0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[9C0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[9D0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[9E0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[9F0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[A00] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[A10] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[A20] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[A30] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[A40] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[A50] CC CC CC CC CC CC CC CC CC CC CC CC 15 00 00 00 ........ ........
+[A60] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[A70] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[A80] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[A90] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[AA0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[AB0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[AC0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[AD0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[AE0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[AF0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[B00] CC CC CC CC CC CC CC CC 14 00 00 00 CC CC CC CC ........ ........
+[B10] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[B20] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[B30] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[B40] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[B50] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[B60] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[B70] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[B80] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[B90] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[BA0] CC CC CC CC CC CC CC CC CC CC CC CC 13 00 00 00 ........ ........
+[BB0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[BC0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[BD0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[BE0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[BF0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[C00] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[C10] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[C20] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[C30] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[C40] CC CC CC CC CC CC CC CC 12 00 00 00 CC CC CC CC ........ ........
+[C50] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[C60] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[C70] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[C80] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[C90] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[CA0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[CB0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[CC0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[CD0] CC CC CC CC CC CC CC CC CC CC CC CC 11 00 00 00 ........ ........
+[CE0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[CF0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[D00] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[D10] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[D20] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[D30] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[D40] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[D50] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[D60] CC CC CC CC CC CC CC CC 10 00 00 00 CC CC CC CC ........ ........
+[D70] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[D80] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[D90] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[DA0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[DB0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[DC0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[DD0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[DE0] CC CC CC CC CC CC CC CC CC CC CC CC 0F 00 00 00 ........ ........
+[DF0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[E00] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[E10] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[E20] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[E30] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[E40] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[E50] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[E60] CC CC CC CC CC CC CC CC 0E 00 00 00 CC CC CC CC ........ ........
+[E70] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[E80] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[E90] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[EA0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[EB0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[EC0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[ED0] CC CC CC CC CC CC CC CC CC CC CC CC 0D 00 00 00 ........ ........
+[EE0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[EF0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[F00] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[F10] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[F20] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[F30] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[F40] CC CC CC CC CC CC CC CC 0C 00 00 00 CC CC CC CC ........ ........
+[F50] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[F60] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[F70] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[F80] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[F90] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[FA0] CC CC CC CC CC CC CC CC CC CC CC CC 0B 00 00 00 ........ ........
+[FB0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[FC0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[FD0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[FE0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[FF0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[1000] CC CC CC CC CC CC CC CC 0A 00 00 00 CC CC CC CC ........ ........
+[1010] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[1020] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[1030] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[1040] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[1050] CC CC CC CC CC CC CC CC CC CC CC CC 09 00 00 00 ........ ........
+[1060] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[1070] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[1080] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[1090] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[10A0] CC CC CC CC CC CC CC CC 08 00 00 00 CC CC CC CC ........ ........
+[10B0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[10C0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[10D0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[10E0] CC CC CC CC CC CC CC CC CC CC CC CC 07 00 00 00 ........ ........
+[10F0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[1100] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[1110] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[1120] CC CC CC CC CC CC CC CC 06 00 00 00 CC CC CC CC ........ ........
+[1130] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[1140] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[1150] CC CC CC CC CC CC CC CC CC CC CC CC 05 00 00 00 ........ ........
+[1160] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[1170] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[1180] CC CC CC CC CC CC CC CC 04 00 00 00 CC CC CC CC ........ ........
+[1190] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[11A0] CC CC CC CC CC CC CC CC CC CC CC CC 03 00 00 00 ........ ........
+[11B0] CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC ........ ........
+[11C0] CC CC CC CC CC CC CC CC 02 00 00 00 CC CC CC CC ........ ........
+[11D0] CC CC CC CC CC CC CC CC CC CC CC CC 01 00 00 00 ........ ........
+[11E0] CC CC CC CC CC CC CC CC 00 00 00 00 03 00 00 00 ........ ........
+[11F0] 00 00 02 00 03 00 00 00 BB BB BB 00 54 72 75 65 ........ ....True
+
+alloc1:outp: bsize[6664], bcount[1]
+alloc2:outp: bsize[6664], bcount[833]
+push:outp: ecount[104]
+alloc1:outp: bsize[6664], bcount[833]
+alloc2:outp: bsize[6664], bcount[833]
+push:outp: ecount[104]
+alloc1:outp: bsize[6664], bcount[833]
+alloc2:outp: bsize[6664], bcount[833]
+push:outp: ecount[104]
+alloc1:outp: bsize[6664], bcount[833]
+alloc2:outp: bsize[6664], bcount[833]
+push:outp: ecount[104]
+alloc1:outp: bsize[6664], bcount[833]
+alloc2:outp: bsize[6664], bcount[833]
+push:outp: ecount[104]
+alloc1:outp: bsize[6664], bcount[833]
+alloc2:outp: bsize[6664], bcount[833]
+push:outp: ecount[104]
+alloc1:outp: bsize[6664], bcount[833]
+alloc2:outp: bsize[6664], bcount[833]
+push:outp: ecount[104]
+alloc1:outp: bsize[6664], bcount[833]
+alloc2:outp: bsize[6664], bcount[833]
+push:outp: ecount[104]
+alloc1:outp: bsize[6664], bcount[833]
+alloc2:outp: bsize[6664], bcount[833]
+push:outp: ecount[104]
+alloc1:outp: bsize[6664], bcount[833]
+alloc2:outp: bsize[6664], bcount[833]
+push:outp: ecount[104]
+alloc1:outp: bsize[6664], bcount[833]
+alloc2:outp: bsize[6664], bcount[833]
+push:outp: ecount[104]
+alloc1:outp: bsize[6664], bcount[833]
+alloc2:outp: bsize[6664], bcount[833]
+push:outp: ecount[104]
+alloc1:outp: bsize[6664], bcount[833]
+alloc2:outp: bsize[6664], bcount[833]
+push:outp: ecount[27]
+push:outp: ecount[0]
+NDRTcpThread[ndr64] stop
+NDRTcpThread[ndr64] stop
+
+Test OK
diff --git a/testprogs/win32/midltests/valid/midltests_DRS_EXTENSIONS.idl b/testprogs/win32/midltests/valid/midltests_DRS_EXTENSIONS.idl
new file mode 100644
index 0000000..73aeb16
--- /dev/null
+++ b/testprogs/win32/midltests/valid/midltests_DRS_EXTENSIONS.idl
@@ -0,0 +1,64 @@
+#ifndef MIDLTESTS_C_CODE
+
+/*
+ * For midltests_tcp.exe you may want to
+ * redirect the traffic via rinetd
+ * with a /etc/rinetd.conf like this:
+ *
+ * 172.31.9.1 5032 172.31.9.8 5032
+ * 172.31.9.1 5064 172.31.9.8 5064
+ *
+ * This is useful to watch the traffic with
+ * a network sniffer.
+ */
+/*
+cpp_quote("#define LISTEN_IP \"0.0.0.0\"")
+cpp_quote("#define FORWARD_IP \"127.0.0.1\"")
+cpp_quote("#define CONNECT_IP \"172.31.9.1\"")
+*/
+
+/*
+ * With midltests_tcp.exe NDR64 is enforced by default.
+ * For testing it might be needed to allow downgrades
+ * to NDR32. This is needed when you use 'pipe'.
+ */
+//cpp_quote("#define DONOT_FORCE_NDR64 1")
+
+[
+ uuid("225b9fcb-eb3d-497b-8b0b-591f049a2507"),
+ pointer_default(unique)
+]
+interface midltests
+{
+
+ typedef struct {
+ [range(1,10000)] long cb;
+ [size_is(cb)] char rcg[];
+ } DRS_EXTENSIONS;
+
+ long midltests_fn(
+ [out] DRS_EXTENSIONS **e
+ );
+}
+
+#elif MIDLTESTS_C_CODE
+
+static void midltests(void)
+{
+ DRS_EXTENSIONS *e = NULL;
+ cli_midltests_fn(&e);
+}
+
+long srv_midltests_fn(DRS_EXTENSIONS **_e)
+{
+ DRS_EXTENSIONS *e;
+ printf("srv_midltests_fn: Start\n");
+ e = (DRS_EXTENSIONS *)malloc(sizeof(DRS_EXTENSIONS) + 0x34);
+ e->cb = 0x34;
+ memset(e->rcg, 0xcd, e->cb);
+ *_e = e;
+ printf("srv_midltests_fn: End\n");
+ return 0x65757254;
+}
+
+#endif
diff --git a/testprogs/win32/midltests/valid/midltests_DRS_EXTENSIONS.out b/testprogs/win32/midltests/valid/midltests_DRS_EXTENSIONS.out
new file mode 100644
index 0000000..e0b3a0e
--- /dev/null
+++ b/testprogs/win32/midltests/valid/midltests_DRS_EXTENSIONS.out
@@ -0,0 +1,43 @@
+Wait for setup of server threads
+
+Test NDR32
+
+ndr32: disable NDR64
+
+ndr32:in => out: ptype[request] flen[24] plen[0] ahint[0]
+
+
+srv_midltests_fn: Start
+srv_midltests_fn: End
+
+ndr32:out => in: ptype[response] flen[92] plen[68] ahint[68]
+
+[000] 00 00 02 00 34 00 00 00 34 00 00 00 CD CD CD CD ....4... 4.......
+[010] CD CD CD CD CD CD CD CD CD CD CD CD CD CD CD CD ........ ........
+[020] CD CD CD CD CD CD CD CD CD CD CD CD CD CD CD CD ........ ........
+[030] CD CD CD CD CD CD CD CD CD CD CD CD CD CD CD CD ........ ........
+[040] 54 72 75 65 True
+
+NDRTcpThread[ndr32] stop
+
+Test NDR64
+
+ndr64: got NDR64
+
+ndr64:in => out: ptype[request] flen[24] plen[0] ahint[0]
+
+
+srv_midltests_fn: Start
+srv_midltests_fn: End
+
+ndr64:out => in: ptype[response] flen[100] plen[76] ahint[76]
+
+[000] 00 00 02 00 00 00 00 00 34 00 00 00 00 00 00 00 ........ 4.......
+[010] 34 00 00 00 CD CD CD CD CD CD CD CD CD CD CD CD 4....... ........
+[020] CD CD CD CD CD CD CD CD CD CD CD CD CD CD CD CD ........ ........
+[030] CD CD CD CD CD CD CD CD CD CD CD CD CD CD CD CD ........ ........
+[040] CD CD CD CD CD CD CD CD 54 72 75 65 ........ True
+
+NDRTcpThread[ndr64] stop
+
+Test OK
diff --git a/testprogs/win32/midltests/valid/midltests_fixed_size_in_array_01.idl b/testprogs/win32/midltests/valid/midltests_fixed_size_in_array_01.idl
new file mode 100644
index 0000000..170b147
--- /dev/null
+++ b/testprogs/win32/midltests/valid/midltests_fixed_size_in_array_01.idl
@@ -0,0 +1,29 @@
+#ifndef MIDLTESTS_C_CODE
+
+[
+ uuid("225b9fcb-eb3d-497b-8b0b-591f049a2507"),
+ pointer_default(unique)
+]
+interface midltests
+{
+ long midltests_fn(
+ [in] long a[2]
+ );
+}
+
+#elif MIDLTESTS_C_CODE
+
+static void midltests(void)
+{
+ long a[2] = { 1, 2 };
+ cli_midltests_fn(a);
+}
+
+long srv_midltests_fn(long a[2])
+{
+ printf("srv_midltests_fn: Start\n");
+ printf("srv_midltests_fn: End\n");
+ return 0x65757254;
+}
+
+#endif
diff --git a/testprogs/win32/midltests/valid/midltests_fixed_size_in_array_01.txt b/testprogs/win32/midltests/valid/midltests_fixed_size_in_array_01.txt
new file mode 100644
index 0000000..8903c4c
--- /dev/null
+++ b/testprogs/win32/midltests/valid/midltests_fixed_size_in_array_01.txt
@@ -0,0 +1,6 @@
+[in] Buffer[8/24]
+[000] 01 00 00 00 02 00 00 00 ........
+srv_midltests_fn: Start
+srv_midltests_fn: End
+[out] Buffer[4]
+[000] 54 72 75 65 True
diff --git a/testprogs/win32/midltests/valid/midltests_strings_array_01.err.txt b/testprogs/win32/midltests/valid/midltests_strings_array_01.err.txt
new file mode 100644
index 0000000..dbbc89a
--- /dev/null
+++ b/testprogs/win32/midltests/valid/midltests_strings_array_01.err.txt
@@ -0,0 +1,13 @@
+[in] Buffer[53/53]
+[000] 03 00 00 00 03 00 00 00 00 00 02 00 04 00 02 00 ........ ........
+[010] 00 00 00 00 04 00 00 00 00 00 00 00 04 00 00 00 ........ ........
+[020] 66 6F 6F 00 05 00 00 00 00 00 00 00 05 00 00 00 foo..... ........
+[030] 62 61 72 32 00 bar2.
+srv_midltests_fn: Start
+srv_midltests_fn: End
+[out] Buffer[60]
+[000] 03 00 00 00 03 00 00 00 00 00 02 00 04 00 02 00 ........ ........
+[010] 00 00 00 00 04 00 00 00 00 00 00 00 04 00 00 00 ........ ........
+[020] 66 6F 6F 00 05 00 00 00 00 00 00 00 05 00 00 00 foo..... ........
+[030] 62 61 72 32 00 00 00 00 54 72 75 65 bar2.... True
+Runtime error 0x6f7
diff --git a/testprogs/win32/midltests/valid/midltests_strings_array_01.idl b/testprogs/win32/midltests/valid/midltests_strings_array_01.idl
new file mode 100644
index 0000000..db05bb2
--- /dev/null
+++ b/testprogs/win32/midltests/valid/midltests_strings_array_01.idl
@@ -0,0 +1,44 @@
+#ifndef MIDLTESTS_C_CODE
+
+[
+ uuid("225b9fcb-eb3d-497b-8b0b-591f049a2507"),
+ pointer_default(unique)
+]
+interface midltests
+{
+ struct strings {
+ long count;
+ [size_is(count),string] char *val[];
+ };
+
+ long midltests_fn(
+ [in,out,ref] struct strings *s
+ );
+}
+
+#elif MIDLTESTS_C_CODE
+
+static void midltests(void)
+{
+ const char *s1 = "foo";
+ const char *s2 = "bar";
+ char *a[] = { "foo", "bar2", NULL };
+ char buffer[1024];
+ struct strings *s = buffer;
+
+ s->count = 3;
+ s->val[0] = "foo";
+ s->val[1] = "bar2";
+ s->val[2] = NULL;
+
+ cli_midltests_fn(s);
+}
+
+long srv_midltests_fn(struct strings *a)
+{
+ printf("srv_midltests_fn: Start\n");
+ printf("srv_midltests_fn: End\n");
+ return 0x65757254;
+}
+
+#endif
diff --git a/testprogs/win32/midltests/valid/midltests_strings_array_02.idl b/testprogs/win32/midltests/valid/midltests_strings_array_02.idl
new file mode 100644
index 0000000..46154c9
--- /dev/null
+++ b/testprogs/win32/midltests/valid/midltests_strings_array_02.idl
@@ -0,0 +1,44 @@
+#ifndef MIDLTESTS_C_CODE
+
+[
+ uuid("225b9fcb-eb3d-497b-8b0b-591f049a2507"),
+ pointer_default(unique)
+]
+interface midltests
+{
+ struct strings {
+ long count;
+ [size_is(count),string] char *val[];
+ };
+
+ long midltests_fn(
+ [in,ref] struct strings *s
+ );
+}
+
+#elif MIDLTESTS_C_CODE
+
+static void midltests(void)
+{
+ const char *s1 = "foo";
+ const char *s2 = "bar";
+ char *a[] = { "foo", "bar2", NULL };
+ char buffer[1024];
+ struct strings *s = buffer;
+
+ s->count = 3;
+ s->val[0] = "foo";
+ s->val[1] = "bar2";
+ s->val[2] = NULL;
+
+ cli_midltests_fn(s);
+}
+
+long srv_midltests_fn(struct strings *a)
+{
+ printf("srv_midltests_fn: Start\n");
+ printf("srv_midltests_fn: End\n");
+ return 0x65757254;
+}
+
+#endif
diff --git a/testprogs/win32/midltests/valid/midltests_strings_array_02.txt b/testprogs/win32/midltests/valid/midltests_strings_array_02.txt
new file mode 100644
index 0000000..2bec6a0
--- /dev/null
+++ b/testprogs/win32/midltests/valid/midltests_strings_array_02.txt
@@ -0,0 +1,9 @@
+[in] Buffer[53/53]
+[000] 03 00 00 00 03 00 00 00 00 00 02 00 04 00 02 00 ........ ........
+[010] 00 00 00 00 04 00 00 00 00 00 00 00 04 00 00 00 ........ ........
+[020] 66 6F 6F 00 05 00 00 00 00 00 00 00 05 00 00 00 foo..... ........
+[030] 62 61 72 32 00 bar2.
+srv_midltests_fn: Start
+srv_midltests_fn: End
+[out] Buffer[4]
+[000] 54 72 75 65 True
diff --git a/testprogs/win32/midltests/valid/midltests_union_align_01.idl b/testprogs/win32/midltests/valid/midltests_union_align_01.idl
new file mode 100644
index 0000000..fcea072
--- /dev/null
+++ b/testprogs/win32/midltests/valid/midltests_union_align_01.idl
@@ -0,0 +1,42 @@
+#ifndef MIDLTESTS_C_CODE
+
+[
+ uuid("225b9fcb-eb3d-497b-8b0b-591f049a2507"),
+ pointer_default(unique)
+]
+interface midltests
+{
+ [switch_type(short)] union u {
+ [case(0)];
+ [case(2)] short s;
+ [case(4)] long l;
+ [case(8)] hyper h;
+ };
+
+ long midltests_fn(
+ [in] short level,
+ [in,switch_is(level)] union u u
+ );
+}
+
+#elif MIDLTESTS_C_CODE
+
+static void midltests(void)
+{
+ union u u;
+ u.h = 0xFFFFFFFFFFFFFFFFLL;
+
+ cli_midltests_fn(0, u);
+ cli_midltests_fn(2, u);
+ cli_midltests_fn(4, u);
+ cli_midltests_fn(8, u);
+}
+
+long srv_midltests_fn(short level, union u u)
+{
+ printf("srv_midltests_fn: Start\n");
+ printf("srv_midltests_fn: End\n");
+ return 0x65757254;
+}
+
+#endif
diff --git a/testprogs/win32/midltests/valid/midltests_union_align_01.txt b/testprogs/win32/midltests/valid/midltests_union_align_01.txt
new file mode 100644
index 0000000..cc372c8
--- /dev/null
+++ b/testprogs/win32/midltests/valid/midltests_union_align_01.txt
@@ -0,0 +1,24 @@
+[in] Buffer[4/8]
+[000] 00 00 00 00 ....
+srv_midltests_fn: Start
+srv_midltests_fn: End
+[out] Buffer[4]
+[000] 54 72 75 65 True
+[in] Buffer[6/10]
+[000] 02 00 02 00 FF FF ......
+srv_midltests_fn: Start
+srv_midltests_fn: End
+[out] Buffer[4]
+[000] 54 72 75 65 True
+[in] Buffer[8/12]
+[000] 04 00 04 00 FF FF FF FF ........
+srv_midltests_fn: Start
+srv_midltests_fn: End
+[out] Buffer[4]
+[000] 54 72 75 65 True
+[in] Buffer[16/16]
+[000] 08 00 08 00 00 00 00 00 FF FF FF FF FF FF FF FF ........ ........
+srv_midltests_fn: Start
+srv_midltests_fn: End
+[out] Buffer[4]
+[000] 54 72 75 65 True
diff --git a/testprogs/win32/midltests/valid/midltests_union_align_02.idl b/testprogs/win32/midltests/valid/midltests_union_align_02.idl
new file mode 100644
index 0000000..dc2d84d
--- /dev/null
+++ b/testprogs/win32/midltests/valid/midltests_union_align_02.idl
@@ -0,0 +1,61 @@
+#ifndef MIDLTESTS_C_CODE
+
+/*
+ * For midltests_tcp.exe you may want to
+ * redirect the traffic via rinetd
+ * with a /etc/rinetd.conf like this:
+ *
+ * 172.31.9.1 5032 172.31.9.8 5032
+ * 172.31.9.1 5064 172.31.9.8 5064
+ *
+ * This is useful to watch the traffic with
+ * a network sniffer.
+ */
+/*
+cpp_quote("#define LISTEN_IP \"0.0.0.0\"")
+cpp_quote("#define FORWARD_IP \"127.0.0.1\"")
+cpp_quote("#define CONNECT_IP \"172.31.9.1\"")
+*/
+
+/*
+ * With midltests_tcp.exe NDR64 is enforced by default.
+ * For testing it might be needed to allow downgrades
+ * to NDR32. This is needed when you use 'pipe'.
+ */
+//cpp_quote("#define DONOT_FORCE_NDR64 1")
+
+[
+ uuid("225b9fcb-eb3d-497b-8b0b-591f049a2507"),
+ pointer_default(unique)
+]
+interface midltests
+{
+ typedef [switch_type(char)] union {
+ [case(1)] char c;
+ } u;
+ long midltests_fn(
+ [in] char l,
+ [in,switch_is(l)] u u
+ );
+}
+
+#elif MIDLTESTS_C_CODE
+
+static void midltests(void)
+{
+ char l;
+ u u;
+
+ l = 1;
+ u.c = 'A';
+ cli_midltests_fn(l,u);
+}
+
+long srv_midltests_fn(char l, u u)
+{
+ printf("srv_midltests_fn: Start\n");
+ printf("srv_midltests_fn: End\n");
+ return 0x65757254;
+}
+
+#endif
diff --git a/testprogs/win32/midltests/valid/midltests_union_align_02.txt b/testprogs/win32/midltests/valid/midltests_union_align_02.txt
new file mode 100644
index 0000000..16186ea
--- /dev/null
+++ b/testprogs/win32/midltests/valid/midltests_union_align_02.txt
@@ -0,0 +1,37 @@
+Wait for setup of server threads
+
+Test NDR32
+
+ndr32: disable NDR64
+
+ndr32:in => out: ptype[request] flen[27] plen[3] ahint[3]
+
+[000] 01 01 41 ..A
+
+srv_midltests_fn: Start
+srv_midltests_fn: End
+
+ndr32:out => in: ptype[response] flen[28] plen[4] ahint[4]
+
+[000] 54 72 75 65 True
+
+NDRTcpThread[ndr32] stop
+
+Test NDR64
+
+ndr64: got NDR64
+
+ndr64:in => out: ptype[request] flen[27] plen[3] ahint[3]
+
+[000] 01 01 41 ..A
+
+srv_midltests_fn: Start
+srv_midltests_fn: End
+
+ndr64:out => in: ptype[response] flen[28] plen[4] ahint[4]
+
+[000] 54 72 75 65 True
+
+NDRTcpThread[ndr64] stop
+
+Test OK
diff --git a/testprogs/win32/midltests/valid/midltests_union_align_03.idl b/testprogs/win32/midltests/valid/midltests_union_align_03.idl
new file mode 100644
index 0000000..699dd6c
--- /dev/null
+++ b/testprogs/win32/midltests/valid/midltests_union_align_03.idl
@@ -0,0 +1,64 @@
+#ifndef MIDLTESTS_C_CODE
+
+/*
+ * For midltests_tcp.exe you may want to
+ * redirect the traffic via rinetd
+ * with a /etc/rinetd.conf like this:
+ *
+ * 172.31.9.1 5032 172.31.9.8 5032
+ * 172.31.9.1 5064 172.31.9.8 5064
+ *
+ * This is useful to watch the traffic with
+ * a network sniffer.
+ */
+/*
+cpp_quote("#define LISTEN_IP \"0.0.0.0\"")
+cpp_quote("#define FORWARD_IP \"127.0.0.1\"")
+cpp_quote("#define CONNECT_IP \"172.31.9.1\"")
+*/
+
+/*
+ * With midltests_tcp.exe NDR64 is enforced by default.
+ * For testing it might be needed to allow downgrades
+ * to NDR32. This is needed when you use 'pipe'.
+ */
+//cpp_quote("#define DONOT_FORCE_NDR64 1")
+
+[
+ uuid("225b9fcb-eb3d-497b-8b0b-591f049a2507"),
+ pointer_default(unique)
+]
+interface midltests
+{
+ typedef [switch_type(short)] union {
+ [case(1)] char c;
+ } u;
+ long midltests_fn(
+ [in] short l,
+ [in] char v,
+ [in,switch_is(l)] u u
+ );
+}
+
+#elif MIDLTESTS_C_CODE
+
+static void midltests(void)
+{
+ short l;
+ char v;
+ u u;
+
+ l = 1;
+ v = 'V';
+ u.c = 'C';
+ cli_midltests_fn(l, v, u);
+}
+
+long srv_midltests_fn(short l, char v, u u)
+{
+ printf("srv_midltests_fn: Start\n");
+ printf("srv_midltests_fn: End\n");
+ return 0x65757254;
+}
+
+#endif
diff --git a/testprogs/win32/midltests/valid/midltests_union_align_03.txt b/testprogs/win32/midltests/valid/midltests_union_align_03.txt
new file mode 100644
index 0000000..7078dd3
--- /dev/null
+++ b/testprogs/win32/midltests/valid/midltests_union_align_03.txt
@@ -0,0 +1,37 @@
+Wait for setup of server threads
+
+Test NDR32
+
+ndr32: disable NDR64
+
+ndr32:in => out: ptype[request] flen[31] plen[7] ahint[7]
+
+[000] 01 00 56 00 01 00 43 ..V...C
+
+srv_midltests_fn: Start
+srv_midltests_fn: End
+
+ndr32:out => in: ptype[response] flen[28] plen[4] ahint[4]
+
+[000] 54 72 75 65 True
+
+NDRTcpThread[ndr32] stop
+
+Test NDR64
+
+ndr64: got NDR64
+
+ndr64:in => out: ptype[request] flen[31] plen[7] ahint[7]
+
+[000] 01 00 56 00 01 00 43 ..V...C
+
+srv_midltests_fn: Start
+srv_midltests_fn: End
+
+ndr64:out => in: ptype[response] flen[28] plen[4] ahint[4]
+
+[000] 54 72 75 65 True
+
+NDRTcpThread[ndr64] stop
+
+Test OK
diff --git a/testprogs/win32/midltests/valid/midltests_union_align_04.idl b/testprogs/win32/midltests/valid/midltests_union_align_04.idl
new file mode 100644
index 0000000..a7c6ad7
--- /dev/null
+++ b/testprogs/win32/midltests/valid/midltests_union_align_04.idl
@@ -0,0 +1,64 @@
+#ifndef MIDLTESTS_C_CODE
+
+/*
+ * For midltests_tcp.exe you may want to
+ * redirect the traffic via rinetd
+ * with a /etc/rinetd.conf like this:
+ *
+ * 172.31.9.1 5032 172.31.9.8 5032
+ * 172.31.9.1 5064 172.31.9.8 5064
+ *
+ * This is useful to watch the traffic with
+ * a network sniffer.
+ */
+/*
+cpp_quote("#define LISTEN_IP \"0.0.0.0\"")
+cpp_quote("#define FORWARD_IP \"127.0.0.1\"")
+cpp_quote("#define CONNECT_IP \"172.31.9.1\"")
+*/
+
+/*
+ * With midltests_tcp.exe NDR64 is enforced by default.
+ * For testing it might be needed to allow downgrades
+ * to NDR32. This is needed when you use 'pipe'.
+ */
+//cpp_quote("#define DONOT_FORCE_NDR64 1")
+
+[
+ uuid("225b9fcb-eb3d-497b-8b0b-591f049a2507"),
+ pointer_default(unique)
+]
+interface midltests
+{
+ typedef [switch_type(long)] union {
+ [case(1)] char c;
+ } u;
+ long midltests_fn(
+ [in] long l,
+ [in] char v,
+ [in,switch_is(l)] u u
+ );
+}
+
+#elif MIDLTESTS_C_CODE
+
+static void midltests(void)
+{
+ long l;
+ char v;
+ u u;
+
+ l = 1;
+ v = 'V';
+ u.c = 'C';
+ cli_midltests_fn(l, v, u);
+}
+
+long srv_midltests_fn(long l, char v, u u)
+{
+ printf("srv_midltests_fn: Start\n");
+ printf("srv_midltests_fn: End\n");
+ return 0x65757254;
+}
+
+#endif
diff --git a/testprogs/win32/midltests/valid/midltests_union_align_04.txt b/testprogs/win32/midltests/valid/midltests_union_align_04.txt
new file mode 100644
index 0000000..d323860
--- /dev/null
+++ b/testprogs/win32/midltests/valid/midltests_union_align_04.txt
@@ -0,0 +1,37 @@
+Wait for setup of server threads
+
+Test NDR32
+
+ndr32: disable NDR64
+
+ndr32:in => out: ptype[request] flen[37] plen[13] ahint[13]
+
+[000] 01 00 00 00 56 00 00 00 01 00 00 00 43 ....V... ....C
+
+srv_midltests_fn: Start
+srv_midltests_fn: End
+
+ndr32:out => in: ptype[response] flen[28] plen[4] ahint[4]
+
+[000] 54 72 75 65 True
+
+NDRTcpThread[ndr32] stop
+
+Test NDR64
+
+ndr64: got NDR64
+
+ndr64:in => out: ptype[request] flen[37] plen[13] ahint[13]
+
+[000] 01 00 00 00 56 00 00 00 01 00 00 00 43 ....V... ....C
+
+srv_midltests_fn: Start
+srv_midltests_fn: End
+
+ndr64:out => in: ptype[response] flen[28] plen[4] ahint[4]
+
+[000] 54 72 75 65 True
+
+NDRTcpThread[ndr64] stop
+
+Test OK
diff --git a/testprogs/win32/midltests/valid/midltests_union_align_05.idl b/testprogs/win32/midltests/valid/midltests_union_align_05.idl
new file mode 100644
index 0000000..da46bab
--- /dev/null
+++ b/testprogs/win32/midltests/valid/midltests_union_align_05.idl
@@ -0,0 +1,61 @@
+#ifndef MIDLTESTS_C_CODE
+
+/*
+ * For midltests_tcp.exe you may want to
+ * redirect the traffic via rinetd
+ * with a /etc/rinetd.conf like this:
+ *
+ * 172.31.9.1 5032 172.31.9.8 5032
+ * 172.31.9.1 5064 172.31.9.8 5064
+ *
+ * This is useful to watch the traffic with
+ * a network sniffer.
+ */
+/*
+cpp_quote("#define LISTEN_IP \"0.0.0.0\"")
+cpp_quote("#define FORWARD_IP \"127.0.0.1\"")
+cpp_quote("#define CONNECT_IP \"172.31.9.1\"")
+*/
+
+/*
+ * With midltests_tcp.exe NDR64 is enforced by default.
+ * For testing it might be needed to allow downgrades
+ * to NDR32. This is needed when you use 'pipe'.
+ */
+//cpp_quote("#define DONOT_FORCE_NDR64 1")
+
+[
+ uuid("225b9fcb-eb3d-497b-8b0b-591f049a2507"),
+ pointer_default(unique)
+]
+interface midltests
+{
+ typedef [switch_type(char)] union {
+ [case(1)] short c;
+ } u;
+ long midltests_fn(
+ [in] char l,
+ [in,switch_is(l)] u u
+ );
+}
+
+#elif MIDLTESTS_C_CODE
+
+static void midltests(void)
+{
+ char l;
+ u u;
+
+ l = 1;
+ u.c = 'C';
+ cli_midltests_fn(l, u);
+}
+
+long srv_midltests_fn(hyper l, u u)
+{
+ printf("srv_midltests_fn: Start\n");
+ printf("srv_midltests_fn: End\n");
+ return 0x65757254;
+}
+
+#endif
diff --git a/testprogs/win32/midltests/valid/midltests_union_align_05.txt b/testprogs/win32/midltests/valid/midltests_union_align_05.txt
new file mode 100644
index 0000000..1938b0a
--- /dev/null
+++ b/testprogs/win32/midltests/valid/midltests_union_align_05.txt
@@ -0,0 +1,37 @@
+Wait for setup of server threads
+
+Test NDR32
+
+ndr32: disable NDR64
+
+ndr32:in => out: ptype[request] flen[28] plen[4] ahint[4]
+
+[000] 01 01 43 00 ..C.
+
+srv_midltests_fn: Start
+srv_midltests_fn: End
+
+ndr32:out => in: ptype[response] flen[28] plen[4] ahint[4]
+
+[000] 54 72 75 65 True
+
+NDRTcpThread[ndr32] stop
+
+Test NDR64
+
+ndr64: got NDR64
+
+ndr64:in => out: ptype[request] flen[30] plen[6] ahint[6]
+
+[000] 01 00 01 00 43 00 ....C.
+
+srv_midltests_fn: Start
+srv_midltests_fn: End
+
+ndr64:out => in: ptype[response] flen[28] plen[4] ahint[4]
+
+[000] 54 72 75 65 True
+
+NDRTcpThread[ndr64] stop
+
+Test OK
diff --git a/testprogs/win32/midltests/valid/midltests_union_align_06.idl b/testprogs/win32/midltests/valid/midltests_union_align_06.idl
new file mode 100644
index 0000000..63fb310
--- /dev/null
+++ b/testprogs/win32/midltests/valid/midltests_union_align_06.idl
@@ -0,0 +1,61 @@
+#ifndef MIDLTESTS_C_CODE
+
+/*
+ * For midltests_tcp.exe you may want to
+ * redirect the traffic via rinetd
+ * with a /etc/rinetd.conf like this:
+ *
+ * 172.31.9.1 5032 172.31.9.8 5032
+ * 172.31.9.1 5064 172.31.9.8 5064
+ *
+ * This is useful to watch the traffic with
+ * a network sniffer.
+ */
+/*
+cpp_quote("#define LISTEN_IP \"0.0.0.0\"")
+cpp_quote("#define FORWARD_IP \"127.0.0.1\"")
+cpp_quote("#define CONNECT_IP \"172.31.9.1\"")
+*/
+
+/*
+ * With midltests_tcp.exe NDR64 is enforced by default.
+ * For testing it might be needed to allow downgrades
+ * to NDR32. This is needed when you use 'pipe'.
+ */
+//cpp_quote("#define DONOT_FORCE_NDR64 1")
+
+[
+ uuid("225b9fcb-eb3d-497b-8b0b-591f049a2507"),
+ pointer_default(unique)
+]
+interface midltests
+{
+ typedef [switch_type(char)] union {
+ [case(1)] long c;
+ } u;
+ long midltests_fn(
+ [in] char l,
+ [in,switch_is(l)] u u
+ );
+}
+
+#elif MIDLTESTS_C_CODE
+
+static void midltests(void)
+{
+ char l;
+ u u;
+
+ l = 1;
+ u.c = 'C';
+ cli_midltests_fn(l, u);
+}
+
+long srv_midltests_fn(hyper l, u u)
+{
+ printf("srv_midltests_fn: Start\n");
+ printf("srv_midltests_fn: End\n");
+ return 0x65757254;
+}
+
+#endif
diff --git a/testprogs/win32/midltests/valid/midltests_union_align_06.txt b/testprogs/win32/midltests/valid/midltests_union_align_06.txt
new file mode 100644
index 0000000..c864e51
--- /dev/null
+++ b/testprogs/win32/midltests/valid/midltests_union_align_06.txt
@@ -0,0 +1,37 @@
+Wait for setup of server threads
+
+Test NDR32
+
+ndr32: disable NDR64
+
+ndr32:in => out: ptype[request] flen[32] plen[8] ahint[8]
+
+[000] 01 01 00 00 43 00 00 00 ....C...
+
+srv_midltests_fn: Start
+srv_midltests_fn: End
+
+ndr32:out => in: ptype[response] flen[28] plen[4] ahint[4]
+
+[000] 54 72 75 65 True
+
+NDRTcpThread[ndr32] stop
+
+Test NDR64
+
+ndr64: got NDR64
+
+ndr64:in => out: ptype[request] flen[36] plen[12] ahint[12]
+
+[000] 01 00 00 00 01 00 00 00 43 00 00 00 ........ C...
+
+srv_midltests_fn: Start
+srv_midltests_fn: End
+
+ndr64:out => in: ptype[response] flen[28] plen[4] ahint[4]
+
+[000] 54 72 75 65 True
+
+NDRTcpThread[ndr64] stop
+
+Test OK
diff --git a/testprogs/win32/midltests/valid/midltests_union_align_07.idl b/testprogs/win32/midltests/valid/midltests_union_align_07.idl
new file mode 100644
index 0000000..892460d
--- /dev/null
+++ b/testprogs/win32/midltests/valid/midltests_union_align_07.idl
@@ -0,0 +1,61 @@
+#ifndef MIDLTESTS_C_CODE
+
+/*
+ * For midltests_tcp.exe you may want to
+ * redirect the traffic via rinetd
+ * with a /etc/rinetd.conf like this:
+ *
+ * 172.31.9.1 5032 172.31.9.8 5032
+ * 172.31.9.1 5064 172.31.9.8 5064
+ *
+ * This is useful to watch the traffic with
+ * a network sniffer.
+ */
+/*
+cpp_quote("#define LISTEN_IP \"0.0.0.0\"")
+cpp_quote("#define FORWARD_IP \"127.0.0.1\"")
+cpp_quote("#define CONNECT_IP \"172.31.9.1\"")
+*/
+
+/*
+ * With midltests_tcp.exe NDR64 is enforced by default.
+ * For testing it might be needed to allow downgrades
+ * to NDR32. This is needed when you use 'pipe'.
+ */
+//cpp_quote("#define DONOT_FORCE_NDR64 1")
+
+[
+ uuid("225b9fcb-eb3d-497b-8b0b-591f049a2507"),
+ pointer_default(unique)
+]
+interface midltests
+{
+ typedef [switch_type(char)] union {
+ [case(1)] hyper c;
+ } u;
+ long midltests_fn(
+ [in] char l,
+ [in,switch_is(l)] u u
+ );
+}
+
+#elif MIDLTESTS_C_CODE
+
+static void midltests(void)
+{
+ char l;
+ u u;
+
+ l = 1;
+ u.c = 'C';
+ cli_midltests_fn(l, u);
+}
+
+long srv_midltests_fn(hyper l, u u)
+{
+ printf("srv_midltests_fn: Start\n");
+ printf("srv_midltests_fn: End\n");
+ return 0x65757254;
+}
+
+#endif
diff --git a/testprogs/win32/midltests/valid/midltests_union_align_07.txt b/testprogs/win32/midltests/valid/midltests_union_align_07.txt
new file mode 100644
index 0000000..88b44ec
--- /dev/null
+++ b/testprogs/win32/midltests/valid/midltests_union_align_07.txt
@@ -0,0 +1,38 @@
+Wait for setup of server threads
+
+Test NDR32
+
+ndr32: disable NDR64
+
+ndr32:in => out: ptype[request] flen[40] plen[16] ahint[16]
+
+[000] 01 01 00 00 00 00 00 00 43 00 00 00 00 00 00 00 ........ C.......
+
+srv_midltests_fn: Start
+srv_midltests_fn: End
+
+ndr32:out => in: ptype[response] flen[28] plen[4] ahint[4]
+
+[000] 54 72 75 65 True
+
+NDRTcpThread[ndr32] stop
+
+Test NDR64
+
+ndr64: got NDR64
+
+ndr64:in => out: ptype[request] flen[48] plen[24] ahint[24]
+
+[000] 01 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 ........ ........
+[010] 43 00 00 00 00 00 00 00 C.......
+
+srv_midltests_fn: Start
+srv_midltests_fn: End
+
+ndr64:out => in: ptype[response] flen[28] plen[4] ahint[4]
+
+[000] 54 72 75 65 True
+
+NDRTcpThread[ndr64] stop
+
+Test OK
diff --git a/testprogs/win32/midltests/valid/midltests_union_align_08.idl b/testprogs/win32/midltests/valid/midltests_union_align_08.idl
new file mode 100644
index 0000000..0cbdbfe
--- /dev/null
+++ b/testprogs/win32/midltests/valid/midltests_union_align_08.idl
@@ -0,0 +1,68 @@
+#ifndef MIDLTESTS_C_CODE
+
+/*
+ * For midltests_tcp.exe you may want to
+ * redirect the traffic via rinetd
+ * with a /etc/rinetd.conf like this:
+ *
+ * 172.31.9.1 5032 172.31.9.8 5032
+ * 172.31.9.1 5064 172.31.9.8 5064
+ *
+ * This is useful to watch the traffic with
+ * a network sniffer.
+ */
+/*
+cpp_quote("#define LISTEN_IP \"0.0.0.0\"")
+cpp_quote("#define FORWARD_IP \"127.0.0.1\"")
+cpp_quote("#define CONNECT_IP \"172.31.9.1\"")
+*/
+
+/*
+ * With midltests_tcp.exe NDR64 is enforced by default.
+ * For testing it might be needed to allow downgrades
+ * to NDR32. This is needed when you use 'pipe'.
+ */
+//cpp_quote("#define DONOT_FORCE_NDR64 1")
+
+[
+ uuid("225b9fcb-eb3d-497b-8b0b-591f049a2507"),
+ pointer_default(unique)
+]
+interface midltests
+{
+ [switch_type(char)] union u {
+ [case(0)];
+ [case(1)] char c;
+ [case(2)] short s;
+ [case(4)] long l;
+ [case(8)] hyper h;
+ };
+
+ long midltests_fn(
+ [in] char level,
+ [in,switch_is(level)] union u u
+ );
+}
+
+#elif MIDLTESTS_C_CODE
+
+static void midltests(void)
+{
+ union u u;
+ u.h = 0xFFFFFFFFFFFFFFFFLL;
+
+ cli_midltests_fn(0, u);
+ cli_midltests_fn(1, u);
+ cli_midltests_fn(2, u);
+ cli_midltests_fn(4, u);
+ cli_midltests_fn(8, u);
+}
+
+long srv_midltests_fn(char level, union u u)
+{
+ printf("srv_midltests_fn: Start\n");
+ printf("srv_midltests_fn: End\n");
+ return 0x65757254;
+}
+
+#endif
diff --git a/testprogs/win32/midltests/valid/midltests_union_align_08.txt b/testprogs/win32/midltests/valid/midltests_union_align_08.txt
new file mode 100644
index 0000000..1bf5cd9
--- /dev/null
+++ b/testprogs/win32/midltests/valid/midltests_union_align_08.txt
@@ -0,0 +1,129 @@
+Wait for setup of server threads
+
+Test NDR32
+
+ndr32: disable NDR64
+
+ndr32:in => out: ptype[request] flen[26] plen[2] ahint[2]
+
+[000] 00 00 ..
+
+srv_midltests_fn: Start
+srv_midltests_fn: End
+
+ndr32:out => in: ptype[response] flen[28] plen[4] ahint[4]
+
+[000] 54 72 75 65 True
+
+ndr32:in => out: ptype[request] flen[27] plen[3] ahint[3]
+
+[000] 01 01 FF ...
+
+srv_midltests_fn: Start
+srv_midltests_fn: End
+
+ndr32:out => in: ptype[response] flen[28] plen[4] ahint[4]
+
+[000] 54 72 75 65 True
+
+ndr32:in => out: ptype[request] flen[28] plen[4] ahint[4]
+
+[000] 02 02 FF FF ....
+
+srv_midltests_fn: Start
+srv_midltests_fn: End
+
+ndr32:out => in: ptype[response] flen[28] plen[4] ahint[4]
+
+[000] 54 72 75 65 True
+
+ndr32:in => out: ptype[request] flen[32] plen[8] ahint[8]
+
+[000] 04 04 00 00 FF FF FF FF ........
+
+srv_midltests_fn: Start
+srv_midltests_fn: End
+
+ndr32:out => in: ptype[response] flen[28] plen[4] ahint[4]
+
+[000] 54 72 75 65 True
+
+ndr32:in => out: ptype[request] flen[40] plen[16] ahint[16]
+
+[000] 08 08 00 00 00 00 00 00 FF FF FF FF FF FF FF FF ........ ........
+
+srv_midltests_fn: Start
+srv_midltests_fn: End
+
+ndr32:out => in: ptype[response] flen[28] plen[4] ahint[4]
+
+[000] 54 72 75 65 True
+
+NDRTcpThread[ndr32] stop
+
+Test NDR64
+
+ndr64: got NDR64
+
+ndr64:in => out: ptype[request] flen[40] plen[16] ahint[16]
+
+[000] 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ........ ........
+
+srv_midltests_fn: Start
+srv_midltests_fn: End
+
+ndr64:out => in: ptype[response] flen[28] plen[4] ahint[4]
+
+[000] 54 72 75 65 True
+
+ndr64:in => out: ptype[request] flen[41] plen[17] ahint[17]
+
+[000] 01 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 ........ ........
+[010] FF .
+
+srv_midltests_fn: Start
+srv_midltests_fn: End
+
+ndr64:out => in: ptype[response] flen[28] plen[4] ahint[4]
+
+[000] 54 72 75 65 True
+
+ndr64:in => out: ptype[request] flen[42] plen[18] ahint[18]
+
+[000] 02 00 00 00 00 00 00 00 02 00 00 00 00 00 00 00 ........ ........
+[010] FF FF ..
+
+srv_midltests_fn: Start
+srv_midltests_fn: End
+
+ndr64:out => in: ptype[response] flen[28] plen[4] ahint[4]
+
+[000] 54 72 75 65 True
+
+ndr64:in => out: ptype[request] flen[44] plen[20] ahint[20]
+
+[000] 04 00 00 00 00 00 00 00 04 00 00 00 00 00 00 00 ........ ........
+[010] FF FF FF FF ....
+
+srv_midltests_fn: Start
+srv_midltests_fn: End
+
+ndr64:out => in: ptype[response] flen[28] plen[4] ahint[4]
+
+[000] 54 72 75 65 True
+
+ndr64:in => out: ptype[request] flen[48] plen[24] ahint[24]
+
+[000] 08 00 00 00 00 00 00 00 08 00 00 00 00 00 00 00 ........ ........
+[010] FF FF FF FF FF FF FF FF ........
+
+srv_midltests_fn: Start
+srv_midltests_fn: End
+
+ndr64:out => in: ptype[response] flen[28] plen[4] ahint[4]
+
+[000] 54 72 75 65 True
+
+NDRTcpThread[ndr64] stop
+
+Test OK
diff --git a/testprogs/win32/midltests/valid/midltests_union_align_09.idl b/testprogs/win32/midltests/valid/midltests_union_align_09.idl
new file mode 100644
index 0000000..358a598
--- /dev/null
+++ b/testprogs/win32/midltests/valid/midltests_union_align_09.idl
@@ -0,0 +1,69 @@
+#ifndef MIDLTESTS_C_CODE
+
+/*
+ * For midltests_tcp.exe you may want to
+ * redirect the traffic via rinetd
+ * with a /etc/rinetd.conf like this:
+ *
+ * 172.31.9.1 5032 172.31.9.8 5032
+ * 172.31.9.1 5064 172.31.9.8 5064
+ *
+ * This is useful to watch the traffic with
+ * a network sniffer.
+ */
+/*
+cpp_quote("#define LISTEN_IP \"0.0.0.0\"")
+cpp_quote("#define FORWARD_IP \"127.0.0.1\"")
+cpp_quote("#define CONNECT_IP \"172.31.9.1\"")
+*/
+
+/*
+ * With midltests_tcp.exe NDR64 is enforced by default.
+ * For testing it might be needed to allow downgrades
+ * to NDR32. This is needed when you use 'pipe'.
+ */
+//cpp_quote("#define DONOT_FORCE_NDR64 1")
+
+[
+ uuid("225b9fcb-eb3d-497b-8b0b-591f049a2507"),
+ ms_union,
+ pointer_default(unique)
+]
+interface midltests
+{
+ [switch_type(char)] union u {
+ [case(0)];
+ [case(1)] char c;
+ [case(2)] short s;
+ [case(4)] long l;
+ [case(8)] hyper h;
+ };
+
+ long midltests_fn(
+ [in] char level,
+ [in,switch_is(level)] union u u
+ );
+}
+
+#elif MIDLTESTS_C_CODE
+
+static void midltests(void)
+{
+ union u u;
+ u.h = 0xFFFFFFFFFFFFFFFFLL;
+
+ cli_midltests_fn(0, u);
+ cli_midltests_fn(1, u);
+ cli_midltests_fn(2, u);
+ cli_midltests_fn(4, u);
+ cli_midltests_fn(8, u);
+}
+
+long srv_midltests_fn(char level, union u u)
+{
+ printf("srv_midltests_fn: Start\n");
+ printf("srv_midltests_fn: End\n");
+ return 0x65757254;
+}
+
+#endif
diff --git a/testprogs/win32/midltests/valid/midltests_union_align_09.txt b/testprogs/win32/midltests/valid/midltests_union_align_09.txt
new file mode 100644
index 0000000..5e7e192
--- /dev/null
+++ b/testprogs/win32/midltests/valid/midltests_union_align_09.txt
@@ -0,0 +1,129 @@
+Wait for setup of server threads
+
+Test NDR32
+
+ndr32: disable NDR64
+
+ndr32:in => out: ptype[request] flen[32] plen[8] ahint[8]
+
+[000] 00 00 00 00 00 00 00 00 ........
+
+srv_midltests_fn: Start
+srv_midltests_fn: End
+
+ndr32:out => in: ptype[response] flen[28] plen[4] ahint[4]
+
+[000] 54 72 75 65 True
+
+ndr32:in => out: ptype[request] flen[33] plen[9] ahint[9]
+
+[000] 01 01 00 00 00 00 00 00 FF ........ .
+
+srv_midltests_fn: Start
+srv_midltests_fn: End
+
+ndr32:out => in: ptype[response] flen[28] plen[4] ahint[4]
+
+[000] 54 72 75 65 True
+
+ndr32:in => out: ptype[request] flen[34] plen[10] ahint[10]
+
+[000] 02 02 00 00 00 00 00 00 FF FF ........ ..
+
+srv_midltests_fn: Start
+srv_midltests_fn: End
+
+ndr32:out => in: ptype[response] flen[28] plen[4] ahint[4]
+
+[000] 54 72 75 65 True
+
+ndr32:in => out: ptype[request] flen[36] plen[12] ahint[12]
+
+[000] 04 04 00 00 00 00 00 00 FF FF FF FF ........ ....
+
+srv_midltests_fn: Start
+srv_midltests_fn: End
+
+ndr32:out => in: ptype[response] flen[28] plen[4] ahint[4]
+
+[000] 54 72 75 65 True
+
+ndr32:in => out: ptype[request] flen[40] plen[16] ahint[16]
+
+[000] 08 08 00 00 00 00 00 00 FF FF FF FF FF FF FF FF ........ ........
+
+srv_midltests_fn: Start
+srv_midltests_fn: End
+
+ndr32:out => in: ptype[response] flen[28] plen[4] ahint[4]
+
+[000] 54 72 75 65 True
+
+NDRTcpThread[ndr32] stop
+
+Test NDR64
+
+ndr64: got NDR64
+
+ndr64:in => out: ptype[request] flen[40] plen[16] ahint[16]
+
+[000] 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ........ ........
+
+srv_midltests_fn: Start
+srv_midltests_fn: End
+
+ndr64:out => in: ptype[response] flen[28] plen[4] ahint[4]
+
+[000] 54 72 75 65 True
+
+ndr64:in => out: ptype[request] flen[41] plen[17] ahint[17]
+
+[000] 01 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 ........ ........
+[010] FF .
+
+srv_midltests_fn: Start
+srv_midltests_fn: End
+
+ndr64:out => in: ptype[response] flen[28] plen[4] ahint[4]
+
+[000] 54 72 75 65 True
+
+ndr64:in => out: ptype[request] flen[42] plen[18] ahint[18]
+
+[000] 02 00 00 00 00 00 00 00 02 00 00 00 00 00 00 00 ........ ........
+[010] FF FF ..
+
+srv_midltests_fn: Start
+srv_midltests_fn: End
+
+ndr64:out => in: ptype[response] flen[28] plen[4] ahint[4]
+
+[000] 54 72 75 65 True
+
+ndr64:in => out: ptype[request] flen[44] plen[20] ahint[20]
+
+[000] 04 00 00 00 00 00 00 00 04 00 00 00 00 00 00 00 ........ ........
+[010] FF FF FF FF ....
+
+srv_midltests_fn: Start
+srv_midltests_fn: End
+
+ndr64:out => in: ptype[response] flen[28] plen[4] ahint[4]
+
+[000] 54 72 75 65 True
+
+ndr64:in => out: ptype[request] flen[48] plen[24] ahint[24]
+
+[000] 08 00 00 00 00 00 00 00 08 00 00 00 00 00 00 00 ........ ........
+[010] FF FF FF FF FF FF FF FF ........
+
+srv_midltests_fn: Start
+srv_midltests_fn: End
+
+ndr64:out => in: ptype[response] flen[28] plen[4] ahint[4]
+
+[000] 54 72 75 65 True
+
+NDRTcpThread[ndr64] stop
+
+Test OK
diff --git a/testprogs/win32/midltests/valid/midltests_union_align_10.idl b/testprogs/win32/midltests/valid/midltests_union_align_10.idl
new file mode 100644
index 0000000..6d66272
--- /dev/null
+++ b/testprogs/win32/midltests/valid/midltests_union_align_10.idl
@@ -0,0 +1,71 @@
+#ifndef MIDLTESTS_C_CODE
+
+/*
+ * For midltests_tcp.exe you may want to
+ * redirect the traffic via rinetd
+ * with a /etc/rinetd.conf like this:
+ *
+ * 172.31.9.1 5032 172.31.9.8 5032
+ * 172.31.9.1 5064 172.31.9.8 5064
+ *
+ * This is useful to watch the traffic with
+ * a network sniffer.
+ */
+/*
+cpp_quote("#define LISTEN_IP \"0.0.0.0\"")
+cpp_quote("#define FORWARD_IP \"127.0.0.1\"")
+cpp_quote("#define CONNECT_IP \"172.31.9.1\"")
+*/
+
+/*
+ * With midltests_tcp.exe NDR64 is enforced by default.
+ * For testing it might be needed to allow downgrades
+ * to NDR32. This is needed when you use 'pipe'.
+ */
+//cpp_quote("#define DONOT_FORCE_NDR64 1")
+
+[
+ uuid("225b9fcb-eb3d-497b-8b0b-591f049a2507"),
+ ms_union,
+ pointer_default(unique)
+]
+interface midltests
+{
+ enum level_enum { ZERO = 0, ONE = 1, TWO = 2, FOUR = 4, EIGHT = 8 };
+
+ [switch_type(long)] union u {
+ [case(ZERO)];
+ [case(ONE)] char c;
+ [case(TWO)] short s;
+ [case(FOUR)] long l;
+ [case(EIGHT)] hyper h;
+ };
+
+ long midltests_fn(
+ [in] enum level_enum level,
+ [in,switch_is(level)] union u u
+ );
+}
+
+#elif MIDLTESTS_C_CODE
+
+static void midltests(void)
+{
+ union u u;
+ u.h = 0xFFFFFFFFFFFFFFFFLL;
+
+ cli_midltests_fn(ZERO, u);
+ cli_midltests_fn(ONE, u);
+ cli_midltests_fn(TWO, u);
+ cli_midltests_fn(FOUR, u);
+ cli_midltests_fn(EIGHT, u);
+}
+
+long srv_midltests_fn(char level, union u u)
+{
+ printf("srv_midltests_fn: Start\n");
+ printf("srv_midltests_fn: End\n");
+ return 0x65757254;
+}
+
+#endif
diff --git a/testprogs/win32/midltests/valid/midltests_union_align_10.txt b/testprogs/win32/midltests/valid/midltests_union_align_10.txt
new file mode 100644
index 0000000..babae12
--- /dev/null
+++ b/testprogs/win32/midltests/valid/midltests_union_align_10.txt
@@ -0,0 +1,129 @@
+Wait for setup of server threads
+
+Test NDR32
+
+ndr32: disable NDR64
+
+ndr32:in => out: ptype[request] flen[32] plen[8] ahint[8]
+
+[000] 00 00 00 00 00 00 00 00 ........
+
+srv_midltests_fn: Start
+srv_midltests_fn: End
+
+ndr32:out => in: ptype[response] flen[28] plen[4] ahint[4]
+
+[000] 54 72 75 65 True
+
+ndr32:in => out: ptype[request] flen[33] plen[9] ahint[9]
+
+[000] 01 00 00 00 01 00 00 00 FF ........ .
+
+srv_midltests_fn: Start
+srv_midltests_fn: End
+
+ndr32:out => in: ptype[response] flen[28] plen[4] ahint[4]
+
+[000] 54 72 75 65 True
+
+ndr32:in => out: ptype[request] flen[34] plen[10] ahint[10]
+
+[000] 02 00 00 00 02 00 00 00 FF FF ........ ..
+
+srv_midltests_fn: Start
+srv_midltests_fn: End
+
+ndr32:out => in: ptype[response] flen[28] plen[4] ahint[4]
+
+[000] 54 72 75 65 True
+
+ndr32:in => out: ptype[request] flen[36] plen[12] ahint[12]
+
+[000] 04 00 00 00 04 00 00 00 FF FF FF FF ........ ....
+
+srv_midltests_fn: Start
+srv_midltests_fn: End
+
+ndr32:out => in: ptype[response] flen[28] plen[4] ahint[4]
+
+[000] 54 72 75 65 True
+
+ndr32:in => out: ptype[request] flen[40] plen[16] ahint[16]
+
+[000] 08 00 00 00 08 00 00 00 FF FF FF FF FF FF FF FF ........ ........
+
+srv_midltests_fn: Start
+srv_midltests_fn: End
+
+ndr32:out => in: ptype[response] flen[28] plen[4] ahint[4]
+
+[000] 54 72 75 65 True
+
+NDRTcpThread[ndr32] stop
+
+Test NDR64
+
+ndr64: got NDR64
+
+ndr64:in => out: ptype[request] flen[40] plen[16] ahint[16]
+
+[000] 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ........ ........
+
+srv_midltests_fn: Start
+srv_midltests_fn: End
+
+ndr64:out => in: ptype[response] flen[28] plen[4] ahint[4]
+
+[000] 54 72 75 65 True
+
+ndr64:in => out: ptype[request] flen[41] plen[17] ahint[17]
+
+[000] 01 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 ........ ........
+[010] FF .
+
+srv_midltests_fn: Start
+srv_midltests_fn: End
+
+ndr64:out => in: ptype[response] flen[28] plen[4] ahint[4]
+
+[000] 54 72 75 65 True
+
+ndr64:in => out: ptype[request] flen[42] plen[18] ahint[18]
+
+[000] 02 00 00 00 00 00 00 00 02 00 00 00 00 00 00 00 ........ ........
+[010] FF FF ..
+
+srv_midltests_fn: Start
+srv_midltests_fn: End
+
+ndr64:out => in: ptype[response] flen[28] plen[4] ahint[4]
+
+[000] 54 72 75 65 True
+
+ndr64:in => out: ptype[request] flen[44] plen[20] ahint[20]
+
+[000] 04 00 00 00 00 00 00 00 04 00 00 00 00 00 00 00 ........ ........
+[010] FF FF FF FF ....
+
+srv_midltests_fn: Start
+srv_midltests_fn: End
+
+ndr64:out => in: ptype[response] flen[28] plen[4] ahint[4]
+
+[000] 54 72 75 65 True
+
+ndr64:in => out: ptype[request] flen[48] plen[24] ahint[24]
+
+[000] 08 00 00 00 00 00 00 00 08 00 00 00 00 00 00 00 ........ ........
+[010] FF FF FF FF FF FF FF FF ........
+
+srv_midltests_fn: Start
+srv_midltests_fn: End
+
+ndr64:out => in: ptype[response] flen[28] plen[4] ahint[4]
+
+[000] 54 72 75 65 True
+
+NDRTcpThread[ndr64] stop
+
+Test OK
diff --git a/testprogs/win32/midltests/valid/midltests_union_align_11.idl b/testprogs/win32/midltests/valid/midltests_union_align_11.idl
new file mode 100644
index 0000000..1036abe
--- /dev/null
+++ b/testprogs/win32/midltests/valid/midltests_union_align_11.idl
@@ -0,0 +1,70 @@
+#ifndef MIDLTESTS_C_CODE
+
+/*
+ * For midltests_tcp.exe you may want to
+ * redirect the traffic via rinetd
+ * with a /etc/rinetd.conf like this:
+ *
+ * 172.31.9.1 5032 172.31.9.8 5032
+ * 172.31.9.1 5064 172.31.9.8 5064
+ *
+ * This is useful to watch the traffic with
+ * a network sniffer.
+ */
+/*
+cpp_quote("#define LISTEN_IP \"0.0.0.0\"")
+cpp_quote("#define FORWARD_IP \"127.0.0.1\"")
+cpp_quote("#define CONNECT_IP \"172.31.9.1\"")
+*/
+
+/*
+ * With midltests_tcp.exe NDR64 is enforced by default.
+ * For testing it might be needed to allow downgrades
+ * to NDR32. This is needed when you use 'pipe'.
+ */
+//cpp_quote("#define DONOT_FORCE_NDR64 1")
+
+[
+ uuid("225b9fcb-eb3d-497b-8b0b-591f049a2507"),
+ pointer_default(unique)
+]
+interface midltests
+{
+ enum level_enum { ZERO = 0, ONE = 1, TWO = 2, FOUR = 4, EIGHT = 8 };
+
+ [switch_type(long)] union u {
+ [case(ZERO)];
+ [case(ONE)] char c;
+ [case(TWO)] short s;
+ [case(FOUR)] long l;
+ [case(EIGHT)] hyper h;
+ };
+
+ long midltests_fn(
+ [in] enum level_enum level,
+ [in,switch_is(level)] union u u
+ );
+}
+
+#elif MIDLTESTS_C_CODE
+
+static void midltests(void)
+{
+ union u u;
+ u.h = 0xFFFFFFFFFFFFFFFFLL;
+
+ cli_midltests_fn(ZERO, u);
+ cli_midltests_fn(ONE, u);
+ cli_midltests_fn(TWO, u);
+ cli_midltests_fn(FOUR, u);
+ cli_midltests_fn(EIGHT, u);
+}
+
+long srv_midltests_fn(char level, union u u)
+{
+ printf("srv_midltests_fn: Start\n");
+ printf("srv_midltests_fn: End\n");
+ return 0x65757254;
+}
+
+#endif
diff --git a/testprogs/win32/midltests/valid/midltests_union_align_11.txt b/testprogs/win32/midltests/valid/midltests_union_align_11.txt
new file mode 100644
index 0000000..babae12
--- /dev/null
+++ b/testprogs/win32/midltests/valid/midltests_union_align_11.txt
@@ -0,0 +1,129 @@
+Wait for setup of server threads
+
+Test NDR32
+
+ndr32: disable NDR64
+
+ndr32:in => out: ptype[request] flen[32] plen[8] ahint[8]
+
+[000] 00 00 00 00 00 00 00 00 ........
+
+srv_midltests_fn: Start
+srv_midltests_fn: End
+
+ndr32:out => in: ptype[response] flen[28] plen[4] ahint[4]
+
+[000] 54 72 75 65 True
+
+ndr32:in => out: ptype[request] flen[33] plen[9] ahint[9]
+
+[000] 01 00 00 00 01 00 00 00 FF ........ .
+
+srv_midltests_fn: Start
+srv_midltests_fn: End
+
+ndr32:out => in: ptype[response] flen[28] plen[4] ahint[4]
+
+[000] 54 72 75 65 True
+
+ndr32:in => out: ptype[request] flen[34] plen[10] ahint[10]
+
+[000] 02 00 00 00 02 00 00 00 FF FF ........ ..
+
+srv_midltests_fn: Start
+srv_midltests_fn: End
+
+ndr32:out => in: ptype[response] flen[28] plen[4] ahint[4]
+
+[000] 54 72 75 65 True
+
+ndr32:in => out: ptype[request] flen[36] plen[12] ahint[12]
+
+[000] 04 00 00 00 04 00 00 00 FF FF FF FF ........ ....
+
+srv_midltests_fn: Start
+srv_midltests_fn: End
+
+ndr32:out => in: ptype[response] flen[28] plen[4] ahint[4]
+
+[000] 54 72 75 65 True
+
+ndr32:in => out: ptype[request] flen[40] plen[16] ahint[16]
+
+[000] 08 00 00 00 08 00 00 00 FF FF FF FF FF FF FF FF ........ ........
+
+srv_midltests_fn: Start
+srv_midltests_fn: End
+
+ndr32:out => in: ptype[response] flen[28] plen[4] ahint[4]
+
+[000] 54 72 75 65 True
+
+NDRTcpThread[ndr32] stop
+
+Test NDR64
+
+ndr64: got NDR64
+
+ndr64:in => out: ptype[request] flen[40] plen[16] ahint[16]
+
+[000] 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ........ ........
+
+srv_midltests_fn: Start
+srv_midltests_fn: End
+
+ndr64:out => in: ptype[response] flen[28] plen[4] ahint[4]
+
+[000] 54 72 75 65 True
+
+ndr64:in => out: ptype[request] flen[41] plen[17] ahint[17]
+
+[000] 01 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 ........ ........
+[010] FF .
+
+srv_midltests_fn: Start
+srv_midltests_fn: End
+
+ndr64:out => in: ptype[response] flen[28] plen[4] ahint[4]
+
+[000] 54 72 75 65 True
+
+ndr64:in => out: ptype[request] flen[42] plen[18] ahint[18]
+
+[000] 02 00 00 00 00 00 00 00 02 00 00 00 00 00 00 00 ........ ........
+[010] FF FF ..
+
+srv_midltests_fn: Start
+srv_midltests_fn: End
+
+ndr64:out => in: ptype[response] flen[28] plen[4] ahint[4]
+
+[000] 54 72 75 65 True
+
+ndr64:in => out: ptype[request] flen[44] plen[20] ahint[20]
+
+[000] 04 00 00 00 00 00 00 00 04 00 00 00 00 00 00 00 ........ ........
+[010] FF FF FF FF ....
+
+srv_midltests_fn: Start
+srv_midltests_fn: End
+
+ndr64:out => in: ptype[response] flen[28] plen[4] ahint[4]
+
+[000] 54 72 75 65 True
+
+ndr64:in => out: ptype[request] flen[48] plen[24] ahint[24]
+
+[000] 08 00 00 00 00 00 00 00 08 00 00 00 00 00 00 00 ........ ........
+[010] FF FF FF FF FF FF FF FF ........
+
+srv_midltests_fn: Start
+srv_midltests_fn: End
+
+ndr64:out => in: ptype[response] flen[28] plen[4] ahint[4]
+
+[000] 54 72 75 65 True
+
+NDRTcpThread[ndr64] stop
+
+Test OK
diff --git a/testprogs/win32/midltests/valid/midltests_union_align_12.idl b/testprogs/win32/midltests/valid/midltests_union_align_12.idl
new file mode 100644
index 0000000..6b27cb9
--- /dev/null
+++ b/testprogs/win32/midltests/valid/midltests_union_align_12.idl
@@ -0,0 +1,70 @@
+#ifndef MIDLTESTS_C_CODE
+
+/*
+ * For midltests_tcp.exe you may want to
+ * redirect the traffic via rinetd
+ * with a /etc/rinetd.conf like this:
+ *
+ * 172.31.9.1 5032 172.31.9.8 5032
+ * 172.31.9.1 5064 172.31.9.8 5064
+ *
+ * This is useful to watch the traffic with
+ * a network sniffer.
+ */
+/*
+cpp_quote("#define LISTEN_IP \"0.0.0.0\"")
+cpp_quote("#define FORWARD_IP \"127.0.0.1\"")
+cpp_quote("#define CONNECT_IP \"172.31.9.1\"")
+*/
+
+/*
+ * With midltests_tcp.exe NDR64 is enforced by default.
+ * For testing it might be needed to allow downgrades
+ * to NDR32. This is needed when you use 'pipe'.
+ */
+//cpp_quote("#define DONOT_FORCE_NDR64 1")
+
+[
+ uuid("225b9fcb-eb3d-497b-8b0b-591f049a2507"),
+ pointer_default(unique)
+]
+interface midltests
+{
+ enum level_enum { ZERO = 0, ONE = 1, TWO = 2, FOUR = 4, EIGHT = 8 };
+
+ [switch_type(enum level_enum)] union u {
+ [case(ZERO)];
+ [case(ONE)] char c;
+ [case(TWO)] short s;
+ [case(FOUR)] long l;
+ [case(EIGHT)] hyper h;
+ };
+
+ long midltests_fn(
+ [in] enum level_enum level,
+ [in,switch_is(level)] union u u
+ );
+}
+
+#elif MIDLTESTS_C_CODE
+
+static void midltests(void)
+{
+ union u u;
+ u.h = 0xFFFFFFFFFFFFFFFFLL;
+
+ cli_midltests_fn(ZERO, u);
+ cli_midltests_fn(ONE, u);
+ cli_midltests_fn(TWO, u);
+ cli_midltests_fn(FOUR, u);
+ cli_midltests_fn(EIGHT, u);
+}
+
+long srv_midltests_fn(char level, union u u)
+{
+ printf("srv_midltests_fn: Start\n");
+ printf("srv_midltests_fn: End\n");
+ return 0x65757254;
+}
+
+#endif
diff --git a/testprogs/win32/midltests/valid/midltests_union_align_12.txt b/testprogs/win32/midltests/valid/midltests_union_align_12.txt
new file mode 100644
index 0000000..1a32739
--- /dev/null
+++ b/testprogs/win32/midltests/valid/midltests_union_align_12.txt
@@ -0,0 +1,129 @@
+Wait for setup of server threads
+
+Test NDR32
+
+ndr32: disable NDR64
+
+ndr32:in => out: ptype[request] flen[28] plen[4] ahint[4]
+
+[000] 00 00 00 00 ....
+
+srv_midltests_fn: Start
+srv_midltests_fn: End
+
+ndr32:out => in: ptype[response] flen[28] plen[4] ahint[4]
+
+[000] 54 72 75 65 True
+
+ndr32:in => out: ptype[request] flen[29] plen[5] ahint[5]
+
+[000] 01 00 01 00 FF .....
+
+srv_midltests_fn: Start
+srv_midltests_fn: End
+
+ndr32:out => in: ptype[response] flen[28] plen[4] ahint[4]
+
+[000] 54 72 75 65 True
+
+ndr32:in => out: ptype[request] flen[30] plen[6] ahint[6]
+
+[000] 02 00 02 00 FF FF ......
+
+srv_midltests_fn: Start
+srv_midltests_fn: End
+
+ndr32:out => in: ptype[response] flen[28] plen[4] ahint[4]
+
+[000] 54 72 75 65 True
+
+ndr32:in => out: ptype[request] flen[32] plen[8] ahint[8]
+
+[000] 04 00 04 00 FF FF FF FF ........
+
+srv_midltests_fn: Start
+srv_midltests_fn: End
+
+ndr32:out => in: ptype[response] flen[28] plen[4] ahint[4]
+
+[000] 54 72 75 65 True
+
+ndr32:in => out: ptype[request] flen[40] plen[16] ahint[16]
+
+[000] 08 00 08 00 00 00 00 00 FF FF FF FF FF FF FF FF ........ ........
+
+srv_midltests_fn: Start
+srv_midltests_fn: End
+
+ndr32:out => in: ptype[response] flen[28] plen[4] ahint[4]
+
+[000] 54 72 75 65 True
+
+NDRTcpThread[ndr32] stop
+
+Test NDR64
+
+ndr64: got NDR64
+
+ndr64:in => out: ptype[request] flen[40] plen[16] ahint[16]
+
+[000] 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ........ ........
+
+srv_midltests_fn: Start
+srv_midltests_fn: End
+
+ndr64:out => in: ptype[response] flen[28] plen[4] ahint[4]
+
+[000] 54 72 75 65 True
+
+ndr64:in => out: ptype[request] flen[41] plen[17] ahint[17]
+
+[000] 01 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 ........ ........
+[010] FF .
+
+srv_midltests_fn: Start
+srv_midltests_fn: End
+
+ndr64:out => in: ptype[response] flen[28] plen[4] ahint[4]
+
+[000] 54 72 75 65 True
+
+ndr64:in => out: ptype[request] flen[42] plen[18] ahint[18]
+
+[000] 02 00 00 00 00 00 00 00 02 00 00 00 00 00 00 00 ........ ........
+[010] FF FF ..
+
+srv_midltests_fn: Start
+srv_midltests_fn: End
+
+ndr64:out => in: ptype[response] flen[28] plen[4] ahint[4]
+
+[000] 54 72 75 65 True
+
+ndr64:in => out: ptype[request] flen[44] plen[20] ahint[20]
+
+[000] 04 00 00 00 00 00 00 00 04 00 00 00 00 00 00 00 ........ ........
+[010] FF FF FF FF ....
+
+srv_midltests_fn: Start
+srv_midltests_fn: End
+
+ndr64:out => in: ptype[response] flen[28] plen[4] ahint[4]
+
+[000] 54 72 75 65 True
+
+ndr64:in => out: ptype[request] flen[48] plen[24] ahint[24]
+
+[000] 08 00 00 00 00 00 00 00 08 00 00 00 00 00 00 00 ........ ........
+[010] FF FF FF FF FF FF FF FF ........
+
+srv_midltests_fn: Start
+srv_midltests_fn: End
+
+ndr64:out => in: ptype[response] flen[28] plen[4] ahint[4]
+
+[000] 54 72 75 65 True
+
+NDRTcpThread[ndr64] stop
+
+Test OK
diff --git a/testprogs/win32/midltests/valid/midltests_union_align_13.idl b/testprogs/win32/midltests/valid/midltests_union_align_13.idl
new file mode 100644
index 0000000..a29dcb9
--- /dev/null
+++ b/testprogs/win32/midltests/valid/midltests_union_align_13.idl
@@ -0,0 +1,71 @@
+#ifndef MIDLTESTS_C_CODE
+
+/*
+ * For midltests_tcp.exe you may want to
+ * redirect the traffic via rinetd
+ * with a /etc/rinetd.conf like this:
+ *
+ * 172.31.9.1 5032 172.31.9.8 5032
+ * 172.31.9.1 5064 172.31.9.8 5064
+ *
+ * This is useful to watch the traffic with
+ * a network sniffer.
+ */
+/*
+cpp_quote("#define LISTEN_IP \"0.0.0.0\"")
+cpp_quote("#define FORWARD_IP \"127.0.0.1\"")
+cpp_quote("#define CONNECT_IP \"172.31.9.1\"")
+*/
+
+/*
+ * With midltests_tcp.exe NDR64 is enforced by default.
+ * For testing it might be needed to allow downgrades
+ * to NDR32. This is needed when you use 'pipe'.
+ */
+//cpp_quote("#define DONOT_FORCE_NDR64 1")
+
+[
+ uuid("225b9fcb-eb3d-497b-8b0b-591f049a2507"),
+ ms_union,
+ pointer_default(unique)
+]
+interface midltests
+{
+ enum level_enum { ZERO = 0, ONE = 1, TWO = 2, FOUR = 4, EIGHT = 8 };
+
+ [switch_type(enum level_enum)] union u {
+ [case(ZERO)];
+ [case(ONE)] char c;
+ [case(TWO)] short s;
+ [case(FOUR)] long l;
+ [case(EIGHT)] hyper h;
+ };
+
+ long midltests_fn(
+ [in] enum level_enum level,
+ [in,switch_is(level)] union u u
+ );
+}
+
+#elif MIDLTESTS_C_CODE
+
+static void midltests(void)
+{
+ union u u;
+ u.h = 0xFFFFFFFFFFFFFFFFLL;
+
+ cli_midltests_fn(ZERO, u);
+ cli_midltests_fn(ONE, u);
+ cli_midltests_fn(TWO, u);
+ cli_midltests_fn(FOUR, u);
+ cli_midltests_fn(EIGHT, u);
+}
+
+long srv_midltests_fn(char level, union u u)
+{
+ printf("srv_midltests_fn: Start\n");
+ printf("srv_midltests_fn: End\n");
+ return 0x65757254;
+}
+
+#endif
diff --git a/testprogs/win32/midltests/valid/midltests_union_align_13.txt b/testprogs/win32/midltests/valid/midltests_union_align_13.txt
new file mode 100644
index 0000000..8f0563b
--- /dev/null
+++ b/testprogs/win32/midltests/valid/midltests_union_align_13.txt
@@ -0,0 +1,129 @@
+Wait for setup of server threads
+
+Test NDR32
+
+ndr32: disable NDR64
+
+ndr32:in => out: ptype[request] flen[32] plen[8] ahint[8]
+
+[000] 00 00 00 00 00 00 00 00 ........
+
+srv_midltests_fn: Start
+srv_midltests_fn: End
+
+ndr32:out => in: ptype[response] flen[28] plen[4] ahint[4]
+
+[000] 54 72 75 65 True
+
+ndr32:in => out: ptype[request] flen[33] plen[9] ahint[9]
+
+[000] 01 00 01 00 00 00 00 00 FF ........ .
+
+srv_midltests_fn: Start
+srv_midltests_fn: End
+
+ndr32:out => in: ptype[response] flen[28] plen[4] ahint[4]
+
+[000] 54 72 75 65 True
+
+ndr32:in => out: ptype[request] flen[34] plen[10] ahint[10]
+
+[000] 02 00 02 00 00 00 00 00 FF FF ........ ..
+
+srv_midltests_fn: Start
+srv_midltests_fn: End
+
+ndr32:out => in: ptype[response] flen[28] plen[4] ahint[4]
+
+[000] 54 72 75 65 True
+
+ndr32:in => out: ptype[request] flen[36] plen[12] ahint[12]
+
+[000] 04 00 04 00 00 00 00 00 FF FF FF FF ........ ....
+
+srv_midltests_fn: Start
+srv_midltests_fn: End
+
+ndr32:out => in: ptype[response] flen[28] plen[4] ahint[4]
+
+[000] 54 72 75 65 True
+
+ndr32:in => out: ptype[request] flen[40] plen[16] ahint[16]
+
+[000] 08 00 08 00 00 00 00 00 FF FF FF FF FF FF FF FF ........ ........
+
+srv_midltests_fn: Start
+srv_midltests_fn: End
+
+ndr32:out => in: ptype[response] flen[28] plen[4] ahint[4]
+
+[000] 54 72 75 65 True
+
+NDRTcpThread[ndr32] stop
+
+Test NDR64
+
+ndr64: got NDR64
+
+ndr64:in => out: ptype[request] flen[40] plen[16] ahint[16]
+
+[000] 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ........ ........
+
+srv_midltests_fn: Start
+srv_midltests_fn: End
+
+ndr64:out => in: ptype[response] flen[28] plen[4] ahint[4]
+
+[000] 54 72 75 65 True
+
+ndr64:in => out: ptype[request] flen[41] plen[17] ahint[17]
+
+[000] 01 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 ........ ........
+[010] FF .
+
+srv_midltests_fn: Start
+srv_midltests_fn: End
+
+ndr64:out => in: ptype[response] flen[28] plen[4] ahint[4]
+
+[000] 54 72 75 65 True
+
+ndr64:in => out: ptype[request] flen[42] plen[18] ahint[18]
+
+[000] 02 00 00 00 00 00 00 00 02 00 00 00 00 00 00 00 ........ ........
+[010] FF FF ..
+
+srv_midltests_fn: Start
+srv_midltests_fn: End
+
+ndr64:out => in: ptype[response] flen[28] plen[4] ahint[4]
+
+[000] 54 72 75 65 True
+
+ndr64:in => out: ptype[request] flen[44] plen[20] ahint[20]
+
+[000] 04 00 00 00 00 00 00 00 04 00 00 00 00 00 00 00 ........ ........
+[010] FF FF FF FF ....
+
+srv_midltests_fn: Start
+srv_midltests_fn: End
+
+ndr64:out => in: ptype[response] flen[28] plen[4] ahint[4]
+
+[000] 54 72 75 65 True
+
+ndr64:in => out: ptype[request] flen[48] plen[24] ahint[24]
+
+[000] 08 00 00 00 00 00 00 00 08 00 00 00 00 00 00 00 ........ ........
+[010] FF FF FF FF FF FF FF FF ........
+
+srv_midltests_fn: Start
+srv_midltests_fn: End
+
+ndr64:out => in: ptype[response] flen[28] plen[4] ahint[4]
+
+[000] 54 72 75 65 True
+
+NDRTcpThread[ndr64] stop
+
+Test OK
diff --git a/testprogs/win32/midltests/valid/midltests_union_align_14.idl b/testprogs/win32/midltests/valid/midltests_union_align_14.idl
new file mode 100644
index 0000000..c029f5a
--- /dev/null
+++ b/testprogs/win32/midltests/valid/midltests_union_align_14.idl
@@ -0,0 +1,71 @@
+#ifndef MIDLTESTS_C_CODE
+
+/*
+ * For midltests_tcp.exe you may want to
+ * redirect the traffic via rinetd
+ * with a /etc/rinetd.conf like this:
+ *
+ * 172.31.9.1 5032 172.31.9.8 5032
+ * 172.31.9.1 5064 172.31.9.8 5064
+ *
+ * This is useful to watch the traffic with
+ * a network sniffer.
+ */
+/*
+cpp_quote("#define LISTEN_IP \"0.0.0.0\"")
+cpp_quote("#define FORWARD_IP \"127.0.0.1\"")
+cpp_quote("#define CONNECT_IP \"172.31.9.1\"")
+*/
+
+/*
+ * With midltests_tcp.exe NDR64 is enforced by default.
+ * For testing it might be needed to allow downgrades
+ * to NDR32. This is needed when you use 'pipe'.
+ */
+//cpp_quote("#define DONOT_FORCE_NDR64 1")
+
+[
+ uuid("225b9fcb-eb3d-497b-8b0b-591f049a2507"),
+ pointer_default(unique)
+]
+interface midltests
+{
+ enum level_enum { ZERO = 0, ONE = 1, TWO = 2, FOUR = 4, EIGHT = 8 };
+
+ [switch_type(enum level_enum)] union u {
+ [case(ZERO)];
+ [case(ONE)] char c;
+ [case(TWO)] short s;
+ [case(FOUR)] long l;
+ [case(EIGHT)] hyper h;
+ };
+
+ long midltests_fn(
+ [in] enum level_enum level,
+ [in,switch_is(level)] union u u,
+ [in] char c
+ );
+}
+
+#elif MIDLTESTS_C_CODE
+
+static void midltests(void)
+{
+ union u u;
+ u.h = 0xFFFFFFFFFFFFFFFFLL;
+
+ cli_midltests_fn(ZERO, u, 'c');
+ cli_midltests_fn(ONE, u, 'c');
+ cli_midltests_fn(TWO, u, 'c');
+ cli_midltests_fn(FOUR, u, 'c');
+ cli_midltests_fn(EIGHT, u, 'c');
+}
+
+long srv_midltests_fn(char level, union u u, char c)
+{
+ printf("srv_midltests_fn: Start\n");
+ printf("srv_midltests_fn: End\n");
+ return 0x65757254;
+}
+
+#endif
diff --git a/testprogs/win32/midltests/valid/midltests_union_align_14.txt b/testprogs/win32/midltests/valid/midltests_union_align_14.txt
new file mode 100644
index 0000000..9713788
--- /dev/null
+++ b/testprogs/win32/midltests/valid/midltests_union_align_14.txt
@@ -0,0 +1,131 @@
+Wait for setup of server threads
+
+Test NDR32
+
+ndr32: disable NDR64
+
+ndr32:in => out: ptype[request] flen[29] plen[5] ahint[5]
+
+[000] 00 00 00 00 63 ....c
+
+srv_midltests_fn: Start
+srv_midltests_fn: End
+
+ndr32:out => in: ptype[response] flen[28] plen[4] ahint[4]
+
+[000] 54 72 75 65 True
+
+ndr32:in => out: ptype[request] flen[30] plen[6] ahint[6]
+
+[000] 01 00 01 00 FF 63 .....c
+
+srv_midltests_fn: Start
+srv_midltests_fn: End
+
+ndr32:out => in: ptype[response] flen[28] plen[4] ahint[4]
+
+[000] 54 72 75 65 True
+
+ndr32:in => out: ptype[request] flen[31] plen[7] ahint[7]
+
+[000] 02 00 02 00 FF FF 63 ......c
+
+srv_midltests_fn: Start
+srv_midltests_fn: End
+
+ndr32:out => in: ptype[response] flen[28] plen[4] ahint[4]
+
+[000] 54 72 75 65 True
+
+ndr32:in => out: ptype[request] flen[33] plen[9] ahint[9]
+
+[000] 04 00 04 00 FF FF FF FF 63 ........ c
+
+srv_midltests_fn: Start
+srv_midltests_fn: End
+
+ndr32:out => in: ptype[response] flen[28] plen[4] ahint[4]
+
+[000] 54 72 75 65 True
+
+ndr32:in => out: ptype[request] flen[41] plen[17] ahint[17]
+
+[000] 08 00 08 00 00 00 00 00 FF FF FF FF FF FF FF FF ........ ........
+[010] 63 c
+
+srv_midltests_fn: Start
+srv_midltests_fn: End
+
+ndr32:out => in: ptype[response] flen[28] plen[4] ahint[4]
+
+[000] 54 72 75 65 True
+
+NDRTcpThread[ndr32] stop
+
+Test NDR64
+
+ndr64: got NDR64
+
+ndr64:in => out: ptype[request] flen[41] plen[17] ahint[17]
+
+[000] 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ........ ........
+[010] 63 c
+
+srv_midltests_fn: Start
+srv_midltests_fn: End
+
+ndr64:out => in: ptype[response] flen[28] plen[4] ahint[4]
+
+[000] 54 72 75 65 True
+
+ndr64:in => out: ptype[request] flen[42] plen[18] ahint[18]
+
+[000] 01 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 ........ ........
+[010] FF 63 .c
+
+srv_midltests_fn: Start
+srv_midltests_fn: End
+
+ndr64:out => in: ptype[response] flen[28] plen[4] ahint[4]
+
+[000] 54 72 75 65 True
+
+ndr64:in => out: ptype[request] flen[43] plen[19] ahint[19]
+
+[000] 02 00 00 00 00 00 00 00 02 00 00 00 00 00 00 00 ........ ........
+[010] FF FF 63 ..c
+
+srv_midltests_fn: Start
+srv_midltests_fn: End
+
+ndr64:out => in: ptype[response] flen[28] plen[4] ahint[4]
+
+[000] 54 72 75 65 True
+
+ndr64:in => out: ptype[request] flen[45] plen[21] ahint[21]
+
+[000] 04 00 00 00 00 00 00 00 04 00 00 00 00 00 00 00 ........ ........
+[010] FF FF FF FF 63 ....c
+
+srv_midltests_fn: Start
+srv_midltests_fn: End
+
+ndr64:out => in: ptype[response] flen[28] plen[4] ahint[4]
+
+[000] 54 72 75 65 True
+
+ndr64:in => out: ptype[request] flen[49] plen[25] ahint[25]
+
+[000] 08 00 00 00 00 00 00 00 08 00 00 00 00 00 00 00 ........ ........
+[010] FF FF FF FF FF FF FF FF 63 ........ c
+
+srv_midltests_fn: Start
+srv_midltests_fn: End
+
+ndr64:out => in: ptype[response] flen[28] plen[4] ahint[4]
+
+[000] 54 72 75 65 True
+
+NDRTcpThread[ndr64] stop
+
+Test OK
diff --git a/testprogs/win32/midltests/valid/midltests_union_align_15.idl b/testprogs/win32/midltests/valid/midltests_union_align_15.idl
new file mode 100644
index 0000000..c8037b8
--- /dev/null
+++ b/testprogs/win32/midltests/valid/midltests_union_align_15.idl
@@ -0,0 +1,72 @@
+#ifndef MIDLTESTS_C_CODE
+
+/*
+ * For midltests_tcp.exe you may want to
+ * redirect the traffic via rinetd
+ * with a /etc/rinetd.conf like this:
+ *
+ * 172.31.9.1 5032 172.31.9.8 5032
+ * 172.31.9.1 5064 172.31.9.8 5064
+ *
+ * This is useful to watch the traffic with
+ * a network sniffer.
+ */
+/*
+cpp_quote("#define LISTEN_IP \"0.0.0.0\"")
+cpp_quote("#define FORWARD_IP \"127.0.0.1\"")
+cpp_quote("#define CONNECT_IP \"172.31.9.1\"")
+*/
+
+/*
+ * With midltests_tcp.exe NDR64 is enforced by default.
+ * For testing it might be needed to allow downgrades
+ * to NDR32. This is needed when you use 'pipe'.
+ */
+//cpp_quote("#define DONOT_FORCE_NDR64 1")
+
+[
+ uuid("225b9fcb-eb3d-497b-8b0b-591f049a2507"),
+ ms_union,
+ pointer_default(unique)
+]
+interface midltests
+{
+ enum level_enum { ZERO = 0, ONE = 1, TWO = 2, FOUR = 4, EIGHT = 8 };
+
+ [switch_type(enum level_enum)] union u {
+ [case(ZERO)];
+ [case(ONE)] char c;
+ [case(TWO)] short s;
+ [case(FOUR)] long l;
+ [case(EIGHT)] hyper h;
+ };
+
+ long midltests_fn(
+ [in] enum level_enum level,
+ [in,switch_is(level)] union u u,
+ [in] char c
+ );
+}
+
+#elif MIDLTESTS_C_CODE
+
+static void midltests(void)
+{
+ union u u;
+ u.h = 0xFFFFFFFFFFFFFFFFLL;
+
+ cli_midltests_fn(ZERO, u, 'c');
+ cli_midltests_fn(ONE, u, 'c');
+ cli_midltests_fn(TWO, u, 'c');
+ cli_midltests_fn(FOUR, u, 'c');
+ cli_midltests_fn(EIGHT, u, 'c');
+}
+
+long srv_midltests_fn(char level, union u u, char c)
+{
+ printf("srv_midltests_fn: Start\n");
+ printf("srv_midltests_fn: End\n");
+ return 0x65757254;
+}
+
+#endif
diff --git a/testprogs/win32/midltests/valid/midltests_union_align_15.txt b/testprogs/win32/midltests/valid/midltests_union_align_15.txt
new file mode 100644
index 0000000..4754930
--- /dev/null
+++ b/testprogs/win32/midltests/valid/midltests_union_align_15.txt
@@ -0,0 +1,131 @@
+Wait for setup of server threads
+
+Test NDR32
+
+ndr32: disable NDR64
+
+ndr32:in => out: ptype[request] flen[33] plen[9] ahint[9]
+
+[000] 00 00 00 00 00 00 00 00 63 ........ c
+
+srv_midltests_fn: Start
+srv_midltests_fn: End
+
+ndr32:out => in: ptype[response] flen[28] plen[4] ahint[4]
+
+[000] 54 72 75 65 True
+
+ndr32:in => out: ptype[request] flen[34] plen[10] ahint[10]
+
+[000] 01 00 01 00 00 00 00 00 FF 63 ........ .c
+
+srv_midltests_fn: Start
+srv_midltests_fn: End
+
+ndr32:out => in: ptype[response] flen[28] plen[4] ahint[4]
+
+[000] 54 72 75 65 True
+
+ndr32:in => out: ptype[request] flen[35] plen[11] ahint[11]
+
+[000] 02 00 02 00 00 00 00 00 FF FF 63 ........ ..c
+
+srv_midltests_fn: Start
+srv_midltests_fn: End
+
+ndr32:out => in: ptype[response] flen[28] plen[4] ahint[4]
+
+[000] 54 72 75 65 True
+
+ndr32:in => out: ptype[request] flen[37] plen[13] ahint[13]
+
+[000] 04 00 04 00 00 00 00 00 FF FF FF FF 63 ........ ....c
+
+srv_midltests_fn: Start
+srv_midltests_fn: End
+
+ndr32:out => in: ptype[response] flen[28] plen[4] ahint[4]
+
+[000] 54 72 75 65 True
+
+ndr32:in => out: ptype[request] flen[41] plen[17] ahint[17]
+
+[000] 08 00 08 00 00 00 00 00 FF FF FF FF FF FF FF FF ........ ........
+[010] 63 c
+
+srv_midltests_fn: Start
+srv_midltests_fn: End
+
+ndr32:out => in: ptype[response] flen[28] plen[4] ahint[4]
+
+[000] 54 72 75 65 True
+
+NDRTcpThread[ndr32] stop
+
+Test NDR64
+
+ndr64: got NDR64
+
+ndr64:in => out: ptype[request] flen[41] plen[17] ahint[17]
+
+[000] 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ........ ........
+[010] 63 c
+
+srv_midltests_fn: Start
+srv_midltests_fn: End
+
+ndr64:out => in: ptype[response] flen[28] plen[4] ahint[4]
+
+[000] 54 72 75 65 True
+
+ndr64:in => out: ptype[request] flen[42] plen[18] ahint[18]
+
+[000] 01 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 ........ ........
+[010] FF 63 .c
+
+srv_midltests_fn: Start
+srv_midltests_fn: End
+
+ndr64:out => in: ptype[response] flen[28] plen[4] ahint[4]
+
+[000] 54 72 75 65 True
+
+ndr64:in => out: ptype[request] flen[43] plen[19] ahint[19]
+
+[000] 02 00 00 00 00 00 00 00 02 00 00 00 00 00 00 00 ........ ........
+[010] FF FF 63 ..c
+
+srv_midltests_fn: Start
+srv_midltests_fn: End
+
+ndr64:out => in: ptype[response] flen[28] plen[4] ahint[4]
+
+[000] 54 72 75 65 True
+
+ndr64:in => out: ptype[request] flen[45] plen[21] ahint[21]
+
+[000] 04 00 00 00 00 00 00 00 04 00 00 00 00 00 00 00 ........ ........
+[010] FF FF FF FF 63 ....c
+
+srv_midltests_fn: Start
+srv_midltests_fn: End
+
+ndr64:out => in: ptype[response] flen[28] plen[4] ahint[4]
+
+[000] 54 72 75 65 True
+
+ndr64:in => out: ptype[request] flen[49] plen[25] ahint[25]
+
+[000] 08 00 00 00 00 00 00 00 08 00 00 00 00 00 00 00 ........ ........
+[010] FF FF FF FF FF FF FF FF 63 ........ c
+
+srv_midltests_fn: Start
+srv_midltests_fn: End
+
+ndr64:out => in: ptype[response] flen[28] plen[4] ahint[4]
+
+[000] 54 72 75 65 True
+
+NDRTcpThread[ndr64] stop
+
+Test OK
diff --git a/testprogs/win32/midltests/valid/midltests_union_align_16.idl b/testprogs/win32/midltests/valid/midltests_union_align_16.idl
new file mode 100644
index 0000000..683a79a
--- /dev/null
+++ b/testprogs/win32/midltests/valid/midltests_union_align_16.idl
@@ -0,0 +1,93 @@
+#ifndef MIDLTESTS_C_CODE
+
+/*
+ * For midltests_tcp.exe you may want to
+ * redirect the traffic via rinetd
+ * with a /etc/rinetd.conf like this:
+ *
+ * 172.31.9.1 5032 172.31.9.8 5032
+ * 172.31.9.1 5064 172.31.9.8 5064
+ *
+ * This is useful to watch the traffic with
+ * a network sniffer.
+ */
+/*
+cpp_quote("#define LISTEN_IP \"0.0.0.0\"")
+cpp_quote("#define FORWARD_IP \"127.0.0.1\"")
+cpp_quote("#define CONNECT_IP \"172.31.9.1\"")
+*/
+
+/*
+ * With midltests_tcp.exe NDR64 is enforced by default.
+ * For testing it might be needed to allow downgrades
+ * to NDR32. This is needed when you use 'pipe'.
+ */
+//cpp_quote("#define DONOT_FORCE_NDR64 1")
+
+[
+ uuid("225b9fcb-eb3d-497b-8b0b-591f049a2507"),
+ pointer_default(unique)
+]
+interface midltests
+{
+ enum level_enum { ZERO = 0, ONE = 1, TWO = 2, FOUR = 4, EIGHT = 8 };
+
+ [switch_type(enum level_enum)] union u {
+ [case(ZERO)];
+ [case(ONE)] char c;
+ [case(TWO)] short s;
+ [case(FOUR)] long l;
+ [case(EIGHT)] hyper h;
+ };
+
+ struct us {
+ enum level_enum level;
+ [switch_is(level)] union {
+ [case(ZERO)];
+ [case(ONE)] char c;
+ [case(TWO)] short s;
+ [case(FOUR)] long l;
+ [case(EIGHT)] hyper h;
+ } u;
+ };
+
+ void midltests_fn(
+ [in,ref] enum level_enum *level,
+ [in,switch_is(*level)] union u u,
+ [out,ref] struct us *us,
+ [in,out,ref] char *c
+ );
+}
+
+#elif MIDLTESTS_C_CODE
+
+static void midltests(void)
+{
+ enum level_enum level;
+ unsigned char c = 'c';
+ struct us us;
+ union u u;
+ u.h = 0xFFFFFFFFFFFFFFFFLL;
+
+ level = ZERO;
+ cli_midltests_fn(&level, u, &us, &c);
+ level = ONE;
+ cli_midltests_fn(&level, u, &us, &c);
+ level = TWO;
+ cli_midltests_fn(&level, u, &us, &c);
+ level = FOUR;
+ cli_midltests_fn(&level, u, &us, &c);
+ level = EIGHT;
+ cli_midltests_fn(&level, u, &us, &c);
+}
+
+void srv_midltests_fn(enum level_enum *level, union u u, struct us *us, unsigned char *c)
+{
+ printf("srv_midltests_fn: Start\n");
+ us->level = *level;
+ us->u.h = u.h;
+ printf("srv_midltests_fn: End\n");
+ return;
+}
+
+#endif
diff --git a/testprogs/win32/midltests/valid/midltests_union_align_16.txt b/testprogs/win32/midltests/valid/midltests_union_align_16.txt
new file mode 100644
index 0000000..5366c14
--- /dev/null
+++ b/testprogs/win32/midltests/valid/midltests_union_align_16.txt
@@ -0,0 +1,137 @@
+Wait for setup of server threads
+
+Test NDR32
+
+ndr32: disable NDR64
+
+ndr32:in => out: ptype[request] flen[29] plen[5] ahint[5]
+
+[000] 00 00 00 00 63 ....c
+
+srv_midltests_fn: Start
+srv_midltests_fn: End
+
+ndr32:out => in: ptype[response] flen[29] plen[5] ahint[5]
+
+[000] 00 00 00 00 63 ....c
+
+ndr32:in => out: ptype[request] flen[30] plen[6] ahint[6]
+
+[000] 01 00 01 00 FF 63 .....c
+
+srv_midltests_fn: Start
+srv_midltests_fn: End
+
+ndr32:out => in: ptype[response] flen[30] plen[6] ahint[6]
+
+[000] 01 00 01 00 FF 63 .....c
+
+ndr32:in => out: ptype[request] flen[31] plen[7] ahint[7]
+
+[000] 02 00 02 00 FF FF 63 ......c
+
+srv_midltests_fn: Start
+srv_midltests_fn: End
+
+ndr32:out => in: ptype[response] flen[31] plen[7] ahint[7]
+
+[000] 02 00 02 00 FF FF 63 ......c
+
+ndr32:in => out: ptype[request] flen[33] plen[9] ahint[9]
+
+[000] 04 00 04 00 FF FF FF FF 63 ........ c
+
+srv_midltests_fn: Start
+srv_midltests_fn: End
+
+ndr32:out => in: ptype[response] flen[33] plen[9] ahint[9]
+
+[000] 04 00 04 00 FF FF FF FF 63 ........ c
+
+ndr32:in => out: ptype[request] flen[41] plen[17] ahint[17]
+
+[000] 08 00 08 00 00 00 00 00 FF FF FF FF FF FF FF FF ........ ........
+[010] 63 c
+
+srv_midltests_fn: Start
+srv_midltests_fn: End
+
+ndr32:out => in: ptype[response] flen[41] plen[17] ahint[17]
+
+[000] 08 00 08 00 00 00 00 00 FF FF FF FF FF FF FF FF ........ ........
+[010] 63 c
+
+NDRTcpThread[ndr32] stop
+
+Test NDR64
+
+ndr64: got NDR64
+
+ndr64:in => out: ptype[request] flen[41] plen[17] ahint[17]
+
+[000] 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ........ ........
+[010] 63 c
+
+srv_midltests_fn: Start
+srv_midltests_fn: End
+
+ndr64:out => in: ptype[response] flen[41] plen[17] ahint[17]
+
+[000] 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ........ ........
+[010] 63 c
+
+ndr64:in => out: ptype[request] flen[42] plen[18] ahint[18]
+
+[000] 01 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 ........ ........
+[010] FF 63 .c
+
+srv_midltests_fn: Start
+srv_midltests_fn: End
+
+ndr64:out => in: ptype[response] flen[49] plen[25] ahint[25]
+
+[000] 01 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 ........ ........
+[010] FF 00 00 00 00 00 00 00 63 ........ c
+
+ndr64:in => out: ptype[request] flen[43] plen[19] ahint[19]
+
+[000] 02 00 00 00 00 00 00 00 02 00 00 00 00 00 00 00 ........ ........
+[010] FF FF 63 ..c
+
+srv_midltests_fn: Start
+srv_midltests_fn: End
+
+ndr64:out => in: ptype[response] flen[49] plen[25] ahint[25]
+
+[000] 02 00 00 00 00 00 00 00 02 00 00 00 00 00 00 00 ........ ........
+[010] FF FF 00 00 00 00 00 00 63 ........ c
+
+ndr64:in => out: ptype[request] flen[45] plen[21] ahint[21]
+
+[000] 04 00 00 00 00 00 00 00 04 00 00 00 00 00 00 00 ........ ........
+[010] FF FF FF FF 63 ....c
+
+srv_midltests_fn: Start
+srv_midltests_fn: End
+
+ndr64:out => in: ptype[response] flen[49] plen[25] ahint[25]
+
+[000] 04 00 00 00 00 00 00 00 04 00 00 00 00 00 00 00 ........ ........
+[010] FF FF FF FF 00 00 00 00 63 ........ c
+
+ndr64:in => out: ptype[request] flen[49] plen[25] ahint[25]
+
+[000] 08 00 00 00 00 00 00 00 08 00 00 00 00 00 00 00 ........ ........
+[010] FF FF FF FF FF FF FF FF 63 ........ c
+
+srv_midltests_fn: Start
+srv_midltests_fn: End
+
+ndr64:out => in: ptype[response] flen[49] plen[25] ahint[25]
+
+[000] 08 00 00 00 00 00 00 00 08 00 00 00 00 00 00 00 ........ ........
+[010] FF FF FF FF FF FF FF FF 63 ........ c
+
+NDRTcpThread[ndr64] stop
+
+Test OK
diff --git a/testprogs/win32/midltests/valid/midltests_union_align_17.idl b/testprogs/win32/midltests/valid/midltests_union_align_17.idl
new file mode 100644
index 0000000..f151452
--- /dev/null
+++ b/testprogs/win32/midltests/valid/midltests_union_align_17.idl
@@ -0,0 +1,94 @@
+#ifndef MIDLTESTS_C_CODE
+
+/*
+ * For midltests_tcp.exe you may want to
+ * redirect the traffic via rinetd
+ * with a /etc/rinetd.conf like this:
+ *
+ * 172.31.9.1 5032 172.31.9.8 5032
+ * 172.31.9.1 5064 172.31.9.8 5064
+ *
+ * This is useful to watch the traffic with
+ * a network sniffer.
+ */
+/*
+cpp_quote("#define LISTEN_IP \"0.0.0.0\"")
+cpp_quote("#define FORWARD_IP \"127.0.0.1\"")
+cpp_quote("#define CONNECT_IP \"172.31.9.1\"")
+*/
+
+/*
+ * With midltests_tcp.exe NDR64 is enforced by default.
+ * For testing it might be needed to allow downgrades
+ * to NDR32. This is needed when you use 'pipe'.
+ */
+//cpp_quote("#define DONOT_FORCE_NDR64 1")
+
+[
+ uuid("225b9fcb-eb3d-497b-8b0b-591f049a2507"),
+ ms_union,
+ pointer_default(unique)
+]
+interface midltests
+{
+ enum level_enum { ZERO = 0, ONE = 1, TWO = 2, FOUR = 4, EIGHT = 8 };
+
+ [switch_type(enum level_enum)] union u {
+ [case(ZERO)];
+ [case(ONE)] char c;
+ [case(TWO)] short s;
+ [case(FOUR)] long l;
+ [case(EIGHT)] hyper h;
+ };
+
+ struct us {
+ enum level_enum level;
+ [switch_is(level)] union {
+ [case(ZERO)];
+ [case(ONE)] char c;
+ [case(TWO)] short s;
+ [case(FOUR)] long l;
+ [case(EIGHT)] hyper h;
+ } u;
+ };
+
+ void midltests_fn(
+ [in,ref] enum level_enum *level,
+ [in,switch_is(*level)] union u u,
+ [out,ref] struct us *us,
+ [in,out,ref] char *c
+ );
+}
+
+#elif MIDLTESTS_C_CODE
+
+static void midltests(void)
+{
+ enum level_enum level;
+ char c = 'c';
+ struct us us;
+ union u u;
+ u.h = 0xFFFFFFFFFFFFFFFFLL;
+
+ level = ZERO;
+ cli_midltests_fn(&level, u, &us, &c);
+ level = ONE;
+ cli_midltests_fn(&level, u, &us, &c);
+ level = TWO;
+ cli_midltests_fn(&level, u, &us, &c);
+ level = FOUR;
+ cli_midltests_fn(&level, u, &us, &c);
+ level = EIGHT;
+ cli_midltests_fn(&level, u, &us, &c);
+}
+
+void srv_midltests_fn(enum level_enum *level, union u u, struct us *us, char *c)
+{
+ printf("srv_midltests_fn: Start\n");
+ us->level = *level;
+ us->u.h = u.h;
+ printf("srv_midltests_fn: End\n");
+ return;
+}
+
+#endif
diff --git a/testprogs/win32/midltests/valid/midltests_union_align_17.txt b/testprogs/win32/midltests/valid/midltests_union_align_17.txt
new file mode 100644
index 0000000..7b62241
--- /dev/null
+++ b/testprogs/win32/midltests/valid/midltests_union_align_17.txt
@@ -0,0 +1,137 @@
+Wait for setup of server threads
+
+Test NDR32
+
+ndr32: disable NDR64
+
+ndr32:in => out: ptype[request] flen[33] plen[9] ahint[9]
+
+[000] 00 00 00 00 00 00 00 00 63 ........ c
+
+srv_midltests_fn: Start
+srv_midltests_fn: End
+
+ndr32:out => in: ptype[response] flen[33] plen[9] ahint[9]
+
+[000] 00 00 00 00 00 00 00 00 63 ........ c
+
+ndr32:in => out: ptype[request] flen[34] plen[10] ahint[10]
+
+[000] 01 00 01 00 00 00 00 00 FF 63 ........ .c
+
+srv_midltests_fn: Start
+srv_midltests_fn: End
+
+ndr32:out => in: ptype[response] flen[34] plen[10] ahint[10]
+
+[000] 01 00 01 00 00 00 00 00 FF 63 ........ .c
+
+ndr32:in => out: ptype[request] flen[35] plen[11] ahint[11]
+
+[000] 02 00 02 00 00 00 00 00 FF FF 63 ........ ..c
+
+srv_midltests_fn: Start
+srv_midltests_fn: End
+
+ndr32:out => in: ptype[response] flen[35] plen[11] ahint[11]
+
+[000] 02 00 02 00 00 00 00 00 FF FF 63 ........ ..c
+
+ndr32:in => out: ptype[request] flen[37] plen[13] ahint[13]
+
+[000] 04 00 04 00 00 00 00 00 FF FF FF FF 63 ........ ....c
+
+srv_midltests_fn: Start
+srv_midltests_fn: End
+
+ndr32:out => in: ptype[response] flen[37] plen[13] ahint[13]
+
+[000] 04 00 04 00 00 00 00 00 FF FF FF FF 63 ........ ....c
+
+ndr32:in => out: ptype[request] flen[41] plen[17] ahint[17]
+
+[000] 08 00 08 00 00 00 00 00 FF FF FF FF FF FF FF FF ........ ........
+[010] 63 c
+
+srv_midltests_fn: Start
+srv_midltests_fn: End
+
+ndr32:out => in: ptype[response] flen[41] plen[17] ahint[17]
+
+[000] 08 00 08 00 00 00 00 00 FF FF FF FF FF FF FF FF ........ ........
+[010] 63 c
+
+NDRTcpThread[ndr32] stop
+
+Test NDR64
+
+ndr64: got NDR64
+
+ndr64:in => out: ptype[request] flen[41] plen[17] ahint[17]
+
+[000] 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ........ ........
+[010] 63 c
+
+srv_midltests_fn: Start
+srv_midltests_fn: End
+
+ndr64:out => in: ptype[response] flen[41] plen[17] ahint[17]
+
+[000] 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ........ ........
+[010] 63 c
+
+ndr64:in => out: ptype[request] flen[42] plen[18] ahint[18]
+
+[000] 01 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 ........ ........
+[010] FF 63 .c
+
+srv_midltests_fn: Start
+srv_midltests_fn: End
+
+ndr64:out => in: ptype[response] flen[49] plen[25] ahint[25]
+
+[000] 01 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 ........ ........
+[010] FF 00 00 00 00 00 00 00 63 ........ c
+
+ndr64:in => out: ptype[request] flen[43] plen[19] ahint[19]
+
+[000] 02 00 00 00 00 00 00 00 02 00 00 00 00 00 00 00 ........ ........
+[010] FF FF 63 ..c
+
+srv_midltests_fn: Start
+srv_midltests_fn: End
+
+ndr64:out => in: ptype[response] flen[49] plen[25] ahint[25]
+
+[000] 02 00 00 00 00 00 00 00 02 00 00 00 00 00 00 00 ........ ........
+[010] FF FF 00 00 00 00 00 00 63 ........ c
+
+ndr64:in => out: ptype[request] flen[45] plen[21] ahint[21]
+
+[000] 04 00 00 00 00 00 00 00 04 00 00 00 00 00 00 00 ........ ........
+[010] FF FF FF FF 63 ....c
+
+srv_midltests_fn: Start
+srv_midltests_fn: End
+
+ndr64:out => in: ptype[response] flen[49] plen[25] ahint[25]
+
+[000] 04 00 00 00 00 00 00 00 04 00 00 00 00 00 00 00 ........ ........
+[010] FF FF FF FF 00 00 00 00 63 ........ c
+
+ndr64:in => out: ptype[request] flen[49] plen[25] ahint[25]
+
+[000] 08 00 00 00 00 00 00 00 08 00 00 00 00 00 00 00 ........ ........
+[010] FF FF FF FF FF FF FF FF 63 ........ c
+
+srv_midltests_fn: Start
+srv_midltests_fn: End
+
+ndr64:out => in: ptype[response] flen[49] plen[25] ahint[25]
+
+[000] 08 00 00 00 00 00 00 00 08 00 00 00 00 00 00 00 ........ ........
+[010] FF FF FF FF FF FF FF FF 63 ........ c
+
+NDRTcpThread[ndr64] stop
+
+Test OK
diff --git a/testprogs/win32/midltests/valid/midltests_union_align_18.idl b/testprogs/win32/midltests/valid/midltests_union_align_18.idl
new file mode 100644
index 0000000..542973b
--- /dev/null
+++ b/testprogs/win32/midltests/valid/midltests_union_align_18.idl
@@ -0,0 +1,93 @@
+#ifndef MIDLTESTS_C_CODE
+
+/*
+ * For midltests_tcp.exe you may want to
+ * redirect the traffic via rinetd
+ * with a /etc/rinetd.conf like this:
+ *
+ * 172.31.9.1 5032 172.31.9.8 5032
+ * 172.31.9.1 5064 172.31.9.8 5064
+ *
+ * This is useful to watch the traffic with
+ * a network sniffer.
+ */
+/*
+cpp_quote("#define LISTEN_IP \"0.0.0.0\"")
+cpp_quote("#define FORWARD_IP \"127.0.0.1\"")
+cpp_quote("#define CONNECT_IP \"172.31.9.1\"")
+*/
+
+/*
+ * With midltests_tcp.exe NDR64 is enforced by default.
+ * For testing it might be needed to allow downgrades
+ * to NDR32. This is needed when you use 'pipe'.
+ */
+//cpp_quote("#define DONOT_FORCE_NDR64 1")
+
+[
+ uuid("225b9fcb-eb3d-497b-8b0b-591f049a2507"),
+ pointer_default(unique)
+]
+interface midltests
+{
+ enum level_enum { ZERO = 0, ONE = 1, TWO = 2, FOUR = 4, EIGHT = 8 };
+
+ [switch_type(enum level_enum),ms_union] union u {
+ [case(ZERO)];
+ [case(ONE)] char c;
+ [case(TWO)] short s;
+ [case(FOUR)] long l;
+ [case(EIGHT)] hyper h;
+ };
+
+ struct us {
+ enum level_enum level;
+ [switch_is(level)] union {
+ [case(ZERO)];
+ [case(ONE)] char c;
+ [case(TWO)] short s;
+ [case(FOUR)] long l;
+ [case(EIGHT)] hyper h;
+ } u;
+ };
+
+ void midltests_fn(
+ [in,ref] enum level_enum *level,
+ [in,switch_is(*level)] union u u,
+ [out,ref] struct us *us,
+ [in,out,ref] char *c
+ );
+}
+
+#elif MIDLTESTS_C_CODE
+
+static void midltests(void)
+{
+ enum level_enum level;
+ char c = 'c';
+ struct us us;
+ union u u;
+ u.h = 0xFFFFFFFFFFFFFFFFLL;
+
+ level = ZERO;
+ cli_midltests_fn(&level, u, &us, &c);
+ level = ONE;
+ cli_midltests_fn(&level, u, &us, &c);
+ level = TWO;
+ cli_midltests_fn(&level, u, &us, &c);
+ level = FOUR;
+ cli_midltests_fn(&level, u, &us, &c);
+ level = EIGHT;
+ cli_midltests_fn(&level, u, &us, &c);
+}
+
+void srv_midltests_fn(enum level_enum *level, union u u, struct us *us, char *c)
+{
+ printf("srv_midltests_fn: Start\n");
+ us->level = *level;
+ us->u.h = u.h;
+ printf("srv_midltests_fn: End\n");
+ return;
+}
+
+#endif
diff --git a/testprogs/win32/midltests/valid/midltests_union_align_18.txt b/testprogs/win32/midltests/valid/midltests_union_align_18.txt
new file mode 100644
index 0000000..5693dd3
--- /dev/null
+++ b/testprogs/win32/midltests/valid/midltests_union_align_18.txt
@@ -0,0 +1,137 @@
+Wait for setup of server threads
+
+Test NDR32
+
+ndr32: disable NDR64
+
+ndr32:in => out: ptype[request] flen[33] plen[9] ahint[9]
+
+[000] 00 00 00 00 00 00 00 00 63 ........ c
+
+srv_midltests_fn: Start
+srv_midltests_fn: End
+
+ndr32:out => in: ptype[response] flen[29] plen[5] ahint[5]
+
+[000] 00 00 00 00 63 ....c
+
+ndr32:in => out: ptype[request] flen[34] plen[10] ahint[10]
+
+[000] 01 00 01 00 00 00 00 00 FF 63 ........ .c
+
+srv_midltests_fn: Start
+srv_midltests_fn: End
+
+ndr32:out => in: ptype[response] flen[30] plen[6] ahint[6]
+
+[000] 01 00 01 00 FF 63 .....c
+
+ndr32:in => out: ptype[request] flen[35] plen[11] ahint[11]
+
+[000] 02 00 02 00 00 00 00 00 FF FF 63 ........ ..c
+
+srv_midltests_fn: Start
+srv_midltests_fn: End
+
+ndr32:out => in: ptype[response] flen[31] plen[7] ahint[7]
+
+[000] 02 00 02 00 FF FF 63 ......c
+
+ndr32:in => out: ptype[request] flen[37] plen[13] ahint[13]
+
+[000] 04 00 04 00 00 00 00 00 FF FF FF FF 63 ........ ....c
+
+srv_midltests_fn: Start
+srv_midltests_fn: End
+
+ndr32:out => in: ptype[response] flen[33] plen[9] ahint[9]
+
+[000] 04 00 04 00 FF FF FF FF 63 ........ c
+
+ndr32:in => out: ptype[request] flen[41] plen[17] ahint[17]
+
+[000] 08 00 08 00 00 00 00 00 FF FF FF FF FF FF FF FF ........ ........
+[010] 63 c
+
+srv_midltests_fn: Start
+srv_midltests_fn: End
+
+ndr32:out => in: ptype[response] flen[41] plen[17] ahint[17]
+
+[000] 08 00 08 00 00 00 00 00 FF FF FF FF FF FF FF FF ........ ........
+[010] 63 c
+
+NDRTcpThread[ndr32] stop
+
+Test NDR64
+
+ndr64: got NDR64
+
+ndr64:in => out: ptype[request] flen[41] plen[17] ahint[17]
+
+[000] 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ........ ........
+[010] 63 c
+
+srv_midltests_fn: Start
+srv_midltests_fn: End
+
+ndr64:out => in: ptype[response] flen[41] plen[17] ahint[17]
+
+[000] 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ........ ........
+[010] 63 c
+
+ndr64:in => out: ptype[request] flen[42] plen[18] ahint[18]
+
+[000] 01 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 ........ ........
+[010] FF 63 .c
+
+srv_midltests_fn: Start
+srv_midltests_fn: End
+
+ndr64:out => in: ptype[response] flen[49] plen[25] ahint[25]
+
+[000] 01 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 ........ ........
+[010] FF 00 00 00 00 00 00 00 63 ........ c
+
+ndr64:in => out: ptype[request] flen[43] plen[19] ahint[19]
+
+[000] 02 00 00 00 00 00 00 00 02 00 00 00 00 00 00 00 ........ ........
+[010] FF FF 63 ..c
+
+srv_midltests_fn: Start
+srv_midltests_fn: End
+
+ndr64:out => in: ptype[response] flen[49] plen[25] ahint[25]
+
+[000] 02 00 00 00 00 00 00 00 02 00 00 00 00 00 00 00 ........ ........
+[010] FF FF 00 00 00 00 00 00 63 ........ c
+
+ndr64:in => out: ptype[request] flen[45] plen[21] ahint[21]
+
+[000] 04 00 00 00 00 00 00 00 04 00 00 00 00 00 00 00 ........ ........
+[010] FF FF FF FF 63 ....c
+
+srv_midltests_fn: Start
+srv_midltests_fn: End
+
+ndr64:out => in: ptype[response] flen[49] plen[25] ahint[25]
+
+[000] 04 00 00 00 00 00 00 00 04 00 00 00 00 00 00 00 ........ ........
+[010] FF FF FF FF 00 00 00 00 63 ........ c
+
+ndr64:in => out: ptype[request] flen[49] plen[25] ahint[25]
+
+[000] 08 00 00 00 00 00 00 00 08 00 00 00 00 00 00 00 ........ ........
+[010] FF FF FF FF FF FF FF FF 63 ........ c
+
+srv_midltests_fn: Start
+srv_midltests_fn: End
+
+ndr64:out => in: ptype[response] flen[49] plen[25] ahint[25]
+
+[000] 08 00 00 00 00 00 00 00 08 00 00 00 00 00 00 00 ........ ........
+[010] FF FF FF FF FF FF FF FF 63 ........ c
+
+NDRTcpThread[ndr64] stop
+
+Test OK
diff --git a/testprogs/win32/midltests/valid/midltests_union_align_19.idl b/testprogs/win32/midltests/valid/midltests_union_align_19.idl
new file mode 100644
index 0000000..b8ff0d6
--- /dev/null
+++ b/testprogs/win32/midltests/valid/midltests_union_align_19.idl
@@ -0,0 +1,90 @@
+#ifndef MIDLTESTS_C_CODE
+
+/*
+ * For midltests_tcp.exe you may want to
+ * redirect the traffic via rinetd
+ * with a /etc/rinetd.conf like this:
+ *
+ * 172.31.9.1 5032 172.31.9.8 5032
+ * 172.31.9.1 5064 172.31.9.8 5064
+ *
+ * This is useful to watch the traffic with
+ * a network sniffer.
+ */
+/*
+cpp_quote("#define LISTEN_IP \"0.0.0.0\"")
+cpp_quote("#define FORWARD_IP \"127.0.0.1\"")
+cpp_quote("#define CONNECT_IP \"172.31.9.1\"")
+*/
+
+/*
+ * With midltests_tcp.exe NDR64 is enforced by default.
+ * For testing it might be needed to allow downgrades
+ * to NDR32. This is needed when you use 'pipe'.
+ */
+//cpp_quote("#define DONOT_FORCE_NDR64 1")
+
+[
+ uuid("225b9fcb-eb3d-497b-8b0b-591f049a2507"),
+ pointer_default(unique)
+]
+interface midltests
+{
+ enum level_enum { ZERO = 0, ONE = 1, TWO = 2, FOUR = 4, EIGHT = 8 };
+
+ [switch_type(enum level_enum)] union u {
+ [case(ZERO)];
+ [case(ONE)] char c;
+ [case(TWO)] short s;
+ [case(FOUR)] long l;
+ [case(EIGHT)] hyper h;
+ };
+
+ union ue switch(enum level_enum level) u {
+ case(ZERO):;
+ case(ONE): char c;
+ case(TWO): short s;
+ case(FOUR): long l;
+ case(EIGHT): hyper h;
+ };
+
+ void midltests_fn(
+ [in,out,ref] enum level_enum *level,
+ [in,switch_is(*level)] union u u,
+ [out,ref] union ue *ue,
+ [in,out,ref] char *c
+ );
+}
+
+#elif MIDLTESTS_C_CODE
+
+static void midltests(void)
+{
+ enum level_enum level;
+ unsigned char c = 'c';
+ struct ue ue;
+ union u u;
+ u.h = 0xFFFFFFFFFFFFFFFFLL;
+
+ level = ZERO;
+ cli_midltests_fn(&level, u, &ue, &c);
+ level = ONE;
+ cli_midltests_fn(&level, u, &ue, &c);
+ level = TWO;
+ cli_midltests_fn(&level, u, &ue, &c);
+ level = FOUR;
+ cli_midltests_fn(&level, u, &ue, &c);
+ level = EIGHT;
+ cli_midltests_fn(&level, u, &ue, &c);
+}
+
+void srv_midltests_fn(enum level_enum *level, union u u, struct ue *ue, unsigned char *c)
+{
+ printf("srv_midltests_fn: Start\n");
+ ue->level = *level;
+ ue->u.h = u.h;
+ printf("srv_midltests_fn: End\n");
+ return;
+}
+
+#endif
diff --git a/testprogs/win32/midltests/valid/midltests_union_align_19.txt b/testprogs/win32/midltests/valid/midltests_union_align_19.txt
new file mode 100644
index 0000000..804f0ed
--- /dev/null
+++ b/testprogs/win32/midltests/valid/midltests_union_align_19.txt
@@ -0,0 +1,137 @@
+Wait for setup of server threads
+
+Test NDR32
+
+ndr32: disable NDR64
+
+ndr32:in => out: ptype[request] flen[29] plen[5] ahint[5]
+
+[000] 00 00 00 00 63 ....c
+
+srv_midltests_fn: Start
+srv_midltests_fn: End
+
+ndr32:out => in: ptype[response] flen[29] plen[5] ahint[5]
+
+[000] 00 00 00 00 63 ....c
+
+ndr32:in => out: ptype[request] flen[30] plen[6] ahint[6]
+
+[000] 01 00 01 00 FF 63 .....c
+
+srv_midltests_fn: Start
+srv_midltests_fn: End
+
+ndr32:out => in: ptype[response] flen[30] plen[6] ahint[6]
+
+[000] 01 00 01 00 FF 63 .....c
+
+ndr32:in => out: ptype[request] flen[31] plen[7] ahint[7]
+
+[000] 02 00 02 00 FF FF 63 ......c
+
+srv_midltests_fn: Start
+srv_midltests_fn: End
+
+ndr32:out => in: ptype[response] flen[31] plen[7] ahint[7]
+
+[000] 02 00 02 00 FF FF 63 ......c
+
+ndr32:in => out: ptype[request] flen[33] plen[9] ahint[9]
+
+[000] 04 00 04 00 FF FF FF FF 63 ........ c
+
+srv_midltests_fn: Start
+srv_midltests_fn: End
+
+ndr32:out => in: ptype[response] flen[33] plen[9] ahint[9]
+
+[000] 04 00 04 00 FF FF FF FF 63 ........ c
+
+ndr32:in => out: ptype[request] flen[41] plen[17] ahint[17]
+
+[000] 08 00 08 00 00 00 00 00 FF FF FF FF FF FF FF FF ........ ........
+[010] 63 c
+
+srv_midltests_fn: Start
+srv_midltests_fn: End
+
+ndr32:out => in: ptype[response] flen[41] plen[17] ahint[17]
+
+[000] 08 00 08 00 00 00 00 00 FF FF FF FF FF FF FF FF ........ ........
+[010] 63 c
+
+NDRTcpThread[ndr32] stop
+
+Test NDR64
+
+ndr64: got NDR64
+
+ndr64:in => out: ptype[request] flen[41] plen[17] ahint[17]
+
+[000] 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ........ ........
+[010] 63 c
+
+srv_midltests_fn: Start
+srv_midltests_fn: End
+
+ndr64:out => in: ptype[response] flen[41] plen[17] ahint[17]
+
+[000] 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ........ ........
+[010] 63 c
+
+ndr64:in => out: ptype[request] flen[42] plen[18] ahint[18]
+
+[000] 01 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 ........ ........
+[010] FF 63 .c
+
+srv_midltests_fn: Start
+srv_midltests_fn: End
+
+ndr64:out => in: ptype[response] flen[42] plen[18] ahint[18]
+
+[000] 01 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 ........ ........
+[010] FF 63 .c
+
+ndr64:in => out: ptype[request] flen[43] plen[19] ahint[19]
+
+[000] 02 00 00 00 00 00 00 00 02 00 00 00 00 00 00 00 ........ ........
+[010] FF FF 63 ..c
+
+srv_midltests_fn: Start
+srv_midltests_fn: End
+
+ndr64:out => in: ptype[response] flen[43] plen[19] ahint[19]
+
+[000] 02 00 00 00 00 00 00 00 02 00 00 00 00 00 00 00 ........ ........
+[010] FF FF 63 ..c
+
+ndr64:in => out: ptype[request] flen[45] plen[21] ahint[21]
+
+[000] 04 00 00 00 00 00 00 00 04 00 00 00 00 00 00 00 ........ ........
+[010] FF FF FF FF 63 ....c
+
+srv_midltests_fn: Start
+srv_midltests_fn: End
+
+ndr64:out => in: ptype[response] flen[45] plen[21] ahint[21]
+
+[000] 04 00 00 00 00 00 00 00 04 00 00 00 00 00 00 00 ........ ........
+[010] FF FF FF FF 63 ....c
+
+ndr64:in => out: ptype[request] flen[49] plen[25] ahint[25]
+
+[000] 08 00 00 00 00 00 00 00 08 00 00 00 00 00 00 00 ........ ........
+[010] FF FF FF FF FF FF FF FF 63 ........ c
+
+srv_midltests_fn: Start
+srv_midltests_fn: End
+
+ndr64:out => in: ptype[response] flen[49] plen[25] ahint[25]
+
+[000] 08 00 00 00 00 00 00 00 08 00 00 00 00 00 00 00 ........ ........
+[010] FF FF FF FF FF FF FF FF 63 ........ c
+
+NDRTcpThread[ndr64] stop
+
+Test OK
diff --git a/testprogs/win32/midltests/valid/midltests_union_align_20.idl b/testprogs/win32/midltests/valid/midltests_union_align_20.idl
new file mode 100644
index 0000000..fe8bb72
--- /dev/null
+++ b/testprogs/win32/midltests/valid/midltests_union_align_20.idl
@@ -0,0 +1,91 @@
+#ifndef MIDLTESTS_C_CODE
+
+/*
+ * For midltests_tcp.exe you may want to
+ * redirect the traffic via rinetd
+ * with a /etc/rinetd.conf like this:
+ *
+ * 172.31.9.1 5032 172.31.9.8 5032
+ * 172.31.9.1 5064 172.31.9.8 5064
+ *
+ * This is useful to watch the traffic with
+ * a network sniffer.
+ */
+/*
+cpp_quote("#define LISTEN_IP \"0.0.0.0\"")
+cpp_quote("#define FORWARD_IP \"127.0.0.1\"")
+cpp_quote("#define CONNECT_IP \"172.31.9.1\"")
+*/
+
+/*
+ * With midltests_tcp.exe NDR64 is enforced by default.
+ * For testing it might be needed to allow downgrades
+ * to NDR32. This is needed when you use 'pipe'.
+ */
+//cpp_quote("#define DONOT_FORCE_NDR64 1")
+
+[
+ uuid("225b9fcb-eb3d-497b-8b0b-591f049a2507"),
+ ms_union,
+ pointer_default(unique)
+]
+interface midltests
+{
+ enum level_enum { ZERO = 0, ONE = 1, TWO = 2, FOUR = 4, EIGHT = 8 };
+
+ [switch_type(enum level_enum)] union u {
+ [case(ZERO)];
+ [case(ONE)] char c;
+ [case(TWO)] short s;
+ [case(FOUR)] long l;
+ [case(EIGHT)] hyper h;
+ };
+
+ union ue switch(enum level_enum level) u {
+ case(ZERO):;
+ case(ONE): char c;
+ case(TWO): short s;
+ case(FOUR): long l;
+ case(EIGHT): hyper h;
+ };
+
+ void midltests_fn(
+ [in,out,ref] enum level_enum *level,
+ [in,switch_is(*level)] union u u,
+ [out,ref] union ue *ue,
+ [in,out,ref] char *c
+ );
+}
+
+#elif MIDLTESTS_C_CODE
+
+static void midltests(void)
+{
+ enum level_enum level;
+ unsigned char c = 'c';
+ struct ue ue;
+ union u u;
+ u.h = 0xFFFFFFFFFFFFFFFFLL;
+
+ level = ZERO;
+ cli_midltests_fn(&level, u, &ue, &c);
+ level = ONE;
+ cli_midltests_fn(&level, u, &ue, &c);
+ level = TWO;
+ cli_midltests_fn(&level, u, &ue, &c);
+ level = FOUR;
+ cli_midltests_fn(&level, u, &ue, &c);
+ level = EIGHT;
+ cli_midltests_fn(&level, u, &ue, &c);
+}
+
+void srv_midltests_fn(enum level_enum *level, union u u, struct ue *ue, unsigned char *c)
+{
+ printf("srv_midltests_fn: Start\n");
+ ue->level = *level;
+ ue->u.h = u.h;
+ printf("srv_midltests_fn: End\n");
+ return;
+}
+
+#endif
diff --git a/testprogs/win32/midltests/valid/midltests_union_align_20.txt b/testprogs/win32/midltests/valid/midltests_union_align_20.txt
new file mode 100644
index 0000000..84d62aa
--- /dev/null
+++ b/testprogs/win32/midltests/valid/midltests_union_align_20.txt
@@ -0,0 +1,137 @@
+Wait for setup of server threads
+
+Test NDR32
+
+ndr32: disable NDR64
+
+ndr32:in => out: ptype[request] flen[33] plen[9] ahint[9]
+
+[000] 00 00 00 00 00 00 00 00 63 ........ c
+
+srv_midltests_fn: Start
+srv_midltests_fn: End
+
+ndr32:out => in: ptype[response] flen[29] plen[5] ahint[5]
+
+[000] 00 00 00 00 63 ....c
+
+ndr32:in => out: ptype[request] flen[34] plen[10] ahint[10]
+
+[000] 01 00 01 00 00 00 00 00 FF 63 ........ .c
+
+srv_midltests_fn: Start
+srv_midltests_fn: End
+
+ndr32:out => in: ptype[response] flen[30] plen[6] ahint[6]
+
+[000] 01 00 01 00 FF 63 .....c
+
+ndr32:in => out: ptype[request] flen[35] plen[11] ahint[11]
+
+[000] 02 00 02 00 00 00 00 00 FF FF 63 ........ ..c
+
+srv_midltests_fn: Start
+srv_midltests_fn: End
+
+ndr32:out => in: ptype[response] flen[31] plen[7] ahint[7]
+
+[000] 02 00 02 00 FF FF 63 ......c
+
+ndr32:in => out: ptype[request] flen[37] plen[13] ahint[13]
+
+[000] 04 00 04 00 00 00 00 00 FF FF FF FF 63 ........ ....c
+
+srv_midltests_fn: Start
+srv_midltests_fn: End
+
+ndr32:out => in: ptype[response] flen[33] plen[9] ahint[9]
+
+[000] 04 00 04 00 FF FF FF FF 63 ........ c
+
+ndr32:in => out: ptype[request] flen[41] plen[17] ahint[17]
+
+[000] 08 00 08 00 00 00 00 00 FF FF FF FF FF FF FF FF ........ ........
+[010] 63 c
+
+srv_midltests_fn: Start
+srv_midltests_fn: End
+
+ndr32:out => in: ptype[response] flen[41] plen[17] ahint[17]
+
+[000] 08 00 08 00 00 00 00 00 FF FF FF FF FF FF FF FF ........ ........
+[010] 63 c
+
+NDRTcpThread[ndr32] stop
+
+Test NDR64
+
+ndr64: got NDR64
+
+ndr64:in => out: ptype[request] flen[41] plen[17] ahint[17]
+
+[000] 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ........ ........
+[010] 63 c
+
+srv_midltests_fn: Start
+srv_midltests_fn: End
+
+ndr64:out => in: ptype[response] flen[41] plen[17] ahint[17]
+
+[000] 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ........ ........
+[010] 63 c
+
+ndr64:in => out: ptype[request] flen[42] plen[18] ahint[18]
+
+[000] 01 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 ........ ........
+[010] FF 63 .c
+
+srv_midltests_fn: Start
+srv_midltests_fn: End
+
+ndr64:out => in: ptype[response] flen[42] plen[18] ahint[18]
+
+[000] 01 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 ........ ........
+[010] FF 63 .c
+
+ndr64:in => out: ptype[request] flen[43] plen[19] ahint[19]
+
+[000] 02 00 00 00 00 00 00 00 02 00 00 00 00 00 00 00 ........ ........
+[010] FF FF 63 ..c
+
+srv_midltests_fn: Start
+srv_midltests_fn: End
+
+ndr64:out => in: ptype[response] flen[43] plen[19] ahint[19]
+
+[000] 02 00 00 00 00 00 00 00 02 00 00 00 00 00 00 00 ........ ........
+[010] FF FF 63 ..c
+
+ndr64:in => out: ptype[request] flen[45] plen[21] ahint[21]
+
+[000] 04 00 00 00 00 00 00 00 04 00 00 00 00 00 00 00 ........ ........
+[010] FF FF FF FF 63 ....c
+
+srv_midltests_fn: Start
+srv_midltests_fn: End
+
+ndr64:out => in: ptype[response] flen[45] plen[21] ahint[21]
+
+[000] 04 00 00 00 00 00 00 00 04 00 00 00 00 00 00 00 ........ ........
+[010] FF FF FF FF 63 ....c
+
+ndr64:in => out: ptype[request] flen[49] plen[25] ahint[25]
+
+[000] 08 00 00 00 00 00 00 00 08 00 00 00 00 00 00 00 ........ ........
+[010] FF FF FF FF FF FF FF FF 63 ........ c
+
+srv_midltests_fn: Start
+srv_midltests_fn: End
+
+ndr64:out => in: ptype[response] flen[49] plen[25] ahint[25]
+
+[000] 08 00 00 00 00 00 00 00 08 00 00 00 00 00 00 00 ........ ........
+[010] FF FF FF FF FF FF FF FF 63 ........ c
+
+NDRTcpThread[ndr64] stop
+
+Test OK
diff --git a/testprogs/win32/midltests/valid/midltests_v1_enum_01.idl b/testprogs/win32/midltests/valid/midltests_v1_enum_01.idl
new file mode 100644
index 0000000..18a5ceb
--- /dev/null
+++ b/testprogs/win32/midltests/valid/midltests_v1_enum_01.idl
@@ -0,0 +1,56 @@
+#ifndef MIDLTESTS_C_CODE
+
+/*
+ * For midltests_tcp.exe you may want to
+ * redirect the traffic via rinetd
+ * with a /etc/rinetd.conf like this:
+ *
+ * 172.31.9.1 5032 172.31.9.8 5032
+ * 172.31.9.1 5064 172.31.9.8 5064
+ *
+ * This is useful to watch the traffic with
+ * a network sniffer.
+ */
+/*
+cpp_quote("#define LISTEN_IP \"0.0.0.0\"")
+cpp_quote("#define FORWARD_IP \"127.0.0.1\"")
+cpp_quote("#define CONNECT_IP \"172.31.9.1\"")
+*/
+
+/*
+ * With midltests_tcp.exe NDR64 is enforced by default.
+ * For testing it might be needed to allow downgrades
+ * to NDR32. This is needed when you use 'pipe'.
+ */
+//cpp_quote("#define DONOT_FORCE_NDR64 1")
+
+[
+ uuid("225b9fcb-eb3d-497b-8b0b-591f049a2507"),
+ pointer_default(unique)
+]
+interface midltests
+{
+ typedef [v1_enum] enum {
+ value1 = -1
+ } midltests_enum;
+
+ long midltests_fn(
+ midltests_enum v
+ );
+}
+
+#elif MIDLTESTS_C_CODE
+
+static void midltests(void)
+{
+ cli_midltests_fn(value1);
+}
+
+long srv_midltests_fn(enum midltests_enum v)
+{
+ printf("srv_midltests_fn: Start\n");
+ printf("srv_midltests_fn: End\n");
+ return 0x65757254;
+}
+
+#endif
diff --git a/testprogs/win32/midltests/valid/midltests_v1_enum_01.txt b/testprogs/win32/midltests/valid/midltests_v1_enum_01.txt
new file mode 100644
index 0000000..d4d018c
--- /dev/null
+++ b/testprogs/win32/midltests/valid/midltests_v1_enum_01.txt
@@ -0,0 +1,37 @@
+Wait for setup of server threads
+
+Test NDR32
+
+ndr32: disable NDR64
+
+ndr32:in => out: ptype[request] flen[28] plen[4] ahint[4]
+
+[000] FF FF FF FF ....
+
+srv_midltests_fn: Start
+srv_midltests_fn: End
+
+ndr32:out => in: ptype[response] flen[28] plen[4] ahint[4]
+
+[000] 54 72 75 65 True
+
+NDRTcpThread[ndr32] stop
+
+Test NDR64
+
+ndr64: got NDR64
+
+ndr64:in => out: ptype[request] flen[28] plen[4] ahint[4]
+
+[000] FF FF FF FF ....
+
+srv_midltests_fn: Start
+srv_midltests_fn: End
+
+ndr64:out => in: ptype[response] flen[28] plen[4] ahint[4]
+
+[000] 54 72 75 65 True
+
+NDRTcpThread[ndr64] stop
+
+Test OK
diff --git a/testprogs/win32/npecho/GNUmakefile b/testprogs/win32/npecho/GNUmakefile
new file mode 100755
index 0000000..5b4f976
--- /dev/null
+++ b/testprogs/win32/npecho/GNUmakefile
@@ -0,0 +1,24 @@
+INCLUDES=-I.
+CFLAGS=$(INCLUDES)
+
+NPECHO = npecho_client.exe
+#npecho_server.exe
+
+NPECHO2 = npecho_client2.exe npecho_server2.exe
+
+all: $(NPECHO) $(NPECHO2)
+
+MINGW_CC = i586-mingw32msvc-cc
+CC = $(MINGW_CC)
+
+.SUFFIXES: .c .obj .exe
+
+.c.obj:
+ $(CC) $(CFLAGS) -c $< -o $@
+
+.obj.exe:
+ $(CC) $(CFLAGS) -o $@ $< $(LIBS)
+
+clean:
+ rm -f *~ *.obj *.exe
+
diff --git a/testprogs/win32/npecho/NMakefile b/testprogs/win32/npecho/NMakefile
new file mode 100755
index 0000000..a0e61d7
--- /dev/null
+++ b/testprogs/win32/npecho/NMakefile
@@ -0,0 +1,26 @@
+#
+# use nmake /f NMakefile [<target>]
+#
+INCLUDES=-I
+CFLAGS=$(INCLUDES) -Zi -nologo
+
+NPECHO = npecho_client.exe
+# missing npecho_server.exe
+NPECHO2 = npecho_client2.exe npecho_server2.exe
+
+all: $(NPECHO) $(NPECHO2)
+
+clean:
+ del *~ *.obj *.exe
+
+npecho_client.exe: npecho_client.obj
+ $(CC) $(CFLAGS) -o npecho_client.exe npecho_client.obj $(LIBS)
+
+npecho_server.exe: npecho_server.obj
+ $(CC) $(CFLAGS) -o npecho_server.exe npecho_server.obj $(LIBS)
+
+npecho_client2.exe: npecho_client2.obj
+ $(CC) $(CFLAGS) -o npecho_client2.exe npecho_client2.obj $(LIBS)
+
+npecho_server2.exe: npecho_server2.obj
+ $(CC) $(CFLAGS) -o npecho_server2.exe npecho_server2.obj $(LIBS)
diff --git a/testprogs/win32/npecho/npecho_client.c b/testprogs/win32/npecho/npecho_client.c
new file mode 100755
index 0000000..97d31c4
--- /dev/null
+++ b/testprogs/win32/npecho/npecho_client.c
@@ -0,0 +1,50 @@
+/*
+ * Simple Named Pipe Client
+ * (C) 2005 Jelmer Vernooij <jelmer@samba.org>
+ * Published to the public domain
+ */
+
+#include <windows.h>
+#include <stdio.h>
+
+#define ECHODATA "Black Dog"
+
+int main(int argc, char *argv[])
+{
+ HANDLE h;
+ DWORD numread = 0;
+ char *outbuffer = malloc(strlen(ECHODATA));
+
+ if (argc == 1) {
+ printf("Usage: %s pipename\n", argv[0]);
+ printf(" Where pipename is something like \\\\servername\\NPECHO\n");
+ return -1;
+ }
+
+ h = CreateFile(argv[1], GENERIC_READ|GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL);
+ if (h == INVALID_HANDLE_VALUE) {
+ printf("Error opening: %d\n", GetLastError());
+ return -1;
+ }
+
+ if (!WriteFile(h, ECHODATA, strlen(ECHODATA), &numread, NULL)) {
+ printf("Error writing: %d\n", GetLastError());
+ return -1;
+ }
+
+ if (!ReadFile(h, outbuffer, strlen(ECHODATA), &numread, NULL)) {
+ printf("Error reading: %d\n", GetLastError());
+ return -1;
+ }
+
+ printf("Read: %s\n", outbuffer);
+
+ if (!TransactNamedPipe(h, ECHODATA, strlen(ECHODATA), outbuffer, strlen(ECHODATA), &numread, NULL)) {
+ printf("TransactNamedPipe failed: %d!\n", GetLastError());
+ return -1;
+ }
+
+ printf("Result: %s\n", outbuffer);
+
+ return 0;
+}
diff --git a/testprogs/win32/npecho/npecho_client2.c b/testprogs/win32/npecho/npecho_client2.c
new file mode 100755
index 0000000..ebf4f9a
--- /dev/null
+++ b/testprogs/win32/npecho/npecho_client2.c
@@ -0,0 +1,117 @@
+/*
+ * Simple Named Pipe Client
+ * (C) 2005 Jelmer Vernooij <jelmer@samba.org>
+ * (C) 2009 Stefan Metzmacher <metze@samba.org>
+ * Published to the public domain
+ */
+
+#include <windows.h>
+#include <stdio.h>
+
+#define ECHODATA "Black Dog"
+
+int main(int argc, char *argv[])
+{
+ HANDLE h;
+ DWORD numread = 0;
+ char *outbuffer = malloc(sizeof(ECHODATA)*2);
+ BOOL small_reads = FALSE;
+ DWORD state = 0;
+ DWORD flags = 0;
+
+ if (argc == 1) {
+ goto usage;
+ } else if (argc >= 3) {
+ if (strcmp(argv[2], "large") == 0) {
+ small_reads = FALSE;
+ } else if (strcmp(argv[2], "small") == 0) {
+ small_reads = TRUE;
+ } else {
+ goto usage;
+ }
+ }
+
+ h = CreateFile(argv[1], GENERIC_READ|GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL);
+ if (h == INVALID_HANDLE_VALUE) {
+ printf("Error opening: %d\n", GetLastError());
+ return -1;
+ }
+
+ GetNamedPipeHandleState(h, &state, NULL, NULL, NULL, NULL, 0);
+
+ if (state & PIPE_READMODE_MESSAGE) {
+ printf("message read mode\n");
+ } else {
+ printf("byte read mode\n");
+ }
+
+ Sleep(5000);
+
+ if (small_reads) {
+ DWORD ofs, size, nread;
+ const char *more = "";
+ printf("small reads\n");
+ numread = 0;
+ ofs = 0;
+ size = sizeof(ECHODATA)/2;
+ if (ReadFile(h, outbuffer+ofs, size, &nread, NULL)) {
+ if (state & PIPE_READMODE_MESSAGE) {
+ printf("Error message mode small read succeeded\n");
+ return -1;
+ }
+ } else if (GetLastError() == ERROR_MORE_DATA) {
+ if (!(state & PIPE_READMODE_MESSAGE)) {
+ printf("Error byte mode small read returned ERROR_MORE_DATA\n");
+ return -1;
+ }
+ more = " more data";
+ } else {
+ printf("Error reading: %d\n", GetLastError());
+ return -1;
+ }
+ printf("Small Read: %d%s\n", nread, more);
+ numread += nread;
+ ofs = size;
+ size = sizeof(ECHODATA) - ofs;
+ if (!ReadFile(h, outbuffer+ofs, size, &nread, NULL)) {
+ printf("Error reading: %d\n", GetLastError());
+ return -1;
+ }
+ printf("Small Read: %d\n", nread);
+ numread += nread;
+ } else {
+ printf("large read\n");
+ if (!ReadFile(h, outbuffer, sizeof(ECHODATA)*2, &numread, NULL)) {
+ printf("Error reading: %d\n", GetLastError());
+ return -1;
+ }
+ }
+ printf("Read: %s %d\n", outbuffer, numread);
+ if (state & PIPE_READMODE_MESSAGE) {
+ if (numread != sizeof(ECHODATA)) {
+ printf("message mode returned %d bytes should be %s\n",
+ numread, sizeof(ECHODATA));
+ return -1;
+ }
+ } else {
+ if (numread != (sizeof(ECHODATA)*2)) {
+ printf("message mode returned %d bytes should be %s\n",
+ numread, (sizeof(ECHODATA)*2));
+ return -1;
+ }
+ }
+
+ if (!ReadFile(h, outbuffer, sizeof(ECHODATA)*2, &numread, NULL)) {
+ printf("Error reading: %d\n", GetLastError());
+ return -1;
+ }
+
+ printf("Read: %s %d\n", outbuffer, numread);
+
+ return 0;
+usage:
+ printf("Usage: %s pipename [read]\n", argv[0]);
+ printf(" Where pipename is something like \\\\servername\\NPECHO\n");
+ printf(" Where read is something 'large' or 'small'\n");
+ return -1;
+}
diff --git a/testprogs/win32/npecho/npecho_server2.c b/testprogs/win32/npecho/npecho_server2.c
new file mode 100755
index 0000000..281fc45
--- /dev/null
+++ b/testprogs/win32/npecho/npecho_server2.c
@@ -0,0 +1,76 @@
+/*
+ * Simple Named Pipe Client
+ * (C) 2005 Jelmer Vernooij <jelmer@samba.org>
+ * (C) 2009 Stefan Metzmacher <metze@samba.org>
+ * Published to the public domain
+ */
+
+#include <windows.h>
+#include <stdio.h>
+
+#define ECHODATA "Black Dog"
+
+int main(int argc, char *argv[])
+{
+ HANDLE h;
+ DWORD numread = 0;
+ char *outbuffer = malloc(sizeof(ECHODATA));
+ BOOL msgmode = FALSE;
+ DWORD type = 0;
+
+ if (argc == 1) {
+ goto usage;
+ } else if (argc >= 3) {
+ if (strcmp(argv[2], "byte") == 0) {
+ msgmode = FALSE;
+ } else if (strcmp(argv[2], "message") == 0) {
+ msgmode = TRUE;
+ } else {
+ goto usage;
+ }
+ }
+
+ if (msgmode == TRUE) {
+ printf("using message mode\n");
+ type = PIPE_TYPE_MESSAGE | PIPE_READMODE_MESSAGE | PIPE_WAIT;
+ } else {
+ printf("using byte mode\n");
+ type = PIPE_TYPE_BYTE | PIPE_READMODE_BYTE | PIPE_WAIT;
+ }
+
+ h = CreateNamedPipe(argv[1],
+ PIPE_ACCESS_DUPLEX,
+ type,
+ PIPE_UNLIMITED_INSTANCES,
+ 1024,
+ 1024,
+ 0,
+ NULL);
+ if (h == INVALID_HANDLE_VALUE) {
+ printf("Error opening: %d\n", GetLastError());
+ return -1;
+ }
+
+ ConnectNamedPipe(h, NULL);
+
+ if (!WriteFile(h, ECHODATA, sizeof(ECHODATA), &numread, NULL)) {
+ printf("Error writing: %d\n", GetLastError());
+ return -1;
+ }
+
+ if (!WriteFile(h, ECHODATA, sizeof(ECHODATA), &numread, NULL)) {
+ printf("Error writing: %d\n", GetLastError());
+ return -1;
+ }
+
+ FlushFileBuffers(h);
+ DisconnectNamedPipe(h);
+ CloseHandle(h);
+
+ return 0;
+usage:
+ printf("Usage: %s pipename [mode]\n", argv[0]);
+ printf(" Where pipename is something like \\\\servername\\PIPE\\NPECHO\n");
+ printf(" Where mode is 'byte' or 'message'\n");
+ return -1;
+}
diff --git a/testprogs/win32/prepare_dcpromo/GNUmakefile b/testprogs/win32/prepare_dcpromo/GNUmakefile
new file mode 100755
index 0000000..1c95613
--- /dev/null
+++ b/testprogs/win32/prepare_dcpromo/GNUmakefile
@@ -0,0 +1,21 @@
+INCLUDES=-I.
+CFLAGS=$(INCLUDES)
+LIBS=-ladvapi32
+
+PREPARE_DCPROMO = prepare_dcpromo.exe
+
+all: $(PREPARE_DCPROMO)
+
+MINGW_CC = i586-mingw32msvc-cc
+CC = $(MINGW_CC)
+
+.SUFFIXES: .c .obj .exe
+
+.c.obj:
+ $(CC) $(CFLAGS) -c $< -o $@
+
+.obj.exe:
+ $(CC) $(CFLAGS) -o $@ $< $(LIBS)
+
+clean:
+ rm -f *~ *.obj *.exe
diff --git a/testprogs/win32/prepare_dcpromo/NMakefile b/testprogs/win32/prepare_dcpromo/NMakefile
new file mode 100755
index 0000000..6f810ee
--- /dev/null
+++ b/testprogs/win32/prepare_dcpromo/NMakefile
@@ -0,0 +1,16 @@
+#
+# use nmake /f NMakefile [<target>]
+#
+INCLUDES=-I
+CFLAGS=$(INCLUDES) -Zi -nologo -Dsnprintf=sprintf_s
+LIBS=advapi32.lib
+
+PREPARE_DCPROMO = prepare_dcpromo.exe
+
+all: $(PREPARE_DCPROMO)
+
+clean:
+ del *~ *.obj *.exe
+
+prepare_dcpromo.exe: prepare_dcpromo.obj
+ $(CC) $(CFLAGS) -o prepare_dcpromo.exe prepare_dcpromo.obj $(LIBS)
diff --git a/testprogs/win32/prepare_dcpromo/prepare_dcpromo.c b/testprogs/win32/prepare_dcpromo/prepare_dcpromo.c
new file mode 100755
index 0000000..91b819b
--- /dev/null
+++ b/testprogs/win32/prepare_dcpromo/prepare_dcpromo.c
@@ -0,0 +1,1074 @@
+/*
+ Copyright (C) Stefan Metzmacher <metze@samba.org> 2010
+
+ 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
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+ Published to the public domain
+ */
+
+/*
+ * This tool can set the DOMAIN-SID and nextRid counter in
+ * the local SAM on windows servers (tested with w2k8r2)
+ *
+ * dcpromo will use this values for the ad domain it creates.
+ *
+ * This might be useful for upgrades from a Samba3 domain.
+ */
+
+#include <windows.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <ctype.h>
+
+/* Convert a binary SID to a character string */
+static DWORD SidToString(const SID *sid,
+ char **string)
+{
+ DWORD id_auth;
+ int i, ofs, maxlen;
+ char *result;
+
+ if (!sid) {
+ return ERROR_INVALID_SID;
+ }
+
+ maxlen = sid->SubAuthorityCount * 11 + 25;
+
+ result = (char *)malloc(maxlen);
+ if (result == NULL) {
+ return ERROR_NOT_ENOUGH_MEMORY;
+ }
+
+ /*
+ * BIG NOTE: this function only does SIDS where the identauth is not
+ * >= ^32 in a range of 2^48.
+ */
+
+ id_auth = sid->IdentifierAuthority.Value[5] +
+ (sid->IdentifierAuthority.Value[4] << 8) +
+ (sid->IdentifierAuthority.Value[3] << 16) +
+ (sid->IdentifierAuthority.Value[2] << 24);
+
+ ofs = snprintf(result, maxlen, "S-%u-%lu",
+ (unsigned int)sid->Revision, (unsigned long)id_auth);
+
+ for (i = 0; i < sid->SubAuthorityCount; i++) {
+ ofs += snprintf(result + ofs, maxlen - ofs, "-%lu",
+ (unsigned long)sid->SubAuthority[i]);
+ }
+
+ *string = result;
+ return ERROR_SUCCESS;
+}
+
+static DWORD StringToSid(const char *str,
+ SID *sid)
+{
+ const char *p;
+ char *q;
+ DWORD x;
+
+ if (!sid) {
+ return ERROR_INVALID_PARAMETER;
+ }
+
+ /* Sanity check for either "S-" or "s-" */
+
+ if (!str
+ || (str[0]!='S' && str[0]!='s')
+ || (str[1]!='-'))
+ {
+ return ERROR_INVALID_PARAMETER;
+ }
+
+ /* Get the SID revision number */
+
+ p = str+2;
+ x = (DWORD)strtol(p, &q, 10);
+ if (x==0 || !q || *q!='-') {
+ return ERROR_INVALID_SID;
+ }
+ sid->Revision = (BYTE)x;
+
+ /* Next the Identifier Authority. This is stored in big-endian
+ in a 6 byte array. */
+
+ p = q+1;
+ x = (DWORD)strtol(p, &q, 10);
+ if (!q || *q!='-') {
+ return ERROR_INVALID_SID;
+ }
+ sid->IdentifierAuthority.Value[5] = (x & 0x000000ff);
+ sid->IdentifierAuthority.Value[4] = (x & 0x0000ff00) >> 8;
+ sid->IdentifierAuthority.Value[3] = (x & 0x00ff0000) >> 16;
+ sid->IdentifierAuthority.Value[2] = (x & 0xff000000) >> 24;
+ sid->IdentifierAuthority.Value[1] = 0;
+ sid->IdentifierAuthority.Value[0] = 0;
+
+ /* now read the the subauthorities */
+
+ p = q +1;
+ sid->SubAuthorityCount = 0;
+ while (sid->SubAuthorityCount < 6) {
+ x=(DWORD)strtoul(p, &q, 10);
+ if (p == q)
+ break;
+ if (q == NULL) {
+ return ERROR_INVALID_SID;
+ }
+ sid->SubAuthority[sid->SubAuthorityCount++] = x;
+
+ if ((*q!='-') || (*q=='\0'))
+ break;
+ p = q + 1;
+ }
+
+ /* IF we ended early, then the SID could not be converted */
+
+ if (q && *q!='\0') {
+ return ERROR_INVALID_SID;
+ }
+
+ return ERROR_SUCCESS;
+}
+
+#define MIN(a,b) ((a)<(b)?(a):(b))
+static void print_asc(const unsigned char *buf,int len)
+{
+ int i;
+ for (i=0;i<len;i++)
+ printf("%c", isprint(buf[i])?buf[i]:'.');
+}
+
+static void dump_data(const unsigned char *buf1,int len)
+{
+ const unsigned char *buf = (const unsigned char *)buf1;
+ int i=0;
+ if (len<=0) return;
+
+ printf("[%03X] ",i);
+ for (i=0;i<len;) {
+ printf("%02X ",(int)buf[i]);
+ i++;
+ if (i%8 == 0) printf(" ");
+ if (i%16 == 0) {
+ print_asc(&buf[i-16],8); printf(" ");
+ print_asc(&buf[i-8],8); printf("\n");
+ if (i<len) printf("[%03X] ",i);
+ }
+ }
+ if (i%16) {
+ int n;
+ n = 16 - (i%16);
+ printf(" ");
+ if (n>8) printf(" ");
+ while (n--) printf(" ");
+ n = MIN(8,i%16);
+ print_asc(&buf[i-(i%16)],n); printf( " " );
+ n = (i%16) - n;
+ if (n>0) print_asc(&buf[i-n],n);
+ printf("\n");
+ }
+}
+
+static DWORD calc_tmp_HKLM_SECURITY_SD(SECURITY_DESCRIPTOR *old_sd,
+ SID *current_user_sid,
+ SECURITY_DESCRIPTOR **_old_parent_sd,
+ SECURITY_DESCRIPTOR **_old_child_sd,
+ SECURITY_DESCRIPTOR **_new_parent_sd,
+ SECURITY_DESCRIPTOR **_new_child_sd)
+{
+ LONG status;
+ DWORD cbSecurityDescriptor = 0;
+ SECURITY_DESCRIPTOR *old_parent_sd = NULL;
+ SECURITY_DESCRIPTOR *old_child_sd = NULL;
+ SECURITY_DESCRIPTOR *new_parent_sd = NULL;
+ SECURITY_DESCRIPTOR *new_child_sd = NULL;
+ BOOL ok;
+ ACL *old_Dacl = NULL;
+ ACL *new_Dacl = NULL;
+ ACL_SIZE_INFORMATION dacl_info;
+ DWORD i = 0;
+ SECURITY_DESCRIPTOR *AbsoluteSD = NULL;
+ DWORD dwAbsoluteSDSize = 0;
+ DWORD dwRelativeSDSize = 0;
+ DWORD dwDaclSize = 0;
+ ACL *Sacl = NULL;
+ DWORD dwSaclSize = 0;
+ SID *Owner = NULL;
+ DWORD dwOwnerSize = 0;
+ SID *PrimaryGroup = NULL;
+ DWORD dwPrimaryGroupSize = 0;
+ ACCESS_ALLOWED_ACE *ace = NULL;
+
+ ok = MakeAbsoluteSD(old_sd,
+ NULL,
+ &dwAbsoluteSDSize,
+ NULL,
+ &dwDaclSize,
+ NULL,
+ &dwSaclSize,
+ NULL,
+ &dwOwnerSize,
+ NULL,
+ &dwPrimaryGroupSize);
+ if (!ok) {
+ status = GetLastError();
+ }
+ if (status != ERROR_INSUFFICIENT_BUFFER) {
+ printf("LINE:%u: Error: %d (0x%X)\n", __LINE__, status, status);
+ return status;
+ }
+
+ AbsoluteSD = (SECURITY_DESCRIPTOR *)malloc(dwAbsoluteSDSize+1024);
+ if (AbsoluteSD == NULL) {
+ printf("LINE:%u: Error: no memory\n", __LINE__);
+ return ERROR_NOT_ENOUGH_MEMORY;
+ }
+ old_Dacl = (ACL *)malloc(dwDaclSize + 1024);
+ if (old_Dacl == NULL) {
+ printf("LINE:%u: Error: no memory\n", __LINE__);
+ return ERROR_NOT_ENOUGH_MEMORY;
+ }
+ Sacl = (ACL *)malloc(dwSaclSize);
+ if (Sacl == NULL) {
+ printf("LINE:%u: Error: no memory\n", __LINE__);
+ return ERROR_NOT_ENOUGH_MEMORY;
+ }
+ Owner = (SID *)malloc(dwOwnerSize);
+ if (Owner == NULL) {
+ printf("LINE:%u: Error: no memory\n", __LINE__);
+ return ERROR_NOT_ENOUGH_MEMORY;
+ }
+ PrimaryGroup = (SID *)malloc(dwPrimaryGroupSize);
+ if (PrimaryGroup == NULL) {
+ printf("LINE:%u: Error: no memory\n", __LINE__);
+ return ERROR_NOT_ENOUGH_MEMORY;
+ }
+
+ ok = MakeAbsoluteSD(old_sd,
+ AbsoluteSD,
+ &dwAbsoluteSDSize,
+ old_Dacl,
+ &dwDaclSize,
+ Sacl,
+ &dwSaclSize,
+ Owner,
+ &dwOwnerSize,
+ PrimaryGroup,
+ &dwPrimaryGroupSize);
+ if (!ok) {
+ status = GetLastError();
+ printf("LINE:%u: Error: %d (0x%X)\n", __LINE__, status, status);
+ return status;
+ }
+
+ AbsoluteSD->Control |= SE_DACL_AUTO_INHERITED | SE_DACL_AUTO_INHERIT_REQ | SE_DACL_PROTECTED;
+ dwRelativeSDSize = 0;
+ ok = MakeSelfRelativeSD(AbsoluteSD,
+ NULL,
+ &dwRelativeSDSize);
+ if (!ok) {
+ status = GetLastError();
+ }
+ if (status != ERROR_INSUFFICIENT_BUFFER) {
+ printf("LINE:%u: Error: %d (0x%X)\n", __LINE__, status, status);
+ return ERROR_NOT_ENOUGH_MEMORY;
+ }
+
+ old_parent_sd = (SECURITY_DESCRIPTOR *)malloc(dwRelativeSDSize);
+ if (old_parent_sd == NULL) {
+ printf("LINE:%u: Error: no memory\n", __LINE__);
+ return ERROR_NOT_ENOUGH_MEMORY;
+ }
+
+ ok = MakeSelfRelativeSD(AbsoluteSD,
+ old_parent_sd,
+ &dwRelativeSDSize);
+ if (!ok) {
+ status = GetLastError();
+ printf("LINE:%u: Error: %d (0x%X)\n", __LINE__, status, status);
+ return status;
+ }
+
+ ok = GetAclInformation(old_Dacl,
+ &dacl_info,
+ sizeof(dacl_info),
+ AclSizeInformation);
+ if (!ok) {
+ status = GetLastError();
+ printf("LINE:%u: Error: %d (0x%X)\n", __LINE__, status, status);
+ return status;
+ }
+
+ new_Dacl = (ACL *)calloc(dacl_info.AclBytesInUse + 1024, 1);
+ if (new_Dacl == NULL) {
+ printf("LINE:%u: Error: no memory\n", __LINE__);
+ return ERROR_NOT_ENOUGH_MEMORY;
+ }
+
+ InitializeAcl(new_Dacl, dacl_info.AclBytesInUse + 1024, ACL_REVISION);
+
+ ok = AddAccessAllowedAce(new_Dacl, ACL_REVISION,
+ KEY_ALL_ACCESS, current_user_sid);
+ if (!ok) {
+ status = GetLastError();
+ printf("LINE:%u: Error: %d (0x%X)\n", __LINE__, status, status);
+ return status;
+ }
+
+ ok = GetAce(new_Dacl, 0, (LPVOID *)&ace);
+ if (!ok) {
+ status = GetLastError();
+ printf("LINE:%u: Error: %d (0x%X)\n", __LINE__, status, status);
+ return status;
+ }
+
+ ace->Header.AceFlags |= CONTAINER_INHERIT_ACE | OBJECT_INHERIT_ACE;
+
+ for (i=0; i < dacl_info.AceCount; i++) {
+ ok = GetAce(old_Dacl, i, (LPVOID *)&ace);
+ if (!ok) {
+ status = GetLastError();
+ printf("LINE:%u: Error: %d (0x%X)\n", __LINE__, status, status);
+ return status;
+ }
+
+ ok = AddAce(new_Dacl, ACL_REVISION, MAXDWORD,
+ ace, ace->Header.AceSize);
+ if (!ok) {
+ status = GetLastError();
+ printf("LINE:%u: Error: %d (0x%X)\n", __LINE__, status, status);
+ return status;
+ }
+ }
+
+ AbsoluteSD->Dacl = new_Dacl;
+ dwRelativeSDSize = 0;
+ ok = MakeSelfRelativeSD(AbsoluteSD,
+ NULL,
+ &dwRelativeSDSize);
+ if (!ok) {
+ status = GetLastError();
+ }
+ if (status != ERROR_INSUFFICIENT_BUFFER) {
+ printf("LINE:%u: Error: %d (0x%X)\n", __LINE__, status, status);
+ return ERROR_NOT_ENOUGH_MEMORY;
+ }
+
+ new_parent_sd = (SECURITY_DESCRIPTOR *)malloc(dwRelativeSDSize);
+ if (new_parent_sd == NULL) {
+ printf("LINE:%u: Error: no memory\n", __LINE__);
+ return ERROR_NOT_ENOUGH_MEMORY;
+ }
+
+ ok = MakeSelfRelativeSD(AbsoluteSD,
+ new_parent_sd,
+ &dwRelativeSDSize);
+ if (!ok) {
+ status = GetLastError();
+ printf("LINE:%u: Error: %d (0x%X)\n", __LINE__, status, status);
+ return status;
+ }
+
+ for (i=0; i < dacl_info.AceCount; i++) {
+ ok = GetAce(old_Dacl, i, (LPVOID *)&ace);
+ if (!ok) {
+ status = GetLastError();
+ printf("LINE:%u: Error: %d (0x%X)\n", __LINE__, status, status);
+ return status;
+ }
+
+ ace->Header.AceFlags |= INHERITED_ACE;
+ }
+
+ AbsoluteSD->Control &= ~SE_DACL_PROTECTED;
+ AbsoluteSD->Dacl = old_Dacl;
+ dwRelativeSDSize = 0;
+ ok = MakeSelfRelativeSD(AbsoluteSD,
+ NULL,
+ &dwRelativeSDSize);
+ if (!ok) {
+ status = GetLastError();
+ }
+ if (status != ERROR_INSUFFICIENT_BUFFER) {
+ printf("LINE:%u: Error: %d (0x%X)\n", __LINE__, status, status);
+ return ERROR_NOT_ENOUGH_MEMORY;
+ }
+
+ old_child_sd = (SECURITY_DESCRIPTOR *)malloc(dwRelativeSDSize);
+ if (old_child_sd == NULL) {
+ printf("LINE:%u: Error: no memory\n", __LINE__);
+ return ERROR_NOT_ENOUGH_MEMORY;
+ }
+
+ ok = MakeSelfRelativeSD(AbsoluteSD,
+ old_child_sd,
+ &dwRelativeSDSize);
+ if (!ok) {
+ status = GetLastError();
+ printf("LINE:%u: Error: %d (0x%X)\n", __LINE__, status, status);
+ return status;
+ }
+
+ for (i=0; i < dacl_info.AceCount + 1; i++) {
+ ok = GetAce(new_Dacl, i, (LPVOID *)&ace);
+ if (!ok) {
+ status = GetLastError();
+ printf("LINE:%u: Error: %d (0x%X)\n", __LINE__, status, status);
+ return status;
+ }
+
+ ace->Header.AceFlags |= INHERITED_ACE;
+ }
+
+ AbsoluteSD->Dacl = new_Dacl;
+ dwRelativeSDSize = 0;
+ ok = MakeSelfRelativeSD(AbsoluteSD,
+ NULL,
+ &dwRelativeSDSize);
+ if (!ok) {
+ status = GetLastError();
+ }
+ if (status != ERROR_INSUFFICIENT_BUFFER) {
+ printf("LINE:%u: Error: %d (0x%X)\n", __LINE__, status, status);
+ return ERROR_NOT_ENOUGH_MEMORY;
+ }
+
+ new_child_sd = (SECURITY_DESCRIPTOR *)malloc(dwRelativeSDSize);
+ if (new_child_sd == NULL) {
+ printf("LINE:%u: Error: no memory\n", __LINE__);
+ return ERROR_NOT_ENOUGH_MEMORY;
+ }
+
+ ok = MakeSelfRelativeSD(AbsoluteSD,
+ new_child_sd,
+ &dwRelativeSDSize);
+ if (!ok) {
+ status = GetLastError();
+ printf("LINE:%u: Error: %d (0x%X)\n", __LINE__, status, status);
+ return status;
+ }
+
+ *_old_parent_sd = old_parent_sd;
+ *_old_child_sd = old_child_sd;
+ *_new_parent_sd = new_parent_sd;
+ *_new_child_sd = new_child_sd;
+ return ERROR_SUCCESS;
+}
+
+static DWORD inherit_SD(HKEY parent_hk,
+ char *current_key,
+ BOOL reset,
+ SECURITY_DESCRIPTOR *current_sd,
+ SECURITY_DESCRIPTOR *child_sd)
+{
+ DWORD status;
+ DWORD i = 0;
+ HKEY current_hk;
+
+ if (!reset) {
+ status = RegOpenKeyEx(parent_hk,
+ current_key,
+ 0, /* options */
+ WRITE_DAC, /* samDesired */
+ &current_hk);
+ if (status != ERROR_SUCCESS) {
+ printf("LINE:%u: Error: %d (0x%X)\n", __LINE__, status, status);
+ return status;
+ }
+
+ status = RegSetKeySecurity(current_hk,
+ DACL_SECURITY_INFORMATION |
+ PROTECTED_DACL_SECURITY_INFORMATION |
+ UNPROTECTED_DACL_SECURITY_INFORMATION |
+ UNPROTECTED_SACL_SECURITY_INFORMATION,
+ current_sd /* pSecurityDescriptor */
+ );
+ if (status != ERROR_SUCCESS) {
+ printf("LINE:%u: Error: %d (0x%X)\n", __LINE__, status, status);
+ return status;
+ }
+
+ RegCloseKey(current_hk);
+ }
+
+ status = RegOpenKeyEx(parent_hk,
+ current_key,
+ 0, /* options */
+ KEY_ENUMERATE_SUB_KEYS, /* samDesired */
+ &current_hk);
+ if (status != ERROR_SUCCESS) {
+ printf("LINE:%u: Error: %d (0x%X)\n", __LINE__, status, status);
+ return status;
+ }
+
+ for (i=0; ; i++) {
+ char subkey[10240];
+ HKEY hk_child;
+
+ memset(subkey, 0, sizeof(subkey));
+ status = RegEnumKey(current_hk, i, subkey, sizeof(subkey));
+ if (status == ERROR_NO_MORE_ITEMS) {
+ break;
+ }
+ if (status != ERROR_SUCCESS) {
+ printf("LINE:%u: Error: %d (0x%X)\n", __LINE__, status, status);
+ return status;
+ }
+
+#if 0
+ printf("subkey: %s\n", subkey);
+#endif
+
+ status = inherit_SD(current_hk, subkey, reset,
+ child_sd, child_sd);
+ if (status != ERROR_SUCCESS) {
+ printf("LINE:%u: Error: %d (0x%X)\n", __LINE__, status, status);
+ return status;
+ }
+ }
+
+ RegCloseKey(current_hk);
+
+ if (reset) {
+ status = RegOpenKeyEx(parent_hk,
+ current_key,
+ 0, /* options */
+ WRITE_DAC, /* samDesired */
+ &current_hk);
+ if (status != ERROR_SUCCESS) {
+ printf("LINE:%u: Error: %d (0x%X)\n", __LINE__, status, status);
+ return status;
+ }
+
+ status = RegSetKeySecurity(current_hk,
+ DACL_SECURITY_INFORMATION |
+ PROTECTED_DACL_SECURITY_INFORMATION |
+ UNPROTECTED_DACL_SECURITY_INFORMATION |
+ UNPROTECTED_SACL_SECURITY_INFORMATION,
+ current_sd /* pSecurityDescriptor */
+ );
+ if (status != ERROR_SUCCESS) {
+ printf("LINE:%u: Error: %d (0x%X)\n", __LINE__, status, status);
+ return status;
+ }
+
+ RegCloseKey(current_hk);
+ }
+
+ return ERROR_SUCCESS;
+}
+
+static DWORD replaceSIDBuffer(BYTE *buf, DWORD len,
+ SID *oldDomainSid,
+ SID *newDomainSid)
+{
+ DWORD ret = 0;
+ BYTE *oldb = ((BYTE *)oldDomainSid)+2;
+ BYTE *newb = ((BYTE *)newDomainSid)+2;
+ int cmp;
+
+#if 0
+ printf("replaceSIDBuffer: %u\n", len);
+ dump_data(buf, len);
+#endif
+
+ if (len < 24) {
+ return 0;
+ }
+
+ if (buf[0] != SID_REVISION) {
+ return 0;
+ }
+
+ switch (buf[1]) {
+ case 4:
+ ret = 24;
+ break;
+ case 5:
+ if (len < 28) {
+ return 0;
+ }
+ ret = 28;
+ break;
+ default:
+ return 0;
+ }
+
+#if 0
+ printf("oldb:\n");
+ dump_data(oldb, 22);
+#endif
+ cmp = memcmp(&buf[2], oldb, 22);
+ if (cmp != 0) {
+ return 0;
+ }
+
+ memcpy(&buf[2], newb, 22);
+
+ return ret;
+}
+
+static DWORD replaceSID(HKEY parent_hk,
+ const char *parent_path,
+ const char *current_key,
+ SID *oldDomainSid,
+ SID *newDomainSid)
+{
+ DWORD status;
+ DWORD i = 0;
+ HKEY current_hk;
+ char current_path[10240];
+
+ snprintf(current_path, sizeof(current_path), "%s\\%s",
+ parent_path, current_key);
+
+ status = RegOpenKeyEx(parent_hk,
+ current_key,
+ 0, /* options */
+ KEY_ALL_ACCESS, /* samDesired */
+ &current_hk);
+ if (status != ERROR_SUCCESS) {
+ printf("LINE:%u: Error: %d (0x%X)\n", __LINE__, status, status);
+ return status;
+ }
+
+ for (i=0; ; i++) {
+ char subkey[10240];
+ HKEY hk_child;
+
+ memset(subkey, 0, sizeof(subkey));
+ status = RegEnumKey(current_hk, i, subkey, sizeof(subkey));
+ if (status == ERROR_NO_MORE_ITEMS) {
+ break;
+ }
+ if (status != ERROR_SUCCESS) {
+ printf("LINE:%u: Error: %d (0x%X)\n", __LINE__, status, status);
+ return status;
+ }
+
+#if 0
+ printf("subkey: %s\n", subkey);
+#endif
+
+ status = replaceSID(current_hk, current_path, subkey,
+ oldDomainSid, newDomainSid);
+ if (status != ERROR_SUCCESS) {
+ printf("LINE:%u: Error: %d (0x%X)\n", __LINE__, status, status);
+ return status;
+ }
+ }
+
+ for (i=0; ; i++) {
+ char valueName[10240];
+ DWORD cbValueName;
+ DWORD valueType = 0;
+ BYTE *valueData = NULL;
+ DWORD cbValueData = 0;
+ DWORD ofs = 0;
+ BOOL modified = FALSE;
+
+ memset(valueName, 0, sizeof(valueName));
+ cbValueName = sizeof(valueName)-1;
+ status = RegEnumValue(current_hk, i,
+ valueName, &cbValueName,
+ NULL, NULL,
+ NULL, &cbValueData);
+ if (status == ERROR_NO_MORE_ITEMS) {
+ break;
+ }
+ if (status != ERROR_SUCCESS) {
+ printf("LINE:%u: Error: %d (0x%X)\n", __LINE__, status, status);
+ return status;
+ }
+
+ valueData = (BYTE *)malloc(cbValueData);
+ if (valueData == NULL) {
+ printf("LINE:%u: Error: no memory\n", __LINE__);
+ return ERROR_NOT_ENOUGH_MEMORY;
+ }
+
+ cbValueName = sizeof(valueName)-1;
+ status = RegEnumValue(current_hk, i,
+ valueName, &cbValueName,
+ NULL, &valueType,
+ valueData, &cbValueData);
+ if (status != ERROR_SUCCESS) {
+ printf("LINE:%u: Error: %d (0x%X)\n", __LINE__, status, status);
+ return status;
+ }
+
+ if (valueType != REG_BINARY) {
+ free(valueData);
+ continue;
+ }
+
+ for (ofs=0; ofs < cbValueData;) {
+ DWORD len;
+
+ len = replaceSIDBuffer(valueData + ofs,
+ cbValueData - ofs,
+ oldDomainSid,
+ newDomainSid);
+ if (len == 0) {
+ ofs += 4;
+ continue;
+ }
+
+#if 0
+ printf("%s value[%u]:%s modified ofs:%u (0x%X) len:%u\n",
+ current_path, i, valueName, ofs, ofs, len);
+#endif
+
+ ofs += len;
+ modified = TRUE;
+ }
+
+ if (!modified) {
+ free(valueData);
+ continue;
+ }
+
+ printf("%s value[%u]:%s replacing data\n",
+ current_path, i, valueName);
+ status = RegSetValueEx(current_hk,
+ valueName,
+ 0,
+ valueType,
+ valueData,
+ cbValueData);
+ if (status != ERROR_SUCCESS) {
+ printf("LINE:%u: Error: %d (0x%X)\n", __LINE__, status, status);
+ return status;
+ }
+
+ free(valueData);
+ }
+
+ RegCloseKey(current_hk);
+
+ return ERROR_SUCCESS;
+}
+
+int main(int argc, char *argv[])
+{
+ LONG status;
+ HANDLE tokenHandle = NULL;
+ TOKEN_USER *tokenUser = NULL;
+ DWORD cbTokenUser = 0;
+ HKEY hklm;
+ HKEY hk_security;
+ HKEY hk_account_domain;
+ DWORD cbSecurityDescriptor = 0;
+ SECURITY_DESCRIPTOR *security_old_sd = NULL;
+ SECURITY_DESCRIPTOR *security_parent_old_sd = NULL;
+ SECURITY_DESCRIPTOR *security_child_old_sd = NULL;
+ SECURITY_DESCRIPTOR *security_parent_new_sd = NULL;
+ SECURITY_DESCRIPTOR *security_child_new_sd = NULL;
+ SID *currentUserSid = NULL;
+ char *currentUserSidString = NULL;
+ BOOL ok;
+ DWORD cbTmp = 0;
+ BYTE *AccountDomainF = NULL;
+ DWORD cbAccountDomainF = 0;
+ DWORD AccountDomainFType = 0;
+ DWORD *nextRid = NULL;
+ DWORD oldNextRid = 0;
+ DWORD newNextRid = 0;
+ BYTE *AccountDomainV = NULL;
+ DWORD cbAccountDomainV = 0;
+ SID *oldDomainSid = NULL;
+ char *oldDomainSidString = NULL;
+ SID *newDomainSid = NULL;
+ const char *newDomainSidString = NULL;
+
+ if (argc < 2 || argc > 3) {
+ printf("Usage: %s <DOMAINSID> [<NEXTRID>]\n", argv[0]);
+ return -1;
+ }
+
+ newDomainSidString = argv[1];
+
+ newDomainSid = (SID *)malloc(24);
+ if (newDomainSid == NULL) {
+ printf("LINE:%u: Error: no memory\n", __LINE__);
+ return -1;
+ }
+
+ status = StringToSid(newDomainSidString, newDomainSid);
+ if (status != ERROR_SUCCESS) {
+ printf("Failed to parse DOMAINSID[%s]: Error: %d (0x%X)\n",
+ newDomainSidString, status, status);
+ return -1;
+ }
+ if (newDomainSid->SubAuthorityCount != 4) {
+ printf("DOMAINSID[%s]: Invalid SubAuthorityCount[%u] should be 4\n",
+ newDomainSidString, newDomainSid->SubAuthorityCount);
+ return -1;
+ }
+
+ if (argc == 3) {
+ char *q = NULL;
+ newNextRid = (DWORD)strtoul(argv[2], &q, 10);
+ if (newNextRid == 0 || newNextRid == 0xFFFFFFFF || !q || *q!='\0') {
+ printf("Invalid newNextRid[%s]\n", argv[2]);
+ return -1;
+ }
+ if (newNextRid < 1000) {
+ printf("newNextRid[%u] < 1000\n", newNextRid);
+ return -1;
+ }
+ }
+
+ ok = OpenProcessToken(GetCurrentProcess(), TOKEN_READ, &tokenHandle);
+ if (!ok) {
+ status = GetLastError();
+ printf("LINE:%u: Error: %d (0x%X)\n", __LINE__, status, status);
+ return status;
+ }
+
+ ok = GetTokenInformation(tokenHandle, TokenUser,
+ NULL, 0, &cbTokenUser);
+ if (!ok) {
+ status = GetLastError();
+ }
+ if (status != ERROR_INSUFFICIENT_BUFFER) {
+ printf("LINE:%u: Error: %d (0x%X)\n", __LINE__, status, status);
+ return status;
+ }
+
+ tokenUser = (TOKEN_USER *)malloc(cbTokenUser);
+ if (tokenUser == NULL) {
+ printf("LINE:%u: Error: no memory\n", __LINE__);
+ return -1;
+ }
+
+ ok = GetTokenInformation(tokenHandle, TokenUser,
+ tokenUser, cbTokenUser, &cbTokenUser);
+ if (!ok) {
+ status = GetLastError();
+ printf("LINE:%u: Error: %d (0x%X)\n", __LINE__, status, status);
+ return status;
+ }
+
+ currentUserSid = tokenUser->User.Sid;
+
+ status = SidToString(currentUserSid, &currentUserSidString);
+ if (status != ERROR_SUCCESS) {
+ printf("LINE:%u: Error: %d (0x%X)\n", __LINE__, status, status);
+ return -1;
+ }
+
+ status = RegConnectRegistry(NULL, HKEY_LOCAL_MACHINE, &hklm);
+ if (status != ERROR_SUCCESS) {
+ printf("LINE:%u: Error: %d (0x%X)\n", __LINE__, status, status);
+ return -1;
+ }
+
+ status = RegOpenKeyEx(hklm, "SECURITY",
+ 0, /* options */
+ READ_CONTROL, /* samDesired */
+ &hk_security);
+ if (status != ERROR_SUCCESS) {
+ printf("LINE:%u: Error: %d (0x%X)\n", __LINE__, status, status);
+ return -1;
+ }
+
+ status = RegGetKeySecurity(hk_security,
+ OWNER_SECURITY_INFORMATION |
+ GROUP_SECURITY_INFORMATION |
+ DACL_SECURITY_INFORMATION |
+ PROTECTED_DACL_SECURITY_INFORMATION |
+ UNPROTECTED_DACL_SECURITY_INFORMATION |
+ UNPROTECTED_SACL_SECURITY_INFORMATION,
+ NULL, /* pSecurityDescriptor */
+ &cbSecurityDescriptor /* lpcbSecurityDescriptor */
+ );
+ if (status != ERROR_INSUFFICIENT_BUFFER) {
+ printf("LINE:%u: Error: %d (0x%X)\n", __LINE__, status, status);
+ return -1;
+ }
+
+ security_old_sd = (SECURITY_DESCRIPTOR *)malloc(cbSecurityDescriptor);
+ if (security_old_sd == NULL) {
+ printf("LINE:%u: Error: no memory\n", __LINE__);
+ return -1;
+ }
+
+ status = RegGetKeySecurity(hk_security,
+ OWNER_SECURITY_INFORMATION |
+ GROUP_SECURITY_INFORMATION |
+ DACL_SECURITY_INFORMATION |
+ PROTECTED_DACL_SECURITY_INFORMATION |
+ UNPROTECTED_DACL_SECURITY_INFORMATION |
+ UNPROTECTED_SACL_SECURITY_INFORMATION,
+ security_old_sd, /* pSecurityDescriptor */
+ &cbSecurityDescriptor /* lpcbSecurityDescriptor */
+ );
+ if (status != ERROR_SUCCESS) {
+ printf("LINE:%u: Error: %d (0x%X)\n", __LINE__, status, status);
+ return -1;
+ }
+
+ RegCloseKey(hk_security);
+
+ printf("currentUserSid: %s\n", currentUserSidString);
+
+ status = calc_tmp_HKLM_SECURITY_SD(security_old_sd,
+ currentUserSid,
+ &security_parent_old_sd,
+ &security_child_old_sd,
+ &security_parent_new_sd,
+ &security_child_new_sd);
+ if (status != ERROR_SUCCESS) {
+ printf("LINE:%u: Error: %d (0x%X)\n", __LINE__, status, status);
+ return -1;
+ }
+
+ printf("Grant full access to HKLM\\SECURITY\n");
+ status = inherit_SD(hklm, "SECURITY", FALSE,
+ security_parent_new_sd, security_child_new_sd);
+ if (status != ERROR_SUCCESS) {
+ printf("LINE:%u: Error: %d (0x%X)\n", __LINE__, status, status);
+ return -1;
+ }
+
+ status = RegOpenKeyEx(hklm, "SECURITY\\SAM\\Domains\\Account",
+ 0, /* options */
+ KEY_ALL_ACCESS, /* samDesired */
+ &hk_account_domain);
+ if (status != ERROR_SUCCESS) {
+ printf("LINE:%u: Error: %d (0x%X)\n", __LINE__, status, status);
+ return -1;
+ }
+
+ status = RegQueryValueEx(hk_account_domain,
+ "F", NULL, NULL,
+ NULL,
+ &cbAccountDomainF);
+ if (status != ERROR_SUCCESS) {
+ printf("LINE:%u: Error: %d (0x%X)\n", __LINE__, status, status);
+ return -1;
+ }
+
+ AccountDomainF = (BYTE *)malloc(cbAccountDomainF);
+ if (AccountDomainF == NULL) {
+ printf("LINE:%u: Error: no memory\n", __LINE__);
+ return -1;
+ }
+
+ status = RegQueryValueEx(hk_account_domain,
+ "F", NULL, NULL,
+ AccountDomainF,
+ &cbAccountDomainF);
+ if (status != ERROR_SUCCESS) {
+ printf("LINE:%u: Error: %d (0x%X)\n", __LINE__, status, status);
+ return -1;
+ }
+
+ nextRid = (DWORD *)((BYTE *)AccountDomainF + 0x48);
+ oldNextRid = *nextRid;
+ if (newNextRid == 0) {
+ newNextRid = oldNextRid;
+ }
+ printf("AccountDomainF: %u bytes\n", cbAccountDomainF);
+
+ status = RegQueryValueEx(hk_account_domain,
+ "V", NULL, NULL,
+ NULL,
+ &cbAccountDomainV);
+ if (status != ERROR_SUCCESS) {
+ printf("LINE:%u: Error: %d (0x%X)\n", __LINE__, status, status);
+ return -1;
+ }
+
+ AccountDomainV = (BYTE *)malloc(cbAccountDomainV);
+ if (AccountDomainV == NULL) {
+ printf("LINE:%u: Error: no memory\n", __LINE__);
+ return -1;
+ }
+
+ status = RegQueryValueEx(hk_account_domain,
+ "V", NULL, NULL,
+ AccountDomainV,
+ &cbAccountDomainV);
+ if (status != ERROR_SUCCESS) {
+ printf("LINE:%u: Error: %d (0x%X)\n", __LINE__, status, status);
+ return -1;
+ }
+
+ printf("AccountDomainV: %u bytes\n", cbAccountDomainV);
+ oldDomainSid = (SID *)((BYTE *)AccountDomainV + (cbAccountDomainV - 24));
+
+ status = SidToString(oldDomainSid, &oldDomainSidString);
+ if (status != ERROR_SUCCESS) {
+ printf("LINE:%u: Error: %d (0x%X)\n", __LINE__, status, status);
+ return -1;
+ }
+
+ printf("Old Domain:%s, NextRid: %u (0x%08X)\n",
+ oldDomainSidString, oldNextRid, oldNextRid);
+ printf("New Domain:%s, NextRid: %u (0x%08X)\n",
+ newDomainSidString, newNextRid, newNextRid);
+
+ status = replaceSID(hklm, "HKLM", "SECURITY\\SAM\\Domains",
+ oldDomainSid, newDomainSid);
+ if (status != ERROR_SUCCESS) {
+ printf("LINE:%u: Error: %d (0x%X)\n", __LINE__, status, status);
+ goto failed;
+ }
+
+ status = RegQueryValueEx(hk_account_domain,
+ "F", NULL, &AccountDomainFType,
+ AccountDomainF,
+ &cbAccountDomainF);
+ if (status != ERROR_SUCCESS) {
+ printf("LINE:%u: Error: %d (0x%X)\n", __LINE__, status, status);
+ return -1;
+ }
+ nextRid = (DWORD *)((BYTE *)AccountDomainF + 0x48);
+ *nextRid = newNextRid;
+
+ printf("AccountDomainF replacing data (nextRid)\n");
+ status = RegSetValueEx(hk_account_domain,
+ "F",
+ 0,
+ AccountDomainFType,
+ AccountDomainF,
+ cbAccountDomainF);
+ if (status != ERROR_SUCCESS) {
+ printf("LINE:%u: Error: %d (0x%X)\n", __LINE__, status, status);
+ return status;
+ }
+
+ printf("Withdraw full access to HKLM\\SECURITY\n");
+ status = inherit_SD(hklm, "SECURITY", TRUE,
+ security_parent_old_sd, security_child_old_sd);
+ if (status != ERROR_SUCCESS) {
+ printf("LINE:%u: Error: %d (0x%X)\n", __LINE__, status, status);
+ return -1;
+ }
+ printf("DONE!\n");
+ return 0;
+failed:
+ printf("Withdraw full access to HKLM\\SECURITY\n");
+ status = inherit_SD(hklm, "SECURITY", TRUE,
+ security_parent_old_sd, security_child_old_sd);
+ if (status != ERROR_SUCCESS) {
+ printf("LINE:%u: Error: %d (0x%X)\n", __LINE__, status, status);
+ return -1;
+ }
+ printf("FAILED!\n");
+ return 0;
+}
diff --git a/testprogs/win32/rpcecho/Makefile b/testprogs/win32/rpcecho/Makefile
new file mode 100644
index 0000000..ca0c823
--- /dev/null
+++ b/testprogs/win32/rpcecho/Makefile
@@ -0,0 +1,23 @@
+INCLUDES=-I
+CFLAGS=$(INCLUDES) -Zi -nologo
+LIBS=rpcrt4.lib
+
+all: client server
+
+clean:
+ del *~ *.obj client server rpcecho_c.c rpcecho_s.c rpcecho.h
+
+rpcecho.h rpcecho_s.c rpcecho_c.c: rpcecho.idl rpcecho.acf
+ midl rpcecho.idl
+
+client: client.obj rpcecho_c.obj utils.obj
+ $(CC) $(CFLAGS) -o client client.obj rpcecho_c.obj utils.obj $(LIBS)
+
+server: server.obj rpcecho_s.obj utils.obj
+ $(CC) $(CFLAGS) -o server server.obj rpcecho_s.obj utils.obj $(LIBS)
+
+client.obj: rpcecho.h client.c
+server.obj: rpcecho.h server.c
+rpcecho_c.obj: rpcecho.h rpcecho_c.c
+rpcecho_s.obj: rpcecho.h rpcecho_s.c
+utils.obj: rpcecho.h utils.c
diff --git a/testprogs/win32/rpcecho/README b/testprogs/win32/rpcecho/README
new file mode 100644
index 0000000..2eb6ab9
--- /dev/null
+++ b/testprogs/win32/rpcecho/README
@@ -0,0 +1,46 @@
+This directory contains two win32 programs to test large RPC requests
+and responses. The two programs are:
+
+ server A command line RPC server that listens and processes
+ RPC requests on the \pipe\rpcecho named pipe.
+
+ client A command line RPC client program that
+
+Samba also implements the client and server sides of the rpcecho pipe
+if the --enable-developer option to configure has been used. The
+rpcclient(1) program is used to implement the client side RPC
+operations.
+
+There are currently four RPC calls defined in the rpcecho pipe. They
+are:
+
+ AddOne Adds one to an integer sent by the client
+
+ EchoData The client sends an array of bytes and it is echoed
+ back by the server.
+
+ SourceData The client sends an array of bytes and it is discarded
+ by the server.
+
+ SinkData The server returns an array of bytes.
+
+The Ethereal network protocol decoder (http://www.ethereal.com/) also
+contains support for the rpcecho pipe as part of its DCERPC for
+Windows.
+
+Starting the win32 server program is easy. Just run server.exe in a
+command window. The win32 client program is also run from a command
+window. The usage information is shown below:
+
+ Usage: client hostname cmd [args]
+
+ Where hostname is the name of the host to connect to,
+ and cmd is the command to execute with optional args:
+
+ addone num Add one to num and return the result
+ echodata size Send an array of size bytes and receive it back
+ sinkdata size Send an array of size bytes
+ sourcedata size Receive an array of size bytes
+
+Tim Potter
+tpot@samba.org
diff --git a/testprogs/win32/rpcecho/client.c b/testprogs/win32/rpcecho/client.c
new file mode 100644
index 0000000..dae2a4b
--- /dev/null
+++ b/testprogs/win32/rpcecho/client.c
@@ -0,0 +1,367 @@
+/*
+ RPC echo client.
+
+ Copyright (C) Tim Potter 2003
+
+ 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
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <ctype.h>
+#include "rpcecho.h"
+
+void main(int argc, char **argv)
+{
+ RPC_STATUS status;
+ char *binding = NULL;
+ const char *username=NULL;
+ const char *password=NULL;
+ const char *domain=NULL;
+ unsigned sec_options = 0;
+
+ argv += 1;
+ argc -= 1;
+
+ while (argc > 2 && argv[0][0] == '-') {
+ const char *option;
+
+ switch (argv[0][1]) {
+ case 'e':
+ binding = argv[1];
+ break;
+ case 'u':
+ username = argv[1];
+ break;
+ case 'p':
+ password = argv[1];
+ break;
+ case 'd':
+ domain = argv[1];
+ break;
+ case '-':
+ option = &argv[0][2];
+ if (strcmp(option, "sign") == 0) {
+ if (sec_options == RPC_C_AUTHN_LEVEL_PKT_PRIVACY) {
+ printf("You must choose sign or seal, not both\n");
+ exit(1);
+ }
+ sec_options = RPC_C_AUTHN_LEVEL_PKT_INTEGRITY;
+ } else if (strcmp(option, "seal") == 0) {
+ if (sec_options == RPC_C_AUTHN_LEVEL_PKT_INTEGRITY) {
+ printf("You must choose sign or seal, not both\n");
+ exit(1);
+ }
+ sec_options = RPC_C_AUTHN_LEVEL_PKT_PRIVACY;
+ } else {
+ printf("Bad security option '%s'\n", option);
+ exit(1);
+ }
+ argv++;
+ argc--;
+ continue;
+ default:
+ printf("Bad option -%c\n", argv[0][0]);
+ exit(1);
+ }
+ argv += 2;
+ argc -= 2;
+ }
+
+ if (argc < 2) {
+ printf("Usage: client [options] hostname cmd [args]\n\n");
+ printf("Where hostname is the name of the host to connect to,\n");
+ printf("and cmd is the command to execute with optional args:\n\n");
+ printf("\taddone num\tAdd one to num and return the result\n");
+ printf("\techodata size\tSend an array of size bytes and receive it back\n");
+ printf("\tsinkdata size\tSend an array of size bytes\n");
+ printf("\tsourcedata size\tReceive an array of size bytes\n");
+ printf("\ttest\trun testcall\n");
+ printf("\noptions:\n");
+ printf("\t-u username -d domain -p password -e endpoint\n");
+ printf("\t--sign --seal\n");
+ printf("\nExamples:\n");
+ printf("\tclient HOSTNAME addone 3\n");
+ printf("\tclient 192.168.115.1 addone 3\n");
+ printf("\tclient -e ncacn_np:HOSTNAME[\\\\pipe\\\\rpcecho] addone 3\n");
+ printf("\tclient -e ncacn_ip_tcp:192.168.115.1 addone 3\n");
+ printf("\tclient -e ncacn_ip_tcp:192.168.115.1 -u tridge -d MYDOMAIN -p PASSWORD addone 3\n");
+ exit(0);
+ }
+
+
+ if (!binding) {
+ char *network_address = argv[0];
+
+ argc--;
+ argv++;
+
+ status = RpcStringBindingCompose(
+ NULL, /* uuid */
+ "ncacn_np",
+ network_address,
+ "\\pipe\\rpcecho",
+ NULL, /* options */
+ &binding);
+
+ if (status) {
+ printf("RpcStringBindingCompose returned %d\n", status);
+ exit(status);
+ }
+ }
+
+ printf("Endpoint is %s\n", binding);
+
+ status = RpcBindingFromStringBinding(
+ binding,
+ &rpcecho_IfHandle);
+
+ if (status) {
+ printf("RpcBindingFromStringBinding returned %d\n", status);
+ exit(status);
+ }
+
+ if (username) {
+ SEC_WINNT_AUTH_IDENTITY ident = { username, strlen(username),
+ domain, strlen(domain),
+ password, strlen(password),
+ SEC_WINNT_AUTH_IDENTITY_ANSI };
+
+ status = RpcBindingSetAuthInfo(rpcecho_IfHandle, NULL,
+ sec_options,
+ RPC_C_AUTHN_WINNT,
+ &ident, 0);
+ if (status) {
+ printf ("RpcBindingSetAuthInfo failed: 0x%x\n", status);
+ exit (1);
+ }
+ }
+
+
+ while (argc > 0) {
+ RpcTryExcept {
+
+ /* Add one to a number */
+
+ if (strcmp(argv[0], "addone") == 0) {
+ int arg, result;
+
+ if (argc < 2) {
+ printf("Usage: addone num\n");
+ exit(1);
+ }
+
+ arg = atoi(argv[1]);
+
+ AddOne(arg, &result);
+ printf("%d + 1 = %d\n", arg, result);
+
+ argc -= 2;
+ argv += 2;
+ continue;
+ }
+
+ /* Echo an array */
+
+ if (strcmp(argv[0], "echodata") == 0) {
+ int arg, i;
+ char *indata, *outdata;
+
+ if (argc < 2) {
+ printf("Usage: echo num\n");
+ exit(1);
+ }
+
+ arg = atoi(argv[1]);
+
+ if ((indata = malloc(arg)) == NULL) {
+ printf("Error allocating %d bytes for input\n", arg);
+ exit(1);
+ }
+
+ if ((outdata = malloc(arg)) == NULL) {
+ printf("Error allocating %d bytes for output\n", arg);
+ exit(1);
+ }
+
+ for (i = 0; i < arg; i++)
+ indata[i] = i & 0xff;
+
+ EchoData(arg, indata, outdata);
+
+ printf("echo %d\n", arg);
+
+ for (i = 0; i < arg; i++) {
+ if (indata[i] != outdata[i]) {
+ printf("data mismatch at offset %d, %d != %d\n",
+ i, indata[i], outdata[i]);
+ exit(0);
+ }
+ }
+
+ argc -= 2;
+ argv += 2;
+ continue;
+ }
+
+ if (strcmp(argv[0], "sinkdata") == 0) {
+ int arg, i;
+ char *indata;
+
+ if (argc < 2) {
+ printf("Usage: sinkdata num\n");
+ exit(1);
+ }
+
+ arg = atoi(argv[1]);
+
+ if ((indata = malloc(arg)) == NULL) {
+ printf("Error allocating %d bytes for input\n", arg);
+ exit(1);
+ }
+
+ for (i = 0; i < arg; i++)
+ indata[i] = i & 0xff;
+
+ SinkData(arg, indata);
+
+ printf("sinkdata %d\n", arg);
+ argc -= 2;
+ argv += 2;
+ continue;
+ }
+
+ if (strcmp(argv[0], "sourcedata") == 0) {
+ int arg, i;
+ unsigned char *outdata;
+
+ if (argc < 2) {
+ printf("Usage: sourcedata num\n");
+ exit(1);
+ }
+
+ arg = atoi(argv[1]);
+
+ if ((outdata = malloc(arg)) == NULL) {
+ printf("Error allocating %d bytes for output\n", arg);
+ exit(1);
+ }
+
+ SourceData(arg, outdata);
+
+ printf("sourcedata %d\n", arg);
+
+ for (i = 0; i < arg; i++) {
+ if (outdata[i] != (i & 0xff)) {
+ printf("data mismatch at offset %d, %d != %d\n",
+ i, outdata[i], i & 0xff);
+ }
+ }
+
+ argc -= 2;
+ argv += 2;
+ continue;
+ }
+
+ if (strcmp(argv[0], "test") == 0) {
+ printf("no TestCall\n");
+
+ argc -= 1;
+ argv += 1;
+ continue;
+ }
+
+
+ if (strcmp(argv[0], "enum") == 0) {
+ enum echo_Enum1 v = ECHO_ENUM1;
+ echo_Enum2 e2;
+ echo_Enum3 e3;
+
+ e2.e1 = 76;
+ e2.e2 = ECHO_ENUM1_32;
+ e3.e1 = ECHO_ENUM2;
+
+ argc -= 1;
+ argv += 1;
+
+ echo_TestEnum(&v, &e2, &e3);
+
+ continue;
+ }
+
+ if (strcmp(argv[0], "double") == 0) {
+ typedef unsigned short uint16;
+ uint16 v = 13;
+ uint16 *pv = &v;
+ uint16 **ppv = &pv;
+ uint16 ret;
+
+ argc -= 1;
+ argv += 1;
+
+ ret = echo_TestDoublePointer(&ppv);
+
+ printf("TestDoublePointer v=%d ret=%d\n", v, ret);
+
+ continue;
+ }
+
+ if (strcmp(argv[0], "sleep") == 0) {
+ long arg, result;
+
+ if (argc < 2) {
+ printf("Usage: sleep num\n");
+ exit(1);
+ }
+
+ arg = atoi(argv[1]);
+
+// result = TestSleep(arg);
+// printf("Slept for %d seconds\n", result);
+ printf("Sleep disabled (need async code)\n");
+
+ argc -= 2;
+ argv += 2;
+ continue;
+ }
+
+ printf("Invalid command '%s'\n", argv[0]);
+ goto done;
+
+ } RpcExcept(1) {
+ unsigned long ex;
+
+ ex = RpcExceptionCode();
+ printf("Runtime error 0x%x\n", ex);
+ } RpcEndExcept
+ }
+
+done:
+
+ status = RpcStringFree(&binding);
+
+ if (status) {
+ printf("RpcStringFree returned %d\n", status);
+ exit(status);
+ }
+
+ status = RpcBindingFree(&rpcecho_IfHandle);
+
+ if (status) {
+ printf("RpcBindingFree returned %d\n", status);
+ exit(status);
+ }
+
+ exit(0);
+}
diff --git a/testprogs/win32/rpcecho/rpcecho.acf b/testprogs/win32/rpcecho/rpcecho.acf
new file mode 100644
index 0000000..56c7d33
--- /dev/null
+++ b/testprogs/win32/rpcecho/rpcecho.acf
@@ -0,0 +1,26 @@
+/*
+ RPC echo ACF.
+
+ Copyright (C) Tim Potter 2003
+
+ 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
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+[
+ implicit_handle (handle_t rpcecho_IfHandle)
+]
+interface rpcecho
+{
+/* [async] TestSleep(); */
+}
diff --git a/testprogs/win32/rpcecho/rpcecho.idl b/testprogs/win32/rpcecho/rpcecho.idl
new file mode 100644
index 0000000..b0ddb81
--- /dev/null
+++ b/testprogs/win32/rpcecho/rpcecho.idl
@@ -0,0 +1,146 @@
+/*
+ RPC echo IDL.
+
+ Copyright (C) Tim Potter 2003
+
+ 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
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#ifndef __PIDL__
+#define unistr [string] wchar_t *
+#endif
+
+[
+uuid(60a15ec5-4de8-11d7-a637-005056a20182),
+version(1.0)
+]
+interface rpcecho
+{
+ // Add one to an integer
+ void AddOne(
+ [in] int in_data,
+ [out] int *out_data
+ );
+ // Echo an array of bytes back at the caller
+ void EchoData(
+ [in] int len,
+ [in] [size_is(len)] char in_data[],
+ [out] [size_is(len)] char out_data[]
+ );
+ // Sink data to the server
+ void SinkData(
+ [in] int len,
+ [in] [size_is(len)] char in_data[]
+ );
+ // Source data from server
+ void SourceData(
+ [in] int len,
+ [out] [size_is(len)] char out_data[]
+ );
+ const long myconstant = 42;
+
+ /* test strings */
+ void TestCall (
+ [in] unistr *s1,
+ [out] unistr *s2
+ );
+
+ /* test some alignment issues */
+ typedef struct {
+ char v;
+ } echo_info1;
+
+ typedef struct {
+ short v;
+ } echo_info2;
+
+ typedef struct {
+ long v;
+ } echo_info3;
+
+ typedef struct {
+ hyper v;
+ } echo_info4;
+
+ typedef struct {
+ char v1;
+ hyper v2;
+ } echo_info5;
+
+ typedef struct {
+ char v1;
+ echo_info1 info1;
+ } echo_info6;
+
+ typedef struct {
+ char v1;
+ echo_info4 info4;
+ } echo_info7;
+
+ typedef union {
+ [case(1)] echo_info1 info1;
+ [case(2)] echo_info2 info2;
+ [case(3)] echo_info3 info3;
+ [case(4)] echo_info4 info4;
+ [case(5)] echo_info5 info5;
+ [case(6)] echo_info6 info6;
+ [case(7)] echo_info7 info7;
+ } echo_Info;
+
+ long TestCall2 (
+ [in] short level,
+ [out,switch_is(level)] echo_Info **info
+ );
+
+ long TestSleep(
+ [in] long seconds
+ );
+
+ typedef enum {
+ ECHO_ENUM1 = 1,
+ ECHO_ENUM2 = 2
+ } echo_Enum1;
+
+ typedef [v1_enum] enum {
+ ECHO_ENUM1_32 = 1,
+ ECHO_ENUM2_32 = 2
+ } echo_Enum1_32;
+
+ typedef struct {
+ echo_Enum1 e1;
+ echo_Enum1_32 e2;
+ } echo_Enum2;
+
+ typedef union {
+ [case(ECHO_ENUM1)] echo_Enum1 e1;
+ [case(ECHO_ENUM2)] echo_Enum2 e2;
+ } echo_Enum3;
+
+ void echo_TestEnum(
+ [in,out,ref] echo_Enum1 *foo1,
+ [in,out,ref] echo_Enum2 *foo2,
+ [in,out,ref,switch_is(*foo1)] echo_Enum3 *foo3
+ );
+
+ typedef struct {
+ long x;
+ [size_is(x)] short surrounding[*];
+ } echo_Surrounding;
+
+ void echo_TestSurrounding(
+ [in,out,ref] echo_Surrounding *data
+ );
+
+ short echo_TestDoublePointer([in] short ***data);
+}
diff --git a/testprogs/win32/rpcecho/server.c b/testprogs/win32/rpcecho/server.c
new file mode 100644
index 0000000..b092852
--- /dev/null
+++ b/testprogs/win32/rpcecho/server.c
@@ -0,0 +1,208 @@
+/*
+ RPC echo server.
+
+ Copyright (C) Tim Potter 2003
+
+ 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
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#define _WIN32_WINNT 0x0500
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <ctype.h>
+#include "rpcecho.h"
+
+#define RPC_MIN_CALLS 1
+#define RPC_MAX_CALLS 20
+#define RPC_ENDPOINT "\\pipe\\rpcecho"
+
+void AddOne(int in_data, __RPC_FAR int *out_data)
+{
+ printf("AddOne: got in_data = %d\n", in_data);
+ *out_data = in_data + 1;
+}
+
+void EchoData(int len, unsigned char __RPC_FAR in_data[],
+ unsigned char __RPC_FAR out_data[])
+{
+ printf("EchoData: got len = %d\n", len);
+
+ memcpy(out_data, in_data, len);
+}
+
+void SinkData(int len, unsigned char __RPC_FAR in_data[ ])
+{
+ printf("SinkData: got len = %d\n", len);
+}
+
+void SourceData(int len, unsigned char __RPC_FAR out_data[ ])
+{
+ int i;
+
+ printf("SourceData: got len = %d\n", len);
+
+ for (i = 0; i < len; i++)
+ out_data[i] = i & 0xff;
+}
+
+void TestCall(wchar_t **s1, wchar_t **s2)
+{
+ if (*s1) {
+ printf("s1='%S'\n", *s1);
+ } else {
+ printf("s1=NULL\n");
+ }
+ *s2 = L"test string";
+}
+
+long TestCall2(short level, echo_Info **info)
+{
+ static echo_Info i;
+
+ printf("TestCall2 level %d\n", level);
+
+ *info = &i;
+
+ switch (level) {
+ case 1:
+ i.info1.v = 10;
+ break;
+ case 2:
+ i.info2.v = 20;
+ break;
+ case 3:
+ i.info3.v = 30;
+ break;
+ case 4:
+ i.info4.v = 40;
+ break;
+ case 5:
+ i.info5.v1 = 50;
+ i.info5.v2 = 51;
+ break;
+ case 6:
+ i.info6.v1 = 60;
+ i.info6.info1.v = 61;
+ break;
+ case 7:
+ i.info7.v1 = 70;
+ i.info7.info4.v = 71;
+ break;
+ default:
+ return -1;
+ }
+ return 0;
+}
+
+#if 0
+void TestSleep(PRPC_ASYNC_STATE pAsync, long seconds)
+{
+ long ret;
+ printf("async Sleeping for %d seconds\n", seconds);
+ Sleep(1000 * seconds);
+ ret = seconds;
+ RpcAsyncCompleteCall(pAsync, &ret);
+}
+#else
+long TestSleep(long seconds)
+{
+ printf("non-async Sleeping for %d seconds\n", seconds);
+ Sleep(1000 * seconds);
+ return seconds;
+}
+#endif
+
+
+void echo_TestEnum(echo_Enum1 *foo1,
+ echo_Enum2 *foo2,
+ echo_Enum3 *foo3)
+{
+ foo2->e1 = ECHO_ENUM2;
+}
+
+void echo_TestSurrounding(echo_Surrounding *data)
+{
+ printf("Incoming array of size %d\n", data->x);
+ data->x *= 2;
+}
+
+short echo_TestDoublePointer(short ***data)
+{
+ if (!*data) {
+ printf("WARNING: *data == NULL\n");
+ return 0;
+ }
+ if (!**data) {
+ printf("WARNING: **data == NULL\n");
+ return 0;
+ }
+ printf("Incoming double pointer: %d\n", ***data);
+ return ***data;
+}
+
+void main(int argc, char **argv)
+{
+ RPC_STATUS status;
+ RPC_BINDING_VECTOR *pBindingVector;
+
+ if (argc != 1) {
+ printf("Usage: rpcechosrv\n");
+ exit(0);
+ }
+
+ status = RpcServerUseProtseqEp("ncacn_np", RPC_MAX_CALLS, "\\pipe\\rpcecho", NULL);
+ if (status) {
+ printf("Failed to register ncacn_np endpoint\n");
+ exit(status);
+ }
+
+ status = RpcServerUseProtseqEp("ncacn_ip_tcp", RPC_MAX_CALLS, "1234", NULL);
+ if (status) {
+ printf("Failed to register ncacn_ip_tcp endpoint\n");
+ exit(status);
+ }
+
+ status = RpcServerInqBindings(&pBindingVector);
+ if (status) {
+ printf("Failed RpcServerInqBindings\n");
+ exit(status);
+ }
+
+ status = RpcEpRegister(rpcecho_v1_0_s_ifspec, pBindingVector, NULL, "rpcecho server");
+ if (status) {
+ printf("Failed RpcEpRegister\n");
+ exit(status);
+ }
+
+ status = RpcServerRegisterIf(rpcecho_v1_0_s_ifspec, NULL, NULL);
+
+ if (status) {
+ printf("Failed to register interface\n");
+ exit(status);
+ }
+
+ status = RpcServerRegisterAuthInfo(NULL, RPC_C_AUTHN_GSS_NEGOTIATE, NULL, NULL);
+ if (status) {
+ printf("Failed to setup auth info\n");
+ }
+
+ status = RpcServerListen(RPC_MIN_CALLS, RPC_MAX_CALLS, FALSE);
+
+ if (status) {
+ printf("RpcServerListen returned error %d\n", status);
+ exit(status);
+ }
+}
+
diff --git a/testprogs/win32/rpcecho/utils.c b/testprogs/win32/rpcecho/utils.c
new file mode 100644
index 0000000..09a81d1
--- /dev/null
+++ b/testprogs/win32/rpcecho/utils.c
@@ -0,0 +1,32 @@
+/*
+ RPC echo utility functions.
+
+ Copyright (C) Tim Potter 2003
+
+ 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
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#include "rpcecho.h"
+
+/* MIDL allocate and free functions */
+
+void __RPC_FAR *__RPC_USER midl_user_allocate(size_t len)
+{
+ return(malloc(len));
+}
+
+void __RPC_USER midl_user_free(void __RPC_FAR *ptr)
+{
+ free(ptr);
+}
diff --git a/testprogs/win32/spoolss/GNUmakefile b/testprogs/win32/spoolss/GNUmakefile
new file mode 100644
index 0000000..0321a65
--- /dev/null
+++ b/testprogs/win32/spoolss/GNUmakefile
@@ -0,0 +1,23 @@
+CFLAGS=-I../../../
+MINGW_CC = i586-mingw32msvc-cc
+CC = $(MINGW_CC)
+
+LIBS=-lwinspool
+
+all: testspoolss.exe
+
+clean:
+ rm -vf *.exe tags
+
+ctags:
+ ctags `find . -name "*.[ch]" | grep -v include/proto.h`
+ ctags --c-kinds=-p -a `find /usr/i686-pc-mingw32/sys-root/mingw/include -name "*.[ch]" | grep -v /CVS/`
+
+proto:
+ mkproto.pl printlib.c --private=printlib_proto.h --public=printlib_proto_pub.h --srcdir=. --builddir=.
+ mkproto.pl torture.c --private=torture_proto.h --public=torture_proto_pub.h --srcdir=. --builddir=.
+
+testspoolss.exe: testspoolss.c printlib.c torture.c error.c
+ @echo Compiling testspoolss.exe
+ @$(CC) $(CFLAGS) $(LDFLAGS) testspoolss.c printlib.c torture.c error.c $(LIBS) -o testspoolss.exe
+
diff --git a/testprogs/win32/spoolss/NMakefile b/testprogs/win32/spoolss/NMakefile
new file mode 100644
index 0000000..949104e
--- /dev/null
+++ b/testprogs/win32/spoolss/NMakefile
@@ -0,0 +1,43 @@
+#
+# use nmake /f NMakefile [<target>]
+#
+CFLAGS = /nologo /Zi /MT /Gm- /W4 /FR /D_CRT_SECURE_NO_WARNINGS
+LIBS = kernel32.lib gdi32.lib user32.lib shell32.lib \
+ advapi32.lib ole32.lib ws2_32.lib rpcrt4.lib
+WINSPOOL_LIBS = winspool.lib
+
+all: testspoolss.exe
+
+.cpp.obj:
+ cl /c $(CFLAGS) $*.cpp
+
+.c.obj:
+ cl /c $(CFLAGS) $*.c
+
+clean: cleantmp
+ -del *.dll 2>nul
+
+cleantmp:
+ -del *~ *.o *.obj *.sbr *.bsc *.pdb *.lib *.ilk *.exp 2>nul
+ -del test_s.c test_c.c test.h 2>nul
+
+###############################
+# helpers
+###############################
+
+printlib.obj: printlib.c
+
+error.obj: error.c
+
+torture.obj: torture.c
+
+###############################
+# binaries
+###############################
+
+testspoolss.obj: testspoolss.c
+
+testspoolss.exe: testspoolss.obj printlib.obj error.obj torture.obj
+ cl $(CFLAGS) /Fe$@ testspoolss.obj printlib.obj error.obj torture.obj \
+ /link /incremental:no /subsystem:console $(LIBS) $(WINSPOOL_LIBS)
+
diff --git a/testprogs/win32/spoolss/README.win32 b/testprogs/win32/spoolss/README.win32
new file mode 100644
index 0000000..f43a9c7
--- /dev/null
+++ b/testprogs/win32/spoolss/README.win32
@@ -0,0 +1,65 @@
+
+This directory holds sources for a Win32 test utility to test the "spoolss"
+(print spool subsystem) functions of either a Windows or a Samba server. The
+sources are known to build with (free as in beer) Microsoft Visual C++ 2008
+Express Edition's "nmake.exe" on Windows XP Professional.
+
+
+How to build
+------------
+
+Use the Microsoft "nmake" command to build the *.exe. This command is in your
+%path% if you start the "Visual Studio 2008 Command Prompt" from your Start
+menu.
+
+Currently the real build target is named "testspoolss.exe". Run
+
+ nmake /f Makefile
+
+to build the testspoolss.exe. After a successful build you may want to clean up
+temporary files:
+
+ nmake /f Makefile cleantmp
+
+
+How to use
+----------
+
+Running testspoolss.exe with no additional params displays a short usage info.
+
+..............................................................................
+usage: testspoolss.exe <name> [print] [samba3] [architecture=ARCHITECTURE]
+
+ <name> can be a server or printer name URI
+ [print] will print all data that has been retrieved
+ from the printserver
+ [samba3] will skip some tests samba servers are known
+ not to have implemented
+ [architecture=X] allows one to define a specific
+ architecture to test with. choose between:
+ "Windows NT x86" or "Windows x64"
+..............................................................................
+
+The utility may be most useful if you use the "print" parameter to output all
+data received from the print server. You may re-direct the data into log files
+for later evaluation like this:
+
+ testspoolss.exe \\smbserver print samba3 1>smbserver.log 2>smbserver.err
+ testspoolss.exe \\smbserver print 1>smbserver.log 2>smbserver.err
+ testspoolss.exe \\winserver print 1>winserver.log 2>winserver.err
+
+One interesting source of learning could be to compare the output for (maybe
+"the same") printers/drivers as installed on a Windows and on a Samba print
+server:
+
+ testspoolss.exe \\winserver\printername print 1>winprinter.log 2>winprinter.err
+ testspoolss.exe \\smbserver\printername print 1>smbprinter.log 2>smbprinter.err
+
+and then compare the respective log files with a diff utility of your choice.
+To install "the same" printer/driver on a Samba server as on a Windows server,
+you can use the Samba "net" utility, which has the following syntax:
+
+ net rpc printer MIGRATE PRINTERS printername \
+ --server=winserver \
+ --destination=smbserver \
+ -UAdministrator%secretpassword
diff --git a/testprogs/win32/spoolss/error.c b/testprogs/win32/spoolss/error.c
new file mode 100644
index 0000000..3f96594
--- /dev/null
+++ b/testprogs/win32/spoolss/error.c
@@ -0,0 +1,137 @@
+/*
+ Unix SMB/CIFS implementation.
+ test suite for spoolss rpc operations
+
+ Copyright (C) Guenther Deschner 2009
+
+ 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
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#include "testspoolss.h"
+
+const char *errstr(DWORD error)
+{
+ static char tmp[20];
+
+ switch (error) {
+ case ERROR_FILE_NOT_FOUND:
+ return "ERROR_FILE_NOT_FOUND";
+ case ERROR_ACCESS_DENIED:
+ return "ERROR_ACCESS_DENIED";
+ case ERROR_INVALID_PARAMETER:
+ return "ERROR_INVALID_PARAMETER";
+ case ERROR_INVALID_HANDLE:
+ return "ERROR_INVALID_HANDLE";
+ case ERROR_CALL_NOT_IMPLEMENTED:
+ return "ERROR_CALL_NOT_IMPLEMENTED";
+ case ERROR_INSUFFICIENT_BUFFER:
+ return "ERROR_INSUFFICIENT_BUFFER";
+ case ERROR_INVALID_NAME:
+ return "ERROR_INVALID_NAME";
+ case ERROR_INVALID_LEVEL:
+ return "ERROR_INVALID_LEVEL";
+ case ERROR_INVALID_DATA:
+ return "ERROR_INVALID_DATA";
+ case ERROR_MORE_DATA:
+ return "ERROR_MORE_DATA";
+ case ERROR_NO_MORE_ITEMS:
+ return "ERROR_NO_MORE_ITEMS";
+#ifdef ERROR_INVALID_DATATYPE
+ case ERROR_INVALID_DATATYPE:
+ return "ERROR_INVALID_DATATYPE";
+#endif
+ case ERROR_INVALID_ENVIRONMENT:
+ return "ERROR_INVALID_ENVIRONMENT";
+ case ERROR_INVALID_PRINTER_COMMAND:
+ return "ERROR_INVALID_PRINTER_COMMAND";
+ case ERROR_PRINTER_ALREADY_EXISTS:
+ return "ERROR_PRINTER_ALREADY_EXISTS";
+ case ERROR_INVALID_PRINTER_NAME:
+ return "ERROR_INVALID_PRINTER_NAME";
+ case ERROR_INVALID_PRIORITY:
+ return "ERROR_INVALID_PRIORITY";
+ case ERROR_INVALID_SEPARATOR_FILE:
+ return "ERROR_INVALID_SEPARATOR_FILE";
+ case ERROR_UNKNOWN_PRINTPROCESSOR:
+ return "ERROR_UNKNOWN_PRINTPROCESSOR";
+ case ERROR_UNKNOWN_PRINTER_DRIVER:
+ return "ERROR_UNKNOWN_PRINTER_DRIVER";
+ case ERROR_UNKNOWN_PORT:
+ return "ERROR_UNKNOWN_PORT";
+ case ERROR_PRINTER_DRIVER_ALREADY_INSTALLED:
+ return "ERROR_PRINTER_DRIVER_ALREADY_INSTALLED";
+ case ERROR_UNKNOWN_PRINT_MONITOR:
+ return "ERROR_UNKNOWN_PRINT_MONITOR";
+ case ERROR_PRINTER_DRIVER_IN_USE:
+ return "ERROR_PRINTER_DRIVER_IN_USE";
+ case ERROR_SPOOL_FILE_NOT_FOUND:
+ return "ERROR_SPOOL_FILE_NOT_FOUND";
+ case ERROR_SPL_NO_STARTDOC:
+ return "ERROR_SPL_NO_STARTDOC";
+ case ERROR_SPL_NO_ADDJOB:
+ return "ERROR_SPL_NO_ADDJOB";
+ case ERROR_PRINT_PROCESSOR_ALREADY_INSTALLED:
+ return "ERROR_PRINT_PROCESSOR_ALREADY_INSTALLED";
+ case ERROR_PRINT_MONITOR_ALREADY_INSTALLED:
+ return "ERROR_PRINT_MONITOR_ALREADY_INSTALLED";
+ case ERROR_INVALID_PRINT_MONITOR:
+ return "ERROR_INVALID_PRINT_MONITOR";
+ case ERROR_PRINT_MONITOR_IN_USE:
+ return "ERROR_PRINT_MONITOR_IN_USE";
+ case ERROR_PRINTER_HAS_JOBS_QUEUED:
+ return "ERROR_PRINTER_HAS_JOBS_QUEUED";
+ case ERROR_PRINTER_NOT_FOUND:
+ return "ERROR_PRINTER_NOT_FOUND";
+ case ERROR_PRINTER_DRIVER_WARNED:
+ return "ERROR_PRINTER_DRIVER_WARNED";
+ case ERROR_PRINTER_DRIVER_BLOCKED:
+ return "ERROR_PRINTER_DRIVER_BLOCKED";
+#ifdef ERROR_PRINTER_DRIVER_PACKAGE_IN_USE
+ case ERROR_PRINTER_DRIVER_PACKAGE_IN_USE:
+ return "ERROR_PRINTER_DRIVER_PACKAGE_IN_USE";
+#endif
+#ifdef ERROR_CORE_DRIVER_PACKAGE_NOT_FOUND
+ case ERROR_CORE_DRIVER_PACKAGE_NOT_FOUND:
+ return "ERROR_CORE_DRIVER_PACKAGE_NOT_FOUND";
+#endif
+#ifdef ERROR_PRINTER_DRIVER_DOWNLOAD_NEEDED
+ case ERROR_PRINTER_DRIVER_DOWNLOAD_NEEDED:
+ return "ERROR_PRINTER_DRIVER_DOWNLOAD_NEEDED";
+#endif
+#ifdef ERROR_PRINT_JOB_RESTART_REQUIRED
+ case ERROR_PRINT_JOB_RESTART_REQUIRED:
+ return "ERROR_PRINT_JOB_RESTART_REQUIRED";
+#endif
+ case ERROR_CANCELLED:
+ return "ERROR_CANCELLED";
+ case ERROR_NOACCESS:
+ return "ERROR_NOACCESS";
+ case RPC_X_NULL_REF_POINTER:
+ return "RPC_X_NULL_REF_POINTER";
+ case RPC_S_PROCNUM_OUT_OF_RANGE:
+ return "RPC_S_PROCNUM_OUT_OF_RANGE";
+ case RPC_S_SERVER_UNAVAILABLE:
+ return "RPC_S_SERVER_UNAVAILABLE";
+ case RPC_S_INVALID_NET_ADDR:
+ return "RPC_S_INVALID_NET_ADDR";
+ case RPC_S_CALL_FAILED:
+ return "RPC_S_CALL_FAILED";
+ default:
+ break;
+ }
+
+ sprintf(tmp, "0x%08x", error);
+
+ return tmp;
+}
diff --git a/testprogs/win32/spoolss/error.h b/testprogs/win32/spoolss/error.h
new file mode 100644
index 0000000..581c109
--- /dev/null
+++ b/testprogs/win32/spoolss/error.h
@@ -0,0 +1,36 @@
+/*
+ Unix SMB/CIFS implementation.
+ test suite for spoolss rpc operations
+
+ Copyright (C) Guenther Deschner 2009
+
+ 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
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#ifndef ERROR_INVALID_PARAMETER
+#define ERROR_INVALID_PARAMETER 87
+#endif
+
+#ifndef ERROR_INSUFFICIENT_BUFFER
+#define ERROR_INSUFFICIENT_BUFFER 0x007a
+#endif
+
+#if 0
+#ifdef STATUS_PENDING
+#undef STATUS_PENDING
+#define STATUS_PENDING 0x0103
+#endif
+#endif
+
+const char *errstr(DWORD error);
diff --git a/testprogs/win32/spoolss/printlib.c b/testprogs/win32/spoolss/printlib.c
new file mode 100644
index 0000000..1dd1277
--- /dev/null
+++ b/testprogs/win32/spoolss/printlib.c
@@ -0,0 +1,1386 @@
+/*
+ Unix SMB/CIFS implementation.
+ test suite for spoolss rpc operations
+
+ Copyright (C) Gerald (Jerry) Carter 2007
+ Copyright (C) Guenther Deschner 2009-2010
+
+ 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
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#include <windows.h>
+#include <stdio.h>
+#include <assert.h>
+#include <sddl.h>
+
+#ifndef MIN
+#define MIN(a,b) ((a)<(b)?(a):(b))
+#endif
+
+void print_devmode(DEVMODE *pDevModeIn)
+{
+ if (pDevModeIn == NULL) {
+ printf("\tDevice Mode\t= (null)\n");
+ return;
+ }
+
+ printf("\tDEVMODE:----------\n");
+ printf("\tDeviceName: [%s]\n", pDevModeIn->dmDeviceName);
+ printf("\tSpecVersion: %d\n", pDevModeIn->dmSpecVersion);
+ printf("\tDriverVersion: %d\n", pDevModeIn->dmDriverVersion);
+ printf("\tSize: %d\n", pDevModeIn->dmSize);
+ printf("\tDriverExtra: %d\n", pDevModeIn->dmDriverExtra);
+ printf("\tFields: 0x%x\n", pDevModeIn->dmFields);
+
+ if (pDevModeIn->dmFields & DM_ORIENTATION)
+ printf("\tOrientation: %d\n", pDevModeIn->dmOrientation);
+ if (pDevModeIn->dmFields & DM_PAPERSIZE)
+ printf("\tPaperSize: %d\n", pDevModeIn->dmPaperSize);
+ if (pDevModeIn->dmFields & DM_PAPERLENGTH)
+ printf("\tPaperLength: %d\n", pDevModeIn->dmPaperLength);
+ if (pDevModeIn->dmFields & DM_PAPERWIDTH)
+ printf("\tPaperWidth: %d\n", pDevModeIn->dmPaperWidth);
+// if (pDevModeIn->dmFields & DM_POSITION)
+// printf("\tPosition: %d\n", pDevModeIn->dmPosition);
+ if (pDevModeIn->dmFields & DM_SCALE)
+ printf("\tScale: %d\n", pDevModeIn->dmScale);
+ if (pDevModeIn->dmFields & DM_COPIES)
+ printf("\tCopies: %d\n", pDevModeIn->dmCopies );
+ if (pDevModeIn->dmFields & DM_DEFAULTSOURCE)
+ printf("\tDefaultSource: %d\n", pDevModeIn->dmDefaultSource);
+ if (pDevModeIn->dmFields & DM_PRINTQUALITY)
+ printf("\tPrintQuality: %d\n", pDevModeIn->dmPrintQuality);
+ if (pDevModeIn->dmFields & DM_COLOR)
+ printf("\tColor: %d\n", pDevModeIn->dmColor);
+ if (pDevModeIn->dmFields & DM_DUPLEX)
+ printf("\tDuplex: %d\n", pDevModeIn->dmDuplex);
+ if (pDevModeIn->dmFields & DM_YRESOLUTION)
+ printf("\tYResolution: %d\n", pDevModeIn->dmYResolution);
+ if (pDevModeIn->dmFields & DM_TTOPTION)
+ printf("\tTTOption: %d\n", pDevModeIn->dmTTOption);
+ if (pDevModeIn->dmFields & DM_COLLATE)
+ printf("\tCollate: %d\n", pDevModeIn->dmCollate);
+ if (pDevModeIn->dmFields & DM_FORMNAME)
+ printf("\tForm: [%s]\n", pDevModeIn->dmFormName);
+ if (pDevModeIn->dmFields & DM_LOGPIXELS)
+ printf("\tLogPixels: %d\n", pDevModeIn->dmLogPixels);
+ if (pDevModeIn->dmFields & DM_BITSPERPEL)
+ printf("\tBitsPerPel: %d\n", pDevModeIn->dmBitsPerPel);
+ if (pDevModeIn->dmFields & DM_PELSWIDTH)
+ printf("\tPelsWidth: %d\n", pDevModeIn->dmPelsWidth);
+ if (pDevModeIn->dmFields & DM_PELSHEIGHT)
+ printf("\tPelsHeight: %d\n", pDevModeIn->dmPelsHeight);
+ if (pDevModeIn->dmFields & DM_DISPLAYFLAGS)
+ printf("\tDisplayFlags: %d\n", pDevModeIn->dmDisplayFlags);
+// if (pDevModeIn->dmFields & DM_NUP)
+// printf("\tNup: %d\n", pDevModeIn->dmNup);
+ if (pDevModeIn->dmFields & DM_DISPLAYFREQUENCY)
+ printf("\tDisplayFrequency:%d\n", pDevModeIn->dmDisplayFrequency);
+ if (pDevModeIn->dmFields & DM_ICMMETHOD)
+ printf("\tICMMethod: %d\n", pDevModeIn->dmICMMethod);
+ if (pDevModeIn->dmFields & DM_ICMINTENT)
+ printf("\tICMIntent: %d\n", pDevModeIn->dmICMIntent);
+ if (pDevModeIn->dmFields & DM_MEDIATYPE)
+ printf("\tMediaType: %d\n", pDevModeIn->dmMediaType);
+ if (pDevModeIn->dmFields & DM_DITHERTYPE)
+ printf("\tDitherType: %d\n", pDevModeIn->dmDitherType);
+// if (pDevModeIn->dmFields & DM_PANNINGWIDTH)
+// printf("\tPanningWidth: %d\n", pDevModeIn->dmPanningWidth);
+// if (pDevModeIn->dmFields & DM_PANNINGHEIGHT)
+// printf("\tPanningHeight: %d\n", pDevModeIn->dmPanningHeight);
+
+#if 0
+ if (bForceIn) {
+ printf("DEVMODE\n");
+ Dump((BYTE*)pDevModeIn, sizeof(DEVMODE), LEADER);
+
+ if (pDevModeIn->dmDriverExtra) {
+ printf("DriverExtra\n");
+ Dump((BYTE*)pDevModeIn + sizeof(DEVMODE), pDevModeIn->dmDriverExtra, LEADER);
+ }
+ }
+#endif
+
+ return;
+}
+
+void print_acl(const char* str, ACL *acl)
+{
+ printf("%s\n", str);
+ if (acl == NULL)
+ return;
+
+ printf("\t\tACL Revision \t\t 0x%x\n", acl->AclRevision);
+ printf("\t\tSbz1\t\t 0x%x\n", acl->Sbz1);
+ printf("\t\tSbz2\t\t 0x%x\n", acl->Sbz2);
+ printf("\t\tACL Size\t\t 0x%x\n", acl->AclSize);
+ printf("\t\tACL Count\t\t 0x%x\n", acl->AceCount);
+
+ return;
+}
+
+void PrintLastError();
+
+void print_sid(LPSTR str, PSID sid)
+{
+ LPSTR sid_string;
+
+ printf("%s\n", str);
+
+ if (sid == NULL) {
+ printf("(null sid)\n");
+ return;
+ }
+
+ if (!ConvertSidToStringSid(sid, &sid_string)) {
+ PrintLastError();
+ return;
+ }
+
+ printf("%s\n", sid_string);
+ LocalFree(sid_string);
+
+ return;
+}
+
+void print_secdesc(SECURITY_DESCRIPTOR *secdesc)
+{
+ LPSTR sd_string;
+
+ if (secdesc == NULL) {
+ printf("\tSecurity Descriptor\t= (null)\n");
+ return;
+ }
+
+ if (!ConvertSecurityDescriptorToStringSecurityDescriptor(secdesc, 1, 7, &sd_string, NULL)) {
+ PrintLastError();
+ return;
+ }
+
+ printf("%s\n", sd_string);
+ LocalFree(sd_string);
+
+#if 0
+ printf("\tRevision\t= 0x%x\n", secdesc->Revision);
+ printf("\tSbz1\t\t= 0x%x\n", secdesc->Sbz1);
+ printf("\tControl\t\t= 0x%x\n", secdesc->Control);
+ print_sid("\tOwner\t\t= ", secdesc->Owner);
+ print_sid("\tGroup\t\t= ",secdesc->Group);
+ print_acl("\tSacl\t\t= ", secdesc->Sacl);
+ print_acl("\tDacl\t\t= ", secdesc->Dacl);
+#endif
+ return;
+}
+
+void PrintLastError()
+{
+ LPVOID lpMsgBuf;
+ DWORD status;
+
+ status = GetLastError();
+
+ FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
+ NULL, GetLastError(), MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
+ (LPTSTR)&lpMsgBuf, 0, NULL);
+ printf("ERROR [0x%x] : %s\n", status, (char*)lpMsgBuf);
+ LocalFree(lpMsgBuf);
+
+ return;
+}
+
+
+void print_job_info_1(PJOB_INFO_1 info)
+{
+ printf("\tJob ID\t\t= %d\n", info->JobId);
+ printf("\tPrinter Name\t= %s\n", info->pPrinterName);
+ printf("\tMachine Name\t= %s\n", info->pMachineName);
+ printf("\tUser Name\t= %s\n", info->pUserName);
+ printf("\tDocument\t= %s\n", info->pDocument);
+ printf("\tDatatype\t= %s\n", info->pDatatype);
+ printf("\tStatus\t\t= %s\n", info->pStatus);
+ printf("\tStatus\t= %d\n", info->Status);
+ printf("\tPriority\t= %d\n", info->Priority);
+ printf("\tPosition\t= %d\n", info->Position);
+ printf("\tTotal Pages\t= %d\n", info->TotalPages);
+ printf("\tPages Printed\t= %d\n", info->PagesPrinted);
+ printf("\tSubmitted (DD:MM:YY HH:MM:SS)\t= %d:%d:%d %d:%d:%d UTC\n",
+ info->Submitted.wDay, info->Submitted.wMonth,
+ info->Submitted.wYear, info->Submitted.wHour,
+ info->Submitted.wMinute, info->Submitted.wSecond);
+
+ return;
+}
+
+void print_job_info_2(PJOB_INFO_2 info)
+{
+ printf("\tJob ID\t\t= %d\n", info->JobId);
+ printf("\tPrinter Name\t= %s\n", info->pPrinterName);
+ printf("\tMachine Name\t= %s\n", info->pMachineName);
+ printf("\tUser Name\t= %s\n", info->pUserName);
+ printf("\tDocument\t= %s\n", info->pDocument);
+ printf("\tDatatype\t= %s\n", info->pDatatype);
+ printf("\tNotify Name\t= %s\n", info->pNotifyName);
+ printf("\tPrint Processor\t= %s\n", info->pPrintProcessor);
+ printf("\tParameters\t= %s\n", info->pParameters);
+ printf("\tDriver Name\t= %s\n", info->pDriverName);
+ printf("\tStatus\t\t= %s\n", info->pStatus);
+ printf("\tStatus\t\t= %d\n", info->Status);
+ printf("\tPriority\t= %d\n", info->Priority);
+ printf("\tPosition\t= %d\n", info->Position);
+ printf("\tTotal Pages\t= %d\n", info->TotalPages);
+ printf("\tPages Printed\t= %d\n", info->PagesPrinted);
+ printf("\tStart Time\t= %d\n", info->StartTime);
+ printf("\tUntil Time\t= %d\n", info->UntilTime);
+ printf("\tTime\t\t= %d\n", info->Time);
+ printf("\tSize\t\t= %d\n", info->Size);
+ printf("\tSubmitted (DD:MM:YY HH:MM:SS)\t= %d:%d:%d %d:%d:%d UTC\n",
+ info->Submitted.wDay, info->Submitted.wMonth,
+ info->Submitted.wYear, info->Submitted.wHour,
+ info->Submitted.wMinute, info->Submitted.wSecond);
+ printf("\tDevice Mode Information\n");
+ printf("\t-----------------------\n");
+ print_devmode(info->pDevMode);
+ printf("\tSecurity Descriptor Information\n");
+ printf("\t-------------------------------\n");
+ print_secdesc(info->pSecurityDescriptor);
+
+ return;
+}
+
+void print_job_info_3(PJOB_INFO_3 info)
+{
+ printf("\tJob ID\t\t= %d\n", info->JobId);
+ printf("\tJob ID Next Job\t= %d\n", info->NextJobId);
+ printf("\tReserved (must be 0)\t= %d\n",info->Reserved);
+
+ return;
+}
+
+void print_job_info_4(PJOB_INFO_4 info)
+{
+ printf("\tJob ID\t\t= %d\n", info->JobId);
+ printf("\tPrinter Name\t= %s\n", info->pPrinterName);
+ printf("\tMachine Name\t= %s\n", info->pMachineName);
+ printf("\tUser Name\t= %s\n", info->pUserName);
+ printf("\tDocument\t= %s\n", info->pDocument);
+ printf("\tDatatype\t= %s\n", info->pDatatype);
+ printf("\tNotify Name\t= %s\n", info->pNotifyName);
+ printf("\tPrint Processor\t= %s\n", info->pPrintProcessor);
+ printf("\tDriver Name\t= %s\n", info->pDriverName);
+ printf("\tStatus\t\t= %s\n", info->pStatus);
+ printf("\tStatus\t\t= %d\n", info->Status);
+ printf("\tPriority\t= %d\n", info->Priority);
+ printf("\tPosition\t= %d\n", info->Position);
+ printf("\tTotal Pages\t= %d\n", info->TotalPages);
+ printf("\tPages Printed\t= %d\n", info->PagesPrinted);
+ printf("\tStart Time\t= %d\n", info->StartTime);
+ printf("\tUntil Time\t= %d\n", info->UntilTime);
+ printf("\tTime\t\t= %d\n", info->Time);
+ printf("\tSize\t\t= %d\n", info->Size);
+ printf("\tSize High\t\t= 0x%016x\n", info->SizeHigh);
+ printf("\tSubmitted (DD:MM:YY HH:MM:SS)\t= %d:%d:%d %d:%d:%d UTC\n",
+ info->Submitted.wDay, info->Submitted.wMonth,
+ info->Submitted.wYear, info->Submitted.wHour,
+ info->Submitted.wMinute, info->Submitted.wSecond);
+ printf("\tDevice Mode Information\n");
+ printf("\t-----------------------\n");
+ print_devmode(info->pDevMode);
+ printf("\tSecurity Descriptor Information\n");
+ printf("\t-------------------------------\n");
+ print_secdesc(info->pSecurityDescriptor);
+
+ return;
+}
+
+void print_job_info_bylevel(DWORD level, LPBYTE buffer, DWORD count)
+{
+ DWORD i;
+ PJOB_INFO_1 buffer1 = NULL;
+ PJOB_INFO_2 buffer2 = NULL;
+ PJOB_INFO_3 buffer3 = NULL;
+ PJOB_INFO_4 buffer4 = NULL;
+
+ if (!buffer) {
+ return;
+ }
+
+ switch (level) {
+ case 1:
+ buffer1 = (PJOB_INFO_1)buffer;
+ break;
+ case 2:
+ buffer2 = (PJOB_INFO_2)buffer;
+ break;
+ case 3:
+ buffer3 = (PJOB_INFO_3)buffer;
+ break;
+ case 4:
+ buffer4 = (PJOB_INFO_4)buffer;
+ break;
+ default:
+ break;
+ }
+
+ printf("Job Info Level %d:\n", level);
+
+ switch (level) {
+ case 1:
+ for (i=0; i<count; i++) {
+ print_job_info_1(&buffer1[i]);
+ printf("\n");
+ }
+ break;
+ case 2:
+ for (i=0; i<count; i++) {
+ print_job_info_2(&buffer2[i]);
+ printf("\n");
+ }
+ break;
+ case 3:
+ for (i=0; i<count; i++) {
+ print_job_info_3(&buffer3[i]);
+ printf("\n");
+ }
+ break;
+ case 4:
+ for (i=0; i<count; i++) {
+ print_job_info_4(&buffer4[i]);
+ printf("\n");
+ }
+ break;
+ default:
+ break;
+ }
+}
+
+void print_monitor_info_1(PMONITOR_INFO_1 info)
+{
+ printf("\tMonitor Name\t= %s\n", info->pName);
+
+ return;
+}
+
+void print_monitor_info_2(PMONITOR_INFO_2 info)
+{
+ printf("\tMonitor Name\t= %s\n", info->pName);
+ printf("\tEnvironment\t= %s\n", info->pEnvironment);
+ printf("\tDLL Name\t= %s\n", info->pDLLName);
+
+ return;
+}
+
+void print_monitor_info_bylevel(DWORD level, LPBYTE buffer, DWORD count)
+{
+ DWORD i;
+ PMONITOR_INFO_1 buffer1 = NULL;
+ PMONITOR_INFO_2 buffer2 = NULL;
+
+ if (!buffer) {
+ return;
+ }
+
+ switch (level) {
+ case 1:
+ buffer1 = (PMONITOR_INFO_1)buffer;
+ break;
+ case 2:
+ buffer2 = (PMONITOR_INFO_2)buffer;
+ break;
+ default:
+ break;
+ }
+
+ printf("Monitor Info Level %d:\n", level);
+
+ switch (level) {
+ case 1:
+ for (i=0; i<count; i++) {
+ print_monitor_info_1(&buffer1[i]);
+ printf("\n");
+ }
+ break;
+ case 2:
+ for (i=0; i<count; i++) {
+ print_monitor_info_2(&buffer2[i]);
+ printf("\n");
+ }
+ break;
+ default:
+ break;
+ }
+}
+
+void print_port_info_1(PPORT_INFO_1 info)
+{
+ printf("\tPort Name\t= %s\n", info->pName);
+ return;
+}
+
+void print_port_info_2(PPORT_INFO_2 info)
+{
+ printf("\tPort Name\t= %s\n", info->pPortName);
+ printf("\tMonitor Name\t= %s\n",info->pMonitorName);
+ printf("\tDescription\t= %s\n", info->pDescription);
+ printf("\tPort Type\t= 0x%08x\n", info->fPortType);
+ printf("\tReserved\t= 0x%08x\n", info->Reserved);
+ return;
+}
+
+void print_port_info_3(PPORT_INFO_3 info)
+{
+ printf("\tStatus\t= 0x%08x\n", info->dwStatus);
+ printf("\tStatus String\t= %s\n", info->pszStatus);
+ printf("\tSeverity\t= 0x%08x\n", info->dwSeverity);
+ return;
+}
+
+void print_port_info_bylevel(DWORD level, LPBYTE buffer, DWORD count)
+{
+ DWORD i;
+ PPORT_INFO_1 buffer1 = NULL;
+ PPORT_INFO_2 buffer2 = NULL;
+ PPORT_INFO_3 buffer3 = NULL;
+
+ if (!buffer) {
+ return;
+ }
+
+ switch (level) {
+ case 1:
+ buffer1 = (PPORT_INFO_1)buffer;
+ break;
+ case 2:
+ buffer2 = (PPORT_INFO_2)buffer;
+ break;
+ case 3:
+ buffer3 = (PPORT_INFO_3)buffer;
+ break;
+ default:
+ break;
+ }
+
+ printf("Port Info Level %d:\n", level);
+
+ switch (level) {
+ case 1:
+ for (i=0; i<count; i++) {
+ print_port_info_1(&buffer1[i]);
+ printf("\n");
+ }
+ break;
+ case 2:
+ for (i=0; i<count; i++) {
+ print_port_info_2(&buffer2[i]);
+ printf("\n");
+ }
+ break;
+ case 3:
+ for (i=0; i<count; i++) {
+ print_port_info_3(&buffer3[i]);
+ printf("\n");
+ }
+ break;
+ default:
+ break;
+ }
+}
+
+void print_form_info_1(PFORM_INFO_1 info)
+{
+ printf("\tForm Name\t= %s\n", info->pName);
+ printf("\tFlags\t\t= 0x%x\n", info->Flags);
+ printf("\tSize\t\t= %d x %d\n", info->Size.cx, info->Size.cy);
+ printf("\tRectangle\t= [left]%d [right]%d [top]%d [bottom]%d\n",
+ info->ImageableArea.left, info->ImageableArea.right,
+ info->ImageableArea.top, info->ImageableArea.bottom);
+
+ return;
+}
+
+void print_form_info_2(PFORM_INFO_2 info)
+{
+ printf("\tForm Name\t= %s\n", info->pName);
+ printf("\tFlags\t\t= 0x%x\n", info->Flags);
+ printf("\tSize\t\t= %d x %d\n", info->Size.cx, info->Size.cy);
+ printf("\tRectangle\t= [left]%d [right]%d [top]%d [bottom]%d\n",
+ info->ImageableArea.left, info->ImageableArea.right,
+ info->ImageableArea.top, info->ImageableArea.bottom);
+ printf("\tKeyword\t= %s\n", info->pKeyword);
+ printf("\tString Type\t= 0x%08x\n", info->StringType);
+ printf("\tMui DLL\t= %s\n", info->pMuiDll);
+ printf("\tResource Id\t= 0x%08x\n", info->dwResourceId);
+ printf("\tDisplay Name\t= %s\n",info->pDisplayName);
+ printf("\tLang Id\t= 0x%04x\n", info->wLangId);
+
+ return;
+}
+
+void print_form_info_bylevel(DWORD level, LPBYTE buffer, DWORD count)
+{
+ DWORD i;
+ PFORM_INFO_1 buffer1 = NULL;
+ PFORM_INFO_2 buffer2 = NULL;
+
+ if (!buffer) {
+ return;
+ }
+
+ switch (level) {
+ case 1:
+ buffer1 = (PFORM_INFO_1)buffer;
+ break;
+ case 2:
+ buffer2 = (PFORM_INFO_2)buffer;
+ break;
+ default:
+ break;
+ }
+
+ printf("Form Info Level %d:\n", level);
+
+ switch (level) {
+ case 1:
+ for (i=0; i<count; i++) {
+ print_form_info_1(&buffer1[i]);
+ printf("\n");
+ }
+ break;
+ case 2:
+ for (i=0; i<count; i++) {
+ print_form_info_2(&buffer2[i]);
+ printf("\n");
+ }
+ break;
+ default:
+ break;
+ }
+}
+
+void print_printer_info_1(PPRINTER_INFO_1 info)
+{
+ printf("\tPrinter Name\t= %s\n", info->pName);
+ printf("\tDescription\t= %s\n", info->pDescription);
+ printf("\tComment\t\t= %s\n", info->pComment);
+ printf("\tFlags\t\t= 0x%x\n", info->Flags);
+
+ return;
+}
+
+void print_printer_info_2(PPRINTER_INFO_2 info)
+{
+ printf("\tServer Name\t\t= %s\n", info->pServerName);
+ printf("\tPrinter Name\t\t= %s\n", info->pPrinterName);
+ printf("\tPort Name\t\t= %s\n", info->pPortName);
+ printf("\tShare Name\t\t= %s\n", info->pShareName);
+ printf("\tDriver Name\t\t= %s\n", info->pDriverName);
+ printf("\tComment\t\t\t= %s\n", info->pComment);
+ printf("\tLocation\t\t= %s\n", info->pLocation);
+ printf("\tSeparator File\t\t= %s\n", info->pSepFile);
+ printf("\tDefault Data Type\t= %s\n", info->pDatatype);
+ printf("\tPrint Processor\t\t= %s\n", info->pPrintProcessor);
+ printf("\tParameters\t\t= %s\n", info->pParameters);
+ printf("\tAttributes\t\t= 0x%x\n", info->Attributes);
+ printf("\tPriority\t\t= 0x%x\n", info->Priority);
+ printf("\tDefault Priority\t= 0x%x\n", info->DefaultPriority);
+ printf("\tStart Time\t\t= 0x%x\n", info->StartTime);
+ printf("\tUntil Time\t\t= 0x%x\n", info->UntilTime);
+ printf("\tStatus\t\t\t= 0x%x\n", info->Status);
+ printf("\tcJobs\t\t\t= 0x%x\n", info->cJobs);
+ printf("\tAverage PPM\t\t= 0x%x\n", info->AveragePPM);
+
+ printf("\tDevice Mode Information\n");
+ printf("\t-----------------------\n");
+ print_devmode(info->pDevMode);
+ printf("\tSecurity Descriptor Information\n");
+ printf("\t-------------------------------\n");
+ print_secdesc(info->pSecurityDescriptor);
+ return;
+}
+
+void print_printer_info_3(PPRINTER_INFO_3 info)
+{
+ printf("\tSecurity Descriptor Information\n");
+ printf("\t-------------------------------\n");
+ print_secdesc(info->pSecurityDescriptor);
+ return;
+}
+
+void print_printer_info_4(PPRINTER_INFO_4 info)
+{
+ printf("\tServer Name\t\t= %s\n", info->pServerName);
+ printf("\tPrinter Name\t\t= %s\n", info->pPrinterName);
+ printf("\tAttributes\t\t= 0x%x\n", info->Attributes);
+ return;
+}
+
+void print_printer_info_5(PPRINTER_INFO_5 info)
+{
+ printf("\tPrinter Name\t\t\t= %s\n", info->pPrinterName);
+ printf("\tPort Name\t\t\t= %s\n", info->pPortName);
+ printf("\tAttributes\t\t\t= 0x%x\n", info->Attributes);
+ printf("\tDev NotSelect Timeout\t= 0x%x\n", info->DeviceNotSelectedTimeout);
+ printf("\tTX RetryTimeout\t\t= 0x%x\n", info->TransmissionRetryTimeout);
+ return;
+}
+
+void print_printer_info_6(PPRINTER_INFO_6 info)
+{
+ printf("\tStatus\t\t\t= 0x%x\n", info->dwStatus);
+ return;
+}
+
+void print_printer_info_7(PPRINTER_INFO_7 info)
+{
+ printf("\tObject GUID\t\t\t= %s\n", info->pszObjectGUID);
+ printf("\tAction\t\t\t= 0x%x\n", info->dwAction);
+ return;
+}
+
+void print_printer_info_8(PPRINTER_INFO_8 info)
+{
+ print_devmode(info->pDevMode);
+}
+
+void print_printer_info_9(PPRINTER_INFO_9 info)
+{
+ print_devmode(info->pDevMode);
+}
+
+void print_printer_info_bylevel(DWORD level, LPBYTE buffer, DWORD count)
+{
+ DWORD i;
+ PPRINTER_INFO_1 buffer1 = NULL;
+ PPRINTER_INFO_2 buffer2 = NULL;
+ PPRINTER_INFO_3 buffer3 = NULL;
+ PPRINTER_INFO_4 buffer4 = NULL;
+ PPRINTER_INFO_5 buffer5 = NULL;
+ PPRINTER_INFO_6 buffer6 = NULL;
+ PPRINTER_INFO_7 buffer7 = NULL;
+ PPRINTER_INFO_8 buffer8 = NULL;
+ PPRINTER_INFO_9 buffer9 = NULL;
+
+ if (!buffer) {
+ return;
+ }
+
+ switch (level) {
+ case 1:
+ buffer1 = (PPRINTER_INFO_1)buffer;
+ break;
+ case 2:
+ buffer2 = (PPRINTER_INFO_2)buffer;
+ break;
+ case 3:
+ buffer3 = (PPRINTER_INFO_3)buffer;
+ break;
+ case 4:
+ buffer4 = (PPRINTER_INFO_4)buffer;
+ break;
+ case 5:
+ buffer5 = (PPRINTER_INFO_5)buffer;
+ break;
+ case 6:
+ buffer6 = (PPRINTER_INFO_6)buffer;
+ break;
+ case 7:
+ buffer7 = (PPRINTER_INFO_7)buffer;
+ break;
+ case 8:
+ buffer8 = (PPRINTER_INFO_8)buffer;
+ break;
+ case 9:
+ buffer9 = (PPRINTER_INFO_9)buffer;
+ break;
+ default:
+ break;
+ }
+
+ printf("Printer Info Level %d:\n", level);
+
+ switch (level) {
+ case 1:
+ for (i=0; i<count; i++) {
+ print_printer_info_1(&buffer1[i]);
+ printf("\n");
+ }
+ break;
+ case 2:
+ for (i=0; i<count; i++) {
+ print_printer_info_2(&buffer2[i]);
+ printf("\n");
+ }
+ break;
+ case 3:
+ for (i=0; i<count; i++) {
+ print_printer_info_3(&buffer3[i]);
+ printf("\n");
+ }
+ break;
+ case 4:
+ for (i=0; i<count; i++) {
+ print_printer_info_4(&buffer4[i]);
+ printf("\n");
+ }
+ break;
+ case 5:
+ for (i=0; i<count; i++) {
+ print_printer_info_5(&buffer5[i]);
+ printf("\n");
+ }
+ break;
+ case 6:
+ for (i=0; i<count; i++) {
+ print_printer_info_6(&buffer6[i]);
+ printf("\n");
+ }
+ break;
+ case 7:
+ for (i=0; i<count; i++) {
+ print_printer_info_7(&buffer7[i]);
+ printf("\n");
+ }
+ break;
+ case 8:
+ for (i=0; i<count; i++) {
+ print_printer_info_8(&buffer8[i]);
+ printf("\n");
+ }
+ break;
+ case 9:
+ for (i=0; i<count; i++) {
+ print_printer_info_9(&buffer9[i]);
+ printf("\n");
+ }
+ break;
+ default:
+ break;
+ }
+}
+
+void print_printprocessor_info_1(PPRINTPROCESSOR_INFO_1 info)
+{
+ printf("\tPrint Processor Name\t= %s\n", info->pName);
+
+ return;
+}
+
+void print_printprocessor_info_bylevel(DWORD level, LPBYTE buffer, DWORD count)
+{
+ DWORD i;
+ PPRINTPROCESSOR_INFO_1 buffer1 = NULL;
+
+ if (!buffer) {
+ return;
+ }
+
+ switch (level) {
+ case 1:
+ buffer1 = (PPRINTPROCESSOR_INFO_1)buffer;
+ break;
+ default:
+ break;
+ }
+
+ printf("Print Processor Info Level %d:\n", level);
+
+ switch (level) {
+ case 1:
+ for (i=0; i<count; i++) {
+ print_printprocessor_info_1(&buffer1[i]);
+ printf("\n");
+ }
+ break;
+ default:
+ break;
+ }
+}
+
+void print_datatypes_info_1(PDATATYPES_INFO_1 info)
+{
+ printf("\tDataTypes Name\t= %s\n", info->pName);
+
+ return;
+}
+
+void print_datatypes_info_bylevel(DWORD level, LPBYTE buffer, DWORD count)
+{
+ DWORD i;
+ PDATATYPES_INFO_1 buffer1 = NULL;
+
+ if (!buffer) {
+ return;
+ }
+
+ switch (level) {
+ case 1:
+ buffer1 = (PDATATYPES_INFO_1)buffer;
+ break;
+ default:
+ break;
+ }
+
+ printf("DataTypes Info Level %d:\n", level);
+
+ switch (level) {
+ case 1:
+ for (i=0; i<count; i++) {
+ print_datatypes_info_1(&buffer1[i]);
+ printf("\n");
+ }
+ break;
+ default:
+ break;
+ }
+}
+
+void print_driver_info_1(PDRIVER_INFO_1 info)
+{
+ printf("\tDriver Name\t= %s\n\n", info->pName);
+
+ return;
+}
+
+void print_driver_info_2(PDRIVER_INFO_2 info)
+{
+ printf("\tDriver Name\t= %s\n", info->pName);
+ printf("\tEnvironment\t= %s\n", info->pEnvironment);
+ printf("\tVersion\t\t= %d\n", info->cVersion);
+ printf("\tDriver Path\t= %s\n", info->pDriverPath);
+ printf("\tData File\t= %s\n", info->pDataFile);
+ printf("\tConfig File\t= %s\n\n", info->pConfigFile);
+
+ return;
+}
+
+void print_driver_info_3(PDRIVER_INFO_3 info)
+{
+ char *ptr = NULL;
+
+ printf("\tDriver Name\t= %s\n", info->pName);
+ printf("\tEnvironment\t= %s\n", info->pEnvironment);
+ printf("\tVersion\t\t= %d\n", info->cVersion);
+ printf("\tDriver Path\t= %s\n", info->pDriverPath);
+ printf("\tData File\t= %s\n", info->pDataFile);
+ printf("\tConfig File\t= %s\n", info->pConfigFile);
+ printf("\tHelp Path\t= %s\n", info->pHelpFile);
+ printf("\tMonitor Name\t= %s\n", info->pMonitorName);
+ printf("\tData Type\t= %s\n", info->pDefaultDataType);
+ ptr = (char*)info->pDependentFiles;
+ while ((ptr != NULL) && (*ptr != '\0')) {
+ printf("\tDependent Files\t= %s\n", ptr);
+ for (;*ptr != '\0'; ptr++)
+ /* printf("%s\n", ptr); */
+ ;
+ ptr++;
+ }
+
+ return;
+}
+
+void print_driver_info_4(PDRIVER_INFO_4 info)
+{
+ char *ptr = NULL;
+
+ printf("\tDriver Name\t= %s\n", info->pName);
+ printf("\tEnvironment\t= %s\n", info->pEnvironment);
+ printf("\tVersion\t\t= %d\n", info->cVersion);
+ printf("\tDriver Path\t= %s\n", info->pDriverPath);
+ printf("\tData File\t= %s\n", info->pDataFile);
+ printf("\tConfig File\t= %s\n", info->pConfigFile);
+ printf("\tHelp Path\t= %s\n", info->pHelpFile);
+ printf("\tMonitor Name\t= %s\n", info->pMonitorName);
+ printf("\tData Type\t= %s\n", info->pDefaultDataType);
+ printf("\tPrevious Names\t= %s\n", info->pszzPreviousNames);
+ ptr = (char*)info->pDependentFiles;
+ while ((ptr != NULL) && (*ptr != '\0')) {
+ printf("\tDependent Files\t= %s\n", ptr);
+ for (;*ptr != '\0'; ptr++)
+ /* printf("%s\n", ptr); */
+ ;
+ ptr++;
+ }
+
+ return;
+}
+
+void print_driver_info_5(PDRIVER_INFO_5 info)
+{
+ printf("\tDriver Name\t= %s\n", info->pName);
+ printf("\tEnvironment\t= %s\n", info->pEnvironment);
+ printf("\tVersion\t\t= %d\n", info->cVersion);
+ printf("\tDriver Path\t= %s\n", info->pDriverPath);
+ printf("\tData File\t= %s\n", info->pDataFile);
+ printf("\tConfig File\t= %s\n", info->pConfigFile);
+ printf("\tDriver Attributes\t= %d\n", info->dwDriverAttributes);
+ printf("\tConfig Version\t= %d\n", info->dwConfigVersion);
+ printf("\tDriver Version\t= %d\n", info->dwDriverVersion);
+
+ return;
+}
+
+void print_driver_info_6(PDRIVER_INFO_6 info)
+{
+ char *ptr = NULL;
+
+ printf("\tDriver Name\t= %s\n", info->pName);
+ printf("\tEnvironment\t= %s\n", info->pEnvironment);
+ printf("\tVersion\t\t= %d\n", info->cVersion);
+ printf("\tDriver Path\t= %s\n", info->pDriverPath);
+ printf("\tData File\t= %s\n", info->pDataFile);
+ printf("\tConfig File\t= %s\n", info->pConfigFile);
+ printf("\tHelp Path\t= %s\n", info->pHelpFile);
+ printf("\tMonitor Name\t= %s\n", info->pMonitorName);
+ printf("\tData Type\t= %s\n", info->pDefaultDataType);
+ printf("\tPrevious Names\t= %s\n", info->pszzPreviousNames);
+ ptr = (char*)info->pDependentFiles;
+ if (ptr != NULL) {
+ while (*ptr != '\0') {
+ printf("\tDependent Files\t= %s\n", ptr);
+ for (;*ptr != '\0'; ptr++)
+ /* printf("%s\n", ptr); */
+ ;
+ ptr++;
+ }
+ } else {
+ printf("\tPrevious Names\t= (null)\n");
+ }
+
+ ptr = (char*)info->pszzPreviousNames;
+ if (ptr != NULL) {
+ while (*ptr != '\0') {
+ printf("\tPrevious Names\t= %s\n", ptr);
+ for (;*ptr != '\0'; ptr++)
+ /* printf("%s\n", ptr); */
+ ;
+ ptr++;
+ }
+ } else {
+ printf("\tPrevious Names\t= (null)\n");
+ }
+
+ printf("\tDriver Date\t= %d (%08x:%08x)\n",
+ info->ftDriverDate,
+ info->ftDriverDate.dwLowDateTime,
+ info->ftDriverDate.dwHighDateTime);
+ printf("\t\t");
+ print_file_time(&info->ftDriverDate);
+ printf("\tDriver Version\t= %d\n", info->dwlDriverVersion);
+ printf("\tManufacture Name = %s\n", info->pszMfgName);
+ printf("\tOEM URL\t\t= %s\n", info->pszOEMUrl);
+ printf("\tHardware ID\t= %s\n", info->pszHardwareID);
+ printf("\tProvider\t= %s\n", info->pszProvider);
+ return;
+}
+
+static void print_multi_sz(LPSTR multisz)
+{
+ char *ptr = NULL;
+
+ ptr = (char *)multisz;
+
+ if (!ptr) {
+ printf("(null)\n");
+ return;
+ }
+
+ while (*ptr != '\0') {
+ printf("%s\n", ptr);
+ for (; *ptr != '\0'; ptr++) {
+ /* printf("%s\n", ptr); */
+ ;
+ }
+ ptr++;
+ }
+}
+
+void print_driver_info_8(PDRIVER_INFO_8 info)
+{
+ printf("\tDriver Name\t= %s\n", info->pName);
+ printf("\tEnvironment\t= %s\n", info->pEnvironment);
+ printf("\tVersion\t\t= %d\n", info->cVersion);
+ printf("\tDriver Path\t= %s\n", info->pDriverPath);
+ printf("\tData File\t= %s\n", info->pDataFile);
+ printf("\tConfig File\t= %s\n", info->pConfigFile);
+ printf("\tHelp Path\t= %s\n", info->pHelpFile);
+ printf("\tMonitor Name\t= %s\n", info->pMonitorName);
+ printf("\tData Type\t= %s\n", info->pDefaultDataType);
+ printf("\tPrevious Names\t=\n");
+ print_multi_sz(info->pszzPreviousNames);
+ printf("\tDependent Files\t=\n");
+ print_multi_sz(info->pDependentFiles);
+ printf("\tDriver Date\t= %d (%08x:%08x)\n",
+ info->ftDriverDate,
+ info->ftDriverDate.dwLowDateTime,
+ info->ftDriverDate.dwHighDateTime);
+ printf("\t\t");
+ print_file_time(&info->ftDriverDate);
+ printf("\tDriver Version\t= %d\n", info->dwlDriverVersion);
+ printf("\tManufacture Name = %s\n", info->pszMfgName);
+ printf("\tOEM URL\t\t= %s\n", info->pszOEMUrl);
+ printf("\tHardware ID\t= %s\n", info->pszHardwareID);
+ printf("\tProvider\t= %s\n", info->pszProvider);
+ printf("\tPrint Processor\t= %s\n", info->pszPrintProcessor);
+ printf("\tVendor Setup\t= %s\n", info->pszVendorSetup);
+ printf("\tColor Profiles\t=\n");
+ print_multi_sz(info->pszzColorProfiles);
+ printf("\tInf Path\t= %s\n", info->pszInfPath);
+ printf("\tPrinter Driver Attributes = %d\n", info->dwPrinterDriverAttributes);
+ printf("\tCore Driver Dependencies\t=\n");
+ print_multi_sz(info->pszzCoreDriverDependencies);
+ printf("\tMin Inbox Driver VerDate\t= %d (%08x:%08x)\n",
+ info->ftMinInboxDriverVerDate,
+ info->ftMinInboxDriverVerDate.dwLowDateTime,
+ info->ftMinInboxDriverVerDate.dwHighDateTime);
+ printf("\t\t");
+ print_file_time(&info->ftMinInboxDriverVerDate);
+ printf("\tMin Inbox Driver VerVersion\t= %d\n", info->dwlMinInboxDriverVerVersion);
+ return;
+}
+
+void print_driver_info_bylevel(DWORD level, LPBYTE buffer, DWORD count)
+{
+ DWORD i;
+ PDRIVER_INFO_1 buffer1 = NULL;
+ PDRIVER_INFO_2 buffer2 = NULL;
+ PDRIVER_INFO_3 buffer3 = NULL;
+ PDRIVER_INFO_4 buffer4 = NULL;
+ PDRIVER_INFO_5 buffer5 = NULL;
+ PDRIVER_INFO_6 buffer6 = NULL;
+ PDRIVER_INFO_8 buffer8 = NULL;
+
+ if (!buffer) {
+ return;
+ }
+
+ switch (level) {
+ case 1:
+ buffer1 = (PDRIVER_INFO_1)buffer;
+ break;
+ case 2:
+ buffer2 = (PDRIVER_INFO_2)buffer;
+ break;
+ case 3:
+ buffer3 = (PDRIVER_INFO_3)buffer;
+ break;
+ case 4:
+ buffer4 = (PDRIVER_INFO_4)buffer;
+ break;
+ case 5:
+ buffer5 = (PDRIVER_INFO_5)buffer;
+ break;
+ case 6:
+ buffer6 = (PDRIVER_INFO_6)buffer;
+ break;
+ case 8:
+ buffer8 = (PDRIVER_INFO_8)buffer;
+ break;
+ default:
+ break;
+ }
+
+ printf("Driver Info Level %d:\n", level);
+
+ switch (level) {
+ case 1:
+ for (i=0; i<count; i++) {
+ print_driver_info_1(&buffer1[i]);
+ printf("\n");
+ }
+ break;
+ case 2:
+ for (i=0; i<count; i++) {
+ print_driver_info_2(&buffer2[i]);
+ printf("\n");
+ }
+ break;
+ case 3:
+ for (i=0; i<count; i++) {
+ print_driver_info_3(&buffer3[i]);
+ printf("\n");
+ }
+ break;
+ case 4:
+ for (i=0; i<count; i++) {
+ print_driver_info_4(&buffer4[i]);
+ printf("\n");
+ }
+ break;
+ case 5:
+ for (i=0; i<count; i++) {
+ print_driver_info_5(&buffer5[i]);
+ printf("\n");
+ }
+ break;
+ case 6:
+ for (i=0; i<count; i++) {
+ print_driver_info_6(&buffer6[i]);
+ printf("\n");
+ }
+ break;
+ case 8:
+ for (i=0; i<count; i++) {
+ print_driver_info_8(&buffer8[i]);
+ printf("\n");
+ }
+ break;
+ default:
+ break;
+ }
+}
+
+void print_doc_info_1(PDOC_INFO_1 info)
+{
+ printf("\tDocument Name\t= %s\n", info->pDocName);
+ printf("\tOutput Filename\t= %s\n", info->pOutputFile);
+ printf("\tDatatype\t= %s\n", info->pDatatype);
+ return;
+}
+
+void print_printer_keys(LPSTR buffer)
+{
+ LPSTR p = NULL;
+
+ p = buffer;
+
+ while (p && *p) {
+ printf("%s\n", p);
+ for (; *p; p = CharNext(p)) {
+ p = CharNext(p);
+ }
+ }
+}
+
+LPSTR reg_type_str(DWORD type)
+{
+ switch (type) {
+ case REG_DWORD:
+ return "REG_DWORD";
+ case REG_SZ:
+ return "REG_SZ";
+ case REG_MULTI_SZ:
+ return "REG_MULTI_SZ";
+ case REG_BINARY:
+ return "REG_BINARY";
+ default:
+ return NULL;
+ }
+}
+
+void print_asc(const BYTE *buf, DWORD len)
+{
+ int i;
+ for (i=0; i<len; i++) {
+ printf("%c", isprint(buf[i])?buf[i]:'.');
+ }
+}
+
+static void dump_data(const BYTE *buf, int len)
+{
+ int i=0;
+ static const BYTE empty[16] = { 0, };
+
+ if (len<=0) return;
+
+ for (i=0; i<len;) {
+
+ if (i%16 == 0) {
+ if ((i > 0) &&
+ (len > i+16) &&
+ (memcmp(&buf[i], &empty, 16) == 0))
+ {
+ i +=16;
+ continue;
+ }
+
+ if (i<len) {
+ printf("[%04X] ",i);
+ }
+ }
+
+ printf("%02x ", buf[i]);
+ i++;
+
+ if (i%8 == 0) printf(" ");
+ if (i%16 == 0) {
+ print_asc(&buf[i-16],8); printf(" ");
+ print_asc(&buf[i-8],8); printf("\n");
+ }
+ }
+
+ if (i%16) {
+ int n;
+ n = 16 - (i%16);
+ printf(" ");
+ if (n>8) printf(" ");
+ while (n--) printf(" ");
+ n = MIN(8,i%16);
+ print_asc(&buf[i-(i%16)],n); printf( " " );
+ n = (i%16) - n;
+ if (n>0) print_asc(&buf[i-n],n);
+ printf("\n");
+ }
+}
+
+static void dump_printer_data(DWORD size, LPBYTE buffer, DWORD type)
+{
+ DWORD i = 0;
+ LPSTR p = NULL;
+
+ switch (type) {
+ case REG_SZ:
+ dump_data(buffer, size);
+ break;
+ case REG_MULTI_SZ:
+ dump_data(buffer, size);
+ p = (LPSTR)buffer;
+ while (p && *p) {
+ printf("\t\t%s\n", p);
+ for (; *p; p = CharNext(p)) {
+ p = CharNext(p);
+ }
+ }
+ break;
+ case REG_DWORD:
+ assert(size == 4);
+ printf("\t\t0x%08x\n", (DWORD)*buffer);
+ break;
+ case REG_BINARY:
+ dump_data(buffer, size);
+ break;
+ default:
+ break;
+ }
+}
+
+void print_printer_data(LPSTR keyname, LPSTR valuename, DWORD size, LPBYTE buffer, DWORD type)
+{
+ if (keyname) {
+ printf("\tKey Name:\t%s\n", keyname);
+ }
+
+ printf("\tValue Name:\t%s\n", valuename);
+ printf("\tSize:\t\t0x%x (%d)\n", size, size);
+ printf("\tType:\t\t%s\n", reg_type_str(type));
+
+ if (buffer == NULL || size == 0) {
+ return;
+ }
+
+ dump_printer_data(size, buffer, type);
+}
+
+void print_printer_dataw(LPCWSTR keyname, LPCWSTR valuename, DWORD size, LPBYTE buffer, DWORD type)
+{
+ if (keyname) {
+ printf("\tKey Name:\t%ls\n", keyname);
+ }
+
+ printf("\tValue Name:\t%ls\n", valuename);
+ printf("\tSize:\t\t0x%x (%d)\n", size, size);
+ printf("\tType:\t\t%s\n", reg_type_str(type));
+
+ if (buffer == NULL || size == 0) {
+ return;
+ }
+
+ dump_printer_data(size, buffer, type);
+}
+
+
+void print_printer_enum_values(PRINTER_ENUM_VALUES *info)
+{
+ print_printer_data(NULL, info->pValueName, info->cbData, info->pData, info->dwType);
+}
+
+void print_file_time(const FILETIME *t)
+{
+ SYSTEMTIME s;
+ LPSTR dayofweek = NULL;
+ LPSTR month = NULL;
+
+ if (!FileTimeToSystemTime(t, &s)) {
+ printf("Failed to convert FILETIME to SYSTEMTIME\n");
+ return;
+ }
+ switch (s.wDayOfWeek) {
+ case 0:
+ dayofweek = "Sun";
+ break;
+ case 1:
+ dayofweek = "Mon";
+ break;
+ case 2:
+ dayofweek = "Tue";
+ break;
+ case 3:
+ dayofweek = "Wed";
+ break;
+ case 4:
+ dayofweek = "Thu";
+ break;
+ case 5:
+ dayofweek = "Fri";
+ break;
+ case 6:
+ dayofweek = "Sat";
+ break;
+ default:
+ break;
+ }
+
+ switch (s.wMonth) {
+ case 1:
+ month = "Jan";
+ break;
+ case 2:
+ month = "Feb";
+ break;
+ case 3:
+ month = "Mar";
+ break;
+ case 4:
+ month = "Apr";
+ break;
+ case 5:
+ month = "May";
+ break;
+ case 6:
+ month = "Jun";
+ break;
+ case 7:
+ month = "Jul";
+ break;
+ case 8:
+ month = "Aug";
+ break;
+ case 9:
+ month = "Sep";
+ break;
+ case 10:
+ month = "Oct";
+ break;
+ case 11:
+ month = "Nov";
+ break;
+ case 12:
+ month = "Dec";
+ break;
+ default:
+ break;
+ }
+
+ printf("%s %s %02d %02d:%02d:%02d %04d\n",
+ dayofweek, month, s.wDay,
+ s.wHour, s.wMinute, s.wSecond, s.wYear);
+}
diff --git a/testprogs/win32/spoolss/printlib_proto.h b/testprogs/win32/spoolss/printlib_proto.h
new file mode 100644
index 0000000..704cdbf
--- /dev/null
+++ b/testprogs/win32/spoolss/printlib_proto.h
@@ -0,0 +1,67 @@
+#ifndef __PRINTLIB_PROTO_H__
+#define __PRINTLIB_PROTO_H__
+
+#undef _PRINTF_ATTRIBUTE
+#define _PRINTF_ATTRIBUTE(a1, a2) PRINTF_ATTRIBUTE(a1, a2)
+/* This file was automatically generated by mkproto.pl. DO NOT EDIT */
+
+/* this file contains prototypes for functions that are private
+ * to this subsystem or library. These functions should not be
+ * used outside this particular subsystem! */
+
+
+/* The following definitions come from printlib.c */
+
+void print_devmode(DEVMODE *pDevModeIn);
+void print_acl(const char* str, ACL *acl);
+void print_sid(const char* str, SID *sid);
+void print_secdesc(SECURITY_DESCRIPTOR *secdesc);
+void PrintLastError();
+void print_job_info_1(PJOB_INFO_1 info);
+void print_job_info_2(PJOB_INFO_2 info);
+void print_job_info_3(PJOB_INFO_3 info);
+void print_job_info_4(PJOB_INFO_4 info);
+void print_job_info_bylevel(DWORD level, LPBYTE buffer, DWORD count);
+void print_monitor_info_1(PMONITOR_INFO_1 info);
+void print_monitor_info_2(PMONITOR_INFO_2 info);
+void print_monitor_info_bylevel(DWORD level, LPBYTE buffer, DWORD count);
+void print_port_info_1(PPORT_INFO_1 info);
+void print_port_info_2(PPORT_INFO_2 info);
+void print_port_info_3(PPORT_INFO_3 info);
+void print_port_info_bylevel(DWORD level, LPBYTE buffer, DWORD count);
+void print_form_info_1(PFORM_INFO_1 info);
+void print_form_info_2(PFORM_INFO_2 info);
+void print_form_info_bylevel(DWORD level, LPBYTE buffer, DWORD count);
+void print_printer_info_1(PPRINTER_INFO_1 info);
+void print_printer_info_2(PPRINTER_INFO_2 info);
+void print_printer_info_5(PPRINTER_INFO_5 info);
+void print_printer_info_6(PPRINTER_INFO_6 info);
+void print_printer_info_7(PPRINTER_INFO_7 info);
+void print_printer_info_8(PPRINTER_INFO_8 info);
+void print_printer_info_9(PPRINTER_INFO_9 info);
+void print_printer_info_bylevel(DWORD level, LPBYTE buffer, DWORD count);
+void print_printprocessor_info_1(PPRINTPROCESSOR_INFO_1 info);
+void print_printprocessor_info_bylevel(DWORD level, LPBYTE buffer, DWORD count);
+void print_datatypes_info_1(PDATATYPES_INFO_1 info);
+void print_datatypes_info_bylevel(DWORD level, LPBYTE buffer, DWORD count);
+void print_driver_info_1(PDRIVER_INFO_1 info);
+void print_driver_info_2(PDRIVER_INFO_2 info);
+void print_driver_info_3(PDRIVER_INFO_3 info);
+void print_driver_info_4(PDRIVER_INFO_4 info);
+void print_driver_info_5(PDRIVER_INFO_5 info);
+void print_driver_info_6(PDRIVER_INFO_6 info);
+void print_driver_info_8(PDRIVER_INFO_8 info);
+void print_driver_info_bylevel(DWORD level, LPBYTE buffer, DWORD count);
+void print_doc_info_1(PDOC_INFO_1 info);
+void print_printer_keys(LPSTR buffer);
+LPSTR reg_type_str(DWORD type);
+void print_printer_data(LPSTR keyname, LPSTR valuename, DWORD size, LPBYTE buffer, DWORD type);
+void print_printer_dataw(LPCWSTR keyname, LPCWSTR valuename, DWORD size, LPBYTE buffer, DWORD type);
+void print_printer_enum_values(PRINTER_ENUM_VALUES *info);
+void print_file_time(const FILETIME *t);
+
+#undef _PRINTF_ATTRIBUTE
+#define _PRINTF_ATTRIBUTE(a1, a2)
+
+#endif /* __PRINTLIB_PROTO_H__ */
+
diff --git a/testprogs/win32/spoolss/string.h b/testprogs/win32/spoolss/string.h
new file mode 100644
index 0000000..17561eb
--- /dev/null
+++ b/testprogs/win32/spoolss/string.h
@@ -0,0 +1,15 @@
+/* __location__ macro replacement taken from talloc.h */
+
+/*
+ this uses a little trick to allow __LINE__ to be stringified
+*/
+#ifndef __location__
+#define __STRING_LINE1__(s) #s
+#define __STRING_LINE2__(s) __STRING_LINE1__(s)
+#define __STRING_LINE3__ __STRING_LINE2__(__LINE__)
+#define __location__ __FILE__ ":" __STRING_LINE3__
+#endif
+
+#ifndef __STRING
+#define __STRING(s) #s
+#endif
diff --git a/testprogs/win32/spoolss/testspoolss.c b/testprogs/win32/spoolss/testspoolss.c
new file mode 100644
index 0000000..794e545
--- /dev/null
+++ b/testprogs/win32/spoolss/testspoolss.c
@@ -0,0 +1,1842 @@
+/*
+ Unix SMB/CIFS implementation.
+ test suite for spoolss rpc operations
+
+ Copyright (C) Guenther Deschner 2009-2010
+
+ 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
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+/****************************************************************************
+****************************************************************************/
+
+#include "testspoolss.h"
+#include "string.h"
+#include "torture.h"
+
+/****************************************************************************
+****************************************************************************/
+
+static BOOL test_OpenPrinter(struct torture_context *tctx,
+ LPSTR printername,
+ LPPRINTER_DEFAULTS defaults,
+ LPHANDLE handle)
+{
+ torture_comment(tctx, "Testing OpenPrinter(%s)", printername);
+
+ if (!OpenPrinter(printername, handle, defaults)) {
+ char tmp[1024];
+ sprintf(tmp, "failed to open printer %s, error was: 0x%08x\n",
+ printername, GetLastError());
+ torture_fail(tctx, tmp);
+ }
+
+ return TRUE;
+}
+
+/****************************************************************************
+****************************************************************************/
+
+static BOOL test_ClosePrinter(struct torture_context *tctx,
+ HANDLE handle)
+{
+ torture_comment(tctx, "Testing ClosePrinter");
+
+ if (!ClosePrinter(handle)) {
+ char tmp[1024];
+ sprintf(tmp, "failed to close printer, error was: %s\n",
+ errstr(GetLastError()));
+ torture_fail(tctx, tmp);
+ }
+
+ return TRUE;
+}
+
+
+/****************************************************************************
+****************************************************************************/
+
+static BOOL test_EnumPrinters(struct torture_context *tctx,
+ LPSTR servername)
+{
+ DWORD levels[] = { 1, 2, 5 };
+ DWORD success[] = { 1, 1, 1 };
+ DWORD i;
+ DWORD flags = PRINTER_ENUM_NAME;
+ LPBYTE buffer = NULL;
+
+ for (i=0; i < ARRAY_SIZE(levels); i++) {
+
+ DWORD needed = 0;
+ DWORD returned = 0;
+ DWORD err = 0;
+ char tmp[1024];
+
+ torture_comment(tctx, "Testing EnumPrinters level %d", levels[i]);
+
+ EnumPrinters(flags, servername, levels[i], NULL, 0, &needed, &returned);
+ err = GetLastError();
+ if (err == ERROR_INSUFFICIENT_BUFFER) {
+ err = 0;
+ buffer = malloc(needed);
+ torture_assert(tctx, buffer, "malloc failed");
+ if (!EnumPrinters(flags, servername, levels[i], buffer, needed, &needed, &returned)) {
+ err = GetLastError();
+ }
+ }
+ if (err) {
+ sprintf(tmp, "EnumPrinters failed level %d on [%s] (buffer size = %d), error: %s\n",
+ levels[i], servername, needed, errstr(err));
+ if (success[i]) {
+ torture_fail(tctx, tmp);
+ } else {
+ torture_warning(tctx, tmp);
+ }
+ }
+
+ if (tctx->print) {
+ print_printer_info_bylevel(levels[i], buffer, returned);
+ }
+
+ free(buffer);
+ buffer = NULL;
+ }
+
+ return TRUE;
+}
+
+/****************************************************************************
+****************************************************************************/
+
+static BOOL test_EnumDrivers(struct torture_context *tctx,
+ LPSTR servername,
+ LPSTR architecture)
+{
+ DWORD levels[] = { 1, 2, 3, 4, 5, 6 };
+ DWORD success[] = { 1, 1, 1, 1, 1, 1 };
+ DWORD i;
+ LPBYTE buffer = NULL;
+
+ for (i=0; i < ARRAY_SIZE(levels); i++) {
+
+ DWORD needed = 0;
+ DWORD returned = 0;
+ DWORD err = 0;
+ char tmp[1024];
+
+ torture_comment(tctx, "Testing EnumPrinterDrivers(%s) level %d",
+ architecture, levels[i]);
+
+ EnumPrinterDrivers(servername, architecture, levels[i], NULL, 0, &needed, &returned);
+ err = GetLastError();
+ if (err == ERROR_INSUFFICIENT_BUFFER) {
+ err = 0;
+ buffer = malloc(needed);
+ torture_assert(tctx, buffer, "malloc failed");
+ if (!EnumPrinterDrivers(servername, architecture, levels[i], buffer, needed, &needed, &returned)) {
+ err = GetLastError();
+ }
+ }
+ if (err) {
+ sprintf(tmp, "EnumPrinterDrivers failed level %d on [%s] (buffer size = %d), error: %s\n",
+ levels[i], servername, needed, errstr(err));
+ if (success[i]) {
+ torture_fail(tctx, tmp);
+ } else {
+ torture_warning(tctx, tmp);
+ }
+ }
+
+ if (tctx->print) {
+ print_driver_info_bylevel(levels[i], buffer, returned);
+ }
+
+ free(buffer);
+ buffer = NULL;
+ }
+
+ return TRUE;
+}
+
+/****************************************************************************
+****************************************************************************/
+
+static BOOL test_GetForm(struct torture_context *tctx,
+ LPSTR servername,
+ HANDLE handle,
+ LPSTR formname)
+{
+ DWORD levels[] = { 1, 2 };
+ DWORD success[] = { 1, 0 };
+ DWORD i;
+ LPBYTE buffer = NULL;
+
+ for (i=0; i < ARRAY_SIZE(levels); i++) {
+
+ DWORD needed = 0;
+ DWORD err = 0;
+ char tmp[1024];
+
+ torture_comment(tctx, "Testing GetForm(%s) level %d", formname, levels[i]);
+
+ GetForm(handle, formname, levels[i], NULL, 0, &needed);
+ err = GetLastError();
+ if (err == ERROR_INSUFFICIENT_BUFFER) {
+ err = 0;
+ buffer = malloc(needed);
+ torture_assert(tctx, buffer, "malloc failed");
+ if (!GetForm(handle, formname, levels[i], buffer, needed, &needed)) {
+ err = GetLastError();
+ }
+ }
+ if (err) {
+ sprintf(tmp, "GetForm failed level %d on [%s] (buffer size = %d), error: %s\n",
+ levels[i], servername, needed, errstr(err));
+ if (success[i]) {
+ torture_fail(tctx, tmp);
+ } else {
+ torture_warning(tctx, tmp);
+ }
+ }
+
+ if (tctx->print) {
+ print_form_info_bylevel(levels[i], buffer, 1);
+ }
+
+ free(buffer);
+ buffer = NULL;
+ }
+
+ return TRUE;
+}
+
+/****************************************************************************
+****************************************************************************/
+
+static BOOL test_EnumForms(struct torture_context *tctx,
+ LPSTR servername,
+ HANDLE handle)
+{
+ DWORD levels[] = { 1, 2 };
+ DWORD success[] = { 1, 1 };
+ DWORD i;
+ LPBYTE buffer = NULL;
+
+ for (i=0; i < ARRAY_SIZE(levels); i++) {
+
+ DWORD needed = 0;
+ DWORD returned = 0;
+ DWORD err = 0;
+ char tmp[1024];
+
+ torture_comment(tctx, "Testing EnumForms level %d", levels[i]);
+
+ if (tctx->samba3 && levels[i] == 2) {
+ torture_comment(tctx, "skipping level %d enum against samba\n", levels[i]);
+ continue;
+ }
+
+ EnumForms(handle, levels[i], NULL, 0, &needed, &returned);
+ err = GetLastError();
+ if (err == ERROR_INSUFFICIENT_BUFFER) {
+ err = 0;
+ buffer = malloc(needed);
+ torture_assert(tctx, buffer, "malloc failed");
+ if (!EnumForms(handle, levels[i], buffer, needed, &needed, &returned)) {
+ err = GetLastError();
+ }
+ }
+ if (err) {
+ sprintf(tmp, "EnumForms failed level %d on [%s] (buffer size = %d), error: %s\n",
+ levels[i], servername, needed, errstr(err));
+ if (success[i]) {
+ torture_fail(tctx, tmp);
+ } else {
+ torture_warning(tctx, tmp);
+ }
+ }
+
+ if (tctx->print) {
+ print_form_info_bylevel(levels[i], buffer, returned);
+ }
+
+ free(buffer);
+ buffer = NULL;
+ }
+
+ return TRUE;
+}
+
+/****************************************************************************
+****************************************************************************/
+
+static BOOL test_EnumPorts(struct torture_context *tctx,
+ LPSTR servername)
+{
+ DWORD levels[] = { 1, 2 };
+ DWORD success[] = { 1, 1 };
+ DWORD i;
+ LPBYTE buffer = NULL;
+
+ for (i=0; i < ARRAY_SIZE(levels); i++) {
+
+ DWORD needed = 0;
+ DWORD returned = 0;
+ DWORD err = 0;
+ char tmp[1024];
+
+ torture_comment(tctx, "Testing EnumPorts level %d", levels[i]);
+
+ EnumPorts(servername, levels[i], NULL, 0, &needed, &returned);
+ err = GetLastError();
+ if (err == ERROR_INSUFFICIENT_BUFFER) {
+ err = 0;
+ buffer = malloc(needed);
+ torture_assert(tctx, buffer, "malloc failed");
+ if (!EnumPorts(servername, levels[i], buffer, needed, &needed, &returned)) {
+ err = GetLastError();
+ }
+ }
+ if (err) {
+ sprintf(tmp, "EnumPorts failed level %d on [%s] (buffer size = %d), error: %s\n",
+ levels[i], servername, needed, errstr(err));
+ if (success[i]) {
+ torture_fail(tctx, tmp);
+ } else {
+ torture_warning(tctx, tmp);
+ }
+ }
+
+ if (tctx->print) {
+ print_port_info_bylevel(levels[i], buffer, returned);
+ }
+
+ free(buffer);
+ buffer = NULL;
+ }
+
+ return TRUE;
+}
+
+/****************************************************************************
+****************************************************************************/
+
+static BOOL test_EnumMonitors(struct torture_context *tctx,
+ LPSTR servername)
+{
+ DWORD levels[] = { 1, 2 };
+ DWORD success[] = { 1, 1 };
+ DWORD i;
+ LPBYTE buffer = NULL;
+
+ for (i=0; i < ARRAY_SIZE(levels); i++) {
+
+ DWORD needed = 0;
+ DWORD returned = 0;
+ DWORD err = 0;
+ char tmp[1024];
+
+ torture_comment(tctx, "Testing EnumMonitors level %d", levels[i]);
+
+ EnumMonitors(servername, levels[i], NULL, 0, &needed, &returned);
+ err = GetLastError();
+ if (err == ERROR_INSUFFICIENT_BUFFER) {
+ err = 0;
+ buffer = malloc(needed);
+ torture_assert(tctx, buffer, "malloc failed");
+ if (!EnumMonitors(servername, levels[i], buffer, needed, &needed, &returned)) {
+ err = GetLastError();
+ }
+ }
+ if (err) {
+ sprintf(tmp, "EnumMonitors failed level %d on [%s] (buffer size = %d), error: %s\n",
+ levels[i], servername, needed, errstr(err));
+ if (success[i]) {
+ torture_fail(tctx, tmp);
+ } else {
+ torture_warning(tctx, tmp);
+ }
+ }
+
+ if (tctx->print) {
+ print_monitor_info_bylevel(levels[i], buffer, returned);
+ }
+
+ free(buffer);
+ buffer = NULL;
+ }
+
+ return TRUE;
+}
+
+/****************************************************************************
+****************************************************************************/
+
+static BOOL test_EnumPrintProcessors(struct torture_context *tctx,
+ LPSTR servername,
+ LPSTR architecture)
+{
+ DWORD levels[] = { 1 };
+ DWORD success[] = { 1 };
+ DWORD i;
+ LPBYTE buffer = NULL;
+
+ for (i=0; i < ARRAY_SIZE(levels); i++) {
+
+ DWORD needed = 0;
+ DWORD returned = 0;
+ DWORD err = 0;
+ char tmp[1024];
+
+ torture_comment(tctx, "Testing EnumPrintProcessors(%s) level %d", architecture, levels[i]);
+
+ EnumPrintProcessors(servername, architecture, levels[i], NULL, 0, &needed, &returned);
+ err = GetLastError();
+ if (err == ERROR_INSUFFICIENT_BUFFER) {
+ err = 0;
+ buffer = malloc(needed);
+ torture_assert(tctx, buffer, "malloc failed");
+ if (!EnumPrintProcessors(servername, architecture, levels[i], buffer, needed, &needed, &returned)) {
+ err = GetLastError();
+ }
+ }
+ if (err) {
+ sprintf(tmp, "EnumPrintProcessors failed level %d on [%s] (buffer size = %d), error: %s\n",
+ levels[i], servername, needed, errstr(err));
+ if (success[i]) {
+ torture_fail(tctx, tmp);
+ } else {
+ torture_warning(tctx, tmp);
+ }
+ }
+
+ if (tctx->print) {
+ print_printprocessor_info_bylevel(levels[i], buffer, returned);
+ }
+
+ free(buffer);
+ buffer = NULL;
+ }
+
+ return TRUE;
+}
+
+/****************************************************************************
+****************************************************************************/
+
+static BOOL test_EnumPrintProcessorDatatypes(struct torture_context *tctx,
+ LPSTR servername)
+{
+ DWORD levels[] = { 1 };
+ DWORD success[] = { 1 };
+ DWORD i;
+ LPBYTE buffer = NULL;
+
+ for (i=0; i < ARRAY_SIZE(levels); i++) {
+
+ DWORD needed = 0;
+ DWORD returned = 0;
+ DWORD err = 0;
+ char tmp[1024];
+
+ torture_comment(tctx, "Testing EnumPrintProcessorDatatypes level %d", levels[i]);
+
+ EnumPrintProcessorDatatypes(servername, "winprint", levels[i], NULL, 0, &needed, &returned);
+ err = GetLastError();
+ if (err == ERROR_INSUFFICIENT_BUFFER) {
+ err = 0;
+ buffer = malloc(needed);
+ torture_assert(tctx, buffer, "malloc failed");
+ if (!EnumPrintProcessorDatatypes(servername, "winprint", levels[i], buffer, needed, &needed, &returned)) {
+ err = GetLastError();
+ }
+ }
+ if (err) {
+ sprintf(tmp, "EnumPrintProcessorDatatypes failed level %d on [%s] (buffer size = %d), error: %s\n",
+ levels[i], servername, needed, errstr(err));
+ if (success[i]) {
+ torture_fail(tctx, tmp);
+ } else {
+ torture_warning(tctx, tmp);
+ }
+ }
+
+ if (tctx->print) {
+ print_datatypes_info_bylevel(levels[i], buffer, returned);
+ }
+
+ free(buffer);
+ buffer = NULL;
+ }
+
+ return TRUE;
+}
+
+/****************************************************************************
+****************************************************************************/
+
+static BOOL test_EnumPrinterKey(struct torture_context *tctx,
+ LPSTR servername,
+ HANDLE handle,
+ LPCSTR key)
+{
+ LPSTR buffer = NULL;
+ DWORD needed = 0;
+ DWORD err = 0;
+ char tmp[1024];
+
+ torture_comment(tctx, "Testing EnumPrinterKey(%s)", key);
+
+ err = EnumPrinterKey(handle, key, NULL, 0, &needed);
+ if (err == ERROR_MORE_DATA) {
+ buffer = (LPTSTR)malloc(needed);
+ torture_assert(tctx, buffer, "malloc failed");
+ err = EnumPrinterKey(handle, key, buffer, needed, &needed);
+ }
+ if (err) {
+ sprintf(tmp, "EnumPrinterKey(%s) failed on [%s] (buffer size = %d), error: %s\n",
+ key, servername, needed, errstr(err));
+ torture_fail(tctx, tmp);
+ }
+
+ if (tctx->print) {
+ print_printer_keys(buffer);
+ }
+
+ free(buffer);
+
+ return TRUE;
+}
+
+/****************************************************************************
+****************************************************************************/
+
+static BOOL test_GetPrinter(struct torture_context *tctx,
+ LPSTR printername,
+ HANDLE handle)
+{
+ DWORD levels[] = { 1, 2, 3, 4, 5, 6, 7, 8 };
+ DWORD success[] = { 1, 1, 1, 1, 1, 1, 1, 1 };
+ DWORD i;
+ LPBYTE buffer = NULL;
+
+ for (i=0; i < ARRAY_SIZE(levels); i++) {
+
+ DWORD needed = 0;
+ DWORD err = 0;
+ char tmp[1024];
+
+ torture_comment(tctx, "Testing GetPrinter level %d", levels[i]);
+
+ GetPrinter(handle, levels[i], NULL, 0, &needed);
+ err = GetLastError();
+ if (err == ERROR_INSUFFICIENT_BUFFER) {
+ err = 0;
+ buffer = malloc(needed);
+ torture_assert(tctx, buffer, "malloc failed");
+ if (!GetPrinter(handle, levels[i], buffer, needed, &needed)) {
+ err = GetLastError();
+ }
+ }
+ if (err) {
+ sprintf(tmp, "GetPrinter failed level %d on [%s] (buffer size = %d), error: %s\n",
+ levels[i], printername, needed, errstr(err));
+ if (success[i]) {
+ torture_fail(tctx, tmp);
+ } else {
+ torture_warning(tctx, tmp);
+ }
+ }
+
+ if (tctx->print) {
+ print_printer_info_bylevel(levels[i], buffer, 1);
+ }
+
+ free(buffer);
+ buffer = NULL;
+ }
+
+ return TRUE;
+}
+
+/****************************************************************************
+****************************************************************************/
+
+static BOOL test_GetPrinterDriver(struct torture_context *tctx,
+ LPSTR printername,
+ LPSTR architecture,
+ HANDLE handle)
+{
+ DWORD levels[] = { 1, 2, 3, 4, 5, 6, 8 };
+ DWORD success[] = { 1, 1, 1, 1, 1, 1, 1 };
+ DWORD i;
+ LPBYTE buffer = NULL;
+
+ for (i=0; i < ARRAY_SIZE(levels); i++) {
+
+ DWORD needed = 0;
+ DWORD err = 0;
+ char tmp[1024];
+
+ torture_comment(tctx, "Testing GetPrinterDriver(%s) level %d",
+ architecture, levels[i]);
+
+ GetPrinterDriver(handle, architecture, levels[i], NULL, 0, &needed);
+ err = GetLastError();
+ if (err == ERROR_INSUFFICIENT_BUFFER) {
+ err = 0;
+ buffer = malloc(needed);
+ torture_assert(tctx, buffer, "malloc failed");
+ if (!GetPrinterDriver(handle, architecture, levels[i], buffer, needed, &needed)) {
+ err = GetLastError();
+ }
+ }
+ if (err) {
+ sprintf(tmp, "GetPrinterDriver failed level %d on [%s] (buffer size = %d), error: %s\n",
+ levels[i], printername, needed, errstr(err));
+ if (success[i]) {
+ torture_fail(tctx, tmp);
+ } else {
+ torture_warning(tctx, tmp);
+ }
+ }
+
+ if (tctx->print) {
+ print_driver_info_bylevel(levels[i], buffer, 1);
+ }
+
+ free(buffer);
+ buffer = NULL;
+ }
+
+ return TRUE;
+}
+
+
+/****************************************************************************
+****************************************************************************/
+
+static BOOL test_EnumJobs(struct torture_context *tctx,
+ LPSTR printername,
+ HANDLE handle)
+{
+ DWORD levels[] = { 1, 2, 3, 4 };
+ DWORD success[] = { 1, 1, 1, 1 };
+ DWORD i;
+ LPBYTE buffer = NULL;
+
+ for (i=0; i < ARRAY_SIZE(levels); i++) {
+
+ DWORD needed = 0;
+ DWORD returned = 0;
+ DWORD err = 0;
+ char tmp[1024];
+
+ torture_comment(tctx, "Testing EnumJobs level %d", levels[i]);
+
+ if (tctx->samba3 && levels[i] == 4) {
+ torture_comment(tctx, "skipping level %d enum against samba\n", levels[i]);
+ continue;
+ }
+
+ EnumJobs(handle, 0, 100, levels[i], NULL, 0, &needed, &returned);
+ err = GetLastError();
+ if (err == ERROR_INSUFFICIENT_BUFFER) {
+ err = 0;
+ buffer = malloc(needed);
+ torture_assert(tctx, buffer, "malloc failed");
+ if (!EnumJobs(handle, 0, 100, levels[i], buffer, needed, &needed, &returned)) {
+ err = GetLastError();
+ }
+ }
+ if (err) {
+ sprintf(tmp, "EnumJobs failed level %d on [%s] (buffer size = %d), error: %s\n",
+ levels[i], printername, needed, errstr(err));
+ if (success[i]) {
+ torture_fail(tctx, tmp);
+ } else {
+ torture_warning(tctx, tmp);
+ }
+ }
+
+ if (tctx->print) {
+ print_job_info_bylevel(levels[i], buffer, returned);
+ }
+
+ free(buffer);
+ buffer = NULL;
+ }
+
+ return TRUE;
+}
+
+/****************************************************************************
+****************************************************************************/
+
+static BOOL test_EnumPrinterData(struct torture_context *tctx,
+ LPSTR servername,
+ HANDLE handle)
+{
+ DWORD err = 0;
+ LPTSTR value_name;
+ LPBYTE data;
+ DWORD index = 0;
+ DWORD type;
+ DWORD value_offered = 0, value_needed;
+ DWORD data_offered = 0, data_needed;
+ char tmp[1024];
+
+ torture_comment(tctx, "Testing EnumPrinterData(%d) (value offered: %d, data_offered: %d)\n",
+ index, value_offered, data_offered);
+
+ err = EnumPrinterData(handle, 0, NULL, 0, &value_needed, NULL, NULL, 0, &data_needed);
+ if (err) {
+ sprintf(tmp, "EnumPrinterData(%d) failed on [%s] (value size = %d, data size = %d), error: %s\n",
+ index, servername, value_offered, data_offered, errstr(err));
+ torture_fail(tctx, tmp);
+ }
+
+ value_name = malloc(value_needed);
+ torture_assert(tctx, value_name, "malloc failed");
+ data = malloc(data_needed);
+ torture_assert(tctx, data, "malloc failed");
+
+ value_offered = value_needed;
+ data_offered = data_needed;
+
+ do {
+
+ value_needed = 0;
+ data_needed = 0;
+
+ torture_comment(tctx, "Testing EnumPrinterData(%d) (value offered: %d, data_offered: %d)\n",
+ index, value_offered, data_offered);
+
+ err = EnumPrinterData(handle, index++, value_name, value_offered, &value_needed, &type, data, data_offered, &data_needed);
+ if (err == ERROR_NO_MORE_ITEMS) {
+ break;
+ }
+ if (err) {
+ sprintf(tmp, "EnumPrinterData(%d) failed on [%s] (value size = %d, data size = %d), error: %s\n",
+ index, servername, value_offered, data_offered, errstr(err));
+ torture_fail(tctx, tmp);
+ }
+
+ if (tctx->print) {
+ print_printer_data(NULL, value_name, data_needed, data, type);
+ }
+
+ } while (err != ERROR_NO_MORE_ITEMS);
+
+ free(value_name);
+ free(data);
+
+ return TRUE;
+}
+
+/****************************************************************************
+****************************************************************************/
+
+static BOOL test_EnumPrinterDataEx(struct torture_context *tctx,
+ LPSTR servername,
+ LPSTR keyname,
+ HANDLE handle,
+ LPBYTE *buffer_p,
+ DWORD *returned_p)
+{
+ LPBYTE buffer = NULL;
+ DWORD needed = 0;
+ DWORD returned = 0;
+ DWORD err = 0;
+ char tmp[1024];
+
+ torture_comment(tctx, "Testing EnumPrinterDataEx(%s)", keyname);
+
+ err = EnumPrinterDataEx(handle, keyname, NULL, 0, &needed, &returned);
+ if (err == ERROR_MORE_DATA) {
+ buffer = malloc(needed);
+ torture_assert(tctx, buffer, "malloc failed");
+ err = EnumPrinterDataEx(handle, keyname, buffer, needed, &needed, &returned);
+ }
+ if (err) {
+ sprintf(tmp, "EnumPrinterDataEx(%s) failed on [%s] (buffer size = %d), error: %s\n",
+ keyname, servername, needed, errstr(err));
+ torture_fail(tctx, tmp);
+ }
+
+ if (tctx->print) {
+ DWORD i;
+ LPPRINTER_ENUM_VALUES v = (LPPRINTER_ENUM_VALUES)buffer;
+ for (i=0; i < returned; i++) {
+ print_printer_enum_values(&v[i]);
+ }
+ }
+
+ if (returned_p) {
+ *returned_p = returned;
+ }
+
+ if (buffer_p) {
+ *buffer_p = buffer;
+ } else {
+ free(buffer);
+ }
+
+ return TRUE;
+}
+
+/****************************************************************************
+****************************************************************************/
+
+static BOOL test_devicemode_equal(struct torture_context *tctx,
+ const DEVMODE *d1,
+ const DEVMODE *d2)
+{
+ if (d1 == d2) {
+ return TRUE;
+ }
+
+ if (!d1 || !d2) {
+ torture_comment(tctx, "%s\n", __location__);
+ return FALSE;
+ }
+
+ torture_assert_str_equal(tctx, (const char *)d1->dmDeviceName, (const char *)d2->dmDeviceName, "dmDeviceName mismatch");
+ torture_assert_int_equal(tctx, d1->dmSpecVersion, d2->dmSpecVersion, "dmSpecVersion mismatch");
+ torture_assert_int_equal(tctx, d1->dmDriverVersion, d2->dmDriverVersion, "dmDriverVersion mismatch");
+ torture_assert_int_equal(tctx, d1->dmSize, d2->dmSize, "size mismatch");
+ torture_assert_int_equal(tctx, d1->dmDriverExtra, d2->dmDriverExtra, "dmDriverExtra mismatch");
+ torture_assert_int_equal(tctx, d1->dmFields, d2->dmFields, "dmFields mismatch");
+
+ torture_assert_int_equal(tctx, d1->dmOrientation, d2->dmOrientation, "dmOrientation mismatch");
+ torture_assert_int_equal(tctx, d1->dmPaperSize, d2->dmPaperSize, "dmPaperSize mismatch");
+ torture_assert_int_equal(tctx, d1->dmPaperLength, d2->dmPaperLength, "dmPaperLength mismatch");
+ torture_assert_int_equal(tctx, d1->dmPaperWidth, d2->dmPaperWidth, "dmPaperWidth mismatch");
+ torture_assert_int_equal(tctx, d1->dmScale, d2->dmScale, "dmScale mismatch");
+ torture_assert_int_equal(tctx, d1->dmCopies, d2->dmCopies, "dmCopies mismatch");
+ torture_assert_int_equal(tctx, d1->dmDefaultSource, d2->dmDefaultSource, "dmDefaultSource mismatch");
+ torture_assert_int_equal(tctx, d1->dmPrintQuality, d2->dmPrintQuality, "dmPrintQuality mismatch");
+
+ torture_assert_int_equal(tctx, d1->dmColor, d2->dmColor, "dmColor mismatch");
+ torture_assert_int_equal(tctx, d1->dmDuplex, d2->dmDuplex, "dmDuplex mismatch");
+ torture_assert_int_equal(tctx, d1->dmYResolution, d2->dmYResolution, "dmYResolution mismatch");
+ torture_assert_int_equal(tctx, d1->dmTTOption, d2->dmTTOption, "dmTTOption mismatch");
+ torture_assert_int_equal(tctx, d1->dmCollate, d2->dmCollate, "dmCollate mismatch");
+ torture_assert_str_equal(tctx, (const char *)d1->dmFormName, (const char *)d2->dmFormName, "dmFormName mismatch");
+ torture_assert_int_equal(tctx, d1->dmLogPixels, d2->dmLogPixels, "dmLogPixels mismatch");
+ torture_assert_int_equal(tctx, d1->dmBitsPerPel, d2->dmBitsPerPel, "dmBitsPerPel mismatch");
+ torture_assert_int_equal(tctx, d1->dmPelsWidth, d2->dmPelsWidth, "dmPelsWidth mismatch");
+ torture_assert_int_equal(tctx, d1->dmPelsHeight, d2->dmPelsHeight, "dmPelsHeight mismatch");
+
+ torture_assert_int_equal(tctx, d1->dmDisplayFlags, d2->dmDisplayFlags, "dmDisplayFlags mismatch");
+ /* or dmNup ? */
+ torture_assert_int_equal(tctx, d1->dmDisplayFrequency, d2->dmDisplayFrequency, "dmDisplayFrequency mismatch");
+
+ torture_assert_int_equal(tctx, d1->dmICMMethod, d2->dmICMMethod, "dmICMMethod mismatch");
+ torture_assert_int_equal(tctx, d1->dmICMIntent, d2->dmICMIntent, "dmICMIntent mismatch");
+ torture_assert_int_equal(tctx, d1->dmMediaType, d2->dmMediaType, "dmMediaType mismatch");
+ torture_assert_int_equal(tctx, d1->dmDitherType, d2->dmDitherType, "dmDitherType mismatch");
+ torture_assert_int_equal(tctx, d1->dmReserved1, d2->dmReserved1, "dmReserved1 mismatch");
+ torture_assert_int_equal(tctx, d1->dmReserved2, d2->dmReserved2, "reserved2 mismatch");
+
+ torture_assert_int_equal(tctx, d1->dmPanningWidth, d2->dmPanningWidth, "dmPanningWidth mismatch");
+ torture_assert_int_equal(tctx, d1->dmPanningHeight, d2->dmPanningHeight, "dmPanningHeight mismatch");
+
+ /* torture_assert_mem_equal(tctx, d1 + d1->dmSize, d2 + d2->dmSize, d1->dmDriverExtra, "private extra data mismatch"); */
+
+ return TRUE;
+}
+
+/****************************************************************************
+****************************************************************************/
+
+static BOOL test_DeviceModes(struct torture_context *tctx,
+ LPSTR printername,
+ HANDLE handle)
+{
+ PPRINTER_INFO_2 info2 = NULL;
+ PPRINTER_INFO_8 info8 = NULL;
+ DWORD needed = 0;
+ DWORD err = 0;
+ char tmp[1024];
+
+ torture_comment(tctx, "Testing DeviceModes");
+
+ torture_comment(tctx, "Testing GetPrinter level %d", 2);
+
+ GetPrinter(handle, 2, NULL, 0, &needed);
+ err = GetLastError();
+ if (err == ERROR_INSUFFICIENT_BUFFER) {
+ err = 0;
+ info2 = (PPRINTER_INFO_2)malloc(needed);
+ torture_assert(tctx, (LPBYTE)info2, "malloc failed");
+ if (!GetPrinter(handle, 2, (LPBYTE)info2, needed, &needed)) {
+ err = GetLastError();
+ }
+ }
+ if (err) {
+ sprintf(tmp, "GetPrinter failed level %d on [%s] (buffer size = %d), error: %s\n",
+ 2, printername, needed, errstr(err));
+ torture_fail(tctx, tmp);
+ }
+
+ if (tctx->print) {
+ print_printer_info_2(info2);
+ }
+
+ torture_comment(tctx, "Testing GetPrinter level %d", 8);
+
+ GetPrinter(handle, 8, NULL, 0, &needed);
+ err = GetLastError();
+ if (err == ERROR_INSUFFICIENT_BUFFER) {
+ err = 0;
+ info8 = (PPRINTER_INFO_8)malloc(needed);
+ torture_assert(tctx, (LPBYTE)info8, "malloc failed");
+ if (!GetPrinter(handle, 8, (LPBYTE)info8, needed, &needed)) {
+ err = GetLastError();
+ }
+ }
+ if (err) {
+ sprintf(tmp, "GetPrinter failed level %d on [%s] (buffer size = %d), error: %s\n",
+ 8, printername, needed, errstr(err));
+ torture_fail(tctx, tmp);
+ }
+
+ if (tctx->print) {
+ print_printer_info_8(info8);
+ }
+
+ torture_assert(tctx, test_devicemode_equal(tctx, info2->pDevMode, info8->pDevMode), "");
+
+ free(info2);
+ free(info8);
+
+ return TRUE;
+}
+
+/****************************************************************************
+****************************************************************************/
+
+static BOOL test_GetJob(struct torture_context *tctx,
+ LPSTR printername,
+ HANDLE handle,
+ DWORD job_id)
+{
+ DWORD levels[] = { 1, 2, 3, 4 };
+ DWORD success[] = { 1, 1, 1, 1 };
+ DWORD i;
+ LPBYTE buffer = NULL;
+
+ for (i=0; i < ARRAY_SIZE(levels); i++) {
+
+ DWORD needed = 0;
+ DWORD err = 0;
+ char tmp[1024];
+
+ torture_comment(tctx, "Testing GetJob(%d) level %d", job_id, levels[i]);
+
+ if (tctx->samba3 && (levels[i] == 4) || (levels[i] == 3)) {
+ torture_comment(tctx, "skipping level %d getjob against samba\n", levels[i]);
+ continue;
+ }
+
+ GetJob(handle, job_id, levels[i], NULL, 0, &needed);
+ err = GetLastError();
+ if (err == ERROR_INSUFFICIENT_BUFFER) {
+ err = 0;
+ buffer = malloc(needed);
+ torture_assert(tctx, buffer, "malloc failed");
+ if (!GetJob(handle, job_id, levels[i], buffer, needed, &needed)) {
+ err = GetLastError();
+ }
+ }
+ if (err) {
+ sprintf(tmp, "GetJob failed level %d on [%s] (buffer size = %d), error: %s\n",
+ levels[i], printername, needed, errstr(err));
+ if (success[i]) {
+ torture_fail(tctx, tmp);
+ } else {
+ torture_warning(tctx, tmp);
+ }
+ }
+
+ if (tctx->print) {
+ print_job_info_bylevel(levels[i], buffer, 1);
+ }
+
+ free(buffer);
+ buffer = NULL;
+ }
+
+ return TRUE;
+}
+
+/****************************************************************************
+****************************************************************************/
+
+static BOOL test_EachJob(struct torture_context *tctx,
+ LPSTR printername,
+ HANDLE handle)
+{
+ DWORD i;
+ PJOB_INFO_1 buffer = NULL;
+ DWORD needed = 0;
+ DWORD returned = 0;
+ DWORD err = 0;
+ DWORD level = 1;
+ char tmp[1024];
+ BOOL ret = TRUE;
+
+ torture_comment(tctx, "Testing Each PrintJob %d");
+
+ EnumJobs(handle, 0, 100, level, NULL, 0, &needed, &returned);
+ err = GetLastError();
+ if (err == ERROR_INSUFFICIENT_BUFFER) {
+ err = 0;
+ buffer = (PJOB_INFO_1)malloc(needed);
+ torture_assert(tctx, buffer, "malloc failed");
+ if (!EnumJobs(handle, 0, 100, level, (LPBYTE)buffer, needed, &needed, &returned)) {
+ err = GetLastError();
+ }
+ }
+ if (err) {
+ sprintf(tmp, "EnumJobs failed level %d on [%s] (buffer size = %d), error: %s\n",
+ level, printername, needed, errstr(err));
+ torture_fail(tctx, tmp);
+ }
+
+ if (tctx->print) {
+ print_job_info_bylevel(level, (LPBYTE)buffer, returned);
+ }
+
+ for (i=0; i < returned; i++) {
+ ret = test_GetJob(tctx, printername, handle, buffer[i].JobId);
+ }
+
+ free(buffer);
+
+ return ret;
+
+}
+
+/****************************************************************************
+****************************************************************************/
+
+static BOOL test_OnePrinter(struct torture_context *tctx,
+ LPSTR printername,
+ LPSTR architecture,
+ LPPRINTER_DEFAULTS defaults)
+{
+ HANDLE handle;
+ BOOL ret = TRUE;
+
+ torture_comment(tctx, "Testing Printer %s", printername);
+
+ ret &= test_OpenPrinter(tctx, printername, defaults, &handle);
+ ret &= test_GetPrinter(tctx, printername, handle);
+ ret &= test_GetPrinterDriver(tctx, printername, architecture, handle);
+ ret &= test_EnumForms(tctx, printername, handle);
+ ret &= test_EnumJobs(tctx, printername, handle);
+ ret &= test_EachJob(tctx, printername, handle);
+ ret &= test_EnumPrinterKey(tctx, printername, handle, "");
+ ret &= test_EnumPrinterKey(tctx, printername, handle, "PrinterDriverData");
+ ret &= test_EnumPrinterData(tctx, printername, handle);
+ ret &= test_EnumPrinterDataEx(tctx, printername, "PrinterDriverData", handle, NULL, NULL);
+ ret &= test_DeviceModes(tctx, printername, handle);
+#if 0
+ /* don't run these at the moment, behaviour is PrinterData API calls (not
+ * dcerpc calls) is almost unpredictable - gd */
+ ret &= test_PrinterData(tctx, printername, handle);
+ ret &= test_PrinterDataW(tctx, printername, handle);
+#endif
+ ret &= test_ClosePrinter(tctx, handle);
+
+ return ret;
+}
+
+/****************************************************************************
+****************************************************************************/
+
+static BOOL test_EachPrinter(struct torture_context *tctx,
+ LPSTR servername,
+ LPSTR architecture,
+ LPPRINTER_DEFAULTS defaults)
+{
+ DWORD needed = 0;
+ DWORD returned = 0;
+ DWORD err = 0;
+ char tmp[1024];
+ DWORD i;
+ DWORD flags = PRINTER_ENUM_NAME;
+ PPRINTER_INFO_1 buffer = NULL;
+ BOOL ret = TRUE;
+
+ torture_comment(tctx, "Testing EnumPrinters level %d", 1);
+
+ EnumPrinters(flags, servername, 1, NULL, 0, &needed, &returned);
+ err = GetLastError();
+ if (err == ERROR_INSUFFICIENT_BUFFER) {
+ err = 0;
+ buffer = (PPRINTER_INFO_1)malloc(needed);
+ torture_assert(tctx, buffer, "malloc failed");
+ if (!EnumPrinters(flags, servername, 1, (LPBYTE)buffer, needed, &needed, &returned)) {
+ err = GetLastError();
+ }
+ }
+ if (err) {
+ sprintf(tmp, "EnumPrinters failed level %d on [%s] (buffer size = %d), error: %s\n",
+ 1, servername, needed, errstr(err));
+ torture_fail(tctx, tmp);
+ }
+
+ for (i=0; i < returned; i++) {
+ ret &= test_OnePrinter(tctx, buffer[i].pName, architecture, defaults);
+ }
+
+ free(buffer);
+
+ return ret;
+}
+
+/****************************************************************************
+****************************************************************************/
+
+static BOOL test_GetPrintProcessorDirectory(struct torture_context *tctx,
+ LPSTR servername,
+ LPSTR architecture)
+{
+ DWORD levels[] = { 1 };
+ DWORD success[] = { 1 };
+ DWORD i;
+ LPBYTE buffer = NULL;
+
+ for (i=0; i < ARRAY_SIZE(levels); i++) {
+
+ DWORD needed = 0;
+ DWORD err = 0;
+ char tmp[1024];
+
+ torture_comment(tctx, "Testing GetPrintProcessorDirectory(%s) level %d",
+ architecture, levels[i]);
+
+ GetPrintProcessorDirectory(servername, architecture, levels[i], NULL, 0, &needed);
+ err = GetLastError();
+ if (err == ERROR_INSUFFICIENT_BUFFER) {
+ err = 0;
+ buffer = malloc(needed);
+ torture_assert(tctx, buffer, "malloc failed");
+ if (!GetPrintProcessorDirectory(servername, architecture, levels[i], buffer, needed, &needed)) {
+ err = GetLastError();
+ }
+ }
+ if (err) {
+ sprintf(tmp, "GetPrintProcessorDirectory failed level %d on [%s] (buffer size = %d), error: %s\n",
+ levels[i], servername, needed, errstr(err));
+ if (success[i]) {
+ torture_fail(tctx, tmp);
+ } else {
+ torture_warning(tctx, tmp);
+ }
+ }
+
+ if (tctx->print) {
+ printf("\tPrint Processor Directory\t= %s\n\n", (LPSTR)buffer);
+ }
+
+ free(buffer);
+ buffer = NULL;
+ }
+
+ return TRUE;
+}
+
+/****************************************************************************
+****************************************************************************/
+
+static BOOL test_GetPrinterDriverDirectory(struct torture_context *tctx,
+ LPSTR servername,
+ LPSTR architecture)
+{
+ DWORD levels[] = { 1 };
+ DWORD success[] = { 1 };
+ DWORD i;
+ LPBYTE buffer = NULL;
+
+ for (i=0; i < ARRAY_SIZE(levels); i++) {
+
+ DWORD needed = 0;
+ DWORD err = 0;
+ char tmp[1024];
+
+ torture_comment(tctx, "Testing GetPrinterDriverDirectory(%s) level %d",
+ architecture, levels[i]);
+
+ GetPrinterDriverDirectory(servername, architecture, levels[i], NULL, 0, &needed);
+ err = GetLastError();
+ if (err == ERROR_INSUFFICIENT_BUFFER) {
+ err = 0;
+ buffer = malloc(needed);
+ torture_assert(tctx, buffer, "malloc failed");
+ if (!GetPrinterDriverDirectory(servername, architecture, levels[i], buffer, needed, &needed)) {
+ err = GetLastError();
+ }
+ }
+ if (err) {
+ sprintf(tmp, "GetPrinterDriverDirectory failed level %d on [%s] (buffer size = %d), error: %s\n",
+ levels[i], servername, needed, errstr(err));
+ if (success[i]) {
+ torture_fail(tctx, tmp);
+ } else {
+ torture_warning(tctx, tmp);
+ }
+ }
+
+ if (tctx->print) {
+ printf("\tPrinter Driver Directory\t= %s\n\n", (LPSTR)buffer);
+ }
+
+ free(buffer);
+ buffer = NULL;
+ }
+
+ return TRUE;
+}
+
+/****************************************************************************
+****************************************************************************/
+
+static BOOL test_GetPrinterData(struct torture_context *tctx,
+ LPSTR servername,
+ LPSTR valuename,
+ HANDLE handle,
+ DWORD *type_p,
+ LPBYTE *buffer_p,
+ DWORD *size_p)
+{
+ LPBYTE buffer = NULL;
+ DWORD needed = 0;
+ DWORD type;
+ DWORD err = 0;
+ char tmp[1024];
+
+ torture_comment(tctx, "Testing GetPrinterData(%s)", valuename);
+
+ err = GetPrinterData(handle, valuename, &type, NULL, 0, &needed);
+ if (err == ERROR_MORE_DATA) {
+ buffer = (LPBYTE)malloc(needed);
+ torture_assert(tctx, buffer, "malloc failed");
+ err = GetPrinterData(handle, valuename, &type, buffer, needed, &needed);
+ }
+ if (err) {
+ sprintf(tmp, "GetPrinterData(%s) failed on [%s] (buffer size = %d), error: %s\n",
+ valuename, servername, needed, errstr(err));
+ torture_fail(tctx, tmp);
+ }
+
+ if (tctx->print) {
+ print_printer_data("PrinterDriverData", valuename, needed, buffer, type);
+ }
+
+ if (type_p) {
+ *type_p = type;
+ }
+
+ if (size_p) {
+ *size_p = needed;
+ }
+
+ if (buffer_p) {
+ *buffer_p = buffer;
+ } else {
+ free(buffer);
+ }
+
+ return TRUE;
+}
+
+/****************************************************************************
+****************************************************************************/
+
+static BOOL test_GetPrinterDataEx(struct torture_context *tctx,
+ LPSTR servername,
+ LPSTR keyname,
+ LPSTR valuename,
+ HANDLE handle,
+ DWORD *type_p,
+ LPBYTE *buffer_p,
+ DWORD *size_p)
+{
+ LPBYTE buffer = NULL;
+ DWORD needed = 0;
+ DWORD type;
+ DWORD err = 0;
+ char tmp[1024];
+
+ torture_comment(tctx, "Testing GetPrinterDataEx(%s - %s)", keyname, valuename);
+
+ err = GetPrinterDataEx(handle, keyname, valuename, &type, NULL, 0, &needed);
+ if (err == ERROR_MORE_DATA) {
+ buffer = (LPBYTE)malloc(needed);
+ torture_assert(tctx, buffer, "malloc failed");
+ err = GetPrinterDataEx(handle, keyname, valuename, &type, buffer, needed, &needed);
+ }
+ if (err) {
+ sprintf(tmp, "GetPrinterDataEx(%s) failed on [%s] (buffer size = %d), error: %s\n",
+ valuename, servername, needed, errstr(err));
+ torture_fail(tctx, tmp);
+ }
+
+ if (tctx->print) {
+ print_printer_data(keyname, valuename, needed, buffer, type);
+ }
+
+ if (type_p) {
+ *type_p = type;
+ }
+
+ if (size_p) {
+ *size_p = needed;
+ }
+
+ if (buffer_p) {
+ *buffer_p = buffer;
+ } else {
+ free(buffer);
+ }
+
+ return TRUE;
+}
+
+/****************************************************************************
+****************************************************************************/
+
+static BOOL test_GetPrinterDataExW(struct torture_context *tctx,
+ LPSTR servername,
+ LPCWSTR keyname,
+ LPCWSTR valuename,
+ HANDLE handle,
+ DWORD *type_p,
+ LPBYTE *buffer_p,
+ DWORD *size_p)
+{
+ LPBYTE buffer = NULL;
+ DWORD needed = 0;
+ DWORD type;
+ DWORD err = 0;
+ char tmp[1024];
+
+ torture_comment(tctx, "Testing GetPrinterDataExW(%ls - %ls)", keyname, valuename);
+
+ err = GetPrinterDataExW(handle, keyname, valuename, &type, NULL, 0, &needed);
+ if (err == ERROR_MORE_DATA) {
+ buffer = (LPBYTE)malloc(needed);
+ torture_assert(tctx, buffer, "malloc failed");
+ err = GetPrinterDataExW(handle, keyname, valuename, &type, buffer, needed, &needed);
+ }
+ if (err) {
+ sprintf(tmp, "GetPrinterDataExW(%ls) failed on [%s] (buffer size = %d), error: %s\n",
+ valuename, servername, needed, errstr(err));
+ torture_fail(tctx, tmp);
+ }
+
+ if (tctx->print) {
+ print_printer_dataw(keyname, valuename, needed, buffer, type);
+ }
+
+ if (type_p) {
+ *type_p = type;
+ }
+
+ if (size_p) {
+ *size_p = needed;
+ }
+
+ if (buffer_p) {
+ *buffer_p = buffer;
+ } else {
+ free(buffer);
+ }
+
+ return TRUE;
+}
+
+
+/****************************************************************************
+****************************************************************************/
+
+static BOOL test_DeletePrinterDataEx(struct torture_context *tctx,
+ LPSTR servername,
+ LPSTR keyname,
+ LPSTR valuename,
+ HANDLE handle)
+{
+ DWORD err = 0;
+ char tmp[1024];
+
+ torture_comment(tctx, "Testing DeletePrinterDataEx(%s - %s)", keyname, valuename);
+
+ err = DeletePrinterDataEx(handle, keyname, valuename);
+ if (err) {
+ sprintf(tmp, "DeletePrinterDataEx(%s - %s) failed on [%s], error: %s\n",
+ keyname, valuename, servername, errstr(err));
+ torture_fail(tctx, tmp);
+ }
+
+ return TRUE;
+}
+
+/****************************************************************************
+****************************************************************************/
+
+static BOOL test_DeletePrinterDataExW(struct torture_context *tctx,
+ LPSTR servername,
+ LPCWSTR keyname,
+ LPCWSTR valuename,
+ HANDLE handle)
+{
+ DWORD err = 0;
+ char tmp[1024];
+
+ torture_comment(tctx, "Testing DeletePrinterDataExW(%ls - %ls)", keyname, valuename);
+
+ err = DeletePrinterDataExW(handle, keyname, valuename);
+ if (err) {
+ sprintf(tmp, "DeletePrinterDataExW(%ls - %ls) failed on [%s], error: %s\n",
+ keyname, valuename, servername, errstr(err));
+ torture_fail(tctx, tmp);
+ }
+
+ return TRUE;
+}
+
+
+/****************************************************************************
+****************************************************************************/
+
+static BOOL test_DeletePrinterKey(struct torture_context *tctx,
+ LPSTR servername,
+ LPSTR keyname,
+ HANDLE handle)
+{
+ DWORD err = 0;
+ char tmp[1024];
+
+ torture_comment(tctx, "Testing DeletePrinterKey(%s)", keyname);
+
+ err = DeletePrinterKey(handle, keyname);
+ if (err) {
+ sprintf(tmp, "DeletePrinterKey(%s) failed on [%s], error: %s\n",
+ keyname, servername, errstr(err));
+ torture_fail(tctx, tmp);
+ }
+
+ return TRUE;
+}
+
+/****************************************************************************
+****************************************************************************/
+
+static BOOL test_DeletePrinterKeyW(struct torture_context *tctx,
+ LPSTR servername,
+ LPCWSTR keyname,
+ HANDLE handle)
+{
+ DWORD err = 0;
+ char tmp[1024];
+
+ torture_comment(tctx, "Testing DeletePrinterKeyW(%ls)", keyname);
+
+ err = DeletePrinterKeyW(handle, keyname);
+ if (err) {
+ sprintf(tmp, "DeletePrinterKeyW(%ls) failed on [%s], error: %s\n",
+ keyname, servername, errstr(err));
+ torture_fail(tctx, tmp);
+ }
+
+ return TRUE;
+}
+
+/****************************************************************************
+****************************************************************************/
+
+static BOOL test_SetPrinterDataEx(struct torture_context *tctx,
+ LPSTR servername,
+ LPSTR keyname,
+ LPSTR valuename,
+ HANDLE handle,
+ DWORD type,
+ LPBYTE buffer,
+ DWORD offered)
+{
+ DWORD err = 0;
+ char tmp[1024];
+
+ torture_comment(tctx, "Testing SetPrinterDataEx(%s - %s)", keyname, valuename);
+
+ err = SetPrinterDataEx(handle, keyname, valuename, type, buffer, offered);
+ if (err) {
+ sprintf(tmp, "SetPrinterDataEx(%s) failed on [%s] (buffer size = %d), error: %s\n",
+ valuename, servername, offered, errstr(err));
+ torture_fail(tctx, tmp);
+ }
+
+ return TRUE;
+}
+
+/****************************************************************************
+****************************************************************************/
+
+static BOOL test_SetPrinterDataExW(struct torture_context *tctx,
+ LPCSTR servername,
+ LPCWSTR keyname,
+ LPCWSTR valuename,
+ HANDLE handle,
+ DWORD type,
+ LPBYTE buffer,
+ DWORD offered)
+{
+ DWORD err = 0;
+ char tmp[1024];
+
+ torture_comment(tctx, "Testing SetPrinterDataExW(%ls - %ls)", keyname, valuename);
+
+ err = SetPrinterDataExW(handle, keyname, valuename, type, buffer, offered);
+ if (err) {
+ sprintf(tmp, "SetPrinterDataExW(%ls) failed on [%s] (buffer size = %d), error: %s\n",
+ valuename, servername, offered, errstr(err));
+ torture_fail(tctx, tmp);
+ }
+
+ return TRUE;
+}
+
+
+/****************************************************************************
+****************************************************************************/
+
+static BOOL test_PrinterData_Server(struct torture_context *tctx,
+ LPSTR servername,
+ HANDLE handle)
+{
+ BOOL ret = TRUE;
+ DWORD i;
+ DWORD type, type_ex;
+ LPBYTE buffer, buffer_ex;
+ DWORD size, size_ex;
+ LPSTR valuenames[] = {
+ SPLREG_DEFAULT_SPOOL_DIRECTORY,
+ SPLREG_MAJOR_VERSION,
+ SPLREG_MINOR_VERSION,
+ SPLREG_DS_PRESENT,
+ SPLREG_DNS_MACHINE_NAME,
+ SPLREG_ARCHITECTURE,
+ SPLREG_OS_VERSION
+ };
+
+ for (i=0; i < ARRAY_SIZE(valuenames); i++) {
+ ret &= test_GetPrinterData(tctx, servername, valuenames[i], handle, &type, &buffer, &size);
+ ret &= test_GetPrinterDataEx(tctx, servername, "random", valuenames[i], handle, &type_ex, &buffer_ex, &size_ex);
+ torture_assert_int_equal(tctx, type, type_ex, "type mismatch");
+ torture_assert_int_equal(tctx, size, size_ex, "size mismatch");
+ torture_assert_mem_equal(tctx, buffer, buffer_ex, size, "buffer mismatch");
+ free(buffer);
+ free(buffer_ex);
+ }
+
+ return ret;
+}
+
+/****************************************************************************
+****************************************************************************/
+
+static BOOL PrinterDataEqual(struct torture_context *tctx,
+ DWORD type1, DWORD type2,
+ DWORD size1, DWORD size2,
+ LPBYTE buffer1, LPBYTE buffer2)
+{
+ torture_assert_int_equal(tctx, type1, type2, "type mismatch");
+ torture_assert_int_equal(tctx, size1, size2, "size mismatch");
+ torture_assert_mem_equal(tctx, buffer1, buffer2, size1, "buffer mismatch");
+
+ return TRUE;
+}
+
+/****************************************************************************
+****************************************************************************/
+
+static BOOL test_PrinterData(struct torture_context *tctx,
+ LPSTR printername,
+ HANDLE handle)
+{
+ char tmp[1024];
+ LPSTR keyname = "torture_key";
+ LPSTR valuename = "torture_value";
+ BOOL ret = TRUE;
+ DWORD types[] = {
+ REG_SZ,
+ REG_DWORD,
+ REG_BINARY
+ };
+ DWORD value = 12345678;
+ LPSTR str = "abcdefghijklmnopqrstuvwxzy";
+ DWORD t, s;
+
+ for (t=0; t < ARRAY_SIZE(types); t++) {
+ for (s=0; s < strlen(str); s++) {
+
+ DWORD type, type_ex;
+ LPBYTE buffer, buffer_ex;
+ DWORD size, size_ex;
+
+ if (types[t] == REG_DWORD) {
+ s = 0xffff;
+ }
+
+ switch (types[t]) {
+ case REG_BINARY:
+ buffer = malloc(s);
+ memcpy(buffer, str, s);
+ size = s;
+ break;
+ case REG_DWORD:
+ buffer = malloc(4);
+ memcpy(buffer, &value, 4);
+ size = 4;
+ break;
+ case REG_SZ:
+ buffer = malloc(s);
+ memcpy(buffer, str, s);
+ size = s;
+ break;
+ default:
+ sprintf(tmp, "type %d untested\n", types[t]);
+ torture_fail(tctx, tmp);
+ break;
+ }
+
+ type = types[t];
+
+ torture_comment(tctx, "Testing PrinterData (type: %s, size: 0x%08x)", reg_type_str(type), size);
+
+ torture_assert(tctx,
+ test_SetPrinterDataEx(tctx, printername, keyname, valuename, handle, type, buffer, size),
+ "failed to call SetPrinterDataEx");
+ torture_assert(tctx,
+ test_GetPrinterDataEx(tctx, printername, keyname, valuename, handle, &type_ex, &buffer_ex, &size_ex),
+ "failed to call GetPrinterDataEx");
+
+ if (!PrinterDataEqual(tctx, type_ex, type, size_ex, size, buffer_ex, buffer)) {
+ torture_warning(tctx, "GetPrinterDataEx does not return the same info as we set with SetPrinterDataEx");
+ ret = FALSE;
+ }
+ ret &= test_DeletePrinterDataEx(tctx, printername, keyname, valuename, handle);
+ ret &= test_DeletePrinterKey(tctx, printername, keyname, handle);
+
+ free(buffer);
+ free(buffer_ex);
+ }
+ }
+
+ return ret;
+}
+
+/****************************************************************************
+****************************************************************************/
+
+static BOOL test_PrinterDataW(struct torture_context *tctx,
+ LPSTR printername,
+ HANDLE handle)
+{
+ char tmp[1024];
+ LPCWSTR keyname = L"torture_key";
+ LPCWSTR valuename = L"torture_value";
+ BOOL ret = TRUE;
+ DWORD types[] = {
+ REG_SZ,
+ REG_DWORD,
+ REG_BINARY
+ };
+ DWORD value = 12345678;
+ LPSTR str = "abcdefghijklmnopqrstuvwxzy";
+ DWORD t, s;
+
+ for (t=0; t < ARRAY_SIZE(types); t++) {
+ for (s=0; s < strlen(str); s++) {
+
+ DWORD type, type_ex;
+ LPBYTE buffer, buffer_ex;
+ DWORD size, size_ex;
+
+ if (types[t] == REG_DWORD) {
+ s = 0xffff;
+ }
+
+ switch (types[t]) {
+ case REG_BINARY:
+ buffer = malloc(s);
+ memcpy(buffer, str, s);
+ size = s;
+ break;
+ case REG_DWORD:
+ buffer = malloc(4);
+ memcpy(buffer, &value, 4);
+ size = 4;
+ break;
+ case REG_SZ:
+ buffer = malloc(s);
+ memcpy(buffer, str, s);
+ size = s;
+ break;
+ default:
+ sprintf(tmp, "type %d untested\n", types[t]);
+ torture_fail(tctx, tmp);
+ break;
+ }
+
+ type = types[t];
+
+ torture_comment(tctx, "Testing PrinterDataW (type: %s, size: 0x%08x)", reg_type_str(type), size);
+
+ torture_assert(tctx,
+ test_SetPrinterDataExW(tctx, printername, keyname, valuename, handle, type, buffer, size),
+ "failed to call SetPrinterDataExW");
+ torture_assert(tctx,
+ test_GetPrinterDataExW(tctx, printername, keyname, valuename, handle, &type_ex, &buffer_ex, &size_ex),
+ "failed to call GetPrinterDataExW");
+
+ if (!PrinterDataEqual(tctx, type_ex, type, size_ex, size, buffer_ex, buffer)) {
+ torture_warning(tctx, "GetPrinterDataExW does not return the same info as we set with SetPrinterDataExW");
+ ret = FALSE;
+ }
+ ret &= test_DeletePrinterDataExW(tctx, printername, keyname, valuename, handle);
+ ret &= test_DeletePrinterKeyW(tctx, printername, keyname, handle);
+
+ free(buffer);
+ free(buffer_ex);
+ }
+ }
+
+ return ret;
+}
+
+/****************************************************************************
+****************************************************************************/
+
+const char *get_string_param(const char *str)
+{
+ const char *p;
+
+ p = strchr(str, '=');
+ if (!p) {
+ return NULL;
+ }
+
+ return (p+1);
+}
+
+/****************************************************************************
+****************************************************************************/
+
+int main(int argc, char *argv[])
+{
+ BOOL ret = FALSE;
+ LPSTR servername;
+ LPSTR architecture = "Windows NT x86";
+ HANDLE server_handle;
+ PRINTER_DEFAULTS defaults_admin, defaults_use;
+ struct torture_context *tctx;
+ int i;
+
+ if (argc < 2) {
+ fprintf(stderr, "usage: %s <name> [print] [samba3] [architecture=ARCHITECTURE]\n\n", argv[0]);
+ fprintf(stderr, "\t<name> can be a server or printer name URI\n");
+ fprintf(stderr, "\t[print] will print all data that has been retrieved\n");
+ fprintf(stderr, "\t from the printserver\n");
+ fprintf(stderr, "\t[samba3] will skip some tests samba servers are known\n");
+ fprintf(stderr, "\t not to have implemented\n");
+ fprintf(stderr, "\t[architecture=X] allows one to define a specific\n");
+ fprintf(stderr, "\t architecture to test with. choose between:\n");
+ fprintf(stderr, "\t \"Windows NT x86\" or \"Windows x64\"\n");
+ exit(-1);
+ }
+
+ tctx = malloc(sizeof(struct torture_context));
+ if (!tctx) {
+ fprintf(stderr, "out of memory\n");
+ exit(-1);
+ }
+ memset(tctx, '\0', sizeof(*tctx));
+
+ servername = argv[1];
+
+ for (i=1; i < argc; i++) {
+ if (strcmp(argv[i], "print") == 0) {
+ tctx->print = TRUE;
+ }
+ if (strcmp(argv[i], "samba3") == 0) {
+ tctx->samba3 = TRUE;
+ }
+ if (strncmp(argv[i], "architecture", strlen("architecture")) == 0) {
+ architecture = get_string_param(argv[i]);
+ }
+ }
+
+ printf("Running testsuite with architecture: %s\n", architecture);
+
+ defaults_admin.pDatatype = NULL;
+ defaults_admin.pDevMode = NULL;
+ defaults_admin.DesiredAccess = PRINTER_ACCESS_ADMINISTER;
+
+ defaults_use.pDatatype = NULL;
+ defaults_use.pDevMode = NULL;
+ defaults_use.DesiredAccess = PRINTER_ACCESS_USE;
+
+ if ((servername[0] == '\\') && (servername[1] == '\\')) {
+ LPSTR p = servername+2;
+ LPSTR p2;
+ if ((p2 = strchr(p, '\\')) != NULL) {
+ ret = test_OnePrinter(tctx, servername, architecture, &defaults_admin);
+ goto done;
+ }
+ }
+
+ ret &= test_EnumPrinters(tctx, servername);
+ ret &= test_EnumDrivers(tctx, servername, architecture);
+ ret &= test_OpenPrinter(tctx, servername, NULL, &server_handle);
+/* ret &= test_EnumPrinterKey(tctx, servername, server_handle, ""); */
+ ret &= test_PrinterData_Server(tctx, servername, server_handle);
+ ret &= test_EnumForms(tctx, servername, server_handle);
+ ret &= test_ClosePrinter(tctx, server_handle);
+ ret &= test_EnumPorts(tctx, servername);
+ ret &= test_EnumMonitors(tctx, servername);
+ ret &= test_EnumPrintProcessors(tctx, servername, architecture);
+ ret &= test_EnumPrintProcessorDatatypes(tctx, servername);
+ ret &= test_GetPrintProcessorDirectory(tctx, servername, architecture);
+ ret &= test_GetPrinterDriverDirectory(tctx, servername, architecture);
+ ret &= test_EachPrinter(tctx, servername, architecture, &defaults_admin);
+
+ done:
+ if (!ret) {
+ if (tctx->last_reason) {
+ fprintf(stderr, "failed: %s\n", tctx->last_reason);
+ }
+ free(tctx);
+ return -1;
+ }
+
+ printf("%s run successfully\n", argv[0]);
+
+ free(tctx);
+ return 0;
+}
diff --git a/testprogs/win32/spoolss/testspoolss.h b/testprogs/win32/spoolss/testspoolss.h
new file mode 100644
index 0000000..eb19c64
--- /dev/null
+++ b/testprogs/win32/spoolss/testspoolss.h
@@ -0,0 +1,51 @@
+/*
+ Unix SMB/CIFS implementation.
+ test suite for spoolss rpc operations
+
+ Copyright (C) Guenther Deschner 2009
+
+ 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
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#if 0
+#include "lib/replace/replace.h"
+#endif
+
+#include <windows.h>
+#include <stdio.h>
+
+#include "error.h"
+#include "printlib_proto.h"
+
+#if 0
+#include <talloc.h>
+#include "libcli/util/ntstatus.h"
+#include "lib/torture/torture.h"
+#endif
+
+#ifndef ARRAY_SIZE
+#define ARRAY_SIZE(a) (sizeof(a)/sizeof(a[0]))
+#endif
+
+#ifndef true
+#define true TRUE
+#endif
+
+#ifndef false
+#define false FALSE
+#endif
+
+#ifndef PRINTER_ENUM_NAME
+#define PRINTER_ENUM_NAME 8
+#endif
diff --git a/testprogs/win32/spoolss/testspoolss.sln b/testprogs/win32/spoolss/testspoolss.sln
new file mode 100644
index 0000000..2082f5a
--- /dev/null
+++ b/testprogs/win32/spoolss/testspoolss.sln
@@ -0,0 +1,20 @@
+
+Microsoft Visual Studio Solution File, Format Version 10.00
+# Visual C++ Express 2008
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "testspoolss", "testspoolss.vcproj", "{60508731-0901-4B1D-9B11-DE070147DEF7}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Win32 = Debug|Win32
+ Release|Win32 = Release|Win32
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {60508731-0901-4B1D-9B11-DE070147DEF7}.Debug|Win32.ActiveCfg = Debug|Win32
+ {60508731-0901-4B1D-9B11-DE070147DEF7}.Debug|Win32.Build.0 = Debug|Win32
+ {60508731-0901-4B1D-9B11-DE070147DEF7}.Release|Win32.ActiveCfg = Release|Win32
+ {60508731-0901-4B1D-9B11-DE070147DEF7}.Release|Win32.Build.0 = Release|Win32
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+EndGlobal
diff --git a/testprogs/win32/spoolss/testspoolss.vcproj b/testprogs/win32/spoolss/testspoolss.vcproj
new file mode 100644
index 0000000..45544bc
--- /dev/null
+++ b/testprogs/win32/spoolss/testspoolss.vcproj
@@ -0,0 +1,224 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="9.00"
+ Name="testspoolss"
+ ProjectGUID="{60508731-0901-4B1D-9B11-DE070147DEF7}"
+ Keyword="Win32Proj"
+ TargetFrameworkVersion="0"
+ >
+ <Platforms>
+ <Platform
+ Name="Win32"
+ />
+ </Platforms>
+ <ToolFiles>
+ </ToolFiles>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory="Debug"
+ IntermediateDirectory="Debug"
+ ConfigurationType="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;"
+ MinimalRebuild="true"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="3"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ Detect64BitPortabilityProblems="true"
+ DebugInformationFormat="4"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ LinkIncremental="2"
+ GenerateDebugInformation="true"
+ SubSystem="1"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory="Release"
+ IntermediateDirectory="Release"
+ ConfigurationType="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;"
+ RuntimeLibrary="2"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ Detect64BitPortabilityProblems="true"
+ DebugInformationFormat="3"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ LinkIncremental="2"
+ GenerateDebugInformation="true"
+ SubSystem="1"
+ OptimizeReferences="2"
+ EnableCOMDATFolding="2"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <Filter
+ Name="Header Files"
+ Filter="h;hpp;hxx;hm;inl;inc;xsd"
+ UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
+ >
+ <File
+ RelativePath=".\error.h"
+ >
+ </File>
+ <File
+ RelativePath=".\printlib_proto.h"
+ >
+ </File>
+ <File
+ RelativePath=".\string.h"
+ >
+ </File>
+ <File
+ RelativePath=".\testspoolss.h"
+ >
+ </File>
+ <File
+ RelativePath=".\torture.h"
+ >
+ </File>
+ <File
+ RelativePath=".\torture_proto.h"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="Resource Files"
+ Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx"
+ UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
+ >
+ </Filter>
+ <Filter
+ Name="Source Files"
+ Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
+ UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
+ >
+ <File
+ RelativePath=".\error.c"
+ >
+ </File>
+ <File
+ RelativePath=".\printlib.c"
+ >
+ </File>
+ <File
+ RelativePath=".\testspoolss.c"
+ >
+ </File>
+ <File
+ RelativePath=".\torture.c"
+ >
+ </File>
+ </Filter>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>
diff --git a/testprogs/win32/spoolss/torture.c b/testprogs/win32/spoolss/torture.c
new file mode 100644
index 0000000..ff2824a
--- /dev/null
+++ b/testprogs/win32/spoolss/torture.c
@@ -0,0 +1,106 @@
+/*
+ Unix SMB/CIFS implementation.
+ SMB torture UI functions
+
+ Copyright (C) Jelmer Vernooij 2006
+
+ 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
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#include "testspoolss.h"
+#include "torture.h"
+
+/****************************************************************************
+****************************************************************************/
+
+void torture_warning(struct torture_context *context, const char *comment, ...)
+{
+ va_list ap;
+ char tmp[1024];
+
+#if 0
+ if (!context->results->ui_ops->warning)
+ return;
+#endif
+
+ va_start(ap, comment);
+ if (vsprintf(tmp, comment, ap) == -1) {
+ return;
+ }
+ va_end(ap);
+
+ fprintf(stderr, "WARNING: %s\n", tmp);
+#if 0
+ context->results->ui_ops->warning(context, tmp);
+
+ free(tmp);
+#endif
+}
+
+/****************************************************************************
+****************************************************************************/
+
+void torture_result(struct torture_context *context,
+ enum torture_result result, const char *fmt, ...)
+{
+ va_list ap;
+ char tmp[1024];
+
+ va_start(ap, fmt);
+
+ if (context->last_reason) {
+ torture_warning(context, "%s", context->last_reason);
+ free(context->last_reason);
+ context->last_reason = NULL;
+ }
+
+ context->last_result = result;
+ if (vsprintf(tmp, fmt, ap) == -1) {
+ return;
+ }
+ context->last_reason = malloc(sizeof(tmp));
+ if (!context->last_reason) {
+ return;
+ }
+ memcpy(context->last_reason, tmp, sizeof(tmp));
+
+ va_end(ap);
+}
+
+/****************************************************************************
+****************************************************************************/
+
+void torture_comment(struct torture_context *context, const char *comment, ...)
+{
+ va_list ap;
+ char tmp[1024];
+#if 0
+ if (!context->results->ui_ops->comment)
+ return;
+#endif
+ va_start(ap, comment);
+ if (vsprintf(tmp, comment, ap) == -1) {
+ return;
+ }
+ va_end(ap);
+
+#if 0
+ context->results->ui_ops->comment(context, tmp);
+#endif
+ fprintf(stdout, "%s\n", tmp);
+
+#if 0
+ free(tmp);
+#endif
+}
diff --git a/testprogs/win32/spoolss/torture.h b/testprogs/win32/spoolss/torture.h
new file mode 100644
index 0000000..7c9c443
--- /dev/null
+++ b/testprogs/win32/spoolss/torture.h
@@ -0,0 +1,92 @@
+/*
+ Unix SMB/CIFS implementation.
+ SMB torture UI functions
+
+ Copyright (C) Jelmer Vernooij 2006
+
+ 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
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#ifndef __TORTURE_UI_H__
+#define __TORTURE_UI_H__
+
+/****************************************************************************
+****************************************************************************/
+
+enum torture_result {
+ TORTURE_OK=0,
+ TORTURE_FAIL=1,
+ TORTURE_ERROR=2,
+ TORTURE_SKIP=3
+};
+
+struct torture_context {
+ enum torture_result last_result;
+ char *last_reason;
+ BOOL print;
+ BOOL samba3;
+};
+
+/****************************************************************************
+****************************************************************************/
+
+#define torture_assert(torture_ctx,expr,cmt) do {\
+ if (!(expr)) {\
+ torture_result(torture_ctx, TORTURE_FAIL, __location__": Expression `%s' failed: %s", __STRING(expr), cmt); \
+ return false;\
+ }\
+} while(0)
+
+#define torture_assert_str_equal(torture_ctx,got,expected,cmt)\
+ do { const char *__got = (got), *__expected = (expected); \
+ if (strcmp(__got, __expected) != 0) { \
+ torture_result(torture_ctx, TORTURE_FAIL, \
+ __location__": "#got" was %s, expected %s: %s", \
+ __got, __expected, cmt); \
+ return false; \
+ } \
+ } while(0)
+
+#define torture_assert_int_equal(torture_ctx,got,expected,cmt)\
+ do { int __got = (got), __expected = (expected); \
+ if (__got != __expected) { \
+ torture_result(torture_ctx, TORTURE_FAIL, \
+ __location__": "#got" was %d, expected %d: %s", \
+ __got, __expected, cmt); \
+ return false; \
+ } \
+ } while(0)
+
+#define torture_assert_mem_equal(torture_ctx,got,expected,len,cmt)\
+ do { const void *__got = (got), *__expected = (expected); \
+ if (memcmp(__got, __expected, len) != 0) { \
+ torture_result(torture_ctx, TORTURE_FAIL, \
+ __location__": "#got" of len %d did not match "#expected": %s", (int)len, cmt); \
+ return false; \
+ } \
+ } while(0)
+
+#define torture_skip(torture_ctx,cmt) do {\
+ torture_result(torture_ctx, TORTURE_SKIP, __location__": %s", cmt);\
+ return true; \
+ } while(0)
+
+#define torture_fail(torture_ctx,cmt) do {\
+ torture_result(torture_ctx, TORTURE_FAIL, __location__": %s", cmt);\
+ return false; \
+ } while (0)
+
+#include "torture_proto.h"
+
+#endif
diff --git a/testprogs/win32/spoolss/torture_proto.h b/testprogs/win32/spoolss/torture_proto.h
new file mode 100644
index 0000000..5d1dd88
--- /dev/null
+++ b/testprogs/win32/spoolss/torture_proto.h
@@ -0,0 +1,32 @@
+#ifndef __TORTURE_PROTO_H__
+#define __TORTURE_PROTO_H__
+
+#undef _PRINTF_ATTRIBUTE
+#define _PRINTF_ATTRIBUTE(a1, a2) PRINTF_ATTRIBUTE(a1, a2)
+/* This file was automatically generated by mkproto.pl. DO NOT EDIT */
+
+/* this file contains prototypes for functions that are private
+ * to this subsystem or library. These functions should not be
+ * used outside this particular subsystem! */
+
+
+/* The following definitions come from torture.c */
+
+
+/****************************************************************************
+****************************************************************************/
+void torture_warning(struct torture_context *context, const char *comment, ...);
+
+/****************************************************************************
+****************************************************************************/
+void torture_result(struct torture_context *context,
+ enum torture_result result, const char *fmt, ...);
+
+/****************************************************************************
+****************************************************************************/
+void torture_comment(struct torture_context *context, const char *comment, ...);
+#undef _PRINTF_ATTRIBUTE
+#define _PRINTF_ATTRIBUTE(a1, a2)
+
+#endif /* __TORTURE_PROTO_H__ */
+
diff --git a/testprogs/win32/testmailslot/GNUmakefile b/testprogs/win32/testmailslot/GNUmakefile
new file mode 100644
index 0000000..a41fb91
--- /dev/null
+++ b/testprogs/win32/testmailslot/GNUmakefile
@@ -0,0 +1,16 @@
+INCLUDES=-I.
+CFLAGS=$(INCLUDES)
+MINGW_CC = i586-mingw32msvc-cc
+CC = $(MINGW_CC)
+
+all: testmailslot.exe
+
+clean:
+ rm -f *~ *.obj testmailslot.exe
+
+.SUFFIXES: .obj .exe .c
+
+testmailslot.exe: testmailslot.c
+
+.c.exe:
+ $(CC) $(CFLAGS) -o $@ $^ $(LIBS)
diff --git a/testprogs/win32/testmailslot/NMakefile b/testprogs/win32/testmailslot/NMakefile
new file mode 100644
index 0000000..7551d7b
--- /dev/null
+++ b/testprogs/win32/testmailslot/NMakefile
@@ -0,0 +1,13 @@
+#
+# use nmake /f NMakefile [<target>]
+#
+INCLUDES=-I
+CFLAGS=$(INCLUDES) -Zi -nologo
+
+all: testmailslot.exe
+
+clean:
+ del *~ *.obj testmailslot.exe
+
+testmailslot.exe: testmailslot.obj
+ $(CC) $(CFLAGS) -o testmailslot.exe testmailslot.obj $(LIBS)
diff --git a/testprogs/win32/testmailslot/testmailslot.c b/testprogs/win32/testmailslot/testmailslot.c
new file mode 100644
index 0000000..b953636
--- /dev/null
+++ b/testprogs/win32/testmailslot/testmailslot.c
@@ -0,0 +1,80 @@
+/*
+ * Very simple test application for mailslots
+ * (C) 2005 Jelmer Vernooij <jelmer@samba.org>
+ * Published to the public domain
+ */
+
+#include <windows.h>
+#include <stdio.h>
+
+int read_slot(const char *mailslotname)
+{
+ HANDLE h;
+ DWORD nr;
+ char data[30000];
+ DWORD nextsize, nummsg = 0;
+
+ if (strncmp(mailslotname, "\\\\.\\mailslot\\", 13) && strncmp(mailslotname, "\\\\*\\mailslot\\", 13)) {
+ printf("Must specify local mailslot name (starting with \\\\.\\mailslot\\)\n");
+ return 1;
+ }
+
+ h = CreateMailslot(mailslotname, 0, MAILSLOT_WAIT_FOREVER, NULL);
+
+ if (h == INVALID_HANDLE_VALUE) {
+ printf("Unable to create mailslot %s: %d\n", mailslotname, GetLastError());
+ return 1;
+ }
+
+ if (!ReadFile(h, data, sizeof(data)-1, &nr, NULL)) {
+ printf("Error reading: %d\n", GetLastError());
+ return 1;
+ }
+
+ data[nr] = '\0';
+
+ printf("%s\n", data);
+
+ CloseHandle(h);
+}
+
+int write_slot(const char *mailslotname)
+{
+ HANDLE h;
+ DWORD nw;
+ char data[30000];
+ h = CreateFile(mailslotname, GENERIC_WRITE, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
+
+ if (h == INVALID_HANDLE_VALUE) {
+ printf("Unable to open file: %d\n", GetLastError());
+ return 1;
+ }
+
+ gets(data);
+
+ if (!WriteFile(h, data, strlen(data), &nw, NULL)) {
+ printf("Error writing file: %d\n", GetLastError());
+ return 1;
+ }
+
+ CloseHandle(h);
+}
+
+int main(int argc, char **argv)
+{
+ if (argc < 3 ||
+ (strcmp(argv[1], "read") && strcmp(argv[1], "write"))) {
+ printf("Usage: %s read|write mailslot\n", argv[0]);
+ return 1;
+ }
+
+ if (!strcmp(argv[1], "read")) {
+ return read_slot(argv[2]);
+ }
+
+ if (!strcmp(argv[1], "write")) {
+ return write_slot(argv[2]);
+ }
+
+ return 0;
+}
diff --git a/testprogs/win32/vs2010-metze.cmd b/testprogs/win32/vs2010-metze.cmd
new file mode 100644
index 0000000..de7a9d4
--- /dev/null
+++ b/testprogs/win32/vs2010-metze.cmd
@@ -0,0 +1,24 @@
+@echo off
+set ComSpec=C:\Windows\system32\cmd.exe
+set DevEnvDir=C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\
+set INCLUDE=C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE;C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\ATLMFC\INCLUDE;C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\include;
+set LIB=C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\LIB;C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\ATLMFC\LIB;C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\lib;
+set LIBPATH=C:\Windows\Microsoft.NET\Framework\v4.0.30319;C:\Windows\Microsoft.NET\Framework\v3.5;C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\LIB;C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\ATLMFC\LIB;
+set Path=C:\Program Files (x86)\Microsoft Visual Studio 10.0\VSTSDB\Deploy;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\;C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\BIN;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\Tools;C:\Windows\Microsoft.NET\Framework\v4.0.30319;C:\Windows\Microsoft.NET\Framework\v3.5;C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\VCPackages;C:\Program Files (x86)\HTML Help Workshop;C:\Program Files (x86)\HTML Help Workshop;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Performance Tools;C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\bin\NETFX 4.0 Tools;C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\idmu\common
+set PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC
+set PSModulePath=C:\Windows\system32\WindowsPowerShell\v1.0\Modules\
+set VCINSTALLDIR=C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\
+set VisualStudioDir=C:\Users\Administrator\Documents\Visual Studio 2010
+set VS100COMNTOOLS=C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\Tools\
+set VSINSTALLDIR=C:\Program Files (x86)\Microsoft Visual Studio 10.0\
+set WindowsSdkDir=C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\
+cls
+cd C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC
+C:
+call vcvarsall.bat help
+
+echo #
+echo # You may want to enter 'C:' followed by 'vcvarsall.bat amd64' and 'Y:'
+echo #
+Y:
+@cmd.exe
diff --git a/testprogs/win32/wmi/echoprocessor.vbs b/testprogs/win32/wmi/echoprocessor.vbs
new file mode 100755
index 0000000..8ce6f7a
--- /dev/null
+++ b/testprogs/win32/wmi/echoprocessor.vbs
@@ -0,0 +1,10 @@
+For Each Host In WScript.Arguments
+ Set WMIservice = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & host & "\root\cimv2")
+
+ Set colsettings = WMIservice.ExecQuery("SELECT * FROM Win32_Processor")
+
+
+ For Each proc In colsettings
+ Wscript.Echo(host & ": " & proc.description)
+ Next
+Next