FIXME ! How does the share mask/mode fit into this.... ?
****************************************************************************/
-static bool remove_posix_acl(connection_struct *conn,
+static NTSTATUS remove_posix_acl(connection_struct *conn,
files_struct *fsp,
const struct smb_filename *smb_fname)
{
SMB_ACL_T file_acl = NULL;
int entry_id = SMB_ACL_FIRST_ENTRY;
SMB_ACL_ENTRY_T entry;
- bool ok = false;
const char *fname = smb_fname->base_name;
/* Create a new ACL with only 3 entries, u/g/w. */
SMB_ACL_T new_file_acl = NULL;
SMB_ACL_ENTRY_T user_ent = NULL;
SMB_ACL_ENTRY_T group_ent = NULL;
SMB_ACL_ENTRY_T other_ent = NULL;
+ NTSTATUS status;
int ret;
new_file_acl = sys_acl_init(talloc_tos());
if (new_file_acl == NULL) {
+ status = map_nt_error_from_unix(errno);
DBG_INFO("failed to init new ACL with 3 entries "
"for file %s %s.\n",
fname,
/* Now create the u/g/w entries. */
ret = sys_acl_create_entry(&new_file_acl, &user_ent);
if (ret == -1) {
+ status = map_nt_error_from_unix(errno);
DBG_INFO("Failed to create user entry for file %s. (%s)\n",
fname,
strerror(errno));
}
ret = sys_acl_set_tag_type(user_ent, SMB_ACL_USER_OBJ);
if (ret == -1) {
+ status = map_nt_error_from_unix(errno);
DBG_INFO("Failed to set user entry for file %s. (%s)\n",
fname,
strerror(errno));
ret = sys_acl_create_entry(&new_file_acl, &group_ent);
if (ret == -1) {
+ status = map_nt_error_from_unix(errno);
DBG_INFO("Failed to create group entry for file %s. (%s)\n",
fname,
strerror(errno));
}
ret = sys_acl_set_tag_type(group_ent, SMB_ACL_GROUP_OBJ);
if (ret == -1) {
+ status = map_nt_error_from_unix(errno);
DBG_INFO("Failed to set group entry for file %s. (%s)\n",
fname,
strerror(errno));
ret = sys_acl_create_entry(&new_file_acl, &other_ent);
if (ret == -1) {
+ status = map_nt_error_from_unix(errno);
DBG_INFO("Failed to create other entry for file %s. (%s)\n",
fname,
strerror(errno));
}
ret = sys_acl_set_tag_type(other_ent, SMB_ACL_OTHER);
if (ret == -1) {
+ status = map_nt_error_from_unix(errno);
DBG_INFO("Failed to set other entry for file %s. (%s)\n",
fname,
strerror(errno));
}
if (file_acl == NULL) {
+ status = map_nt_error_from_unix(errno);
/* This is only returned if an error occurred. Even for a file with
no acl a u/g/w acl should be returned. */
DBG_INFO("failed to get ACL from file %s (%s).\n",
ret = sys_acl_get_tag_type(entry, &tagtype);
if (ret == -1) {
+ status = map_nt_error_from_unix(errno);
DBG_INFO("failed to get tagtype from ACL "
"on file %s (%s).\n",
fname,
ret = sys_acl_get_permset(entry, &permset);
if (ret == -1) {
+ status = map_nt_error_from_unix(errno);
DBG_INFO("failed to get permset from ACL "
"on file %s (%s).\n",
fname,
if (tagtype == SMB_ACL_USER_OBJ) {
ret = sys_acl_set_permset(user_ent, permset);
if (ret == -1) {
+ status = map_nt_error_from_unix(errno);
DBG_INFO("failed to set permset from ACL "
"on file %s (%s).\n",
fname,
} else if (tagtype == SMB_ACL_GROUP_OBJ) {
ret = sys_acl_set_permset(group_ent, permset);
if (ret == -1) {
+ status = map_nt_error_from_unix(errno);
DBG_INFO("failed to set permset from ACL "
"on file %s (%s).\n",
fname,
} else if (tagtype == SMB_ACL_OTHER) {
ret = sys_acl_set_permset(other_ent, permset);
if (ret == -1) {
+ status = map_nt_error_from_unix(errno);
DBG_INFO("failed to set permset from ACL "
"on file %s (%s).\n",
fname,
if (fsp && fsp->fh->fd != -1) {
ret = SMB_VFS_SYS_ACL_SET_FD(fsp, new_file_acl);
if (ret == -1) {
+ status = map_nt_error_from_unix(errno);
DBG_INFO("acl_set_file failed on %s (%s)\n",
fname,
strerror(errno));
SMB_ACL_TYPE_ACCESS,
new_file_acl);
if (ret == -1) {
+ status = map_nt_error_from_unix(errno);
DBG_INFO("acl_set_file failed on %s (%s)\n",
fname,
strerror(errno));
}
}
- ok = true;
+ status = NT_STATUS_OK;
done:
TALLOC_FREE(file_acl);
TALLOC_FREE(new_file_acl);
- return ok;
+ return status;
}
/****************************************************************************
SMB_ACL_T file_acl = NULL;
const char *fname = smb_fname->base_name;
int ret;
+ NTSTATUS status;
if (!num_acls) {
/* Remove the ACL from the file. */
- return remove_posix_acl(conn, fsp, smb_fname);
+ status = remove_posix_acl(conn, fsp, smb_fname);
+ if (!NT_STATUS_IS_OK(status)) {
+ return false;
+ }
+ return true;
}
file_acl = create_posix_acl_from_wire(conn,