From 6b7a99107d956651fae43a7e62d1fbf69d97d0c7 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Thu, 16 Aug 2012 16:50:47 +1000 Subject: s3-torture: Allow vfstest to set ACLs on a directory Autobuild-User(master): Andrew Bartlett Autobuild-Date(master): Fri Aug 17 02:35:49 CEST 2012 on sn-devel-104 --- source3/script/tests/vfstest-acl/vfstest.cmd | 9 +++++++++ source3/torture/cmd_vfs.c | 17 +++++++++++------ 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/source3/script/tests/vfstest-acl/vfstest.cmd b/source3/script/tests/vfstest-acl/vfstest.cmd index 19f5fd6900..61686717ec 100644 --- a/source3/script/tests/vfstest-acl/vfstest.cmd +++ b/source3/script/tests/vfstest-acl/vfstest.cmd @@ -1,6 +1,15 @@ connect open x RC 0700 +sys_acl_get_file . 0 +sys_acl_get_file . 1 +get_nt_acl . +set_nt_acl . G:DAD:P(A;OICI;0x001f01ff;;;BA)(A;OICI;0x001200a9;;;SO)(A;OICI;0x001f01ff;;;SY)(A;OICI;0x001200a9;;;AU) +get_nt_acl . +sys_acl_get_file . 0 +sys_acl_get_file . 1 get_nt_acl x +sys_acl_get_file x 0 set_nt_acl x G:DAD:P(A;OICI;0x001f01ff;;;BA)(A;OICI;0x001200a9;;;SO)(A;OICI;0x001f01ff;;;SY)(A;OICI;0x001200a9;;;AU) get_nt_acl x sys_acl_get_file x 0 + diff --git a/source3/torture/cmd_vfs.c b/source3/torture/cmd_vfs.c index 9c19f2f6d2..236b9c09f8 100644 --- a/source3/torture/cmd_vfs.c +++ b/source3/torture/cmd_vfs.c @@ -1459,8 +1459,6 @@ static NTSTATUS cmd_set_nt_acl(struct vfs_state *vfs, TALLOC_CTX *mem_ctx, int a mode = 00400; - flags = O_RDWR; - fsp = talloc_zero(vfs, struct files_struct); if (fsp == NULL) { return NT_STATUS_NO_MEMORY; @@ -1481,7 +1479,17 @@ static NTSTATUS cmd_set_nt_acl(struct vfs_state *vfs, TALLOC_CTX *mem_ctx, int a fsp->fsp_name = smb_fname; - fsp->fh->fd = SMB_VFS_OPEN(vfs->conn, smb_fname, fsp, flags, mode); +#ifdef O_DIRECTORY + flags = O_RDONLY|O_DIRECTORY; +#else + /* POSIX allows us to open a directory with O_RDONLY. */ + flags = O_RDONLY; +#endif + + fsp->fh->fd = SMB_VFS_OPEN(vfs->conn, smb_fname, fsp, O_RDWR, mode); + if (fsp->fh->fd == -1 && errno == EISDIR) { + 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)); TALLOC_FREE(fsp); @@ -1497,9 +1505,6 @@ static NTSTATUS cmd_set_nt_acl(struct vfs_state *vfs, TALLOC_CTX *mem_ctx, int a 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)) { -- cgit