summaryrefslogtreecommitdiff
path: root/source3/modules
diff options
context:
space:
mode:
Diffstat (limited to 'source3/modules')
-rw-r--r--source3/modules/vfs_acl_common.c30
-rw-r--r--source3/modules/vfs_acl_tdb.c50
2 files changed, 31 insertions, 49 deletions
diff --git a/source3/modules/vfs_acl_common.c b/source3/modules/vfs_acl_common.c
index 5fdd2b4725..39fd2ad0ed 100644
--- a/source3/modules/vfs_acl_common.c
+++ b/source3/modules/vfs_acl_common.c
@@ -380,21 +380,26 @@ static NTSTATUS inherit_new_acl(vfs_handle_struct *handle,
}
if (!psd || psd->dacl == NULL) {
- int ret;
TALLOC_FREE(psd);
- if (fsp && !fsp->is_directory && fsp->fh->fd != -1) {
- ret = SMB_VFS_FSTAT(fsp, &smb_fname->st);
+ if (fsp) {
+ status = vfs_stat_fsp(fsp);
+ smb_fname->st = fsp->fsp_name->st;
} else {
- if (fsp && fsp->posix_open) {
+ int ret;
+ if (lp_posix_pathnames()) {
ret = SMB_VFS_LSTAT(handle->conn, smb_fname);
} else {
ret = SMB_VFS_STAT(handle->conn, smb_fname);
}
+ if (ret == -1) {
+ status = map_nt_error_from_unix(errno);
+ }
}
- if (ret == -1) {
- return map_nt_error_from_unix(errno);
+ if (!NT_STATUS_IS_OK(status)) {
+ return status;
}
+
psd = default_file_sd(ctx, &smb_fname->st);
if (!psd) {
return NT_STATUS_NO_MEMORY;
@@ -580,23 +585,14 @@ static NTSTATUS fset_nt_acl_common(vfs_handle_struct *handle, files_struct *fsp,
/* Ensure owner and group are set. */
if (!psd->owner_sid || !psd->group_sid) {
- int ret;
DOM_SID owner_sid, group_sid;
struct security_descriptor *nc_psd = dup_sec_desc(talloc_tos(), psd);
if (!nc_psd) {
return NT_STATUS_OK;
}
- if (fsp->is_directory || fsp->fh->fd == -1) {
- if (fsp->posix_open) {
- ret = SMB_VFS_LSTAT(fsp->conn, fsp->fsp_name);
- } else {
- ret = SMB_VFS_STAT(fsp->conn, fsp->fsp_name);
- }
- } else {
- ret = SMB_VFS_FSTAT(fsp, &fsp->fsp_name->st);
- }
- if (ret == -1) {
+ status = vfs_stat_fsp(fsp);
+ if (!NT_STATUS_IS_OK(status)) {
/* Lower level acl set succeeded,
* so still return OK. */
return NT_STATUS_OK;
diff --git a/source3/modules/vfs_acl_tdb.c b/source3/modules/vfs_acl_tdb.c
index 285c58ed9d..424ecbf65b 100644
--- a/source3/modules/vfs_acl_tdb.c
+++ b/source3/modules/vfs_acl_tdb.c
@@ -147,24 +147,26 @@ static NTSTATUS get_acl_blob(TALLOC_CTX *ctx,
TDB_DATA data;
struct file_id id;
struct db_context *db;
- int ret = -1;
+ NTSTATUS status;
SMB_STRUCT_STAT sbuf;
SMB_VFS_HANDLE_GET_DATA(handle, db, struct db_context,
return NT_STATUS_INTERNAL_DB_CORRUPTION);
- if (fsp && fsp->fh->fd != -1) {
- ret = SMB_VFS_FSTAT(fsp, &sbuf);
+ ZERO_STRUCT(sbuf);
+
+ if (fsp) {
+ status = vfs_stat_fsp(fsp);
+ sbuf = fsp->fsp_name->st;
} else {
- if (fsp && fsp->posix_open) {
- ret = vfs_lstat_smb_fname(handle->conn, name, &sbuf);
- } else {
- ret = vfs_stat_smb_fname(handle->conn, name, &sbuf);
+ int ret = vfs_stat_smb_fname(handle->conn, name, &sbuf);
+ if (ret == -1) {
+ status = map_nt_error_from_unix(errno);
}
}
- if (ret == -1) {
- return map_nt_error_from_unix(errno);
+ if (!NT_STATUS_IS_OK(status)) {
+ return status;
}
id = vfs_file_id_from_sbuf(handle->conn, &sbuf);
@@ -204,7 +206,7 @@ static NTSTATUS store_acl_blob_fsp(vfs_handle_struct *handle,
TDB_DATA data;
struct db_context *db;
struct db_record *rec;
- int ret = -1;
+ NTSTATUS status;
DEBUG(10,("store_acl_blob_fsp: storing blob length %u on file %s\n",
(unsigned int)pblob->length, fsp_str_dbg(fsp)));
@@ -212,18 +214,9 @@ static NTSTATUS store_acl_blob_fsp(vfs_handle_struct *handle,
SMB_VFS_HANDLE_GET_DATA(handle, db, struct db_context,
return NT_STATUS_INTERNAL_DB_CORRUPTION);
- if (fsp->fh->fd != -1) {
- ret = SMB_VFS_FSTAT(fsp, &fsp->fsp_name->st);
- } else {
- if (fsp->posix_open) {
- ret = SMB_VFS_LSTAT(handle->conn, fsp->fsp_name);
- } else {
- ret = SMB_VFS_STAT(handle->conn, fsp->fsp_name);
- }
- }
-
- if (ret == -1) {
- return map_nt_error_from_unix(errno);
+ status = vfs_stat_fsp(fsp);
+ if (!NT_STATUS_IS_OK(status)) {
+ return status;
}
id = vfs_file_id_from_sbuf(handle->conn, &fsp->fsp_name->st);
@@ -438,20 +431,13 @@ static int sys_acl_set_fd_tdb(vfs_handle_struct *handle,
SMB_ACL_T theacl)
{
struct db_context *db;
+ NTSTATUS status;
int ret;
SMB_VFS_HANDLE_GET_DATA(handle, db, struct db_context, return -1);
- if (fsp->is_directory || fsp->fh->fd == -1) {
- if (fsp->posix_open) {
- ret = SMB_VFS_LSTAT(fsp->conn, fsp->fsp_name);
- } else {
- ret = SMB_VFS_STAT(fsp->conn, fsp->fsp_name);
- }
- } else {
- ret = SMB_VFS_FSTAT(fsp, &fsp->fsp_name->st);
- }
- if (ret == -1) {
+ status = vfs_stat_fsp(fsp);
+ if (!NT_STATUS_IS_OK(status)) {
return -1;
}