The branch, master has been updated via 357bafe6258 smbd: Allow POSIX getinfo levels for smb3 unix extensions via bbc82a5d425 s3: Test that store_smb2_posix_info hides info for '..' via d0ad452fc81 s3: smbd: store_smb2_posix_info hide info for '..' via bdb98c83974 smbd: Implement SMB2_FS_POSIX_INFORMATION_INTERNAL via a73d9032388 tests/s3: Test file/dir permissions with SMB3 posix via 09c8426b95a tests/s3: Test case sensitive open with SMB3 posix via 160173ee064 tests/s3: Test delete on close with SMB3 posix via f481cd4a60a libcli: Add client support for SMB2_FILE_POSIX_INFORMATION via f0e1137425f tests/s3: Test reserved chars in posix filename via 08226d6c2e8 smbd: Implement SMB2_FILE_POSIX_INFORMATION in smbd_marshall_dir_entry via 7c2f08d564f tests/s3: Test SMB2_FIND_POSIX_INFORMATION dir query via 284787996d4 libsmb: Allow listing with posix context via 99de8d7cfa3 libsmb: Make info_level configurable in dir listing via 2c1a02d622c smbd: Plumb SMB2_FIND_POSIX_INFORMATION through the directory reading code. via 72004f8f948 s3: smbd: Add SMB2_FILE_POSIX_INFORMATION getinfo info level (100 on the wire). from 535a08dfc4c smbd: reject FILE_ATTRIBUTE_TEMPORARY on directories
https://git.samba.org/?p=samba.git;a=shortlog;h=master - Log ----------------------------------------------------------------- commit 357bafe62584e2ca1bbf0dfaf6f949262daf59dc Author: Volker Lendecke <v...@samba.org> Date: Tue Nov 22 16:00:53 2022 +0100 smbd: Allow POSIX getinfo levels for smb3 unix extensions Signed-off-by: Volker Lendecke <v...@samba.org> Reviewed-by: David Mulder <dmul...@samba.org> Autobuild-User(master): Volker Lendecke <v...@samba.org> Autobuild-Date(master): Tue Nov 29 11:23:58 UTC 2022 on sn-devel-184 commit bbc82a5d425ad51a269e1ab8e4db859943fcc4ff Author: David Mulder <dmul...@samba.org> Date: Thu Nov 3 10:28:58 2022 -0600 s3: Test that store_smb2_posix_info hides info for '..' Signed-off-by: David Mulder <dmul...@samba.org> Reviewed-by: Volker Lendecke <v...@samba.org> commit d0ad452fc81f65017d1f783e98a58117278d8289 Author: David Mulder <dmul...@samba.org> Date: Tue Oct 18 07:37:47 2022 -0600 s3: smbd: store_smb2_posix_info hide info for '..' When receiving a query for '..', hide the owner and group sids, the inode, and the dev id. Signed-off-by: David Mulder <dmul...@samba.org> Reviewed-by: Volker Lendecke <v...@samba.org> commit bdb98c8397462805b4cdfaedeee24c5d2b294b86 Author: David Mulder <dmul...@samba.org> Date: Mon Sep 12 16:09:50 2022 -0700 smbd: Implement SMB2_FS_POSIX_INFORMATION_INTERNAL Signed-off-by: David Mulder <dmul...@samba.org> Reviewed-by: Volker Lendecke <v...@samba.org> commit a73d903238807f0e53c70dc2ecb017093206b7e8 Author: David Mulder <dmul...@suse.com> Date: Fri Aug 5 14:00:30 2022 -0600 tests/s3: Test file/dir permissions with SMB3 posix Signed-off-by: David Mulder <dmul...@suse.com> Reviewed-by: Volker Lendecke <v...@samba.org> commit 09c8426b95a0f95e10e1c22a1f0a285ce81fb19f Author: David Mulder <dmul...@suse.com> Date: Fri Aug 5 13:05:48 2022 -0600 tests/s3: Test case sensitive open with SMB3 posix Disabled because we don't handle posix paths correctly yet. Signed-off-by: David Mulder <dmul...@suse.com> Reviewed-by: Volker Lendecke <v...@samba.org> commit 160173ee0641c871981868ee100d84b4046710a6 Author: David Mulder <dmul...@suse.com> Date: Fri Aug 5 10:56:32 2022 -0600 tests/s3: Test delete on close with SMB3 posix Signed-off-by: David Mulder <dmul...@suse.com> Reviewed-by: Volker Lendecke <v...@samba.org> commit f481cd4a60a55a30e78fe6da4aa5f5fe90fa433e Author: David Mulder <dmul...@suse.com> Date: Fri Jul 8 13:15:51 2022 -0600 libcli: Add client support for SMB2_FILE_POSIX_INFORMATION Signed-off-by: David Mulder <dmul...@suse.com> Reviewed-by: Volker Lendecke <v...@samba.org> commit f0e1137425f5ed1ff97c729e4b39be626602e6b7 Author: David Mulder <dmul...@suse.com> Date: Thu Jul 7 12:57:01 2022 -0600 tests/s3: Test reserved chars in posix filename Disabled because we don't handle posix paths correctly yet. Signed-off-by: David Mulder <dmul...@suse.com> Reviewed-by: Volker Lendecke <v...@samba.org> commit 08226d6c2e8ed1e1d8104afcfcea37a66de0a413 Author: David Mulder <dmul...@suse.com> Date: Fri Jun 17 15:06:29 2022 -0600 smbd: Implement SMB2_FILE_POSIX_INFORMATION in smbd_marshall_dir_entry Signed-off-by: David Mulder <dmul...@suse.com> Reviewed-by: Volker Lendecke <v...@samba.org> commit 7c2f08d564f74d8259d0ad8c3b25923eb3e5ece4 Author: David Mulder <dmul...@suse.com> Date: Wed Jun 15 15:39:00 2022 -0600 tests/s3: Test SMB2_FIND_POSIX_INFORMATION dir query Signed-off-by: David Mulder <dmul...@suse.com> Reviewed-by: Volker Lendecke <v...@samba.org> commit 284787996d45ee8e5848a5071b42f114c791a56a Author: David Mulder <dmul...@samba.org> Date: Tue Sep 20 10:28:20 2022 -0600 libsmb: Allow listing with posix context Signed-off-by: David Mulder <dmul...@samba.org> Reviewed-by: Volker Lendecke <v...@samba.org> commit 99de8d7cfa390a06a0a7e5ac14843a3bea3c9365 Author: David Mulder <dmul...@suse.com> Date: Wed Jun 15 13:20:30 2022 -0600 libsmb: Make info_level configurable in dir listing This was hard coded to SMB2_FIND_ID_BOTH_DIRECTORY_INFO Signed-off-by: David Mulder <dmul...@suse.com> Reviewed-by: Volker Lendecke <v...@samba.org> commit 2c1a02d622c710bb77d2142c9cdf09b921ddb888 Author: Jeremy Allison <j...@samba.org> Date: Mon Dec 18 13:27:06 2017 -0800 smbd: Plumb SMB2_FIND_POSIX_INFORMATION through the directory reading code. Signed-off-by: Jeremy Allison <j...@samba.org> Reviewed-by: Volker Lendecke <v...@samba.org> commit 72004f8f94824e00ed120d87893ec57c96c5f8f2 Author: Jeremy Allison <j...@samba.org> Date: Thu Dec 14 15:18:21 2017 -0800 s3: smbd: Add SMB2_FILE_POSIX_INFORMATION getinfo info level (100 on the wire). Signed-off-by: Jeremy Allison <j...@samba.org> Reviewed-by: Volker Lendecke <v...@samba.org> ----------------------------------------------------------------------- Summary of changes: libcli/smb/smb_unix_ext.h | 6 +- python/samba/tests/smb3unix.py | 216 ++++++++++++++++++++++++++++++++++++ selftest/knownfail.d/smb3unix | 2 + selftest/target/Samba3.pm | 8 ++ source3/include/client.h | 7 ++ source3/include/trans2.h | 1 + source3/libsmb/cli_smb2_fnum.c | 156 ++++++++++++++++++++++++-- source3/libsmb/cli_smb2_fnum.h | 4 +- source3/libsmb/clilist.c | 17 ++- source3/libsmb/proto.h | 3 +- source3/libsmb/pylibsmb.c | 85 +++++++++++++- source3/smbd/dir.c | 7 ++ source3/smbd/smb2_getinfo.c | 8 ++ source3/smbd/smb2_posix.c | 13 ++- source3/smbd/smb2_query_directory.c | 7 ++ source3/smbd/smb2_trans2.c | 151 ++++++++++++++++++++++++- 16 files changed, 660 insertions(+), 31 deletions(-) create mode 100644 selftest/knownfail.d/smb3unix Changeset truncated at 500 lines: diff --git a/libcli/smb/smb_unix_ext.h b/libcli/smb/smb_unix_ext.h index 6d5b76da613..2f2357d8acf 100644 --- a/libcli/smb/smb_unix_ext.h +++ b/libcli/smb/smb_unix_ext.h @@ -33,8 +33,6 @@ #define MIN_UNIX_INFO_LEVEL 0x200 #define MAX_UNIX_INFO_LEVEL 0x2FF -#define INFO_LEVEL_IS_UNIX(level) (((level) >= MIN_UNIX_INFO_LEVEL) && ((level) <= MAX_UNIX_INFO_LEVEL)) - #define SMB_QUERY_FILE_UNIX_BASIC 0x200 /* UNIX File Info*/ #define SMB_SET_FILE_UNIX_BASIC 0x200 #define SMB_SET_FILE_UNIX_INFO2 0x20B /* UNIX File Info2 */ @@ -453,4 +451,8 @@ enum smb_whoami_flags { #define SMB_POSIX_UNLINK_FILE_TARGET 0 #define SMB_POSIX_UNLINK_DIRECTORY_TARGET 1 +#define INFO_LEVEL_IS_UNIX(level) ((((level) >= MIN_UNIX_INFO_LEVEL) && \ + ((level) <= MAX_UNIX_INFO_LEVEL)) || \ + ((level) == SMB2_FILE_POSIX_INFORMATION_INTERNAL)) + #endif /* __SMB_UNIX_EXT_H__ */ diff --git a/python/samba/tests/smb3unix.py b/python/samba/tests/smb3unix.py index 514c245515f..3ad49af09fa 100644 --- a/python/samba/tests/smb3unix.py +++ b/python/samba/tests/smb3unix.py @@ -18,6 +18,11 @@ from samba.samba3 import libsmb_samba_internal as libsmb from samba import NTSTATUSError,ntstatus import samba.tests.libsmb +from samba.dcerpc import security +from samba.common import get_string + +def posix_context(mode): + return (libsmb.SMB2_CREATE_TAG_POSIX, mode.to_bytes(4, 'little')) class Smb3UnixTests(samba.tests.libsmb.LibsmbTests): @@ -144,3 +149,214 @@ class Smb3UnixTests(samba.tests.libsmb.LibsmbTests): finally: self.disable_smb3unix() + + def delete_test_file(self, c, fname, mode=0): + f,_,cc_out = c.create_ex(fname, + DesiredAccess=security.SEC_STD_ALL, + CreateDisposition=libsmb.FILE_OPEN, + CreateContexts=[posix_context(mode)]) + c.delete_on_close(f, True) + c.close(f) + + def test_posix_query_dir(self): + test_files = [] + try: + self.enable_smb3unix() + + c = libsmb.Conn( + self.server_ip, + "smb3_posix_share", + self.lp, + self.creds, + posix=True) + self.assertTrue(c.have_posix()) + + for i in range(10): + fname = '\\test%d' % i + f,_,cc_out = c.create_ex(fname, + CreateDisposition=libsmb.FILE_OPEN_IF, + CreateContexts=[posix_context(0o744)]) + c.close(f) + test_files.append(fname) + + expected_count = len(c.list('')) + self.assertNotEqual(expected_count, 0, 'No files were found') + + actual_count = len(c.list('', + info_level=libsmb.SMB2_FIND_POSIX_INFORMATION, + posix=True)) + self.assertEqual(actual_count-2, expected_count, + 'SMB2_FIND_POSIX_INFORMATION failed to list contents') + + finally: + for fname in test_files: + self.delete_test_file(c, fname) + + self.disable_smb3unix() + + def test_posix_reserved_char(self): + try: + self.enable_smb3unix() + + c = libsmb.Conn( + self.server_ip, + "smb3_posix_share", + self.lp, + self.creds, + posix=True) + self.assertTrue(c.have_posix()) + + test_files = ['a ', 'a ', '. ', '. ', 'a.', + '.a', ' \\ ', '>', '<' '?'] + + for fname in test_files: + try: + f,_,cc_out = c.create_ex('\\%s' % fname, + CreateDisposition=libsmb.FILE_CREATE, + DesiredAccess=security.SEC_STD_DELETE, + CreateContexts=[posix_context(0o744)]) + except NTSTATUSError as e: + self.fail(e) + c.delete_on_close(f, True) + c.close(f) + + finally: + self.disable_smb3unix() + + def test_posix_delete_on_close(self): + try: + self.enable_smb3unix() + + c = libsmb.Conn( + self.server_ip, + "smb3_posix_share", + self.lp, + self.creds, + posix=True) + self.assertTrue(c.have_posix()) + + f,_,cc_out = c.create_ex('\\TESTING999', + DesiredAccess=security.SEC_STD_ALL, + CreateDisposition=libsmb.FILE_CREATE, + CreateContexts=[posix_context(0o744)]) + c.delete_on_close(f, True) + c.close(f) + + finally: + self.disable_smb3unix() + + def test_posix_case_sensitive(self): + try: + self.enable_smb3unix() + + c = libsmb.Conn( + self.server_ip, + "smb3_posix_share", + self.lp, + self.creds, + posix=True) + self.assertTrue(c.have_posix()) + + f,_,cc_out = c.create_ex('\\xx', + DesiredAccess=security.SEC_STD_ALL, + CreateDisposition=libsmb.FILE_CREATE, + CreateContexts=[posix_context(0o644)]) + c.close(f) + + fail = False + try: + f,_,cc_out = c.create_ex('\\XX', + DesiredAccess=security.SEC_STD_ALL, + CreateDisposition=libsmb.FILE_OPEN, + CreateContexts=[posix_context(0)]) + except NTSTATUSError: + pass + else: + fail = True + c.close(f) + + self.assertFalse(fail, "Opening uppercase file didn't fail") + + finally: + self.delete_test_file(c, '\\xx') + + self.disable_smb3unix() + + def test_posix_perm_files(self): + try: + self.enable_smb3unix() + + c = libsmb.Conn( + self.server_ip, + "smb3_posix_share", + self.lp, + self.creds, + posix=True) + self.assertTrue(c.have_posix()) + + test_files = {} + for perm in range(0o600, 0o7777+1): + # Owner write permission is required or cleanup will fail, and + # owner read is required to list the file if O_PATH is disabled + if perm & 0o600 != 0o600: + continue + + # Don't create with setuid or setgid. + if perm & 0o6000 != 0: + continue + + fname = 'testfile%04o' % perm + test_files[fname] = perm + f,_,cc_out = c.create_ex('\\%s' % fname, + DesiredAccess=security.SEC_STD_ALL, + CreateDisposition=libsmb.FILE_CREATE, + CreateContexts=[posix_context(perm)]) + c.close(f) + + dname = 'testdir%04o' % perm + test_files[dname] = perm + f,_,cc_out = c.create_ex('\\%s' % dname, + DesiredAccess=security.SEC_STD_ALL, + CreateDisposition=libsmb.FILE_CREATE, + CreateOptions=libsmb.FILE_DIRECTORY_FILE, + CreateContexts=[posix_context(perm)]) + c.close(f) + + res = c.list("", info_level=100, posix=True) + found_files = {get_string(i['name']): i['perms'] 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], + 'Requested %04o, Received %04o' % \ + (test_files[fname], found_files[fname])) + + finally: + for fname in test_files.keys(): + self.delete_test_file(c, '\\%s' % fname) + + self.disable_smb3unix() + + def test_share_root_null_sids_fid(self): + try: + self.enable_smb3unix() + + c = libsmb.Conn( + self.server_ip, + "smb3_posix_share", + self.lp, + self.creds, + posix=True) + self.assertTrue(c.have_posix()) + + res = c.list("", info_level=100, posix=True) + found_files = {get_string(i['name']): i for i in res} + dotdot = found_files['..'] + self.assertEqual('S-1-0-0', dotdot['owner_sid'], + 'The owner sid for .. was not NULL') + self.assertEqual('S-1-0-0', dotdot['group_sid'], + 'The group sid for .. was not NULL') + self.assertEqual(0, dotdot['ino'], 'The ino for .. was not 0') + self.assertEqual(0, dotdot['dev'], 'The dev for .. was not 0') + finally: + self.disable_smb3unix() diff --git a/selftest/knownfail.d/smb3unix b/selftest/knownfail.d/smb3unix new file mode 100644 index 00000000000..2ab886ae75e --- /dev/null +++ b/selftest/knownfail.d/smb3unix @@ -0,0 +1,2 @@ +^samba.tests.smb3unix.samba.tests.smb3unix.Smb3UnixTests.test_posix_reserved_char\(fileserver\) +^samba.tests.smb3unix.samba.tests.smb3unix.Smb3UnixTests.test_posix_case_sensitive\(fileserver\) diff --git a/selftest/target/Samba3.pm b/selftest/target/Samba3.pm index a2808ffbce8..3ec0776e654 100755 --- a/selftest/target/Samba3.pm +++ b/selftest/target/Samba3.pm @@ -3078,6 +3078,14 @@ sub provision($$) directory mask = 0777 force directory mode = 0 vfs objects = xattr_tdb streams_depot +[smb3_posix_share] + vfs objects = fake_acls xattr_tdb streams_depot time_audit full_audit + create mask = 07777 + directory mask = 07777 + mangled names = no + path = $shrdir + read only = no + guest ok = yes [aio] copy = durable aio read size = 1 diff --git a/source3/include/client.h b/source3/include/client.h index 4939e1879cf..5ac9d649142 100644 --- a/source3/include/client.h +++ b/source3/include/client.h @@ -108,6 +108,13 @@ struct file_info { struct timespec ctime_ts; char *name; char *short_name; + uint32_t mode; + uint32_t reparse_tag; + dev_t st_ex_dev; + mode_t st_ex_mode; + nlink_t st_ex_nlink; + struct dom_sid owner_sid; + struct dom_sid group_sid; }; #define CLI_FULL_CONNECTION_DONT_SPNEGO 0x0001 diff --git a/source3/include/trans2.h b/source3/include/trans2.h index dfc59800846..3ed42a3f0b9 100644 --- a/source3/include/trans2.h +++ b/source3/include/trans2.h @@ -412,6 +412,7 @@ Byte offset Type name description #define SMB2_FILE_FULL_EA_INFORMATION (FSCC_FILE_FULL_EA_INFORMATION + SMB2_INFO_SPECIAL) #define SMB2_FILE_ALL_INFORMATION (FSCC_FILE_ALL_INFORMATION + SMB2_INFO_SPECIAL) #define SMB2_FILE_POSIX_INFORMATION_INTERNAL (SMB2_FILE_POSIX_INFORMATION + SMB2_INFO_SPECIAL) +#define SMB2_FS_POSIX_INFORMATION_INTERNAL 1100 /* NT passthrough levels for qfsinfo. */ diff --git a/source3/libsmb/cli_smb2_fnum.c b/source3/libsmb/cli_smb2_fnum.c index a0323d701c3..5cf6f5baf7b 100644 --- a/source3/libsmb/cli_smb2_fnum.c +++ b/source3/libsmb/cli_smb2_fnum.c @@ -1187,6 +1187,109 @@ NTSTATUS cli_smb2_unlink_recv(struct tevent_req *req) return tevent_req_simple_recv_ntstatus(req); } +static ssize_t sid_parse_wire(TALLOC_CTX *mem_ctx, const uint8_t *data, + struct dom_sid *sid, size_t num_rdata) +{ + size_t sid_size; + enum ndr_err_code ndr_err; + DATA_BLOB in = data_blob_const(data, num_rdata); + + ndr_err = ndr_pull_struct_blob(&in, + mem_ctx, + sid, + (ndr_pull_flags_fn_t)ndr_pull_dom_sid); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + return 0; + } + + sid_size = ndr_size_dom_sid(sid, 0); + if (sid_size > num_rdata) { + return 0; + } + + return sid_size; +} + +/*************************************************************** + Utility function to parse a SMB2_FIND_POSIX_INFORMATION reply. +***************************************************************/ + +static NTSTATUS parse_finfo_posix_info(const uint8_t *dir_data, + uint32_t dir_data_length, + struct file_info *finfo, + uint32_t *next_offset) +{ + size_t namelen = 0; + size_t slen = 0, slen2 = 0; + size_t ret = 0; + uint32_t _next_offset = 0; + + if (dir_data_length < 4) { + return NT_STATUS_INFO_LENGTH_MISMATCH; + } + + _next_offset = IVAL(dir_data, 0); + + if (_next_offset > dir_data_length) { + return NT_STATUS_INFO_LENGTH_MISMATCH; + } + + if (_next_offset != 0) { + /* Ensure we only read what in this record. */ + dir_data_length = _next_offset; + } + + if (dir_data_length < 92) { + return NT_STATUS_INFO_LENGTH_MISMATCH; + } + + finfo->btime_ts = interpret_long_date((const char *)dir_data + 8); + finfo->atime_ts = interpret_long_date((const char *)dir_data + 16); + finfo->mtime_ts = interpret_long_date((const char *)dir_data + 24); + finfo->ctime_ts = interpret_long_date((const char *)dir_data + 32); + finfo->allocated_size = PULL_LE_U64(dir_data, 40); + finfo->size = PULL_LE_U64(dir_data, 48); + finfo->mode = PULL_LE_U32(dir_data, 56); + finfo->ino = PULL_LE_U64(dir_data, 60); + finfo->st_ex_dev = PULL_LE_U32(dir_data, 68); + finfo->st_ex_nlink = PULL_LE_U32(dir_data, 76); + finfo->reparse_tag = PULL_LE_U32(dir_data, 80); + finfo->st_ex_mode = wire_perms_to_unix(PULL_LE_U32(dir_data, 84)); + + slen = sid_parse_wire(finfo, dir_data+88, &finfo->owner_sid, + dir_data_length-88); + if (slen == 0) { + return NT_STATUS_INVALID_NETWORK_RESPONSE; + } + slen2 = sid_parse_wire(finfo, dir_data+88+slen, &finfo->group_sid, + dir_data_length-88-slen); + if (slen2 == 0) { + return NT_STATUS_INVALID_NETWORK_RESPONSE; + } + slen += slen2; + + namelen = PULL_LE_U32(dir_data, 88+slen); + ret = pull_string_talloc(finfo, + dir_data, + FLAGS2_UNICODE_STRINGS, + &finfo->name, + dir_data+92+slen, + namelen, + STR_UNICODE); + if (ret == (size_t)-1) { + /* Bad conversion. */ + return NT_STATUS_INVALID_NETWORK_RESPONSE; + } + + if (finfo->name == NULL) { + /* Bad conversion. */ + return NT_STATUS_INVALID_NETWORK_RESPONSE; + } + + *next_offset = _next_offset; + return NT_STATUS_OK; +} + /*************************************************************** Utility function to parse a SMB2_FIND_ID_BOTH_DIRECTORY_INFO reply. ***************************************************************/ @@ -1319,6 +1422,7 @@ struct cli_smb2_list_state { NTSTATUS status; struct cli_smb2_list_dir_data *response; uint32_t offset; + unsigned int info_level; }; static void cli_smb2_list_opened(struct tevent_req *subreq); @@ -1329,12 +1433,15 @@ struct tevent_req *cli_smb2_list_send( TALLOC_CTX *mem_ctx, struct tevent_context *ev, struct cli_state *cli, - const char *pathname) + const char *pathname, + unsigned int info_level, + bool posix) { struct tevent_req *req = NULL, *subreq = NULL; struct cli_smb2_list_state *state = NULL; char *parent = NULL; bool ok; + struct smb2_create_blobs *in_cblobs = NULL; req = tevent_req_create(mem_ctx, &state, struct cli_smb2_list_state); if (req == NULL) { @@ -1343,6 +1450,7 @@ struct tevent_req *cli_smb2_list_send( state->ev = ev; state->cli = cli; state->status = NT_STATUS_OK; + state->info_level = info_level; ok = windows_parent_dirname(state, pathname, &parent, &state->mask); if (!ok) { @@ -1350,6 +1458,29 @@ struct tevent_req *cli_smb2_list_send( return tevent_req_post(req, ev); } + if (smbXcli_conn_have_posix(cli->conn) && posix) { + NTSTATUS status; + + /* The mode MUST be 0 when opening an existing file/dir, and + * will be ignored by the server. + */ + uint8_t linear_mode[4] = { 0 }; + DATA_BLOB blob = { .data=linear_mode, + .length=sizeof(linear_mode) }; + + in_cblobs = talloc_zero(mem_ctx, struct smb2_create_blobs); + if (in_cblobs == NULL) { + return NULL; + } + + status = smb2_create_blob_add(in_cblobs, in_cblobs, + SMB2_CREATE_TAG_POSIX, blob); + if (!NT_STATUS_IS_OK(status)) { + tevent_req_nterror(req, status); + return tevent_req_post(req, ev); + } + } + subreq = cli_smb2_create_fnum_send( state, /* mem_ctx */ ev, /* ev */ @@ -1362,7 +1493,8 @@ struct tevent_req *cli_smb2_list_send( FILE_SHARE_READ|FILE_SHARE_WRITE, /* share_access */ FILE_OPEN, /* create_disposition */ FILE_DIRECTORY_FILE, /* create_options */ - NULL); /* in_cblobs */ + in_cblobs); /* in_cblobs */ + TALLOC_FREE(in_cblobs); if (tevent_req_nomem(subreq, req)) { return tevent_req_post(req, ev); } @@ -1499,7 +1631,7 @@ NTSTATUS cli_smb2_list_recv( cli->timeout, /* timeout_msec */ cli->smb2.session, /* session */ -- Samba Shared Repository