2 Unix SMB/CIFS implementation.
3 SMB NT transaction handling
4 Copyright (C) Jeremy Allison 1994-2007
5 Copyright (C) Stefan (metze) Metzmacher 2003
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 "system/filesys.h"
23 #include "smbd/smbd.h"
24 #include "smbd/globals.h"
25 #include "fake_file.h"
26 #include "../libcli/security/security.h"
27 #include "../librpc/gen_ndr/ndr_security.h"
28 #include "passdb/lookup_sid.h"
30 #include "smbprofile.h"
31 #include "libsmb/libsmb.h"
32 #include "lib/util_ea.h"
33 #include "librpc/gen_ndr/ndr_quota.h"
34 #include "librpc/gen_ndr/ndr_security.h"
36 extern const struct generic_mapping file_generic_mapping
;
38 /*********************************************************************
39 Windows seems to do canonicalization of inheritance bits. Do the
41 *********************************************************************/
43 static void canonicalize_inheritance_bits(struct files_struct
*fsp
,
44 struct security_descriptor
*psd
)
46 bool set_auto_inherited
= false;
49 * We need to filter out the
50 * SEC_DESC_DACL_AUTO_INHERITED|SEC_DESC_DACL_AUTO_INHERIT_REQ
51 * bits. If both are set we store SEC_DESC_DACL_AUTO_INHERITED
52 * as this alters whether SEC_ACE_FLAG_INHERITED_ACE is set
53 * when an ACE is inherited. Otherwise we zero these bits out.
56 * http://social.msdn.microsoft.com/Forums/eu/os_fileservices/thread/11f77b68-731e-407d-b1b3-064750716531
61 if (!lp_acl_flag_inherited_canonicalization(SNUM(fsp
->conn
))) {
62 psd
->type
&= ~SEC_DESC_DACL_AUTO_INHERIT_REQ
;
66 if ((psd
->type
& (SEC_DESC_DACL_AUTO_INHERITED
|SEC_DESC_DACL_AUTO_INHERIT_REQ
))
67 == (SEC_DESC_DACL_AUTO_INHERITED
|SEC_DESC_DACL_AUTO_INHERIT_REQ
)) {
68 set_auto_inherited
= true;
71 psd
->type
&= ~(SEC_DESC_DACL_AUTO_INHERITED
|SEC_DESC_DACL_AUTO_INHERIT_REQ
);
72 if (set_auto_inherited
) {
73 psd
->type
|= SEC_DESC_DACL_AUTO_INHERITED
;
77 /****************************************************************************
78 Internal fn to set security descriptors.
79 ****************************************************************************/
81 NTSTATUS
set_sd(files_struct
*fsp
, struct security_descriptor
*psd
,
82 uint32_t security_info_sent
)
84 files_struct
*sd_fsp
= NULL
;
87 if (!CAN_WRITE(fsp
->conn
)) {
88 return NT_STATUS_ACCESS_DENIED
;
91 if (!lp_nt_acl_support(SNUM(fsp
->conn
))) {
95 status
= refuse_symlink_fsp(fsp
);
96 if (!NT_STATUS_IS_OK(status
)) {
97 DBG_DEBUG("ACL set on symlink %s denied.\n",
102 if (psd
->owner_sid
== NULL
) {
103 security_info_sent
&= ~SECINFO_OWNER
;
105 if (psd
->group_sid
== NULL
) {
106 security_info_sent
&= ~SECINFO_GROUP
;
109 /* Ensure we have at least one thing set. */
110 if ((security_info_sent
& (SECINFO_OWNER
|SECINFO_GROUP
|SECINFO_DACL
|SECINFO_SACL
)) == 0) {
115 /* Ensure we have the rights to do this. */
116 if (security_info_sent
& SECINFO_OWNER
) {
117 if (!(fsp
->access_mask
& SEC_STD_WRITE_OWNER
)) {
118 return NT_STATUS_ACCESS_DENIED
;
122 if (security_info_sent
& SECINFO_GROUP
) {
123 if (!(fsp
->access_mask
& SEC_STD_WRITE_OWNER
)) {
124 return NT_STATUS_ACCESS_DENIED
;
128 if (security_info_sent
& SECINFO_DACL
) {
129 if (!(fsp
->access_mask
& SEC_STD_WRITE_DAC
)) {
130 return NT_STATUS_ACCESS_DENIED
;
132 /* Convert all the generic bits. */
134 security_acl_map_generic(psd
->dacl
, &file_generic_mapping
);
138 if (security_info_sent
& SECINFO_SACL
) {
139 if (!(fsp
->access_mask
& SEC_FLAG_SYSTEM_SECURITY
)) {
140 return NT_STATUS_ACCESS_DENIED
;
143 * Setting a SACL also requires WRITE_DAC.
144 * See the smbtorture3 SMB2-SACL test.
146 if (!(fsp
->access_mask
& SEC_STD_WRITE_DAC
)) {
147 return NT_STATUS_ACCESS_DENIED
;
149 /* Convert all the generic bits. */
151 security_acl_map_generic(psd
->sacl
, &file_generic_mapping
);
155 canonicalize_inheritance_bits(fsp
, psd
);
157 if (DEBUGLEVEL
>= 10) {
158 DEBUG(10,("set_sd for file %s\n", fsp_str_dbg(fsp
)));
159 NDR_PRINT_DEBUG(security_descriptor
, psd
);
162 sd_fsp
= metadata_fsp(fsp
);
163 status
= SMB_VFS_FSET_NT_ACL(sd_fsp
, security_info_sent
, psd
);
170 static bool check_smb2_posix_chmod_ace(const struct files_struct
*fsp
,
171 uint32_t security_info_sent
,
172 struct security_descriptor
*psd
,
178 * This must be an ACL with one ACE containing an
179 * MS NFS style mode entry coming in on a POSIX
182 if (!fsp
->conn
->sconn
->using_smb2
) {
186 if (!(fsp
->posix_flags
& FSP_POSIX_FLAGS_OPEN
)) {
190 if (!(security_info_sent
& SECINFO_DACL
)) {
194 if (psd
->dacl
== NULL
) {
198 if (psd
->dacl
->num_aces
!= 1) {
202 cmp
= dom_sid_compare_domain(&global_sid_Unix_NFS_Mode
,
203 &psd
->dacl
->aces
[0].trustee
);
208 *pmode
= (mode_t
)psd
->dacl
->aces
[0].trustee
.sub_auths
[2];
209 *pmode
&= (S_IRWXU
| S_IRWXG
| S_IRWXO
);
214 /****************************************************************************
215 Internal fn to set security descriptors from a data blob.
216 ****************************************************************************/
218 NTSTATUS
set_sd_blob(files_struct
*fsp
, uint8_t *data
, uint32_t sd_len
,
219 uint32_t security_info_sent
)
221 struct security_descriptor
*psd
= NULL
;
223 bool do_chmod
= false;
224 mode_t smb2_posix_mode
= 0;
228 return NT_STATUS_INVALID_PARAMETER
;
231 status
= unmarshall_sec_desc(talloc_tos(), data
, sd_len
, &psd
);
233 if (!NT_STATUS_IS_OK(status
)) {
237 do_chmod
= check_smb2_posix_chmod_ace(fsp
,
242 return set_sd(fsp
, psd
, security_info_sent
);
247 ret
= SMB_VFS_FCHMOD(fsp
, smb2_posix_mode
);
249 status
= map_nt_error_from_unix(errno
);
250 DBG_ERR("smb2_posix_chmod [%s] [%04o] failed: %s\n",
252 (unsigned)smb2_posix_mode
,
260 /****************************************************************************
262 ****************************************************************************/
264 NTSTATUS
copy_internals(TALLOC_CTX
*ctx
,
265 connection_struct
*conn
,
266 struct smb_request
*req
,
267 struct files_struct
*src_dirfsp
,
268 struct smb_filename
*smb_fname_src
,
269 struct files_struct
*dst_dirfsp
,
270 struct smb_filename
*smb_fname_dst
,
273 files_struct
*fsp1
,*fsp2
;
277 NTSTATUS status
= NT_STATUS_OK
;
278 struct smb_filename
*parent
= NULL
;
279 struct smb_filename
*pathref
= NULL
;
281 if (!CAN_WRITE(conn
)) {
282 status
= NT_STATUS_MEDIA_WRITE_PROTECTED
;
286 /* Source must already exist. */
287 if (!VALID_STAT(smb_fname_src
->st
)) {
288 status
= NT_STATUS_OBJECT_NAME_NOT_FOUND
;
292 /* Ensure attributes match. */
293 fattr
= fdos_mode(smb_fname_src
->fsp
);
294 if ((fattr
& ~attrs
) & (FILE_ATTRIBUTE_HIDDEN
| FILE_ATTRIBUTE_SYSTEM
)) {
295 status
= NT_STATUS_NO_SUCH_FILE
;
299 /* Disallow if dst file already exists. */
300 if (VALID_STAT(smb_fname_dst
->st
)) {
301 status
= NT_STATUS_OBJECT_NAME_COLLISION
;
305 /* No links from a directory. */
306 if (S_ISDIR(smb_fname_src
->st
.st_ex_mode
)) {
307 status
= NT_STATUS_FILE_IS_A_DIRECTORY
;
311 DEBUG(10,("copy_internals: doing file copy %s to %s\n",
312 smb_fname_str_dbg(smb_fname_src
),
313 smb_fname_str_dbg(smb_fname_dst
)));
315 status
= SMB_VFS_CREATE_FILE(
318 src_dirfsp
, /* dirfsp */
319 smb_fname_src
, /* fname */
320 FILE_READ_DATA
|FILE_READ_ATTRIBUTES
|
321 FILE_READ_EA
, /* access_mask */
322 (FILE_SHARE_READ
| FILE_SHARE_WRITE
| /* share_access */
324 FILE_OPEN
, /* create_disposition*/
325 0, /* create_options */
326 FILE_ATTRIBUTE_NORMAL
, /* file_attributes */
327 NO_OPLOCK
, /* oplock_request */
329 0, /* allocation_size */
330 0, /* private_flags */
335 NULL
, NULL
); /* create context */
337 if (!NT_STATUS_IS_OK(status
)) {
341 status
= SMB_VFS_CREATE_FILE(
344 dst_dirfsp
, /* dirfsp */
345 smb_fname_dst
, /* fname */
346 FILE_WRITE_DATA
|FILE_WRITE_ATTRIBUTES
|
347 FILE_WRITE_EA
, /* access_mask */
348 (FILE_SHARE_READ
| FILE_SHARE_WRITE
| /* share_access */
350 FILE_CREATE
, /* create_disposition*/
351 0, /* create_options */
352 fattr
, /* file_attributes */
353 NO_OPLOCK
, /* oplock_request */
355 0, /* allocation_size */
356 0, /* private_flags */
361 NULL
, NULL
); /* create context */
363 if (!NT_STATUS_IS_OK(status
)) {
364 close_file_free(NULL
, &fsp1
, ERROR_CLOSE
);
368 if (smb_fname_src
->st
.st_ex_size
) {
369 ret
= vfs_transfer_file(fsp1
, fsp2
, smb_fname_src
->st
.st_ex_size
);
373 * As we are opening fsp1 read-only we only expect
374 * an error on close on fsp2 if we are out of space.
375 * Thus we don't look at the error return from the
378 close_file_free(NULL
, &fsp1
, NORMAL_CLOSE
);
380 /* Ensure the modtime is set correctly on the destination file. */
381 set_close_write_time(fsp2
, smb_fname_src
->st
.st_ex_mtime
);
383 status
= close_file_free(NULL
, &fsp2
, NORMAL_CLOSE
);
384 if (!NT_STATUS_IS_OK(status
)) {
385 DBG_WARNING("close_file_free() failed: %s\n",
388 * We can't do much but leak the fsp
393 /* Grrr. We have to do this as open_file_ntcreate adds FILE_ATTRIBUTE_ARCHIVE when it
394 creates the file. This isn't the correct thing to do in the copy
397 status
= SMB_VFS_PARENT_PATHNAME(conn
,
402 if (!NT_STATUS_IS_OK(status
)) {
405 if (smb_fname_dst
->fsp
== NULL
) {
406 status
= synthetic_pathref(parent
,
408 smb_fname_dst
->base_name
,
409 smb_fname_dst
->stream_name
,
412 smb_fname_dst
->flags
,
415 /* should we handle NT_STATUS_OBJECT_NAME_NOT_FOUND specially here ???? */
416 if (!NT_STATUS_IS_OK(status
)) {
420 file_set_dosmode(conn
, pathref
, fattr
, parent
, false);
421 smb_fname_dst
->st
.st_ex_mode
= pathref
->st
.st_ex_mode
;
423 file_set_dosmode(conn
, smb_fname_dst
, fattr
, parent
, false);
427 if (ret
< (off_t
)smb_fname_src
->st
.st_ex_size
) {
428 status
= NT_STATUS_DISK_FULL
;
432 if (!NT_STATUS_IS_OK(status
)) {
433 DEBUG(3,("copy_internals: Error %s copy file %s to %s\n",
434 nt_errstr(status
), smb_fname_str_dbg(smb_fname_src
),
435 smb_fname_str_dbg(smb_fname_dst
)));
441 /******************************************************************************
442 Fake up a completely empty SD.
443 *******************************************************************************/
445 static NTSTATUS
get_null_nt_acl(TALLOC_CTX
*mem_ctx
, struct security_descriptor
**ppsd
)
449 *ppsd
= make_standard_sec_desc( mem_ctx
, &global_sid_World
, &global_sid_World
, NULL
, &sd_size
);
451 DEBUG(0,("get_null_nt_acl: Unable to malloc space for security descriptor.\n"));
452 return NT_STATUS_NO_MEMORY
;
458 /****************************************************************************
459 Get a security descriptor from the file system, normalize for components
461 ****************************************************************************/
463 static NTSTATUS
smbd_fetch_security_desc(connection_struct
*conn
,
466 uint32_t security_info_wanted
,
467 struct security_descriptor
**ppsd
)
470 struct security_descriptor
*psd
= NULL
;
471 bool need_to_read_sd
= false;
474 * Get the permissions to return.
477 if ((security_info_wanted
& SECINFO_SACL
) &&
478 !(fsp
->access_mask
& SEC_FLAG_SYSTEM_SECURITY
)) {
479 DEBUG(10, ("Access to SACL denied.\n"));
480 return NT_STATUS_ACCESS_DENIED
;
483 if ((security_info_wanted
& (SECINFO_DACL
|SECINFO_OWNER
|SECINFO_GROUP
)) &&
484 !(fsp
->access_mask
& SEC_STD_READ_CONTROL
)) {
485 DEBUG(10, ("Access to DACL, OWNER, or GROUP denied.\n"));
486 return NT_STATUS_ACCESS_DENIED
;
489 status
= refuse_symlink_fsp(fsp
);
490 if (!NT_STATUS_IS_OK(status
)) {
491 DBG_DEBUG("ACL get on symlink %s denied.\n",
496 if (security_info_wanted
& (SECINFO_DACL
|SECINFO_OWNER
|
497 SECINFO_GROUP
|SECINFO_SACL
)) {
498 /* Don't return SECINFO_LABEL if anything else was
499 requested. See bug #8458. */
500 security_info_wanted
&= ~SECINFO_LABEL
;
503 * Only query the file system SD if the caller asks
504 * for any bits. This allows a caller to open without
505 * READ_CONTROL but still issue a query sd. See
508 need_to_read_sd
= true;
511 if (lp_nt_acl_support(SNUM(conn
)) &&
512 ((security_info_wanted
& SECINFO_LABEL
) == 0) &&
515 files_struct
*sd_fsp
= metadata_fsp(fsp
);
516 status
= SMB_VFS_FGET_NT_ACL(
517 sd_fsp
, security_info_wanted
, mem_ctx
, &psd
);
519 status
= get_null_nt_acl(mem_ctx
, &psd
);
522 if (!NT_STATUS_IS_OK(status
)) {
526 if (!(security_info_wanted
& SECINFO_OWNER
)) {
527 psd
->owner_sid
= NULL
;
529 if (!(security_info_wanted
& SECINFO_GROUP
)) {
530 psd
->group_sid
= NULL
;
532 if (!(security_info_wanted
& SECINFO_DACL
)) {
533 psd
->type
&= ~SEC_DESC_DACL_PRESENT
;
536 if (!(security_info_wanted
& SECINFO_SACL
)) {
537 psd
->type
&= ~SEC_DESC_SACL_PRESENT
;
541 /* If the SACL/DACL is NULL, but was requested, we mark that it is
542 * present in the reply to match Windows behavior */
543 if (psd
->sacl
== NULL
&&
544 security_info_wanted
& SECINFO_SACL
)
545 psd
->type
|= SEC_DESC_SACL_PRESENT
;
546 if (psd
->dacl
== NULL
&&
547 security_info_wanted
& SECINFO_DACL
)
548 psd
->type
|= SEC_DESC_DACL_PRESENT
;
550 if (security_info_wanted
& SECINFO_LABEL
) {
551 /* Like W2K3 return a null object. */
552 psd
->owner_sid
= NULL
;
553 psd
->group_sid
= NULL
;
556 psd
->type
&= ~(SEC_DESC_DACL_PRESENT
|SEC_DESC_SACL_PRESENT
);
563 /****************************************************************************
564 Write a security descriptor into marshalled format.
565 ****************************************************************************/
567 static NTSTATUS
smbd_marshall_security_desc(TALLOC_CTX
*mem_ctx
,
569 struct security_descriptor
*psd
,
570 uint32_t max_data_count
,
571 uint8_t **ppmarshalled_sd
,
574 *psd_size
= ndr_size_security_descriptor(psd
, 0);
576 DBG_NOTICE("sd_size = %zu.\n", *psd_size
);
578 if (DEBUGLEVEL
>= 10) {
579 DBG_DEBUG("security desc for file %s\n",
581 NDR_PRINT_DEBUG(security_descriptor
, psd
);
584 if (max_data_count
< *psd_size
) {
585 return NT_STATUS_BUFFER_TOO_SMALL
;
588 return marshall_sec_desc(mem_ctx
,
594 /****************************************************************************
595 Reply to query a security descriptor.
596 Callable from SMB1 and SMB2.
597 If it returns NT_STATUS_BUFFER_TOO_SMALL, psd_size is initialized with
599 ****************************************************************************/
601 NTSTATUS
smbd_do_query_security_desc(connection_struct
*conn
,
604 uint32_t security_info_wanted
,
605 uint32_t max_data_count
,
606 uint8_t **ppmarshalled_sd
,
610 struct security_descriptor
*psd
= NULL
;
613 * Get the permissions to return.
616 status
= smbd_fetch_security_desc(conn
,
619 security_info_wanted
,
621 if (!NT_STATUS_IS_OK(status
)) {
625 status
= smbd_marshall_security_desc(mem_ctx
,
635 #ifdef HAVE_SYS_QUOTAS
636 static enum ndr_err_code
fill_qtlist_from_sids(TALLOC_CTX
*mem_ctx
,
637 struct files_struct
*fsp
,
638 SMB_NTQUOTA_HANDLE
*qt_handle
,
639 struct dom_sid
*sids
,
643 TALLOC_CTX
*list_ctx
= NULL
;
645 list_ctx
= talloc_init("quota_sid_list");
647 if (list_ctx
== NULL
) {
648 DBG_ERR("failed to allocate\n");
649 return NDR_ERR_ALLOC
;
652 if (qt_handle
->quota_list
!=NULL
) {
653 free_ntquota_list(&(qt_handle
->quota_list
));
655 for (i
= 0; i
< elems
; i
++) {
656 SMB_NTQUOTA_STRUCT qt
;
657 SMB_NTQUOTA_LIST
*list_item
;
660 if (!NT_STATUS_IS_OK(vfs_get_ntquota(fsp
,
663 /* non fatal error, return empty item in result */
669 list_item
= talloc_zero(list_ctx
, SMB_NTQUOTA_LIST
);
670 if (list_item
== NULL
) {
671 DBG_ERR("failed to allocate\n");
672 return NDR_ERR_ALLOC
;
675 ok
= sid_to_uid(&sids
[i
], &list_item
->uid
);
677 struct dom_sid_buf buf
;
678 DBG_WARNING("Could not convert SID %s to uid\n",
679 dom_sid_str_buf(&sids
[i
], &buf
));
680 /* No idea what to return here... */
681 return NDR_ERR_INVALID_POINTER
;
684 list_item
->quotas
= talloc_zero(list_item
, SMB_NTQUOTA_STRUCT
);
685 if (list_item
->quotas
== NULL
) {
686 DBG_ERR("failed to allocate\n");
687 return NDR_ERR_ALLOC
;
690 *list_item
->quotas
= qt
;
691 list_item
->mem_ctx
= list_ctx
;
692 DLIST_ADD(qt_handle
->quota_list
, list_item
);
694 qt_handle
->tmp_list
= qt_handle
->quota_list
;
695 return NDR_ERR_SUCCESS
;
698 static enum ndr_err_code
extract_sids_from_buf(TALLOC_CTX
*mem_ctx
,
699 uint32_t sidlistlength
,
701 struct dom_sid
**sids
,
706 enum ndr_err_code err
;
708 struct sid_list_elem
{
709 struct sid_list_elem
*prev
, *next
;
713 struct sid_list_elem
*sid_list
= NULL
;
714 struct sid_list_elem
*iter
= NULL
;
715 TALLOC_CTX
*list_ctx
= talloc_init("sid_list");
727 struct ndr_pull
*ndr_pull
= NULL
;
729 if (sidlistlength
> sid_buf
->length
) {
730 DBG_ERR("sid_list_length 0x%x exceeds "
731 "available bytes %zx\n",
734 err
= NDR_ERR_OFFSET
;
738 struct file_get_quota_info info
;
739 struct sid_list_elem
*item
= NULL
;
740 uint32_t new_offset
= 0;
741 blob
.data
= sid_buf
->data
+ offset
;
742 blob
.length
= sidlistlength
- offset
;
743 ndr_pull
= ndr_pull_init_blob(&blob
, list_ctx
);
749 err
= ndr_pull_file_get_quota_info(ndr_pull
,
750 NDR_SCALARS
| NDR_BUFFERS
, &info
);
751 if (!NDR_ERR_CODE_IS_SUCCESS(err
)) {
752 DBG_ERR("Failed to pull file_get_quota_info "
753 "from sidlist buffer\n");
756 item
= talloc_zero(list_ctx
, struct sid_list_elem
);
762 item
->sid
= info
.sid
;
763 DLIST_ADD(sid_list
, item
);
765 if (i
== UINT32_MAX
) {
766 DBG_ERR("Integer overflow\n");
767 err
= NDR_ERR_ARRAY_SIZE
;
770 new_offset
= info
.next_entry_offset
;
772 /* if new_offset == 0 no more sid(s) to read. */
773 if (new_offset
== 0) {
778 if ((offset
+ new_offset
) < offset
) {
779 DBG_ERR("Integer wrap while adding "
780 "new_offset 0x%x to current "
781 "buffer offset 0x%x\n",
783 err
= NDR_ERR_OFFSET
;
787 offset
+= new_offset
;
789 /* check if new offset is outside buffer boundary. */
790 if (offset
>= sidlistlength
) {
791 DBG_ERR("bufsize 0x%x exceeded by "
792 "new offset 0x%x)\n",
795 err
= NDR_ERR_OFFSET
;
799 *sids
= talloc_zero_array(mem_ctx
, struct dom_sid
, i
);
808 for (iter
= sid_list
, i
= 0; iter
; iter
= iter
->next
, i
++) {
809 struct dom_sid_buf buf
;
810 (*sids
)[i
] = iter
->sid
;
811 DBG_DEBUG("quota SID[%u] %s\n",
813 dom_sid_str_buf(&iter
->sid
, &buf
));
816 err
= NDR_ERR_SUCCESS
;
818 TALLOC_FREE(list_ctx
);
822 NTSTATUS
smbd_do_query_getinfo_quota(TALLOC_CTX
*mem_ctx
,
826 uint32_t sid_list_length
,
828 uint32_t max_data_count
,
830 uint32_t *p_data_size
)
833 SMB_NTQUOTA_HANDLE
*qt_handle
= NULL
;
834 SMB_NTQUOTA_LIST
*qt_list
= NULL
;
835 DATA_BLOB blob
= data_blob_null
;
836 enum ndr_err_code err
;
839 (SMB_NTQUOTA_HANDLE
*)fsp
->fake_file_handle
->private_data
;
841 if (sid_list_length
) {
842 struct dom_sid
*sids
;
845 * error check pulled offsets and lengths for wrap and
846 * exceeding available bytes.
848 if (sid_list_length
> sid_buf
->length
) {
849 DBG_ERR("sid_list_length 0x%x exceeds "
850 "available bytes %zx\n",
853 return NT_STATUS_INVALID_PARAMETER
;
856 err
= extract_sids_from_buf(mem_ctx
, sid_list_length
,
857 sid_buf
, &sids
, &elems
);
858 if (!NDR_ERR_CODE_IS_SUCCESS(err
) || elems
== 0) {
859 return NT_STATUS_INVALID_PARAMETER
;
861 err
= fill_qtlist_from_sids(mem_ctx
,
866 if (!NDR_ERR_CODE_IS_SUCCESS(err
)) {
867 return NT_STATUS_INVALID_PARAMETER
;
869 } else if (restart_scan
) {
870 if (vfs_get_user_ntquota_list(fsp
,
871 &(qt_handle
->quota_list
))!=0) {
872 return NT_STATUS_INTERNAL_ERROR
;
875 if (qt_handle
->quota_list
!=NULL
&&
876 qt_handle
->tmp_list
==NULL
) {
877 free_ntquota_list(&(qt_handle
->quota_list
));
881 if (restart_scan
!=0 ) {
882 qt_list
= qt_handle
->quota_list
;
884 qt_list
= qt_handle
->tmp_list
;
886 status
= fill_quota_buffer(mem_ctx
, qt_list
,
890 &qt_handle
->tmp_list
);
891 if (!NT_STATUS_IS_OK(status
)) {
894 if (blob
.length
> max_data_count
) {
895 return NT_STATUS_BUFFER_TOO_SMALL
;
899 *p_data_size
= blob
.length
;
902 #endif /* HAVE_SYS_QUOTAS */