summaryrefslogtreecommitdiff
path: root/source3/modules/vfs_acl_xattr.c
diff options
context:
space:
mode:
authorTim Prouty <tprouty@samba.org>2009-07-10 18:11:32 -0700
committerTim Prouty <tprouty@samba.org>2009-07-20 17:26:57 -0700
commitc9b8a017147211d86662f40dcf835b152ab90cf4 (patch)
tree8b234318da33165a45422b4a09cb5fd3dacd2507 /source3/modules/vfs_acl_xattr.c
parent5a8d70d465f28ae02f4df7a3c2905e028c2e3142 (diff)
downloadsamba-c9b8a017147211d86662f40dcf835b152ab90cf4.tar.gz
s3: Finish plumbing the fsp->fsp_name smb_fname conversion through the modules.
Diffstat (limited to 'source3/modules/vfs_acl_xattr.c')
-rw-r--r--source3/modules/vfs_acl_xattr.c60
1 files changed, 37 insertions, 23 deletions
diff --git a/source3/modules/vfs_acl_xattr.c b/source3/modules/vfs_acl_xattr.c
index eb6653bcd17..b18bc658ffc 100644
--- a/source3/modules/vfs_acl_xattr.c
+++ b/source3/modules/vfs_acl_xattr.c
@@ -206,14 +206,14 @@ static NTSTATUS store_acl_blob_fsp(vfs_handle_struct *handle,
int saved_errno = 0;
DEBUG(10,("store_acl_blob_fsp: storing blob length %u on file %s\n",
- (unsigned int)pblob->length, fsp->fsp_name));
+ (unsigned int)pblob->length, fsp_str_dbg(fsp)));
become_root();
if (fsp->fh->fd != -1) {
ret = SMB_VFS_FSETXATTR(fsp, XATTR_NTACL_NAME,
pblob->data, pblob->length, 0);
} else {
- ret = SMB_VFS_SETXATTR(fsp->conn, fsp->fsp_name,
+ ret = SMB_VFS_SETXATTR(fsp->conn, fsp->fsp_name->base_name,
XATTR_NTACL_NAME,
pblob->data, pblob->length, 0);
}
@@ -225,7 +225,7 @@ static NTSTATUS store_acl_blob_fsp(vfs_handle_struct *handle,
errno = saved_errno;
DEBUG(5, ("store_acl_blob_fsp: setting attr failed for file %s"
"with error %s\n",
- fsp->fsp_name,
+ fsp_str_dbg(fsp),
strerror(errno) ));
return map_nt_error_from_unix(errno);
}
@@ -284,7 +284,7 @@ static NTSTATUS get_nt_acl_xattr_internal(vfs_handle_struct *handle,
struct security_descriptor *pdesc_next = NULL;
if (fsp && name == NULL) {
- name = fsp->fsp_name;
+ name = fsp->fsp_name->base_name;
}
DEBUG(10, ("get_nt_acl_xattr_internal: name=%s\n", name));
@@ -408,7 +408,7 @@ static struct security_descriptor *default_file_sd(TALLOC_CTX *mem_ctx,
*********************************************************************/
static NTSTATUS inherit_new_acl(vfs_handle_struct *handle,
- const char *fname,
+ struct smb_filename *smb_fname,
files_struct *fsp,
bool container)
{
@@ -422,7 +422,7 @@ static NTSTATUS inherit_new_acl(vfs_handle_struct *handle,
char *parent_name;
uint8_t hash[16];
- if (!parent_dirname(ctx, fname, &parent_name, NULL)) {
+ if (!parent_dirname(ctx, smb_fname->base_name, &parent_name, NULL)) {
return NT_STATUS_NO_MEMORY;
}
@@ -468,23 +468,22 @@ static NTSTATUS inherit_new_acl(vfs_handle_struct *handle,
}
if (!psd || psd->dacl == NULL) {
- SMB_STRUCT_STAT sbuf;
int ret;
TALLOC_FREE(psd);
if (fsp && !fsp->is_directory && fsp->fh->fd != -1) {
- ret = SMB_VFS_FSTAT(fsp, &sbuf);
+ ret = SMB_VFS_FSTAT(fsp, &smb_fname->st);
} else {
if (fsp && fsp->posix_open) {
- ret = vfs_lstat_smb_fname(handle->conn,fname, &sbuf);
+ ret = SMB_VFS_LSTAT(handle->conn, smb_fname);
} else {
- ret = vfs_stat_smb_fname(handle->conn,fname, &sbuf);
+ ret = SMB_VFS_STAT(handle->conn, smb_fname);
}
}
if (ret == -1) {
return map_nt_error_from_unix(errno);
}
- psd = default_file_sd(ctx, &sbuf);
+ psd = default_file_sd(ctx, &smb_fname->st);
if (!psd) {
return NT_STATUS_NO_MEMORY;
}
@@ -503,7 +502,7 @@ static NTSTATUS inherit_new_acl(vfs_handle_struct *handle,
&pdesc_next);
} else {
status = SMB_VFS_NEXT_GET_NT_ACL(handle,
- fname,
+ smb_fname->base_name,
HASH_SECURITY_INFO,
&pdesc_next);
}
@@ -523,7 +522,8 @@ static NTSTATUS inherit_new_acl(vfs_handle_struct *handle,
if (fsp) {
return store_acl_blob_fsp(handle, fsp, &blob);
} else {
- return store_acl_blob_pathname(handle, fname, &blob);
+ return store_acl_blob_pathname(handle, smb_fname->base_name,
+ &blob);
}
}
@@ -591,8 +591,12 @@ static int open_acl_xattr(vfs_handle_struct *handle,
if (!file_existed && fsp->fh->fd != -1) {
/* File was created. Inherit from parent directory. */
- string_set(&fsp->fsp_name, fname);
- inherit_new_acl(handle, fname, fsp, false);
+ status = fsp_set_smb_fname(fsp, smb_fname);
+ if (!NT_STATUS_IS_OK(status)) {
+ errno = map_errno_from_nt_status(status);
+ return -1;
+ }
+ inherit_new_acl(handle, smb_fname, fsp, false);
}
return fsp->fh->fd;
@@ -600,13 +604,24 @@ static int open_acl_xattr(vfs_handle_struct *handle,
static int mkdir_acl_xattr(vfs_handle_struct *handle, const char *path, mode_t mode)
{
+ struct smb_filename *smb_fname = NULL;
int ret = SMB_VFS_NEXT_MKDIR(handle, path, mode);
+ NTSTATUS status;
if (ret == -1) {
return ret;
}
+
+ status = create_synthetic_smb_fname(talloc_tos(), path, NULL, NULL,
+ &smb_fname);
+ if (!NT_STATUS_IS_OK(status)) {
+ errno = map_errno_from_nt_status(status);
+ return -1;
+ }
+
/* New directory - inherit from parent. */
- inherit_new_acl(handle, path, NULL, true);
+ inherit_new_acl(handle, smb_fname, NULL, true);
+ TALLOC_FREE(smb_fname);
return ret;
}
@@ -646,7 +661,7 @@ static NTSTATUS fset_nt_acl_xattr(vfs_handle_struct *handle, files_struct *fsp,
if (DEBUGLEVEL >= 10) {
DEBUG(10,("fset_nt_acl_xattr: incoming sd for file %s\n",
- fsp->fsp_name));
+ fsp_str_dbg(fsp)));
NDR_PRINT_DEBUG(security_descriptor,
CONST_DISCARD(struct security_descriptor *,psd));
}
@@ -654,7 +669,6 @@ static NTSTATUS fset_nt_acl_xattr(vfs_handle_struct *handle, files_struct *fsp,
/* Ensure owner and group are set. */
if (!psd->owner_sid || !psd->group_sid) {
int ret;
- SMB_STRUCT_STAT sbuf;
DOM_SID owner_sid, group_sid;
struct security_descriptor *nc_psd = dup_sec_desc(talloc_tos(), psd);
@@ -663,19 +677,19 @@ static NTSTATUS fset_nt_acl_xattr(vfs_handle_struct *handle, files_struct *fsp,
}
if (fsp->is_directory || fsp->fh->fd == -1) {
if (fsp->posix_open) {
- ret = vfs_lstat_smb_fname(fsp->conn,fsp->fsp_name, &sbuf);
+ ret = SMB_VFS_LSTAT(fsp->conn, fsp->fsp_name);
} else {
- ret = vfs_stat_smb_fname(fsp->conn,fsp->fsp_name, &sbuf);
+ ret = SMB_VFS_STAT(fsp->conn, fsp->fsp_name);
}
} else {
- ret = SMB_VFS_FSTAT(fsp, &sbuf);
+ ret = SMB_VFS_FSTAT(fsp, &fsp->fsp_name->st);
}
if (ret == -1) {
/* Lower level acl set succeeded,
* so still return OK. */
return NT_STATUS_OK;
}
- create_file_sids(&sbuf, &owner_sid, &group_sid);
+ create_file_sids(&fsp->fsp_name->st, &owner_sid, &group_sid);
/* This is safe as nc_psd is discarded at fn exit. */
nc_psd->owner_sid = &owner_sid;
nc_psd->group_sid = &group_sid;
@@ -723,7 +737,7 @@ static NTSTATUS fset_nt_acl_xattr(vfs_handle_struct *handle, files_struct *fsp,
if (DEBUGLEVEL >= 10) {
DEBUG(10,("fset_nt_acl_xattr: storing xattr sd for file %s\n",
- fsp->fsp_name));
+ fsp_str_dbg(fsp)));
NDR_PRINT_DEBUG(security_descriptor,
CONST_DISCARD(struct security_descriptor *,psd));
}