summaryrefslogtreecommitdiff
path: root/source3/libsmb
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2016-10-30 16:42:45 +0100
committerAndreas Schneider <asn@cryptomilk.org>2016-12-21 18:35:13 +0100
commit151e37b548bdba582bcbe7a216cd9b420d29b7b6 (patch)
treedd84161795ea833c57a45a60b21c9bb9205386db /source3/libsmb
parentc478f688c29f0b9ff114cf2554c1c6cb273c98e4 (diff)
downloadsamba-151e37b548bdba582bcbe7a216cd9b420d29b7b6.tar.gz
s3:libsmb: avoid using cli_session_setup() in SMBC_server_internal()
Using cli_session_creds_init() will allow it to be passed to other sub functions later. Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org>
Diffstat (limited to 'source3/libsmb')
-rw-r--r--source3/libsmb/libsmb_server.c33
1 files changed, 27 insertions, 6 deletions
diff --git a/source3/libsmb/libsmb_server.c b/source3/libsmb/libsmb_server.c
index e0cdc97eeb6..4ea0550971e 100644
--- a/source3/libsmb/libsmb_server.c
+++ b/source3/libsmb/libsmb_server.c
@@ -281,6 +281,11 @@ SMBC_server_internal(TALLOC_CTX *ctx,
int flags = 0;
struct smbXcli_tcon *tcon = NULL;
int signing_state = SMB_SIGNING_DEFAULT;
+ struct cli_credentials *creds = NULL;
+ bool use_kerberos = false;
+ bool fallback_after_kerberos = false;
+ bool use_ccache = false;
+ bool pw_nt_hash = false;
ZERO_STRUCT(c);
*in_cache = false;
@@ -432,18 +437,22 @@ SMBC_server_internal(TALLOC_CTX *ctx,
if (smbc_getOptionUseKerberos(context)) {
flags |= CLI_FULL_CONNECTION_USE_KERBEROS;
+ use_kerberos = true;
}
if (smbc_getOptionFallbackAfterKerberos(context)) {
flags |= CLI_FULL_CONNECTION_FALLBACK_AFTER_KERBEROS;
+ fallback_after_kerberos = true;
}
if (smbc_getOptionUseCCache(context)) {
flags |= CLI_FULL_CONNECTION_USE_CCACHE;
+ use_ccache = true;
}
if (smbc_getOptionUseNTHash(context)) {
flags |= CLI_FULL_CONNECTION_USE_NT_HASH;
+ pw_nt_hash = true;
}
if (context->internal->smb_encryption_level != SMBC_ENCRYPTLEVEL_NONE) {
@@ -494,18 +503,30 @@ SMBC_server_internal(TALLOC_CTX *ctx,
username_used = *pp_username;
password_used = *pp_password;
- if (!NT_STATUS_IS_OK(cli_session_setup(c, username_used,
- password_used,
- *pp_workgroup))) {
+ creds = cli_session_creds_init(c,
+ username_used,
+ *pp_workgroup,
+ NULL, /* realm */
+ password_used,
+ use_kerberos,
+ fallback_after_kerberos,
+ use_ccache,
+ pw_nt_hash);
+ if (creds == NULL) {
+ cli_shutdown(c);
+ errno = ENOMEM;
+ return NULL;
+ }
+
+ status = cli_session_setup_creds(c, creds);
+ if (!NT_STATUS_IS_OK(status)) {
/* Failed. Try an anonymous login, if allowed by flags. */
username_used = "";
password_used = "";
if (smbc_getOptionNoAutoAnonymousLogin(context) ||
- !NT_STATUS_IS_OK(cli_session_setup(c, username_used,
- password_used,
- *pp_workgroup))) {
+ !NT_STATUS_IS_OK(cli_session_setup_anon(c))) {
cli_shutdown(c);
errno = EPERM;