summaryrefslogtreecommitdiff
path: root/source4/torture/libsmbclient
diff options
context:
space:
mode:
authorAndreas Schneider <asn@samba.org>2018-09-03 16:36:54 +0200
committerJeremy Allison <jra@samba.org>2018-09-05 18:22:24 +0200
commit931e64d2e9e42707c53d32a6cc5006ec734ae4ab (patch)
tree28767654e69bdebc98acd73afaf95612e877dbd4 /source4/torture/libsmbclient
parent0dae4e2f5c65167fdb2405e232436921a0bb17e6 (diff)
downloadsamba-931e64d2e9e42707c53d32a6cc5006ec734ae4ab.tar.gz
s4:torture: Set credentials for libsmbclient correctly
Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
Diffstat (limited to 'source4/torture/libsmbclient')
-rw-r--r--source4/torture/libsmbclient/libsmbclient.c40
1 files changed, 38 insertions, 2 deletions
diff --git a/source4/torture/libsmbclient/libsmbclient.c b/source4/torture/libsmbclient/libsmbclient.c
index fb27ddd0326..853d002aa8d 100644
--- a/source4/torture/libsmbclient/libsmbclient.c
+++ b/source4/torture/libsmbclient/libsmbclient.c
@@ -40,9 +40,39 @@ static void debug_callback(void *private_ptr, int level, const char *msg)
return;
}
+static void auth_callback(const char *srv,
+ const char *shr,
+ char *wg, int wglen,
+ char *un, int unlen,
+ char *pw, int pwlen)
+{
+ const char *workgroup =
+ cli_credentials_get_domain(popt_get_cmdline_credentials());
+ const char *username =
+ cli_credentials_get_username(popt_get_cmdline_credentials());
+ const char *password =
+ cli_credentials_get_password(popt_get_cmdline_credentials());
+
+ if (workgroup != NULL) {
+ snprintf(wg, wglen, "%s", workgroup);
+ }
+
+ if (username != NULL) {
+ snprintf(un, unlen, "%s", username);
+ }
+
+ if (password != NULL) {
+ snprintf(pw, pwlen, "%s", password);
+ }
+};
+
bool torture_libsmbclient_init_context(struct torture_context *tctx,
SMBCCTX **ctx_p)
{
+ const char *workgroup =
+ cli_credentials_get_domain(popt_get_cmdline_credentials());
+ const char *username =
+ cli_credentials_get_username(popt_get_cmdline_credentials());
SMBCCTX *ctx = NULL;
SMBCCTX *p = NULL;
bool ok = true;
@@ -64,8 +94,14 @@ bool torture_libsmbclient_init_context(struct torture_context *tctx,
smbc_setDebug(ctx, DEBUGLEVEL);
smbc_setOptionDebugToStderr(ctx, 1);
- smbc_setUser(ctx,
- cli_credentials_get_username(popt_get_cmdline_credentials()));
+ if (workgroup != NULL) {
+ smbc_setWorkgroup(ctx, workgroup);
+ }
+ if (username != NULL) {
+ smbc_setUser(ctx, username);
+ }
+
+ smbc_setFunctionAuthData(ctx, auth_callback);
*ctx_p = ctx;