Lines Matching refs:sid
48 smb_sid_isvalid(smb_sid_t *sid) in smb_sid_isvalid() argument
50 if (sid == NULL) in smb_sid_isvalid()
53 return ((sid->sid_revision == NT_SID_REVISION) && in smb_sid_isvalid()
54 (sid->sid_subauthcnt <= NT_SID_SUBAUTH_MAX)); in smb_sid_isvalid()
63 smb_sid_len(smb_sid_t *sid) in smb_sid_len() argument
65 if (sid == NULL) in smb_sid_len()
69 + (sid->sid_subauthcnt * sizeof (uint32_t))); in smb_sid_len()
80 smb_sid_dup(smb_sid_t *sid) in smb_sid_dup() argument
85 if (sid == NULL) in smb_sid_dup()
88 size = smb_sid_len(sid); in smb_sid_dup()
92 bcopy(sid, new_sid, size); in smb_sid_dup()
107 smb_sid_t *sid; in smb_sid_splice() local
114 if ((sid = smb_sid_alloc(size + sizeof (rid))) == NULL) in smb_sid_splice()
117 bcopy(domain_sid, sid, size); in smb_sid_splice()
119 sid->sid_subauth[domain_sid->sid_subauthcnt] = rid; in smb_sid_splice()
120 ++sid->sid_subauthcnt; in smb_sid_splice()
122 return (sid); in smb_sid_splice()
133 smb_sid_getrid(smb_sid_t *sid, uint32_t *rid) in smb_sid_getrid() argument
135 if (!smb_sid_isvalid(sid) || (rid == NULL) || in smb_sid_getrid()
136 (sid->sid_subauthcnt == 0)) in smb_sid_getrid()
139 *rid = sid->sid_subauth[sid->sid_subauthcnt - 1]; in smb_sid_getrid()
152 smb_sid_split(smb_sid_t *sid, uint32_t *rid) in smb_sid_split() argument
157 if (!smb_sid_isvalid(sid) || (sid->sid_subauthcnt == 0)) in smb_sid_split()
164 size = smb_sid_len(sid) - sizeof (uint32_t); in smb_sid_split()
168 bcopy(sid, domsid, size); in smb_sid_split()
169 domsid->sid_subauthcnt = sid->sid_subauthcnt - 1; in smb_sid_split()
172 *rid = sid->sid_subauth[sid->sid_subauthcnt - 1]; in smb_sid_split()
246 smb_sid_indomain(smb_sid_t *domain_sid, smb_sid_t *sid) in smb_sid_indomain() argument
250 if (sid == NULL || domain_sid == NULL) in smb_sid_indomain()
253 if (domain_sid->sid_revision != sid->sid_revision || in smb_sid_indomain()
254 sid->sid_subauthcnt < domain_sid->sid_subauthcnt) in smb_sid_indomain()
258 if (domain_sid->sid_subauth[i] != sid->sid_subauth[i]) in smb_sid_indomain()
261 if (bcmp(&domain_sid->sid_authority, &sid->sid_authority, in smb_sid_indomain()
275 smb_sid_tostr(const smb_sid_t *sid, char *strsid) in smb_sid_tostr() argument
280 if (sid == NULL || strsid == NULL) in smb_sid_tostr()
283 (void) sprintf(p, "S-%d-", sid->sid_revision); in smb_sid_tostr()
288 if (sid->sid_authority[i] != 0 || i == NT_SID_AUTH_MAX - 1) { in smb_sid_tostr()
289 (void) sprintf(p, "%d", sid->sid_authority[i]); in smb_sid_tostr()
295 for (i = 0; i < sid->sid_subauthcnt && i < NT_SID_SUBAUTH_MAX; ++i) { in smb_sid_tostr()
296 (void) sprintf(p, "-%u", sid->sid_subauth[i]); in smb_sid_tostr()
320 smb_sid_t *sid; in smb_sid_fromstr() local
348 sid = kmem_zalloc(size, KM_SLEEP); in smb_sid_fromstr()
349 sid->sid_revision = NT_SID_REVISION; in smb_sid_fromstr()
350 sid->sid_authority[5] = (uint8_t)sua; in smb_sid_fromstr()
363 sid->sid_subauth[i] = (uint32_t)sua; in smb_sid_fromstr()
369 sid->sid_subauthcnt = i; in smb_sid_fromstr()
370 retsid = smb_sid_dup(sid); in smb_sid_fromstr()
373 kmem_free(sid, size); in smb_sid_fromstr()
380 smb_sid_t *sid; in smb_sid_fromstr() local
407 if ((sid = calloc(size, 1)) == NULL) in smb_sid_fromstr()
410 sid->sid_revision = NT_SID_REVISION; in smb_sid_fromstr()
411 sid->sid_authority[5] = (uint8_t)sua; in smb_sid_fromstr()
418 free(sid); in smb_sid_fromstr()
422 sid->sid_subauth[i] = strtoul(p, (char **)&p, 10); in smb_sid_fromstr()
424 free(sid); in smb_sid_fromstr()
429 sid->sid_subauthcnt = i; in smb_sid_fromstr()
430 return (sid); in smb_sid_fromstr()
467 smb_sid_t *sid; in smb_sid_alloc() local
469 sid = kmem_alloc(size, KM_SLEEP); in smb_sid_alloc()
471 sid = malloc(size); in smb_sid_alloc()
473 return (sid); in smb_sid_alloc()
477 smb_sid_free(smb_sid_t *sid) in smb_sid_free() argument
480 if (sid == NULL) in smb_sid_free()
483 kmem_free(sid, smb_sid_len(sid)); in smb_sid_free()
485 free(sid); in smb_sid_free()