From 279276c9ca0106e4191e170a442b871543c034ac Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 19 Dec 2001 08:37:03 +0000 Subject: fixed sid_compare_domain() (This used to be commit c11c27b2812ceb06a52afbb7662f82a8676b1707) --- source3/lib/util_sid.c | 32 +++++++++++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-) (limited to 'source3/lib/util_sid.c') diff --git a/source3/lib/util_sid.c b/source3/lib/util_sid.c index 1e0feac049c..009cc7742af 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. -- cgit