]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
libcli/security: Add sids_contains_sid()
authorJoseph Sutton <josephsutton@catalyst.net.nz>
Mon, 30 Oct 2023 01:51:17 +0000 (14:51 +1300)
committerAndrew Bartlett <abartlet@samba.org>
Wed, 1 Nov 2023 20:10:45 +0000 (20:10 +0000)
Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
libcli/security/dom_sid.h
libcli/security/util_sid.c

index 534b4808ce52d35099bdfd3d74adb5c31c66fb16..058200d0fe4c735fd6c6e4bddb2f806b002e7b3f 100644 (file)
@@ -141,6 +141,9 @@ void del_sid_from_array(const struct dom_sid *sid, struct dom_sid **sids,
 bool add_rid_to_array_unique(TALLOC_CTX *mem_ctx,
                             uint32_t rid, uint32_t **pp_rids, size_t *p_num);
 bool is_null_sid(const struct dom_sid *sid);
+bool sids_contains_sid(const struct dom_sid *sids,
+                      const uint32_t num_sids,
+                      const struct dom_sid *sid);
 bool sids_contains_sid_attrs(const struct auth_SidAttr *sids,
                             const uint32_t num_sids,
                             const struct dom_sid *sid,
index b3408b37a4690942b857ba8aaa84363d4f4d235c..8b548199261a87db983552e654a7b9651f712e74 100644 (file)
@@ -511,6 +511,28 @@ bool is_null_sid(const struct dom_sid *sid)
        return dom_sid_equal(sid, &null_sid);
 }
 
+/**
+ * Return true if an array of SIDs contains a certain SID.
+ *
+ * @param [in] sids    The SID array.
+ * @param [in] num_sids        The size of the SID array.
+ * @param [in] sid     The SID in question.
+ * @returns true if the array contains the SID.
+ */
+bool sids_contains_sid(const struct dom_sid *sids,
+                      const uint32_t num_sids,
+                      const struct dom_sid *sid)
+{
+       uint32_t i;
+
+       for (i = 0; i < num_sids; i++) {
+               if (dom_sid_equal(&sids[i], sid)) {
+                       return true;
+               }
+       }
+       return false;
+}
+
 /**
  * Return true if an array of auth_SidAttr contains a certain SID with certain
  * attributes.