/* setup any EAs and the ACL on newly created files/directories */ static NTSTATUS pvfs_open_setup_eas_acl(struct pvfs_state *pvfs, struct ntvfs_request *req, struct pvfs_filename *name, int fd, struct pvfs_file *f, union smb_open *io) { NTSTATUS status; /* setup any EAs that were asked for */ if (io->ntcreatex.in.ea_list) { status = pvfs_setfileinfo_ea_set(pvfs, name, fd, io->ntcreatex.in.ea_list->num_eas, io->ntcreatex.in.ea_list->eas); if (!NT_STATUS_IS_OK(status)) { return status; } } /* setup an initial sec_desc if requested */ if (io->ntcreatex.in.sec_desc) { union smb_setfileinfo set; /* * TODO: set the full ACL! * - vista denies the creation of the file with NT_STATUS_PRIVILEGE_NOT_HELD, * when a SACL is present on the sd, * but the user doesn't have SeSecurityPrivilege * - w2k3 allows it */ set.set_secdesc.in.file.ntvfs = f->ntvfs; set.set_secdesc.in.secinfo_flags = SECINFO_DACL; set.set_secdesc.in.sd = io->ntcreatex.in.sec_desc; status = pvfs_acl_set(pvfs, req, name, fd, SEC_STD_WRITE_DAC, &set); } else { /* otherwise setup an inherited acl from the parent */ status = pvfs_acl_inherit(pvfs, req, name, fd); } return status; }
/* create a directory with EAs */ static NTSTATUS pvfs_t2mkdir(struct pvfs_state *pvfs, struct ntvfs_request *req, union smb_mkdir *md) { NTSTATUS status; struct pvfs_filename *name; mode_t mode; /* resolve the cifs name to a posix name */ status = pvfs_resolve_name(pvfs, req, md->t2mkdir.in.path, 0, &name); if (!NT_STATUS_IS_OK(status)) { return status; } if (name->exists) { return NT_STATUS_OBJECT_NAME_COLLISION; } status = pvfs_access_check_parent(pvfs, req, name, SEC_DIR_ADD_FILE); if (!NT_STATUS_IS_OK(status)) { return status; } mode = pvfs_fileperms(pvfs, FILE_ATTRIBUTE_DIRECTORY); if (pvfs_sys_mkdir(pvfs, name->full_name, mode, name->allow_override) == -1) { return pvfs_map_errno(pvfs, errno); } pvfs_xattr_unlink_hook(pvfs, name->full_name); status = pvfs_resolve_name(pvfs, req, md->t2mkdir.in.path, 0, &name); if (!NT_STATUS_IS_OK(status)) { return status; } if (!name->exists || !(name->dos.attrib & FILE_ATTRIBUTE_DIRECTORY)) { return NT_STATUS_INTERNAL_ERROR; } /* setup an inherited acl from the parent */ status = pvfs_acl_inherit(pvfs, req, name, -1); if (!NT_STATUS_IS_OK(status)) { pvfs_sys_rmdir(pvfs, name->full_name, name->allow_override); return status; } /* setup any EAs that were asked for */ status = pvfs_setfileinfo_ea_set(pvfs, name, -1, md->t2mkdir.in.num_eas, md->t2mkdir.in.eas); if (!NT_STATUS_IS_OK(status)) { pvfs_sys_rmdir(pvfs, name->full_name, name->allow_override); return status; } notify_trigger(pvfs->notify_context, NOTIFY_ACTION_ADDED, FILE_NOTIFY_CHANGE_DIR_NAME, name->full_name); return NT_STATUS_OK; }