2 Unix SMB/CIFS implementation.
4 Copyright (C) Andrew Tridgell 1994-1998
5 Copyright (C) Gerald (Jerry) Carter 2004
6 Copyright (C) James Peach 2007
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 3 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program. If not, see <http://www.gnu.org/licenses/>.
23 #include "../libcli/auth/libcli_auth.h"
24 #include "../librpc/gen_ndr/rap.h"
25 #include "../lib/util/tevent_ntstatus.h"
26 #include "async_smb.h"
27 #include "libsmb/libsmb.h"
28 #include "libsmb/clirap.h"
30 #include "../libcli/smb/smbXcli_base.h"
31 #include "cli_smb2_fnum.h"
32 #include "lib/util/string_wrappers.h"
34 #include <gnutls/gnutls.h>
35 #include <gnutls/crypto.h>
37 #define PIPE_LANMAN "\\PIPE\\LANMAN"
39 /****************************************************************************
41 ****************************************************************************/
43 bool cli_api(struct cli_state
*cli
,
44 char *param
, int prcnt
, int mprcnt
,
45 char *data
, int drcnt
, int mdrcnt
,
46 char **rparam
, unsigned int *rprcnt
,
47 char **rdata
, unsigned int *rdrcnt
)
51 uint8_t *my_rparam
, *my_rdata
;
52 uint32_t num_my_rparam
, num_my_rdata
;
54 status
= cli_trans(talloc_tos(), cli
, SMBtrans
,
55 PIPE_LANMAN
, 0, /* name, fid */
56 0, 0, /* function, flags */
57 NULL
, 0, 0, /* setup */
58 (uint8_t *)param
, prcnt
, mprcnt
, /* Params, length, max */
59 (uint8_t *)data
, drcnt
, mdrcnt
, /* Data, length, max */
60 NULL
, /* recv_flags2 */
61 NULL
, 0, NULL
, /* rsetup */
62 &my_rparam
, 0, &num_my_rparam
,
63 &my_rdata
, 0, &num_my_rdata
);
64 if (!NT_STATUS_IS_OK(status
)) {
69 * I know this memcpy massively hurts, but there are just tons
70 * of callers of cli_api that eventually need changing to
74 *rparam
= (char *)smb_memdup(my_rparam
, num_my_rparam
);
75 if (*rparam
== NULL
) {
78 *rprcnt
= num_my_rparam
;
79 TALLOC_FREE(my_rparam
);
81 *rdata
= (char *)smb_memdup(my_rdata
, num_my_rdata
);
85 *rdrcnt
= num_my_rdata
;
86 TALLOC_FREE(my_rdata
);
90 TALLOC_FREE(my_rdata
);
91 TALLOC_FREE(my_rparam
);
99 /****************************************************************************
100 Call a NetShareEnum - try and browse available connections on a host.
101 ****************************************************************************/
103 int cli_RNetShareEnum(struct cli_state
*cli
, void (*fn
)(const char *, uint32_t, const char *, void *), void *state
)
108 unsigned int rdrcnt
,rprcnt
;
114 /* now send a SMBtrans command with api RNetShareEnum */
116 SSVAL(p
,0,0); /* api number */
118 strlcpy(p
,"WrLeh",sizeof(param
)-PTR_DIFF(p
,param
));
119 p
= skip_string(param
,sizeof(param
),p
);
120 strlcpy(p
,"B13BWz",sizeof(param
)-PTR_DIFF(p
,param
));
121 p
= skip_string(param
,sizeof(param
),p
);
124 * Win2k needs a *smaller* buffer than 0xFFFF here -
125 * it returns "out of server memory" with 0xFFFF !!! JRA.
132 param
, PTR_DIFF(p
,param
), 1024, /* Param, length, maxlen */
133 NULL
, 0, 0xFFE0, /* data, length, maxlen - Win2k needs a small buffer here too ! */
134 &rparam
, &rprcnt
, /* return params, length */
135 &rdata
, &rdrcnt
); /* return data, length */
137 DEBUG(4,("NetShareEnum failed\n"));
142 DBG_ERR("Got invalid result: rprcnt=%u\n", rprcnt
);
146 res
= rparam
? SVAL(rparam
,0) : -1;
148 if (res
== 0 || res
== ERRmoredata
) {
149 int converter
=SVAL(rparam
,2);
151 char *rdata_end
= rdata
+ rdrcnt
;
153 count
=SVAL(rparam
,4);
156 for (i
=0;i
<count
;i
++,p
+=20) {
164 TALLOC_CTX
*frame
= talloc_stackframe();
166 if (p
+ 20 > rdata_end
) {
173 comment_offset
= (IVAL(p
,16) & 0xFFFF) - converter
;
174 if (comment_offset
< 0 ||
175 comment_offset
> (int)rdrcnt
) {
179 cmnt
= comment_offset
?(rdata
+comment_offset
):"";
181 /* Work out the comment length. */
182 for (p1
= cmnt
, len
= 0; *p1
&&
183 p1
< rdata_end
; len
++)
188 pull_string_talloc(frame
,rdata
,0,
189 &s1
,sname
,14,STR_ASCII
);
190 pull_string_talloc(frame
,rdata
,0,
191 &s2
,cmnt
,len
,STR_ASCII
);
197 fn(s1
, type
, s2
, state
);
202 DEBUG(4,("NetShareEnum res=%d\n", res
));
212 /****************************************************************************
213 Call a NetServerEnum for the specified workgroup and servertype mask. This
214 function then calls the specified callback function for each name returned.
216 The callback function takes 4 arguments: the machine name, the server type,
217 the comment and a state pointer.
218 ****************************************************************************/
220 bool cli_NetServerEnum(struct cli_state
*cli
, char *workgroup
, uint32_t stype
,
221 void (*fn
)(const char *, uint32_t, const char *, void *),
226 char *rdata_end
= NULL
;
227 unsigned int rdrcnt
,rprcnt
;
232 uint32_t func
= RAP_NetServerEnum2
;
233 char *last_entry
= NULL
;
238 errno
= 0; /* reset */
241 * This may take more than one transaction, so we should loop until
242 * we no longer get a more data to process or we have all of the
246 /* send a SMBtrans command with api NetServerEnum */
248 SIVAL(p
,0,func
); /* api number */
251 if (func
== RAP_NetServerEnum3
) {
252 strlcpy(p
,"WrLehDzz", sizeof(param
)-PTR_DIFF(p
,param
));
254 strlcpy(p
,"WrLehDz", sizeof(param
)-PTR_DIFF(p
,param
));
257 p
= skip_string(param
, sizeof(param
), p
);
258 strlcpy(p
,"B16BBDz", sizeof(param
)-PTR_DIFF(p
,param
));
260 p
= skip_string(param
, sizeof(param
), p
);
262 SSVAL(p
,2,CLI_BUFFER_SIZE
);
267 /* If we have more data, tell the server where
272 sizeof(param
) - PTR_DIFF(p
,param
) - 1,
273 STR_TERMINATE
|STR_UPPER
);
276 SAFE_FREE(last_entry
);
281 if (func
== RAP_NetServerEnum3
) {
283 last_entry
? last_entry
: "",
284 sizeof(param
) - PTR_DIFF(p
,param
) - 1,
288 SAFE_FREE(last_entry
);
294 /* Next time through we need to use the continue api */
295 func
= RAP_NetServerEnum3
;
298 param
, PTR_DIFF(p
,param
), 8, /* params, length, max */
299 NULL
, 0, CLI_BUFFER_SIZE
, /* data, length, max */
300 &rparam
, &rprcnt
, /* return params, return size */
301 &rdata
, &rdrcnt
)) { /* return data, return size */
303 /* break out of the loop on error */
308 rdata_end
= rdata
+ rdrcnt
;
311 DBG_ERR("Got invalid result: rprcnt=%u\n", rprcnt
);
316 res
= rparam
? SVAL(rparam
,0) : -1;
318 if (res
== 0 || res
== ERRmoredata
||
319 (res
!= -1 && cli_errno(cli
) == 0)) {
322 int converter
=SVAL(rparam
,2);
324 /* Get the number of items returned in this buffer */
325 count
= SVAL(rparam
, 4);
327 /* The next field contains the number of items left,
328 * including those returned in this buffer. So the
329 * first time through this should contain all of the
332 if (total_cnt
== 0) {
333 total_cnt
= SVAL(rparam
, 6);
336 /* Keep track of how many we have read */
340 /* The last name in the previous NetServerEnum reply is
341 * sent back to server in the NetServerEnum3 request
342 * (last_entry). The next reply should repeat this entry
343 * as the first element. We have no proof that this is
344 * always true, but from traces that seems to be the
345 * behavior from Window Servers. So first lets do a lot
346 * of checking, just being paranoid. If the string
347 * matches then we already saw this entry so skip it.
349 * NOTE: sv1_name field must be null terminated and has
350 * a max size of 16 (NetBIOS Name).
352 if (last_entry
&& count
&& p
&&
353 (strncmp(last_entry
, p
, 16) == 0)) {
354 count
-= 1; /* Skip this entry */
355 return_cnt
= -1; /* Not part of total, so don't count. */
356 p
= rdata
+ 26; /* Skip the whole record */
359 for (i
= 0; i
< count
; i
++, p
+= 26) {
364 TALLOC_CTX
*frame
= talloc_stackframe();
365 uint32_t entry_stype
;
367 if (p
+ 26 > rdata_end
) {
373 comment_offset
= (IVAL(p
,22) & 0xFFFF)-converter
;
374 cmnt
= comment_offset
?(rdata
+comment_offset
):"";
376 if (comment_offset
< 0 || comment_offset
>= (int)rdrcnt
) {
381 /* Work out the comment length. */
382 for (p1
= cmnt
, len
= 0; *p1
&&
383 p1
< rdata_end
; len
++)
389 entry_stype
= IVAL(p
,18) & ~SV_TYPE_LOCAL_LIST_ONLY
;
391 pull_string_talloc(frame
,rdata
,0,
392 &s1
,sname
,16,STR_ASCII
);
393 pull_string_talloc(frame
,rdata
,0,
394 &s2
,cmnt
,len
,STR_ASCII
);
401 fn(s1
, entry_stype
, s2
, state
);
405 /* We are done with the old last entry, so now we can free it */
407 SAFE_FREE(last_entry
); /* This will set it to null */
410 /* We always make a copy of the last entry if we have one */
412 last_entry
= smb_xstrdup(sname
);
415 /* If we have more data, but no last entry then error out */
416 if (!last_entry
&& (res
== ERRmoredata
)) {
425 } while ((res
== ERRmoredata
) && (total_cnt
> return_cnt
));
429 SAFE_FREE(last_entry
);
432 errno
= cli_errno(cli
);
435 /* this is a very special case, when the domain master for the
436 work group isn't part of the work group itself, there is something
442 return(return_cnt
> 0);
445 /****************************************************************************
446 Send a SamOEMChangePassword command.
447 ****************************************************************************/
449 bool cli_oem_change_password(struct cli_state
*cli
, const char *user
, const char *new_password
,
450 const char *old_password
)
453 unsigned char data
[532];
455 unsigned char old_pw_hash
[16];
456 unsigned char new_pw_hash
[16];
457 unsigned int data_len
;
458 unsigned int param_len
= 0;
461 unsigned int rprcnt
, rdrcnt
;
462 gnutls_cipher_hd_t cipher_hnd
= NULL
;
463 gnutls_datum_t old_pw_key
= {
465 .size
= sizeof(old_pw_hash
),
469 if (strlen(user
) >= sizeof(fstring
)-1) {
470 DEBUG(0,("cli_oem_change_password: user name %s is too long.\n", user
));
474 SSVAL(p
,0,214); /* SamOEMChangePassword command. */
476 strlcpy(p
, "zsT", sizeof(param
)-PTR_DIFF(p
,param
));
477 p
= skip_string(param
,sizeof(param
),p
);
478 strlcpy(p
, "B516B16", sizeof(param
)-PTR_DIFF(p
,param
));
479 p
= skip_string(param
,sizeof(param
),p
);
480 strlcpy(p
,user
, sizeof(param
)-PTR_DIFF(p
,param
));
481 p
= skip_string(param
,sizeof(param
),p
);
485 param_len
= PTR_DIFF(p
,param
);
488 * Get the Lanman hash of the old password, we
489 * use this as the key to make_oem_passwd_hash().
491 E_deshash(old_password
, old_pw_hash
);
493 encode_pw_buffer(data
, new_password
, STR_ASCII
);
495 #ifdef DEBUG_PASSWORD
496 DEBUG(100,("make_oem_passwd_hash\n"));
497 dump_data(100, data
, 516);
499 rc
= gnutls_cipher_init(&cipher_hnd
,
500 GNUTLS_CIPHER_ARCFOUR_128
,
504 DBG_ERR("gnutls_cipher_init failed: %s\n",
505 gnutls_strerror(rc
));
508 rc
= gnutls_cipher_encrypt(cipher_hnd
,
511 gnutls_cipher_deinit(cipher_hnd
);
517 * Now place the old password hash in the data.
519 E_deshash(new_password
, new_pw_hash
);
521 rc
= E_old_pw_hash( new_pw_hash
, old_pw_hash
, (uchar
*)&data
[516]);
523 DBG_ERR("E_old_pw_hash failed: %s\n", gnutls_strerror(rc
));
530 param
, param_len
, 4, /* param, length, max */
531 (char *)data
, data_len
, 0, /* data, length, max */
534 DEBUG(0,("cli_oem_change_password: Failed to send password change for user %s\n",
540 cli
->rap_error
= ERRbadformat
;
545 cli
->rap_error
= SVAL(rparam
,0);
552 return (cli
->rap_error
== 0);
555 /****************************************************************************
556 Send a qpathinfo call.
557 ****************************************************************************/
559 struct cli_qpathinfo1_state
{
560 struct cli_state
*cli
;
565 static void cli_qpathinfo1_done(struct tevent_req
*subreq
);
567 struct tevent_req
*cli_qpathinfo1_send(TALLOC_CTX
*mem_ctx
,
568 struct tevent_context
*ev
,
569 struct cli_state
*cli
,
572 struct tevent_req
*req
= NULL
, *subreq
= NULL
;
573 struct cli_qpathinfo1_state
*state
= NULL
;
575 req
= tevent_req_create(mem_ctx
, &state
, struct cli_qpathinfo1_state
);
580 subreq
= cli_qpathinfo_send(state
, ev
, cli
, fname
, SMB_INFO_STANDARD
,
581 22, CLI_BUFFER_SIZE
);
582 if (tevent_req_nomem(subreq
, req
)) {
583 return tevent_req_post(req
, ev
);
585 tevent_req_set_callback(subreq
, cli_qpathinfo1_done
, req
);
589 static void cli_qpathinfo1_done(struct tevent_req
*subreq
)
591 struct tevent_req
*req
= tevent_req_callback_data(
592 subreq
, struct tevent_req
);
593 struct cli_qpathinfo1_state
*state
= tevent_req_data(
594 req
, struct cli_qpathinfo1_state
);
597 status
= cli_qpathinfo_recv(subreq
, state
, &state
->data
,
600 if (!NT_STATUS_IS_OK(status
)) {
601 tevent_req_nterror(req
, status
);
604 tevent_req_done(req
);
607 NTSTATUS
cli_qpathinfo1_recv(struct tevent_req
*req
,
614 struct cli_qpathinfo1_state
*state
= tevent_req_data(
615 req
, struct cli_qpathinfo1_state
);
618 time_t (*date_fn
)(const void *buf
, int serverzone
);
620 if (tevent_req_is_nterror(req
, &status
)) {
624 if (state
->cli
->win95
) {
625 date_fn
= make_unix_date
;
627 date_fn
= make_unix_date2
;
631 *change_time
= date_fn(state
->data
+0, smb1cli_conn_server_time_zone(state
->cli
->conn
));
634 *access_time
= date_fn(state
->data
+4, smb1cli_conn_server_time_zone(state
->cli
->conn
));
637 *write_time
= date_fn(state
->data
+8, smb1cli_conn_server_time_zone(state
->cli
->conn
));
640 *size
= IVAL(state
->data
, 12);
643 *pattr
= SVAL(state
->data
, l1_attrFile
);
648 NTSTATUS
cli_qpathinfo1(struct cli_state
*cli
,
656 TALLOC_CTX
*frame
= talloc_stackframe();
657 struct tevent_context
*ev
;
658 struct tevent_req
*req
;
659 NTSTATUS status
= NT_STATUS_NO_MEMORY
;
661 if (smbXcli_conn_has_async_calls(cli
->conn
)) {
663 * Can't use sync call while an async call is in flight
665 status
= NT_STATUS_INVALID_PARAMETER
;
668 ev
= samba_tevent_context_init(frame
);
672 req
= cli_qpathinfo1_send(frame
, ev
, cli
, fname
);
676 if (!tevent_req_poll_ntstatus(req
, ev
, &status
)) {
679 status
= cli_qpathinfo1_recv(req
, change_time
, access_time
,
680 write_time
, size
, pattr
);
686 static void prep_basic_information_buf(
688 struct timespec create_time
,
689 struct timespec access_time
,
690 struct timespec write_time
,
691 struct timespec change_time
,
694 char *p
= (char *)buf
;
696 * Add the create, last access, modification, and status change times
698 put_long_date_full_timespec(
699 TIMESTAMP_SET_NT_OR_BETTER
, p
, &create_time
);
702 put_long_date_full_timespec(
703 TIMESTAMP_SET_NT_OR_BETTER
, p
, &access_time
);
706 put_long_date_full_timespec(
707 TIMESTAMP_SET_NT_OR_BETTER
, p
, &write_time
);
710 put_long_date_full_timespec(
711 TIMESTAMP_SET_NT_OR_BETTER
, p
, &change_time
);
714 if (attr
== (uint32_t)-1 || attr
== FILE_ATTRIBUTE_NORMAL
) {
717 } else if (attr
== 0) {
718 /* Clear all existing attributes. */
719 attr
= FILE_ATTRIBUTE_NORMAL
;
731 SMB_ASSERT(PTR_DIFF(p
, buf
) == 40);
734 NTSTATUS
cli_setpathinfo_ext(struct cli_state
*cli
, const char *fname
,
735 struct timespec create_time
,
736 struct timespec access_time
,
737 struct timespec write_time
,
738 struct timespec change_time
,
743 prep_basic_information_buf(
751 if (smbXcli_conn_protocol(cli
->conn
) >= PROTOCOL_SMB2_02
) {
752 DATA_BLOB in_data
= data_blob_const(buf
, sizeof(buf
));
754 * Split out SMB2 here as we need to select
755 * the correct info type and level.
757 return cli_smb2_setpathinfo(cli
,
759 1, /* SMB2_SETINFO_FILE */
760 SMB_FILE_BASIC_INFORMATION
- 1000,
764 return cli_setpathinfo(
765 cli
, SMB_FILE_BASIC_INFORMATION
, fname
, buf
, sizeof(buf
));
768 struct cli_setfileinfo_ext_state
{
773 static void cli_setfileinfo_ext_done(struct tevent_req
*subreq
);
774 static void cli_setfileinfo_ext_done2(struct tevent_req
*subreq
);
776 struct tevent_req
*cli_setfileinfo_ext_send(
778 struct tevent_context
*ev
,
779 struct cli_state
*cli
,
781 struct timespec create_time
,
782 struct timespec access_time
,
783 struct timespec write_time
,
784 struct timespec change_time
,
787 struct tevent_req
*req
= NULL
, *subreq
= NULL
;
788 struct cli_setfileinfo_ext_state
*state
= NULL
;
790 req
= tevent_req_create(
791 mem_ctx
, &state
, struct cli_setfileinfo_ext_state
);
795 prep_basic_information_buf(
803 if (smbXcli_conn_protocol(cli
->conn
) >= PROTOCOL_SMB2_02
) {
804 state
->in_data
= (DATA_BLOB
) {
805 .data
= state
->data
, .length
= sizeof(state
->data
),
808 subreq
= cli_smb2_set_info_fnum_send(
814 SMB_FILE_BASIC_INFORMATION
- 1000,
816 0); /* in_additional_info */
817 if (tevent_req_nomem(subreq
, req
)) {
818 return tevent_req_post(req
, ev
);
820 tevent_req_set_callback(
821 subreq
, cli_setfileinfo_ext_done2
, req
);
825 subreq
= cli_setfileinfo_send(
830 SMB_FILE_BASIC_INFORMATION
,
832 sizeof(state
->data
));
833 if (tevent_req_nomem(subreq
, req
)) {
834 return tevent_req_post(req
, ev
);
836 tevent_req_set_callback(subreq
, cli_setfileinfo_ext_done
, req
);
840 static void cli_setfileinfo_ext_done(struct tevent_req
*subreq
)
842 NTSTATUS status
= cli_setfileinfo_recv(subreq
);
843 tevent_req_simple_finish_ntstatus(subreq
, status
);
846 static void cli_setfileinfo_ext_done2(struct tevent_req
*subreq
)
848 NTSTATUS status
= cli_smb2_set_info_fnum_recv(subreq
);
849 tevent_req_simple_finish_ntstatus(subreq
, status
);
852 NTSTATUS
cli_setfileinfo_ext_recv(struct tevent_req
*req
)
854 return tevent_req_simple_recv_ntstatus(req
);
857 NTSTATUS
cli_setfileinfo_ext(
858 struct cli_state
*cli
,
860 struct timespec create_time
,
861 struct timespec access_time
,
862 struct timespec write_time
,
863 struct timespec change_time
,
866 TALLOC_CTX
*frame
= NULL
;
867 struct tevent_context
*ev
= NULL
;
868 struct tevent_req
*req
= NULL
;
869 NTSTATUS status
= NT_STATUS_NO_MEMORY
;
871 if (smbXcli_conn_has_async_calls(cli
->conn
)) {
873 * Can't use sync call while an async call is in flight
875 return NT_STATUS_INVALID_PARAMETER
;
878 frame
= talloc_stackframe();
880 ev
= samba_tevent_context_init(frame
);
884 req
= cli_setfileinfo_ext_send(
897 if (!tevent_req_poll_ntstatus(req
, ev
, &status
)) {
900 status
= cli_setfileinfo_ext_recv(req
);
906 /****************************************************************************
907 Send a qpathinfo call with the SMB_QUERY_FILE_ALL_INFO info level.
908 ****************************************************************************/
910 struct cli_qpathinfo2_state
{
915 static void cli_qpathinfo2_done(struct tevent_req
*subreq
);
917 struct tevent_req
*cli_qpathinfo2_send(TALLOC_CTX
*mem_ctx
,
918 struct tevent_context
*ev
,
919 struct cli_state
*cli
,
922 struct tevent_req
*req
= NULL
, *subreq
= NULL
;
923 struct cli_qpathinfo2_state
*state
= NULL
;
925 req
= tevent_req_create(mem_ctx
, &state
, struct cli_qpathinfo2_state
);
929 subreq
= cli_qpathinfo_send(state
, ev
, cli
, fname
,
930 SMB_QUERY_FILE_ALL_INFO
,
931 68, CLI_BUFFER_SIZE
);
932 if (tevent_req_nomem(subreq
, req
)) {
933 return tevent_req_post(req
, ev
);
935 tevent_req_set_callback(subreq
, cli_qpathinfo2_done
, req
);
939 static void cli_qpathinfo2_done(struct tevent_req
*subreq
)
941 struct tevent_req
*req
= tevent_req_callback_data(
942 subreq
, struct tevent_req
);
943 struct cli_qpathinfo2_state
*state
= tevent_req_data(
944 req
, struct cli_qpathinfo2_state
);
947 status
= cli_qpathinfo_recv(subreq
, state
, &state
->data
,
950 if (!NT_STATUS_IS_OK(status
)) {
951 tevent_req_nterror(req
, status
);
954 tevent_req_done(req
);
957 NTSTATUS
cli_qpathinfo2_recv(struct tevent_req
*req
,
958 struct timespec
*create_time
,
959 struct timespec
*access_time
,
960 struct timespec
*write_time
,
961 struct timespec
*change_time
,
962 off_t
*size
, uint32_t *pattr
,
965 struct cli_qpathinfo2_state
*state
= tevent_req_data(
966 req
, struct cli_qpathinfo2_state
);
969 if (tevent_req_is_nterror(req
, &status
)) {
974 *create_time
= interpret_long_date((char *)state
->data
+0);
977 *access_time
= interpret_long_date((char *)state
->data
+8);
980 *write_time
= interpret_long_date((char *)state
->data
+16);
983 *change_time
= interpret_long_date((char *)state
->data
+24);
986 /* SMB_QUERY_FILE_ALL_INFO returns 32-bit attributes. */
987 *pattr
= IVAL(state
->data
, 32);
990 *size
= IVAL2_TO_SMB_BIG_UINT(state
->data
,48);
994 * SMB1 qpathinfo2 uses SMB_QUERY_FILE_ALL_INFO
995 * which doesn't return an inode number (fileid).
996 * We can't change this to one of the FILE_ID
997 * info levels as only Win2003 and above support
998 * these [MS-SMB: 2.2.2.3.1] and the SMB1 code
999 * needs to support older servers.
1003 return NT_STATUS_OK
;
1006 NTSTATUS
cli_qpathinfo2(struct cli_state
*cli
, const char *fname
,
1007 struct timespec
*create_time
,
1008 struct timespec
*access_time
,
1009 struct timespec
*write_time
,
1010 struct timespec
*change_time
,
1011 off_t
*size
, uint32_t *pattr
,
1014 TALLOC_CTX
*frame
= NULL
;
1015 struct tevent_context
*ev
;
1016 struct tevent_req
*req
;
1017 NTSTATUS status
= NT_STATUS_NO_MEMORY
;
1019 if (smbXcli_conn_protocol(cli
->conn
) >= PROTOCOL_SMB2_02
) {
1020 return cli_smb2_qpathinfo2(cli
,
1031 frame
= talloc_stackframe();
1033 if (smbXcli_conn_has_async_calls(cli
->conn
)) {
1035 * Can't use sync call while an async call is in flight
1037 status
= NT_STATUS_INVALID_PARAMETER
;
1040 ev
= samba_tevent_context_init(frame
);
1044 req
= cli_qpathinfo2_send(frame
, ev
, cli
, fname
);
1048 if (!tevent_req_poll_ntstatus(req
, ev
, &status
)) {
1051 status
= cli_qpathinfo2_recv(req
, create_time
, access_time
,
1052 write_time
, change_time
, size
, pattr
, ino
);
1058 /****************************************************************************
1060 ****************************************************************************/
1062 struct cli_qpathinfo_streams_state
{
1067 static void cli_qpathinfo_streams_done(struct tevent_req
*subreq
);
1069 struct tevent_req
*cli_qpathinfo_streams_send(TALLOC_CTX
*mem_ctx
,
1070 struct tevent_context
*ev
,
1071 struct cli_state
*cli
,
1074 struct tevent_req
*req
= NULL
, *subreq
= NULL
;
1075 struct cli_qpathinfo_streams_state
*state
= NULL
;
1077 req
= tevent_req_create(mem_ctx
, &state
,
1078 struct cli_qpathinfo_streams_state
);
1082 subreq
= cli_qpathinfo_send(state
, ev
, cli
, fname
,
1083 SMB_FILE_STREAM_INFORMATION
,
1084 0, CLI_BUFFER_SIZE
);
1085 if (tevent_req_nomem(subreq
, req
)) {
1086 return tevent_req_post(req
, ev
);
1088 tevent_req_set_callback(subreq
, cli_qpathinfo_streams_done
, req
);
1092 static void cli_qpathinfo_streams_done(struct tevent_req
*subreq
)
1094 struct tevent_req
*req
= tevent_req_callback_data(
1095 subreq
, struct tevent_req
);
1096 struct cli_qpathinfo_streams_state
*state
= tevent_req_data(
1097 req
, struct cli_qpathinfo_streams_state
);
1100 status
= cli_qpathinfo_recv(subreq
, state
, &state
->data
,
1102 TALLOC_FREE(subreq
);
1103 if (!NT_STATUS_IS_OK(status
)) {
1104 tevent_req_nterror(req
, status
);
1107 tevent_req_done(req
);
1110 NTSTATUS
cli_qpathinfo_streams_recv(struct tevent_req
*req
,
1111 TALLOC_CTX
*mem_ctx
,
1112 unsigned int *pnum_streams
,
1113 struct stream_struct
**pstreams
)
1115 struct cli_qpathinfo_streams_state
*state
= tevent_req_data(
1116 req
, struct cli_qpathinfo_streams_state
);
1119 if (tevent_req_is_nterror(req
, &status
)) {
1122 if (!parse_streams_blob(mem_ctx
, state
->data
, state
->num_data
,
1123 pnum_streams
, pstreams
)) {
1124 return NT_STATUS_INVALID_NETWORK_RESPONSE
;
1126 return NT_STATUS_OK
;
1129 NTSTATUS
cli_qpathinfo_streams(struct cli_state
*cli
, const char *fname
,
1130 TALLOC_CTX
*mem_ctx
,
1131 unsigned int *pnum_streams
,
1132 struct stream_struct
**pstreams
)
1134 TALLOC_CTX
*frame
= NULL
;
1135 struct tevent_context
*ev
;
1136 struct tevent_req
*req
;
1137 NTSTATUS status
= NT_STATUS_NO_MEMORY
;
1139 if (smbXcli_conn_protocol(cli
->conn
) >= PROTOCOL_SMB2_02
) {
1140 return cli_smb2_qpathinfo_streams(cli
,
1147 frame
= talloc_stackframe();
1149 if (smbXcli_conn_has_async_calls(cli
->conn
)) {
1151 * Can't use sync call while an async call is in flight
1153 status
= NT_STATUS_INVALID_PARAMETER
;
1156 ev
= samba_tevent_context_init(frame
);
1160 req
= cli_qpathinfo_streams_send(frame
, ev
, cli
, fname
);
1164 if (!tevent_req_poll_ntstatus(req
, ev
, &status
)) {
1167 status
= cli_qpathinfo_streams_recv(req
, mem_ctx
, pnum_streams
,
1174 bool parse_streams_blob(TALLOC_CTX
*mem_ctx
, const uint8_t *rdata
,
1176 unsigned int *pnum_streams
,
1177 struct stream_struct
**pstreams
)
1179 unsigned int num_streams
;
1180 struct stream_struct
*streams
;
1187 while ((data_len
> ofs
) && (data_len
- ofs
>= 24)) {
1191 struct stream_struct
*tmp
;
1194 tmp
= talloc_realloc(mem_ctx
, streams
,
1195 struct stream_struct
,
1203 nlen
= IVAL(rdata
, ofs
+ 0x04);
1205 streams
[num_streams
].size
= IVAL_TO_SMB_OFF_T(
1207 streams
[num_streams
].alloc_size
= IVAL_TO_SMB_OFF_T(
1210 if (nlen
> data_len
- (ofs
+ 24)) {
1215 * We need to null-terminate src, how do I do this with
1216 * convert_string_talloc??
1219 tmp_buf
= talloc_array(streams
, uint8_t, nlen
+2);
1220 if (tmp_buf
== NULL
) {
1224 memcpy(tmp_buf
, rdata
+ofs
+24, nlen
);
1226 tmp_buf
[nlen
+1] = 0;
1228 if (!convert_string_talloc(streams
, CH_UTF16
, CH_UNIX
, tmp_buf
,
1229 nlen
+2, &vstr
, &size
))
1231 TALLOC_FREE(tmp_buf
);
1235 TALLOC_FREE(tmp_buf
);
1236 streams
[num_streams
].name
= (char *)vstr
;
1239 len
= IVAL(rdata
, ofs
);
1240 if (len
> data_len
- ofs
) {
1243 if (len
== 0) break;
1247 *pnum_streams
= num_streams
;
1248 *pstreams
= streams
;
1252 TALLOC_FREE(streams
);
1256 /****************************************************************************
1257 Send a qfileinfo QUERY_FILE_NAME_INFO call.
1258 ****************************************************************************/
1260 NTSTATUS
cli_qfilename(struct cli_state
*cli
, uint16_t fnum
,
1261 TALLOC_CTX
*mem_ctx
, char **_name
)
1263 uint16_t recv_flags2
;
1270 status
= cli_qfileinfo(talloc_tos(), cli
, fnum
,
1271 SMB_QUERY_FILE_NAME_INFO
,
1272 4, CLI_BUFFER_SIZE
, &recv_flags2
,
1273 &rdata
, &num_rdata
);
1274 if (!NT_STATUS_IS_OK(status
)) {
1278 namelen
= IVAL(rdata
, 0);
1279 if (namelen
> (num_rdata
- 4)) {
1281 return NT_STATUS_INVALID_NETWORK_RESPONSE
;
1284 pull_string_talloc(mem_ctx
,
1285 (const char *)rdata
,
1292 status
= map_nt_error_from_unix(errno
);
1299 return NT_STATUS_OK
;
1302 struct cli_qfileinfo_basic_state
{
1305 struct timespec create_time
;
1306 struct timespec access_time
;
1307 struct timespec write_time
;
1308 struct timespec change_time
;
1312 static void cli_qfileinfo_basic_done(struct tevent_req
*subreq
);
1313 static void cli_qfileinfo_basic_doneE(struct tevent_req
*subreq
);
1314 static void cli_qfileinfo_basic_done2(struct tevent_req
*subreq
);
1316 struct tevent_req
*cli_qfileinfo_basic_send(
1317 TALLOC_CTX
*mem_ctx
,
1318 struct tevent_context
*ev
,
1319 struct cli_state
*cli
,
1322 struct tevent_req
*req
= NULL
, *subreq
= NULL
;
1323 struct cli_qfileinfo_basic_state
*state
= NULL
;
1325 req
= tevent_req_create(
1326 mem_ctx
, &state
, struct cli_qfileinfo_basic_state
);
1331 if ((smbXcli_conn_protocol(cli
->conn
) < PROTOCOL_LANMAN2
) ||
1335 * https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-cifs/3d9d8f3e-dc70-410d-a3fc-6f4a881e8cab
1336 * SMB_COM_TRANSACTION2 used in cli_qfileinfo_send()
1337 * further down was introduced with the LAN Manager
1338 * 1.2 dialect, which we encode as PROTOCOL_LANMAN2.
1340 * The "win95" check was introduced with commit
1341 * 27e5850fd3e1c8 in 1998. Hard to check these days,
1344 * Use a lowerlevel fallback in both cases.
1347 subreq
= cli_getattrE_send(state
, ev
, cli
, fnum
);
1348 if (tevent_req_nomem(subreq
, req
)) {
1349 return tevent_req_post(req
, ev
);
1351 tevent_req_set_callback(
1352 subreq
, cli_qfileinfo_basic_doneE
, req
);
1356 if (smbXcli_conn_protocol(cli
->conn
) >= PROTOCOL_SMB2_02
) {
1357 subreq
= cli_smb2_query_info_fnum_send(
1358 state
, /* mem_ctx */
1362 1, /* in_info_type */
1363 (SMB_FILE_ALL_INFORMATION
- 1000), /* in_file_info_class */
1364 0xFFFF, /* in_max_output_length */
1365 NULL
, /* in_input_buffer */
1366 0, /* in_additional_info */
1368 if (tevent_req_nomem(subreq
, req
)) {
1369 return tevent_req_post(req
, ev
);
1371 tevent_req_set_callback(
1372 subreq
, cli_qfileinfo_basic_done2
, req
);
1376 subreq
= cli_qfileinfo_send(
1381 SMB_QUERY_FILE_ALL_INFO
, /* level */
1383 CLI_BUFFER_SIZE
); /* max_rdata */
1384 if (tevent_req_nomem(subreq
, req
)) {
1385 return tevent_req_post(req
, ev
);
1387 tevent_req_set_callback(subreq
, cli_qfileinfo_basic_done
, req
);
1391 static void cli_qfileinfo_basic_done(struct tevent_req
*subreq
)
1393 struct tevent_req
*req
= tevent_req_callback_data(
1394 subreq
, struct tevent_req
);
1395 struct cli_qfileinfo_basic_state
*state
= tevent_req_data(
1396 req
, struct cli_qfileinfo_basic_state
);
1401 status
= cli_qfileinfo_recv(
1402 subreq
, state
, NULL
, &rdata
, &num_rdata
);
1403 TALLOC_FREE(subreq
);
1404 if (tevent_req_nterror(req
, status
)) {
1408 state
->create_time
= interpret_long_date((char *)rdata
+0);
1409 state
->access_time
= interpret_long_date((char *)rdata
+8);
1410 state
->write_time
= interpret_long_date((char *)rdata
+16);
1411 state
->change_time
= interpret_long_date((char *)rdata
+24);
1412 state
->attr
= PULL_LE_U32(rdata
, 32);
1413 state
->size
= PULL_LE_U64(rdata
,48);
1414 state
->ino
= PULL_LE_U32(rdata
, 64);
1417 tevent_req_done(req
);
1420 static void cli_qfileinfo_basic_doneE(struct tevent_req
*subreq
)
1422 struct tevent_req
*req
= tevent_req_callback_data(
1423 subreq
, struct tevent_req
);
1424 struct cli_qfileinfo_basic_state
*state
= tevent_req_data(
1425 req
, struct cli_qfileinfo_basic_state
);
1428 status
= cli_getattrE_recv(
1432 &state
->change_time
.tv_sec
,
1433 &state
->access_time
.tv_sec
,
1434 &state
->write_time
.tv_sec
);
1435 TALLOC_FREE(subreq
);
1436 if (tevent_req_nterror(req
, status
)) {
1439 tevent_req_done(req
);
1442 static void cli_qfileinfo_basic_done2(struct tevent_req
*subreq
)
1444 struct tevent_req
*req
= tevent_req_callback_data(
1445 subreq
, struct tevent_req
);
1446 struct cli_qfileinfo_basic_state
*state
= tevent_req_data(
1447 req
, struct cli_qfileinfo_basic_state
);
1448 DATA_BLOB outbuf
= {0};
1451 status
= cli_smb2_query_info_fnum_recv(subreq
, state
, &outbuf
);
1452 TALLOC_FREE(subreq
);
1453 if (tevent_req_nterror(req
, status
)) {
1457 /* Parse the reply. */
1458 if (outbuf
.length
< 0x60) {
1459 tevent_req_nterror(req
, NT_STATUS_INVALID_NETWORK_RESPONSE
);
1463 state
->create_time
= interpret_long_date(
1464 (const char *)outbuf
.data
+ 0x0);
1465 state
->access_time
= interpret_long_date(
1466 (const char *)outbuf
.data
+ 0x8);
1467 state
->write_time
= interpret_long_date(
1468 (const char *)outbuf
.data
+ 0x10);
1469 state
->change_time
= interpret_long_date(
1470 (const char *)outbuf
.data
+ 0x18);
1471 state
->attr
= IVAL(outbuf
.data
, 0x20);
1472 state
->size
= BVAL(outbuf
.data
, 0x30);
1473 state
->ino
= BVAL(outbuf
.data
, 0x40);
1475 data_blob_free(&outbuf
);
1477 tevent_req_done(req
);
1480 NTSTATUS
cli_qfileinfo_basic_recv(
1481 struct tevent_req
*req
,
1484 struct timespec
*create_time
,
1485 struct timespec
*access_time
,
1486 struct timespec
*write_time
,
1487 struct timespec
*change_time
,
1490 struct cli_qfileinfo_basic_state
*state
= tevent_req_data(
1491 req
, struct cli_qfileinfo_basic_state
);
1494 if (tevent_req_is_nterror(req
, &status
)) {
1498 if (create_time
!= NULL
) {
1499 *create_time
= state
->create_time
;
1501 if (access_time
!= NULL
) {
1502 *access_time
= state
->access_time
;
1504 if (write_time
!= NULL
) {
1505 *write_time
= state
->write_time
;
1507 if (change_time
!= NULL
) {
1508 *change_time
= state
->change_time
;
1511 *attr
= state
->attr
;
1514 *size
= state
->size
;
1520 return NT_STATUS_OK
;
1522 /****************************************************************************
1523 Send a qfileinfo call.
1524 ****************************************************************************/
1526 NTSTATUS
cli_qfileinfo_basic(
1527 struct cli_state
*cli
,
1531 struct timespec
*create_time
,
1532 struct timespec
*access_time
,
1533 struct timespec
*write_time
,
1534 struct timespec
*change_time
,
1537 TALLOC_CTX
*frame
= NULL
;
1538 struct tevent_context
*ev
= NULL
;
1539 struct tevent_req
*req
= NULL
;
1540 NTSTATUS status
= NT_STATUS_NO_MEMORY
;
1542 frame
= talloc_stackframe();
1544 if (smbXcli_conn_has_async_calls(cli
->conn
)) {
1546 * Can't use sync call while an async call is in flight
1548 status
= NT_STATUS_INVALID_PARAMETER
;
1551 ev
= samba_tevent_context_init(frame
);
1555 req
= cli_qfileinfo_basic_send(frame
, ev
, cli
, fnum
);
1559 if (!tevent_req_poll_ntstatus(req
, ev
, &status
)) {
1563 status
= cli_qfileinfo_basic_recv(
1573 /* cli_smb2_query_info_fnum_recv doesn't set this */
1574 cli
->raw_status
= status
;
1580 /****************************************************************************
1581 Send a qpathinfo BASIC_INFO call.
1582 ****************************************************************************/
1584 struct cli_qpathinfo_basic_state
{
1589 static void cli_qpathinfo_basic_done(struct tevent_req
*subreq
);
1591 struct tevent_req
*cli_qpathinfo_basic_send(TALLOC_CTX
*mem_ctx
,
1592 struct tevent_context
*ev
,
1593 struct cli_state
*cli
,
1596 struct tevent_req
*req
= NULL
, *subreq
= NULL
;
1597 struct cli_qpathinfo_basic_state
*state
= NULL
;
1599 req
= tevent_req_create(mem_ctx
, &state
,
1600 struct cli_qpathinfo_basic_state
);
1604 subreq
= cli_qpathinfo_send(state
, ev
, cli
, fname
,
1605 SMB_QUERY_FILE_BASIC_INFO
,
1606 36, CLI_BUFFER_SIZE
);
1607 if (tevent_req_nomem(subreq
, req
)) {
1608 return tevent_req_post(req
, ev
);
1610 tevent_req_set_callback(subreq
, cli_qpathinfo_basic_done
, req
);
1614 static void cli_qpathinfo_basic_done(struct tevent_req
*subreq
)
1616 struct tevent_req
*req
= tevent_req_callback_data(
1617 subreq
, struct tevent_req
);
1618 struct cli_qpathinfo_basic_state
*state
= tevent_req_data(
1619 req
, struct cli_qpathinfo_basic_state
);
1622 status
= cli_qpathinfo_recv(subreq
, state
, &state
->data
,
1624 TALLOC_FREE(subreq
);
1625 if (!NT_STATUS_IS_OK(status
)) {
1626 tevent_req_nterror(req
, status
);
1629 tevent_req_done(req
);
1632 NTSTATUS
cli_qpathinfo_basic_recv(struct tevent_req
*req
,
1633 SMB_STRUCT_STAT
*sbuf
, uint32_t *attributes
)
1635 struct cli_qpathinfo_basic_state
*state
= tevent_req_data(
1636 req
, struct cli_qpathinfo_basic_state
);
1639 if (tevent_req_is_nterror(req
, &status
)) {
1643 sbuf
->st_ex_btime
= interpret_long_date((char *)state
->data
);
1644 sbuf
->st_ex_atime
= interpret_long_date((char *)state
->data
+8);
1645 sbuf
->st_ex_mtime
= interpret_long_date((char *)state
->data
+16);
1646 sbuf
->st_ex_ctime
= interpret_long_date((char *)state
->data
+24);
1647 *attributes
= IVAL(state
->data
, 32);
1648 return NT_STATUS_OK
;
1651 NTSTATUS
cli_qpathinfo_basic(struct cli_state
*cli
, const char *name
,
1652 SMB_STRUCT_STAT
*sbuf
, uint32_t *attributes
)
1654 TALLOC_CTX
*frame
= NULL
;
1655 struct tevent_context
*ev
;
1656 struct tevent_req
*req
;
1657 NTSTATUS status
= NT_STATUS_NO_MEMORY
;
1659 if (smbXcli_conn_protocol(cli
->conn
) >= PROTOCOL_SMB2_02
) {
1660 return cli_smb2_qpathinfo_basic(cli
,
1666 frame
= talloc_stackframe();
1668 if (smbXcli_conn_has_async_calls(cli
->conn
)) {
1670 * Can't use sync call while an async call is in flight
1672 status
= NT_STATUS_INVALID_PARAMETER
;
1675 ev
= samba_tevent_context_init(frame
);
1679 req
= cli_qpathinfo_basic_send(frame
, ev
, cli
, name
);
1683 if (!tevent_req_poll_ntstatus(req
, ev
, &status
)) {
1686 status
= cli_qpathinfo_basic_recv(req
, sbuf
, attributes
);
1692 /****************************************************************************
1693 Send a qpathinfo SMB_QUERY_FILE_ALT_NAME_INFO call.
1694 ****************************************************************************/
1696 NTSTATUS
cli_qpathinfo_alt_name(struct cli_state
*cli
, const char *fname
, fstring alt_name
)
1701 char *converted
= NULL
;
1702 size_t converted_size
= 0;
1705 if (smbXcli_conn_protocol(cli
->conn
) >= PROTOCOL_SMB2_02
) {
1706 return cli_smb2_qpathinfo_alt_name(cli
,
1711 status
= cli_qpathinfo(talloc_tos(), cli
, fname
,
1712 SMB_QUERY_FILE_ALT_NAME_INFO
,
1713 4, CLI_BUFFER_SIZE
, &rdata
, &num_rdata
);
1714 if (!NT_STATUS_IS_OK(status
)) {
1718 len
= IVAL(rdata
, 0);
1720 if (len
> num_rdata
- 4) {
1721 return NT_STATUS_INVALID_NETWORK_RESPONSE
;
1724 /* The returned data is a pushed string, not raw data. */
1725 if (!convert_string_talloc(talloc_tos(),
1726 smbXcli_conn_use_unicode(cli
->conn
) ? CH_UTF16LE
: CH_DOS
,
1732 return NT_STATUS_NO_MEMORY
;
1734 fstrcpy(alt_name
, converted
);
1736 TALLOC_FREE(converted
);
1739 return NT_STATUS_OK
;
1742 /****************************************************************************
1743 Send a qpathinfo SMB_QUERY_FILE_STANDARD_INFO call.
1744 ****************************************************************************/
1746 NTSTATUS
cli_qpathinfo_standard(struct cli_state
*cli
, const char *fname
,
1747 uint64_t *allocated
, uint64_t *size
,
1749 bool *is_del_pending
, bool *is_dir
)
1755 if (smbXcli_conn_protocol(cli
->conn
) >= PROTOCOL_SMB2_02
) {
1756 return NT_STATUS_NOT_IMPLEMENTED
;
1759 status
= cli_qpathinfo(talloc_tos(), cli
, fname
,
1760 SMB_QUERY_FILE_STANDARD_INFO
,
1761 24, CLI_BUFFER_SIZE
, &rdata
, &num_rdata
);
1762 if (!NT_STATUS_IS_OK(status
)) {
1767 *allocated
= BVAL(rdata
, 0);
1771 *size
= BVAL(rdata
, 8);
1775 *nlinks
= IVAL(rdata
, 16);
1778 if (is_del_pending
) {
1779 *is_del_pending
= CVAL(rdata
, 20);
1783 *is_dir
= CVAL(rdata
, 20);
1788 return NT_STATUS_OK
;
1792 /* like cli_qpathinfo2 but do not use SMB_QUERY_FILE_ALL_INFO with smb1 */
1793 NTSTATUS
cli_qpathinfo3(struct cli_state
*cli
, const char *fname
,
1794 struct timespec
*create_time
,
1795 struct timespec
*access_time
,
1796 struct timespec
*write_time
,
1797 struct timespec
*change_time
,
1798 off_t
*size
, uint32_t *pattr
,
1801 NTSTATUS status
= NT_STATUS_OK
;
1802 SMB_STRUCT_STAT st
= { 0 };
1806 if (smbXcli_conn_protocol(cli
->conn
) >= PROTOCOL_SMB2_02
) {
1808 * NB. cli_qpathinfo2() checks pattr is valid before
1809 * storing a value into it, so we don't need to use
1810 * an intermediate attr variable as below but can
1811 * pass pattr directly.
1813 return cli_qpathinfo2(cli
, fname
,
1814 create_time
, access_time
, write_time
, change_time
,
1818 if (create_time
|| access_time
|| write_time
|| change_time
|| pattr
) {
1820 * cli_qpathinfo_basic() always indirects the passed
1821 * in pointers so we use intermediate variables to
1822 * collect all of them before assigning any requested
1825 status
= cli_qpathinfo_basic(cli
, fname
, &st
, &attr
);
1826 if (!NT_STATUS_IS_OK(status
)) {
1832 status
= cli_qpathinfo_standard(cli
, fname
,
1833 NULL
, &pos
, NULL
, NULL
, NULL
);
1834 if (!NT_STATUS_IS_OK(status
)) {
1842 *create_time
= st
.st_ex_btime
;
1845 *access_time
= st
.st_ex_atime
;
1848 *write_time
= st
.st_ex_mtime
;
1851 *change_time
= st
.st_ex_ctime
;
1860 return NT_STATUS_OK
;