summaryrefslogtreecommitdiff
path: root/source3/lib
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2001-12-19 08:37:03 +0000
committerAndrew Tridgell <tridge@samba.org>2001-12-19 08:37:03 +0000
commit279276c9ca0106e4191e170a442b871543c034ac (patch)
tree94745d054a0a75a0f42c96557f301423ea5ad51f /source3/lib
parent085d62b38cc9869dbab1356c105520ab2347939d (diff)
downloadsamba-279276c9ca0106e4191e170a442b871543c034ac.tar.gz
samba-279276c9ca0106e4191e170a442b871543c034ac.tar.bz2
samba-279276c9ca0106e4191e170a442b871543c034ac.zip
fixed sid_compare_domain()
(This used to be commit c11c27b2812ceb06a52afbb7662f82a8676b1707)
Diffstat (limited to 'source3/lib')
-rw-r--r--source3/lib/util_sid.c32
1 files changed, 29 insertions, 3 deletions
diff --git a/source3/lib/util_sid.c b/source3/lib/util_sid.c
index 1e0feac049..009cc7742a 100644
--- a/source3/lib/util_sid.c
+++ b/source3/lib/util_sid.c
@@ -358,6 +358,16 @@ char *sid_to_string(fstring sidstr_out, DOM_SID *sid)
return sidstr_out;
}
+/*
+ useful function for debug lines
+*/
+const char *sid_string_static(DOM_SID *sid)
+{
+ static fstring sid_str;
+ sid_to_string(sid_str, sid);
+ return sid_str;
+}
+
/*****************************************************************
Convert a string to a SID. Returns True on success, False on fail.
*****************************************************************/
@@ -531,9 +541,9 @@ BOOL sid_parse(char *inbuf, size_t len, DOM_SID *sid)
/*****************************************************************
- Compare the domain portion of two sids.
+ Compare the auth portion of two sids.
*****************************************************************/
-int sid_compare_domain(const DOM_SID *sid1, const DOM_SID *sid2)
+int sid_compare_auth(const DOM_SID *sid1, const DOM_SID *sid2)
{
int i;
@@ -570,9 +580,25 @@ int sid_compare(const DOM_SID *sid1, const DOM_SID *sid2)
if (sid1->sub_auths[i] != sid2->sub_auths[i])
return sid1->sub_auths[i] - sid2->sub_auths[i];
- return sid_compare_domain(sid1, sid2);
+ return sid_compare_auth(sid1, sid2);
}
+/*****************************************************************
+see if 2 SIDs are in the same domain
+this just compares the leading sub-auths
+*****************************************************************/
+int sid_compare_domain(const DOM_SID *sid1, const DOM_SID *sid2)
+{
+ int n, i;
+
+ n = MIN(sid1->num_auths, sid2->num_auths);
+
+ for (i = n-1; i >= 0; --i)
+ if (sid1->sub_auths[i] != sid2->sub_auths[i])
+ return sid1->sub_auths[i] - sid2->sub_auths[i];
+
+ return sid_compare_auth(sid1, sid2);
+}
/*****************************************************************
Compare two sids.