The branch, master has been updated via 9636b40b05b smbd: Use get_dirent_ea_size() also for BOTH_DIRECTORY_INFO via dc98e564604 smbd: Factor out get_dirent_ea_size() via 8000c188374 pylibsmb: Add reparse tag definitions via ecdb225a7c6 pylibsmb: Get reparse tag when listing directories via d4f47d4b869 smbd: Modernize a DBG statement via eb0e911c73c smbd: Shorten a few lines via 852ce99e2ae smbd: Remove duplicate/unused #defines via 7a21dc75645 torture: Fix whitespace via 71610e3633d smbd: Move SMB_QUERY_FILE_UNIX_LINK to smb1_trans2.c via f48e2489ad7 smbd: Move get_posix_fsp() to smb1_trans2.c via 6fc64f53a80 smbd: Move SMB_QUERY_POSIX_ACL to smb1_trans2.c via 01e14e0fe13 smbd: Move SMB_QUERY_FILE_UNIX_[BASIC|INFO2] to smb1_trans2.c via 0cfea607927 smbd: Remove an unnecessary if-statement via 65fc2b105a3 smbd: Remove an unnecessary if-statement via 4f69b76fa18 smbd: Move smb_set_posix_acl() to smb1_trans2.c via 19c41395e55 smbd: Make get_posix_fsp() public via b0dfee968a4 smbd: smbd_do_qfilepathinfo() does not need lock_data anymore via e53988cdea2 smbd: Handle SMB_QUERY_POSIX_LOCK() in call_trans2qfileinfo() via ad453a3827b smbd: Remove two variables never set after initialization via 2be0e68ec51 smbd: Move SMB_SET_FILE_UNIX_[BASIC|INFO2] to smb1_trans2.c via 483aa414809 smbd: Make map_info2_flags_to_sbuf() public via 1c21fc72e9a smbd: Make smb_set_file_size() public via 765f9bcf666 smbd: Move handling smb_set_posix_lock() to smb1_trans2.c via 2cef6fcd6d1 smbd: Move smb_set_file_unix_hlink() to smb1_trans2.c via 5273c1da12a smbd: Move smb_set_file_unix_link() to smb1_trans2.c via cabef724697 smbd: Move smb_posix_unlink() to smb1_trans2.c via bcc621a69f9 smbd: Make smb_set_file_disposition_info() public via 38b15fada27 smbd: Move smb_posix_open() to smb1_trans2.c via 58287995e5b smbd: Make store_file_unix_basic[_info2] public via bad8aa10cd8 smbd: Factor out handle_trans2qfilepathinfo_result() via 5f7d16dbefa smbd: Simplify call_trans2qfilepathinfo() via d66dc816716 smbd: Fix qfileinfo profiling via 3b76bc9689c smbd: Remove call_trans2setfilepathinfo() via 5f38f23668b smbd: Factor out handle_trans2setfilepathinfo_result() via f72572ff6f4 smbd: Simplify call_trans2setfilepathinfo() via 6619b16fec7 smbd: Fix setfileinfo profiling from c9a6e242d15 s3: smbd: Strip any leading '\' characters if the SMB2 DFS flag is set.
https://git.samba.org/?p=samba.git;a=shortlog;h=master - Log ----------------------------------------------------------------- commit 9636b40b05b90e5317bb1ef29985ffb91bccf482 Author: Volker Lendecke <v...@samba.org> Date: Mon Jan 2 16:21:50 2023 +0100 smbd: Use get_dirent_ea_size() also for BOTH_DIRECTORY_INFO This is a bit more involved as readdir_attr_data needs to be looked at. The meaning of this if-statements should be the same though, readdir_attr_data can only be non-NULL if we don't have a reparse point around. See the beginning of smbd_marshall_dir_entry(). Signed-off-by: Volker Lendecke <v...@samba.org> Reviewed-by: Ralph Boehme <s...@samba.org> Autobuild-User(master): Ralph Böhme <s...@samba.org> Autobuild-Date(master): Wed Jan 4 09:48:37 UTC 2023 on sn-devel-184 commit dc98e564604f4b61fbc6bd41ba8c05ead30e7aa2 Author: Volker Lendecke <v...@samba.org> Date: Mon Jan 2 16:19:12 2023 +0100 smbd: Factor out get_dirent_ea_size() Signed-off-by: Volker Lendecke <v...@samba.org> Reviewed-by: Ralph Boehme <s...@samba.org> commit 8000c1883748dcf4a5e2c2ea8f90115dff07254a Author: Volker Lendecke <v...@samba.org> Date: Mon Jan 2 16:01:10 2023 +0100 pylibsmb: Add reparse tag definitions Signed-off-by: Volker Lendecke <v...@samba.org> Reviewed-by: Ralph Boehme <s...@samba.org> commit ecdb225a7c6688f1d8ad53e6f651e7e985297582 Author: Volker Lendecke <v...@samba.org> Date: Mon Jan 2 14:29:12 2023 +0100 pylibsmb: Get reparse tag when listing directories Signed-off-by: Volker Lendecke <v...@samba.org> Reviewed-by: Ralph Boehme <s...@samba.org> commit d4f47d4b86923741ef8644b6aee8fc2faab79d74 Author: Volker Lendecke <v...@samba.org> Date: Wed Dec 28 23:18:20 2022 +0100 smbd: Modernize a DBG statement Signed-off-by: Volker Lendecke <v...@samba.org> Reviewed-by: Ralph Boehme <s...@samba.org> commit eb0e911c73cfc8d1ec348a17de13f71344901f92 Author: Volker Lendecke <v...@samba.org> Date: Wed Dec 28 23:14:25 2022 +0100 smbd: Shorten a few lines Signed-off-by: Volker Lendecke <v...@samba.org> Reviewed-by: Ralph Boehme <s...@samba.org> commit 852ce99e2aeea148c3f0d5301ad4e93be9c94630 Author: Volker Lendecke <v...@samba.org> Date: Fri Dec 23 09:21:25 2022 +0100 smbd: Remove duplicate/unused #defines Signed-off-by: Volker Lendecke <v...@samba.org> Reviewed-by: Ralph Boehme <s...@samba.org> commit 7a21dc75645040e44a8940e6dad3e064124e918e Author: Volker Lendecke <v...@samba.org> Date: Sat Dec 24 14:08:40 2022 +0100 torture: Fix whitespace Signed-off-by: Volker Lendecke <v...@samba.org> Reviewed-by: Ralph Boehme <s...@samba.org> commit 71610e3633d2a0f58d851f17fc847be25a73002c Author: Volker Lendecke <v...@samba.org> Date: Mon Jan 2 09:47:05 2023 +0100 smbd: Move SMB_QUERY_FILE_UNIX_LINK to smb1_trans2.c Signed-off-by: Volker Lendecke <v...@samba.org> Reviewed-by: Ralph Boehme <s...@samba.org> commit f48e2489ad7645a9923fbd97a179c85979651f4c Author: Volker Lendecke <v...@samba.org> Date: Sat Dec 31 17:41:16 2022 +0100 smbd: Move get_posix_fsp() to smb1_trans2.c Signed-off-by: Volker Lendecke <v...@samba.org> Reviewed-by: Ralph Boehme <s...@samba.org> commit 6fc64f53a80b192e7309a2c7a3a6b6ba420157d6 Author: Volker Lendecke <v...@samba.org> Date: Sat Dec 31 17:39:09 2022 +0100 smbd: Move SMB_QUERY_POSIX_ACL to smb1_trans2.c Signed-off-by: Volker Lendecke <v...@samba.org> Reviewed-by: Ralph Boehme <s...@samba.org> commit 01e14e0fe138f13f64067ae3c932e9564cd7dd4e Author: Volker Lendecke <v...@samba.org> Date: Fri Dec 30 16:26:38 2022 +0100 smbd: Move SMB_QUERY_FILE_UNIX_[BASIC|INFO2] to smb1_trans2.c Signed-off-by: Volker Lendecke <v...@samba.org> Reviewed-by: Ralph Boehme <s...@samba.org> commit 0cfea6079270de7a9b420cb3ad34e31cfdd5d037 Author: Volker Lendecke <v...@samba.org> Date: Fri Dec 30 22:22:31 2022 +0100 smbd: Remove an unnecessary if-statement Signed-off-by: Volker Lendecke <v...@samba.org> Reviewed-by: Ralph Boehme <s...@samba.org> commit 65fc2b105a30718cf33241e851f66c345ff2e3e5 Author: Volker Lendecke <v...@samba.org> Date: Fri Dec 30 22:21:48 2022 +0100 smbd: Remove an unnecessary if-statement Signed-off-by: Volker Lendecke <v...@samba.org> Reviewed-by: Ralph Boehme <s...@samba.org> commit 4f69b76fa18c8f335919d4859f93bacaabc544ec Author: Volker Lendecke <v...@samba.org> Date: Fri Dec 30 20:49:11 2022 +0100 smbd: Move smb_set_posix_acl() to smb1_trans2.c Signed-off-by: Volker Lendecke <v...@samba.org> Reviewed-by: Ralph Boehme <s...@samba.org> commit 19c41395e556199ee823f24111bb8967c64dc390 Author: Volker Lendecke <v...@samba.org> Date: Fri Dec 30 20:39:54 2022 +0100 smbd: Make get_posix_fsp() public This will go static again soon. Signed-off-by: Volker Lendecke <v...@samba.org> Reviewed-by: Ralph Boehme <s...@samba.org> commit b0dfee968a4f4e2c277eb89b6001d982b1e96cd1 Author: Volker Lendecke <v...@samba.org> Date: Fri Dec 30 22:15:50 2022 +0100 smbd: smbd_do_qfilepathinfo() does not need lock_data anymore Signed-off-by: Volker Lendecke <v...@samba.org> Reviewed-by: Ralph Boehme <s...@samba.org> commit e53988cdea2875719e567d2f792c6bf9da2c8aca Author: Volker Lendecke <v...@samba.org> Date: Fri Dec 30 22:12:23 2022 +0100 smbd: Handle SMB_QUERY_POSIX_LOCK() in call_trans2qfileinfo() smbd_do_qfilepathinfo() does not use the lock data anymore, we can pass NULL/0 now. Signed-off-by: Volker Lendecke <v...@samba.org> Reviewed-by: Ralph Boehme <s...@samba.org> commit ad453a3827b375c1cad84096e3840ecff0853212 Author: Volker Lendecke <v...@samba.org> Date: Fri Dec 30 21:43:06 2022 +0100 smbd: Remove two variables never set after initialization Signed-off-by: Volker Lendecke <v...@samba.org> Reviewed-by: Ralph Boehme <s...@samba.org> commit 2be0e68ec512b77f525edba904c25c545d2605dd Author: Volker Lendecke <v...@samba.org> Date: Fri Dec 30 16:26:38 2022 +0100 smbd: Move SMB_SET_FILE_UNIX_[BASIC|INFO2] to smb1_trans2.c Signed-off-by: Volker Lendecke <v...@samba.org> Reviewed-by: Ralph Boehme <s...@samba.org> commit 483aa4148093670b08cf9a1cc358dfd7c5982b54 Author: Volker Lendecke <v...@samba.org> Date: Fri Dec 30 16:23:52 2022 +0100 smbd: Make map_info2_flags_to_sbuf() public Signed-off-by: Volker Lendecke <v...@samba.org> Reviewed-by: Ralph Boehme <s...@samba.org> commit 1c21fc72e9ab17ee861cbbf4899fe63493ee5d14 Author: Volker Lendecke <v...@samba.org> Date: Fri Dec 30 16:23:27 2022 +0100 smbd: Make smb_set_file_size() public Signed-off-by: Volker Lendecke <v...@samba.org> Reviewed-by: Ralph Boehme <s...@samba.org> commit 765f9bcf6669b20bd98b146b3a5f39ba160ac9ea Author: Volker Lendecke <v...@samba.org> Date: Thu Dec 29 10:59:45 2022 +0100 smbd: Move handling smb_set_posix_lock() to smb1_trans2.c Most of this is direct cut&paste without reformatting. Don't pass SMB_SET_POSIX_LOCK through smbd_do_setfilepathinfo(), directly handle it in call_trans2setfileinfo() where we know we have a fsp. Signed-off-by: Volker Lendecke <v...@samba.org> Reviewed-by: Ralph Boehme <s...@samba.org> commit 2cef6fcd6d13b68193a04ef64b3d9717a6d1173b Author: Volker Lendecke <v...@samba.org> Date: Thu Dec 29 10:47:12 2022 +0100 smbd: Move smb_set_file_unix_hlink() to smb1_trans2.c Most of this is direct cut&paste without reformatting. Don't pass SMB_SET_FILE_UNIX_HLINK through smbd_do_setfilepathinfo(), directly handle it in call_trans2setpathinfo() where we know we have a path. Signed-off-by: Volker Lendecke <v...@samba.org> Reviewed-by: Ralph Boehme <s...@samba.org> commit 5273c1da12a2e8e1f34abdbe13051c6de7945900 Author: Volker Lendecke <v...@samba.org> Date: Thu Dec 29 10:44:33 2022 +0100 smbd: Move smb_set_file_unix_link() to smb1_trans2.c Most of this is direct cut&paste without reformatting. Don't pass SMB_SET_FILE_UNIX_LINK through smbd_do_setfilepathinfo(), directly handle it in call_trans2setpathinfo() where we know we have a path. Signed-off-by: Volker Lendecke <v...@samba.org> Reviewed-by: Ralph Boehme <s...@samba.org> commit cabef7246977b19398affb0a323e22b0062c8dac Author: Volker Lendecke <v...@samba.org> Date: Thu Dec 29 00:07:21 2022 +0100 smbd: Move smb_posix_unlink() to smb1_trans2.c Most of this is direct cut&paste without reformatting. Don't pass SMB_POSIX_PATH_UNLINK through smbd_do_setfilepathinfo(), directly handle it in call_trans2setpathinfo() where we know we have a path. Signed-off-by: Volker Lendecke <v...@samba.org> Reviewed-by: Ralph Boehme <s...@samba.org> commit bcc621a69f90bc556b79eb5b0dd79faddb99a5d3 Author: Volker Lendecke <v...@samba.org> Date: Thu Dec 29 00:06:58 2022 +0100 smbd: Make smb_set_file_disposition_info() public Signed-off-by: Volker Lendecke <v...@samba.org> Reviewed-by: Ralph Boehme <s...@samba.org> commit 38b15fada27e8bd6555d0902e94e69b603bf2b32 Author: Volker Lendecke <v...@samba.org> Date: Wed Dec 28 23:50:53 2022 +0100 smbd: Move smb_posix_open() to smb1_trans2.c Most of this is direct cut&paste without reformatting. Don't pass SMB_POSIX_PATH_OPEN through smbd_do_setfilepathinfo(), directly handle it in call_trans2setpathinfo() where we know we have a path. Signed-off-by: Volker Lendecke <v...@samba.org> Reviewed-by: Ralph Boehme <s...@samba.org> commit 58287995e5b38914c8357d00172a228e97c1f153 Author: Volker Lendecke <v...@samba.org> Date: Wed Dec 28 23:47:42 2022 +0100 smbd: Make store_file_unix_basic[_info2] public Signed-off-by: Volker Lendecke <v...@samba.org> Reviewed-by: Ralph Boehme <s...@samba.org> commit bad8aa10cd80c03f43b6e2e10b01a6a0ed92fddb Author: Volker Lendecke <v...@samba.org> Date: Fri Dec 30 12:23:58 2022 +0100 smbd: Factor out handle_trans2qfilepathinfo_result() The error handling will be used in other places. Signed-off-by: Volker Lendecke <v...@samba.org> Reviewed-by: Ralph Boehme <s...@samba.org> commit 5f7d16dbefaf26abe161ed32b7383c0bb1e2e7bb Author: Volker Lendecke <v...@samba.org> Date: Fri Dec 23 18:20:15 2022 +0100 smbd: Simplify call_trans2qfilepathinfo() Move the file/path specific preparations to the respective callers. Signed-off-by: Volker Lendecke <v...@samba.org> Reviewed-by: Ralph Boehme <s...@samba.org> commit d66dc816716c63311c4e1faad089c3a3667b91c8 Author: Volker Lendecke <v...@samba.org> Date: Fri Dec 23 17:23:36 2022 +0100 smbd: Fix qfileinfo profiling This ran under qpathinfo profiling Signed-off-by: Volker Lendecke <v...@samba.org> Reviewed-by: Ralph Boehme <s...@samba.org> commit 3b76bc9689c4a1ac8bed2b9e2d13eb03dedfddc9 Author: Volker Lendecke <v...@samba.org> Date: Fri Dec 30 10:27:11 2022 +0100 smbd: Remove call_trans2setfilepathinfo() What's left was just a simple wrapper around smbd_do_setfilepathinfo() and handle_trans2setfilepathinfo_result() Signed-off-by: Volker Lendecke <v...@samba.org> Reviewed-by: Ralph Boehme <s...@samba.org> commit 5f38f23668b6c3af4515facd37f1f3bea97d32f4 Author: Volker Lendecke <v...@samba.org> Date: Fri Dec 30 10:13:08 2022 +0100 smbd: Factor out handle_trans2setfilepathinfo_result() This will be lifted up in the next patches. We can also remove the REALLOC of *pparams, for this we only ever send 2 NULL bytes that we stack-allocate now. Signed-off-by: Volker Lendecke <v...@samba.org> Reviewed-by: Ralph Boehme <s...@samba.org> commit f72572ff6f4cf5529124f8f7d65048ae21603035 Author: Volker Lendecke <v...@samba.org> Date: Fri Dec 23 17:29:45 2022 +0100 smbd: Simplify call_trans2setfilepathinfo() Move the file/path specific preparations to the respective callers. Signed-off-by: Volker Lendecke <v...@samba.org> Reviewed-by: Ralph Boehme <s...@samba.org> commit 6619b16fec717813df94c26296270eab96bc4dc8 Author: Volker Lendecke <v...@samba.org> Date: Fri Dec 23 17:18:30 2022 +0100 smbd: Fix setfileinfo profiling This ran under setpathinfo profiling Signed-off-by: Volker Lendecke <v...@samba.org> Reviewed-by: Ralph Boehme <s...@samba.org> ----------------------------------------------------------------------- Summary of changes: source3/include/smb.h | 9 - source3/libsmb/pylibsmb.c | 19 + source3/smbd/globals.h | 2 - source3/smbd/proto.h | 25 + source3/smbd/smb1_trans2.c | 3327 +++++++++++++++++++++++++++++++++------- source3/smbd/smb1_trans2.h | 5 - source3/smbd/smb2_getinfo.c | 4 - source3/smbd/smb2_trans2.c | 2056 +------------------------ source4/torture/basic/delete.c | 534 +++---- 9 files changed, 3126 insertions(+), 2855 deletions(-) Changeset truncated at 500 lines: diff --git a/source3/include/smb.h b/source3/include/smb.h index 67694cb3bc9..704fe559203 100644 --- a/source3/include/smb.h +++ b/source3/include/smb.h @@ -32,7 +32,6 @@ /* logged when starting the various Samba daemons */ #define COPYRIGHT_STARTUP_MESSAGE "Copyright Andrew Tridgell and the Samba Team 1992-2023" -#define SAFETY_MARGIN 1024 #define LARGE_WRITEX_HDR_SIZE 65 #define LARGE_WRITEX_BUFFER_SIZE (128*1024) @@ -50,14 +49,6 @@ #define SIZEOFWORD 2 -/* string manipulation flags - see clistr.c and srvstr.c */ -#define STR_TERMINATE 1 -#define STR_UPPER 2 -#define STR_ASCII 4 -#define STR_UNICODE 8 -#define STR_NOALIGN 16 -#define STR_TERMINATE_ASCII 128 - /* how long to wait for secondary SMB packets (milli-seconds) */ #define SMB_SECONDARY_WAIT (60*1000) diff --git a/source3/libsmb/pylibsmb.c b/source3/libsmb/pylibsmb.c index 0990e2dc995..7952a6ec483 100644 --- a/source3/libsmb/pylibsmb.c +++ b/source3/libsmb/pylibsmb.c @@ -1970,6 +1970,18 @@ static NTSTATUS list_helper(struct file_info *finfo, return NT_STATUS_NO_MEMORY; } + if (finfo->attr & FILE_ATTRIBUTE_REPARSE_POINT) { + unsigned long tag = finfo->reparse_tag; + + ret = PyDict_SetItemString( + file, + "reparse_tag", + PyLong_FromUnsignedLong(tag)); + if (ret == -1) { + return NT_STATUS_INTERNAL_ERROR; + } + } + ret = PyList_Append(result, file); Py_CLEAR(file); if (ret == -1) { @@ -2862,6 +2874,13 @@ MODULE_INIT_FUNC(libsmb_samba_cwrapper) ADD_FLAGS(SYMLINK_TRUST_UNKNOWN); ADD_FLAGS(SYMLINK_TRUST_MASK); + ADD_FLAGS(IO_REPARSE_TAG_SYMLINK); + ADD_FLAGS(IO_REPARSE_TAG_MOUNT_POINT); + ADD_FLAGS(IO_REPARSE_TAG_HSM); + ADD_FLAGS(IO_REPARSE_TAG_SIS); + ADD_FLAGS(IO_REPARSE_TAG_DFS); + ADD_FLAGS(IO_REPARSE_TAG_NFS); + #define ADD_STRING(val) PyModule_AddObject(m, #val, PyBytes_FromString(val)) ADD_STRING(SMB2_CREATE_TAG_EXTA); diff --git a/source3/smbd/globals.h b/source3/smbd/globals.h index d1c0d145de7..5fb9f2e647c 100644 --- a/source3/smbd/globals.h +++ b/source3/smbd/globals.h @@ -126,8 +126,6 @@ NTSTATUS smbd_do_qfilepathinfo(connection_struct *conn, bool delete_pending, struct timespec write_time_ts, struct ea_list *ea_list, - int lock_data_count, - char *lock_data, uint16_t flags2, unsigned int max_data_bytes, size_t *fixed_portion, diff --git a/source3/smbd/proto.h b/source3/smbd/proto.h index 4a9ffbc0998..32e5c33896b 100644 --- a/source3/smbd/proto.h +++ b/source3/smbd/proto.h @@ -1101,6 +1101,19 @@ int sys_statvfs(const char *path, struct vfs_statvfs_struct *statbuf); /* The following definitions come from smbd/trans2.c */ +char *store_file_unix_basic(connection_struct *conn, + char *pdata, + files_struct *fsp, + const SMB_STRUCT_STAT *psbuf); +char *store_file_unix_basic_info2(connection_struct *conn, + char *pdata, + files_struct *fsp, + const SMB_STRUCT_STAT *psbuf); +NTSTATUS smb_set_file_disposition_info(connection_struct *conn, + const char *pdata, + int total_data, + files_struct *fsp, + struct smb_filename *smb_fname); NTSTATUS refuse_symlink_fsp(const struct files_struct *fsp); NTSTATUS check_access_fsp(struct files_struct *fsp, uint32_t access_mask); @@ -1130,6 +1143,18 @@ NTSTATUS smb_set_file_time(connection_struct *conn, struct smb_filename *smb_fname, struct smb_file_time *ft, bool setting_write_time); +NTSTATUS smb_set_file_size(connection_struct *conn, + struct smb_request *req, + files_struct *fsp, + struct smb_filename *smb_fname, + const SMB_STRUCT_STAT *psbuf, + off_t size, + bool fail_after_createfile); + +bool map_info2_flags_to_sbuf(const SMB_STRUCT_STAT *psbuf, + const uint32_t smb_fflags, + const uint32_t smb_fmask, + int *stat_fflags); enum perm_type { PERM_NEW_FILE, diff --git a/source3/smbd/smb1_trans2.c b/source3/smbd/smb1_trans2.c index 29232e348de..815e529b231 100644 --- a/source3/smbd/smb1_trans2.c +++ b/source3/smbd/smb1_trans2.c @@ -280,11 +280,11 @@ static void send_trans2_replies(connection_struct *conn, static void smb_set_posix_lock_done(struct tevent_req *subreq); -NTSTATUS smb_set_posix_lock(connection_struct *conn, - struct smb_request *req, - const char *pdata, - int total_data, - files_struct *fsp) +static NTSTATUS smb_set_posix_lock(connection_struct *conn, + struct smb_request *req, + const char *pdata, + int total_data, + files_struct *fsp) { struct tevent_req *subreq = NULL; struct smbd_lock_element *lck = NULL; @@ -296,6 +296,10 @@ NTSTATUS smb_set_posix_lock(connection_struct *conn, NTSTATUS status = NT_STATUS_OK; + if (!CAN_WRITE(conn)) { + return NT_STATUS_DOS(ERRSRV, ERRaccess); + } + if (fsp == NULL || fsp->fsp_flags.is_pathref || fsp_get_io_fd(fsp) == -1) @@ -1727,32 +1731,39 @@ static void call_trans2setfsinfo(connection_struct *conn, xconn->smb1.unix_info.client_minor = SVAL(pdata,2); xconn->smb1.unix_info.client_cap_low = IVAL(pdata,4); xconn->smb1.unix_info.client_cap_high = IVAL(pdata,8); + /* Just print these values for now. */ - DEBUG(10, ("call_trans2setfsinfo: set unix_info info. " - "major = %u, minor = %u cap_low = 0x%x, " - "cap_high = 0x%xn", - (unsigned int)xconn-> - smb1.unix_info.client_major, - (unsigned int)xconn-> - smb1.unix_info.client_minor, - (unsigned int)xconn-> - smb1.unix_info.client_cap_low, - (unsigned int)xconn-> - smb1.unix_info.client_cap_high)); - - /* Here is where we must switch to posix pathname processing... */ - if (xconn->smb1.unix_info.client_cap_low & CIFS_UNIX_POSIX_PATHNAMES_CAP) { + DBG_DEBUG("set unix_info info. " + "major = %"PRIu16", minor = %"PRIu16 + "cap_low = 0x%"PRIx32", " + "cap_high = 0x%"PRIx32"\n", + xconn->smb1.unix_info.client_major, + xconn->smb1.unix_info.client_minor, + xconn->smb1.unix_info.client_cap_low, + xconn->smb1.unix_info.client_cap_high); + + /* + * Here is where we must switch to posix + * pathname processing... + */ + if (xconn->smb1.unix_info.client_cap_low & + CIFS_UNIX_POSIX_PATHNAMES_CAP) + { lp_set_posix_pathnames(); mangle_change_to_posix(); } - if ((xconn->smb1.unix_info.client_cap_low & CIFS_UNIX_FCNTL_LOCKS_CAP) && - !(xconn->smb1.unix_info.client_cap_low & CIFS_UNIX_POSIX_PATH_OPERATIONS_CAP)) { + if ((xconn->smb1.unix_info.client_cap_low & + CIFS_UNIX_FCNTL_LOCKS_CAP) && + !(xconn->smb1.unix_info.client_cap_low & + CIFS_UNIX_POSIX_PATH_OPERATIONS_CAP)) + { /* Client that knows how to do posix locks, * but not posix open/mkdir operations. Set a * default type for read/write checks. */ - lp_set_posix_default_cifsx_readwrite_locktype(POSIX_LOCK); + lp_set_posix_default_cifsx_readwrite_locktype( + POSIX_LOCK); } break; @@ -1925,6 +1936,68 @@ static void call_trans2qpipeinfo(connection_struct *conn, return; } +static void handle_trans2qfilepathinfo_result( + connection_struct *conn, + struct smb_request *req, + uint16_t info_level, + NTSTATUS status, + char *pdata, + int data_return_size, + size_t fixed_portion, + unsigned int max_data_bytes) +{ + char params[2] = { 0, 0, }; + int param_size = 2; + + /* + * draft-leach-cifs-v1-spec-02.txt + * 4.2.14 TRANS2_QUERY_PATH_INFORMATION: Get File Attributes given Path + * says: + * + * The requested information is placed in the Data portion of the + * transaction response. For the information levels greater than 0x100, + * the transaction response has 1 parameter word which should be + * ignored by the client. + * + * However Windows only follows this rule for the IS_NAME_VALID call. + */ + switch (info_level) { + case SMB_INFO_IS_NAME_VALID: + param_size = 0; + break; + } + + if (!NT_STATUS_IS_OK(status)) { + if (open_was_deferred(req->xconn, req->mid)) { + /* We have re-scheduled this call. */ + return; + } + if (NT_STATUS_EQUAL(status, NT_STATUS_SHARING_VIOLATION)) { + bool ok = defer_smb1_sharing_violation(req); + if (ok) { + return; + } + } + reply_nterror(req, status); + return; + } + + if (fixed_portion > max_data_bytes) { + reply_nterror(req, NT_STATUS_INFO_LENGTH_MISMATCH); + return; + } + + send_trans2_replies( + conn, + req, + NT_STATUS_OK, + params, + param_size, + pdata, + data_return_size, + max_data_bytes); +} + /**************************************************************************** Reply to a TRANS2_QFILEPATHINFO or TRANSACT2_QFILEINFO (query file info by file name or file id). @@ -1933,287 +2006,21 @@ static void call_trans2qpipeinfo(connection_struct *conn, static void call_trans2qfilepathinfo(connection_struct *conn, struct smb_request *req, unsigned int tran_call, + uint16_t info_level, + struct smb_filename *smb_fname, + struct files_struct *fsp, + bool delete_pending, + struct timespec write_time_ts, char **pparams, int total_params, char **ppdata, int total_data, unsigned int max_data_bytes) { char *params = *pparams; char *pdata = *ppdata; - uint16_t info_level; unsigned int data_size = 0; - unsigned int param_size = 2; - struct smb_filename *smb_fname = NULL; - bool delete_pending = False; - struct timespec write_time_ts; - struct files_struct *dirfsp = NULL; - files_struct *fsp = NULL; - struct file_id fileid; struct ea_list *ea_list = NULL; - int lock_data_count = 0; - char *lock_data = NULL; size_t fixed_portion; NTSTATUS status = NT_STATUS_OK; - int ret; - - if (!params) { - reply_nterror(req, NT_STATUS_INVALID_PARAMETER); - return; - } - - ZERO_STRUCT(write_time_ts); - - if (tran_call == TRANSACT2_QFILEINFO) { - if (total_params < 4) { - reply_nterror(req, NT_STATUS_INVALID_PARAMETER); - return; - } - - fsp = file_fsp(req, SVAL(params,0)); - info_level = SVAL(params,2); - - if (IS_IPC(conn)) { - call_trans2qpipeinfo( - conn, - req, - fsp, - info_level, - tran_call, - pparams, - total_params, - ppdata, - total_data, - max_data_bytes); - return; - } - - DEBUG(3,("call_trans2qfilepathinfo: TRANSACT2_QFILEINFO: level = %d\n", info_level)); - - if (INFO_LEVEL_IS_UNIX(info_level)) { - if (!lp_smb1_unix_extensions()) { - reply_nterror(req, NT_STATUS_INVALID_LEVEL); - return; - } - if (!req->posix_pathnames) { - reply_nterror(req, NT_STATUS_INVALID_LEVEL); - return; - } - } - - /* Initial check for valid fsp ptr. */ - if (!check_fsp_open(conn, req, fsp)) { - return; - } - - smb_fname = fsp->fsp_name; - - if(fsp->fake_file_handle) { - /* - * This is actually for the QUOTA_FAKE_FILE --metze - */ - - /* We know this name is ok, it's already passed the checks. */ - - } else if(fsp_get_pathref_fd(fsp) == -1) { - /* - * This is actually a QFILEINFO on a directory - * handle (returned from an NT SMB). NT5.0 seems - * to do this call. JRA. - */ - ret = vfs_stat(conn, smb_fname); - if (ret != 0) { - DBG_NOTICE("vfs_stat of %s failed (%s)\n", - smb_fname_str_dbg(smb_fname), - strerror(errno)); - reply_nterror(req, - map_nt_error_from_unix(errno)); - return; - } - - if (fsp_getinfo_ask_sharemode(fsp)) { - fileid = vfs_file_id_from_sbuf( - conn, &smb_fname->st); - get_file_infos(fileid, fsp->name_hash, - &delete_pending, - &write_time_ts); - } - } else { - /* - * Original code - this is an open file. - */ - status = vfs_stat_fsp(fsp); - if (!NT_STATUS_IS_OK(status)) { - DEBUG(3, ("fstat of %s failed (%s)\n", - fsp_fnum_dbg(fsp), nt_errstr(status))); - reply_nterror(req, status); - return; - } - if (fsp_getinfo_ask_sharemode(fsp)) { - fileid = vfs_file_id_from_sbuf( - conn, &smb_fname->st); - get_file_infos(fileid, fsp->name_hash, - &delete_pending, - &write_time_ts); - } - } - - } else { - uint32_t name_hash; - char *fname = NULL; - uint32_t ucf_flags = ucf_flags_from_smb_request(req); - NTTIME twrp = 0; - - /* qpathinfo */ - if (total_params < 7) { - reply_nterror(req, NT_STATUS_INVALID_PARAMETER); - return; - } - - info_level = SVAL(params,0); - - DEBUG(3,("call_trans2qfilepathinfo: TRANSACT2_QPATHINFO: level = %d\n", info_level)); - - if (INFO_LEVEL_IS_UNIX(info_level)) { - if (!lp_smb1_unix_extensions()) { - reply_nterror(req, NT_STATUS_INVALID_LEVEL); - return; - } - if (!req->posix_pathnames) { - reply_nterror(req, NT_STATUS_INVALID_LEVEL); - return; - } - } - - if (req->posix_pathnames) { - srvstr_get_path_posix(req, - params, - req->flags2, - &fname, - ¶ms[6], - total_params - 6, - STR_TERMINATE, - &status); - } else { - srvstr_get_path(req, - params, - req->flags2, - &fname, - ¶ms[6], - total_params - 6, - STR_TERMINATE, - &status); - } - if (!NT_STATUS_IS_OK(status)) { - reply_nterror(req, status); - return; - } - - if (ucf_flags & UCF_GMT_PATHNAME) { - extract_snapshot_token(fname, &twrp); - } - status = filename_convert_dirfsp(req, - conn, - fname, - ucf_flags, - twrp, - &dirfsp, - &smb_fname); - if (!NT_STATUS_IS_OK(status)) { - if (NT_STATUS_EQUAL(status,NT_STATUS_PATH_NOT_COVERED)) { - reply_botherror(req, - NT_STATUS_PATH_NOT_COVERED, - ERRSRV, ERRbadpath); - return; - } - reply_nterror(req, status); - return; - } - - /* - * qpathinfo must operate on an existing file, so we - * can exit early if filename_convert_dirfsp() returned the - * "new file" NT_STATUS_OK, !VALID_STAT case. - */ - - if (!VALID_STAT(smb_fname->st)) { - reply_nterror(req, NT_STATUS_OBJECT_NAME_NOT_FOUND); - return; - } - - /* - * smb_fname->fsp may be NULL if smb_fname points at a symlink - * and we're in POSIX context, so be careful when using fsp - * below, it can still be NULL. - */ - fsp = smb_fname->fsp; - -- Samba Shared Repository