]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
libsmbclient: Request posix file handles on demand
authorVolker Lendecke <vl@samba.org>
Wed, 4 Jun 2025 06:19:56 +0000 (08:19 +0200)
committerRalph Boehme <slow@samba.org>
Mon, 16 Jun 2025 15:05:32 +0000 (15:05 +0000)
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
source3/libsmb/libsmb_file.c

index 14a567f67d20ec5d3622b948c5f9df30e6d06a62..79a00af454677b295ab5ef41777bceda2390090e 100644 (file)
@@ -54,6 +54,7 @@ SMBC_open_ctx(SMBCCTX *context,
        NTSTATUS status = NT_STATUS_OBJECT_PATH_INVALID;
        struct cli_credentials *creds = NULL;
        TALLOC_CTX *frame = talloc_stackframe();
+       bool smb311_posix_saved;
 
        if (!context || !context->internal->initialized) {
                TALLOC_FREE(frame);
@@ -139,6 +140,17 @@ SMBC_open_ctx(SMBCCTX *context,
        }
        /*d_printf(">>>open: resolved %s as %s\n", path, targetpath);*/
 
+       /*
+        * Indicate to cli_smb2_create_fnum_send() that we want file
+        * handles with posix extensions.
+        */
+
+       smb311_posix_saved = targetcli->smb2.client_smb311_posix;
+       targetcli->smb2.client_smb311_posix =
+               smbc_getOptionPosixExtensions(context) &&
+               (smbXcli_conn_protocol(targetcli->conn) >= PROTOCOL_SMB3_11) &&
+               smbXcli_conn_have_posix(targetcli->conn);
+
        /*
         * Random error that the O_PATH if-block will never return
         */
@@ -177,6 +189,8 @@ SMBC_open_ctx(SMBCCTX *context,
                                  &fd);
        }
 
+       targetcli->smb2.client_smb311_posix = smb311_posix_saved;
+
        if (!NT_STATUS_IS_OK(status)) {
 
                /* Handle the error ... */