2 * Unix SMB/CIFS implementation.
4 * Support for OneFS native NTFS ACLs
6 * Copyright (C) Steven Danneman, 2008
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/>.
24 #include <isi_acl/isi_acl_util.h>
25 #include <ifs/ifs_syscalls.h>
27 const struct enum_list enum_onefs_acl_wire_format[] = {
28 {ACL_FORMAT_RAW, "No Format"},
29 {ACL_FORMAT_WINDOWS_SD, "Format Windows SD"},
30 {ACL_FORMAT_ALWAYS, "Always Format SD"},
35 * Turn SID into UID/GID and setup a struct ifs_identity
38 onefs_sid_to_identity(const DOM_SID *sid, struct ifs_identity *id,
41 enum ifs_identity_type type = IFS_ID_TYPE_LAST+1;
45 if (!sid || sid_equal(sid, &global_sid_NULL))
46 type = IFS_ID_TYPE_NULL;
47 else if (sid_equal(sid, &global_sid_World))
48 type = IFS_ID_TYPE_EVERYONE;
49 else if (sid_equal(sid, &global_sid_Creator_Owner))
50 type = IFS_ID_TYPE_CREATOR_OWNER;
51 else if (sid_equal(sid, &global_sid_Creator_Group))
52 type = IFS_ID_TYPE_CREATOR_GROUP;
54 if (!sid_to_gid(sid, &gid))
56 type = IFS_ID_TYPE_GID;
58 if (sid_to_uid(sid, &uid))
59 type = IFS_ID_TYPE_UID;
60 else if (sid_to_gid(sid, &gid))
61 type = IFS_ID_TYPE_GID;
66 if (aclu_initialize_identity(id, type, uid, gid, is_group)) {
67 DEBUG(3, ("Call to aclu_initialize_identity failed! id=%x, "
68 "type=%d, uid=%u, gid=%u, is_group=%d\n",
69 (unsigned int)id, type, uid, gid, is_group));
77 * Turn struct ifs_identity into SID
80 onefs_identity_to_sid(struct ifs_identity *id, DOM_SID *sid)
85 if (id->type >= IFS_ID_TYPE_LAST)
90 uid_to_sid(sid, id->id.uid);
93 gid_to_sid(sid, id->id.gid);
95 case IFS_ID_TYPE_EVERYONE:
96 sid_copy(sid, &global_sid_World);
98 case IFS_ID_TYPE_NULL:
99 sid_copy(sid, &global_sid_NULL);
101 case IFS_ID_TYPE_CREATOR_OWNER:
102 sid_copy(sid, &global_sid_Creator_Owner);
104 case IFS_ID_TYPE_CREATOR_GROUP:
105 sid_copy(sid, &global_sid_Creator_Group);
108 DEBUG(0, ("Unknown identity type: %d\n", id->type));
116 onefs_og_to_identity(DOM_SID *sid, struct ifs_identity * ident,
117 bool is_group, int snum)
119 const DOM_SID *b_admin_sid = &global_sid_Builtin_Administrators;
121 if (!onefs_sid_to_identity(sid, ident, is_group)) {
122 if (!lp_parm_bool(snum, PARM_ONEFS_TYPE,
123 PARM_UNMAPPABLE_SIDS_IGNORE,
124 PARM_UNMAPPABLE_SIDS_IGNORE_DEFAULT)) {
125 DEBUG(3, ("Unresolvable SID (%s) found.\n",
126 sid_string_dbg(sid)));
129 if (!onefs_sid_to_identity(b_admin_sid, ident, is_group)) {
132 DEBUG(3, ("Mapping unresolvable owner SID (%s) to Builtin "
133 "Administrators group.\n",
134 sid_string_dbg(sid)));
140 sid_in_ignore_list(DOM_SID * sid, int snum)
142 const char ** sid_list = NULL;
145 sid_list = lp_parm_string_list(snum, PARM_ONEFS_TYPE,
146 PARM_UNMAPPABLE_SIDS_IGNORE_LIST,
147 PARM_UNMAPPABLE_SIDS_IGNORE_LIST_DEFAULT);
149 /* Fast path a NULL list */
150 if (!sid_list || *sid_list == NULL)
154 if (string_to_sid(&match, *sid_list))
155 if (sid_equal(sid, &match))
164 * Convert a trustee to a struct identity
167 onefs_samba_ace_to_ace(SEC_ACE * samba_ace, struct ifs_ace * ace,
168 bool *mapped, int snum)
170 struct ifs_identity ident = {.type=IFS_ID_TYPE_LAST, .id.uid=0};
174 SMB_ASSERT(samba_ace);
176 if (onefs_sid_to_identity(&samba_ace->trustee, &ident, false)) {
180 SMB_ASSERT(ident.id.uid >= 0);
182 /* Ignore the sid if it's in the list */
183 if (sid_in_ignore_list(&samba_ace->trustee, snum)) {
184 DEBUG(3, ("Silently failing to set ACE for SID (%s) "
185 "because it is in the ignore sids list\n",
186 sid_string_dbg(&samba_ace->trustee)));
188 } else if ((samba_ace->type == SEC_ACE_TYPE_ACCESS_DENIED) &&
189 lp_parm_bool(snum, PARM_ONEFS_TYPE,
190 PARM_UNMAPPABLE_SIDS_DENY_EVERYONE,
191 PARM_UNMAPPABLE_SIDS_DENY_EVERYONE_DEFAULT)) {
192 /* If the ace is deny translated to Everyone */
193 DEBUG(3, ("Mapping unresolvable deny ACE SID (%s) "
195 sid_string_dbg(&samba_ace->trustee)));
196 if (aclu_initialize_identity(&ident,
197 IFS_ID_TYPE_EVERYONE, 0, 0, False) != 0) {
198 DEBUG(2, ("aclu_initialize_identity() "
199 "failed making Everyone\n"));
203 } else if (lp_parm_bool(snum, PARM_ONEFS_TYPE,
204 PARM_UNMAPPABLE_SIDS_IGNORE,
205 PARM_UNMAPPABLE_SIDS_IGNORE_DEFAULT)) {
206 DEBUG(3, ("Silently failing to set ACE for SID (%s) "
207 "because it is unresolvable\n",
208 sid_string_dbg(&samba_ace->trustee)));
211 /* Fail for lack of a better option */
217 if (aclu_initialize_ace(ace, samba_ace->type,
218 samba_ace->access_mask, samba_ace->flags, 0,
222 if ((ace->trustee.type == IFS_ID_TYPE_CREATOR_OWNER ||
223 ace->trustee.type == IFS_ID_TYPE_CREATOR_GROUP) &&
224 nt4_compatible_acls())
225 ace->flags |= SEC_ACE_FLAG_INHERIT_ONLY;
232 * Convert a SEC_ACL to a struct ifs_security_acl
235 onefs_samba_acl_to_acl(SEC_ACL *samba_acl, struct ifs_security_acl **acl,
236 bool * ignore_aces, int snum)
239 struct ifs_ace *aces = NULL;
244 SMB_ASSERT(ignore_aces);
246 if ((!acl) || (!samba_acl))
249 samba_aces = samba_acl->aces;
251 if (samba_acl->num_aces > 0 && samba_aces) {
253 num_aces = samba_acl->num_aces;
254 aces = SMB_MALLOC_ARRAY(struct ifs_ace, num_aces);
256 for (i = 0, j = 0; j < num_aces; i++, j++) {
257 if (!onefs_samba_ace_to_ace(&samba_aces[j],
258 &aces[i], &mapped, snum))
267 /* If aces are given but we cannot apply them due to the reasons
268 * above we do not change the SD. However, if we are told to
269 * explicitly set an SD with 0 aces we honor this operation */
270 *ignore_aces = samba_acl->num_aces > 0 && num_aces < 1;
272 if (*ignore_aces == false)
273 if (aclu_initialize_acl(acl, aces, num_aces))
276 if (aclu_initialize_acl(acl, aces, num_aces))
279 /* Currently aclu_initialize_acl should copy the aces over, allowing
280 * us to immediately free */
290 * Convert a struct ifs_security_acl to a SEC_ACL
293 onefs_acl_to_samba_acl(struct ifs_security_acl *acl, SEC_ACL **samba_acl)
295 SEC_ACE *samba_aces = NULL;
296 SEC_ACL *tmp_samba_acl = NULL;
308 /* Determine number of aces in ACL */
312 num_aces = acl->num_aces;
314 /* Allocate the ace list. */
316 if ((samba_aces = SMB_MALLOC_ARRAY(SEC_ACE, num_aces)) == NULL)
318 DEBUG(0, ("Unable to malloc space for %d aces.\n",
322 memset(samba_aces, '\0', (num_aces) * sizeof(SEC_ACE));
325 for (i = 0; i < num_aces; i++) {
328 if (!onefs_identity_to_sid(&acl->aces[i].trustee, &sid))
331 init_sec_ace(&samba_aces[i], &sid, acl->aces[i].type,
332 acl->aces[i].access_mask, acl->aces[i].flags);
335 if ((tmp_samba_acl = make_sec_acl(talloc_tos(), acl->revision, num_aces,
336 samba_aces)) == NULL) {
337 DEBUG(0, ("Unable to malloc space for acl.\n"));
341 *samba_acl = tmp_samba_acl;
342 SAFE_FREE(samba_aces);
345 SAFE_FREE(samba_aces);
350 * @brief Reorder ACLs into the "correct" order for Windows Explorer.
352 * Windows Explorer expects ACLs to be in a standard order (inherited first,
353 * then deny, then permit.) When ACLs are composed from POSIX file permissions
354 * bits, they may not match these expectations, generating an annoying warning
355 * dialog for the user. This function will, if configured appropriately,
356 * reorder the ACLs for these "synthetic" (POSIX-derived) descriptors to prevent
357 * this. The list is changed within the security descriptor passed in.
359 * @param fsp files_struct with service configs; must not be NULL
360 * @param sd security descriptor being normalized;
361 * sd->dacl->aces is rewritten in-place, so must not be NULL
362 * @return true on success, errno will be set on error
364 * @bug Although Windows Explorer likes the reordering, they seem to cause
365 * problems with Excel and Word sending back the reordered ACLs to us and
366 * changing policy; see Isilon bug 30165.
369 onefs_canon_acl(files_struct *fsp, struct ifs_security_descriptor *sd)
373 struct ifs_ace *new_aces = NULL;
374 int new_aces_count = 0;
375 SMB_STRUCT_STAT sbuf;
377 if (sd == NULL || sd->dacl == NULL || sd->dacl->num_aces == 0)
381 * Find out if this is a windows bit, and if the smb policy wants us to
384 SMB_ASSERT(fsp != NULL);
385 switch (lp_parm_enum(SNUM(fsp->conn), PARM_ONEFS_TYPE,
386 PARM_ACL_WIRE_FORMAT, enum_onefs_acl_wire_format,
387 PARM_ACL_WIRE_FORMAT_DEFAULT)) {
391 case ACL_FORMAT_WINDOWS_SD:
392 error = SMB_VFS_FSTAT(fsp, &sbuf);
396 if ((sbuf.st_flags & SF_HASNTFSACL) != 0) {
397 DEBUG(10, ("Did not canonicalize ACLs because a "
398 "Windows ACL set was found for file %s\n",
404 case ACL_FORMAT_ALWAYS:
412 new_aces = SMB_MALLOC_ARRAY(struct ifs_ace, sd->dacl->num_aces);
413 if (new_aces == NULL)
417 * By walking down the list 3 separate times, we can avoid the need
418 * to create multiple temp buffers and extra copies.
420 for (cur = 0; cur < sd->dacl->num_aces; cur++) {
421 if (sd->dacl->aces[cur].flags & IFS_ACE_FLAG_INHERITED_ACE)
422 new_aces[new_aces_count++] = sd->dacl->aces[cur];
425 for (cur = 0; cur < sd->dacl->num_aces; cur++) {
426 if (!(sd->dacl->aces[cur].flags & IFS_ACE_FLAG_INHERITED_ACE) &&
427 (sd->dacl->aces[cur].type == IFS_ACE_TYPE_ACCESS_DENIED))
428 new_aces[new_aces_count++] = sd->dacl->aces[cur];
431 for (cur = 0; cur < sd->dacl->num_aces; cur++) {
432 if (!(sd->dacl->aces[cur].flags & IFS_ACE_FLAG_INHERITED_ACE) &&
433 !(sd->dacl->aces[cur].type == IFS_ACE_TYPE_ACCESS_DENIED))
434 new_aces[new_aces_count++] = sd->dacl->aces[cur];
437 SMB_ASSERT(new_aces_count == sd->dacl->num_aces);
438 DEBUG(10, ("Performed canonicalization of ACLs for file %s\n",
442 * At this point you would think we could just do this:
443 * SAFE_FREE(sd->dacl->aces);
444 * sd->dacl->aces = new_aces;
445 * However, in some cases the existing aces pointer does not point
446 * to the beginning of an allocated block. So we have to do a more
449 memcpy(sd->dacl->aces, new_aces,
450 sizeof(struct ifs_ace) * new_aces_count);
458 * This enum is a helper for onefs_fget_nt_acl() to communicate with
461 enum mode_ident { USR, GRP, OTH };
464 * Initializes an ACE for addition to a synthetic ACL.
466 static struct ifs_ace onefs_init_ace(struct connection_struct *conn,
469 enum mode_ident ident)
471 struct ifs_ace result;
472 enum ifs_ace_rights r,w,x;
474 r = isdir ? UNIX_DIRECTORY_ACCESS_R : UNIX_ACCESS_R;
475 w = isdir ? UNIX_DIRECTORY_ACCESS_W : UNIX_ACCESS_W;
476 x = isdir ? UNIX_DIRECTORY_ACCESS_X : UNIX_ACCESS_X;
478 result.type = IFS_ACE_TYPE_ACCESS_ALLOWED;
479 result.ifs_flags = 0;
480 result.flags = isdir ? IFS_ACE_FLAG_CONTAINER_INHERIT :
481 IFS_ACE_FLAG_OBJECT_INHERIT;
482 result.flags |= IFS_ACE_FLAG_INHERIT_ONLY;
487 ((mode & S_IRUSR) ? r : 0 ) |
488 ((mode & S_IWUSR) ? w : 0 ) |
489 ((mode & S_IXUSR) ? x : 0 );
490 if (lp_parm_bool(SNUM(conn), PARM_ONEFS_TYPE,
491 PARM_CREATOR_OWNER_GETS_FULL_CONTROL,
492 PARM_CREATOR_OWNER_GETS_FULL_CONTROL_DEFAULT))
493 result.access_mask |= GENERIC_ALL_ACCESS;
494 result.trustee.type = IFS_ID_TYPE_CREATOR_OWNER;
498 ((mode & S_IRGRP) ? r : 0 ) |
499 ((mode & S_IWGRP) ? w : 0 ) |
500 ((mode & S_IXGRP) ? x : 0 );
501 result.trustee.type = IFS_ID_TYPE_CREATOR_GROUP;
505 ((mode & S_IROTH) ? r : 0 ) |
506 ((mode & S_IWOTH) ? w : 0 ) |
507 ((mode & S_IXOTH) ? x : 0 );
508 result.trustee.type = IFS_ID_TYPE_EVERYONE;
516 * This adds inheritable ACEs to the end of the DACL, with the ACEs
517 * being derived from the mode bits. This is useful for clients that have the
518 * MoveSecurityAttributes regkey set to 0 or are in Simple File Sharing Mode.
520 * On these clients, when copying files from one folder to another inside the
521 * same volume/share, the DACL is explicitely cleared. Without inheritable
522 * aces on the target folder the mode bits of the copied file are set to 000.
524 * See Isilon Bug 27990
526 * Note: This function allocates additional memory onto sd->dacl->aces, that
527 * must be freed by the caller.
529 static bool add_sfs_aces(files_struct *fsp, struct ifs_security_descriptor *sd)
532 SMB_STRUCT_STAT sbuf;
534 error = SMB_VFS_FSTAT(fsp, &sbuf);
536 DEBUG(0, ("Failed to stat %s in simple files sharing "
537 "compatibility mode. errno=%d\n",
538 fsp->fsp_name, errno));
542 /* Only continue if this is a synthetic ACL and a directory. */
543 if (S_ISDIR(sbuf.st_mode) && (sbuf.st_flags & SF_HASNTFSACL) == 0) {
544 struct ifs_ace new_aces[6];
545 struct ifs_ace *old_aces;
546 int i, num_aces_to_add = 0;
547 mode_t file_mode = 0, dir_mode = 0;
549 /* Use existing samba logic to derive the mode bits. */
550 file_mode = unix_mode(fsp->conn, 0, fsp->fsp_name, false);
551 dir_mode = unix_mode(fsp->conn, aDIR, fsp->fsp_name, false);
553 /* Initialize ACEs. */
554 new_aces[0] = onefs_init_ace(fsp->conn, file_mode, false, USR);
555 new_aces[1] = onefs_init_ace(fsp->conn, file_mode, false, GRP);
556 new_aces[2] = onefs_init_ace(fsp->conn, file_mode, false, OTH);
557 new_aces[3] = onefs_init_ace(fsp->conn, dir_mode, true, USR);
558 new_aces[4] = onefs_init_ace(fsp->conn, dir_mode, true, GRP);
559 new_aces[5] = onefs_init_ace(fsp->conn, dir_mode, true, OTH);
561 for (i = 0; i < 6; i++)
562 if (new_aces[i].access_mask != 0)
565 /* Expand the ACEs array */
566 if (num_aces_to_add != 0) {
567 old_aces = sd->dacl->aces;
569 sd->dacl->aces = SMB_MALLOC_ARRAY(struct ifs_ace,
570 sd->dacl->num_aces + num_aces_to_add);
571 if (!sd->dacl->aces) {
572 DEBUG(0, ("Unable to malloc space for "
574 sd->dacl->num_aces + num_aces_to_add));
577 memcpy(sd->dacl->aces, old_aces,
578 sizeof(struct ifs_ace) * sd->dacl->num_aces);
580 /* Add the new ACEs to the DACL. */
581 for (i = 0; i < 6; i++) {
582 if (new_aces[i].access_mask != 0) {
583 sd->dacl->aces[sd->dacl->num_aces] =
585 sd->dacl->num_aces++;
594 * Isilon-specific function for getting an NTFS ACL from an open file.
596 * @param[out] ppdesc SecDesc to allocate and fill in
598 * @return NTSTATUS based off errno on error
601 onefs_fget_nt_acl(vfs_handle_struct *handle, files_struct *fsp,
602 uint32 security_info, SEC_DESC **ppdesc)
605 uint32_t sd_size = 0;
607 struct ifs_security_descriptor *sd = NULL;
608 DOM_SID owner_sid, group_sid;
609 DOM_SID *ownerp, *groupp;
610 SEC_ACL *dacl, *sacl;
612 bool alloced = false;
613 bool new_aces_alloced = false;
614 bool fopened = false;
615 NTSTATUS status = NT_STATUS_OK;
619 DEBUG(5, ("Getting sd for file %s. security_info=%u\n",
620 fsp->fsp_name, security_info));
622 if (fsp->fh->fd == -1) {
623 if ((fsp->fh->fd = onefs_sys_create_file(handle->conn,
637 DEBUG(0, ("Error opening file %s. errno=%d (%s)\n",
638 fsp->fsp_name, errno, strerror(errno)));
639 status = map_nt_error_from_unix(errno);
645 /* Get security descriptor */
648 /* Allocate memory for get_security_descriptor */
650 sd = SMB_REALLOC(sd, sd_size);
652 DEBUG(0, ("Unable to malloc %u bytes of space "
653 "for security descriptor.\n", sd_size));
654 status = map_nt_error_from_unix(errno);
661 error = ifs_get_security_descriptor(fsp->fh->fd, security_info,
662 sd_size, &sd_size, sd);
663 if (error && (errno != EMSGSIZE)) {
664 DEBUG(0, ("Failed getting size of security descriptor! "
665 "errno=%d\n", errno));
666 status = map_nt_error_from_unix(errno);
671 DEBUG(5, ("Got sd, size=%u:\n", sd_size));
673 if (lp_parm_bool(SNUM(fsp->conn),
675 PARM_SIMPLE_FILE_SHARING_COMPATIBILITY_MODE,
676 PARM_SIMPLE_FILE_SHARING_COMPATIBILITY_MODE_DEFAULT) &&
678 if(!(new_aces_alloced = add_sfs_aces(fsp, sd)))
682 if (!(onefs_canon_acl(fsp, sd))) {
683 status = map_nt_error_from_unix(errno);
687 DEBUG(5, ("Finished canonicalizing ACL\n"));
694 /* Copy owner into ppdesc */
695 if (security_info & OWNER_SECURITY_INFORMATION) {
696 if (!onefs_identity_to_sid(sd->owner, &owner_sid)) {
697 status = NT_STATUS_INVALID_PARAMETER;
704 /* Copy group into ppdesc */
705 if (security_info & GROUP_SECURITY_INFORMATION) {
706 if (!onefs_identity_to_sid(sd->group, &group_sid)) {
707 status = NT_STATUS_INVALID_PARAMETER;
714 /* Copy DACL into ppdesc */
715 if (security_info & DACL_SECURITY_INFORMATION) {
716 if (!onefs_acl_to_samba_acl(sd->dacl, &dacl)) {
717 status = NT_STATUS_INVALID_PARAMETER;
722 /* Copy SACL into ppdesc */
723 if (security_info & SACL_SECURITY_INFORMATION) {
724 if (!onefs_acl_to_samba_acl(sd->sacl, &sacl)) {
725 status = NT_STATUS_INVALID_PARAMETER;
730 /* AUTO_INHERIT_REQ bits are not returned over the wire so strip them
731 * off. Eventually we should stop storing these in the kernel
732 * all together. See Isilon bug 40364 */
733 sd->control &= ~(IFS_SD_CTRL_DACL_AUTO_INHERIT_REQ |
734 IFS_SD_CTRL_SACL_AUTO_INHERIT_REQ);
736 pdesc = make_sec_desc(talloc_tos(), sd->revision, sd->control,
737 ownerp, groupp, sacl, dacl, &size);
740 DEBUG(0, ("Problem with make_sec_desc. Memory?\n"));
741 status = map_nt_error_from_unix(errno);
747 DEBUG(5, ("Finished retrieving/canonicalizing SD!\n"));
751 if (new_aces_alloced && sd->dacl->aces)
752 SAFE_FREE(sd->dacl->aces);
766 * Isilon-specific function for getting an NTFS ACL from a file path.
768 * Since onefs_fget_nt_acl() needs to open a filepath if the fd is invalid,
769 * we just mock up a files_struct with the path and bad fd and call into it.
771 * @param[out] ppdesc SecDesc to allocate and fill in
773 * @return NTSTATUS based off errno on error
776 onefs_get_nt_acl(vfs_handle_struct *handle, const char* name,
777 uint32 security_info, SEC_DESC **ppdesc)
786 finfo.conn = handle->conn;
789 finfo.fsp_name = CONST_DISCARD(char *, name);
791 return onefs_fget_nt_acl(handle, &finfo, security_info, ppdesc);
795 * Isilon-specific function for setting up an ifs_security_descriptor, given a
798 * @param[out] sd ifs_security_descriptor to fill in
800 * @return NTSTATUS_OK if successful
802 NTSTATUS onefs_samba_sd_to_sd(uint32 security_info_sent, SEC_DESC *psd,
803 struct ifs_security_descriptor *sd, int snum)
805 struct ifs_security_acl *daclp, *saclp;
806 struct ifs_identity owner, group, *ownerp, *groupp;
815 if (security_info_sent & OWNER_SECURITY_INFORMATION) {
816 if (!onefs_og_to_identity(psd->owner_sid, &owner, false, snum))
817 return NT_STATUS_UNSUCCESSFUL;
819 SMB_ASSERT(owner.id.uid >= 0);
825 if (security_info_sent & GROUP_SECURITY_INFORMATION) {
826 if (!onefs_og_to_identity(psd->group_sid, &group, true, snum))
827 return NT_STATUS_UNSUCCESSFUL;
829 SMB_ASSERT(group.id.gid >= 0);
835 if ((security_info_sent & DACL_SECURITY_INFORMATION) && (psd->dacl)) {
836 if (!onefs_samba_acl_to_acl(psd->dacl, &daclp, &ignore_aces,
838 return NT_STATUS_UNSUCCESSFUL;
840 if (ignore_aces == true)
841 security_info_sent &= ~DACL_SECURITY_INFORMATION;
845 if (security_info_sent & SACL_SECURITY_INFORMATION) {
847 if (lp_parm_bool(snum, PARM_ONEFS_TYPE,
848 PARM_IGNORE_SACL, PARM_IGNORE_SACL_DEFAULT)) {
849 DEBUG(5, ("Ignoring SACLs.\n"));
850 security_info_sent &= ~SACL_SECURITY_INFORMATION;
853 if (!onefs_samba_acl_to_acl(psd->sacl,
854 &saclp, &ignore_aces, snum))
855 return NT_STATUS_UNSUCCESSFUL;
857 if (ignore_aces == true) {
858 security_info_sent &=
859 ~SACL_SECURITY_INFORMATION;
865 /* Setup ifs_security_descriptor */
866 DEBUG(5,("Setting up SD\n"));
867 if (aclu_initialize_sd(sd, psd->type, ownerp, groupp,
868 (daclp ? &daclp : NULL), (saclp ? &saclp : NULL), false))
869 return NT_STATUS_UNSUCCESSFUL;
875 * Isilon-specific function for setting an NTFS ACL on an open file.
877 * @return NT_STATUS_UNSUCCESSFUL for userspace errors, NTSTATUS based off
878 * errno on syscall errors
881 onefs_fset_nt_acl(vfs_handle_struct *handle, files_struct *fsp,
882 uint32 security_info_sent, SEC_DESC *psd)
884 struct ifs_security_descriptor sd = {};
886 bool fopened = false;
889 DEBUG(5,("Setting SD on file %s.\n", fsp->fsp_name ));
891 status = onefs_samba_sd_to_sd(security_info_sent, psd, &sd,
894 if (!NT_STATUS_IS_OK(status)) {
895 DEBUG(3, ("SD initialization failure: %s", nt_errstr(status)));
901 if ((fd = onefs_sys_create_file(handle->conn,
915 DEBUG(0, ("Error opening file %s. errno=%d (%s)\n",
916 fsp->fsp_name, errno, strerror(errno)));
917 status = map_nt_error_from_unix(errno);
924 if (ifs_set_security_descriptor(fd, security_info_sent, &sd)) {
925 DEBUG(0, ("Error setting security descriptor = %d\n", errno));
926 status = map_nt_error_from_unix(errno);
930 DEBUG(5, ("Security descriptor set correctly!\n"));
931 status = NT_STATUS_OK;
938 aclu_free_sd(&sd, false);