The branch, master has been updated via 273d48504e1 CI: smb3unix.py: check more attributes of test files (and dirs) in test_posix_perm_files() via ab2d619f205 smbtorture3: also check test file and it's attributes in two POSIX tests via 95abd2f59fa smbd: allow setting ARCHIVE bit in POSIX context with "store dos attributes" via cd858a2a239 smbtorture3: prepare POSIX tests for differentianting between client flavour in the list callback via cad82600ef6 smbtorture3: remove unused initializers via ddc9cb779f5 smbd: s/FILE_ATTRIBUTES_INVALID/FILE_ATTRIBUTE_INVALID/g via 4c91f8ac2a9 smbtorture3: reduce indentation in posix_ls_fn() via ec143274c79 smbd: allow POSIX opens for file_set_dosmode() in rename_internals_fsp() via 17bb46abfe6 smbd: allow POSIX opens for file_set_dosmode() in mkdir_internal() via f5604640e90 smbd: allow POSIX opens for file_set_dosmode() in mark_file_modified() via 4d1b4d893d2 smbd: move POSIX check from possibly_set_archive() to file_set_dosmode() via b3c6c677a70 smbd: in file_set_dosmode() do an early exit if smb_fname->fsp is NULL via 7c7786a121c smbd: ignore symlinks in file_set_dosmode() via 9b3c085409a smbd: add and use helper function possibly_set_archive() via 19434fe06d1 smbd: remove call to fdos_mode() when setting DOS attrs from cfec96d5e9f third_party/heimdal: Import lorikeet-heimdal-202311030123 (commit 2346a67fe25cbf16128501665db41f6840546e15)
https://git.samba.org/?p=samba.git;a=shortlog;h=master - Log ----------------------------------------------------------------- commit 273d48504e1da726af21cc5b0517c1761e51e6f9 Author: Ralph Boehme <s...@samba.org> Date: Sun Oct 29 18:08:22 2023 +0100 CI: smb3unix.py: check more attributes of test files (and dirs) in test_posix_perm_files() Signed-off-by: Ralph Boehme <s...@samba.org> Reviewed-by: Jeremy Allison <j...@samba.org> Autobuild-User(master): Jeremy Allison <j...@samba.org> Autobuild-Date(master): Sun Nov 5 19:35:51 UTC 2023 on atb-devel-224 commit ab2d619f205f854eddaecb47b6858a49953b291d Author: Ralph Boehme <s...@samba.org> Date: Fri Nov 3 11:09:47 2023 +0100 smbtorture3: also check test file and it's attributes in two POSIX tests Verifies that the correct DOS attribute, FILE_ATTRIBUTE_ARCHIVE in this case, are returned over SMB1 with UNIX extensions. Signed-off-by: Ralph Boehme <s...@samba.org> Reviewed-by: Jeremy Allison <j...@samba.org> commit 95abd2f59fa98159a7dee2ca18da849631781275 Author: Ralph Boehme <s...@samba.org> Date: Tue Oct 31 12:25:38 2023 +0100 smbd: allow setting ARCHIVE bit in POSIX context with "store dos attributes" Cf https://lists.samba.org/archive/samba-technical/2023-October/138504.html Signed-off-by: Ralph Boehme <s...@samba.org> Reviewed-by: Jeremy Allison <j...@samba.org> commit cd858a2a239a687b96c3b0e7633ccd7b8b8edb0e Author: Ralph Boehme <s...@samba.org> Date: Tue Oct 31 10:11:50 2023 +0100 smbtorture3: prepare POSIX tests for differentianting between client flavour in the list callback No change in behaviour. Signed-off-by: Ralph Boehme <s...@samba.org> Reviewed-by: Jeremy Allison <j...@samba.org> commit cad82600ef6ab4caa3ad8a7255b9f3db616decc3 Author: Ralph Boehme <s...@samba.org> Date: Tue Oct 31 12:28:28 2023 +0100 smbtorture3: remove unused initializers Signed-off-by: Ralph Boehme <s...@samba.org> Reviewed-by: Jeremy Allison <j...@samba.org> commit ddc9cb779f56476aaa1a85c4008c0b848dff4cf7 Author: Ralph Boehme <s...@samba.org> Date: Tue Oct 31 10:05:30 2023 +0100 smbd: s/FILE_ATTRIBUTES_INVALID/FILE_ATTRIBUTE_INVALID/g No idea what got me into having an "S" in the define when I added it. Signed-off-by: Ralph Boehme <s...@samba.org> Reviewed-by: Jeremy Allison <j...@samba.org> commit 4c91f8ac2a9943f4b58090faf8cb3dcdb2a19e5a Author: Ralph Boehme <s...@samba.org> Date: Tue Oct 31 06:05:25 2023 +0100 smbtorture3: reduce indentation in posix_ls_fn() Prepares for adding more logic in a later commit. Signed-off-by: Ralph Boehme <s...@samba.org> Reviewed-by: Jeremy Allison <j...@samba.org> commit ec143274c7992f92337d0e4b2c6cc9163fa69f49 Author: Ralph Boehme <s...@samba.org> Date: Tue Oct 31 12:24:35 2023 +0100 smbd: allow POSIX opens for file_set_dosmode() in rename_internals_fsp() As this check was previously added to file_set_dosmode() this is not yet a change in behaviour. Signed-off-by: Ralph Boehme <s...@samba.org> Reviewed-by: Jeremy Allison <j...@samba.org> commit 17bb46abfe6c996676ff8dd33711f617e18ffa35 Author: Ralph Boehme <s...@samba.org> Date: Tue Oct 31 12:24:12 2023 +0100 smbd: allow POSIX opens for file_set_dosmode() in mkdir_internal() As this check was previously added to file_set_dosmode() this is not yet a change in behaviour. Signed-off-by: Ralph Boehme <s...@samba.org> Reviewed-by: Jeremy Allison <j...@samba.org> commit f5604640e90b522533abee16905361aa0ef9e48d Author: Ralph Boehme <s...@samba.org> Date: Tue Oct 31 12:23:44 2023 +0100 smbd: allow POSIX opens for file_set_dosmode() in mark_file_modified() As this check was previously added to file_set_dosmode() this is not yet a change in behaviour. Signed-off-by: Ralph Boehme <s...@samba.org> Reviewed-by: Jeremy Allison <j...@samba.org> commit 4d1b4d893d2fe297218309736ae63bac63404b5b Author: Ralph Boehme <s...@samba.org> Date: Tue Oct 31 12:16:59 2023 +0100 smbd: move POSIX check from possibly_set_archive() to file_set_dosmode() No change in behaviour. Move the check to the more low-level function file_set_dosmode() to ensure all callers use this consistently. Signed-off-by: Ralph Boehme <s...@samba.org> Reviewed-by: Jeremy Allison <j...@samba.org> commit b3c6c677a7031ad3a182a90c621a3f1ffb37e9fb Author: Ralph Boehme <s...@samba.org> Date: Tue Oct 31 12:10:17 2023 +0100 smbd: in file_set_dosmode() do an early exit if smb_fname->fsp is NULL No change in behaviour. Simplifies coming changes. Signed-off-by: Ralph Boehme <s...@samba.org> Reviewed-by: Jeremy Allison <j...@samba.org> commit 7c7786a121cedd56c37c7b349912680780b151f6 Author: Ralph Boehme <s...@samba.org> Date: Tue Oct 31 10:06:38 2023 +0100 smbd: ignore symlinks in file_set_dosmode() Signed-off-by: Ralph Boehme <s...@samba.org> Reviewed-by: Jeremy Allison <j...@samba.org> commit 9b3c085409a18298097b4bf015d8dba640ccc404 Author: Ralph Boehme <s...@samba.org> Date: Mon Oct 30 19:15:53 2023 +0100 smbd: add and use helper function possibly_set_archive() Signed-off-by: Ralph Boehme <s...@samba.org> Reviewed-by: Jeremy Allison <j...@samba.org> commit 19434fe06d14a7fc2c9089cc880c93257eda5518 Author: Ralph Boehme <s...@samba.org> Date: Mon Oct 30 19:04:56 2023 +0100 smbd: remove call to fdos_mode() when setting DOS attrs This added in 49a754b82d33fb523cda4151a865584ae52a2e2f to work with stored itime based File-Ids. Since switching back to purely inode based File-Ids we can remove this call that primed itime from DOS xattr. Signed-off-by: Ralph Boehme <s...@samba.org> Reviewed-by: Jeremy Allison <j...@samba.org> ----------------------------------------------------------------------- Summary of changes: libcli/smb/smb_constants.h | 2 +- python/samba/tests/smb3unix.py | 32 +++++-- source3/include/smb_macros.h | 2 +- source3/smbd/dosmode.c | 35 +++++--- source3/smbd/fileio.c | 3 - source3/smbd/files.c | 8 +- source3/smbd/open.c | 59 +++++++++---- source3/smbd/smb2_reply.c | 1 - source3/torture/test_posix.c | 188 +++++++++++++++++++++++++++++------------ 9 files changed, 231 insertions(+), 99 deletions(-) Changeset truncated at 500 lines: diff --git a/libcli/smb/smb_constants.h b/libcli/smb/smb_constants.h index ead047d924f..1d55a555157 100644 --- a/libcli/smb/smb_constants.h +++ b/libcli/smb/smb_constants.h @@ -329,7 +329,7 @@ enum csc_policy { #define FLAGS2_UNICODE_STRINGS 0x8000 /* FileAttributes (search attributes) field */ -#define FILE_ATTRIBUTES_INVALID 0x0000L +#define FILE_ATTRIBUTE_INVALID 0x0000L #define FILE_ATTRIBUTE_READONLY 0x0001L #define FILE_ATTRIBUTE_HIDDEN 0x0002L #define FILE_ATTRIBUTE_SYSTEM 0x0004L diff --git a/python/samba/tests/smb3unix.py b/python/samba/tests/smb3unix.py index a98109d096b..33a3d546f75 100644 --- a/python/samba/tests/smb3unix.py +++ b/python/samba/tests/smb3unix.py @@ -233,9 +233,11 @@ class Smb3UnixTests(samba.tests.libsmb.LibsmbTests): fname = 'testfile%04o' % perm test_files[fname] = perm f,_,cc_out = c.create_ex('\\%s' % fname, - DesiredAccess=security.SEC_STD_ALL, + DesiredAccess=security.SEC_FILE_ALL, CreateDisposition=libsmb.FILE_CREATE, CreateContexts=[posix_context(perm)]) + if perm & 0o200 == 0o200: + c.write(f, buffer=b"data", offset=0) c.close(f) dname = 'testdir%04o' % perm @@ -248,13 +250,33 @@ class Smb3UnixTests(samba.tests.libsmb.LibsmbTests): c.close(f) res = c.list("", info_level=libsmb.SMB2_FIND_POSIX_INFORMATION) - found_files = {get_string(i['name']): i['perms'] for i in res} - for fname, perm in test_files.items(): + + found_files = {get_string(i['name']): i for i in res} + for fname,perm in test_files.items(): self.assertIn(get_string(fname), found_files.keys(), 'Test file not found') - self.assertEqual(test_files[fname], found_files[fname], + self.assertEqual(test_files[fname], found_files[fname]['perms'], 'Requested %04o, Received %04o' % \ - (test_files[fname], found_files[fname])) + (test_files[fname], found_files[fname]['perms'])) + + self.assertEqual(found_files[fname]['reparse_tag'], + libsmb.IO_REPARSE_TAG_RESERVED_ZERO) + self.assertEqual(found_files[fname]['perms'], perm) + self.assertEqual(found_files[fname]['owner_sid'], + self.samsid + "-1000") + self.assertTrue(found_files[fname]['group_sid'].startswith("S-1-22-2-")) + + if fname.startswith("testfile"): + self.assertEqual(found_files[fname]['nlink'], 1) + self.assertEqual(found_files[fname]['size'], 4) + self.assertEqual(found_files[fname]['allocaction_size'], + 4096) + self.assertEqual(found_files[fname]['attrib'], + libsmb.FILE_ATTRIBUTE_ARCHIVE) + else: + self.assertEqual(found_files[fname]['nlink'], 2) + self.assertEqual(found_files[fname]['attrib'], + libsmb.FILE_ATTRIBUTE_DIRECTORY) finally: if len(test_files) > 0: diff --git a/source3/include/smb_macros.h b/source3/include/smb_macros.h index f9aaf786ed3..3a942f9df11 100644 --- a/source3/include/smb_macros.h +++ b/source3/include/smb_macros.h @@ -103,7 +103,7 @@ #define VALID_STAT_OF_DIR(st) (VALID_STAT(st) && S_ISDIR((st).st_ex_mode)) #define SET_STAT_INVALID(st) { \ (st).st_ex_nlink = 0; \ - (st).cached_dos_attributes = FILE_ATTRIBUTES_INVALID; \ + (st).cached_dos_attributes = FILE_ATTRIBUTE_INVALID; \ }; /* Macros to get at offsets within smb_lkrng and smb_unlkrng diff --git a/source3/smbd/dosmode.c b/source3/smbd/dosmode.c index 2eef953a9cb..c0fc468cdfb 100644 --- a/source3/smbd/dosmode.c +++ b/source3/smbd/dosmode.c @@ -710,7 +710,7 @@ uint32_t fdos_mode(struct files_struct *fsp) return FILE_ATTRIBUTE_NORMAL; } - if (fsp->fsp_name->st.cached_dos_attributes != FILE_ATTRIBUTES_INVALID) { + if (fsp->fsp_name->st.cached_dos_attributes != FILE_ATTRIBUTE_INVALID) { return fsp->fsp_name->st.cached_dos_attributes; } @@ -903,6 +903,11 @@ int file_set_dosmode(connection_struct *conn, return -1; } + if (S_ISLNK(smb_fname->st.st_ex_mode)) { + /* A symlink in POSIX context, ignore */ + return 0; + } + if ((S_ISDIR(smb_fname->st.st_ex_mode)) && (dosmode & FILE_ATTRIBUTE_TEMPORARY)) { @@ -915,26 +920,30 @@ int file_set_dosmode(connection_struct *conn, DEBUG(10,("file_set_dosmode: setting dos mode 0x%x on file %s\n", dosmode, smb_fname_str_dbg(smb_fname))); - unixmode = smb_fname->st.st_ex_mode; + if (smb_fname->fsp == NULL) { + errno = ENOENT; + return -1; + } - if (smb_fname->fsp != NULL) { - get_acl_group_bits( - conn, smb_fname->fsp, &smb_fname->st.st_ex_mode); + if (smb_fname->fsp->posix_flags & FSP_POSIX_FLAGS_OPEN && + !lp_store_dos_attributes(SNUM(conn))) + { + return 0; } + unixmode = smb_fname->st.st_ex_mode; + + get_acl_group_bits(conn, smb_fname->fsp, &smb_fname->st.st_ex_mode); + if (S_ISDIR(smb_fname->st.st_ex_mode)) dosmode |= FILE_ATTRIBUTE_DIRECTORY; else dosmode &= ~FILE_ATTRIBUTE_DIRECTORY; - if (smb_fname->fsp != NULL) { - /* Store the DOS attributes in an EA by preference. */ - status = SMB_VFS_FSET_DOS_ATTRIBUTES( - conn, metadata_fsp(smb_fname->fsp), dosmode); - } else { - status = NT_STATUS_OBJECT_NAME_NOT_FOUND; - } - + /* Store the DOS attributes in an EA by preference. */ + status = SMB_VFS_FSET_DOS_ATTRIBUTES(conn, + metadata_fsp(smb_fname->fsp), + dosmode); if (NT_STATUS_IS_OK(status)) { smb_fname->st.cached_dos_attributes = dosmode; ret = 0; diff --git a/source3/smbd/fileio.c b/source3/smbd/fileio.c index 3b3d3a5fcd9..ed62159a495 100644 --- a/source3/smbd/fileio.c +++ b/source3/smbd/fileio.c @@ -237,9 +237,6 @@ void mark_file_modified(files_struct *fsp) fsp->fsp_flags.modified = true; - if (fsp->posix_flags & FSP_POSIX_FLAGS_OPEN) { - return; - } if (!(lp_store_dos_attributes(SNUM(fsp->conn)) || MAP_ARCHIVE(fsp->conn))) { return; diff --git a/source3/smbd/files.c b/source3/smbd/files.c index 1bbf822df28..0c54ca37468 100644 --- a/source3/smbd/files.c +++ b/source3/smbd/files.c @@ -2038,7 +2038,7 @@ files_struct *file_fsp(struct smb_request *req, uint16_t fid) } req->chain_fsp = fsp; - fsp->fsp_name->st.cached_dos_attributes = FILE_ATTRIBUTES_INVALID; + fsp->fsp_name->st.cached_dos_attributes = FILE_ATTRIBUTE_INVALID; return fsp; } @@ -2085,7 +2085,7 @@ struct files_struct *file_fsp_get(struct smbd_smb2_request *smb2req, return NULL; } - fsp->fsp_name->st.cached_dos_attributes = FILE_ATTRIBUTES_INVALID; + fsp->fsp_name->st.cached_dos_attributes = FILE_ATTRIBUTE_INVALID; return fsp; } @@ -2101,7 +2101,7 @@ struct files_struct *file_fsp_smb2(struct smbd_smb2_request *smb2req, return NULL; } smb2req->compat_chain_fsp->fsp_name->st.cached_dos_attributes = - FILE_ATTRIBUTES_INVALID; + FILE_ATTRIBUTE_INVALID; return smb2req->compat_chain_fsp; } @@ -2231,7 +2231,7 @@ static NTSTATUS fsp_attach_smb_fname(struct files_struct *fsp, fsp->name_hash = name_hash; fsp->fsp_name = smb_fname_new; - fsp->fsp_name->st.cached_dos_attributes = FILE_ATTRIBUTES_INVALID; + fsp->fsp_name->st.cached_dos_attributes = FILE_ATTRIBUTE_INVALID; *_smb_fname = NULL; return NT_STATUS_OK; } diff --git a/source3/smbd/open.c b/source3/smbd/open.c index 9e5bf2f6731..4b1d5a4de65 100644 --- a/source3/smbd/open.c +++ b/source3/smbd/open.c @@ -3728,6 +3728,42 @@ static void open_ntcreate_lock_cleanup_entry(struct share_mode_lock *lck, } } +static void possibly_set_archive(struct connection_struct *conn, + struct files_struct *fsp, + struct smb_filename *smb_fname, + struct smb_filename *parent_dir_fname, + int info, + uint32_t dosattrs, + mode_t *unx_mode) +{ + bool set_archive = false; + int ret; + + if (info == FILE_WAS_OPENED) { + return; + } + + /* Overwritten files should be initially set as archive */ + if ((info == FILE_WAS_OVERWRITTEN && lp_map_archive(SNUM(conn)))) { + set_archive = true; + } else if (lp_store_dos_attributes(SNUM(conn))) { + set_archive = true; + } + if (!set_archive) { + return; + } + + ret = file_set_dosmode(conn, + smb_fname, + dosattrs | FILE_ATTRIBUTE_ARCHIVE, + parent_dir_fname, + true); + if (ret != 0) { + return; + } + *unx_mode = smb_fname->st.st_ex_mode; +} + /**************************************************************************** Open a file with a share mode. Passed in an already created files_struct *. ****************************************************************************/ @@ -4410,20 +4446,13 @@ static NTSTATUS open_file_ntcreate(connection_struct *conn, fsp->fsp_flags.initial_delete_on_close = true; } - if (info != FILE_WAS_OPENED) { - /* Overwritten files should be initially set as archive */ - if ((info == FILE_WAS_OVERWRITTEN && lp_map_archive(SNUM(conn))) || - lp_store_dos_attributes(SNUM(conn))) { - (void)fdos_mode(fsp); - if (!posix_open) { - if (file_set_dosmode(conn, smb_fname, - new_dos_attributes | FILE_ATTRIBUTE_ARCHIVE, - parent_dir_fname, true) == 0) { - unx_mode = smb_fname->st.st_ex_mode; - } - } - } - } + possibly_set_archive(conn, + fsp, + smb_fname, + parent_dir_fname, + info, + new_dos_attributes, + &smb_fname->st.st_ex_mode); /* Determine sparse flag. */ if (posix_open) { @@ -4595,7 +4624,7 @@ static NTSTATUS mkdir_internal(connection_struct *conn, return NT_STATUS_NOT_A_DIRECTORY; } - if (lp_store_dos_attributes(SNUM(conn)) && !posix_open) { + if (lp_store_dos_attributes(SNUM(conn))) { file_set_dosmode(conn, smb_dname, file_attributes | FILE_ATTRIBUTE_DIRECTORY, diff --git a/source3/smbd/smb2_reply.c b/source3/smbd/smb2_reply.c index ce66e9b869f..269482f11ec 100644 --- a/source3/smbd/smb2_reply.c +++ b/source3/smbd/smb2_reply.c @@ -1762,7 +1762,6 @@ NTSTATUS rename_internals_fsp(connection_struct *conn, smb_fname_dst); if (!fsp->fsp_flags.is_directory && - !(fsp->posix_flags & FSP_POSIX_FLAGS_PATHNAMES) && (lp_map_archive(SNUM(conn)) || lp_store_dos_attributes(SNUM(conn)))) { diff --git a/source3/torture/test_posix.c b/source3/torture/test_posix.c index dbf72db7b03..ac4c1a1cb34 100644 --- a/source3/torture/test_posix.c +++ b/source3/torture/test_posix.c @@ -33,54 +33,73 @@ struct posix_test_entry { const char *name; const char *target; const char *expected; - uint32_t attr; + uint32_t attr_win; + uint32_t attr_lin; uint64_t returned_size; bool ok; }; +enum client_flavour { WINDOWS, POSIX }; + +struct posix_test_state { + enum client_flavour flavour; + struct posix_test_entry *entries; +}; + static NTSTATUS posix_ls_fn(struct file_info *finfo, const char *name, void *_state) { - struct posix_test_entry *state = - (struct posix_test_entry *)_state; - - for (; state->name != NULL; state++) { - if (strequal(finfo->name, state->expected)) { - if (state->attr != finfo->attr) { - break; - } - state->ok = true; - state->returned_size = finfo->size; + struct posix_test_state *state = + (struct posix_test_state *)_state; + struct posix_test_entry *e = state->entries; + + for (; e->name != NULL; e++) { + uint32_t attr; + if (!strequal(finfo->name, e->expected)) { + continue; + } + if (state->flavour == WINDOWS) { + attr = e->attr_win; + } else { + attr = e->attr_lin; + } + if (attr != finfo->attr) { break; } + e->ok = true; + e->returned_size = finfo->size; + break; } return NT_STATUS_OK; } -static void posix_test_entries_reset(struct posix_test_entry *state) +static void posix_test_entries_reset(struct posix_test_state *state) { - for (; state->name != NULL; state++) { - state->ok = false; - state->returned_size = 0; + struct posix_test_entry *e = state->entries; + + for (; e->name != NULL; e++) { + e->ok = false; + e->returned_size = 0; } } -static bool posix_test_entry_check(struct posix_test_entry *state, +static bool posix_test_entry_check(struct posix_test_state *state, const char *name, bool expected, uint64_t expected_size) { + struct posix_test_entry *e = state->entries; bool result = false; - for (; state->name != NULL; state++) { - if (strequal(name, state->name)) { - result = state->ok; + for (; e->name != NULL; e++) { + if (strequal(name, e->name)) { + result = e->ok; break; } } - if (state->name == NULL) { + if (e->name == NULL) { printf("test failed, unknown name: %s\n", name); return false; } @@ -113,26 +132,39 @@ bool run_posix_ls_wildcard_test(int dummy) const char *symlnk_dst_in_share = file; const char *symlnk_outside_share = "symlnk_outside_share"; const char *symlnk_dst_outside_share = "/etc/passwd"; - struct posix_test_entry state[] = { + struct posix_test_entry entries[] = { { + .name = file, + .target = NULL, + .expected = file, + .attr_win = FILE_ATTRIBUTE_ARCHIVE, + .attr_lin = FILE_ATTRIBUTE_ARCHIVE, + }, { .name = symlnk_dangling, .target = symlnk_dst_dangling, .expected = symlnk_dangling, - .attr = FILE_ATTRIBUTE_NORMAL, + .attr_win = FILE_ATTRIBUTE_INVALID, + .attr_lin = FILE_ATTRIBUTE_NORMAL, }, { .name = symlnk_in_share, .target = symlnk_dst_in_share, .expected = symlnk_in_share, - .attr = FILE_ATTRIBUTE_NORMAL, + .attr_win = FILE_ATTRIBUTE_ARCHIVE, + .attr_lin = FILE_ATTRIBUTE_NORMAL, }, { .name = symlnk_outside_share, .target = symlnk_dst_outside_share, .expected = symlnk_outside_share, - .attr = FILE_ATTRIBUTE_NORMAL, + .attr_win = FILE_ATTRIBUTE_INVALID, + .attr_lin = FILE_ATTRIBUTE_NORMAL, }, { .name = NULL, } }; + struct posix_test_state _state = { + .entries = entries, + }; + struct posix_test_state *state = &_state; int i; bool correct = false; @@ -183,10 +215,13 @@ bool run_posix_ls_wildcard_test(int dummy) } fnum = (uint16_t)-1; - for (i = 0; state[i].name != NULL; i++) { + for (i = 0; entries[i].name != NULL; i++) { + if (entries[i].target == NULL) { + continue; + } status = cli_posix_symlink(cli_unix, - state[i].target, - state[i].name); + entries[i].target, + entries[i].name); if (!NT_STATUS_IS_OK(status)) { printf("POSIX symlink of %s failed (%s)\n", symlnk_dangling, nt_errstr(status)); @@ -195,6 +230,7 @@ bool run_posix_ls_wildcard_test(int dummy) } printf("Doing Windows ls *\n"); + state->flavour = WINDOWS; status = cli_list(cli_win, "*", 0, posix_ls_fn, state); if (!NT_STATUS_IS_OK(status)) { @@ -202,6 +238,9 @@ bool run_posix_ls_wildcard_test(int dummy) goto out; } + if (!posix_test_entry_check(state, file, true, 0)) { + goto out; + } if (!posix_test_entry_check(state, symlnk_dangling, false, 0)) { goto out; } @@ -215,6 +254,7 @@ bool run_posix_ls_wildcard_test(int dummy) posix_test_entries_reset(state); printf("Doing POSIX ls *\n"); + state->flavour = LINUX; status = cli_list(cli_unix, "*", 0, posix_ls_fn, state); if (!NT_STATUS_IS_OK(status)) { @@ -222,6 +262,9 @@ bool run_posix_ls_wildcard_test(int dummy) goto out; } + if (!posix_test_entry_check(state, file, true, 0)) { + goto out; + } if (!posix_test_entry_check(state, symlnk_dangling, true, @@ -280,26 +323,39 @@ bool run_posix_ls_single_test(int dummy) const char *symlnk_dst_in_share = file; const char *symlnk_outside_share = "symlnk_outside_share"; const char *symlnk_dst_outside_share = "/etc/passwd"; - struct posix_test_entry state[] = { + struct posix_test_entry entries[] = { -- Samba Shared Repository