]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
libsmb: Add cli_smb2_fnum_is_posix
authorVolker Lendecke <vl@samba.org>
Fri, 2 Aug 2024 09:18:40 +0000 (11:18 +0200)
committerJeremy Allison <jra@samba.org>
Tue, 6 Aug 2024 16:29:33 +0000 (16:29 +0000)
Will be used in smb311 unix chmod soon: We should only do the special
setsd on real posix handles. Otherwise we would probably destroy a
valid acl.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
source3/libsmb/cli_smb2_fnum.c
source3/libsmb/cli_smb2_fnum.h

index c0b7d38eceddb2d9796ee0fcbaa791511bfd094b..34d65019d80ba338e7c77d010748330306483269 100644 (file)
@@ -49,6 +49,7 @@
 struct smb2_hnd {
        uint64_t fid_persistent;
        uint64_t fid_volatile;
+       bool posix; /* Opened with posix context */
 };
 
 /*
@@ -63,6 +64,7 @@ struct smb2_hnd {
 static NTSTATUS map_smb2_handle_to_fnum(struct cli_state *cli,
                                        uint64_t fid_persistent,
                                        uint64_t fid_volatile,
+                                       bool posix,
                                        uint16_t *pfnum)
 {
        int ret;
@@ -76,6 +78,7 @@ static NTSTATUS map_smb2_handle_to_fnum(struct cli_state *cli,
        *owned_h = (struct smb2_hnd){
                .fid_persistent = fid_persistent,
                .fid_volatile = fid_volatile,
+               .posix = posix,
        };
 
        if (idp == NULL) {
@@ -347,6 +350,7 @@ static void cli_smb2_create_fnum_done(struct tevent_req *subreq)
        struct cli_smb2_create_fnum_state *state = tevent_req_data(
                req, struct cli_smb2_create_fnum_state);
        uint64_t fid_persistent, fid_volatile;
+       struct smb2_create_blob *posix = NULL;
        NTSTATUS status;
 
        status = smb2cli_create_recv(subreq,
@@ -361,9 +365,13 @@ static void cli_smb2_create_fnum_done(struct tevent_req *subreq)
                return;
        }
 
+       posix = smb2_create_blob_find(&state->in_cblobs,
+                                     SMB2_CREATE_TAG_POSIX);
+
        status = map_smb2_handle_to_fnum(state->cli,
                                         fid_persistent,
                                         fid_volatile,
+                                        (posix != NULL),
                                         &state->fnum);
        if (tevent_req_nterror(req, status)) {
                return;
@@ -415,6 +423,18 @@ NTSTATUS cli_smb2_create_fnum_recv(
        return NT_STATUS_OK;
 }
 
+bool cli_smb2_fnum_is_posix(struct cli_state *cli, uint16_t fnum)
+{
+       struct smb2_hnd *ph = NULL;
+       NTSTATUS status;
+
+       status = map_fnum_to_smb2_handle(cli, fnum, &ph);
+       if (!NT_STATUS_IS_OK(status)) {
+               return false;
+       }
+       return ph->posix;
+}
+
 NTSTATUS cli_smb2_create_fnum(
        struct cli_state *cli,
        const char *fname,
index abac569385ddedca21f7e10502b5549ee13484ce..2b19e6ebb4eef7a2771bef7401d524df0b8000a2 100644 (file)
@@ -67,6 +67,8 @@ NTSTATUS cli_smb2_create_fnum(
        TALLOC_CTX *mem_ctx,
        struct smb2_create_blobs *out_cblobs);
 
+bool cli_smb2_fnum_is_posix(struct cli_state *cli, uint16_t fnum);
+
 struct tevent_req *cli_smb2_close_fnum_send(TALLOC_CTX *mem_ctx,
                                            struct tevent_context *ev,
                                            struct cli_state *cli,