mirror of
https://github.com/samba-team/samba.git
synced 2025-08-03 04:22:09 +03:00
Remove tiny code duplication
sid_size did the same as ndr_size_dom_sid
(This used to be commit 8aec5d09ba
)
This commit is contained in:
@ -59,7 +59,7 @@ void init_sec_ace(SEC_ACE *t, const DOM_SID *sid, enum security_ace_type type,
|
||||
{
|
||||
t->type = type;
|
||||
t->flags = flag;
|
||||
t->size = sid_size(sid) + 8;
|
||||
t->size = ndr_size_dom_sid(sid, 0) + 8;
|
||||
t->access_mask = mask;
|
||||
|
||||
ZERO_STRUCTP(&t->trustee);
|
||||
@ -86,7 +86,7 @@ NTSTATUS sec_ace_add_sid(TALLOC_CTX *ctx, SEC_ACE **pp_new, SEC_ACE *old, unsign
|
||||
|
||||
(*pp_new)[i].type = SEC_ACE_TYPE_ACCESS_ALLOWED;
|
||||
(*pp_new)[i].flags = 0;
|
||||
(*pp_new)[i].size = SEC_ACE_HEADER_SIZE + sid_size(sid);
|
||||
(*pp_new)[i].size = SEC_ACE_HEADER_SIZE + ndr_size_dom_sid(sid, 0);
|
||||
(*pp_new)[i].access_mask = mask;
|
||||
sid_copy(&(*pp_new)[i].trustee, sid);
|
||||
return NT_STATUS_OK;
|
||||
|
@ -46,10 +46,10 @@ size_t sec_desc_size(SEC_DESC *psd)
|
||||
/* don't align */
|
||||
|
||||
if (psd->owner_sid != NULL)
|
||||
offset += sid_size(psd->owner_sid);
|
||||
offset += ndr_size_dom_sid(psd->owner_sid, 0);
|
||||
|
||||
if (psd->group_sid != NULL)
|
||||
offset += sid_size(psd->group_sid);
|
||||
offset += ndr_size_dom_sid(psd->group_sid, 0);
|
||||
|
||||
if (psd->sacl != NULL)
|
||||
offset += psd->sacl->size;
|
||||
@ -235,11 +235,11 @@ SEC_DESC *make_sec_desc(TALLOC_CTX *ctx,
|
||||
}
|
||||
|
||||
if (dst->owner_sid != NULL) {
|
||||
offset += sid_size(dst->owner_sid);
|
||||
offset += ndr_size_dom_sid(dst->owner_sid, 0);
|
||||
}
|
||||
|
||||
if (dst->group_sid != NULL) {
|
||||
offset += sid_size(dst->group_sid);
|
||||
offset += ndr_size_dom_sid(dst->group_sid, 0);
|
||||
}
|
||||
|
||||
*sd_size = (size_t)offset;
|
||||
|
@ -382,7 +382,7 @@ bool sid_linearize(char *outbuf, size_t len, const DOM_SID *sid)
|
||||
{
|
||||
size_t i;
|
||||
|
||||
if (len < sid_size(sid))
|
||||
if (len < ndr_size_dom_sid(sid, 0))
|
||||
return False;
|
||||
|
||||
SCVAL(outbuf,0,sid->sid_rev_num);
|
||||
@ -494,18 +494,6 @@ bool sid_equal(const DOM_SID *sid1, const DOM_SID *sid2)
|
||||
return sid_compare(sid1, sid2) == 0;
|
||||
}
|
||||
|
||||
/*****************************************************************
|
||||
Calculates size of a sid.
|
||||
*****************************************************************/
|
||||
|
||||
size_t sid_size(const DOM_SID *sid)
|
||||
{
|
||||
if (sid == NULL)
|
||||
return 0;
|
||||
|
||||
return sid->num_auths * sizeof(uint32) + 8;
|
||||
}
|
||||
|
||||
/*****************************************************************
|
||||
Returns true if SID is internal (and non-mappable).
|
||||
*****************************************************************/
|
||||
@ -535,7 +523,7 @@ bool non_mappable_sid(DOM_SID *sid)
|
||||
char *sid_binstring(const DOM_SID *sid)
|
||||
{
|
||||
char *buf, *s;
|
||||
int len = sid_size(sid);
|
||||
int len = ndr_size_dom_sid(sid, 0);
|
||||
buf = (char *)SMB_MALLOC(len);
|
||||
if (!buf)
|
||||
return NULL;
|
||||
@ -553,7 +541,7 @@ char *sid_binstring(const DOM_SID *sid)
|
||||
char *sid_binstring_hex(const DOM_SID *sid)
|
||||
{
|
||||
char *buf, *s;
|
||||
int len = sid_size(sid);
|
||||
int len = ndr_size_dom_sid(sid, 0);
|
||||
buf = (char *)SMB_MALLOC(len);
|
||||
if (!buf)
|
||||
return NULL;
|
||||
|
@ -150,7 +150,7 @@ bool cli_get_user_quota(struct cli_state *cli, int quota_fnum, SMB_NTQUOTA_STRUC
|
||||
SIVAL(params, 8,0x00000000);
|
||||
SIVAL(params,12,0x00000024);
|
||||
|
||||
sid_len = sid_size(&pqt->sid);
|
||||
sid_len = ndr_size_dom_sid(&pqt->sid, 0);
|
||||
data_len = sid_len+8;
|
||||
SIVAL(data, 0, 0x00000000);
|
||||
SIVAL(data, 4, sid_len);
|
||||
@ -213,7 +213,7 @@ bool cli_set_user_quota(struct cli_state *cli, int quota_fnum, SMB_NTQUOTA_STRUC
|
||||
|
||||
SSVAL(params,0,quota_fnum);
|
||||
|
||||
sid_len = sid_size(&pqt->sid);
|
||||
sid_len = ndr_size_dom_sid(&pqt->sid, 0);
|
||||
SIVAL(data,0,0);
|
||||
SIVAL(data,4,sid_len);
|
||||
SBIG_UINT(data, 8,(SMB_BIG_UINT)0);
|
||||
|
@ -291,14 +291,14 @@ bool sec_io_desc(const char *desc, SEC_DESC **ppsd, prs_struct *ps, int depth)
|
||||
|
||||
if (psd->owner_sid != NULL) {
|
||||
off_owner_sid = offset;
|
||||
offset += sid_size(psd->owner_sid);
|
||||
offset += ndr_size_dom_sid(psd->owner_sid, 0);
|
||||
} else {
|
||||
off_owner_sid = 0;
|
||||
}
|
||||
|
||||
if (psd->group_sid != NULL) {
|
||||
off_grp_sid = offset;
|
||||
offset += sid_size(psd->group_sid);
|
||||
offset += ndr_size_dom_sid(psd->group_sid, 0);
|
||||
} else {
|
||||
off_grp_sid = 0;
|
||||
}
|
||||
|
@ -2174,7 +2174,8 @@ static void call_nt_transact_get_user_quota(connection_struct *conn,
|
||||
for (;((tmp_list!=NULL)&&((qt_len +40+SID_MAX_SIZE)<max_data_count));
|
||||
tmp_list=tmp_list->next,entry+=entry_len,qt_len+=entry_len) {
|
||||
|
||||
sid_len = sid_size(&tmp_list->quotas->sid);
|
||||
sid_len = ndr_size_dom_sid(
|
||||
&tmp_list->quotas->sid, 0);
|
||||
entry_len = 40 + sid_len;
|
||||
|
||||
/* nextoffset entry 4 bytes */
|
||||
|
@ -2897,8 +2897,8 @@ cBytesSector=%u, cUnitTotal=%u, cUnitAvail=%d\n", (unsigned int)bsize, (unsigned
|
||||
*/
|
||||
for (i = 0, sid_bytes = 0;
|
||||
i < current_user.nt_user_token->num_sids; ++i) {
|
||||
sid_bytes +=
|
||||
sid_size(¤t_user.nt_user_token->user_sids[i]);
|
||||
sid_bytes += ndr_size_dom_sid(
|
||||
¤t_user.nt_user_token->user_sids[i], 0);
|
||||
}
|
||||
|
||||
/* SID list byte count */
|
||||
@ -2918,8 +2918,8 @@ cBytesSector=%u, cUnitTotal=%u, cUnitAvail=%d\n", (unsigned int)bsize, (unsigned
|
||||
/* SID list */
|
||||
for (i = 0;
|
||||
i < current_user.nt_user_token->num_sids; ++i) {
|
||||
int sid_len =
|
||||
sid_size(¤t_user.nt_user_token->user_sids[i]);
|
||||
int sid_len = ndr_size_dom_sid(
|
||||
¤t_user.nt_user_token->user_sids[i], 0);
|
||||
|
||||
sid_linearize(pdata + data_len, sid_len,
|
||||
¤t_user.nt_user_token->user_sids[i]);
|
||||
|
@ -978,6 +978,7 @@ static bool send_getdc_request(struct sockaddr_storage *dc_ss,
|
||||
char *p;
|
||||
fstring my_acct_name;
|
||||
fstring my_mailslot;
|
||||
size_t sid_size;
|
||||
|
||||
if (dc_ss->ss_family != AF_INET) {
|
||||
return false;
|
||||
@ -1019,7 +1020,9 @@ static bool send_getdc_request(struct sockaddr_storage *dc_ss,
|
||||
SIVAL(p, 0, 0x80);
|
||||
p+=4;
|
||||
|
||||
SIVAL(p, 0, sid_size(sid));
|
||||
sid_size = ndr_size_dom_sid(sid, 0);
|
||||
|
||||
SIVAL(p, 0, sid_size);
|
||||
p+=4;
|
||||
|
||||
p = ALIGN4(p, outbuf);
|
||||
@ -1027,12 +1030,12 @@ static bool send_getdc_request(struct sockaddr_storage *dc_ss,
|
||||
return false;
|
||||
}
|
||||
|
||||
sid_linearize(p, sid_size(sid), sid);
|
||||
if (sid_size(sid) + 8 > sizeof(outbuf) - PTR_DIFF(p, outbuf)) {
|
||||
sid_linearize(p, sid_size, sid);
|
||||
if (sid_size + 8 > sizeof(outbuf) - PTR_DIFF(p, outbuf)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
p += sid_size(sid);
|
||||
p += sid_size;
|
||||
|
||||
SIVAL(p, 0, 1);
|
||||
SSVAL(p, 4, 0xffff);
|
||||
|
Reference in New Issue
Block a user