diff options
author | Volker Lendecke <vl@samba.org> | 2008-09-11 18:57:49 +0200 |
---|---|---|
committer | Volker Lendecke <vl@samba.org> | 2008-12-19 10:28:30 +0100 |
commit | bb8ca0fdbf0fe68ad2cd47d6f8d68743bfbacdec (patch) | |
tree | 99e4cf8220c138e0fce24d8fc87b7f23fb156905 /source3/libsmb | |
parent | 96a3d7be3151c93db9857bb065721c0c7961b2e8 (diff) | |
download | samba-bb8ca0fdbf0fe68ad2cd47d6f8d68743bfbacdec.tar.gz samba-bb8ca0fdbf0fe68ad2cd47d6f8d68743bfbacdec.tar.bz2 samba-bb8ca0fdbf0fe68ad2cd47d6f8d68743bfbacdec.zip |
Make cli_negprot return NTSTATUS instead of bool
Diffstat (limited to 'source3/libsmb')
-rw-r--r-- | source3/libsmb/cliconnect.c | 33 | ||||
-rw-r--r-- | source3/libsmb/clidfs.c | 7 | ||||
-rw-r--r-- | source3/libsmb/libsmb_server.c | 4 | ||||
-rw-r--r-- | source3/libsmb/passchange.c | 6 |
4 files changed, 29 insertions, 21 deletions
diff --git a/source3/libsmb/cliconnect.c b/source3/libsmb/cliconnect.c index f7950823a7..f34b38106a 100644 --- a/source3/libsmb/cliconnect.c +++ b/source3/libsmb/cliconnect.c @@ -1241,7 +1241,7 @@ void cli_negprot_sendsync(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; @@ -1279,21 +1279,25 @@ bool cli_negprot(struct cli_state *cli) 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) { @@ -1331,7 +1335,7 @@ bool cli_negprot(struct cli_state *cli) /* 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; @@ -1339,7 +1343,7 @@ bool cli_negprot(struct cli_state *cli) /* 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; @@ -1381,7 +1385,7 @@ bool cli_negprot(struct cli_state *cli) if (getenv("CLI_FORCE_ASCII")) cli->capabilities &= ~CAP_UNICODE; - return True; + return NT_STATUS_OK; } /**************************************************************************** @@ -1667,12 +1671,9 @@ again: 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; } diff --git a/source3/libsmb/clidfs.c b/source3/libsmb/clidfs.c index f0ac39fed0..4597e63c98 100644 --- a/source3/libsmb/clidfs.c +++ b/source3/libsmb/clidfs.c @@ -195,8 +195,11 @@ static struct cli_state *do_connect(TALLOC_CTX *ctx, 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; } diff --git a/source3/libsmb/libsmb_server.c b/source3/libsmb/libsmb_server.c index 5e37871deb..f4714346d1 100644 --- a/source3/libsmb/libsmb_server.c +++ b/source3/libsmb/libsmb_server.c @@ -433,7 +433,9 @@ again: 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; diff --git a/source3/libsmb/passchange.c b/source3/libsmb/passchange.c index 4c76234e0c..2746a4681e 100644 --- a/source3/libsmb/passchange.c +++ b/source3/libsmb/passchange.c @@ -71,10 +71,12 @@ NTSTATUS remote_password_change(const char *remote_machine, const char *user_nam 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; |