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 "libsmb/libsmb.h"
23 #include "../libcli/auth/spnego.h"
24 #include "../libcli/auth/ntlmssp.h"
25 #include "../lib/util/tevent_ntstatus.h"
26 #include "async_smb.h"
27 #include "smb_crypt.h"
30 /****************************************************************************
31 Get UNIX extensions version info.
32 ****************************************************************************/
34 struct cli_unix_extensions_version_state {
35 struct cli_state *cli;
38 uint16_t major, minor;
39 uint32_t caplow, caphigh;
42 static void cli_unix_extensions_version_done(struct tevent_req *subreq);
44 struct tevent_req *cli_unix_extensions_version_send(TALLOC_CTX *mem_ctx,
45 struct tevent_context *ev,
46 struct cli_state *cli)
48 struct tevent_req *req, *subreq;
49 struct cli_unix_extensions_version_state *state;
51 req = tevent_req_create(mem_ctx, &state,
52 struct cli_unix_extensions_version_state);
57 SSVAL(state->setup, 0, TRANSACT2_QFSINFO);
58 SSVAL(state->param, 0, SMB_QUERY_CIFS_UNIX_INFO);
60 subreq = cli_trans_send(state, ev, cli, SMBtrans2,
65 if (tevent_req_nomem(subreq, req)) {
66 return tevent_req_post(req, ev);
68 tevent_req_set_callback(subreq, cli_unix_extensions_version_done, req);
72 static void cli_unix_extensions_version_done(struct tevent_req *subreq)
74 struct tevent_req *req = tevent_req_callback_data(
75 subreq, struct tevent_req);
76 struct cli_unix_extensions_version_state *state = tevent_req_data(
77 req, struct cli_unix_extensions_version_state);
82 status = cli_trans_recv(subreq, state, NULL, NULL, 0, NULL,
83 NULL, 0, NULL, &data, 12, &num_data);
85 if (!NT_STATUS_IS_OK(status)) {
86 tevent_req_nterror(req, status);
90 state->major = SVAL(data, 0);
91 state->minor = SVAL(data, 2);
92 state->caplow = IVAL(data, 4);
93 state->caphigh = IVAL(data, 8);
98 NTSTATUS cli_unix_extensions_version_recv(struct tevent_req *req,
99 uint16_t *pmajor, uint16_t *pminor,
103 struct cli_unix_extensions_version_state *state = tevent_req_data(
104 req, struct cli_unix_extensions_version_state);
107 if (tevent_req_is_nterror(req, &status)) {
110 *pmajor = state->major;
111 *pminor = state->minor;
112 *pcaplow = state->caplow;
113 *pcaphigh = state->caphigh;
114 state->cli->server_posix_capabilities = *pcaplow;
118 NTSTATUS cli_unix_extensions_version(struct cli_state *cli, uint16 *pmajor,
119 uint16 *pminor, uint32 *pcaplow,
122 TALLOC_CTX *frame = talloc_stackframe();
123 struct event_context *ev;
124 struct tevent_req *req;
125 NTSTATUS status = NT_STATUS_OK;
127 if (cli_has_async_calls(cli)) {
129 * Can't use sync call while an async call is in flight
131 status = NT_STATUS_INVALID_PARAMETER;
135 ev = event_context_init(frame);
137 status = NT_STATUS_NO_MEMORY;
141 req = cli_unix_extensions_version_send(frame, ev, cli);
143 status = NT_STATUS_NO_MEMORY;
147 if (!tevent_req_poll(req, ev)) {
148 status = map_nt_error_from_unix(errno);
152 status = cli_unix_extensions_version_recv(req, pmajor, pminor, pcaplow,
156 if (!NT_STATUS_IS_OK(status)) {
157 cli_set_error(cli, status);
162 /****************************************************************************
163 Set UNIX extensions capabilities.
164 ****************************************************************************/
166 struct cli_set_unix_extensions_capabilities_state {
167 struct cli_state *cli;
173 static void cli_set_unix_extensions_capabilities_done(
174 struct tevent_req *subreq);
176 struct tevent_req *cli_set_unix_extensions_capabilities_send(
177 TALLOC_CTX *mem_ctx, struct tevent_context *ev, struct cli_state *cli,
178 uint16_t major, uint16_t minor, uint32_t caplow, uint32_t caphigh)
180 struct tevent_req *req, *subreq;
181 struct cli_set_unix_extensions_capabilities_state *state;
183 req = tevent_req_create(
185 struct cli_set_unix_extensions_capabilities_state);
191 SSVAL(state->setup+0, 0, TRANSACT2_SETFSINFO);
193 SSVAL(state->param, 0, 0);
194 SSVAL(state->param, 2, SMB_SET_CIFS_UNIX_INFO);
196 SSVAL(state->data, 0, major);
197 SSVAL(state->data, 2, minor);
198 SIVAL(state->data, 4, caplow);
199 SIVAL(state->data, 8, caphigh);
201 subreq = cli_trans_send(state, ev, cli, SMBtrans2,
205 state->data, 12, 560);
206 if (tevent_req_nomem(subreq, req)) {
207 return tevent_req_post(req, ev);
209 tevent_req_set_callback(
210 subreq, cli_set_unix_extensions_capabilities_done, req);
214 static void cli_set_unix_extensions_capabilities_done(
215 struct tevent_req *subreq)
217 struct tevent_req *req = tevent_req_callback_data(
218 subreq, struct tevent_req);
219 struct cli_set_unix_extensions_capabilities_state *state = tevent_req_data(
220 req, struct cli_set_unix_extensions_capabilities_state);
222 NTSTATUS status = cli_trans_recv(subreq, NULL, NULL, NULL, 0, NULL,
223 NULL, 0, NULL, NULL, 0, NULL);
224 if (NT_STATUS_IS_OK(status)) {
225 state->cli->requested_posix_capabilities = IVAL(state->data, 4);
227 tevent_req_simple_finish_ntstatus(subreq, status);
230 NTSTATUS cli_set_unix_extensions_capabilities_recv(struct tevent_req *req)
232 return tevent_req_simple_recv_ntstatus(req);
235 NTSTATUS cli_set_unix_extensions_capabilities(struct cli_state *cli,
236 uint16 major, uint16 minor,
237 uint32 caplow, uint32 caphigh)
239 struct tevent_context *ev;
240 struct tevent_req *req;
241 NTSTATUS status = NT_STATUS_NO_MEMORY;
243 if (cli_has_async_calls(cli)) {
244 return NT_STATUS_INVALID_PARAMETER;
246 ev = tevent_context_init(talloc_tos());
250 req = cli_set_unix_extensions_capabilities_send(
251 ev, ev, cli, major, minor, caplow, caphigh);
255 if (!tevent_req_poll_ntstatus(req, ev, &status)) {
258 status = cli_set_unix_extensions_capabilities_recv(req);
261 if (!NT_STATUS_IS_OK(status)) {
262 cli_set_error(cli, status);
267 struct cli_get_fs_attr_info_state {
273 static void cli_get_fs_attr_info_done(struct tevent_req *subreq);
275 struct tevent_req *cli_get_fs_attr_info_send(TALLOC_CTX *mem_ctx,
276 struct tevent_context *ev,
277 struct cli_state *cli)
279 struct tevent_req *subreq, *req;
280 struct cli_get_fs_attr_info_state *state;
282 req = tevent_req_create(mem_ctx, &state,
283 struct cli_get_fs_attr_info_state);
287 SSVAL(state->setup+0, 0, TRANSACT2_QFSINFO);
288 SSVAL(state->param+0, 0, SMB_QUERY_FS_ATTRIBUTE_INFO);
290 subreq = cli_trans_send(state, ev, cli, SMBtrans2,
295 if (tevent_req_nomem(subreq, req)) {
296 return tevent_req_post(req, ev);
298 tevent_req_set_callback(subreq, cli_get_fs_attr_info_done, req);
302 static void cli_get_fs_attr_info_done(struct tevent_req *subreq)
304 struct tevent_req *req = tevent_req_callback_data(
305 subreq, struct tevent_req);
306 struct cli_get_fs_attr_info_state *state = tevent_req_data(
307 req, struct cli_get_fs_attr_info_state);
312 status = cli_trans_recv(subreq, talloc_tos(), NULL, NULL, 0, NULL,
313 NULL, 0, NULL, &data, 12, &num_data);
315 if (!NT_STATUS_IS_OK(status)) {
316 tevent_req_nterror(req, status);
319 state->fs_attr = IVAL(data, 0);
321 tevent_req_done(req);
324 NTSTATUS cli_get_fs_attr_info_recv(struct tevent_req *req, uint32_t *fs_attr)
326 struct cli_get_fs_attr_info_state *state = tevent_req_data(
327 req, struct cli_get_fs_attr_info_state);
330 if (tevent_req_is_nterror(req, &status)) {
333 *fs_attr = state->fs_attr;
337 NTSTATUS cli_get_fs_attr_info(struct cli_state *cli, uint32_t *fs_attr)
339 struct tevent_context *ev;
340 struct tevent_req *req;
341 NTSTATUS status = NT_STATUS_NO_MEMORY;
343 if (cli_has_async_calls(cli)) {
344 return NT_STATUS_INVALID_PARAMETER;
346 ev = tevent_context_init(talloc_tos());
350 req = cli_get_fs_attr_info_send(ev, ev, cli);
354 if (!tevent_req_poll_ntstatus(req, ev, &status)) {
357 status = cli_get_fs_attr_info_recv(req, fs_attr);
360 if (!NT_STATUS_IS_OK(status)) {
361 cli_set_error(cli, status);
366 NTSTATUS cli_get_fs_volume_info(struct cli_state *cli, fstring volume_name,
367 uint32 *pserial_number, time_t *pdate)
373 uint32_t rdata_count;
376 SSVAL(setup, 0, TRANSACT2_QFSINFO);
377 SSVAL(param,0,SMB_QUERY_FS_VOLUME_INFO);
379 status = cli_trans(talloc_tos(), cli, SMBtrans2,
387 &rdata, 10, &rdata_count);
388 if (!NT_STATUS_IS_OK(status)) {
394 ts = interpret_long_date((char *)rdata);
397 if (pserial_number) {
398 *pserial_number = IVAL(rdata,8);
400 nlen = IVAL(rdata,12);
401 clistr_pull(cli->inbuf, volume_name, rdata + 18, sizeof(fstring),
404 /* todo: but not yet needed
405 * return the other stuff
412 NTSTATUS cli_get_fs_full_size_info(struct cli_state *cli,
413 uint64_t *total_allocation_units,
414 uint64_t *caller_allocation_units,
415 uint64_t *actual_allocation_units,
416 uint64_t *sectors_per_allocation_unit,
417 uint64_t *bytes_per_sector)
421 uint8_t *rdata = NULL;
422 uint32_t rdata_count;
425 SSVAL(setup, 0, TRANSACT2_QFSINFO);
426 SSVAL(param, 0, SMB_FS_FULL_SIZE_INFORMATION);
428 status = cli_trans(talloc_tos(), cli, SMBtrans2,
430 setup, 1, 0, /* setup */
431 param, 2, 0, /* param */
432 NULL, 0, 560, /* data */
434 NULL, 0, NULL, /* rsetup */
435 NULL, 0, NULL, /* rparam */
436 &rdata, 32, &rdata_count); /* rdata */
437 if (!NT_STATUS_IS_OK(status)) {
441 if (total_allocation_units) {
442 *total_allocation_units = BIG_UINT(rdata, 0);
444 if (caller_allocation_units) {
445 *caller_allocation_units = BIG_UINT(rdata,8);
447 if (actual_allocation_units) {
448 *actual_allocation_units = BIG_UINT(rdata,16);
450 if (sectors_per_allocation_unit) {
451 *sectors_per_allocation_unit = IVAL(rdata,24);
453 if (bytes_per_sector) {
454 *bytes_per_sector = IVAL(rdata,28);
462 NTSTATUS cli_get_posix_fs_info(struct cli_state *cli,
463 uint32 *optimal_transfer_size,
465 uint64_t *total_blocks,
466 uint64_t *blocks_available,
467 uint64_t *user_blocks_available,
468 uint64_t *total_file_nodes,
469 uint64_t *free_file_nodes,
470 uint64_t *fs_identifier)
474 uint8_t *rdata = NULL;
477 SSVAL(setup, 0, TRANSACT2_QFSINFO);
478 SSVAL(param,0,SMB_QUERY_POSIX_FS_INFO);
480 status = cli_trans(talloc_tos(), cli, SMBtrans2, NULL, 0, 0, 0,
485 NULL, 0, NULL, /* rsetup */
486 NULL, 0, NULL, /* rparam */
488 if (!NT_STATUS_IS_OK(status)) {
492 if (optimal_transfer_size) {
493 *optimal_transfer_size = IVAL(rdata, 0);
496 *block_size = IVAL(rdata,4);
499 *total_blocks = BIG_UINT(rdata,8);
501 if (blocks_available) {
502 *blocks_available = BIG_UINT(rdata,16);
504 if (user_blocks_available) {
505 *user_blocks_available = BIG_UINT(rdata,24);
507 if (total_file_nodes) {
508 *total_file_nodes = BIG_UINT(rdata,32);
510 if (free_file_nodes) {
511 *free_file_nodes = BIG_UINT(rdata,40);
514 *fs_identifier = BIG_UINT(rdata,48);
520 /******************************************************************************
521 Send/receive the request encryption blob.
522 ******************************************************************************/
524 static NTSTATUS enc_blob_send_receive(struct cli_state *cli, DATA_BLOB *in, DATA_BLOB *out, DATA_BLOB *param_out)
528 uint8_t *rparam=NULL, *rdata=NULL;
529 uint32_t num_rparam, num_rdata;
532 SSVAL(setup+0, 0, TRANSACT2_SETFSINFO);
534 SSVAL(param,2,SMB_REQUEST_TRANSPORT_ENCRYPTION);
536 status = cli_trans(talloc_tos(), cli, SMBtrans2, NULL, 0, 0, 0,
539 (uint8_t *)in->data, in->length, CLI_BUFFER_SIZE,
540 NULL, /* recv_flags */
541 NULL, 0, NULL, /* rsetup */
542 &rparam, 0, &num_rparam,
543 &rdata, 0, &num_rdata);
545 if (!NT_STATUS_IS_OK(status) &&
546 !NT_STATUS_EQUAL(status, NT_STATUS_MORE_PROCESSING_REQUIRED)) {
550 *out = data_blob(rdata, num_rdata);
551 *param_out = data_blob(rparam, num_rparam);
558 /******************************************************************************
559 Make a client state struct.
560 ******************************************************************************/
562 static struct smb_trans_enc_state *make_cli_enc_state(enum smb_trans_enc_type smb_enc_type)
564 struct smb_trans_enc_state *es = NULL;
565 es = SMB_MALLOC_P(struct smb_trans_enc_state);
570 es->smb_enc_type = smb_enc_type;
572 #if defined(HAVE_GSSAPI) && defined(HAVE_KRB5)
573 if (smb_enc_type == SMB_TRANS_ENC_GSS) {
574 es->s.gss_state = SMB_MALLOC_P(struct smb_tran_enc_state_gss);
575 if (!es->s.gss_state) {
579 ZERO_STRUCTP(es->s.gss_state);
585 /******************************************************************************
586 Start a raw ntlmssp encryption.
587 ******************************************************************************/
589 NTSTATUS cli_raw_ntlm_smb_encryption_start(struct cli_state *cli,
594 DATA_BLOB blob_in = data_blob_null;
595 DATA_BLOB blob_out = data_blob_null;
596 DATA_BLOB param_out = data_blob_null;
597 NTSTATUS status = NT_STATUS_UNSUCCESSFUL;
598 struct smb_trans_enc_state *es = make_cli_enc_state(SMB_TRANS_ENC_NTLM);
601 return NT_STATUS_NO_MEMORY;
603 status = ntlmssp_client_start(NULL,
606 lp_client_ntlmv2_auth(),
607 &es->s.ntlmssp_state);
608 if (!NT_STATUS_IS_OK(status)) {
612 ntlmssp_want_feature(es->s.ntlmssp_state, NTLMSSP_FEATURE_SESSION_KEY);
613 es->s.ntlmssp_state->neg_flags |= (NTLMSSP_NEGOTIATE_SIGN|NTLMSSP_NEGOTIATE_SEAL);
615 if (!NT_STATUS_IS_OK(status = ntlmssp_set_username(es->s.ntlmssp_state, user))) {
618 if (!NT_STATUS_IS_OK(status = ntlmssp_set_domain(es->s.ntlmssp_state, domain))) {
621 if (!NT_STATUS_IS_OK(status = ntlmssp_set_password(es->s.ntlmssp_state, pass))) {
626 status = ntlmssp_update(es->s.ntlmssp_state, blob_in, &blob_out);
627 data_blob_free(&blob_in);
628 data_blob_free(¶m_out);
629 if (NT_STATUS_EQUAL(status, NT_STATUS_MORE_PROCESSING_REQUIRED) || NT_STATUS_IS_OK(status)) {
630 NTSTATUS trans_status = enc_blob_send_receive(cli,
634 if (!NT_STATUS_EQUAL(trans_status,
635 NT_STATUS_MORE_PROCESSING_REQUIRED) &&
636 !NT_STATUS_IS_OK(trans_status)) {
637 status = trans_status;
639 if (param_out.length == 2) {
640 es->enc_ctx_num = SVAL(param_out.data, 0);
644 data_blob_free(&blob_out);
645 } while (NT_STATUS_EQUAL(status, NT_STATUS_MORE_PROCESSING_REQUIRED));
647 data_blob_free(&blob_in);
649 if (NT_STATUS_IS_OK(status)) {
650 /* Replace the old state, if any. */
651 if (cli->trans_enc_state) {
652 common_free_encryption_state(&cli->trans_enc_state);
654 cli->trans_enc_state = es;
655 cli->trans_enc_state->enc_on = True;
661 common_free_encryption_state(&es);
665 #if defined(HAVE_GSSAPI) && defined(HAVE_KRB5)
667 #ifndef SMB_GSS_REQUIRED_FLAGS
668 #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)
671 /******************************************************************************
672 Get client gss blob to send to a server.
673 ******************************************************************************/
675 static NTSTATUS make_cli_gss_blob(TALLOC_CTX *ctx,
676 struct smb_trans_enc_state *es,
680 DATA_BLOB spnego_blob_in,
681 DATA_BLOB *p_blob_out)
683 const char *krb_mechs[] = {OID_KERBEROS5, NULL};
687 gss_buffer_desc input_name;
688 gss_buffer_desc *p_tok_in;
689 gss_buffer_desc tok_out, tok_in;
690 DATA_BLOB blob_out = data_blob_null;
691 DATA_BLOB blob_in = data_blob_null;
692 char *host_princ_s = NULL;
693 OM_uint32 ret_flags = 0;
694 NTSTATUS status = NT_STATUS_OK;
696 gss_OID_desc nt_hostbased_service =
697 {10, discard_const_p(char, "\x2a\x86\x48\x86\xf7\x12\x01\x02\x01\x04")};
699 memset(&tok_out, '\0', sizeof(tok_out));
701 /* Get a ticket for the service@host */
702 if (asprintf(&host_princ_s, "%s@%s", service, host) == -1) {
703 return NT_STATUS_NO_MEMORY;
706 input_name.value = host_princ_s;
707 input_name.length = strlen(host_princ_s) + 1;
709 ret = gss_import_name(&min,
711 &nt_hostbased_service,
714 if (ret != GSS_S_COMPLETE) {
715 SAFE_FREE(host_princ_s);
716 return map_nt_error_from_gss(ret, min);
719 if (spnego_blob_in.length == 0) {
720 p_tok_in = GSS_C_NO_BUFFER;
722 /* Remove the SPNEGO wrapper */
723 if (!spnego_parse_auth_response(ctx, spnego_blob_in, status_in, OID_KERBEROS5, &blob_in)) {
724 status = NT_STATUS_UNSUCCESSFUL;
727 tok_in.value = blob_in.data;
728 tok_in.length = blob_in.length;
732 ret = gss_init_sec_context(&min,
733 GSS_C_NO_CREDENTIAL, /* Use our default cred. */
734 &es->s.gss_state->gss_ctx,
736 GSS_C_NO_OID, /* default OID. */
737 GSS_C_MUTUAL_FLAG | GSS_C_REPLAY_FLAG | GSS_C_SEQUENCE_FLAG | GSS_C_DELEG_FLAG,
738 GSS_C_INDEFINITE, /* requested ticket lifetime. */
739 NULL, /* no channel bindings */
741 NULL, /* ignore mech type */
744 NULL); /* ignore time_rec */
746 status = map_nt_error_from_gss(ret, min);
747 if (!NT_STATUS_IS_OK(status) && !NT_STATUS_EQUAL(status,NT_STATUS_MORE_PROCESSING_REQUIRED)) {
748 ADS_STATUS adss = ADS_ERROR_GSS(ret, min);
749 DEBUG(10,("make_cli_gss_blob: gss_init_sec_context failed with %s\n",
754 if ((ret_flags & SMB_GSS_REQUIRED_FLAGS) != SMB_GSS_REQUIRED_FLAGS) {
755 status = NT_STATUS_ACCESS_DENIED;
758 blob_out = data_blob_talloc(ctx, tok_out.value, tok_out.length);
760 /* Wrap in an SPNEGO wrapper */
761 *p_blob_out = spnego_gen_negTokenInit(ctx, krb_mechs, &blob_out, NULL);
765 data_blob_free(&blob_out);
766 data_blob_free(&blob_in);
767 SAFE_FREE(host_princ_s);
768 gss_release_name(&min, &srv_name);
770 gss_release_buffer(&min, &tok_out);
775 /******************************************************************************
776 Start a SPNEGO gssapi encryption context.
777 ******************************************************************************/
779 NTSTATUS cli_gss_smb_encryption_start(struct cli_state *cli)
781 DATA_BLOB blob_recv = data_blob_null;
782 DATA_BLOB blob_send = data_blob_null;
783 DATA_BLOB param_out = data_blob_null;
784 NTSTATUS status = NT_STATUS_UNSUCCESSFUL;
786 const char *servicename;
787 struct smb_trans_enc_state *es = make_cli_enc_state(SMB_TRANS_ENC_GSS);
790 return NT_STATUS_NO_MEMORY;
793 name_to_fqdn(fqdn, cli->desthost);
796 servicename = "cifs";
797 status = make_cli_gss_blob(talloc_tos(), es, servicename, fqdn, NT_STATUS_OK, blob_recv, &blob_send);
798 if (!NT_STATUS_EQUAL(status,NT_STATUS_MORE_PROCESSING_REQUIRED)) {
799 servicename = "host";
800 status = make_cli_gss_blob(talloc_tos(), es, servicename, fqdn, NT_STATUS_OK, blob_recv, &blob_send);
801 if (!NT_STATUS_EQUAL(status,NT_STATUS_MORE_PROCESSING_REQUIRED)) {
807 data_blob_free(&blob_recv);
808 status = enc_blob_send_receive(cli, &blob_send, &blob_recv, ¶m_out);
809 if (param_out.length == 2) {
810 es->enc_ctx_num = SVAL(param_out.data, 0);
812 data_blob_free(&blob_send);
813 status = make_cli_gss_blob(talloc_tos(), es, servicename, fqdn, status, blob_recv, &blob_send);
814 } while (NT_STATUS_EQUAL(status, NT_STATUS_MORE_PROCESSING_REQUIRED));
815 data_blob_free(&blob_recv);
817 if (NT_STATUS_IS_OK(status)) {
818 /* Replace the old state, if any. */
819 if (cli->trans_enc_state) {
820 common_free_encryption_state(&cli->trans_enc_state);
822 cli->trans_enc_state = es;
823 cli->trans_enc_state->enc_on = True;
829 common_free_encryption_state(&es);
833 NTSTATUS cli_gss_smb_encryption_start(struct cli_state *cli)
835 return NT_STATUS_NOT_SUPPORTED;
839 /********************************************************************
840 Ensure a connection is encrypted.
841 ********************************************************************/
843 NTSTATUS cli_force_encryption(struct cli_state *c,
844 const char *username,
845 const char *password,
849 uint32 caplow, caphigh;
852 if (!SERVER_HAS_UNIX_CIFS(c)) {
853 return NT_STATUS_NOT_SUPPORTED;
856 status = cli_unix_extensions_version(c, &major, &minor, &caplow,
858 if (!NT_STATUS_IS_OK(status)) {
859 DEBUG(10, ("cli_force_encryption: cli_unix_extensions_version "
860 "returned %s\n", nt_errstr(status)));
861 return NT_STATUS_UNKNOWN_REVISION;
864 if (!(caplow & CIFS_UNIX_TRANSPORT_ENCRYPTION_CAP)) {
865 return NT_STATUS_UNSUPPORTED_COMPRESSION;
868 if (c->use_kerberos) {
869 return cli_gss_smb_encryption_start(c);
871 return cli_raw_ntlm_smb_encryption_start(c,