]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
smbd: Remove the "posix_pathnames" global variable
authorVolker Lendecke <vl@samba.org>
Thu, 8 May 2025 13:00:34 +0000 (15:00 +0200)
committerStefan Metzmacher <metze@samba.org>
Fri, 9 May 2025 09:59:32 +0000 (09:59 +0000)
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 <vl@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
source3/param/loadparm.c
source3/param/loadparm.h
source3/smbd/pysmbd.c
source3/smbd/smb1_trans2.c
source3/smbd/smb2_process.c
source3/torture/cmd_vfs.c

index 949e40c36ff0aa6187ddef28b16818ea2a8d87af..6dd9ccbe39f0e1b526b42f554fa506bf626a4586 100644 (file)
@@ -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.
 ********************************************************************/
index b2b23157429c183b059dce91a15ea53f6109ac67..ff4087ce9c2e5d0fcd3e3341cc75e222b00e5191 100644 (file)
@@ -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);
index b112440e2c82ebd2819a7e633cb1ba2261dedaa7..2f0788351882ea6e7a8bb4b7619033c579f96426 100644 (file)
@@ -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);
index 2e8362a82e953ac7aa54d19229355eeb4e24ee6e..643c05dd77ed25c8128f306eeaf43b397d6dcee7 100644 (file)
@@ -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();
                        }
 
index 1ec22d476ff51c30e70eb243db6101010a7a5d41..829f6b4b11d544460743fcef8df1af129cdaf2ed 100644 (file)
@@ -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) {
index d9b921b01e80040595e605a90d9d753873889883..ecf7c2bb3a777414cfdae65cf87ebea1d279d672 100644 (file)
@@ -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;
        }