The branch, master has been updated via ea4dcbdc26b smbd: Simplify synthetic_smb_fname_split() via 0bcd86c3db6 smbd: Handle the "posix" special case outside of synthetic_smb_fname_split via c312e6285bc smbd: Remove the "posix_pathnames" global variable from f67a6729b96 third_party: Update socket_wrapper to version 1.5.0
https://git.samba.org/?p=samba.git;a=shortlog;h=master - Log ----------------------------------------------------------------- commit ea4dcbdc26b2eae0c8f0c5ccdaa48e10762c13ec Author: Volker Lendecke <v...@samba.org> Date: Thu May 8 15:11:17 2025 +0200 smbd: Simplify synthetic_smb_fname_split() Remove the "posix_path" parameter, all callers just passed in "false". Signed-off-by: Volker Lendecke <v...@samba.org> Reviewed-by: Stefan Metzmacher <me...@samba.org> Autobuild-User(master): Stefan Metzmacher <me...@samba.org> Autobuild-Date(master): Fri May 9 11:02:41 UTC 2025 on atb-devel-224 commit 0bcd86c3db60d5ad46c830544ae06514843587f6 Author: Volker Lendecke <v...@samba.org> Date: Thu May 8 15:06:23 2025 +0200 smbd: Handle the "posix" special case outside of synthetic_smb_fname_split See next patch Signed-off-by: Volker Lendecke <v...@samba.org> Reviewed-by: Stefan Metzmacher <me...@samba.org> commit c312e6285bc29d941a801fb5780790292ed76de0 Author: Volker Lendecke <v...@samba.org> Date: Thu May 8 15:00:34 2025 +0200 smbd: Remove the "posix_pathnames" global variable This was only set from the smb1 trans2 call negotiating smb1 unix extensions. This means for none of the callers in cmd_vfs and pysmbd this could ever have been set to "true". The only real caller is init_smb1_request(), and there we have the originating xconn with its flags available for direct query. Signed-off-by: Volker Lendecke <v...@samba.org> Reviewed-by: Stefan Metzmacher <me...@samba.org> ----------------------------------------------------------------------- Summary of changes: source3/include/proto.h | 3 +- source3/lib/filename_util.c | 13 +------ source3/param/loadparm.c | 21 ----------- source3/param/loadparm.h | 2 -- source3/smbd/filename.c | 16 ++++++++- source3/smbd/pysmbd.c | 35 +++++++----------- source3/smbd/smb1_trans2.c | 1 - source3/smbd/smb2_process.c | 6 +++- source3/torture/cmd_vfs.c | 86 ++++++++++++--------------------------------- 9 files changed, 57 insertions(+), 126 deletions(-) Changeset truncated at 500 lines: diff --git a/source3/include/proto.h b/source3/include/proto.h index e8dfb533b44..da0d0cb7dfe 100644 --- a/source3/include/proto.h +++ b/source3/include/proto.h @@ -711,8 +711,7 @@ struct smb_filename *full_path_from_dirfsp_atname( const struct files_struct *dirfsp, const struct smb_filename *atname); struct smb_filename *synthetic_smb_fname_split(TALLOC_CTX *ctx, - const char *fname, - bool posix_path); + const char *fname); const char *smb_fname_str_dbg(const struct smb_filename *smb_fname); const char *fsp_str_dbg(const struct files_struct *fsp); const char *fsp_fnum_dbg(const struct files_struct *fsp); diff --git a/source3/lib/filename_util.c b/source3/lib/filename_util.c index 3f8e9033ba5..0108ae6e6a0 100644 --- a/source3/lib/filename_util.c +++ b/source3/lib/filename_util.c @@ -94,24 +94,13 @@ struct smb_filename *cp_smb_filename_nostream(TALLOC_CTX *mem_ctx, * There are a few legitimate users of this. */ struct smb_filename *synthetic_smb_fname_split(TALLOC_CTX *ctx, - const char *fname, - bool posix_path) + const char *fname) { char *stream_name = NULL; char *base_name = NULL; struct smb_filename *ret; bool ok; - if (posix_path) { - /* No stream name looked for. */ - return synthetic_smb_fname(ctx, - fname, - NULL, - NULL, - 0, - SMB_FILENAME_POSIX_PATH); - } - ok = split_stream_filename(ctx, fname, &base_name, diff --git a/source3/param/loadparm.c b/source3/param/loadparm.c index 949e40c36ff..6dd9ccbe39f 100644 --- a/source3/param/loadparm.c +++ b/source3/param/loadparm.c @@ -4666,27 +4666,6 @@ void lp_set_mangling_method(const char *new_method) lpcfg_string_set(Globals.ctx, &Globals.mangling_method, new_method); } -/******************************************************************* - Global state for POSIX pathname processing. -********************************************************************/ - -static bool posix_pathnames; - -bool lp_posix_pathnames(void) -{ - return posix_pathnames; -} - -/******************************************************************* - Change everything needed to ensure POSIX pathname processing (currently - not much). -********************************************************************/ - -void lp_set_posix_pathnames(void) -{ - posix_pathnames = true; -} - /******************************************************************* Global state for POSIX lock processing - CIFS unix extensions. ********************************************************************/ diff --git a/source3/param/loadparm.h b/source3/param/loadparm.h index b2b23157429..ff4087ce9c2 100644 --- a/source3/param/loadparm.h +++ b/source3/param/loadparm.h @@ -188,8 +188,6 @@ uint32_t lp_get_spoolss_state( void ); struct smb1_signing_state; void set_use_sendfile(int snum, bool val); void lp_set_mangling_method(const char *new_method); -bool lp_posix_pathnames(void); -void lp_set_posix_pathnames(void); enum brl_flavour lp_posix_cifsu_locktype(files_struct *fsp); void lp_set_posix_default_cifsx_readwrite_locktype(enum brl_flavour val); int lp_min_receive_file_size(void); diff --git a/source3/smbd/filename.c b/source3/smbd/filename.c index 164e84361e2..e4234178c0d 100644 --- a/source3/smbd/filename.c +++ b/source3/smbd/filename.c @@ -694,7 +694,21 @@ filename_convert_dirfsp_nosymlink(TALLOC_CTX *mem_ctx, if (is_fake_file_path(name_in)) { const struct timespec omit = make_omit_timespec(); - smb_fname = synthetic_smb_fname_split(mem_ctx, name_in, posix); + + if (posix) { + /* + * No stream name to look for + */ + smb_fname = synthetic_smb_fname( + mem_ctx, + name_in, + NULL, + NULL, + 0, + SMB_FILENAME_POSIX_PATH); + } else { + smb_fname = synthetic_smb_fname_split(mem_ctx, name_in); + } if (smb_fname == NULL) { return NT_STATUS_NO_MEMORY; } diff --git a/source3/smbd/pysmbd.c b/source3/smbd/pysmbd.c index b112440e2c8..fe439dfe2c2 100644 --- a/source3/smbd/pysmbd.c +++ b/source3/smbd/pysmbd.c @@ -166,9 +166,7 @@ static int set_sys_acl_conn(const char *fname, NTSTATUS status; smb_fname = synthetic_smb_fname_split( - frame, - canonicalize_path(talloc_tos(), conn, fname), - lp_posix_pathnames()); + frame, canonicalize_path(talloc_tos(), conn, fname)); if (smb_fname == NULL) { TALLOC_FREE(frame); return -1; @@ -220,9 +218,7 @@ static NTSTATUS init_files_struct(TALLOC_CTX *mem_ctx, fsp->conn = conn; smb_fname = synthetic_smb_fname_split( - fsp, - canonicalize_path(talloc_tos(), conn, fname), - lp_posix_pathnames()); + fsp, canonicalize_path(talloc_tos(), conn, fname)); if (smb_fname == NULL) { return NT_STATUS_NO_MEMORY; } @@ -337,9 +333,7 @@ static NTSTATUS get_nt_acl_conn(TALLOC_CTX *mem_ctx, struct smb_filename *smb_fname = NULL; smb_fname = synthetic_smb_fname_split( - frame, - canonicalize_path(talloc_tos(), conn, fname), - lp_posix_pathnames()); + frame, canonicalize_path(talloc_tos(), conn, fname)); if (smb_fname == NULL) { TALLOC_FREE(frame); @@ -733,9 +727,7 @@ static PyObject *py_smbd_unlink(PyObject *self, PyObject *args, PyObject *kwargs } smb_fname = synthetic_smb_fname_split( - frame, - canonicalize_path(talloc_tos(), conn, fname), - lp_posix_pathnames()); + frame, canonicalize_path(talloc_tos(), conn, fname)); if (smb_fname == NULL) { TALLOC_FREE(frame); return PyErr_NoMemory(); @@ -1077,9 +1069,7 @@ static PyObject *py_smbd_get_sys_acl(PyObject *self, PyObject *args, PyObject *k } smb_fname = synthetic_smb_fname_split( - frame, - canonicalize_path(talloc_tos(), conn, fname), - lp_posix_pathnames()); + frame, canonicalize_path(talloc_tos(), conn, fname)); if (smb_fname == NULL) { TALLOC_FREE(frame); return NULL; @@ -1168,13 +1158,14 @@ static PyObject *py_smbd_mkdir(PyObject *self, PyObject *args, PyObject *kwargs) return NULL; } - smb_fname = synthetic_smb_fname( - talloc_tos(), - canonicalize_path(talloc_tos(), conn, fname), - NULL, - NULL, - 0, - lp_posix_pathnames() ? SMB_FILENAME_POSIX_PATH : 0); + smb_fname = synthetic_smb_fname(talloc_tos(), + canonicalize_path(talloc_tos(), + conn, + fname), + NULL, + NULL, + 0, + 0); if (smb_fname == NULL) { TALLOC_FREE(frame); diff --git a/source3/smbd/smb1_trans2.c b/source3/smbd/smb1_trans2.c index 2e8362a82e9..643c05dd77e 100644 --- a/source3/smbd/smb1_trans2.c +++ b/source3/smbd/smb1_trans2.c @@ -1777,7 +1777,6 @@ static void call_trans2setfsinfo(connection_struct *conn, if (xconn->smb1.unix_info.client_cap_low & CIFS_UNIX_POSIX_PATHNAMES_CAP) { - lp_set_posix_pathnames(); mangle_change_to_posix(); } diff --git a/source3/smbd/smb2_process.c b/source3/smbd/smb2_process.c index 1ec22d476ff..829f6b4b11d 100644 --- a/source3/smbd/smb2_process.c +++ b/source3/smbd/smb2_process.c @@ -772,7 +772,11 @@ bool init_smb1_request(struct smb_request *req, req->conn = tcon->compat; } } - req->posix_pathnames = lp_posix_pathnames(); + +#if defined(WITH_SMB1SERVER) + req->posix_pathnames = (xconn->smb1.unix_info.client_cap_low & + CIFS_UNIX_POSIX_PATHNAMES_CAP) != 0; +#endif /* Ensure we have at least wct words and 2 bytes of bcc. */ if (smb_size + req->wct*2 > req_size) { diff --git a/source3/torture/cmd_vfs.c b/source3/torture/cmd_vfs.c index d9b921b01e8..4ae1e4e1931 100644 --- a/source3/torture/cmd_vfs.c +++ b/source3/torture/cmd_vfs.c @@ -33,7 +33,7 @@ static const char *null_string = ""; static uint32_t ssf_flags(void) { - return lp_posix_pathnames() ? SMB_FILENAME_POSIX_PATH : 0; + return false ? SMB_FILENAME_POSIX_PATH : 0; } static NTSTATUS cmd_load_module(struct vfs_state *vfs, TALLOC_CTX *mem_ctx, int argc, const char **argv) @@ -401,9 +401,7 @@ static NTSTATUS cmd_open(struct vfs_state *vfs, TALLOC_CTX *mem_ctx, int argc, c } fsp->conn = vfs->conn; - smb_fname = synthetic_smb_fname_split(NULL, - argv[1], - lp_posix_pathnames()); + smb_fname = synthetic_smb_fname_split(NULL, argv[1]); if (smb_fname == NULL) { goto nomem; } @@ -516,9 +514,7 @@ static NTSTATUS cmd_pathfunc(struct vfs_state *vfs, TALLOC_CTX *mem_ctx, int arg } else if (strcmp("unlink", argv[0]) == 0 ) { TALLOC_FREE(smb_fname); /* unlink can be a stream:name */ - smb_fname = synthetic_smb_fname_split(talloc_tos(), - argv[1], - lp_posix_pathnames()); + smb_fname = synthetic_smb_fname_split(talloc_tos(), argv[1]); if (smb_fname == NULL) { return NT_STATUS_NO_MEMORY; } @@ -682,16 +678,12 @@ static NTSTATUS cmd_rename(struct vfs_state *vfs, TALLOC_CTX *mem_ctx, int argc, return NT_STATUS_OK; } - smb_fname_src = synthetic_smb_fname_split(mem_ctx, - argv[1], - lp_posix_pathnames()); + smb_fname_src = synthetic_smb_fname_split(mem_ctx, argv[1]); if (smb_fname_src == NULL) { return NT_STATUS_NO_MEMORY; } - smb_fname_dst = synthetic_smb_fname_split(mem_ctx, - argv[2], - lp_posix_pathnames()); + smb_fname_dst = synthetic_smb_fname_split(mem_ctx, argv[2]); if (smb_fname_dst == NULL) { TALLOC_FREE(smb_fname_src); return NT_STATUS_NO_MEMORY; @@ -751,9 +743,7 @@ static NTSTATUS cmd_stat(struct vfs_state *vfs, TALLOC_CTX *mem_ctx, int argc, c return NT_STATUS_OK; } - smb_fname = synthetic_smb_fname_split(mem_ctx, - argv[1], - lp_posix_pathnames()); + smb_fname = synthetic_smb_fname_split(mem_ctx, argv[1]); if (smb_fname == NULL) { return NT_STATUS_NO_MEMORY; } @@ -892,9 +882,7 @@ static NTSTATUS cmd_lstat(struct vfs_state *vfs, TALLOC_CTX *mem_ctx, int argc, return NT_STATUS_OK; } - smb_fname = synthetic_smb_fname_split(mem_ctx, - argv[1], - lp_posix_pathnames()); + smb_fname = synthetic_smb_fname_split(mem_ctx, argv[1]); if (smb_fname == NULL) { return NT_STATUS_NO_MEMORY; } @@ -959,9 +947,7 @@ static NTSTATUS cmd_chmod(struct vfs_state *vfs, TALLOC_CTX *mem_ctx, int argc, mode = atoi(argv[2]); - smb_fname = synthetic_smb_fname_split(mem_ctx, - argv[1], - lp_posix_pathnames()); + smb_fname = synthetic_smb_fname_split(mem_ctx, argv[1]); if (smb_fname == NULL) { return NT_STATUS_NO_MEMORY; } @@ -1224,9 +1210,7 @@ static NTSTATUS cmd_symlink(struct vfs_state *vfs, TALLOC_CTX *mem_ctx, int argc return NT_STATUS_OK; } - new_smb_fname = synthetic_smb_fname_split(mem_ctx, - argv[2], - lp_posix_pathnames()); + new_smb_fname = synthetic_smb_fname_split(mem_ctx, argv[2]); if (new_smb_fname == NULL) { return NT_STATUS_NO_MEMORY; } @@ -1271,9 +1255,7 @@ static NTSTATUS cmd_readlink(struct vfs_state *vfs, TALLOC_CTX *mem_ctx, int arg return NT_STATUS_OK; } - smb_fname = synthetic_smb_fname_split(mem_ctx, - argv[1], - lp_posix_pathnames()); + smb_fname = synthetic_smb_fname_split(mem_ctx, argv[1]); if (smb_fname == NULL) { return NT_STATUS_NO_MEMORY; } @@ -1305,15 +1287,11 @@ static NTSTATUS cmd_link(struct vfs_state *vfs, TALLOC_CTX *mem_ctx, int argc, c return NT_STATUS_OK; } - old_smb_fname = synthetic_smb_fname_split(mem_ctx, - argv[1], - lp_posix_pathnames()); + old_smb_fname = synthetic_smb_fname_split(mem_ctx, argv[1]); if (old_smb_fname == NULL) { return NT_STATUS_NO_MEMORY; } - new_smb_fname = synthetic_smb_fname_split(mem_ctx, - argv[2], - lp_posix_pathnames()); + new_smb_fname = synthetic_smb_fname_split(mem_ctx, argv[2]); if (new_smb_fname == NULL) { return NT_STATUS_NO_MEMORY; } @@ -1361,9 +1339,7 @@ static NTSTATUS cmd_mknod(struct vfs_state *vfs, TALLOC_CTX *mem_ctx, int argc, } dev = (SMB_DEV_T)dev_val; - smb_fname = synthetic_smb_fname_split(mem_ctx, - argv[1], - lp_posix_pathnames()); + smb_fname = synthetic_smb_fname_split(mem_ctx, argv[1]); if (smb_fname == NULL) { return NT_STATUS_NO_MEMORY; } @@ -1392,9 +1368,7 @@ static NTSTATUS cmd_realpath(struct vfs_state *vfs, TALLOC_CTX *mem_ctx, int arg return NT_STATUS_OK; } - smb_fname = synthetic_smb_fname_split(mem_ctx, - argv[1], - lp_posix_pathnames()); + smb_fname = synthetic_smb_fname_split(mem_ctx, argv[1]); if (smb_fname == NULL) { return NT_STATUS_NO_MEMORY; } @@ -1423,9 +1397,7 @@ static NTSTATUS cmd_getxattr(struct vfs_state *vfs, TALLOC_CTX *mem_ctx, buf = NULL; - smb_fname = synthetic_smb_fname_split(mem_ctx, - argv[1], - lp_posix_pathnames()); + smb_fname = synthetic_smb_fname_split(mem_ctx, argv[1]); if (smb_fname == NULL) { return NT_STATUS_NO_MEMORY; } @@ -1481,9 +1453,7 @@ static NTSTATUS cmd_listxattr(struct vfs_state *vfs, TALLOC_CTX *mem_ctx, buf = NULL; - smb_fname = synthetic_smb_fname_split(mem_ctx, - argv[1], - lp_posix_pathnames()); + smb_fname = synthetic_smb_fname_split(mem_ctx, argv[1]); if (smb_fname == NULL) { return NT_STATUS_NO_MEMORY; } @@ -1552,9 +1522,7 @@ static NTSTATUS cmd_fsetxattr(struct vfs_state *vfs, TALLOC_CTX *mem_ctx, flags = atoi(argv[4]); } - smb_fname = synthetic_smb_fname_split(mem_ctx, - argv[1], - lp_posix_pathnames()); + smb_fname = synthetic_smb_fname_split(mem_ctx, argv[1]); if (smb_fname == NULL) { return NT_STATUS_NO_MEMORY; } @@ -1594,9 +1562,7 @@ static NTSTATUS cmd_removexattr(struct vfs_state *vfs, TALLOC_CTX *mem_ctx, return NT_STATUS_OK; } - smb_fname = synthetic_smb_fname_split(mem_ctx, - argv[1], - lp_posix_pathnames()); + smb_fname = synthetic_smb_fname_split(mem_ctx, argv[1]); if (smb_fname == NULL) { return NT_STATUS_NO_MEMORY; } @@ -1774,9 +1740,7 @@ static NTSTATUS cmd_set_nt_acl(struct vfs_state *vfs, TALLOC_CTX *mem_ctx, int a } fsp->conn = vfs->conn; - smb_fname = synthetic_smb_fname_split(NULL, - argv[1], - lp_posix_pathnames()); + smb_fname = synthetic_smb_fname_split(NULL, argv[1]); if (smb_fname == NULL) { TALLOC_FREE(fsp); return NT_STATUS_NO_MEMORY; @@ -1917,9 +1881,7 @@ static NTSTATUS cmd_sys_acl_get_file(struct vfs_state *vfs, TALLOC_CTX *mem_ctx, return NT_STATUS_OK; } - smb_fname = synthetic_smb_fname_split(talloc_tos(), - argv[1], - lp_posix_pathnames()); + smb_fname = synthetic_smb_fname_split(talloc_tos(), argv[1]); if (smb_fname == NULL) { return NT_STATUS_NO_MEMORY; } @@ -1972,9 +1934,7 @@ static NTSTATUS cmd_sys_acl_blob_get_file(struct vfs_state *vfs, return NT_STATUS_OK; } - smb_fname = synthetic_smb_fname_split(mem_ctx, - argv[1], - lp_posix_pathnames()); + smb_fname = synthetic_smb_fname_split(mem_ctx, argv[1]); if (smb_fname == NULL) { return NT_STATUS_NO_MEMORY; } @@ -2070,9 +2030,7 @@ static NTSTATUS cmd_sys_acl_delete_def_file(struct vfs_state *vfs, TALLOC_CTX *m return NT_STATUS_OK; } - smb_fname = synthetic_smb_fname_split(mem_ctx, - argv[1], - lp_posix_pathnames()); + smb_fname = synthetic_smb_fname_split(mem_ctx, argv[1]); if (smb_fname == NULL) { return NT_STATUS_NO_MEMORY; } -- Samba Shared Repository