2 Unix SMB/CIFS implementation.
3 Samba utility functions
4 Copyright (C) Andrew Tridgell 1992-1998
5 Copyright (C) Luke Kenneth Caseson Leighton 1998-1999
6 Copyright (C) Jeremy Allison 1999
7 Copyright (C) Stefan (metze) Metzmacher 2002
8 Copyright (C) Simo Sorce 2002
10 This program is free software; you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation; either version 2 of the License, or
13 (at your option) any later version.
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
27 /*****************************************************************
28 Compare the auth portion of two sids.
29 *****************************************************************/
31 static int sid_compare_auth(const struct dom_sid *sid1, const struct dom_sid *sid2)
42 if (sid1->sid_rev_num != sid2->sid_rev_num)
43 return sid1->sid_rev_num - sid2->sid_rev_num;
45 for (i = 0; i < 6; i++)
46 if (sid1->id_auth[i] != sid2->id_auth[i])
47 return sid1->id_auth[i] - sid2->id_auth[i];
52 /*****************************************************************
54 *****************************************************************/
56 static int sid_compare(const struct dom_sid *sid1, const struct dom_sid *sid2)
67 /* Compare most likely different rids, first: i.e start at end */
68 if (sid1->num_auths != sid2->num_auths)
69 return sid1->num_auths - sid2->num_auths;
71 for (i = sid1->num_auths-1; i >= 0; --i)
72 if (sid1->sub_auths[i] != sid2->sub_auths[i])
73 return sid1->sub_auths[i] - sid2->sub_auths[i];
75 return sid_compare_auth(sid1, sid2);
78 /*****************************************************************
80 *****************************************************************/
82 BOOL sid_equal(const struct dom_sid *sid1, const struct dom_sid *sid2)
84 return sid_compare(sid1, sid2) == 0;