char *pserver = NULL;
bool connected_ok = False;
struct named_mutex *mutex = NULL;
+ NTSTATUS status;
if (!(cli = cli_initialise()))
return NULL;
p = pserver;
while(next_token_talloc(mem_ctx, &p, &desthost, LIST_SEP)) {
- NTSTATUS status;
desthost = talloc_sub_basic(mem_ctx,
current_user_info.smb_name,
DEBUG(3,("got session\n"));
- if (!cli_negprot(cli)) {
+ status = cli_negprot(cli);
+
+ if (!NT_STATUS_IS_OK(status)) {
TALLOC_FREE(mutex);
- DEBUG(1,("%s rejected the negprot\n",desthost));
+ DEBUG(1, ("%s rejected the negprot: %s\n",
+ desthost, nt_errstr(status)));
cli_shutdown(cli);
return NULL;
}
const char *share, const char *dev, const char *pass, int passlen);
bool cli_tdis(struct cli_state *cli);
void cli_negprot_sendsync(struct cli_state *cli);
-bool cli_negprot(struct cli_state *cli);
+NTSTATUS cli_negprot(struct cli_state *cli);
bool cli_session_request(struct cli_state *cli,
struct nmb_name *calling, struct nmb_name *called);
NTSTATUS cli_connect(struct cli_state *cli,
Send a negprot command.
****************************************************************************/
-bool cli_negprot(struct cli_state *cli)
+NTSTATUS cli_negprot(struct cli_state *cli)
{
char *p;
int numprots;
SCVAL(smb_buf(cli->outbuf),0,2);
cli_send_smb(cli);
- if (!cli_receive_smb(cli))
- return False;
+ if (!cli_receive_smb(cli)) {
+ return NT_STATUS_UNEXPECTED_IO_ERROR;
+ }
show_msg(cli->inbuf);
- if (cli_is_error(cli) ||
- ((int)SVAL(cli->inbuf,smb_vwv0) >= numprots)) {
- return(False);
+ if (cli_is_error(cli)) {
+ return cli_nt_error(cli);
+ }
+
+ if ((int)SVAL(cli->inbuf,smb_vwv0) >= numprots) {
+ return NT_STATUS_INVALID_NETWORK_RESPONSE;
}
cli->protocol = prots[SVAL(cli->inbuf,smb_vwv0)].prot;
if ((cli->protocol < PROTOCOL_NT1) && cli->sign_info.mandatory_signing) {
DEBUG(0,("cli_negprot: SMB signing is mandatory and the selected protocol level doesn't support it.\n"));
- return False;
+ return NT_STATUS_ACCESS_DENIED;
}
if (cli->protocol >= PROTOCOL_NT1) {
/* Fail if server says signing is mandatory and we don't want to support it. */
if (!cli->sign_info.allow_smb_signing) {
DEBUG(0,("cli_negprot: SMB signing is mandatory and we have disabled it.\n"));
- return False;
+ return NT_STATUS_ACCESS_DENIED;
}
cli->sign_info.negotiated_smb_signing = True;
cli->sign_info.mandatory_signing = True;
/* Fail if client says signing is mandatory and the server doesn't support it. */
if (!(cli->sec_mode & NEGOTIATE_SECURITY_SIGNATURES_ENABLED)) {
DEBUG(1,("cli_negprot: SMB signing is mandatory and the server doesn't support it.\n"));
- return False;
+ return NT_STATUS_ACCESS_DENIED;
}
cli->sign_info.negotiated_smb_signing = True;
cli->sign_info.mandatory_signing = True;
if (getenv("CLI_FORCE_ASCII"))
cli->capabilities &= ~CAP_UNICODE;
- return True;
+ return NT_STATUS_OK;
}
/****************************************************************************
cli->fallback_after_kerberos = true;
}
- if (!cli_negprot(cli)) {
- DEBUG(1,("failed negprot\n"));
- nt_status = cli_nt_error(cli);
- if (NT_STATUS_IS_OK(nt_status)) {
- nt_status = NT_STATUS_UNSUCCESSFUL;
- }
+ nt_status = cli_negprot(cli);
+ if (!NT_STATUS_IS_OK(nt_status)) {
+ DEBUG(1, ("failed negprot: %s\n", nt_errstr(nt_status)));
cli_shutdown(cli);
return nt_status;
}
DEBUG(4,(" session request ok\n"));
- if (!cli_negprot(c)) {
- d_printf("protocol negotiation failed\n");
+ status = cli_negprot(c);
+
+ if (!NT_STATUS_IS_OK(status)) {
+ d_printf("protocol negotiation failed: %s\n",
+ nt_errstr(status));
cli_shutdown(c);
return NULL;
}
DEBUG(4,(" session request ok\n"));
- if (!cli_negprot(c)) {
+ status = cli_negprot(c);
+
+ if (!NT_STATUS_IS_OK(status)) {
cli_shutdown(c);
errno = ETIMEDOUT;
return NULL;
cli->protocol = PROTOCOL_NT1;
- if (!cli_negprot(cli)) {
+ result = cli_negprot(cli);
+
+ if (!NT_STATUS_IS_OK(result)) {
asprintf(err_str, "machine %s rejected the negotiate "
"protocol. Error was : %s.\n",
- remote_machine, cli_errstr(cli) );
+ remote_machine, nt_errstr(result));
result = cli_nt_error(cli);
cli_shutdown(cli);
return result;
return;
}
- if (!cli_negprot(cli)) {
+ status = cli_negprot(cli);
+ if (!NT_STATUS_IS_OK(status)) {
cli_shutdown(cli);
return;
}
DEBUG(4,(" session request ok\n"));
- if (!cli_negprot(c)) {
- DEBUG(0,("protocol negotiation failed\n"));
+ status = cli_negprot(c);
+ if (!NT_STATUS_IS_OK(status)) {
+ DEBUG(0, ("protocol negotiation failed: %s\n",
+ nt_errstr(status)));
cli_shutdown(c);
return NULL;
}
DEBUG(4,(" session request ok\n"));
- if (!cli_negprot(c)) {
- DEBUG(0,("protocol negotiation failed\n"));
+ status = cli_negprot(c);
+ if (!NT_STATUS_IS_OK(status)) {
+ DEBUG(0, ("protocol negotiation failed: %s\n",
+ nt_errstr(status)));
cli_shutdown(c);
return NULL;
}
static struct cli_state *c_dos;
static struct cli_state *c_nt;
+ NTSTATUS status;
uint32 error;
c_nt->use_spnego = False;
- if (!cli_negprot(c_nt)) {
- printf("%s rejected the NT-error negprot (%s)\n",host, cli_errstr(c_nt));
+ status = cli_negprot(c_nt);
+
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("%s rejected the NT-error negprot (%s)\n", host,
+ nt_errstr(status));
cli_shutdown(c_nt);
return False;
}
c_dos->use_spnego = False;
c_dos->force_dos_errors = True;
- if (!cli_negprot(c_dos)) {
- printf("%s rejected the DOS-error negprot (%s)\n",host, cli_errstr(c_dos));
+ status = cli_negprot(c_dos);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("%s rejected the DOS-error negprot (%s)\n", host,
+ nt_errstr(status));
cli_shutdown(c_dos);
return False;
}
return false;
}
- if (!cli_negprot(c)) {
+ status = cli_negprot(c);
+ if (!NT_STATUS_IS_OK(status)) {
printf("%s rejected the NT-error negprot (%s)\n", host,
- cli_errstr(c));
+ nt_errstr(status));
cli_shutdown(c);
return false;
}
if (!attempt_netbios_session_request(&cli, global_myname(),
server_name, &server_ss))
goto done;
- if (!cli_negprot(cli))
+ status = cli_negprot(cli);
+ if (!NT_STATUS_IS_OK(status))
goto done;
if (cli->protocol < PROTOCOL_NT1)
goto done;
fprintf(stderr,"Session request failed\n");
goto done;
}
- if (!cli_negprot(cli)) {
- fprintf(stderr,"Protocol negotiation failed\n");
+ status = cli_negprot(cli);
+ if (!NT_STATUS_IS_OK(status)) {
+ fprintf(stderr, "Protocol negotiation failed: %s\n",
+ nt_errstr(status));
goto done;
}
cli_setup_signing_state(*cli, Undefined);
- if (!cli_negprot(*cli)) {
- DEBUG(1, ("cli_negprot failed\n"));
- result = NT_STATUS_UNSUCCESSFUL;
+ result = cli_negprot(*cli);
+
+ if (!NT_STATUS_IS_OK(result)) {
+ DEBUG(1, ("cli_negprot failed: %s\n", nt_errstr(result)));
goto done;
}