2 Unix SMB/CIFS implementation.
4 Copyright (C) Stefan (metze) Metzmacher 2003
5 Copyright (C) Jeremy Allison 2007
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>.
22 #include "../libcli/auth/spnego.h"
23 #include "../libcli/auth/ntlmssp.h"
24 #include "../lib/util/tevent_ntstatus.h"
25 #include "async_smb.h"
26 #include "smb_crypt.h"
29 /****************************************************************************
30 Get UNIX extensions version info.
31 ****************************************************************************/
33 struct cli_unix_extensions_version_state {
34 struct cli_state *cli;
37 uint16_t major, minor;
38 uint32_t caplow, caphigh;
41 static void cli_unix_extensions_version_done(struct tevent_req *subreq);
43 struct tevent_req *cli_unix_extensions_version_send(TALLOC_CTX *mem_ctx,
44 struct tevent_context *ev,
45 struct cli_state *cli)
47 struct tevent_req *req, *subreq;
48 struct cli_unix_extensions_version_state *state;
50 req = tevent_req_create(mem_ctx, &state,
51 struct cli_unix_extensions_version_state);
56 SSVAL(state->setup, 0, TRANSACT2_QFSINFO);
57 SSVAL(state->param, 0, SMB_QUERY_CIFS_UNIX_INFO);
59 subreq = cli_trans_send(state, ev, cli, SMBtrans2,
64 if (tevent_req_nomem(subreq, req)) {
65 return tevent_req_post(req, ev);
67 tevent_req_set_callback(subreq, cli_unix_extensions_version_done, req);
71 static void cli_unix_extensions_version_done(struct tevent_req *subreq)
73 struct tevent_req *req = tevent_req_callback_data(
74 subreq, struct tevent_req);
75 struct cli_unix_extensions_version_state *state = tevent_req_data(
76 req, struct cli_unix_extensions_version_state);
81 status = cli_trans_recv(subreq, state, NULL, NULL, 0, NULL,
82 NULL, 0, NULL, &data, 12, &num_data);
84 if (!NT_STATUS_IS_OK(status)) {
85 tevent_req_nterror(req, status);
89 state->major = SVAL(data, 0);
90 state->minor = SVAL(data, 2);
91 state->caplow = IVAL(data, 4);
92 state->caphigh = IVAL(data, 8);
97 NTSTATUS cli_unix_extensions_version_recv(struct tevent_req *req,
98 uint16_t *pmajor, uint16_t *pminor,
102 struct cli_unix_extensions_version_state *state = tevent_req_data(
103 req, struct cli_unix_extensions_version_state);
106 if (tevent_req_is_nterror(req, &status)) {
109 *pmajor = state->major;
110 *pminor = state->minor;
111 *pcaplow = state->caplow;
112 *pcaphigh = state->caphigh;
113 state->cli->server_posix_capabilities = *pcaplow;
117 NTSTATUS cli_unix_extensions_version(struct cli_state *cli, uint16 *pmajor,
118 uint16 *pminor, uint32 *pcaplow,
121 TALLOC_CTX *frame = talloc_stackframe();
122 struct event_context *ev;
123 struct tevent_req *req;
124 NTSTATUS status = NT_STATUS_OK;
126 if (cli_has_async_calls(cli)) {
128 * Can't use sync call while an async call is in flight
130 status = NT_STATUS_INVALID_PARAMETER;
134 ev = event_context_init(frame);
136 status = NT_STATUS_NO_MEMORY;
140 req = cli_unix_extensions_version_send(frame, ev, cli);
142 status = NT_STATUS_NO_MEMORY;
146 if (!tevent_req_poll(req, ev)) {
147 status = map_nt_error_from_unix(errno);
151 status = cli_unix_extensions_version_recv(req, pmajor, pminor, pcaplow,
155 if (!NT_STATUS_IS_OK(status)) {
156 cli_set_error(cli, status);
161 /****************************************************************************
162 Set UNIX extensions capabilities.
163 ****************************************************************************/
165 struct cli_set_unix_extensions_capabilities_state {
166 struct cli_state *cli;
172 static void cli_set_unix_extensions_capabilities_done(
173 struct tevent_req *subreq);
175 struct tevent_req *cli_set_unix_extensions_capabilities_send(
176 TALLOC_CTX *mem_ctx, struct tevent_context *ev, struct cli_state *cli,
177 uint16_t major, uint16_t minor, uint32_t caplow, uint32_t caphigh)
179 struct tevent_req *req, *subreq;
180 struct cli_set_unix_extensions_capabilities_state *state;
182 req = tevent_req_create(
184 struct cli_set_unix_extensions_capabilities_state);
190 SSVAL(state->setup+0, 0, TRANSACT2_SETFSINFO);
192 SSVAL(state->param, 0, 0);
193 SSVAL(state->param, 2, SMB_SET_CIFS_UNIX_INFO);
195 SSVAL(state->data, 0, major);
196 SSVAL(state->data, 2, minor);
197 SIVAL(state->data, 4, caplow);
198 SIVAL(state->data, 8, caphigh);
200 subreq = cli_trans_send(state, ev, cli, SMBtrans2,
204 state->data, 12, 560);
205 if (tevent_req_nomem(subreq, req)) {
206 return tevent_req_post(req, ev);
208 tevent_req_set_callback(
209 subreq, cli_set_unix_extensions_capabilities_done, req);
213 static void cli_set_unix_extensions_capabilities_done(
214 struct tevent_req *subreq)
216 struct tevent_req *req = tevent_req_callback_data(
217 subreq, struct tevent_req);
218 struct cli_set_unix_extensions_capabilities_state *state = tevent_req_data(
219 req, struct cli_set_unix_extensions_capabilities_state);
221 NTSTATUS status = cli_trans_recv(subreq, NULL, NULL, NULL, 0, NULL,
222 NULL, 0, NULL, NULL, 0, NULL);
223 if (NT_STATUS_IS_OK(status)) {
224 state->cli->requested_posix_capabilities = IVAL(state->data, 4);
226 tevent_req_simple_finish_ntstatus(subreq, status);
229 NTSTATUS cli_set_unix_extensions_capabilities_recv(struct tevent_req *req)
231 return tevent_req_simple_recv_ntstatus(req);
234 NTSTATUS cli_set_unix_extensions_capabilities(struct cli_state *cli,
235 uint16 major, uint16 minor,
236 uint32 caplow, uint32 caphigh)
238 struct tevent_context *ev;
239 struct tevent_req *req;
240 NTSTATUS status = NT_STATUS_NO_MEMORY;
242 if (cli_has_async_calls(cli)) {
243 return NT_STATUS_INVALID_PARAMETER;
245 ev = tevent_context_init(talloc_tos());
249 req = cli_set_unix_extensions_capabilities_send(
250 ev, ev, cli, major, minor, caplow, caphigh);
254 if (!tevent_req_poll_ntstatus(req, ev, &status)) {
257 status = cli_set_unix_extensions_capabilities_recv(req);
260 if (!NT_STATUS_IS_OK(status)) {
261 cli_set_error(cli, status);
266 struct cli_get_fs_attr_info_state {
272 static void cli_get_fs_attr_info_done(struct tevent_req *subreq);
274 struct tevent_req *cli_get_fs_attr_info_send(TALLOC_CTX *mem_ctx,
275 struct tevent_context *ev,
276 struct cli_state *cli)
278 struct tevent_req *subreq, *req;
279 struct cli_get_fs_attr_info_state *state;
281 req = tevent_req_create(mem_ctx, &state,
282 struct cli_get_fs_attr_info_state);
286 SSVAL(state->setup+0, 0, TRANSACT2_QFSINFO);
287 SSVAL(state->param+0, 0, SMB_QUERY_FS_ATTRIBUTE_INFO);
289 subreq = cli_trans_send(state, ev, cli, SMBtrans2,
294 if (tevent_req_nomem(subreq, req)) {
295 return tevent_req_post(req, ev);
297 tevent_req_set_callback(subreq, cli_get_fs_attr_info_done, req);
301 static void cli_get_fs_attr_info_done(struct tevent_req *subreq)
303 struct tevent_req *req = tevent_req_callback_data(
304 subreq, struct tevent_req);
305 struct cli_get_fs_attr_info_state *state = tevent_req_data(
306 req, struct cli_get_fs_attr_info_state);
311 status = cli_trans_recv(subreq, talloc_tos(), NULL, NULL, 0, NULL,
312 NULL, 0, NULL, &data, 12, &num_data);
314 if (!NT_STATUS_IS_OK(status)) {
315 tevent_req_nterror(req, status);
318 state->fs_attr = IVAL(data, 0);
320 tevent_req_done(req);
323 NTSTATUS cli_get_fs_attr_info_recv(struct tevent_req *req, uint32_t *fs_attr)
325 struct cli_get_fs_attr_info_state *state = tevent_req_data(
326 req, struct cli_get_fs_attr_info_state);
329 if (tevent_req_is_nterror(req, &status)) {
332 *fs_attr = state->fs_attr;
336 NTSTATUS cli_get_fs_attr_info(struct cli_state *cli, uint32_t *fs_attr)
338 struct tevent_context *ev;
339 struct tevent_req *req;
340 NTSTATUS status = NT_STATUS_NO_MEMORY;
342 if (cli_has_async_calls(cli)) {
343 return NT_STATUS_INVALID_PARAMETER;
345 ev = tevent_context_init(talloc_tos());
349 req = cli_get_fs_attr_info_send(ev, ev, cli);
353 if (!tevent_req_poll_ntstatus(req, ev, &status)) {
356 status = cli_get_fs_attr_info_recv(req, fs_attr);
359 if (!NT_STATUS_IS_OK(status)) {
360 cli_set_error(cli, status);
365 NTSTATUS cli_get_fs_volume_info(struct cli_state *cli, fstring volume_name,
366 uint32 *pserial_number, time_t *pdate)
372 uint32_t rdata_count;
375 SSVAL(setup, 0, TRANSACT2_QFSINFO);
376 SSVAL(param,0,SMB_QUERY_FS_VOLUME_INFO);
378 status = cli_trans(talloc_tos(), cli, SMBtrans2,
386 &rdata, 10, &rdata_count);
387 if (!NT_STATUS_IS_OK(status)) {
393 ts = interpret_long_date((char *)rdata);
396 if (pserial_number) {
397 *pserial_number = IVAL(rdata,8);
399 nlen = IVAL(rdata,12);
400 clistr_pull(cli->inbuf, volume_name, rdata + 18, sizeof(fstring),
403 /* todo: but not yet needed
404 * return the other stuff
411 NTSTATUS cli_get_fs_full_size_info(struct cli_state *cli,
412 uint64_t *total_allocation_units,
413 uint64_t *caller_allocation_units,
414 uint64_t *actual_allocation_units,
415 uint64_t *sectors_per_allocation_unit,
416 uint64_t *bytes_per_sector)
420 uint8_t *rdata = NULL;
421 uint32_t rdata_count;
424 SSVAL(setup, 0, TRANSACT2_QFSINFO);
425 SSVAL(param, 0, SMB_FS_FULL_SIZE_INFORMATION);
427 status = cli_trans(talloc_tos(), cli, SMBtrans2,
429 setup, 1, 0, /* setup */
430 param, 2, 0, /* param */
431 NULL, 0, 560, /* data */
433 NULL, 0, NULL, /* rsetup */
434 NULL, 0, NULL, /* rparam */
435 &rdata, 32, &rdata_count); /* rdata */
436 if (!NT_STATUS_IS_OK(status)) {
440 if (total_allocation_units) {
441 *total_allocation_units = BIG_UINT(rdata, 0);
443 if (caller_allocation_units) {
444 *caller_allocation_units = BIG_UINT(rdata,8);
446 if (actual_allocation_units) {
447 *actual_allocation_units = BIG_UINT(rdata,16);
449 if (sectors_per_allocation_unit) {
450 *sectors_per_allocation_unit = IVAL(rdata,24);
452 if (bytes_per_sector) {
453 *bytes_per_sector = IVAL(rdata,28);
461 NTSTATUS cli_get_posix_fs_info(struct cli_state *cli,
462 uint32 *optimal_transfer_size,
464 uint64_t *total_blocks,
465 uint64_t *blocks_available,
466 uint64_t *user_blocks_available,
467 uint64_t *total_file_nodes,
468 uint64_t *free_file_nodes,
469 uint64_t *fs_identifier)
473 uint8_t *rdata = NULL;
476 SSVAL(setup, 0, TRANSACT2_QFSINFO);
477 SSVAL(param,0,SMB_QUERY_POSIX_FS_INFO);
479 status = cli_trans(talloc_tos(), cli, SMBtrans2, NULL, 0, 0, 0,
484 NULL, 0, NULL, /* rsetup */
485 NULL, 0, NULL, /* rparam */
487 if (!NT_STATUS_IS_OK(status)) {
491 if (optimal_transfer_size) {
492 *optimal_transfer_size = IVAL(rdata, 0);
495 *block_size = IVAL(rdata,4);
498 *total_blocks = BIG_UINT(rdata,8);
500 if (blocks_available) {
501 *blocks_available = BIG_UINT(rdata,16);
503 if (user_blocks_available) {
504 *user_blocks_available = BIG_UINT(rdata,24);
506 if (total_file_nodes) {
507 *total_file_nodes = BIG_UINT(rdata,32);
509 if (free_file_nodes) {
510 *free_file_nodes = BIG_UINT(rdata,40);
513 *fs_identifier = BIG_UINT(rdata,48);
519 /******************************************************************************
520 Send/receive the request encryption blob.
521 ******************************************************************************/
523 static NTSTATUS enc_blob_send_receive(struct cli_state *cli, DATA_BLOB *in, DATA_BLOB *out, DATA_BLOB *param_out)
527 uint8_t *rparam=NULL, *rdata=NULL;
528 uint32_t num_rparam, num_rdata;
531 SSVAL(setup+0, 0, TRANSACT2_SETFSINFO);
533 SSVAL(param,2,SMB_REQUEST_TRANSPORT_ENCRYPTION);
535 status = cli_trans(talloc_tos(), cli, SMBtrans2, NULL, 0, 0, 0,
538 (uint8_t *)in->data, in->length, CLI_BUFFER_SIZE,
539 NULL, /* recv_flags */
540 NULL, 0, NULL, /* rsetup */
541 &rparam, 0, &num_rparam,
542 &rdata, 0, &num_rdata);
544 if (!NT_STATUS_IS_OK(status) &&
545 !NT_STATUS_EQUAL(status, NT_STATUS_MORE_PROCESSING_REQUIRED)) {
549 *out = data_blob(rdata, num_rdata);
550 *param_out = data_blob(rparam, num_rparam);
557 /******************************************************************************
558 Make a client state struct.
559 ******************************************************************************/
561 static struct smb_trans_enc_state *make_cli_enc_state(enum smb_trans_enc_type smb_enc_type)
563 struct smb_trans_enc_state *es = NULL;
564 es = SMB_MALLOC_P(struct smb_trans_enc_state);
569 es->smb_enc_type = smb_enc_type;
571 #if defined(HAVE_GSSAPI) && defined(HAVE_KRB5)
572 if (smb_enc_type == SMB_TRANS_ENC_GSS) {
573 es->s.gss_state = SMB_MALLOC_P(struct smb_tran_enc_state_gss);
574 if (!es->s.gss_state) {
578 ZERO_STRUCTP(es->s.gss_state);
584 /******************************************************************************
585 Start a raw ntlmssp encryption.
586 ******************************************************************************/
588 NTSTATUS cli_raw_ntlm_smb_encryption_start(struct cli_state *cli,
593 DATA_BLOB blob_in = data_blob_null;
594 DATA_BLOB blob_out = data_blob_null;
595 DATA_BLOB param_out = data_blob_null;
596 NTSTATUS status = NT_STATUS_UNSUCCESSFUL;
597 struct smb_trans_enc_state *es = make_cli_enc_state(SMB_TRANS_ENC_NTLM);
600 return NT_STATUS_NO_MEMORY;
602 status = ntlmssp_client_start(NULL,
605 lp_client_ntlmv2_auth(),
606 &es->s.ntlmssp_state);
607 if (!NT_STATUS_IS_OK(status)) {
611 ntlmssp_want_feature(es->s.ntlmssp_state, NTLMSSP_FEATURE_SESSION_KEY);
612 es->s.ntlmssp_state->neg_flags |= (NTLMSSP_NEGOTIATE_SIGN|NTLMSSP_NEGOTIATE_SEAL);
614 if (!NT_STATUS_IS_OK(status = ntlmssp_set_username(es->s.ntlmssp_state, user))) {
617 if (!NT_STATUS_IS_OK(status = ntlmssp_set_domain(es->s.ntlmssp_state, domain))) {
620 if (!NT_STATUS_IS_OK(status = ntlmssp_set_password(es->s.ntlmssp_state, pass))) {
625 status = ntlmssp_update(es->s.ntlmssp_state, blob_in, &blob_out);
626 data_blob_free(&blob_in);
627 data_blob_free(¶m_out);
628 if (NT_STATUS_EQUAL(status, NT_STATUS_MORE_PROCESSING_REQUIRED) || NT_STATUS_IS_OK(status)) {
629 NTSTATUS trans_status = enc_blob_send_receive(cli,
633 if (!NT_STATUS_EQUAL(trans_status,
634 NT_STATUS_MORE_PROCESSING_REQUIRED) &&
635 !NT_STATUS_IS_OK(trans_status)) {
636 status = trans_status;
638 if (param_out.length == 2) {
639 es->enc_ctx_num = SVAL(param_out.data, 0);
643 data_blob_free(&blob_out);
644 } while (NT_STATUS_EQUAL(status, NT_STATUS_MORE_PROCESSING_REQUIRED));
646 data_blob_free(&blob_in);
648 if (NT_STATUS_IS_OK(status)) {
649 /* Replace the old state, if any. */
650 if (cli->trans_enc_state) {
651 common_free_encryption_state(&cli->trans_enc_state);
653 cli->trans_enc_state = es;
654 cli->trans_enc_state->enc_on = True;
660 common_free_encryption_state(&es);
664 #if defined(HAVE_GSSAPI) && defined(HAVE_KRB5)
666 #ifndef SMB_GSS_REQUIRED_FLAGS
667 #define SMB_GSS_REQUIRED_FLAGS (GSS_C_CONF_FLAG|GSS_C_INTEG_FLAG|GSS_C_MUTUAL_FLAG|GSS_C_REPLAY_FLAG|GSS_C_SEQUENCE_FLAG)
670 /******************************************************************************
671 Get client gss blob to send to a server.
672 ******************************************************************************/
674 static NTSTATUS make_cli_gss_blob(TALLOC_CTX *ctx,
675 struct smb_trans_enc_state *es,
679 DATA_BLOB spnego_blob_in,
680 DATA_BLOB *p_blob_out)
682 const char *krb_mechs[] = {OID_KERBEROS5, NULL};
686 gss_buffer_desc input_name;
687 gss_buffer_desc *p_tok_in;
688 gss_buffer_desc tok_out, tok_in;
689 DATA_BLOB blob_out = data_blob_null;
690 DATA_BLOB blob_in = data_blob_null;
691 char *host_princ_s = NULL;
692 OM_uint32 ret_flags = 0;
693 NTSTATUS status = NT_STATUS_OK;
695 gss_OID_desc nt_hostbased_service =
696 {10, CONST_DISCARD(char *,"\x2a\x86\x48\x86\xf7\x12\x01\x02\x01\x04")};
698 memset(&tok_out, '\0', sizeof(tok_out));
700 /* Get a ticket for the service@host */
701 if (asprintf(&host_princ_s, "%s@%s", service, host) == -1) {
702 return NT_STATUS_NO_MEMORY;
705 input_name.value = host_princ_s;
706 input_name.length = strlen(host_princ_s) + 1;
708 ret = gss_import_name(&min,
710 &nt_hostbased_service,
713 if (ret != GSS_S_COMPLETE) {
714 SAFE_FREE(host_princ_s);
715 return map_nt_error_from_gss(ret, min);
718 if (spnego_blob_in.length == 0) {
719 p_tok_in = GSS_C_NO_BUFFER;
721 /* Remove the SPNEGO wrapper */
722 if (!spnego_parse_auth_response(ctx, spnego_blob_in, status_in, OID_KERBEROS5, &blob_in)) {
723 status = NT_STATUS_UNSUCCESSFUL;
726 tok_in.value = blob_in.data;
727 tok_in.length = blob_in.length;
731 ret = gss_init_sec_context(&min,
732 GSS_C_NO_CREDENTIAL, /* Use our default cred. */
733 &es->s.gss_state->gss_ctx,
735 GSS_C_NO_OID, /* default OID. */
736 GSS_C_MUTUAL_FLAG | GSS_C_REPLAY_FLAG | GSS_C_SEQUENCE_FLAG | GSS_C_DELEG_FLAG,
737 GSS_C_INDEFINITE, /* requested ticket lifetime. */
738 NULL, /* no channel bindings */
740 NULL, /* ignore mech type */
743 NULL); /* ignore time_rec */
745 status = map_nt_error_from_gss(ret, min);
746 if (!NT_STATUS_IS_OK(status) && !NT_STATUS_EQUAL(status,NT_STATUS_MORE_PROCESSING_REQUIRED)) {
747 ADS_STATUS adss = ADS_ERROR_GSS(ret, min);
748 DEBUG(10,("make_cli_gss_blob: gss_init_sec_context failed with %s\n",
753 if ((ret_flags & SMB_GSS_REQUIRED_FLAGS) != SMB_GSS_REQUIRED_FLAGS) {
754 status = NT_STATUS_ACCESS_DENIED;
757 blob_out = data_blob_talloc(ctx, tok_out.value, tok_out.length);
759 /* Wrap in an SPNEGO wrapper */
760 *p_blob_out = spnego_gen_negTokenInit(ctx, krb_mechs, &blob_out, NULL);
764 data_blob_free(&blob_out);
765 data_blob_free(&blob_in);
766 SAFE_FREE(host_princ_s);
767 gss_release_name(&min, &srv_name);
769 gss_release_buffer(&min, &tok_out);
774 /******************************************************************************
775 Start a SPNEGO gssapi encryption context.
776 ******************************************************************************/
778 NTSTATUS cli_gss_smb_encryption_start(struct cli_state *cli)
780 DATA_BLOB blob_recv = data_blob_null;
781 DATA_BLOB blob_send = data_blob_null;
782 DATA_BLOB param_out = data_blob_null;
783 NTSTATUS status = NT_STATUS_UNSUCCESSFUL;
785 const char *servicename;
786 struct smb_trans_enc_state *es = make_cli_enc_state(SMB_TRANS_ENC_GSS);
789 return NT_STATUS_NO_MEMORY;
792 name_to_fqdn(fqdn, cli->desthost);
795 servicename = "cifs";
796 status = make_cli_gss_blob(talloc_tos(), es, servicename, fqdn, NT_STATUS_OK, blob_recv, &blob_send);
797 if (!NT_STATUS_EQUAL(status,NT_STATUS_MORE_PROCESSING_REQUIRED)) {
798 servicename = "host";
799 status = make_cli_gss_blob(talloc_tos(), es, servicename, fqdn, NT_STATUS_OK, blob_recv, &blob_send);
800 if (!NT_STATUS_EQUAL(status,NT_STATUS_MORE_PROCESSING_REQUIRED)) {
806 data_blob_free(&blob_recv);
807 status = enc_blob_send_receive(cli, &blob_send, &blob_recv, ¶m_out);
808 if (param_out.length == 2) {
809 es->enc_ctx_num = SVAL(param_out.data, 0);
811 data_blob_free(&blob_send);
812 status = make_cli_gss_blob(talloc_tos(), es, servicename, fqdn, status, blob_recv, &blob_send);
813 } while (NT_STATUS_EQUAL(status, NT_STATUS_MORE_PROCESSING_REQUIRED));
814 data_blob_free(&blob_recv);
816 if (NT_STATUS_IS_OK(status)) {
817 /* Replace the old state, if any. */
818 if (cli->trans_enc_state) {
819 common_free_encryption_state(&cli->trans_enc_state);
821 cli->trans_enc_state = es;
822 cli->trans_enc_state->enc_on = True;
828 common_free_encryption_state(&es);
832 NTSTATUS cli_gss_smb_encryption_start(struct cli_state *cli)
834 return NT_STATUS_NOT_SUPPORTED;
838 /********************************************************************
839 Ensure a connection is encrypted.
840 ********************************************************************/
842 NTSTATUS cli_force_encryption(struct cli_state *c,
843 const char *username,
844 const char *password,
848 uint32 caplow, caphigh;
851 if (!SERVER_HAS_UNIX_CIFS(c)) {
852 return NT_STATUS_NOT_SUPPORTED;
855 status = cli_unix_extensions_version(c, &major, &minor, &caplow,
857 if (!NT_STATUS_IS_OK(status)) {
858 DEBUG(10, ("cli_force_encryption: cli_unix_extensions_version "
859 "returned %s\n", nt_errstr(status)));
860 return NT_STATUS_UNKNOWN_REVISION;
863 if (!(caplow & CIFS_UNIX_TRANSPORT_ENCRYPTION_CAP)) {
864 return NT_STATUS_UNSUPPORTED_COMPRESSION;
867 if (c->use_kerberos) {
868 return cli_gss_smb_encryption_start(c);
870 return cli_raw_ntlm_smb_encryption_start(c,