summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSumit Bose <sbose@redhat.com>2012-08-27 16:21:02 +0200
committerMartin Kosek <mkosek@redhat.com>2012-09-06 09:24:59 +0200
commit8697b70d6b0dfecd45f94b0deeca04b63998e1f1 (patch)
tree2762074a06d09d3ad47ed29a8798adfa349770df
parentf864d766eb6f01f7d7d7eb9635a39c8a50360bd6 (diff)
downloadfreeipa-8697b70d6b0dfecd45f94b0deeca04b63998e1f1.tar.gz
freeipa-8697b70d6b0dfecd45f94b0deeca04b63998e1f1.tar.xz
freeipa-8697b70d6b0dfecd45f94b0deeca04b63998e1f1.zip
ipasam: Replace dom_sid_compare_domain()
-rw-r--r--daemons/ipa-sam/ipa_sam.c28
1 files changed, 27 insertions, 1 deletions
diff --git a/daemons/ipa-sam/ipa_sam.c b/daemons/ipa-sam/ipa_sam.c
index 879e60ba4..5ef27dc4d 100644
--- a/daemons/ipa-sam/ipa_sam.c
+++ b/daemons/ipa-sam/ipa_sam.c
@@ -87,7 +87,6 @@ bool sid_check_is_builtin(const struct dom_sid *sid); /* available in libpdb.so
bool sid_check_is_our_sam(const struct dom_sid *sid);
bool sid_linearize(char *outbuf, size_t len, const struct dom_sid *sid); /* available in libsmbconf.so */
bool string_to_sid(struct dom_sid *sidout, const char *sidstr); /* available in libsecurity.so */
-int dom_sid_compare_domain(const struct dom_sid *sid1, const struct dom_sid *sid2); /* available in libsecurity.so */
char *sid_string_talloc(TALLOC_CTX *mem_ctx, const struct dom_sid *sid); /* available in libsmbconf.so */
char *sid_string_dbg(const struct dom_sid *sid); /* available in libsmbconf.so */
bool trim_char(char *s,char cfront,char cback); /* available in libutil_str.so */
@@ -215,6 +214,33 @@ static bool is_null_sid(const struct dom_sid *sid)
return true;
}
+static int dom_sid_compare_domain(const struct dom_sid *sid1,
+ const struct dom_sid *sid2)
+{
+ size_t c;
+ size_t n_sub_auths;
+
+ if (sid1->sid_rev_num != sid2->sid_rev_num) {
+ return sid1->sid_rev_num - sid2->sid_rev_num;
+ }
+
+ for (c = 0; c < 6; c++) {
+ if (sid1->id_auth[c] != sid2->id_auth[c]) {
+ return sid1->id_auth[c] - sid2->id_auth[c];
+ }
+ }
+
+ n_sub_auths = (sid1->num_auths < sid2->num_auths) ? sid1->num_auths :
+ sid2->num_auths;
+
+ for (c = 0; c < n_sub_auths; c++) {
+ if (sid1->sub_auths[c] != sid2->sub_auths[c]) {
+ return sid1->sub_auths[c] - sid2->sub_auths[c];
+ }
+ }
+
+ return 0;
+}
static bool strnequal(const char *s1, const char *s2, size_t n) {
if (s1 == s2) {