]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
libsmb: Add cli_fchmod for smb311 posix extensions
authorVolker Lendecke <vl@samba.org>
Fri, 2 Aug 2024 10:53:05 +0000 (12:53 +0200)
committerJeremy Allison <jra@samba.org>
Tue, 6 Aug 2024 16:29:33 +0000 (16:29 +0000)
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
source3/libsmb/clifile.c

index 449bfe4b6afe079b5f4910cb307e1d874a843886..52fbf8ab5dad9f7aca892cc9c95bf5fe432fa9a5 100644 (file)
@@ -1086,6 +1086,7 @@ struct cli_fchmod_state {
 };
 
 static void cli_fchmod_done1(struct tevent_req *subreq);
+static void cli_fchmod_done2(struct tevent_req *subreq);
 
 struct tevent_req *cli_fchmod_send(TALLOC_CTX *mem_ctx,
                                   struct tevent_context *ev,
@@ -1124,6 +1125,42 @@ struct tevent_req *cli_fchmod_send(TALLOC_CTX *mem_ctx,
                return req;
        }
 
+       if ((proto >= PROTOCOL_SMB3_11) && cli_smb2_fnum_is_posix(cli, fnum)) {
+               struct security_ace ace = {
+                       .type = SEC_ACE_TYPE_ACCESS_ALLOWED,
+                       .trustee = global_sid_Unix_NFS_Mode,
+               };
+               struct security_acl acl = {
+                       .revision = SECURITY_ACL_REVISION_NT4,
+                       .num_aces = 1,
+                       .aces = &ace,
+               };
+               struct security_descriptor *sd = NULL;
+
+               sid_append_rid(&ace.trustee, mode);
+
+               sd = make_sec_desc(state,
+                                  SECURITY_DESCRIPTOR_REVISION_1,
+                                  SEC_DESC_SELF_RELATIVE |
+                                          SEC_DESC_DACL_PRESENT,
+                                  NULL,
+                                  NULL,
+                                  NULL,
+                                  &acl,
+                                  NULL);
+               if (tevent_req_nomem(sd, req)) {
+                       return tevent_req_post(req, ev);
+               }
+
+               subreq = cli_set_security_descriptor_send(
+                       state, ev, cli, fnum, SECINFO_DACL, sd);
+               if (tevent_req_nomem(subreq, req)) {
+                       return tevent_req_post(req, ev);
+               }
+               tevent_req_set_callback(subreq, cli_fchmod_done2, req);
+               return req;
+       }
+
        tevent_req_nterror(req, NT_STATUS_INVALID_LEVEL);
        return tevent_req_post(req, ev);
 }
@@ -1134,6 +1171,12 @@ static void cli_fchmod_done1(struct tevent_req *subreq)
        tevent_req_simple_finish_ntstatus(subreq, status);
 }
 
+static void cli_fchmod_done2(struct tevent_req *subreq)
+{
+       NTSTATUS status = cli_set_security_descriptor_recv(subreq);
+       tevent_req_simple_finish_ntstatus(subreq, status);
+}
+
 NTSTATUS cli_fchmod_recv(struct tevent_req *req)
 {
        return tevent_req_simple_recv_ntstatus(req);