]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
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)
committerJule Anger <janger@samba.org>
Tue, 23 May 2023 07:13:09 +0000 (07:13 +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>
(cherry picked from commit bb3ea36e10079ad9c73c68d7ed8fce51ecb40ebe)

source3/include/proto.h
source3/lib/util_sid.c

index cfc56f1374ee08124a32c143e33748d58c416921..032e7aa3320772bd52f540b6ffbb65dc596e0458 100644 (file)
@@ -447,6 +447,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 16312d27ee6aab651a5301d12c2143bcae2af369..5261341fcde2f5f8a94b139afd09a4356cd03a8e 100644 (file)
@@ -192,3 +192,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);
+}