memset(psbuf, 0, sizeof(SMB_STRUCT_STAT));
if (fsp->is_directory || fsp->fh->fd == -1) {
- return smbacl4_GetFileOwner(fsp->conn, fsp->fsp_name, psbuf);
+ return smbacl4_GetFileOwner(fsp->conn,
+ fsp->fsp_name->base_name, psbuf);
}
if (SMB_VFS_FSTAT(fsp, psbuf) != 0)
{
{
SMB_STRUCT_STAT sbuf;
- DEBUG(10, ("smb_fget_nt_acl_nfs4 invoked for %s\n", fsp->fsp_name));
+ DEBUG(10, ("smb_fget_nt_acl_nfs4 invoked for %s\n", fsp_str_dbg(fsp)));
if (smbacl4_fGetFileOwner(fsp, &sbuf)) {
return map_nt_error_from_unix(errno);
gid_t newGID = (gid_t)-1;
int saved_errno;
- DEBUG(10, ("smb_set_nt_acl_nfs4 invoked for %s\n", fsp->fsp_name));
+ DEBUG(10, ("smb_set_nt_acl_nfs4 invoked for %s\n", fsp_str_dbg(fsp)));
if ((security_info_sent & (DACL_SECURITY_INFORMATION |
GROUP_SECURITY_INFORMATION | OWNER_SECURITY_INFORMATION)) == 0)
}
if (((newUID != (uid_t)-1) && (sbuf.st_ex_uid != newUID)) ||
((newGID != (gid_t)-1) && (sbuf.st_ex_gid != newGID))) {
- struct smb_filename *smb_fname = NULL;
- NTSTATUS status;
- status = create_synthetic_smb_fname_split(talloc_tos(),
- fsp->fsp_name, NULL, &smb_fname);
- if (!NT_STATUS_IS_OK(status)) {
- return status;
- }
- if(try_chown(fsp->conn, smb_fname, newUID, newGID)) {
- DEBUG(3,("chown %s, %u, %u failed. Error = %s.\n",
- fsp->fsp_name, (unsigned int)newUID, (unsigned int)newGID,
+ if(try_chown(fsp->conn, fsp->fsp_name, newUID,
+ newGID)) {
+ DEBUG(3,("chown %s, %u, %u failed. Error = "
+ "%s.\n", fsp_str_dbg(fsp),
+ (unsigned int)newUID,
+ (unsigned int)newGID,
strerror(errno)));
- TALLOC_FREE(smb_fname);
return map_nt_error_from_unix(errno);
}
- TALLOC_FREE(smb_fname);
DEBUG(10,("chown %s, %u, %u succeeded.\n",
- fsp->fsp_name, (unsigned int)newUID, (unsigned int)newGID));
- if (smbacl4_GetFileOwner(fsp->conn, fsp->fsp_name, &sbuf))
+ fsp_str_dbg(fsp), (unsigned int)newUID,
+ (unsigned int)newGID));
+ if (smbacl4_GetFileOwner(fsp->conn,
+ fsp->fsp_name->base_name,
+ &sbuf))
return map_nt_error_from_unix(errno);
/* If we successfully chowned, we know we must
return NT_STATUS_OK;
}
- theacl = smbacl4_win2nfs4(fsp->fsp_name, psd->dacl, ¶ms,
+ theacl = smbacl4_win2nfs4(fsp->fsp_name->base_name, psd->dacl, ¶ms,
sbuf.st_ex_uid, sbuf.st_ex_gid);
if (!theacl)
return map_nt_error_from_unix(errno);
if ((sbuf.st_ex_flags & SF_HASNTFSACL) != 0) {
DEBUG(10, ("Did not canonicalize ACLs because a "
- "Windows ACL set was found for file %s\n",
- fsp->fsp_name));
+ "Windows ACL set was found for file %s\n",
+ fsp_str_dbg(fsp)));
return true;
}
break;
SMB_ASSERT(new_aces_count == sd->dacl->num_aces);
DEBUG(10, ("Performed canonicalization of ACLs for file %s\n",
- fsp->fsp_name));
+ fsp_str_dbg(fsp)));
/*
* At this point you would think we could just do this:
if (error) {
DEBUG(0, ("Failed to stat %s in simple files sharing "
"compatibility mode. errno=%d\n",
- fsp->fsp_name, errno));
+ fsp_str_dbg(fsp), errno));
return false;
}
/* Only continue if this is a synthetic ACL and a directory. */
if (S_ISDIR(sbuf.st_ex_mode) &&
(sbuf.st_ex_flags & SF_HASNTFSACL) == 0) {
- struct smb_filename *smb_fname = NULL;
struct ifs_ace new_aces[6];
struct ifs_ace *old_aces;
int i, num_aces_to_add = 0;
mode_t file_mode = 0, dir_mode = 0;
- NTSTATUS status;
-
- status = create_synthetic_smb_fname_split(talloc_tos(),
- fsp->fsp_name, NULL,
- &smb_fname);
- if (!NT_STATUS_IS_OK(status)) {
- return false;
- }
/* Use existing samba logic to derive the mode bits. */
- file_mode = unix_mode(fsp->conn, 0, smb_fname, NULL);
- dir_mode = unix_mode(fsp->conn, aDIR, smb_fname, NULL);
-
- TALLOC_FREE(smb_fname);
+ file_mode = unix_mode(fsp->conn, 0, fsp->fsp_name, NULL);
+ dir_mode = unix_mode(fsp->conn, aDIR, fsp->fsp_name, NULL);
/* Initialize ACEs. */
new_aces[0] = onefs_init_ace(fsp->conn, file_mode, false, USR);
*ppdesc = NULL;
DEBUG(5, ("Getting sd for file %s. security_info=%u\n",
- fsp->fsp_name, security_info));
+ fsp_str_dbg(fsp), security_info));
if (lp_parm_bool(SNUM(fsp->conn), PARM_ONEFS_TYPE,
PARM_IGNORE_SACLS, PARM_IGNORE_SACLS_DEFAULT)) {
- DEBUG(5, ("Ignoring SACL on %s.\n", fsp->fsp_name));
+ DEBUG(5, ("Ignoring SACL on %s.\n", fsp_str_dbg(fsp)));
security_info &= ~SACL_SECURITY_INFORMATION;
}
if (fsp->fh->fd == -1) {
if ((fsp->fh->fd = onefs_sys_create_file(handle->conn,
-1,
- fsp->fsp_name,
+ fsp->fsp_name->base_name,
0,
0,
0,
0,
NULL)) == -1) {
DEBUG(0, ("Error opening file %s. errno=%d (%s)\n",
- fsp->fsp_name, errno, strerror(errno)));
+ fsp_str_dbg(fsp), errno, strerror(errno)));
status = map_nt_error_from_unix(errno);
goto out;
}
{
files_struct finfo;
struct fd_handle fh;
+ NTSTATUS status;
ZERO_STRUCT(finfo);
ZERO_STRUCT(fh);
finfo.conn = handle->conn;
finfo.fh = &fh;
finfo.fh->fd = -1;
- finfo.fsp_name = CONST_DISCARD(char *, name);
+ status = create_synthetic_smb_fname(talloc_tos(), name, NULL, NULL,
+ &finfo.fsp_name);
+ if (!NT_STATUS_IS_OK(status)) {
+ return status;
+ }
- return onefs_fget_nt_acl(handle, &finfo, security_info, ppdesc);
+ status = onefs_fget_nt_acl(handle, &finfo, security_info, ppdesc);
+
+ TALLOC_FREE(finfo.fsp_name);
+ return status;
}
/**
START_PROFILE(syscall_set_sd);
- DEBUG(5,("Setting SD on file %s.\n", fsp->fsp_name ));
+ DEBUG(5,("Setting SD on file %s.\n", fsp_str_dbg(fsp)));
status = onefs_samba_sd_to_sd(sec_info_sent, psd, &sd,
SNUM(handle->conn), &sec_info_effective);
fd = fsp->fh->fd;
if (fd == -1) {
- DEBUG(10,("Reopening file %s.\n", fsp->fsp_name));
+ DEBUG(10,("Reopening file %s.\n", fsp_str_dbg(fsp)));
if ((fd = onefs_sys_create_file(handle->conn,
-1,
- fsp->fsp_name,
+ fsp->fsp_name->base_name,
0,
0,
0,
0,
NULL)) == -1) {
DEBUG(0, ("Error opening file %s. errno=%d (%s)\n",
- fsp->fsp_name, errno, strerror(errno)));
+ fsp_str_dbg(fsp), errno, strerror(errno)));
status = map_nt_error_from_unix(errno);
goto out;
}
struct security_descriptor *sd,
int *granted_oplock)
{
- char *path = NULL;
struct smb_filename *smb_fname_onefs = NULL;
NTSTATUS status = NT_STATUS_OK;
int accmode = (flags & O_ACCMODE);
* wildcard characters are allowed in stream names
* only test the basefilename
*/
- wild = fsp->base_fsp->fsp_name;
+ wild = fsp->base_fsp->fsp_name->base_name;
} else {
wild = smb_fname->base_name;
}
fsp->aio_write_behind = True;
}
- status = get_full_smb_filename(talloc_tos(), smb_fname,
- &path);
+ status = fsp_set_smb_fname(fsp, smb_fname);
if (!NT_STATUS_IS_OK(status)) {
+ fd_close(fsp);
+ errno = map_errno_from_nt_status(status);
return status;
}
- string_set(&fsp->fsp_name, path);
- TALLOC_FREE(path);
-
fsp->wcp = NULL; /* Write cache pointer. */
DEBUG(2,("%s opened file %s read=%s write=%s (numopen=%d)\n",
fsp->is_directory = True;
fsp->posix_open = posix_open;
- string_set(&fsp->fsp_name, smb_dname->base_name);
+ status = fsp_set_smb_fname(fsp, smb_dname);
+ if (!NT_STATUS_IS_OK(status)) {
+ fd_close(fsp);
+ file_free(req, fsp);
+ return status;
+ }
mtimespec = smb_dname->st.st_ex_mtime;
}
}
- onefs_adjust_stat_time(handle->conn, fsp->fsp_name, sbuf);
+ onefs_adjust_stat_time(handle->conn, fsp->fsp_name->base_name, sbuf);
return ret;
}
fake_fs.conn = conn;
fake_fs.fh = &fake_fh;
- fake_fs.fsp_name = SMB_STRDUP(fname);
+ status = create_synthetic_smb_fname(talloc_tos(), fname, NULL, NULL,
+ &fake_fs.fsp_name);
+ if (!NT_STATUS_IS_OK(status)) {
+ goto out;
+ }
/* Iterate over the streams in the ADS directory. */
while ((dp = SMB_VFS_READDIR(conn, dirp, NULL)) != NULL) {
close(base_fd);
}
- SAFE_FREE(fake_fs.fsp_name);
+ TALLOC_FREE(fake_fs.fsp_name);
return status;
}
{
uint8 id_buf[16];
struct file_id id;
- SMB_STRUCT_STAT sbuf;
TDB_DATA data;
struct db_context *db;
struct db_record *rec;
int ret = -1;
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)));
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, &sbuf);
+ ret = SMB_VFS_FSTAT(fsp, &fsp->fsp_name->st);
} else {
if (fsp->posix_open) {
- ret = vfs_lstat_smb_fname(handle->conn, fsp->fsp_name,
- &sbuf);
+ ret = SMB_VFS_LSTAT(handle->conn, fsp->fsp_name);
} else {
- ret = vfs_stat_smb_fname(handle->conn, fsp->fsp_name,
- &sbuf);
+ ret = SMB_VFS_STAT(handle->conn, fsp->fsp_name);
}
}
return map_nt_error_from_unix(errno);
}
- id = vfs_file_id_from_sbuf(handle->conn, &sbuf);
+ id = vfs_file_id_from_sbuf(handle->conn, &fsp->fsp_name->st);
/* For backwards compatibility only store the dev/inode. */
push_file_id_16((char *)id_buf, &id);
NTSTATUS status;
if (fsp && name == NULL) {
- name = fsp->fsp_name;
+ name = fsp->fsp_name->base_name;
}
DEBUG(10, ("get_nt_acl_tdb_internal: name=%s\n", name));
*********************************************************************/
static NTSTATUS inherit_new_acl(vfs_handle_struct *handle,
- const char *fname,
+ struct smb_filename *smb_fname,
files_struct *fsp,
bool container)
{
size_t size;
char *parent_name;
- if (!parent_dirname(ctx, fname, &parent_name, NULL)) {
+ if (!parent_dirname(ctx, smb_fname->base_name, &parent_name, NULL)) {
return NT_STATUS_NO_MEMORY;
}
}
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;
}
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);
}
}
uint32_t access_granted = 0;
struct security_descriptor *pdesc = NULL;
bool file_existed = true;
- char *fname = NULL;
NTSTATUS status;
- status = get_full_smb_filename(talloc_tos(), smb_fname,
- &fname);
- if (!NT_STATUS_IS_OK(status)) {
- errno = map_errno_from_nt_status(status);
- return -1;
- }
-
status = get_nt_acl_tdb_internal(handle,
NULL,
- fname,
+ smb_fname->base_name,
(OWNER_SECURITY_INFORMATION |
GROUP_SECURITY_INFORMATION |
DACL_SECURITY_INFORMATION),
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;
}
static int mkdir_acl_tdb(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;
}
if (NT_STATUS_IS_OK(status)) {
if (DEBUGLEVEL >= 10) {
DEBUG(10,("fget_nt_acl_tdb: returning tdb sd for file %s\n",
- fsp->fsp_name));
+ fsp_str_dbg(fsp)));
NDR_PRINT_DEBUG(security_descriptor, *ppdesc);
}
return NT_STATUS_OK;
}
DEBUG(10,("fget_nt_acl_tdb: failed to get tdb sd for file %s, Error %s\n",
- fsp->fsp_name,
- nt_errstr(status) ));
+ fsp_str_dbg(fsp), nt_errstr(status)));
return SMB_VFS_NEXT_FGET_NT_ACL(handle, fsp,
security_info, ppdesc);
if (DEBUGLEVEL >= 10) {
DEBUG(10,("fset_nt_acl_tdb: incoming sd for file %s\n",
- fsp->fsp_name));
+ fsp_str_dbg(fsp)));
NDR_PRINT_DEBUG(security_descriptor,
CONST_DISCARD(struct security_descriptor *,psd));
}
/* 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);
}
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;
if (DEBUGLEVEL >= 10) {
DEBUG(10,("fset_nt_acl_tdb: storing tdb sd for file %s\n",
- fsp->fsp_name));
+ fsp_str_dbg(fsp)));
NDR_PRINT_DEBUG(security_descriptor,
CONST_DISCARD(struct security_descriptor *,psd));
}
files_struct *fsp,
SMB_ACL_T theacl)
{
- SMB_STRUCT_STAT sbuf;
struct db_context *db;
int ret;
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) {
return -1;
return -1;
}
- acl_tdb_delete(handle, db, &sbuf);
+ acl_tdb_delete(handle, db, &fsp->fsp_name->st);
return 0;
}
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);
}
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);
}
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));
*********************************************************************/
static NTSTATUS inherit_new_acl(vfs_handle_struct *handle,
- const char *fname,
+ struct smb_filename *smb_fname,
files_struct *fsp,
bool container)
{
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;
}
}
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;
}
&pdesc_next);
} else {
status = SMB_VFS_NEXT_GET_NT_ACL(handle,
- fname,
+ smb_fname->base_name,
HASH_SECURITY_INFO,
&pdesc_next);
}
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);
}
}
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;
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;
}
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));
}
/* 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);
}
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;
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));
}
static size_t afs_to_nt_acl(struct afs_acl *afs_acl,
struct connection_struct *conn,
- const char *name,
+ struct smb_filename *smb_fname,
uint32 security_info,
struct security_descriptor **ppdesc)
{
- SMB_STRUCT_STAT sbuf;
-
/* Get the stat struct for the owner info. */
- if(vfs_stat_smb_fname(conn, name, &sbuf) != 0) {
+ if(SMB_VFS_STAT(conn, smb_fname) != 0) {
return 0;
}
- return afs_to_nt_acl_common(afs_acl, &sbuf, security_info, ppdesc);
+ return afs_to_nt_acl_common(afs_acl, &smb_fname->st, security_info,
+ ppdesc);
}
static size_t afs_fto_nt_acl(struct afs_acl *afs_acl,
ZERO_STRUCT(dir_acl);
ZERO_STRUCT(file_acl);
- name = talloc_strdup(talloc_tos(), fsp->fsp_name);
+ name = talloc_strdup(talloc_tos(), fsp->fsp_name->base_name);
if (!name) {
return NT_STATUS_NO_MEMORY;
}
}
if (!afs_get_afs_acl(name, &old_afs_acl)) {
- DEBUG(3, ("Could not get old ACL of %s\n", fsp->fsp_name));
+ DEBUG(3, ("Could not get old ACL of %s\n", fsp_str_dbg(fsp)));
goto done;
}
}
free_afs_acl(&dir_acl);
- if (!nt_to_afs_acl(fsp->fsp_name, security_info_sent, psd,
+ if (!nt_to_afs_acl(fsp->fsp_name->base_name,
+ security_info_sent, psd,
nt_to_afs_dir_rights, &dir_acl))
goto done;
} else {
}
free_afs_acl(&file_acl);
- if (!nt_to_afs_acl(fsp->fsp_name, security_info_sent, psd,
+ if (!nt_to_afs_acl(fsp->fsp_name->base_name,
+ security_info_sent, psd,
nt_to_afs_file_rights, &file_acl))
goto done;
}
struct afs_acl acl;
size_t sd_size;
- DEBUG(5, ("afsacl_fget_nt_acl: %s\n", fsp->fsp_name));
+ DEBUG(5, ("afsacl_fget_nt_acl: %s\n", fsp_str_dbg(fsp)));
sidpts = lp_parm_bool(SNUM(fsp->conn), "afsacl", "sidpts", False);
- if (!afs_get_afs_acl(fsp->fsp_name, &acl)) {
+ if (!afs_get_afs_acl(fsp->fsp_name->base_name, &acl)) {
return NT_STATUS_ACCESS_DENIED;
}
{
struct afs_acl acl;
size_t sd_size;
+ struct smb_filename *smb_fname = NULL;
+ NTSTATUS status;
DEBUG(5, ("afsacl_get_nt_acl: %s\n", name));
return NT_STATUS_ACCESS_DENIED;
}
- sd_size = afs_to_nt_acl(&acl, handle->conn, name, security_info,
+ status = create_synthetic_smb_fname(talloc_tos(), name, NULL, NULL,
+ &smb_fname);
+ if (!NT_STATUS_IS_OK(status)) {
+ free_afs_acl(&acl);
+ return status;
+ }
+
+ sd_size = afs_to_nt_acl(&acl, handle->conn, smb_fname, security_info,
ppdesc);
+ TALLOC_FREE(smb_fname);
free_afs_acl(&acl);
bool retryPosix = False;
*ppdesc = NULL;
- result = aixjfs2_get_nfs4_acl(fsp->fsp_name, &pacl, &retryPosix);
+ result = aixjfs2_get_nfs4_acl(fsp->fsp_name->base_name, &pacl,
+ &retryPosix);
if (retryPosix)
{
DEBUG(10, ("retrying with posix acl...\n"));
acl_type_t aixjfs2_type;
aixjfs2_type.u64 = ACL_AIXC;
- return aixjfs2_get_posix_acl(fsp->fsp_name, aixjfs2_type);
+ return aixjfs2_get_posix_acl(fsp->fsp_name->base_name, aixjfs2_type);
}
/*
int rc;
acl_type_t acltype;
- DEBUG(10, ("jfs2_process_smbacl invoked on %s\n", fsp->fsp_name));
+ DEBUG(10, ("jfs2_process_smbacl invoked on %s\n", fsp_str_dbg(fsp)));
/* no need to be freed which is alloced with mem_ctx */
mem_ctx = talloc_tos();
/* won't set S_ISUID - the only one JFS2/NFS4 accepts */
rc = aclx_put(
- fsp->fsp_name,
+ fsp->fsp_name->base_name,
SET_ACL, /* set only the ACL, not mode bits */
acltype, /* not a pointer !!! */
jfs2acl,
acl_type_t acl_type_info;
int rc;
- DEBUG(10, ("aixjfs2_sys_acl_set_fd invoked for %s", fsp->fsp_name));
+ DEBUG(10, ("aixjfs2_sys_acl_set_fd invoked for %s", fsp_str_dbg(fsp)));
- rc = aixjfs2_query_acl_support(fsp->fsp_name, ACL_AIXC, &acl_type_info);
+ rc = aixjfs2_query_acl_support(fsp->fsp_name->base_name, ACL_AIXC,
+ &acl_type_info);
if (rc) {
DEBUG(8, ("jfs2_set_nt_acl: AIXC support not found\n"));
return -1;
);
if (rc) {
DEBUG(2, ("aclx_fput failed with %s for %s\n",
- strerror(errno), fsp->fsp_name));
+ strerror(errno), fsp_str_dbg(fsp)));
return -1;
}
result = SMB_VFS_NEXT_FCHMOD(handle, fsp, mode);
syslog(audit_syslog_priority(handle), "fchmod %s mode 0x%x %s%s\n",
- fsp->fsp_name, mode,
+ fsp->fsp_name->base_name, mode,
(result < 0) ? "failed: " : "",
(result < 0) ? strerror(errno) : "");
result = SMB_VFS_NEXT_FCHMOD_ACL(handle, fsp, mode);
syslog(audit_syslog_priority(handle), "fchmod_acl %s mode 0x%x %s%s\n",
- fsp->fsp_name, mode,
+ fsp->fsp_name->base_name, mode,
(result < 0) ? "failed: " : "",
(result < 0) ? strerror(errno) : "");
DEBUG(module_debug,
("%s: doing readahead of %lld bytes at %lld for %s\n",
MODULE, (long long)g_readsz, (long long)*last,
- fsp->fsp_name));
+ fsp_str_dbg(fsp)));
nread = sys_pread(fsp->fh->fd, g_readbuf, g_readsz, *last);
if (nread < 0) {
uint64_t space_avail;
uint64_t bsize,dfree,dsize;
- space_avail = get_dfree_info(fsp->conn,fsp->fsp_name,false,&bsize,&dfree,&dsize);
+ space_avail = get_dfree_info(fsp->conn,
+ fsp->fsp_name->base_name, false,
+ &bsize, &dfree, &dsize);
/* space_avail is 1k blocks */
if (space_avail == (uint64_t)-1 ||
((uint64_t)space_to_write/1024 > space_avail) ) {
if (lp_syslog() > 0) {
syslog(audit_syslog_priority(handle), "fchmod %s mode 0x%x %s%s\n",
- fsp->fsp_name, mode,
+ fsp->fsp_name->base_name, mode,
(result < 0) ? "failed: " : "",
(result < 0) ? strerror(errno) : "");
}
DEBUG(1, ("vfs_extd_audit: fchmod %s mode 0x%x %s %s",
- fsp->fsp_name, (unsigned int)mode,
+ fsp_str_dbg(fsp), (unsigned int)mode,
(result < 0) ? "failed: " : "",
(result < 0) ? strerror(errno) : ""));
if (lp_syslog() > 0) {
syslog(audit_syslog_priority(handle), "fchmod_acl %s mode 0x%x %s%s\n",
- fsp->fsp_name, mode,
+ fsp->fsp_name->base_name, mode,
(result < 0) ? "failed: " : "",
(result < 0) ? strerror(errno) : "");
}
DEBUG(1, ("vfs_extd_audit: fchmod_acl %s mode 0x%x %s %s",
- fsp->fsp_name, (unsigned int)mode,
+ fsp_str_dbg(fsp), (unsigned int)mode,
(result < 0) ? "failed: " : "",
(result < 0) ? strerror(errno) : ""));
return fname;
}
+/**
+ * Return an fsp debug string using the do_log_ctx()
+ */
+static const char *fsp_str_do_log(const struct files_struct *fsp)
+{
+ return smb_fname_str_do_log(fsp->fsp_name);
+}
/* Free function for the private data. */
result = SMB_VFS_NEXT_CLOSE(handle, fsp);
- do_log(SMB_VFS_OP_CLOSE, (result >= 0), handle, "%s", fsp->fsp_name);
+ do_log(SMB_VFS_OP_CLOSE, (result >= 0), handle, "%s",
+ fsp_str_do_log(fsp));
return result;
}
result = SMB_VFS_NEXT_READ(handle, fsp, data, n);
- do_log(SMB_VFS_OP_READ, (result >= 0), handle, "%s", fsp->fsp_name);
+ do_log(SMB_VFS_OP_READ, (result >= 0), handle, "%s",
+ fsp_str_do_log(fsp));
return result;
}
result = SMB_VFS_NEXT_PREAD(handle, fsp, data, n, offset);
- do_log(SMB_VFS_OP_PREAD, (result >= 0), handle, "%s", fsp->fsp_name);
+ do_log(SMB_VFS_OP_PREAD, (result >= 0), handle, "%s",
+ fsp_str_do_log(fsp));
return result;
}
result = SMB_VFS_NEXT_WRITE(handle, fsp, data, n);
- do_log(SMB_VFS_OP_WRITE, (result >= 0), handle, "%s", fsp->fsp_name);
+ do_log(SMB_VFS_OP_WRITE, (result >= 0), handle, "%s",
+ fsp_str_do_log(fsp));
return result;
}
result = SMB_VFS_NEXT_PWRITE(handle, fsp, data, n, offset);
- do_log(SMB_VFS_OP_PWRITE, (result >= 0), handle, "%s", fsp->fsp_name);
+ do_log(SMB_VFS_OP_PWRITE, (result >= 0), handle, "%s",
+ fsp_str_do_log(fsp));
return result;
}
result = SMB_VFS_NEXT_LSEEK(handle, fsp, offset, whence);
do_log(SMB_VFS_OP_LSEEK, (result != (ssize_t)-1), handle,
- "%s", fsp->fsp_name);
+ "%s", fsp_str_do_log(fsp));
return result;
}
result = SMB_VFS_NEXT_SENDFILE(handle, tofd, fromfsp, hdr, offset, n);
do_log(SMB_VFS_OP_SENDFILE, (result >= 0), handle,
- "%s", fromfsp->fsp_name);
+ "%s", fsp_str_do_log(fromfsp));
return result;
}
result = SMB_VFS_NEXT_RECVFILE(handle, fromfd, tofsp, offset, n);
do_log(SMB_VFS_OP_RECVFILE, (result >= 0), handle,
- "%s", tofsp->fsp_name);
+ "%s", fsp_str_do_log(tofsp));
return result;
}
result = SMB_VFS_NEXT_FSYNC(handle, fsp);
- do_log(SMB_VFS_OP_FSYNC, (result >= 0), handle, "%s", fsp->fsp_name);
+ do_log(SMB_VFS_OP_FSYNC, (result >= 0), handle, "%s",
+ fsp_str_do_log(fsp));
return result;
}
result = SMB_VFS_NEXT_FSTAT(handle, fsp, sbuf);
- do_log(SMB_VFS_OP_FSTAT, (result >= 0), handle, "%s", fsp->fsp_name);
+ do_log(SMB_VFS_OP_FSTAT, (result >= 0), handle, "%s",
+ fsp_str_do_log(fsp));
return result;
}
result = SMB_VFS_NEXT_FCHMOD(handle, fsp, mode);
do_log(SMB_VFS_OP_FCHMOD, (result >= 0), handle,
- "%s|%o", fsp->fsp_name, mode);
+ "%s|%o", fsp_str_do_log(fsp), mode);
return result;
}
result = SMB_VFS_NEXT_FCHOWN(handle, fsp, uid, gid);
do_log(SMB_VFS_OP_FCHOWN, (result >= 0), handle, "%s|%ld|%ld",
- fsp->fsp_name, (long int)uid, (long int)gid);
+ fsp_str_do_log(fsp), (long int)uid, (long int)gid);
return result;
}
result = SMB_VFS_NEXT_FTRUNCATE(handle, fsp, len);
do_log(SMB_VFS_OP_FTRUNCATE, (result >= 0), handle,
- "%s", fsp->fsp_name);
+ "%s", fsp_str_do_log(fsp));
return result;
}
result = SMB_VFS_NEXT_LOCK(handle, fsp, op, offset, count, type);
- do_log(SMB_VFS_OP_LOCK, result, handle, "%s", fsp->fsp_name);
+ do_log(SMB_VFS_OP_LOCK, result, handle, "%s", fsp_str_do_log(fsp));
return result;
}
result = SMB_VFS_NEXT_KERNEL_FLOCK(handle, fsp, share_mode);
do_log(SMB_VFS_OP_KERNEL_FLOCK, (result >= 0), handle, "%s",
- fsp->fsp_name);
+ fsp_str_do_log(fsp));
return result;
}
result = SMB_VFS_NEXT_LINUX_SETLEASE(handle, fsp, leasetype);
do_log(SMB_VFS_OP_LINUX_SETLEASE, (result >= 0), handle, "%s",
- fsp->fsp_name);
+ fsp_str_do_log(fsp));
return result;
}
result = SMB_VFS_NEXT_GETLOCK(handle, fsp, poffset, pcount, ptype, ppid);
- do_log(SMB_VFS_OP_GETLOCK, result, handle, "%s", fsp->fsp_name);
+ do_log(SMB_VFS_OP_GETLOCK, result, handle, "%s", fsp_str_do_log(fsp));
return result;
}
blocking_lock, blr);
do_log(SMB_VFS_OP_BRL_LOCK_WINDOWS, NT_STATUS_IS_OK(result), handle,
- "%s:%llu-%llu. type=%d. blocking=%d", br_lck->fsp->fsp_name,
+ "%s:%llu-%llu. type=%d. blocking=%d", fsp_str_do_log(br_lck->fsp),
plock->start, plock->size, plock->lock_type, blocking_lock );
return result;
plock);
do_log(SMB_VFS_OP_BRL_UNLOCK_WINDOWS, (result == 0), handle,
- "%s:%llu-%llu:%d", br_lck->fsp->fsp_name, plock->start,
+ "%s:%llu-%llu:%d", fsp_str_do_log(br_lck->fsp), plock->start,
plock->size, plock->lock_type);
return result;
result = SMB_VFS_NEXT_BRL_CANCEL_WINDOWS(handle, br_lck, plock, blr);
do_log(SMB_VFS_OP_BRL_CANCEL_WINDOWS, (result == 0), handle,
- "%s:%llu-%llu:%d", br_lck->fsp->fsp_name, plock->start,
+ "%s:%llu-%llu:%d", fsp_str_do_log(br_lck->fsp), plock->start,
plock->size);
return result;
result = SMB_VFS_NEXT_STRICT_LOCK(handle, fsp, plock);
do_log(SMB_VFS_OP_STRICT_LOCK, result, handle,
- "%s:%llu-%llu:%d", fsp->fsp_name, plock->start,
+ "%s:%llu-%llu:%d", fsp_str_do_log(fsp), plock->start,
plock->size);
return result;
SMB_VFS_NEXT_STRICT_UNLOCK(handle, fsp, plock);
do_log(SMB_VFS_OP_STRICT_UNLOCK, true, handle,
- "%s:%llu-%llu:%d", fsp->fsp_name, plock->start,
+ "%s:%llu-%llu:%d", fsp_str_do_log(fsp), plock->start,
plock->size);
return;
result = SMB_VFS_NEXT_FGET_NT_ACL(handle, fsp, security_info, ppdesc);
do_log(SMB_VFS_OP_FGET_NT_ACL, NT_STATUS_IS_OK(result), handle,
- "%s", fsp->fsp_name);
+ "%s", fsp_str_do_log(fsp));
return result;
}
result = SMB_VFS_NEXT_FSET_NT_ACL(handle, fsp, security_info_sent, psd);
- do_log(SMB_VFS_OP_FSET_NT_ACL, NT_STATUS_IS_OK(result), handle, "%s", fsp->fsp_name);
+ do_log(SMB_VFS_OP_FSET_NT_ACL, NT_STATUS_IS_OK(result), handle, "%s",
+ fsp_str_do_log(fsp));
return result;
}
result = SMB_VFS_NEXT_FCHMOD_ACL(handle, fsp, mode);
do_log(SMB_VFS_OP_FCHMOD_ACL, (result >= 0), handle,
- "%s|%o", fsp->fsp_name, mode);
+ "%s|%o", fsp_str_do_log(fsp), mode);
return result;
}
result = SMB_VFS_NEXT_SYS_ACL_GET_FD(handle, fsp);
do_log(SMB_VFS_OP_SYS_ACL_GET_FD, (result != NULL), handle,
- "%s", fsp->fsp_name);
+ "%s", fsp_str_do_log(fsp));
return result;
}
result = SMB_VFS_NEXT_SYS_ACL_SET_FD(handle, fsp, theacl);
do_log(SMB_VFS_OP_SYS_ACL_SET_FD, (result >= 0), handle,
- "%s", fsp->fsp_name);
+ "%s", fsp_str_do_log(fsp));
return result;
}
result = SMB_VFS_NEXT_FGETXATTR(handle, fsp, name, value, size);
do_log(SMB_VFS_OP_FGETXATTR, (result >= 0), handle,
- "%s|%s", fsp->fsp_name, name);
+ "%s|%s", fsp_str_do_log(fsp), name);
return result;
}
result = SMB_VFS_NEXT_FLISTXATTR(handle, fsp, list, size);
do_log(SMB_VFS_OP_FLISTXATTR, (result >= 0), handle,
- "%s", fsp->fsp_name);
+ "%s", fsp_str_do_log(fsp));
return result;
}
result = SMB_VFS_NEXT_FREMOVEXATTR(handle, fsp, name);
do_log(SMB_VFS_OP_FREMOVEXATTR, (result >= 0), handle,
- "%s|%s", fsp->fsp_name, name);
+ "%s|%s", fsp_str_do_log(fsp), name);
return result;
}
result = SMB_VFS_NEXT_FSETXATTR(handle, fsp, name, value, size, flags);
do_log(SMB_VFS_OP_FSETXATTR, (result >= 0), handle,
- "%s|%s", fsp->fsp_name, name);
+ "%s|%s", fsp_str_do_log(fsp), name);
return result;
}
result = SMB_VFS_NEXT_AIO_READ(handle, fsp, aiocb);
do_log(SMB_VFS_OP_AIO_READ, (result >= 0), handle,
- "%s", fsp->fsp_name);
+ "%s", fsp_str_do_log(fsp));
return result;
}
result = SMB_VFS_NEXT_AIO_WRITE(handle, fsp, aiocb);
do_log(SMB_VFS_OP_AIO_WRITE, (result >= 0), handle,
- "%s", fsp->fsp_name);
+ "%s", fsp_str_do_log(fsp));
return result;
}
result = SMB_VFS_NEXT_AIO_RETURN(handle, fsp, aiocb);
do_log(SMB_VFS_OP_AIO_RETURN, (result >= 0), handle,
- "%s", fsp->fsp_name);
+ "%s", fsp_str_do_log(fsp));
return result;
}
result = SMB_VFS_NEXT_AIO_CANCEL(handle, fsp, aiocb);
do_log(SMB_VFS_OP_AIO_CANCEL, (result >= 0), handle,
- "%s", fsp->fsp_name);
+ "%s", fsp_str_do_log(fsp));
return result;
}
result = SMB_VFS_NEXT_AIO_ERROR(handle, fsp, aiocb);
do_log(SMB_VFS_OP_AIO_ERROR, (result >= 0), handle,
- "%s", fsp->fsp_name);
+ "%s", fsp_str_do_log(fsp));
return result;
}
result = SMB_VFS_NEXT_AIO_FSYNC(handle, fsp, op, aiocb);
do_log(SMB_VFS_OP_AIO_FSYNC, (result >= 0), handle,
- "%s", fsp->fsp_name);
+ "%s", fsp_str_do_log(fsp));
return result;
}
result = SMB_VFS_NEXT_AIO_SUSPEND(handle, fsp, aiocb, n, ts);
do_log(SMB_VFS_OP_AIO_SUSPEND, (result >= 0), handle,
- "%s", fsp->fsp_name);
+ "%s", fsp_str_do_log(fsp));
return result;
}
result = SMB_VFS_NEXT_AIO_FORCE(handle, fsp);
do_log(SMB_VFS_OP_AIO_FORCE, result, handle,
- "%s", fsp->fsp_name);
+ "%s", fsp_str_do_log(fsp));
return result;
}
int result;
*ppdesc = NULL;
- result = gpfs_get_nfs4_acl(fsp->fsp_name, &pacl);
+ result = gpfs_get_nfs4_acl(fsp->fsp_name->base_name, &pacl);
if (result == 0)
return smb_fget_nt_acl_nfs4(fsp, security_info, ppdesc, pacl);
"merge_writeappend", True)) {
DEBUG(2, ("vfs_gpfs.c: file [%s]: ACE contains "
"WRITE^APPEND, setting WRITE|APPEND\n",
- fsp->fsp_name));
+ fsp_str_dbg(fsp)));
gace->aceMask |= ACE4_MASK_WRITE|ACE4_MASK_APPEND;
}
gacl->acl_nace++;
}
- ret = smbd_gpfs_putacl(fsp->fsp_name, GPFS_PUTACL_STRUCT | GPFS_ACL_SAMBA, gacl);
+ ret = smbd_gpfs_putacl(fsp->fsp_name->base_name,
+ GPFS_PUTACL_STRUCT | GPFS_ACL_SAMBA, gacl);
if (ret != 0) {
DEBUG(8, ("gpfs_putacl failed with %s\n", strerror(errno)));
gpfs_dumpacl(8, gacl);
struct gpfs_acl *acl;
NTSTATUS result = NT_STATUS_ACCESS_DENIED;
- acl = gpfs_getacl_alloc(fsp->fsp_name, 0);
+ acl = gpfs_getacl_alloc(fsp->fsp_name->base_name, 0);
if (acl == NULL)
return result;
static SMB_ACL_T gpfsacl_sys_acl_get_fd(vfs_handle_struct *handle,
files_struct *fsp)
{
- return gpfsacl_get_posix_acl(fsp->fsp_name, GPFS_ACL_TYPE_ACCESS);
+ return gpfsacl_get_posix_acl(fsp->fsp_name->base_name,
+ GPFS_ACL_TYPE_ACCESS);
}
static struct gpfs_acl *smb2gpfs_acl(const SMB_ACL_T pacl,
files_struct *fsp,
SMB_ACL_T theacl)
{
- return gpfsacl_sys_acl_set_file(handle, fsp->fsp_name, SMB_ACL_TYPE_ACCESS, theacl);
+ return gpfsacl_sys_acl_set_file(handle, fsp->fsp_name->base_name,
+ SMB_ACL_TYPE_ACCESS, theacl);
}
static int gpfsacl_sys_acl_delete_def_file(vfs_handle_struct *handle,
int i;
files_struct fake_fsp; /* TODO: rationalize parametrization */
SMB4ACE_T *smbace;
+ struct smb_filename *smb_fname = NULL;
+ NTSTATUS status;
DEBUG(10, ("gpfsacl_emu_chmod invoked for %s mode %o\n", path, mode));
/* don't add complementary DENY ACEs here */
ZERO_STRUCT(fake_fsp);
- fake_fsp.fsp_name = (char *)path; /* no file_new is needed here */
-
+ status = create_synthetic_smb_fname(talloc_tos(), path, NULL, NULL,
+ &fake_fsp.fsp_name);
+ if (!NT_STATUS_IS_OK(status)) {
+ errno = map_errno_from_nt_status(status);
+ return -1;
+ }
/* put the acl */
- if (gpfsacl_process_smbacl(&fake_fsp, pacl) == False)
+ if (gpfsacl_process_smbacl(&fake_fsp, pacl) == False) {
+ TALLOC_FREE(fake_fsp.fsp_name);
return -1;
+ }
+
+ TALLOC_FREE(fake_fsp.fsp_name);
return 0; /* ok for [f]chmod */
}
return 0;
}
- rc = gpfsacl_emu_chmod(fsp->fsp_name, mode);
+ rc = gpfsacl_emu_chmod(fsp->fsp_name->base_name, mode);
if (rc == 1)
return SMB_VFS_NEXT_FCHMOD(handle, fsp, mode);
return rc;
DEBUG(10, ("redirecting call of hpuxacl_sys_acl_get_fd to "
"hpuxacl_sys_acl_get_file (no facl syscall on HPUX).\n"));
- return hpuxacl_sys_acl_get_file(handle, file_struct_p->fsp_name,
- SMB_ACL_TYPE_ACCESS);
+ return hpuxacl_sys_acl_get_file(handle,
+ file_struct_p->fsp_name->base_name,
+ SMB_ACL_TYPE_ACCESS);
}
int hpuxacl_sys_acl_set_file(vfs_handle_struct *handle,
- const char *name,
+ struct smb_filename *smb_fname,
SMB_ACL_TYPE_T type,
SMB_ACL_T theacl)
{
int ret = -1;
- SMB_STRUCT_STAT s;
HPUX_ACL_T hpux_acl = NULL;
int count;
DEBUG(10, ("hpuxacl_sys_acl_set_file called for file '%s'\n",
- name));
+ smb_fname_str_dbg(smb_fname)));
if(hpux_acl_call_present() == False) {
* that has _not_ been specified in "type" from the file first
* and concatenate it with the acl provided.
*/
- if (vfs_stat_smb_fname(handle->conn, name, &s) != 0) {
+ if (SMB_VFS_STAT(handle->conn, smb_fname) != 0) {
DEBUG(10, ("Error in stat call: %s\n", strerror(errno)));
goto done;
}
- if (S_ISDIR(s.st_ex_mode)) {
+ if (S_ISDIR(smb_fname->st.st_ex_mode)) {
HPUX_ACL_T other_acl;
int other_count;
SMB_ACL_TYPE_T other_type;
? SMB_ACL_TYPE_DEFAULT
: SMB_ACL_TYPE_ACCESS;
DEBUGADD(10, ("getting acl from filesystem\n"));
- if (!hpux_acl_get_file(name, &other_acl, &other_count)) {
+ if (!hpux_acl_get_file(smb_fname->base_name, &other_acl,
+ &other_count)) {
DEBUG(10, ("error getting acl from directory\n"));
goto done;
}
}
DEBUG(10, ("resulting acl is valid.\n"));
- ret = acl(CONST_DISCARD(char *, name), ACL_SET, count, hpux_acl);
+ ret = acl(CONST_DISCARD(char *, smb_fname->base_name), ACL_SET, count,
+ hpux_acl);
if (ret != 0) {
DEBUG(0, ("ERROR calling acl: %s\n", strerror(errno)));
}
files_struct *fsp);
int hpuxacl_sys_acl_set_file(vfs_handle_struct *handle,
- const char *name,
+ struct smb_filename *smb_fname,
SMB_ACL_TYPE_T type,
SMB_ACL_T theacl);
static int shadow_copy2_fstat(vfs_handle_struct *handle, files_struct *fsp, SMB_STRUCT_STAT *sbuf)
{
int ret = SMB_VFS_NEXT_FSTAT(handle, fsp, sbuf);
- if (ret == 0 && shadow_copy2_match_name(fsp->fsp_name)) {
- convert_sbuf(handle, fsp->fsp_name, sbuf);
+ if (ret == 0 && shadow_copy2_match_name(fsp->fsp_name->base_name)) {
+ convert_sbuf(handle, fsp->fsp_name->base_name, sbuf);
}
return ret;
}
ssize_t result;
result = SMB_VFS_NEXT_READ(handle, fsp, data, n);
- DEBUG(10, ("smb_traffic_analyzer_read: READ: %s\n", fsp->fsp_name ));
+ DEBUG(10, ("smb_traffic_analyzer_read: READ: %s\n", fsp_str_dbg(fsp)));
smb_traffic_analyzer_send_data(handle,
result,
- fsp->fsp_name,
+ fsp->fsp_name->base_name,
false);
return result;
}
result = SMB_VFS_NEXT_PREAD(handle, fsp, data, n, offset);
- DEBUG(10, ("smb_traffic_analyzer_pread: PREAD: %s\n", fsp->fsp_name ));
+ DEBUG(10, ("smb_traffic_analyzer_pread: PREAD: %s\n",
+ fsp_str_dbg(fsp)));
smb_traffic_analyzer_send_data(handle,
result,
- fsp->fsp_name,
+ fsp->fsp_name->base_name,
false);
return result;
result = SMB_VFS_NEXT_WRITE(handle, fsp, data, n);
- DEBUG(10, ("smb_traffic_analyzer_write: WRITE: %s\n", fsp->fsp_name ));
+ DEBUG(10, ("smb_traffic_analyzer_write: WRITE: %s\n",
+ fsp_str_dbg(fsp)));
smb_traffic_analyzer_send_data(handle,
result,
- fsp->fsp_name,
+ fsp->fsp_name->base_name,
true);
return result;
}
result = SMB_VFS_NEXT_PWRITE(handle, fsp, data, n, offset);
- DEBUG(10, ("smb_traffic_analyzer_pwrite: PWRITE: %s\n", fsp->fsp_name ));
+ DEBUG(10, ("smb_traffic_analyzer_pwrite: PWRITE: %s\n", fsp_str_dbg(fsp)));
smb_traffic_analyzer_send_data(handle,
result,
- fsp->fsp_name,
+ fsp->fsp_name->base_name,
true);
return result;
}
static bool streams_xattr_recheck(struct stream_io *sio)
{
NTSTATUS status;
- struct smb_filename *smb_fname = NULL;
char *xattr_name = NULL;
if (sio->fsp->fsp_name == sio->fsp_name_ptr) {
return true;
}
- status = create_synthetic_smb_fname_split(talloc_tos(),
- sio->fsp->fsp_name, NULL,
- &smb_fname);
- if (!NT_STATUS_IS_OK(status)) {
- return false;
- }
-
- if (smb_fname->stream_name == NULL) {
+ if (sio->fsp->fsp_name->stream_name == NULL) {
/* how can this happen */
errno = EINVAL;
return false;
}
- status = streams_xattr_get_name(talloc_tos(), smb_fname->stream_name,
+ status = streams_xattr_get_name(talloc_tos(),
+ sio->fsp->fsp_name->stream_name,
&xattr_name);
if (!NT_STATUS_IS_OK(status)) {
return false;
sio->xattr_name = talloc_strdup(VFS_MEMCTX_FSP_EXTENSION(sio->handle, sio->fsp),
xattr_name);
sio->base = talloc_strdup(VFS_MEMCTX_FSP_EXTENSION(sio->handle, sio->fsp),
- smb_fname->base_name);
+ sio->fsp->fsp_name->base_name);
sio->fsp_name_ptr = sio->fsp->fsp_name;
- TALLOC_FREE(smb_fname);
TALLOC_FREE(xattr_name);
if ((sio->xattr_name == NULL) || (sio->base == NULL)) {
sio->xattr_name,
ea.value.data, ea.value.length, 0);
} else {
- ret = SMB_VFS_SETXATTR(fsp->conn, fsp->base_fsp->fsp_name,
+ ret = SMB_VFS_SETXATTR(fsp->conn,
+ fsp->base_fsp->fsp_name->base_name,
sio->xattr_name,
ea.value.data, ea.value.length, 0);
}
(struct stream_io *)VFS_FETCH_FSP_EXTENSION(handle, fsp);
DEBUG(10, ("streams_xattr_ftruncate called for file %s offset %.0f\n",
- fsp->fsp_name,
- (double)offset ));
+ fsp_str_dbg(fsp), (double)offset));
if (sio == NULL) {
return SMB_VFS_NEXT_FTRUNCATE(handle, fsp, offset);
sio->xattr_name,
ea.value.data, ea.value.length, 0);
} else {
- ret = SMB_VFS_SETXATTR(fsp->conn, fsp->base_fsp->fsp_name,
+ ret = SMB_VFS_SETXATTR(fsp->conn,
+ fsp->base_fsp->fsp_name->base_name,
sio->xattr_name,
ea.value.data, ea.value.length, 0);
}
if(result >= 0) {
notify_fname(handle->conn, NOTIFY_ACTION_MODIFIED,
FILE_NOTIFY_CHANGE_ATTRIBUTES,
- fsp->fsp_name);
+ fsp->fsp_name->base_name);
}
return result;
*/
notify_fname(handle->conn, NOTIFY_ACTION_MODIFIED,
FILE_NOTIFY_CHANGE_ATTRIBUTES,
- fsp->fsp_name);
+ fsp->fsp_name->base_name);
}
return result;
*/
notify_fname(handle->conn, NOTIFY_ACTION_MODIFIED,
FILE_NOTIFY_CHANGE_ATTRIBUTES,
- fsp->fsp_name);
+ fsp->fsp_name->base_name);
}
return result;
SMB_ASSERT(i == naces);
/* store acl */
- if(acl(fsp->fsp_name, ACE_SETACL, naces, acebuf)) {
+ if(acl(fsp->fsp_name->base_name, ACE_SETACL, naces, acebuf)) {
if(errno == ENOSYS) {
DEBUG(9, ("acl(ACE_SETACL, %s): Operation is not "
"supported on the filesystem where the file "
- "reside", fsp->fsp_name));
+ "reside", fsp_str_dbg(fsp)));
} else {
- DEBUG(9, ("acl(ACE_SETACL, %s): %s ", fsp->fsp_name,
- strerror(errno)));
+ DEBUG(9, ("acl(ACE_SETACL, %s): %s ", fsp_str_dbg(fsp),
+ strerror(errno)));
}
return 0;
}
SMB4ACL_T *pacl;
NTSTATUS status;
- status = zfs_get_nt_acl_common(fsp->fsp_name, security_info, &pacl);
+ status = zfs_get_nt_acl_common(fsp->fsp_name->base_name, security_info,
+ &pacl);
if (!NT_STATUS_IS_OK(status)) {
return status;
}
return NT_STATUS_ACCESS_DENIED; /* No errno around here */
}
+ status = create_synthetic_smb_fname(fsp,
+ print_job_fname(lp_const_servicename(SNUM(conn)), jobid), NULL,
+ NULL, &fsp->fsp_name);
+ if (!NT_STATUS_IS_OK(status)) {
+ pjob_delete(lp_const_servicename(SNUM(conn)), jobid);
+ return status;
+ }
/* setup a full fsp */
fsp->fh->fd = print_job_fd(lp_const_servicename(SNUM(conn)),jobid);
GetTimeOfDay(&fsp->open_time);
fsp->oplock_type = NO_OPLOCK;
fsp->sent_oplock_break = NO_BREAK_SENT;
fsp->is_directory = False;
- string_set(&fsp->fsp_name,print_job_fname(lp_const_servicename(SNUM(conn)),jobid));
fsp->wcp = NULL;
SMB_VFS_FSTAT(fsp, psbuf);
fsp->mode = psbuf->st_ex_mode;
}
if (fsp->fsp_name) {
- string_free(&fsp->fsp_name);
+ TALLOC_FREE(fsp->fsp_name);
}
if (!rap_to_pjobid(fsp->rap_print_jobid, NULL, &jobid)) {
if (fsp == NULL) {
return NT_STATUS_NO_MEMORY;
}
- fsp->fsp_name = SMB_STRDUP(argv[1]);
- if (fsp->fsp_name == NULL) {
- SAFE_FREE(fsp);
- return NT_STATUS_NO_MEMORY;
- }
fsp->fh = SMB_MALLOC_P(struct fd_handle);
if (fsp->fh == NULL) {
SAFE_FREE(fsp->fsp_name);
status = create_synthetic_smb_fname_split(mem_ctx, argv[1], NULL,
&smb_fname);
if (!NT_STATUS_IS_OK(status)) {
- SAFE_FREE(fsp->fsp_name);
SAFE_FREE(fsp);
return status;
}
+ fsp->fsp_name = smb_fname;
+
fsp->fh->fd = SMB_VFS_OPEN(vfs->conn, smb_fname, fsp, flags, mode);
- TALLOC_FREE(smb_fname);
if (fsp->fh->fd == -1) {
printf("open: error=%d (%s)\n", errno, strerror(errno));
SAFE_FREE(fsp->fh);
- SAFE_FREE(fsp->fsp_name);
SAFE_FREE(fsp);
+ TALLOC_FREE(smb_fname);
return NT_STATUS_UNSUCCESSFUL;
}
else
printf("close: ok\n");
- SAFE_FREE(vfs->files[fd]->fsp_name);
+ TALLOC_FREE(vfs->files[fd]->fsp_name);
SAFE_FREE(vfs->files[fd]->fh);
SAFE_FREE(vfs->files[fd]);
vfs->files[fd] = NULL;