summaryrefslogtreecommitdiff
path: root/source3/modules/vfs_acl_common.c
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2009-10-02 13:45:38 -0700
committerJeremy Allison <jra@samba.org>2009-10-02 13:45:38 -0700
commit6f22cd10ad30bd9077916c4fecbc8f7bb08c68b9 (patch)
treee1a873d8586b5386f9ddecc5bf46e961a4d634c7 /source3/modules/vfs_acl_common.c
parente218a529e0affd22118ab8f541474e600be5769a (diff)
downloadsamba-6f22cd10ad30bd9077916c4fecbc8f7bb08c68b9.tar.gz
samba-6f22cd10ad30bd9077916c4fecbc8f7bb08c68b9.tar.bz2
samba-6f22cd10ad30bd9077916c4fecbc8f7bb08c68b9.zip
Remove lots of duplicate code and move it into one
function vfs_stat_fsp(). Stops code looking at fsp->posix_open except for exceptional circumstances. Jeremy.
Diffstat (limited to 'source3/modules/vfs_acl_common.c')
-rw-r--r--source3/modules/vfs_acl_common.c30
1 files changed, 13 insertions, 17 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;