diff options
-rwxr-xr-x | source3/selftest/tests.py | 19 | ||||
-rwxr-xr-x | source4/selftest/tests.py | 6 | ||||
-rw-r--r-- | source4/torture/libsmbclient/libsmbclient.c | 57 |
3 files changed, 75 insertions, 7 deletions
diff --git a/source3/selftest/tests.py b/source3/selftest/tests.py index ed241f002da..3b6735231de 100755 --- a/source3/selftest/tests.py +++ b/source3/selftest/tests.py @@ -431,7 +431,10 @@ unix = ["unix.info2", "unix.whoami"] nbt = ["nbt.dgram"] -libsmbclient = ["libsmbclient"] +libsmbclient = ["libsmbclient.version", "libsmbclient.initialize", + "libsmbclient.configuration", "libsmbclient.setConfiguration", + "libsmbclient.options", "libsmbclient.opendir", + "libsmbclient.list_shares", "libsmbclient.readdirplus"] vfs = ["vfs.fruit", "vfs.acl_xattr", "vfs.fruit_netatalk", "vfs.fruit_file_id", "vfs.fruit_timemachine"] @@ -579,13 +582,17 @@ for t in tests: elif t == "rpc.samba3.netlogon" or t == "rpc.samba3.sessionkey": plansmbtorture4testsuite(t, "nt4_dc", '//$SERVER_IP/tmp -U$USERNAME%$PASSWORD --option=torture:wksname=samba3rpctest') plansmbtorture4testsuite(t, "ad_dc", '//$SERVER/tmp -U$USERNAME%$PASSWORD --option=torture:wksname=samba3rpctest') - elif t == "libsmbclient": + elif t.startswith("libsmbclient"): + url = "smb://$USERNAME:$PASSWORD@$SERVER/tmp" + if t == "libsmbclient.list_shares": + url = "smb://$USERNAME:$PASSWORD@$SERVER" + plansmbtorture4testsuite(t, "nt4_dc", '//$SERVER_IP/tmp -U$USERNAME%%$PASSWORD ' - '--option=torture:smburl=smb://$USERNAME:$PASSWORD@$SERVER/tmp ' - '--option=torture:replace_smbconf=%s' % os.path.join(srcdir(), "testdata/samba3/smb_new.conf")) + '--option=torture:smburl=' + url + + ' --option=torture:replace_smbconf=%s' % os.path.join(srcdir(), "testdata/samba3/smb_new.conf")) plansmbtorture4testsuite(t, "ad_dc", '//$SERVER/tmp -U$USERNAME%%$PASSWORD ' - '--option=torture:smburl=smb://$USERNAME:$PASSWORD@$SERVER/tmp ' - '--option=torture:replace_smbconf=%s' % os.path.join(srcdir(), "testdata/samba3/smb_new.conf")) + '--option=torture:smburl=' + url + + ' --option=torture:replace_smbconf=%s' % os.path.join(srcdir(), "testdata/samba3/smb_new.conf")) elif t == "smb2.streams": plansmbtorture4testsuite(t, "nt4_dc", '//$SERVER_IP/tmp -U$USERNAME%$PASSWORD') plansmbtorture4testsuite(t, "ad_dc", '//$SERVER/tmp -U$USERNAME%$PASSWORD') diff --git a/source4/selftest/tests.py b/source4/selftest/tests.py index b0584928c3a..eb85fecbcc6 100755 --- a/source4/selftest/tests.py +++ b/source4/selftest/tests.py @@ -327,7 +327,11 @@ for t in base + raw + smb2 + netapi: libsmbclient = smbtorture4_testsuites("libsmbclient.") for t in libsmbclient: - libsmbclient_testargs = ["--option=torture:smburl=smb://$USERNAME:$PASSWORD@$SERVER/tmp", + url = "smb://$USERNAME:$PASSWORD@$SERVER/tmp" + if t == "libsmbclient.list_shares": + url = "smb://$USERNAME:$PASSWORD@$SERVER" + + libsmbclient_testargs = ["--option=torture:smburl=" + url, "--option=torture:replace_smbconf=%s/testdata/samba3/smb_new.conf" % srcdir()] plansmbtorture4testsuite(t, "ad_dc", ['//$SERVER/tmp', '-U$USERNAME%$PASSWORD'] + libsmbclient_testargs) diff --git a/source4/torture/libsmbclient/libsmbclient.c b/source4/torture/libsmbclient/libsmbclient.c index b8fab225d90..fb27ddd0326 100644 --- a/source4/torture/libsmbclient/libsmbclient.c +++ b/source4/torture/libsmbclient/libsmbclient.c @@ -522,6 +522,62 @@ done: return ok; } +static bool torture_libsmbclient_list_shares(struct torture_context *tctx) +{ + const char *smburl = torture_setting_string(tctx, "smburl", NULL); + struct smbc_dirent *dirent = NULL; + SMBCCTX *ctx = NULL; + int dhandle = -1; + bool ipc_share_found = false; + bool ok = true; + + if (smburl == NULL) { + torture_fail(tctx, + "option --option=torture:smburl=" + "smb://user:password@server missing\n"); + } + + ok = torture_libsmbclient_init_context(tctx, &ctx); + torture_assert_goto(tctx, + ok, + ok, + out, + "Failed to init context"); + smbc_set_context(ctx); + + torture_comment(tctx, "Listing: %s\n", smburl); + dhandle = smbc_opendir(smburl); + torture_assert_int_not_equal_goto(tctx, + dhandle, + -1, + ok, + out, + "Failed to open smburl"); + + while((dirent = smbc_readdir(dhandle)) != NULL) { + torture_comment(tctx, "DIR: %s\n", dirent->name); + torture_assert_not_null_goto(tctx, + dirent->name, + ok, + out, + "Failed to read name"); + + if (strequal(dirent->name, "IPC$")) { + ipc_share_found = true; + } + } + + torture_assert_goto(tctx, + ipc_share_found, + ok, + out, + "Failed to list IPC$ share"); + +out: + smbc_closedir(dhandle); + return ok; +} + NTSTATUS torture_libsmbclient_init(TALLOC_CTX *ctx) { struct torture_suite *suite; @@ -534,6 +590,7 @@ NTSTATUS torture_libsmbclient_init(TALLOC_CTX *ctx) torture_suite_add_simple_test(suite, "setConfiguration", torture_libsmbclient_setConfiguration); torture_suite_add_simple_test(suite, "options", torture_libsmbclient_options); torture_suite_add_simple_test(suite, "opendir", torture_libsmbclient_opendir); + torture_suite_add_simple_test(suite, "list_shares", torture_libsmbclient_list_shares); torture_suite_add_simple_test(suite, "readdirplus", torture_libsmbclient_readdirplus); |