The branch, master has been updated via b71f729698f smbd: Add reparse tag to smb3_posix_cc_info via ecb17c12c54 smbd: Test reparse tag in smb3_posix_cc_info via d0cdb4160b8 smbd: Use fsctl_get_reparse_tag in fsctl_del_reparse_point via 7b6dc319b53 smbd: Use fsctl_get_reparse_tag in fsctl_set_reparse_point via 3a387673662 smbd: Add fsctl_get_reparse_tag() helper function via 2743127a6e3 smbd: Modernize a few DEBUGs via a85b1e57542 libsmb: Cap max_rdata at UINT16_MAX via 1776918c5bf libsmb: Use the direct FSCC_FILE_ALL_INFORMATION define via 5e0fe4d91ce smbd: Add DEBUG message got get_reparse_point via ee653577630 smbd: Return reparse tag as of MS-FSCC 2.4.6 via d884c2fb0d5 smbd: Fix a DBG via 44b3eadacb3 tests: get TAG_INFORMATION via ba40d97087b pylibsmb: Add py_cli_qfileinfo via c13ac1f1a76 pylibsmb: Add FSCC QUERY_INFO levels via 291a353b16a libsmb: Remove smb2 branch from cli_qfileinfo_basic_send via 893e4f6ebf6 libsmb: Add smb2 branch to cli_qfileinfo via 6e9c18ed821 libsmb: Add a tevent_req_received() where appropriate via bec5920ec91 libsmb: Convert cli_qfileinfo to use FSCC levels via af4bb5f75f7 libsmb: Use SMB2_0_INFO_FILE instead of the raw "1" via 4eac4014c03 libsmb: Use SMB2_0_INFO_SECURITY instead of the raw "3" via 072e4d030ae smbd: Modernize a DEBUG via 7c59f110560 test: Align integer types from 1092d4b0a8e s3:winbindd: Update non cache entries keys (non_centry_keys)
https://git.samba.org/?p=samba.git;a=shortlog;h=master - Log ----------------------------------------------------------------- commit b71f729698fba58543645e9ec40e95d57ea19e3b Author: Volker Lendecke <v...@samba.org> Date: Mon May 13 15:44:52 2024 +0200 smbd: Add reparse tag to smb3_posix_cc_info Signed-off-by: Volker Lendecke <v...@samba.org> Reviewed-by: Jeremy Allison <j...@samba.org> Autobuild-User(master): Jeremy Allison <j...@samba.org> Autobuild-Date(master): Tue May 14 23:29:46 UTC 2024 on atb-devel-224 commit ecb17c12c54214694ecc240ae290646d341cd9a5 Author: Volker Lendecke <v...@samba.org> Date: Mon May 13 15:44:14 2024 +0200 smbd: Test reparse tag in smb3_posix_cc_info Signed-off-by: Volker Lendecke <v...@samba.org> Reviewed-by: Jeremy Allison <j...@samba.org> commit d0cdb4160b84a5f4e9c120c951beb55ac41cf1b3 Author: Volker Lendecke <v...@samba.org> Date: Mon May 13 14:30:30 2024 +0200 smbd: Use fsctl_get_reparse_tag in fsctl_del_reparse_point Signed-off-by: Volker Lendecke <v...@samba.org> Reviewed-by: Jeremy Allison <j...@samba.org> commit 7b6dc319b53ad6df109517ae425d770b62136f7a Author: Volker Lendecke <v...@samba.org> Date: Mon May 13 14:28:55 2024 +0200 smbd: Use fsctl_get_reparse_tag in fsctl_set_reparse_point Signed-off-by: Volker Lendecke <v...@samba.org> Reviewed-by: Jeremy Allison <j...@samba.org> commit 3a3876736627a5c218661ffc6845e96b97322dca Author: Volker Lendecke <v...@samba.org> Date: Mon May 13 14:26:22 2024 +0200 smbd: Add fsctl_get_reparse_tag() helper function There's a few places where we only care about the tag Signed-off-by: Volker Lendecke <v...@samba.org> Reviewed-by: Jeremy Allison <j...@samba.org> commit 2743127a6e3092e292f74e2b851dc41b8b67f825 Author: Volker Lendecke <v...@samba.org> Date: Mon May 13 14:16:48 2024 +0200 smbd: Modernize a few DEBUGs Signed-off-by: Volker Lendecke <v...@samba.org> Reviewed-by: Jeremy Allison <j...@samba.org> commit a85b1e57542831bd26afc985c9add740a063f856 Author: Volker Lendecke <v...@samba.org> Date: Mon May 13 11:16:21 2024 +0200 libsmb: Cap max_rdata at UINT16_MAX The caller does not necessarily query max values for smb1 and smb2+. Signed-off-by: Volker Lendecke <v...@samba.org> Reviewed-by: Jeremy Allison <j...@samba.org> commit 1776918c5bf2e6db4ab9072e09326b91fa211322 Author: Volker Lendecke <v...@samba.org> Date: Wed May 8 16:05:40 2024 +0200 libsmb: Use the direct FSCC_FILE_ALL_INFORMATION define (SMB_FILE_ALL_INFORMATION - 1000) looks a bit silly if you look at the definition of SMB_FILE_ALL_INFORMATION... Signed-off-by: Volker Lendecke <v...@samba.org> Reviewed-by: Jeremy Allison <j...@samba.org> commit 5e0fe4d91cee3cc687b2b4bbfc778a7bf8f58d5e Author: Volker Lendecke <v...@samba.org> Date: Thu Dec 22 11:36:21 2022 +0100 smbd: Add DEBUG message got get_reparse_point Signed-off-by: Volker Lendecke <v...@samba.org> Reviewed-by: Jeremy Allison <j...@samba.org> commit ee653577630d4f68f82fa93c03e0a33b7b6ccdc1 Author: Volker Lendecke <v...@samba.org> Date: Wed May 8 16:03:29 2024 +0200 smbd: Return reparse tag as of MS-FSCC 2.4.6 Signed-off-by: Volker Lendecke <v...@samba.org> Reviewed-by: Jeremy Allison <j...@samba.org> commit d884c2fb0d5a3b72d550d72c2f263f7d80a5dc8a Author: Volker Lendecke <v...@samba.org> Date: Wed May 8 15:48:11 2024 +0200 smbd: Fix a DBG Signed-off-by: Volker Lendecke <v...@samba.org> Reviewed-by: Jeremy Allison <j...@samba.org> commit 44b3eadacb3df92238b30c38abe4abf48c60a971 Author: Volker Lendecke <v...@samba.org> Date: Thu May 9 11:54:31 2024 +0200 tests: get TAG_INFORMATION Signed-off-by: Volker Lendecke <v...@samba.org> Reviewed-by: Jeremy Allison <j...@samba.org> commit ba40d97087bed742eb6178b2e5e03a77e040f343 Author: Volker Lendecke <v...@samba.org> Date: Thu May 9 11:59:20 2024 +0200 pylibsmb: Add py_cli_qfileinfo Signed-off-by: Volker Lendecke <v...@samba.org> Reviewed-by: Jeremy Allison <j...@samba.org> commit c13ac1f1a7606bd78b3527ea931910929adc0c05 Author: Volker Lendecke <v...@samba.org> Date: Thu May 9 12:00:00 2024 +0200 pylibsmb: Add FSCC QUERY_INFO levels Signed-off-by: Volker Lendecke <v...@samba.org> Reviewed-by: Jeremy Allison <j...@samba.org> commit 291a353b16a77dd29b4a2be559b9c2c311c698e9 Author: Volker Lendecke <v...@samba.org> Date: Thu May 9 10:37:49 2024 +0200 libsmb: Remove smb2 branch from cli_qfileinfo_basic_send cli_qfileinfo_send now does it Signed-off-by: Volker Lendecke <v...@samba.org> Reviewed-by: Jeremy Allison <j...@samba.org> commit 893e4f6ebf624d1f87fd320b4bbe833fbda4cc2b Author: Volker Lendecke <v...@samba.org> Date: Thu May 9 10:35:26 2024 +0200 libsmb: Add smb2 branch to cli_qfileinfo Signed-off-by: Volker Lendecke <v...@samba.org> Reviewed-by: Jeremy Allison <j...@samba.org> commit 6e9c18ed821d5c9563ec3ffef612656d87bebb3b Author: Volker Lendecke <v...@samba.org> Date: Thu May 9 10:34:13 2024 +0200 libsmb: Add a tevent_req_received() where appropriate Signed-off-by: Volker Lendecke <v...@samba.org> Reviewed-by: Jeremy Allison <j...@samba.org> commit bec5920ec9115a35b49828338ddb6fbbf9608ca4 Author: Volker Lendecke <v...@samba.org> Date: Thu May 9 10:12:14 2024 +0200 libsmb: Convert cli_qfileinfo to use FSCC levels This will enable this routine to be used for SMB2 as well. The translation table is from [MS-CIFS] 2.2.8. Signed-off-by: Volker Lendecke <v...@samba.org> Reviewed-by: Jeremy Allison <j...@samba.org> commit af4bb5f75f74eea5f635bc0a019e1b3865ab533f Author: Volker Lendecke <v...@samba.org> Date: Thu May 9 10:27:48 2024 +0200 libsmb: Use SMB2_0_INFO_FILE instead of the raw "1" Signed-off-by: Volker Lendecke <v...@samba.org> Reviewed-by: Jeremy Allison <j...@samba.org> commit 4eac4014c0358681aedf6deb0accd2f9860ef882 Author: Volker Lendecke <v...@samba.org> Date: Thu May 9 09:37:51 2024 +0200 libsmb: Use SMB2_0_INFO_SECURITY instead of the raw "3" Signed-off-by: Volker Lendecke <v...@samba.org> Reviewed-by: Jeremy Allison <j...@samba.org> commit 072e4d030aee486e5749dff93ab1be98f931163b Author: Volker Lendecke <v...@samba.org> Date: Wed May 8 14:17:34 2024 +0200 smbd: Modernize a DEBUG Signed-off-by: Volker Lendecke <v...@samba.org> Reviewed-by: Jeremy Allison <j...@samba.org> commit 7c59f1105607310e4a54488e5f40893ebb796a50 Author: Volker Lendecke <v...@samba.org> Date: Tue May 7 17:22:01 2024 +0200 test: Align integer types Signed-off-by: Volker Lendecke <v...@samba.org> Reviewed-by: Jeremy Allison <j...@samba.org> ----------------------------------------------------------------------- Summary of changes: libcli/auth/tests/test_schannel.c | 4 +- python/samba/tests/reparsepoints.py | 24 ++++++++ python/samba/tests/smb3unix.py | 41 ++++++++++++++ source3/libsmb/cli_smb2_fnum.c | 1 + source3/libsmb/clifile.c | 108 ++++++++++++++++++++++++++++++++--- source3/libsmb/clirap.c | 70 +++-------------------- source3/libsmb/clirap.h | 19 +++++-- source3/libsmb/clisecdesc.c | 20 +++---- source3/libsmb/pylibsmb.c | 109 ++++++++++++++++++++++++++++++++++++ source3/modules/util_reparse.c | 54 +++++++++--------- source3/modules/util_reparse.h | 2 + source3/smbd/smb1_reply.c | 5 +- source3/smbd/smb2_create.c | 3 + source3/smbd/smb2_reply.c | 36 ++++++------ source3/smbd/smb2_trans2.c | 55 ++++++++++++------ source3/torture/test_smb2.c | 29 +++++----- source3/torture/torture.c | 13 +++-- 17 files changed, 421 insertions(+), 172 deletions(-) Changeset truncated at 500 lines: diff --git a/libcli/auth/tests/test_schannel.c b/libcli/auth/tests/test_schannel.c index b1c88fdf667..e249ff00751 100644 --- a/libcli/auth/tests/test_schannel.c +++ b/libcli/auth/tests/test_schannel.c @@ -167,7 +167,7 @@ static void torture_schannel_seal_rc4(void **state) int buffer_sizes[] = { 0, 1, 3, 7, 8, 9, 15, 16, 17 }; - int i; + size_t i; torture_schannel_seal_flags(state, 0, session_key, @@ -259,7 +259,7 @@ static void torture_schannel_seal_aes(void **state) int buffer_sizes[] = { 0, 1, 3, 7, 8, 9, 15, 16, 17 }; - int i; + size_t i; torture_schannel_seal_flags(state, NETLOGON_NEG_SUPPORTS_AES, session_key, diff --git a/python/samba/tests/reparsepoints.py b/python/samba/tests/reparsepoints.py index 96ca6eefdd5..1f74c61bc64 100644 --- a/python/samba/tests/reparsepoints.py +++ b/python/samba/tests/reparsepoints.py @@ -118,6 +118,30 @@ class ReparsePoints(samba.tests.libsmb.LibsmbTests): self.assertEqual(e.exception.args[0], ntstatus.NT_STATUS_IO_REPARSE_TAG_MISMATCH) + def test_query_reparse_tag(self): + conn = self.connection() + filename = 'reparse' + self.clean_file(conn, filename) + + fd = conn.create( + filename, + DesiredAccess=sec.SEC_FILE_READ_ATTRIBUTE | + sec.SEC_FILE_WRITE_ATTRIBUTE | + sec.SEC_STD_DELETE, + CreateDisposition=libsmb.FILE_CREATE) + + conn.delete_on_close(fd, 1) + + info = conn.qfileinfo(fd, libsmb.FSCC_FILE_ATTRIBUTE_TAG_INFORMATION); + self.assertEqual(info['tag'], 0) + + b = reparse_symlink.put(0x80000026, 0, b'asdf') + conn.fsctl(fd, libsmb.FSCTL_SET_REPARSE_POINT, b, 0) + + info = conn.qfileinfo(fd, libsmb.FSCC_FILE_ATTRIBUTE_TAG_INFORMATION); + self.assertEqual(info['tag'], 0x80000026) + + # Show that we can write to a reparse point when opened properly def test_write_reparse(self): conn = self.connection() diff --git a/python/samba/tests/smb3unix.py b/python/samba/tests/smb3unix.py index 1962852349c..66aa98b5aa9 100644 --- a/python/samba/tests/smb3unix.py +++ b/python/samba/tests/smb3unix.py @@ -23,6 +23,7 @@ from samba.common import get_string from samba.dcerpc import smb3posix from samba.ndr import ndr_unpack from samba.dcerpc.security import dom_sid +from samba import reparse_symlink import os import subprocess @@ -391,6 +392,46 @@ class Smb3UnixTests(samba.tests.libsmb.LibsmbTests): self.delete_test_file(c, '\\test_create_context_basic1_file') self.delete_test_file(c, '\\test_create_context_basic1_dir') + def test_create_context_reparse(self): + """ + Check reparse tag in posix create context response + """ + try: + c = libsmb.Conn( + self.server_ip, + "smb3_posix_share", + self.lp, + self.creds, + posix=True) + self.assertTrue(c.have_posix()) + + tag = 0x80000025 + + f,_,cc_out = c.create_ex('\\reparse', + DesiredAccess=security.SEC_STD_ALL, + CreateDisposition=libsmb.FILE_CREATE, + CreateContexts=[posix_context(0o600)]) + + cc = ndr_unpack(smb3posix.smb3_posix_cc_info, cc_out[0][1]) + self.assertEqual(cc.reparse_tag, libsmb.IO_REPARSE_TAG_RESERVED_ZERO) + + b = reparse_symlink.put(tag, 0, b'asdf') + c.fsctl(f, libsmb.FSCTL_SET_REPARSE_POINT, b, 0) + + c.close(f) + + f,_,cc_out = c.create_ex('\\reparse', + DesiredAccess=security.SEC_STD_ALL, + CreateDisposition=libsmb.FILE_OPEN, + CreateContexts=[posix_context(0o600)]) + c.close(f) + + cc = ndr_unpack(smb3posix.smb3_posix_cc_info, cc_out[0][1]) + self.assertEqual(cc.reparse_tag, tag) + + finally: + self.delete_test_file(c, '\\reparse') + def test_delete_on_close(self): """ Test two opens with delete-on-close: diff --git a/source3/libsmb/cli_smb2_fnum.c b/source3/libsmb/cli_smb2_fnum.c index 08d95cf3579..cea27444b97 100644 --- a/source3/libsmb/cli_smb2_fnum.c +++ b/source3/libsmb/cli_smb2_fnum.c @@ -1923,6 +1923,7 @@ NTSTATUS cli_smb2_query_info_fnum_recv( .data = talloc_move(mem_ctx, &state->outbuf.data), .length = state->outbuf.length, }; + tevent_req_received(req); return NT_STATUS_OK; } diff --git a/source3/libsmb/clifile.c b/source3/libsmb/clifile.c index 1ff3973bb39..354d8960dd8 100644 --- a/source3/libsmb/clifile.c +++ b/source3/libsmb/clifile.c @@ -6961,24 +6961,84 @@ struct cli_qfileinfo_state { uint32_t num_rdata; }; +static void cli_qfileinfo_done2(struct tevent_req *subreq); static void cli_qfileinfo_done(struct tevent_req *subreq); struct tevent_req *cli_qfileinfo_send(TALLOC_CTX *mem_ctx, struct tevent_context *ev, - struct cli_state *cli, uint16_t fnum, - uint16_t level, uint32_t min_rdata, + struct cli_state *cli, + uint16_t fnum, + uint16_t fscc_level, + uint32_t min_rdata, uint32_t max_rdata) { struct tevent_req *req, *subreq; struct cli_qfileinfo_state *state; + uint16_t smb_level; req = tevent_req_create(mem_ctx, &state, struct cli_qfileinfo_state); if (req == NULL) { return NULL; } + + if (smbXcli_conn_protocol(cli->conn) >= PROTOCOL_SMB2_02) { + max_rdata = MIN(max_rdata, + smb2cli_conn_max_trans_size(cli->conn)); + + subreq = cli_smb2_query_info_fnum_send( + state, /* mem_ctx */ + ev, /* ev */ + cli, /* cli */ + fnum, /* fnum */ + SMB2_0_INFO_FILE, /* in_info_type */ + fscc_level, /* in_file_info_class */ + max_rdata, /* in_max_output_length */ + NULL, /* in_input_buffer */ + 0, /* in_additional_info */ + 0); /* in_flags */ + if (tevent_req_nomem(subreq, req)) { + return tevent_req_post(req, ev); + } + tevent_req_set_callback(subreq, cli_qfileinfo_done2, req); + return req; + } + + max_rdata = MIN(max_rdata, UINT16_MAX); + + switch (fscc_level) { + case FSCC_FILE_BASIC_INFORMATION: + smb_level = SMB_QUERY_FILE_BASIC_INFO; + break; + case FSCC_FILE_STANDARD_INFORMATION: + smb_level = SMB_QUERY_FILE_STANDARD_INFO; + break; + case FSCC_FILE_EA_INFORMATION: + smb_level = SMB_QUERY_FILE_EA_INFO; + break; + case FSCC_FILE_NAME_INFORMATION: + smb_level = SMB_QUERY_FILE_NAME_INFO; + break; + case FSCC_FILE_ALL_INFORMATION: + smb_level = SMB_QUERY_FILE_ALL_INFO; + break; + case FSCC_FILE_ALTERNATE_NAME_INFORMATION: + smb_level = SMB_QUERY_FILE_ALT_NAME_INFO; + break; + case FSCC_FILE_STREAM_INFORMATION: + smb_level = SMB_QUERY_FILE_STREAM_INFO; + break; + case FSCC_FILE_COMPRESSION_INFORMATION: + smb_level = SMB_QUERY_COMPRESSION_INFO; + break; + default: + /* Probably wrong, but the server will tell us */ + smb_level = fscc_level; + break; + } + state->min_rdata = min_rdata; SSVAL(state->param, 0, fnum); - SSVAL(state->param, 2, level); + SSVAL(state->param, 2, smb_level); SSVAL(state->setup, 0, TRANSACT2_QFILEINFO); subreq = cli_trans_send( @@ -7008,6 +7068,31 @@ struct tevent_req *cli_qfileinfo_send(TALLOC_CTX *mem_ctx, return req; } +static void cli_qfileinfo_done2(struct tevent_req *subreq) +{ + struct tevent_req *req = tevent_req_callback_data(subreq, + struct tevent_req); + struct cli_qfileinfo_state *state = tevent_req_data( + req, struct cli_qfileinfo_state); + DATA_BLOB outbuf = {}; + NTSTATUS status; + + status = cli_smb2_query_info_fnum_recv(subreq, state, &outbuf); + TALLOC_FREE(subreq); + if (tevent_req_nterror(req, status)) { + return; + } + + if (outbuf.length < state->min_rdata) { + tevent_req_nterror(req, NT_STATUS_INVALID_NETWORK_RESPONSE); + return; + } + + state->rdata = outbuf.data; + state->num_rdata = outbuf.length; + tevent_req_done(req); +} + static void cli_qfileinfo_done(struct tevent_req *subreq) { struct tevent_req *req = tevent_req_callback_data( @@ -7054,10 +7139,15 @@ NTSTATUS cli_qfileinfo_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx, return NT_STATUS_OK; } -NTSTATUS cli_qfileinfo(TALLOC_CTX *mem_ctx, struct cli_state *cli, - uint16_t fnum, uint16_t level, uint32_t min_rdata, - uint32_t max_rdata, uint16_t *recv_flags2, - uint8_t **rdata, uint32_t *num_rdata) +NTSTATUS cli_qfileinfo(TALLOC_CTX *mem_ctx, + struct cli_state *cli, + uint16_t fnum, + uint16_t fscc_level, + uint32_t min_rdata, + uint32_t max_rdata, + uint16_t *recv_flags2, + uint8_t **rdata, + uint32_t *num_rdata) { TALLOC_CTX *frame = talloc_stackframe(); struct tevent_context *ev; @@ -7075,8 +7165,8 @@ NTSTATUS cli_qfileinfo(TALLOC_CTX *mem_ctx, struct cli_state *cli, if (ev == NULL) { goto fail; } - req = cli_qfileinfo_send(frame, ev, cli, fnum, level, min_rdata, - max_rdata); + req = cli_qfileinfo_send( + frame, ev, cli, fnum, fscc_level, min_rdata, max_rdata); if (req == NULL) { goto fail; } diff --git a/source3/libsmb/clirap.c b/source3/libsmb/clirap.c index 21ee346e0aa..9897b5a3072 100644 --- a/source3/libsmb/clirap.c +++ b/source3/libsmb/clirap.c @@ -1307,7 +1307,6 @@ struct cli_qfileinfo_basic_state { static void cli_qfileinfo_basic_done(struct tevent_req *subreq); static void cli_qfileinfo_basic_doneE(struct tevent_req *subreq); -static void cli_qfileinfo_basic_done2(struct tevent_req *subreq); struct tevent_req *cli_qfileinfo_basic_send( TALLOC_CTX *mem_ctx, @@ -1349,34 +1348,13 @@ struct tevent_req *cli_qfileinfo_basic_send( return req; } - if (smbXcli_conn_protocol(cli->conn) >= PROTOCOL_SMB2_02) { - subreq = cli_smb2_query_info_fnum_send( - state, /* mem_ctx */ - ev, /* ev */ - cli, /* cli */ - fnum, /* fnum */ - 1, /* in_info_type */ - (SMB_FILE_ALL_INFORMATION - 1000), /* in_file_info_class */ - 0xFFFF, /* in_max_output_length */ - NULL, /* in_input_buffer */ - 0, /* in_additional_info */ - 0); /* in_flags */ - if (tevent_req_nomem(subreq, req)) { - return tevent_req_post(req, ev); - } - tevent_req_set_callback( - subreq, cli_qfileinfo_basic_done2, req); - return req; - } - - subreq = cli_qfileinfo_send( - state, - ev, - cli, - fnum, - SMB_QUERY_FILE_ALL_INFO, /* level */ - 68, /* min_rdata */ - CLI_BUFFER_SIZE); /* max_rdata */ + subreq = cli_qfileinfo_send(state, + ev, + cli, + fnum, + FSCC_FILE_ALL_INFORMATION, /* level */ + 68, /* min_rdata */ + CLI_BUFFER_SIZE); /* max_rdata */ if (tevent_req_nomem(subreq, req)) { return tevent_req_post(req, ev); } @@ -1435,40 +1413,6 @@ static void cli_qfileinfo_basic_doneE(struct tevent_req *subreq) tevent_req_done(req); } -static void cli_qfileinfo_basic_done2(struct tevent_req *subreq) -{ - struct tevent_req *req = tevent_req_callback_data( - subreq, struct tevent_req); - struct cli_qfileinfo_basic_state *state = tevent_req_data( - req, struct cli_qfileinfo_basic_state); - DATA_BLOB outbuf = {0}; - NTSTATUS status; - - status = cli_smb2_query_info_fnum_recv(subreq, state, &outbuf); - TALLOC_FREE(subreq); - if (tevent_req_nterror(req, status)) { - return; - } - - /* Parse the reply. */ - if (outbuf.length < 0x60) { - tevent_req_nterror(req, NT_STATUS_INVALID_NETWORK_RESPONSE); - return; - } - - state->create_time = interpret_long_date(BVAL(outbuf.data, 0x0)); - 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->attr = IVAL(outbuf.data, 0x20); - state->size = BVAL(outbuf.data, 0x30); - state->ino = BVAL(outbuf.data, 0x40); - - data_blob_free(&outbuf); - - tevent_req_done(req); -} - NTSTATUS cli_qfileinfo_basic_recv( struct tevent_req *req, uint32_t *attr, diff --git a/source3/libsmb/clirap.h b/source3/libsmb/clirap.h index 4dc0441cc5b..5181ef22290 100644 --- a/source3/libsmb/clirap.h +++ b/source3/libsmb/clirap.h @@ -162,16 +162,23 @@ NTSTATUS cli_qpathinfo(TALLOC_CTX *mem_ctx, struct cli_state *cli, struct tevent_req *cli_qfileinfo_send(TALLOC_CTX *mem_ctx, struct tevent_context *ev, - struct cli_state *cli, uint16_t fnum, - uint16_t level, uint32_t min_rdata, + struct cli_state *cli, + uint16_t fnum, + uint16_t fscc_level, + uint32_t min_rdata, uint32_t max_rdata); NTSTATUS cli_qfileinfo_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx, uint16_t *recv_flags2, uint8_t **rdata, uint32_t *num_rdata); -NTSTATUS cli_qfileinfo(TALLOC_CTX *mem_ctx, struct cli_state *cli, - uint16_t fnum, uint16_t level, uint32_t min_rdata, - uint32_t max_rdata, uint16_t *recv_flags2, - uint8_t **rdata, uint32_t *num_rdata); +NTSTATUS cli_qfileinfo(TALLOC_CTX *mem_ctx, + struct cli_state *cli, + uint16_t fnum, + uint16_t fscc_level, + uint32_t min_rdata, + uint32_t max_rdata, + uint16_t *recv_flags2, + uint8_t **rdata, + uint32_t *num_rdata); struct tevent_req *cli_flush_send(TALLOC_CTX *mem_ctx, struct tevent_context *ev, diff --git a/source3/libsmb/clisecdesc.c b/source3/libsmb/clisecdesc.c index d6a266191ab..e42ca7bc592 100644 --- a/source3/libsmb/clisecdesc.c +++ b/source3/libsmb/clisecdesc.c @@ -49,16 +49,16 @@ struct tevent_req *cli_query_security_descriptor_send( if (smbXcli_conn_protocol(cli->conn) >= PROTOCOL_SMB2_02) { subreq = cli_smb2_query_info_fnum_send( - state, /* mem_ctx */ - ev, /* ev */ - cli, /* cli */ - fnum, /* fnum */ - 3, /* in_info_type */ - 0, /* in_info_class */ - 0xFFFF, /* in_max_output_length */ - NULL, /* in_input_buffer */ - sec_info, /* in_additional_info */ - 0); /* in_flags */ + state, /* mem_ctx */ + ev, /* ev */ + cli, /* cli */ + fnum, /* fnum */ + SMB2_0_INFO_SECURITY, /* in_info_type */ + 0, /* in_info_class */ + 0xFFFF, /* in_max_output_length */ + NULL, /* in_input_buffer */ + sec_info, /* in_additional_info */ + 0); /* in_flags */ if (tevent_req_nomem(subreq, req)) { return tevent_req_post(req, ev); } diff --git a/source3/libsmb/pylibsmb.c b/source3/libsmb/pylibsmb.c index 767187913f6..091cfee76bd 100644 --- a/source3/libsmb/pylibsmb.c +++ b/source3/libsmb/pylibsmb.c @@ -1263,6 +1263,61 @@ static PyObject *py_cli_close(struct py_cli_state *self, PyObject *args) Py_RETURN_NONE; } +static PyObject *py_cli_qfileinfo(struct py_cli_state *self, PyObject *args) +{ + struct tevent_req *req = NULL; + int fnum, level; + uint16_t recv_flags2; + uint8_t *rdata = NULL; + uint32_t num_rdata; + PyObject *result = NULL; + NTSTATUS status; + + if (!PyArg_ParseTuple(args, "ii", &fnum, &level)) { + return NULL; + } + + req = cli_qfileinfo_send( + NULL, self->ev, self->cli, fnum, level, 0, UINT32_MAX); + if (!py_tevent_req_wait_exc(self, req)) { + return NULL; + } + status = cli_qfileinfo_recv( + req, NULL, &recv_flags2, &rdata, &num_rdata); + TALLOC_FREE(req); + + if (!NT_STATUS_IS_OK(status)) { + PyErr_SetNTSTATUS(status); + return NULL; + } + + switch (level) { + case FSCC_FILE_ATTRIBUTE_TAG_INFORMATION: { + uint32_t mode = PULL_LE_U32(rdata, 0); + uint32_t tag = PULL_LE_U32(rdata, 4); + + if (num_rdata != 8) { + PyErr_SetNTSTATUS(NT_STATUS_INVALID_NETWORK_RESPONSE); + return NULL; + } + + result = Py_BuildValue("{s:K,s:K}", + "mode", + (unsigned long long)mode, + "tag", + (unsigned long long)tag); + break; + } + default: + result = PyBytes_FromStringAndSize((char *)rdata, num_rdata); + break; + } -- Samba Shared Repository