[SCM] Samba Shared Repository - branch master updated
Jeremy Allison
jra at samba.org
Wed Oct 4 21:27:02 UTC 2023
The branch, master has been updated
via cb89ea70b1f libsmb: Use pidl generated parsing for posix file info
via cb166028c49 libsmb: Pass NTTIME to interpret_long_date()
via 82a12f7a9a6 libndr: Factor out ndr_pull_struct_blob_noalloc()
via 7b865702164 smbd: Remove unused marshalling of smb3posix file information
via 2d6c643ebdd smbd: Use Use smb3posix marshalling in in smbd_do_qfilepathinfo()
via b573e1da921 smbd: Use Use smb3posix marshalling in in smbd_marshall_dir_entry()
via a8593ad376f smbd: Modernize a DEBUG statement
via 36fd98a5ef5 smbd: Add smb3_file_posix_information_init()
via 6874ed6a9de smbd: Use smb3posix marshalling in smbd_smb2_create_after_exec()
via 8107aafb40c idl: Add smb3posix.idl
via 6f91cce14e4 libsmb: Allow NULL print_name in reparse_data_buffer_marshall()
via 7f1ee32a1b9 pylibsmb: Py_BuildValue can build tuples directly
via 078db302a65 tests: Run smb3unix tests with SMB1
via 52c3edb2820 tests: We always do smb3 unix extensions
from 3ee348a9663 ctdb-scripts: Convert 40.vsftpd to use threshold-based fail counting
https://git.samba.org/?p=samba.git;a=shortlog;h=master
- Log -----------------------------------------------------------------
commit cb89ea70b1f91d3dd286f49fcbac0b6b70add5f0
Author: Volker Lendecke <vl at samba.org>
Date: Wed Oct 4 16:33:01 2023 +0200
libsmb: Use pidl generated parsing for posix file info
Signed-off-by: Volker Lendecke <vl at samba.org>
Reviewed-by: Jeremy Allison <jra at samba.org>
Autobuild-User(master): Jeremy Allison <jra at samba.org>
Autobuild-Date(master): Wed Oct 4 21:26:20 UTC 2023 on atb-devel-224
commit cb166028c49d407429adf256ef9f5d53e3bb1fdd
Author: Volker Lendecke <vl at samba.org>
Date: Wed Oct 4 13:25:21 2023 +0200
libsmb: Pass NTTIME to interpret_long_date()
Separate concerns of conversion and pulling off the wire. Needed soon
for smb311 pidl generated parsing.
Signed-off-by: Volker Lendecke <vl at samba.org>
Reviewed-by: Jeremy Allison <jra at samba.org>
commit 82a12f7a9a62f2c879a49291294fc6145e54ebea
Author: Volker Lendecke <vl at samba.org>
Date: Tue Oct 3 11:39:36 2023 +0200
libndr: Factor out ndr_pull_struct_blob_noalloc()
smb3_file_posix_information is variable length with something behind.
Signed-off-by: Volker Lendecke <vl at samba.org>
Reviewed-by: Jeremy Allison <jra at samba.org>
commit 7b8657021646e940e3e2b7be3adaf939fd3c3ba5
Author: Volker Lendecke <vl at samba.org>
Date: Wed Sep 27 10:54:26 2023 +0200
smbd: Remove unused marshalling of smb3posix file information
Signed-off-by: Volker Lendecke <vl at samba.org>
Reviewed-by: Jeremy Allison <jra at samba.org>
commit 2d6c643ebddda0f5472fa83127a6a7a28ad37728
Author: Volker Lendecke <vl at samba.org>
Date: Wed Sep 27 10:51:37 2023 +0200
smbd: Use Use smb3posix marshalling in in smbd_do_qfilepathinfo()
Signed-off-by: Volker Lendecke <vl at samba.org>
Reviewed-by: Jeremy Allison <jra at samba.org>
commit b573e1da921f072f27a95912cbd99050f9709078
Author: Volker Lendecke <vl at samba.org>
Date: Wed Sep 27 10:48:35 2023 +0200
smbd: Use Use smb3posix marshalling in in smbd_marshall_dir_entry()
Signed-off-by: Volker Lendecke <vl at samba.org>
Reviewed-by: Jeremy Allison <jra at samba.org>
commit a8593ad376f8809ff8c358130249af935ed590fc
Author: Volker Lendecke <vl at samba.org>
Date: Wed Sep 27 17:43:33 2023 +0200
smbd: Modernize a DEBUG statement
Signed-off-by: Volker Lendecke <vl at samba.org>
Reviewed-by: Jeremy Allison <jra at samba.org>
commit 36fd98a5ef527347ed2c7b766383418920fe498e
Author: Volker Lendecke <vl at samba.org>
Date: Wed Sep 27 10:44:30 2023 +0200
smbd: Add smb3_file_posix_information_init()
Copy the logic from store_smb2_posix_info() to allow use of
ndr_push_smb3_file_posix_information().
Signed-off-by: Volker Lendecke <vl at samba.org>
Reviewed-by: Jeremy Allison <jra at samba.org>
commit 6874ed6a9defdf6f842e1e25f1ffd95708534ca6
Author: Volker Lendecke <vl at samba.org>
Date: Wed Sep 27 09:22:53 2023 +0200
smbd: Use smb3posix marshalling in smbd_smb2_create_after_exec()
Signed-off-by: Volker Lendecke <vl at samba.org>
commit 8107aafb40c22cacf56b69129e7c8611fd35184a
Author: Volker Lendecke <vl at samba.org>
Date: Wed Sep 27 06:44:41 2023 +0200
idl: Add smb3posix.idl
Let PIDL take care of encoding SMB2_FILE_POSIX_INFORMATION. This way
we also get parsing.
Signed-off-by: Volker Lendecke <vl at samba.org>
Reviewed-by: Jeremy Allison <jra at samba.org>
commit 6f91cce14e490963ed699629beae136b9fe25656
Author: Volker Lendecke <vl at samba.org>
Date: Tue Sep 26 14:54:37 2023 +0200
libsmb: Allow NULL print_name in reparse_data_buffer_marshall()
read_symlink_reparse() does this.
Signed-off-by: Volker Lendecke <vl at samba.org>
Reviewed-by: Jeremy Allison <jra at samba.org>
commit 7f1ee32a1b91addd84784954e3150afc2b3ae2bc
Author: Volker Lendecke <vl at samba.org>
Date: Tue Sep 26 14:16:08 2023 +0200
pylibsmb: Py_BuildValue can build tuples directly
Signed-off-by: Volker Lendecke <vl at samba.org>
Reviewed-by: Jeremy Allison <jra at samba.org>
commit 078db302a65fffd76722728969e5fcbd393eef02
Author: Volker Lendecke <vl at samba.org>
Date: Tue Sep 26 12:01:17 2023 +0200
tests: Run smb3unix tests with SMB1
We want to create native FIFOs with smb1 extensions
Signed-off-by: Volker Lendecke <vl at samba.org>
Reviewed-by: Jeremy Allison <jra at samba.org>
commit 52c3edb28203bd29f529b31b57bdbc81fd5d009c
Author: Volker Lendecke <vl at samba.org>
Date: Tue Sep 26 11:57:47 2023 +0200
tests: We always do smb3 unix extensions
Signed-off-by: Volker Lendecke <vl at samba.org>
Reviewed-by: Jeremy Allison <jra at samba.org>
-----------------------------------------------------------------------
Summary of changes:
examples/fuse/clifuse.c | 16 +--
libcli/smb/reparse.c | 7 +-
librpc/ABI/{ndr-3.0.1.sigs => ndr-3.0.2.sigs} | 1 +
librpc/idl/smb3posix.idl | 36 ++++++
librpc/idl/wscript_build | 1 +
librpc/ndr/libndr.h | 5 +
librpc/ndr/ndr.c | 70 +++++++----
librpc/wscript_build | 8 +-
source3/include/proto.h | 2 +-
source3/lib/time.c | 4 +-
source3/libsmb/cli_smb2_fnum.c | 119 +++++++++---------
source3/libsmb/clifile.c | 6 +-
source3/libsmb/clifsinfo.c | 2 +-
source3/libsmb/clilist.c | 6 +-
source3/libsmb/clirap.c | 44 +++----
source3/libsmb/pylibsmb.c | 24 +---
source3/selftest/tests.py | 5 +-
source3/smbd/proto.h | 17 +--
source3/smbd/smb2_create.c | 61 ++++-----
source3/smbd/smb2_posix.c | 172 +++++---------------------
source3/smbd/smb2_trans2.c | 89 ++++++-------
source3/torture/test_smb1_dfs.c | 6 +-
source3/wscript | 5 -
source4/librpc/wscript_build | 7 ++
24 files changed, 315 insertions(+), 398 deletions(-)
copy librpc/ABI/{ndr-3.0.1.sigs => ndr-3.0.2.sigs} (99%)
create mode 100644 librpc/idl/smb3posix.idl
Changeset truncated at 500 lines:
diff --git a/examples/fuse/clifuse.c b/examples/fuse/clifuse.c
index 533fe14c2d4..28c5177b250 100644
--- a/examples/fuse/clifuse.c
+++ b/examples/fuse/clifuse.c
@@ -327,10 +327,10 @@ static void cli_get_unixattr_gotinfo(struct tevent_req *subreq)
return;
}
- state->create_time = interpret_long_date((char *)outbuf.data + 0x0);
- state->access_time = interpret_long_date((char *)outbuf.data + 0x8);
- state->write_time = interpret_long_date((char *)outbuf.data + 0x10);
- state->change_time = interpret_long_date((char *)outbuf.data + 0x18);
+ state->create_time = interpret_long_date(BVAL(outbuf.data, 0));
+ state->access_time = interpret_long_date(BVAL(outbuf.data, 0x8));
+ state->write_time = interpret_long_date(BVAL(outbuf.data, 0x10));
+ state->change_time = interpret_long_date(BVAL(outbuf.data, 0x18));
state->mode = IVAL(outbuf.data, 0x20);
state->size = BVAL(outbuf.data, 0x30);
state->ino = BVAL(outbuf.data, 0x40);
@@ -502,10 +502,10 @@ static NTSTATUS parse_finfo_id_both_directory_info(uint8_t *dir_data,
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->btime_ts = interpret_long_date(BVAL(dir_data, 8));
+ finfo->atime_ts = interpret_long_date(BVAL(dir_data, 16));
+ finfo->mtime_ts = interpret_long_date(BVAL(dir_data, 24));
+ finfo->ctime_ts = interpret_long_date(BVAL(dir_data, 32));
finfo->size = IVAL2_TO_SMB_BIG_UINT(dir_data + 40, 0);
finfo->attr = IVAL(dir_data + 56, 0);
namelen = IVAL(dir_data + 60,0);
diff --git a/libcli/smb/reparse.c b/libcli/smb/reparse.c
index 1a6feff17e1..49ecc77725d 100644
--- a/libcli/smb/reparse.c
+++ b/libcli/smb/reparse.c
@@ -388,6 +388,7 @@ reparse_data_buffer_marshall_syml(const struct symlink_reparse_struct *src,
{
uint8_t sbuf[12];
struct iovec iov[3];
+ const char *print_name = src->print_name;
uint8_t *subst_utf16 = NULL;
uint8_t *print_utf16 = NULL;
size_t subst_len = 0;
@@ -399,7 +400,7 @@ reparse_data_buffer_marshall_syml(const struct symlink_reparse_struct *src,
return -1;
}
if (src->print_name == NULL) {
- return -1;
+ print_name = src->substitute_name;
}
iov[0] = (struct iovec){
@@ -428,8 +429,8 @@ reparse_data_buffer_marshall_syml(const struct symlink_reparse_struct *src,
ok = convert_string_talloc(talloc_tos(),
CH_UNIX,
CH_UTF16,
- src->print_name,
- strlen(src->print_name),
+ print_name,
+ strlen(print_name),
&print_utf16,
&print_len);
if (!ok) {
diff --git a/librpc/ABI/ndr-3.0.1.sigs b/librpc/ABI/ndr-3.0.2.sigs
similarity index 99%
copy from librpc/ABI/ndr-3.0.1.sigs
copy to librpc/ABI/ndr-3.0.2.sigs
index 54aab1d56d4..2f9b4b80c84 100644
--- a/librpc/ABI/ndr-3.0.1.sigs
+++ b/librpc/ABI/ndr-3.0.2.sigs
@@ -148,6 +148,7 @@ ndr_pull_string_array: enum ndr_err_code (struct ndr_pull *, int, const char ***
ndr_pull_struct_blob: enum ndr_err_code (const DATA_BLOB *, TALLOC_CTX *, void *, ndr_pull_flags_fn_t)
ndr_pull_struct_blob_all: enum ndr_err_code (const DATA_BLOB *, TALLOC_CTX *, void *, ndr_pull_flags_fn_t)
ndr_pull_struct_blob_all_noalloc: enum ndr_err_code (const DATA_BLOB *, void *, ndr_pull_flags_fn_t)
+ndr_pull_struct_blob_noalloc: enum ndr_err_code (const uint8_t *, size_t, void *, ndr_pull_flags_fn_t, size_t *)
ndr_pull_subcontext_end: enum ndr_err_code (struct ndr_pull *, struct ndr_pull *, size_t, ssize_t)
ndr_pull_subcontext_start: enum ndr_err_code (struct ndr_pull *, struct ndr_pull **, size_t, ssize_t)
ndr_pull_svcctl_ServerType: enum ndr_err_code (struct ndr_pull *, int, uint32_t *)
diff --git a/librpc/idl/smb3posix.idl b/librpc/idl/smb3posix.idl
new file mode 100644
index 00000000000..e75922963a2
--- /dev/null
+++ b/librpc/idl/smb3posix.idl
@@ -0,0 +1,36 @@
+#include "idl_types.h"
+
+/*
+ IDL for smb311 unix structures
+*/
+
+import "security.idl";
+
+[
+ version(0.0),
+ pointer_default(unique)
+]
+interface smb3posix
+{
+ typedef [public,flag(NDR_NOALIGN)] struct {
+ uint32 nlinks;
+ uint32 reparse_tag;
+ uint32 posix_perms;
+ dom_sid owner;
+ dom_sid group;
+ } smb3_posix_cc_info;
+
+ typedef [public,flag(NDR_NOALIGN)] struct {
+ NTTIME creation_time;
+ NTTIME last_access_time;
+ NTTIME last_write_time;
+ NTTIME change_time;
+ hyper end_of_file;
+ hyper allocation_size;
+ uint32 file_attributes;
+ hyper inode;
+ uint32 device;
+ uint32 reserved;
+ smb3_posix_cc_info cc;
+ } smb3_file_posix_information;
+}
diff --git a/librpc/idl/wscript_build b/librpc/idl/wscript_build
index 95f1b340fbd..1221ef829b9 100644
--- a/librpc/idl/wscript_build
+++ b/librpc/idl/wscript_build
@@ -141,6 +141,7 @@ bld.SAMBA_PIDL_LIST('PIDL',
server_id.idl
smb_acl.idl
xattr.idl
+ smb3posix.idl
''',
options='--header --ndr-parser --python',
output_dir='../gen_ndr')
diff --git a/librpc/ndr/libndr.h b/librpc/ndr/libndr.h
index e55f7e12687..4d6a078add0 100644
--- a/librpc/ndr/libndr.h
+++ b/librpc/ndr/libndr.h
@@ -716,6 +716,11 @@ enum ndr_err_code ndr_pull_steal_switch_value(struct ndr_pull *ndr,
uint32_t *v);
enum ndr_err_code ndr_pull_struct_blob(const DATA_BLOB *blob, TALLOC_CTX *mem_ctx, void *p, ndr_pull_flags_fn_t fn);
enum ndr_err_code ndr_pull_struct_blob_all(const DATA_BLOB *blob, TALLOC_CTX *mem_ctx, void *p, ndr_pull_flags_fn_t fn);
+_PUBLIC_ enum ndr_err_code ndr_pull_struct_blob_noalloc(const uint8_t *buf,
+ size_t buflen,
+ void *p,
+ ndr_pull_flags_fn_t fn,
+ size_t *consumed);
enum ndr_err_code ndr_pull_struct_blob_all_noalloc(const DATA_BLOB *blob,
void *p, ndr_pull_flags_fn_t fn);
enum ndr_err_code ndr_pull_union_blob(const DATA_BLOB *blob, TALLOC_CTX *mem_ctx, void *p, uint32_t level, ndr_pull_flags_fn_t fn);
diff --git a/librpc/ndr/ndr.c b/librpc/ndr/ndr.c
index 424d7126f89..52f837cbe8b 100644
--- a/librpc/ndr/ndr.c
+++ b/librpc/ndr/ndr.c
@@ -1347,13 +1347,16 @@ _PUBLIC_ enum ndr_err_code ndr_pull_struct_blob_all(const DATA_BLOB *blob, TALLO
}
/*
- pull a struct from a blob using NDR - failing if all bytes are not consumed
-
- This only works for structures with NO allocated memory, like
- objectSID and GUID. This helps because we parse these a lot.
-*/
-_PUBLIC_ enum ndr_err_code ndr_pull_struct_blob_all_noalloc(const DATA_BLOB *blob,
- void *p, ndr_pull_flags_fn_t fn)
+ * pull a struct from a blob using NDR
+ *
+ * This only works for structures with NO allocated memory, like
+ * objectSID and GUID. This helps because we parse these a lot.
+ */
+_PUBLIC_ enum ndr_err_code ndr_pull_struct_blob_noalloc(const uint8_t *buf,
+ size_t buflen,
+ void *p,
+ ndr_pull_flags_fn_t fn,
+ size_t *consumed)
{
/*
* We init this structure on the stack here, to avoid a
@@ -1364,24 +1367,47 @@ _PUBLIC_ enum ndr_err_code ndr_pull_struct_blob_all_noalloc(const DATA_BLOB *blo
* code without the talloc() overhead.
*/
struct ndr_pull ndr = {
- .data = blob->data,
- .data_size = blob->length,
- .current_mem_ctx = (void *)-1
+ .data = discard_const_p(uint8_t, buf),
+ .data_size = buflen,
+ .current_mem_ctx = (void *)-1,
};
- uint32_t highest_ofs;
+
NDR_CHECK(fn(&ndr, NDR_SCALARS|NDR_BUFFERS, p));
- highest_ofs = MAX(ndr.offset, ndr.relative_highest_offset);
- if (highest_ofs < ndr.data_size) {
- enum ndr_err_code ret;
- ret = ndr_pull_error(
- &ndr,
- NDR_ERR_UNREAD_BYTES,
- "not all bytes consumed ofs[%"PRIu32"] "
- "size[%"PRIu32"]",
- highest_ofs,
- ndr.data_size);
- return ret;
+ *consumed = MAX(ndr.offset, ndr.relative_highest_offset);
+
+ return NDR_ERR_SUCCESS;
+}
+
+/*
+ pull a struct from a blob using NDR - failing if all bytes are not consumed
+
+ This only works for structures with NO allocated memory, like
+ objectSID and GUID. This helps because we parse these a lot.
+*/
+_PUBLIC_ enum ndr_err_code
+ndr_pull_struct_blob_all_noalloc(const DATA_BLOB *blob,
+ void *p,
+ ndr_pull_flags_fn_t fn)
+{
+ size_t consumed;
+ enum ndr_err_code ndr_err;
+
+ ndr_err = ndr_pull_struct_blob_noalloc(blob->data,
+ blob->length,
+ p,
+ fn,
+ &consumed);
+ if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
+ return ndr_err;
}
+
+ if (consumed < blob->length) {
+ D_WARNING("not all bytes consumed ofs[%zu] size[%zu]",
+ consumed,
+ blob->length);
+ return NDR_ERR_UNREAD_BYTES;
+ }
+
return NDR_ERR_SUCCESS;
}
diff --git a/librpc/wscript_build b/librpc/wscript_build
index 3ba7ce23082..be1b158d010 100644
--- a/librpc/wscript_build
+++ b/librpc/wscript_build
@@ -387,6 +387,11 @@ bld.SAMBA_SUBSYSTEM('NDR_XATTR',
public_deps='ndr NDR_SECURITY'
)
+bld.SAMBA_SUBSYSTEM('NDR_SMB3POSIX',
+ source='gen_ndr/ndr_smb3posix.c',
+ public_deps='ndr',
+ public_headers='gen_ndr/smb3posix.h')
+
bld.SAMBA_SUBSYSTEM('NDR_SMB2_LEASE_STRUCT',
source='gen_ndr/ndr_smb2_lease_struct.c',
public_deps='ndr',
@@ -606,6 +611,7 @@ bld.SAMBA_LIBRARY('ndr-samba',
deps='''NDR_DRSBLOBS NDR_DRSUAPI NDR_IDMAP NDR_NTLMSSP NDR_NEGOEX NDR_SCHANNEL NDR_MGMT
NDR_DNSSERVER NDR_EPMAPPER NDR_XATTR NDR_UNIXINFO NDR_NAMED_PIPE_AUTH
NDR_NTPRINTING NDR_FSRVP NDR_WITNESS NDR_MDSSVC NDR_OPEN_FILES NDR_SMBXSRV
+ NDR_SMB3POSIX
NDR_KRB5CCACHE''',
private_library=True,
grouping_library=True
@@ -633,7 +639,7 @@ bld.SAMBA_LIBRARY('ndr',
public_deps='samba-errors talloc samba-util util_str_hex',
public_headers='gen_ndr/misc.h gen_ndr/ndr_misc.h ndr/libndr.h:ndr.h',
header_path= [('*gen_ndr*', 'gen_ndr')],
- vnum='3.0.1',
+ vnum='3.0.2',
abi_directory='ABI',
abi_match='!ndr_table_* ndr_* GUID_* _ndr_pull_error* _ndr_push_error*',
)
diff --git a/source3/include/proto.h b/source3/include/proto.h
index 853d4e57e20..8a6b944a0d6 100644
--- a/source3/include/proto.h
+++ b/source3/include/proto.h
@@ -257,7 +257,7 @@ time_t make_unix_date3(const void *date_ptr, int zone_offset);
time_t srv_make_unix_date(const void *date_ptr);
time_t srv_make_unix_date2(const void *date_ptr);
time_t srv_make_unix_date3(const void *date_ptr);
-struct timespec interpret_long_date(const char *p);
+struct timespec interpret_long_date(NTTIME nt);
void TimeInit(void);
void get_process_uptime(struct timeval *ret_time);
void get_startup_time(struct timeval *ret_time);
diff --git a/source3/lib/time.c b/source3/lib/time.c
index 3b96a9d690c..ec93f6c5347 100644
--- a/source3/lib/time.c
+++ b/source3/lib/time.c
@@ -254,10 +254,8 @@ time_t srv_make_unix_date3(const void *date_ptr)
will be returned as (time_t)-1, whereas nt_time_to_unix returns 0 in this case.
****************************************************************************/
-struct timespec interpret_long_date(const char *p)
+struct timespec interpret_long_date(NTTIME nt)
{
- NTTIME nt;
- nt = BVAL(p, 0);
if (nt == (uint64_t)-1) {
struct timespec ret;
ret.tv_sec = (time_t)-1;
diff --git a/source3/libsmb/cli_smb2_fnum.c b/source3/libsmb/cli_smb2_fnum.c
index d5a167f8dd0..42f6d807fc5 100644
--- a/source3/libsmb/cli_smb2_fnum.c
+++ b/source3/libsmb/cli_smb2_fnum.c
@@ -42,6 +42,7 @@
#include "librpc/gen_ndr/ndr_ioctl.h"
#include "ntioctl.h"
#include "librpc/gen_ndr/ndr_quota.h"
+#include "librpc/gen_ndr/ndr_smb3posix.h"
#include "lib/util/string_wrappers.h"
#include "lib/util/idtree.h"
@@ -1174,29 +1175,6 @@ 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.
***************************************************************/
@@ -1206,8 +1184,10 @@ static NTSTATUS parse_finfo_posix_info(const uint8_t *dir_data,
struct file_info *finfo,
uint32_t *next_offset)
{
+ struct smb3_file_posix_information info = {};
+ size_t consumed;
+ enum ndr_err_code ndr_err;
size_t namelen = 0;
- size_t slen = 0, slen2 = 0;
size_t ret = 0;
uint32_t _next_offset = 0;
@@ -1226,43 +1206,64 @@ static NTSTATUS parse_finfo_posix_info(const uint8_t *dir_data,
dir_data_length = _next_offset;
}
- if (dir_data_length < 92) {
+ /*
+ * Skip NextEntryOffset and FileIndex
+ */
+ if (dir_data_length < 8) {
return NT_STATUS_INFO_LENGTH_MISMATCH;
}
+ dir_data += 8;
+ dir_data_length -= 8;
- 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;
+ ndr_err = ndr_pull_struct_blob_noalloc(
+ dir_data,
+ dir_data_length,
+ &info,
+ (ndr_pull_flags_fn_t)ndr_pull_smb3_file_posix_information,
+ &consumed);
+ if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
+ return ndr_map_error2ntstatus(ndr_err);
}
- 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;
+ if (consumed > dir_data_length) {
+ return NT_STATUS_INFO_LENGTH_MISMATCH;
+ }
+ dir_data += consumed;
+ dir_data_length -= consumed;
+
+ finfo->btime_ts = interpret_long_date(info.creation_time);
+ finfo->atime_ts = interpret_long_date(info.last_access_time);
+ finfo->mtime_ts = interpret_long_date(info.last_write_time);
+ finfo->ctime_ts = interpret_long_date(info.change_time);
+ finfo->allocated_size = info.allocation_size;
+ finfo->size = info.end_of_file;
+ finfo->mode = info.file_attributes;
+ finfo->ino = info.inode;
+ finfo->st_ex_dev = info.device;
+ finfo->st_ex_nlink = info.cc.nlinks;
+ finfo->reparse_tag = info.cc.reparse_tag;
+ finfo->st_ex_mode = wire_perms_to_unix(info.cc.posix_perms);
+ sid_copy(&finfo->owner_sid, &info.cc.owner);
+ sid_copy(&finfo->group_sid, &info.cc.group);
+
+ if (dir_data_length < 4) {
+ return NT_STATUS_INFO_LENGTH_MISMATCH;
+ }
+ namelen = PULL_LE_U32(dir_data, 0);
+
+ dir_data += 4;
+ dir_data_length -= 4;
+
+ if (namelen > dir_data_length) {
+ return NT_STATUS_INFO_LENGTH_MISMATCH;
}
- 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);
+ dir_data,
+ FLAGS2_UNICODE_STRINGS,
+ &finfo->name,
+ dir_data,
+ namelen,
+ STR_UNICODE);
if (ret == (size_t)-1) {
/* Bad conversion. */
return NT_STATUS_INVALID_NETWORK_RESPONSE;
@@ -1309,10 +1310,10 @@ static NTSTATUS parse_finfo_id_both_directory_info(const uint8_t *dir_data,
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->btime_ts = interpret_long_date(BVAL(dir_data, 8));
+ finfo->atime_ts = interpret_long_date(BVAL(dir_data, 16));
+ finfo->mtime_ts = interpret_long_date(BVAL(dir_data, 24));
+ finfo->ctime_ts = interpret_long_date(BVAL(dir_data, 32));
finfo->size = IVAL2_TO_SMB_BIG_UINT(dir_data + 40, 0);
finfo->allocated_size = IVAL2_TO_SMB_BIG_UINT(dir_data + 48, 0);
finfo->attr = IVAL(dir_data + 56, 0);
@@ -2887,7 +2888,7 @@ NTSTATUS cli_smb2_get_fs_volume_info(struct cli_state *cli,
if (pdate) {
struct timespec ts;
- ts = interpret_long_date((char *)outbuf.data);
+ ts = interpret_long_date(BVAL(outbuf.data, 0));
*pdate = ts.tv_sec;
}
if (pserial_number) {
diff --git a/source3/libsmb/clifile.c b/source3/libsmb/clifile.c
index b13946d5be8..46b9f27bf4e 100644
--- a/source3/libsmb/clifile.c
+++ b/source3/libsmb/clifile.c
@@ -852,13 +852,13 @@ static void cli_posix_stat_done(struct tevent_req *subreq)
sbuf->st_ex_blocks /= 512;
#endif
/* time of last change */
- sbuf->st_ex_ctime = interpret_long_date((char *)(data + 16));
+ sbuf->st_ex_ctime = interpret_long_date(BVAL(data, 16));
/* time of last access */
- sbuf->st_ex_atime = interpret_long_date((char *)(data + 24));
+ sbuf->st_ex_atime = interpret_long_date(BVAL(data, 24));
/* time of last modification */
- sbuf->st_ex_mtime = interpret_long_date((char *)(data + 32));
+ sbuf->st_ex_mtime = interpret_long_date(BVAL(data, 32));
sbuf->st_ex_uid = (uid_t) IVAL(data, 40); /* user ID of owner */
sbuf->st_ex_gid = (gid_t) IVAL(data, 48); /* group ID of owner */
diff --git a/source3/libsmb/clifsinfo.c b/source3/libsmb/clifsinfo.c
index 50fb6e52c9f..3183e2f4f43 100644
--
Samba Shared Repository
More information about the samba-cvs
mailing list