2 Unix SMB/CIFS implementation.
4 Copyright (C) Andrew Tridgell 2003
5 Copyright (C) Stefan Metzmacher 2006
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 "smb_server/smb_server.h"
23 #include "librpc/gen_ndr/ndr_misc.h"
24 #include "libcli/raw/libcliraw.h"
25 #include "libcli/raw/raw_proto.h"
27 #define BLOB_CHECK(cmd) do { \
30 NT_STATUS_NOT_OK_RETURN(_status); \
33 #define BLOB_CHECK_MIN_SIZE(blob, size) do { \
34 if ((blob)->length < (size)) { \
35 return NT_STATUS_INVALID_PARAMETER; \
40 /* align the end of the blob on an 8 byte boundary */
41 #define BLOB_ALIGN(blob, alignment) do { \
42 if ((blob)->length & ((alignment)-1)) { \
43 uint8_t _pad = (alignment) - ((blob)->length & ((alignment)-1)); \
44 BLOB_CHECK(smbsrv_blob_fill_data(blob, blob, (blob)->length+_pad)); \
48 /* grow the data size of a trans2 reply */
49 NTSTATUS
smbsrv_blob_grow_data(TALLOC_CTX
*mem_ctx
,
53 if (new_size
> blob
->length
) {
55 p
= talloc_realloc(mem_ctx
, blob
->data
, uint8_t, new_size
);
56 NT_STATUS_HAVE_NO_MEMORY(p
);
59 blob
->length
= new_size
;
63 /* grow the data, zero filling any new bytes */
64 NTSTATUS
smbsrv_blob_fill_data(TALLOC_CTX
*mem_ctx
,
68 uint32_t old_size
= blob
->length
;
69 BLOB_CHECK(smbsrv_blob_grow_data(mem_ctx
, blob
, new_size
));
70 if (new_size
> old_size
) {
71 memset(blob
->data
+ old_size
, 0, new_size
- old_size
);
77 pull a string from a blob in a trans2 request
79 size_t smbsrv_blob_pull_string(struct request_bufinfo
*bufinfo
,
80 const DATA_BLOB
*blob
,
86 /* we use STR_NO_RANGE_CHECK because the params are allocated
87 separately in a DATA_BLOB, so we need to do our own range
89 if (offset
>= blob
->length
) {
93 return req_pull_string(bufinfo
, str
,
95 blob
->length
- offset
,
96 STR_NO_RANGE_CHECK
| flags
);
100 push a string into the data section of a trans2 request
101 return the number of bytes consumed in the output
103 static ssize_t
smbsrv_blob_push_string(TALLOC_CTX
*mem_ctx
,
112 int alignment
= 0, ret
= 0, pkt_len
;
114 /* we use STR_NO_RANGE_CHECK because the params are allocated
115 separately in a DATA_BLOB, so we need to do our own range
117 if (!str
|| offset
>= blob
->length
) {
118 if (flags
& STR_LEN8BIT
) {
119 SCVAL(blob
->data
, len_offset
, 0);
121 SIVAL(blob
->data
, len_offset
, 0);
126 flags
|= STR_NO_RANGE_CHECK
;
128 if (dest_len
== -1 || (dest_len
> blob
->length
- offset
)) {
129 dest_len
= blob
->length
- offset
;
132 if (!(flags
& (STR_ASCII
|STR_UNICODE
))) {
133 flags
|= default_flags
;
136 if ((offset
&1) && (flags
& STR_UNICODE
) && !(flags
& STR_NOALIGN
)) {
139 SCVAL(blob
->data
+ offset
, 0, 0);
140 ret
= push_string(blob
->data
+ offset
+ 1, str
, dest_len
-1, flags
);
143 ret
= push_string(blob
->data
+ offset
, str
, dest_len
, flags
);
149 /* sometimes the string needs to be terminated, but the length
150 on the wire must not include the termination! */
153 if ((flags
& STR_LEN_NOTERM
) && (flags
& STR_TERMINATE
)) {
154 if ((flags
& STR_UNICODE
) && ret
>= 2) {
157 if ((flags
& STR_ASCII
) && ret
>= 1) {
162 if (flags
& STR_LEN8BIT
) {
163 SCVAL(blob
->data
, len_offset
, pkt_len
);
165 SIVAL(blob
->data
, len_offset
, pkt_len
);
168 return ret
+ alignment
;
172 append a string to the data section of a trans2 reply
173 len_offset points to the place in the packet where the length field
176 NTSTATUS
smbsrv_blob_append_string(TALLOC_CTX
*mem_ctx
,
179 unsigned int len_offset
,
185 const int max_bytes_per_char
= 3;
187 offset
= blob
->length
;
188 BLOB_CHECK(smbsrv_blob_grow_data(mem_ctx
, blob
, offset
+ (2+strlen_m(str
))*max_bytes_per_char
));
189 ret
= smbsrv_blob_push_string(mem_ctx
, blob
, len_offset
, offset
, str
, -1, default_flags
, flags
);
191 return NT_STATUS_FOOBAR
;
193 BLOB_CHECK(smbsrv_blob_grow_data(mem_ctx
, blob
, offset
+ ret
));
197 NTSTATUS
smbsrv_push_passthru_fsinfo(TALLOC_CTX
*mem_ctx
,
199 enum smb_fsinfo_level level
,
200 union smb_fsinfo
*fsinfo
,
201 int default_str_flags
)
207 case RAW_QFS_VOLUME_INFORMATION
:
208 BLOB_CHECK(smbsrv_blob_grow_data(mem_ctx
, blob
, 18));
210 push_nttime(blob
->data
, 0, fsinfo
->volume_info
.out
.create_time
);
211 SIVAL(blob
->data
, 8, fsinfo
->volume_info
.out
.serial_number
);
212 SSVAL(blob
->data
, 16, 0); /* padding */
213 BLOB_CHECK(smbsrv_blob_append_string(mem_ctx
, blob
,
214 fsinfo
->volume_info
.out
.volume_name
.s
,
215 12, default_str_flags
,
220 case RAW_QFS_SIZE_INFORMATION
:
221 BLOB_CHECK(smbsrv_blob_grow_data(mem_ctx
, blob
, 24));
223 SBVAL(blob
->data
, 0, fsinfo
->size_info
.out
.total_alloc_units
);
224 SBVAL(blob
->data
, 8, fsinfo
->size_info
.out
.avail_alloc_units
);
225 SIVAL(blob
->data
, 16, fsinfo
->size_info
.out
.sectors_per_unit
);
226 SIVAL(blob
->data
, 20, fsinfo
->size_info
.out
.bytes_per_sector
);
230 case RAW_QFS_DEVICE_INFORMATION
:
231 BLOB_CHECK(smbsrv_blob_grow_data(mem_ctx
, blob
, 8));
233 SIVAL(blob
->data
, 0, fsinfo
->device_info
.out
.device_type
);
234 SIVAL(blob
->data
, 4, fsinfo
->device_info
.out
.characteristics
);
238 case RAW_QFS_ATTRIBUTE_INFORMATION
:
239 BLOB_CHECK(smbsrv_blob_grow_data(mem_ctx
, blob
, 12));
241 SIVAL(blob
->data
, 0, fsinfo
->attribute_info
.out
.fs_attr
);
242 SIVAL(blob
->data
, 4, fsinfo
->attribute_info
.out
.max_file_component_length
);
243 /* this must not be null terminated or win98 gets
244 confused! also note that w2k3 returns this as
245 unicode even when ascii is negotiated */
246 BLOB_CHECK(smbsrv_blob_append_string(mem_ctx
, blob
,
247 fsinfo
->attribute_info
.out
.fs_type
.s
,
248 8, default_str_flags
,
253 case RAW_QFS_QUOTA_INFORMATION
:
254 BLOB_CHECK(smbsrv_blob_grow_data(mem_ctx
, blob
, 48));
256 SBVAL(blob
->data
, 0, fsinfo
->quota_information
.out
.unknown
[0]);
257 SBVAL(blob
->data
, 8, fsinfo
->quota_information
.out
.unknown
[1]);
258 SBVAL(blob
->data
, 16, fsinfo
->quota_information
.out
.unknown
[2]);
259 SBVAL(blob
->data
, 24, fsinfo
->quota_information
.out
.quota_soft
);
260 SBVAL(blob
->data
, 32, fsinfo
->quota_information
.out
.quota_hard
);
261 SBVAL(blob
->data
, 40, fsinfo
->quota_information
.out
.quota_flags
);
266 case RAW_QFS_FULL_SIZE_INFORMATION
:
267 BLOB_CHECK(smbsrv_blob_grow_data(mem_ctx
, blob
, 32));
269 SBVAL(blob
->data
, 0, fsinfo
->full_size_information
.out
.total_alloc_units
);
270 SBVAL(blob
->data
, 8, fsinfo
->full_size_information
.out
.call_avail_alloc_units
);
271 SBVAL(blob
->data
, 16, fsinfo
->full_size_information
.out
.actual_avail_alloc_units
);
272 SIVAL(blob
->data
, 24, fsinfo
->full_size_information
.out
.sectors_per_unit
);
273 SIVAL(blob
->data
, 28, fsinfo
->full_size_information
.out
.bytes_per_sector
);
277 case RAW_QFS_OBJECTID_INFORMATION
: {
280 BLOB_CHECK(smbsrv_blob_grow_data(mem_ctx
, blob
, 64));
282 status
= GUID_to_ndr_blob(&fsinfo
->objectid_information
.out
.guid
, mem_ctx
, &guid_blob
);
283 if (!NT_STATUS_IS_OK(status
)) {
287 memcpy(blob
->data
, guid_blob
.data
, guid_blob
.length
);
290 SBVAL(blob
->data
, 16 + 8*i
, fsinfo
->objectid_information
.out
.unknown
[i
]);
296 return NT_STATUS_INVALID_LEVEL
;
300 NTSTATUS
smbsrv_push_passthru_fileinfo(TALLOC_CTX
*mem_ctx
,
302 enum smb_fileinfo_level level
,
303 union smb_fileinfo
*st
,
304 int default_str_flags
)
310 case RAW_FILEINFO_BASIC_INFORMATION
:
311 BLOB_CHECK(smbsrv_blob_grow_data(mem_ctx
, blob
, 40));
313 push_nttime(blob
->data
, 0, st
->basic_info
.out
.create_time
);
314 push_nttime(blob
->data
, 8, st
->basic_info
.out
.access_time
);
315 push_nttime(blob
->data
, 16, st
->basic_info
.out
.write_time
);
316 push_nttime(blob
->data
, 24, st
->basic_info
.out
.change_time
);
317 SIVAL(blob
->data
, 32, st
->basic_info
.out
.attrib
);
318 SIVAL(blob
->data
, 36, 0); /* padding */
321 case RAW_FILEINFO_NETWORK_OPEN_INFORMATION
:
322 BLOB_CHECK(smbsrv_blob_grow_data(mem_ctx
, blob
, 56));
324 push_nttime(blob
->data
, 0, st
->network_open_information
.out
.create_time
);
325 push_nttime(blob
->data
, 8, st
->network_open_information
.out
.access_time
);
326 push_nttime(blob
->data
, 16, st
->network_open_information
.out
.write_time
);
327 push_nttime(blob
->data
, 24, st
->network_open_information
.out
.change_time
);
328 SBVAL(blob
->data
, 32, st
->network_open_information
.out
.alloc_size
);
329 SBVAL(blob
->data
, 40, st
->network_open_information
.out
.size
);
330 SIVAL(blob
->data
, 48, st
->network_open_information
.out
.attrib
);
331 SIVAL(blob
->data
, 52, 0); /* padding */
334 case RAW_FILEINFO_STANDARD_INFORMATION
:
335 BLOB_CHECK(smbsrv_blob_grow_data(mem_ctx
, blob
, 24));
337 SBVAL(blob
->data
, 0, st
->standard_info
.out
.alloc_size
);
338 SBVAL(blob
->data
, 8, st
->standard_info
.out
.size
);
339 SIVAL(blob
->data
, 16, st
->standard_info
.out
.nlink
);
340 SCVAL(blob
->data
, 20, st
->standard_info
.out
.delete_pending
);
341 SCVAL(blob
->data
, 21, st
->standard_info
.out
.directory
);
342 SSVAL(blob
->data
, 22, 0); /* padding */
345 case RAW_FILEINFO_ATTRIBUTE_TAG_INFORMATION
:
346 BLOB_CHECK(smbsrv_blob_grow_data(mem_ctx
, blob
, 8));
348 SIVAL(blob
->data
, 0, st
->attribute_tag_information
.out
.attrib
);
349 SIVAL(blob
->data
, 4, st
->attribute_tag_information
.out
.reparse_tag
);
352 case RAW_FILEINFO_EA_INFORMATION
:
353 BLOB_CHECK(smbsrv_blob_grow_data(mem_ctx
, blob
, 4));
355 SIVAL(blob
->data
, 0, st
->ea_info
.out
.ea_size
);
358 case RAW_FILEINFO_MODE_INFORMATION
:
359 BLOB_CHECK(smbsrv_blob_grow_data(mem_ctx
, blob
, 4));
361 SIVAL(blob
->data
, 0, st
->mode_information
.out
.mode
);
364 case RAW_FILEINFO_ALIGNMENT_INFORMATION
:
365 BLOB_CHECK(smbsrv_blob_grow_data(mem_ctx
, blob
, 4));
368 st
->alignment_information
.out
.alignment_requirement
);
371 case RAW_FILEINFO_ACCESS_INFORMATION
:
372 BLOB_CHECK(smbsrv_blob_grow_data(mem_ctx
, blob
, 4));
374 SIVAL(blob
->data
, 0, st
->access_information
.out
.access_flags
);
377 case RAW_FILEINFO_POSITION_INFORMATION
:
378 BLOB_CHECK(smbsrv_blob_grow_data(mem_ctx
, blob
, 8));
380 SBVAL(blob
->data
, 0, st
->position_information
.out
.position
);
383 case RAW_FILEINFO_COMPRESSION_INFORMATION
:
384 BLOB_CHECK(smbsrv_blob_grow_data(mem_ctx
, blob
, 16));
386 SBVAL(blob
->data
, 0, st
->compression_info
.out
.compressed_size
);
387 SSVAL(blob
->data
, 8, st
->compression_info
.out
.format
);
388 SCVAL(blob
->data
, 10, st
->compression_info
.out
.unit_shift
);
389 SCVAL(blob
->data
, 11, st
->compression_info
.out
.chunk_shift
);
390 SCVAL(blob
->data
, 12, st
->compression_info
.out
.cluster_shift
);
391 SSVAL(blob
->data
, 13, 0); /* 3 bytes padding */
392 SCVAL(blob
->data
, 15, 0);
395 case RAW_FILEINFO_INTERNAL_INFORMATION
:
396 BLOB_CHECK(smbsrv_blob_grow_data(mem_ctx
, blob
, 8));
398 SBVAL(blob
->data
, 0, st
->internal_information
.out
.file_id
);
401 case RAW_FILEINFO_ALL_INFORMATION
:
402 BLOB_CHECK(smbsrv_blob_grow_data(mem_ctx
, blob
, 72));
404 push_nttime(blob
->data
, 0, st
->all_info
.out
.create_time
);
405 push_nttime(blob
->data
, 8, st
->all_info
.out
.access_time
);
406 push_nttime(blob
->data
, 16, st
->all_info
.out
.write_time
);
407 push_nttime(blob
->data
, 24, st
->all_info
.out
.change_time
);
408 SIVAL(blob
->data
, 32, st
->all_info
.out
.attrib
);
409 SIVAL(blob
->data
, 36, 0); /* padding */
410 SBVAL(blob
->data
, 40, st
->all_info
.out
.alloc_size
);
411 SBVAL(blob
->data
, 48, st
->all_info
.out
.size
);
412 SIVAL(blob
->data
, 56, st
->all_info
.out
.nlink
);
413 SCVAL(blob
->data
, 60, st
->all_info
.out
.delete_pending
);
414 SCVAL(blob
->data
, 61, st
->all_info
.out
.directory
);
415 SSVAL(blob
->data
, 62, 0); /* padding */
416 SIVAL(blob
->data
, 64, st
->all_info
.out
.ea_size
);
417 BLOB_CHECK(smbsrv_blob_append_string(mem_ctx
, blob
,
418 st
->all_info
.out
.fname
.s
,
419 68, default_str_flags
,
423 case RAW_FILEINFO_NAME_INFORMATION
:
424 BLOB_CHECK(smbsrv_blob_grow_data(mem_ctx
, blob
, 4));
426 BLOB_CHECK(smbsrv_blob_append_string(mem_ctx
, blob
,
427 st
->name_info
.out
.fname
.s
,
428 0, default_str_flags
,
432 case RAW_FILEINFO_ALT_NAME_INFORMATION
:
433 BLOB_CHECK(smbsrv_blob_grow_data(mem_ctx
, blob
, 4));
435 BLOB_CHECK(smbsrv_blob_append_string(mem_ctx
, blob
,
436 st
->alt_name_info
.out
.fname
.s
,
437 0, default_str_flags
,
441 case RAW_FILEINFO_STREAM_INFORMATION
:
442 for (i
=0;i
<st
->stream_info
.out
.num_streams
;i
++) {
443 uint32_t data_size
= blob
->length
;
446 BLOB_CHECK(smbsrv_blob_grow_data(mem_ctx
, blob
, data_size
+ 24));
447 data
= blob
->data
+ data_size
;
448 SBVAL(data
, 8, st
->stream_info
.out
.streams
[i
].size
);
449 SBVAL(data
, 16, st
->stream_info
.out
.streams
[i
].alloc_size
);
450 BLOB_CHECK(smbsrv_blob_append_string(mem_ctx
, blob
,
451 st
->stream_info
.out
.streams
[i
].stream_name
.s
,
452 data_size
+ 4, default_str_flags
,
454 if (i
== st
->stream_info
.out
.num_streams
- 1) {
455 SIVAL(blob
->data
, data_size
, 0);
457 BLOB_CHECK(smbsrv_blob_fill_data(mem_ctx
, blob
, (blob
->length
+7)&~7));
458 SIVAL(blob
->data
, data_size
,
459 blob
->length
- data_size
);
464 case RAW_FILEINFO_SMB2_ALL_EAS
:
465 /* if no eas are returned the backend should
466 * have returned NO_EAS_ON_FILE or NO_MORE_EAS
468 * so it's a programmer error if num_eas == 0
470 if (st
->all_eas
.out
.num_eas
== 0) {
471 smb_panic("0 eas for SMB2_ALL_EAS - programmer error in ntvfs backend");
474 list_size
= ea_list_size_chained(st
->all_eas
.out
.num_eas
,
475 st
->all_eas
.out
.eas
, 4);
476 BLOB_CHECK(smbsrv_blob_grow_data(mem_ctx
, blob
, list_size
));
478 ea_put_list_chained(blob
->data
,
479 st
->all_eas
.out
.num_eas
,
480 st
->all_eas
.out
.eas
, 4);
483 case RAW_FILEINFO_SMB2_ALL_INFORMATION
:
484 BLOB_CHECK(smbsrv_blob_grow_data(mem_ctx
, blob
, 0x64));
486 push_nttime(blob
->data
, 0x00, st
->all_info2
.out
.create_time
);
487 push_nttime(blob
->data
, 0x08, st
->all_info2
.out
.access_time
);
488 push_nttime(blob
->data
, 0x10, st
->all_info2
.out
.write_time
);
489 push_nttime(blob
->data
, 0x18, st
->all_info2
.out
.change_time
);
490 SIVAL(blob
->data
, 0x20, st
->all_info2
.out
.attrib
);
491 SIVAL(blob
->data
, 0x24, st
->all_info2
.out
.unknown1
);
492 SBVAL(blob
->data
, 0x28, st
->all_info2
.out
.alloc_size
);
493 SBVAL(blob
->data
, 0x30, st
->all_info2
.out
.size
);
494 SIVAL(blob
->data
, 0x38, st
->all_info2
.out
.nlink
);
495 SCVAL(blob
->data
, 0x3C, st
->all_info2
.out
.delete_pending
);
496 SCVAL(blob
->data
, 0x3D, st
->all_info2
.out
.directory
);
497 SSVAL(blob
->data
, 0x3E, 0); /* padding */
498 SBVAL(blob
->data
, 0x40, st
->all_info2
.out
.file_id
);
499 SIVAL(blob
->data
, 0x48, st
->all_info2
.out
.ea_size
);
500 SIVAL(blob
->data
, 0x4C, st
->all_info2
.out
.access_mask
);
501 SBVAL(blob
->data
, 0x50, st
->all_info2
.out
.position
);
502 SIVAL(blob
->data
, 0x58, st
->all_info2
.out
.mode
);
503 SIVAL(blob
->data
, 0x5C, st
->all_info2
.out
.alignment_requirement
);
504 BLOB_CHECK(smbsrv_blob_append_string(mem_ctx
, blob
,
505 st
->all_info2
.out
.fname
.s
,
506 0x60, default_str_flags
,
511 return NT_STATUS_INVALID_LEVEL
;
515 NTSTATUS
smbsrv_pull_passthru_sfileinfo(TALLOC_CTX
*mem_ctx
,
516 enum smb_setfileinfo_level level
,
517 union smb_setfileinfo
*st
,
518 const DATA_BLOB
*blob
,
519 int default_str_flags
,
520 struct request_bufinfo
*bufinfo
)
526 case SMB_SFILEINFO_BASIC_INFORMATION
:
527 BLOB_CHECK_MIN_SIZE(blob
, 40);
529 st
->basic_info
.in
.create_time
= pull_nttime(blob
->data
, 0);
530 st
->basic_info
.in
.access_time
= pull_nttime(blob
->data
, 8);
531 st
->basic_info
.in
.write_time
= pull_nttime(blob
->data
, 16);
532 st
->basic_info
.in
.change_time
= pull_nttime(blob
->data
, 24);
533 st
->basic_info
.in
.attrib
= IVAL(blob
->data
, 32);
534 st
->basic_info
.in
.reserved
= IVAL(blob
->data
, 36);
538 case SMB_SFILEINFO_DISPOSITION_INFORMATION
:
539 BLOB_CHECK_MIN_SIZE(blob
, 1);
541 st
->disposition_info
.in
.delete_on_close
= CVAL(blob
->data
, 0);
545 case SMB_SFILEINFO_ALLOCATION_INFORMATION
:
546 BLOB_CHECK_MIN_SIZE(blob
, 8);
548 st
->allocation_info
.in
.alloc_size
= BVAL(blob
->data
, 0);
552 case RAW_SFILEINFO_END_OF_FILE_INFORMATION
:
553 BLOB_CHECK_MIN_SIZE(blob
, 8);
555 st
->end_of_file_info
.in
.size
= BVAL(blob
->data
, 0);
559 case RAW_SFILEINFO_RENAME_INFORMATION
:
561 return NT_STATUS_INTERNAL_ERROR
;
563 BLOB_CHECK_MIN_SIZE(blob
, 12);
564 st
->rename_information
.in
.overwrite
= CVAL(blob
->data
, 0);
565 st
->rename_information
.in
.root_fid
= IVAL(blob
->data
, 4);
566 len
= IVAL(blob
->data
, 8);
569 str_blob
.length
= MIN(str_blob
.length
, ofs
+len
);
570 smbsrv_blob_pull_string(bufinfo
, &str_blob
, ofs
,
571 &st
->rename_information
.in
.new_name
,
573 if (st
->rename_information
.in
.new_name
== NULL
) {
574 return NT_STATUS_FOOBAR
;
580 case RAW_SFILEINFO_LINK_INFORMATION
:
582 return NT_STATUS_INTERNAL_ERROR
;
584 BLOB_CHECK_MIN_SIZE(blob
, 20);
585 st
->link_information
.in
.overwrite
= CVAL(blob
->data
, 0);
586 st
->link_information
.in
.root_fid
= IVAL(blob
->data
, 8);
587 len
= IVAL(blob
->data
, 16);
590 str_blob
.length
= MIN(str_blob
.length
, ofs
+len
);
591 smbsrv_blob_pull_string(bufinfo
, &str_blob
, ofs
,
592 &st
->link_information
.in
.new_name
,
594 if (st
->link_information
.in
.new_name
== NULL
) {
595 return NT_STATUS_FOOBAR
;
600 case RAW_SFILEINFO_RENAME_INFORMATION_SMB2
:
601 /* SMB2 uses a different format for rename information */
603 return NT_STATUS_INTERNAL_ERROR
;
605 BLOB_CHECK_MIN_SIZE(blob
, 20);
606 st
->rename_information
.in
.overwrite
= CVAL(blob
->data
, 0);
607 st
->rename_information
.in
.root_fid
= BVAL(blob
->data
, 8);
608 len
= IVAL(blob
->data
,16);
611 str_blob
.length
= MIN(str_blob
.length
, ofs
+len
);
612 smbsrv_blob_pull_string(bufinfo
, &str_blob
, ofs
,
613 &st
->rename_information
.in
.new_name
,
615 if (st
->rename_information
.in
.new_name
== NULL
) {
616 return NT_STATUS_FOOBAR
;
621 case RAW_SFILEINFO_POSITION_INFORMATION
:
622 BLOB_CHECK_MIN_SIZE(blob
, 8);
624 st
->position_information
.in
.position
= BVAL(blob
->data
, 0);
628 case RAW_SFILEINFO_FULL_EA_INFORMATION
:
629 return ea_pull_list_chained(blob
,
631 &st
->full_ea_information
.in
.eas
.num_eas
,
632 &st
->full_ea_information
.in
.eas
.eas
);
634 case RAW_SFILEINFO_MODE_INFORMATION
:
635 BLOB_CHECK_MIN_SIZE(blob
, 4);
637 st
->mode_information
.in
.mode
= IVAL(blob
->data
, 0);
642 return NT_STATUS_INVALID_LEVEL
;
647 fill a single entry in a trans2 find reply
649 NTSTATUS
smbsrv_push_passthru_search(TALLOC_CTX
*mem_ctx
,
651 enum smb_search_data_level level
,
652 const union smb_search_data
*file
,
653 int default_str_flags
)
656 unsigned int ofs
= blob
->length
;
659 case RAW_SEARCH_DATA_DIRECTORY_INFO
:
660 BLOB_CHECK(smbsrv_blob_grow_data(mem_ctx
, blob
, ofs
+ 64));
661 data
= blob
->data
+ ofs
;
662 SIVAL(data
, 4, file
->directory_info
.file_index
);
663 push_nttime(data
, 8, file
->directory_info
.create_time
);
664 push_nttime(data
, 16, file
->directory_info
.access_time
);
665 push_nttime(data
, 24, file
->directory_info
.write_time
);
666 push_nttime(data
, 32, file
->directory_info
.change_time
);
667 SBVAL(data
, 40, file
->directory_info
.size
);
668 SBVAL(data
, 48, file
->directory_info
.alloc_size
);
669 SIVAL(data
, 56, file
->directory_info
.attrib
);
670 BLOB_CHECK(smbsrv_blob_append_string(mem_ctx
, blob
, file
->directory_info
.name
.s
,
671 ofs
+ 60, default_str_flags
,
672 STR_TERMINATE_ASCII
));
674 data
= blob
->data
+ ofs
;
675 SIVAL(data
, 0, blob
->length
- ofs
);
678 case RAW_SEARCH_DATA_FULL_DIRECTORY_INFO
:
679 BLOB_CHECK(smbsrv_blob_grow_data(mem_ctx
, blob
, ofs
+ 68));
680 data
= blob
->data
+ ofs
;
681 SIVAL(data
, 4, file
->full_directory_info
.file_index
);
682 push_nttime(data
, 8, file
->full_directory_info
.create_time
);
683 push_nttime(data
, 16, file
->full_directory_info
.access_time
);
684 push_nttime(data
, 24, file
->full_directory_info
.write_time
);
685 push_nttime(data
, 32, file
->full_directory_info
.change_time
);
686 SBVAL(data
, 40, file
->full_directory_info
.size
);
687 SBVAL(data
, 48, file
->full_directory_info
.alloc_size
);
688 SIVAL(data
, 56, file
->full_directory_info
.attrib
);
689 SIVAL(data
, 64, file
->full_directory_info
.ea_size
);
690 BLOB_CHECK(smbsrv_blob_append_string(mem_ctx
, blob
, file
->full_directory_info
.name
.s
,
691 ofs
+ 60, default_str_flags
,
692 STR_TERMINATE_ASCII
));
694 data
= blob
->data
+ ofs
;
695 SIVAL(data
, 0, blob
->length
- ofs
);
698 case RAW_SEARCH_DATA_NAME_INFO
:
699 BLOB_CHECK(smbsrv_blob_grow_data(mem_ctx
, blob
, ofs
+ 12));
700 data
= blob
->data
+ ofs
;
701 SIVAL(data
, 4, file
->name_info
.file_index
);
702 BLOB_CHECK(smbsrv_blob_append_string(mem_ctx
, blob
, file
->name_info
.name
.s
,
703 ofs
+ 8, default_str_flags
,
704 STR_TERMINATE_ASCII
));
706 data
= blob
->data
+ ofs
;
707 SIVAL(data
, 0, blob
->length
- ofs
);
710 case RAW_SEARCH_DATA_BOTH_DIRECTORY_INFO
:
711 BLOB_CHECK(smbsrv_blob_grow_data(mem_ctx
, blob
, ofs
+ 94));
712 data
= blob
->data
+ ofs
;
713 SIVAL(data
, 4, file
->both_directory_info
.file_index
);
714 push_nttime(data
, 8, file
->both_directory_info
.create_time
);
715 push_nttime(data
, 16, file
->both_directory_info
.access_time
);
716 push_nttime(data
, 24, file
->both_directory_info
.write_time
);
717 push_nttime(data
, 32, file
->both_directory_info
.change_time
);
718 SBVAL(data
, 40, file
->both_directory_info
.size
);
719 SBVAL(data
, 48, file
->both_directory_info
.alloc_size
);
720 SIVAL(data
, 56, file
->both_directory_info
.attrib
);
721 SIVAL(data
, 64, file
->both_directory_info
.ea_size
);
722 SCVAL(data
, 69, 0); /* reserved */
723 memset(data
+70,0,24);
724 smbsrv_blob_push_string(mem_ctx
, blob
,
726 file
->both_directory_info
.short_name
.s
,
727 24, default_str_flags
,
728 STR_UNICODE
| STR_LEN8BIT
);
729 BLOB_CHECK(smbsrv_blob_append_string(mem_ctx
, blob
, file
->both_directory_info
.name
.s
,
730 ofs
+ 60, default_str_flags
,
731 STR_TERMINATE_ASCII
));
733 data
= blob
->data
+ ofs
;
734 SIVAL(data
, 0, blob
->length
- ofs
);
737 case RAW_SEARCH_DATA_ID_FULL_DIRECTORY_INFO
:
738 BLOB_CHECK(smbsrv_blob_grow_data(mem_ctx
, blob
, ofs
+ 80));
739 data
= blob
->data
+ ofs
;
740 SIVAL(data
, 4, file
->id_full_directory_info
.file_index
);
741 push_nttime(data
, 8, file
->id_full_directory_info
.create_time
);
742 push_nttime(data
, 16, file
->id_full_directory_info
.access_time
);
743 push_nttime(data
, 24, file
->id_full_directory_info
.write_time
);
744 push_nttime(data
, 32, file
->id_full_directory_info
.change_time
);
745 SBVAL(data
, 40, file
->id_full_directory_info
.size
);
746 SBVAL(data
, 48, file
->id_full_directory_info
.alloc_size
);
747 SIVAL(data
, 56, file
->id_full_directory_info
.attrib
);
748 SIVAL(data
, 64, file
->id_full_directory_info
.ea_size
);
749 SIVAL(data
, 68, 0); /* padding */
750 SBVAL(data
, 72, file
->id_full_directory_info
.file_id
);
751 BLOB_CHECK(smbsrv_blob_append_string(mem_ctx
, blob
, file
->id_full_directory_info
.name
.s
,
752 ofs
+ 60, default_str_flags
,
753 STR_TERMINATE_ASCII
));
755 data
= blob
->data
+ ofs
;
756 SIVAL(data
, 0, blob
->length
- ofs
);
759 case RAW_SEARCH_DATA_ID_BOTH_DIRECTORY_INFO
:
760 BLOB_CHECK(smbsrv_blob_grow_data(mem_ctx
, blob
, ofs
+ 104));
761 data
= blob
->data
+ ofs
;
762 SIVAL(data
, 4, file
->id_both_directory_info
.file_index
);
763 push_nttime(data
, 8, file
->id_both_directory_info
.create_time
);
764 push_nttime(data
, 16, file
->id_both_directory_info
.access_time
);
765 push_nttime(data
, 24, file
->id_both_directory_info
.write_time
);
766 push_nttime(data
, 32, file
->id_both_directory_info
.change_time
);
767 SBVAL(data
, 40, file
->id_both_directory_info
.size
);
768 SBVAL(data
, 48, file
->id_both_directory_info
.alloc_size
);
769 SIVAL(data
, 56, file
->id_both_directory_info
.attrib
);
770 SIVAL(data
, 64, file
->id_both_directory_info
.ea_size
);
771 SCVAL(data
, 69, 0); /* reserved */
772 memset(data
+70,0,26);
773 smbsrv_blob_push_string(mem_ctx
, blob
,
775 file
->id_both_directory_info
.short_name
.s
,
776 24, default_str_flags
,
777 STR_UNICODE
| STR_LEN8BIT
);
778 SBVAL(data
, 96, file
->id_both_directory_info
.file_id
);
779 BLOB_CHECK(smbsrv_blob_append_string(mem_ctx
, blob
, file
->id_both_directory_info
.name
.s
,
780 ofs
+ 60, default_str_flags
,
781 STR_TERMINATE_ASCII
));
783 data
= blob
->data
+ ofs
;
784 SIVAL(data
, 0, blob
->length
- ofs
);
788 return NT_STATUS_INVALID_LEVEL
;