From: Volker Lendecke Date: Thu, 8 May 2025 13:00:34 +0000 (+0200) Subject: smbd: Remove the "posix_pathnames" global variable X-Git-Tag: tevent-0.17.0~219 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c312e6285bc29d941a801fb5780790292ed76de0;p=thirdparty%2Fsamba.git 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 Reviewed-by: Stefan Metzmacher --- 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/pysmbd.c b/source3/smbd/pysmbd.c index b112440e2c8..2f078835188 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), false); 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), false); 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), false); 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), false); 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), false); 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..ecf7c2bb3a7 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], false); if (smb_fname == NULL) { goto nomem; } @@ -517,8 +515,8 @@ static NTSTATUS cmd_pathfunc(struct vfs_state *vfs, TALLOC_CTX *mem_ctx, int arg TALLOC_FREE(smb_fname); /* unlink can be a stream:name */ smb_fname = synthetic_smb_fname_split(talloc_tos(), - argv[1], - lp_posix_pathnames()); + argv[1], + false); if (smb_fname == NULL) { return NT_STATUS_NO_MEMORY; } @@ -682,16 +680,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], false); 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], false); if (smb_fname_dst == NULL) { TALLOC_FREE(smb_fname_src); return NT_STATUS_NO_MEMORY; @@ -751,9 +745,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], false); if (smb_fname == NULL) { return NT_STATUS_NO_MEMORY; } @@ -892,9 +884,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], false); if (smb_fname == NULL) { return NT_STATUS_NO_MEMORY; } @@ -959,9 +949,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], false); if (smb_fname == NULL) { return NT_STATUS_NO_MEMORY; } @@ -1224,9 +1212,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], false); if (new_smb_fname == NULL) { return NT_STATUS_NO_MEMORY; } @@ -1271,9 +1257,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], false); if (smb_fname == NULL) { return NT_STATUS_NO_MEMORY; } @@ -1305,15 +1289,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], false); 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], false); if (new_smb_fname == NULL) { return NT_STATUS_NO_MEMORY; } @@ -1361,9 +1341,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], false); if (smb_fname == NULL) { return NT_STATUS_NO_MEMORY; } @@ -1392,9 +1370,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], false); if (smb_fname == NULL) { return NT_STATUS_NO_MEMORY; } @@ -1423,9 +1399,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], false); if (smb_fname == NULL) { return NT_STATUS_NO_MEMORY; } @@ -1481,9 +1455,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], false); if (smb_fname == NULL) { return NT_STATUS_NO_MEMORY; } @@ -1552,9 +1524,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], false); if (smb_fname == NULL) { return NT_STATUS_NO_MEMORY; } @@ -1594,9 +1564,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], false); if (smb_fname == NULL) { return NT_STATUS_NO_MEMORY; } @@ -1774,9 +1742,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], false); if (smb_fname == NULL) { TALLOC_FREE(fsp); return NT_STATUS_NO_MEMORY; @@ -1917,9 +1883,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], false); if (smb_fname == NULL) { return NT_STATUS_NO_MEMORY; } @@ -1972,9 +1936,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], false); if (smb_fname == NULL) { return NT_STATUS_NO_MEMORY; } @@ -2070,9 +2032,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], false); if (smb_fname == NULL) { return NT_STATUS_NO_MEMORY; }