summaryrefslogtreecommitdiff
path: root/source3/torture/cmd_vfs.c
diff options
context:
space:
mode:
authorAndrew Bartlett <abartlet@samba.org>2012-08-16 13:46:02 +1000
committerAndrew Bartlett <abartlet@samba.org>2012-08-16 09:32:25 +0200
commitdf8e9c128716c89f5a1d58f032e3d641e033c8b0 (patch)
tree6d41c02053cc284215fd86b648fb178275119be5 /source3/torture/cmd_vfs.c
parent05885a84f9ea67a986bdcb10a2bd07c00a2df0d4 (diff)
downloadsamba-df8e9c128716c89f5a1d58f032e3d641e033c8b0.tar.gz
samba-df8e9c128716c89f5a1d58f032e3d641e033c8b0.tar.bz2
samba-df8e9c128716c89f5a1d58f032e3d641e033c8b0.zip
s3-selftest: Add a seperate test for ACL tests using vfstest
This does not check for consistency or correctness yet, that will be done with python unit tests. The purpose of this test is to ensure that the vfstest wrapper doesn't crash. Andrew Bartlett Autobuild-User(master): Andrew Bartlett <abartlet@samba.org> Autobuild-Date(master): Thu Aug 16 09:32:25 CEST 2012 on sn-devel-104
Diffstat (limited to 'source3/torture/cmd_vfs.c')
-rw-r--r--source3/torture/cmd_vfs.c45
1 files changed, 35 insertions, 10 deletions
diff --git a/source3/torture/cmd_vfs.c b/source3/torture/cmd_vfs.c
index 86373b7464..9c19f2f6d2 100644
--- a/source3/torture/cmd_vfs.c
+++ b/source3/torture/cmd_vfs.c
@@ -1461,14 +1461,13 @@ static NTSTATUS cmd_set_nt_acl(struct vfs_state *vfs, TALLOC_CTX *mem_ctx, int a
flags = O_RDWR;
- fsp = SMB_MALLOC_P(struct files_struct);
+ fsp = talloc_zero(vfs, struct files_struct);
if (fsp == NULL) {
return NT_STATUS_NO_MEMORY;
}
- fsp->fh = SMB_MALLOC_P(struct fd_handle);
+ fsp->fh = talloc_zero(fsp, struct fd_handle);
if (fsp->fh == NULL) {
- SAFE_FREE(fsp->fsp_name);
- SAFE_FREE(fsp);
+ TALLOC_FREE(fsp);
return NT_STATUS_NO_MEMORY;
}
fsp->conn = vfs->conn;
@@ -1476,7 +1475,7 @@ static NTSTATUS cmd_set_nt_acl(struct vfs_state *vfs, TALLOC_CTX *mem_ctx, int a
status = create_synthetic_smb_fname_split(NULL, argv[1], NULL,
&smb_fname);
if (!NT_STATUS_IS_OK(status)) {
- SAFE_FREE(fsp);
+ TALLOC_FREE(fsp);
return status;
}
@@ -1485,12 +1484,40 @@ static NTSTATUS cmd_set_nt_acl(struct vfs_state *vfs, TALLOC_CTX *mem_ctx, int a
fsp->fh->fd = SMB_VFS_OPEN(vfs->conn, smb_fname, fsp, flags, mode);
if (fsp->fh->fd == -1) {
printf("open: error=%d (%s)\n", errno, strerror(errno));
- SAFE_FREE(fsp->fh);
- SAFE_FREE(fsp);
+ TALLOC_FREE(fsp);
TALLOC_FREE(smb_fname);
return NT_STATUS_UNSUCCESSFUL;
}
+ ret = SMB_VFS_FSTAT(fsp, &smb_fname->st);
+ if (ret == -1) {
+ /* If we have an fd, this stat should succeed. */
+ DEBUG(0,("Error doing fstat on open file %s "
+ "(%s)\n",
+ smb_fname_str_dbg(smb_fname),
+ strerror(errno) ));
+ status = map_nt_error_from_unix(errno);
+ } else if (S_ISDIR(smb_fname->st.st_ex_mode)) {
+ errno = EISDIR;
+ status = NT_STATUS_FILE_IS_A_DIRECTORY;
+ }
+
+ if (!NT_STATUS_IS_OK(status)) {
+ goto out;
+ }
+
+ fsp->file_id = vfs_file_id_from_sbuf(vfs->conn, &smb_fname->st);
+ fsp->vuid = UID_FIELD_INVALID;
+ fsp->file_pid = 0;
+ fsp->can_lock = True;
+ fsp->can_read = True;
+ fsp->can_write = True;
+ fsp->print_file = NULL;
+ fsp->modified = False;
+ fsp->sent_oplock_break = NO_BREAK_SENT;
+ fsp->is_directory = False;
+
+
sd = sddl_decode(talloc_tos(), argv[2], get_global_sam_sid());
if (!sd) {
printf("sddl_decode failed to parse %s as SDDL\n", argv[2]);
@@ -1510,9 +1537,7 @@ out:
if (ret == -1 )
printf("close: error=%d (%s)\n", errno, strerror(errno));
- TALLOC_FREE(fsp->fsp_name);
- SAFE_FREE(fsp->fh);
- SAFE_FREE(fsp);
+ TALLOC_FREE(fsp);
return status;
}