lib: Add security_token_del_npa_flags() helper function
authorVolker Lendecke <vl@samba.org>
Tue, 18 Apr 2023 12:32:20 +0000 (14:32 +0200)
committerVolker Lendecke <vl@samba.org>
Tue, 16 May 2023 10:53:40 +0000 (10:53 +0000)
Bug: https://bugzilla.samba.org/show_bug.cgi?id=15361
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
source3/include/proto.h
source3/lib/util_sid.c

index a4ab57e84f324f2cdcd02d1143e1f47276a2b077..f71796b57ae9c38c564c9160c68ee6c956ecd578 100644 (file)
@@ -439,6 +439,7 @@ NTSTATUS sid_array_from_info3(TALLOC_CTX *mem_ctx,
                              bool include_user_group_rid);
 bool security_token_find_npa_flags(const struct security_token *token,
                                   uint32_t *_flags);
+void security_token_del_npa_flags(struct security_token *token);
 
 /* The following definitions come from lib/util_sock.c  */
 
index 9aebb363815a326f745c37f1381773ac1232ff8b..fd767f9c8b36ba8ebc5a1794c09975e2c6f9f408 100644 (file)
@@ -189,3 +189,18 @@ bool security_token_find_npa_flags(const struct security_token *token,
        sid_peek_rid(npa_flags_sid, _flags);
        return true;
 }
+
+void security_token_del_npa_flags(struct security_token *token)
+{
+       const struct dom_sid *npa_flags_sid = NULL;
+       size_t num_npa_sids;
+
+       num_npa_sids =
+               security_token_count_flag_sids(token,
+                                              &global_sid_Samba_NPA_Flags,
+                                              1,
+                                              &npa_flags_sid);
+       SMB_ASSERT(num_npa_sids == 1);
+
+       del_sid_from_array(npa_flags_sid, &token->sids, &token->num_sids);
+}