/*
- * Unix SMB/CIFS implementation.
+ * Unix SMB/Netbios implementation.
+ * Version 1.9.
* RPC Pipe client / server routines
* Copyright (C) Andrew Tridgell 1992-1998,
* Copyright (C) Jeremy R. Allison 1995-1998
Reads or writes a SEC_ACCESS structure.
********************************************************************/
-BOOL sec_io_access(char *desc, SEC_ACCESS *t, prs_struct *ps, int depth)
+BOOL sec_io_access(const char *desc, SEC_ACCESS *t, prs_struct *ps, int depth)
{
if (t == NULL)
return False;
prs_debug(ps, depth, desc, "sec_io_access");
depth++;
-
- if(!prs_align(ps))
- return False;
if(!prs_uint32("mask", ps, depth, &(t->mask)))
return False;
Reads or writes a SEC_ACE structure.
********************************************************************/
-BOOL sec_io_ace(char *desc, SEC_ACE *psa, prs_struct *ps, int depth)
+BOOL sec_io_ace(const char *desc, SEC_ACE *psa, prs_struct *ps, int depth)
{
uint32 old_offset;
uint32 offset_ace_size;
prs_debug(ps, depth, desc, "sec_io_ace");
depth++;
-
- if(!prs_align(ps))
- return False;
old_offset = prs_offset(ps);
if(!sec_io_access("info ", &psa->info, ps, depth))
return False;
- if(!prs_align(ps))
- return False;
-
/* check whether object access is present */
if (!sec_ace_object(psa->type)) {
if (!smb_io_dom_sid("trustee ", &psa->trustee , ps, depth))
adds new SID with its permissions to ACE list
********************************************************************/
-NTSTATUS sec_ace_add_sid(TALLOC_CTX *ctx, SEC_ACE **new, SEC_ACE *old, size_t *num, DOM_SID *sid, uint32 mask)
+NTSTATUS sec_ace_add_sid(TALLOC_CTX *ctx, SEC_ACE **new, SEC_ACE *old, unsigned *num, DOM_SID *sid, uint32 mask)
{
- int i = 0;
+ unsigned int i = 0;
if (!ctx || !new || !old || !sid || !num) return NT_STATUS_INVALID_PARAMETER;
*num += 1;
- if((new[0] = (SEC_ACE *) talloc_zero(ctx, *num * sizeof(SEC_ACE))) == 0)
+ if((new[0] = (SEC_ACE *) talloc_zero(ctx, (*num) * sizeof(SEC_ACE))) == 0)
return NT_STATUS_NO_MEMORY;
for (i = 0; i < *num - 1; i ++)
NTSTATUS sec_ace_mod_sid(SEC_ACE *ace, size_t num, DOM_SID *sid, uint32 mask)
{
- int i = 0;
+ unsigned int i = 0;
if (!ace || !sid) return NT_STATUS_INVALID_PARAMETER;
delete SID from ACL
********************************************************************/
-NTSTATUS sec_ace_del_sid(TALLOC_CTX *ctx, SEC_ACE **new, SEC_ACE *old, size_t *num, DOM_SID *sid)
+static NTSTATUS sec_ace_del_sid(TALLOC_CTX *ctx, SEC_ACE **new, SEC_ACE *old, uint32 *num, DOM_SID *sid)
{
- int i = 0;
- int n_del = 0;
+ unsigned int i = 0;
+ unsigned int n_del = 0;
if (!ctx || !new || !old || !sid || !num) return NT_STATUS_INVALID_PARAMETER;
- if((new[0] = (SEC_ACE *) talloc_zero(ctx, *num * sizeof(SEC_ACE))) == 0)
+ if((new[0] = (SEC_ACE *) talloc_zero(ctx, (*num) * sizeof(SEC_ACE))) == 0)
return NT_STATUS_NO_MEMORY;
for (i = 0; i < *num; i ++) {
for you as it reads them.
********************************************************************/
-BOOL sec_io_acl(char *desc, SEC_ACL **ppsa, prs_struct *ps, int depth)
+BOOL sec_io_acl(const char *desc, SEC_ACL **ppsa, prs_struct *ps, int depth)
{
- int i;
+ unsigned int i;
uint32 old_offset;
uint32 offset_acl_size;
SEC_ACL *psa;
+ /*
+ * Note that the size is always a multiple of 4 bytes due to the
+ * nature of the data structure. Therefore the prs_align() calls
+ * have been removed as they through us off when doing two-layer
+ * marshalling such as in the printing code (NEW_BUFFER). --jerry
+ */
+
if (ppsa == NULL)
return False;
prs_debug(ps, depth, desc, "sec_io_acl");
depth++;
-
- if(!prs_align(ps))
- return False;
old_offset = prs_offset(ps);
return False;
}
- if(!prs_align(ps))
- return False;
-
if(!prs_uint16_post("size ", ps, depth, &psa->size, offset_acl_size, old_offset))
return False;
offset = SEC_DESC_HEADER_SIZE;
+ /* don't align */
+
if (psd->owner_sid != NULL)
- offset += ((sid_size(psd->owner_sid) + 3) & ~3);
+ offset += sid_size(psd->owner_sid);
if (psd->grp_sid != NULL)
- offset += ((sid_size(psd->grp_sid) + 3) & ~3);
+ offset += sid_size(psd->grp_sid);
if (psd->sacl != NULL)
- offset += ((psd->sacl->size + 3) & ~3);
+ offset += psd->sacl->size;
if (psd->dacl != NULL)
- offset += ((psd->dacl->size + 3) & ~3);
+ offset += psd->dacl->size;
return offset;
}
BOOL sec_acl_equal(SEC_ACL *s1, SEC_ACL *s2)
{
- int i, j;
+ unsigned int i, j;
/* Trivial cases */
if (offset == 0)
offset = SEC_DESC_HEADER_SIZE;
- offset += ((sid_size(dst->owner_sid) + 3) & ~3);
+ offset += sid_size(dst->owner_sid);
}
if (dst->grp_sid != NULL) {
if (offset == 0)
offset = SEC_DESC_HEADER_SIZE;
- offset += ((sid_size(dst->grp_sid) + 3) & ~3);
+ offset += sid_size(dst->grp_sid);
}
if (dst->sacl != NULL) {
offset_acl = SEC_DESC_HEADER_SIZE;
dst->off_sacl = offset_acl;
- offset_acl += ((dst->sacl->size + 3) & ~3);
+ offset_acl += dst->sacl->size;
offset += dst->sacl->size;
offset_sid += dst->sacl->size;
}
offset_acl = SEC_DESC_HEADER_SIZE;
dst->off_dacl = offset_acl;
- offset_acl += ((dst->dacl->size + 3) & ~3);
+ offset_acl += dst->dacl->size;
offset += dst->dacl->size;
offset_sid += dst->dacl->size;
}
*sd_size = (size_t)((offset == 0) ? SEC_DESC_HEADER_SIZE : offset);
- if (dst->owner_sid != NULL) {
+ if (dst->owner_sid != NULL)
dst->off_owner_sid = offset_sid;
+
+ /* sid_size() returns 0 if the sid is NULL so this is ok */
+
+ if (dst->grp_sid != NULL)
dst->off_grp_sid = offset_sid + sid_size(dst->owner_sid);
- }
- else
- if (dst->grp_sid != NULL)
- dst->off_grp_sid = offset_sid;
return dst;
If reading and the *ppsd = NULL, allocates the structure.
********************************************************************/
-BOOL sec_io_desc(char *desc, SEC_DESC **ppsd, prs_struct *ps, int depth)
+BOOL sec_io_desc(const char *desc, SEC_DESC **ppsd, prs_struct *ps, int depth)
{
uint32 old_offset;
uint32 max_offset = 0; /* after we're done, move offset to end */
prs_debug(ps, depth, desc, "sec_io_desc");
depth++;
-#if 0 /* JERRY */
+#if 0
/*
* if alignment is needed, should be done by the the
* caller. Not here. This caused me problems when marshalling
if (psd->off_owner_sid != 0) {
+ tmp_offset = prs_offset(ps);
+ if(!prs_set_offset(ps, old_offset + psd->off_owner_sid))
+ return False;
+
if (UNMARSHALLING(ps)) {
- if(!prs_set_offset(ps, old_offset + psd->off_owner_sid))
- return False;
/* reading */
if((psd->owner_sid = (DOM_SID *)prs_alloc_mem(ps,sizeof(*psd->owner_sid))) == NULL)
return False;
}
- tmp_offset = ps->data_offset;
- ps->data_offset = psd->off_owner_sid;
-
if(!smb_io_dom_sid("owner_sid ", psd->owner_sid , ps, depth))
return False;
- if(!prs_align(ps))
- return False;
- ps->data_offset = tmp_offset;
- }
+ max_offset = MAX(max_offset, prs_offset(ps));
- max_offset = MAX(max_offset, prs_offset(ps));
+ if (!prs_set_offset(ps,tmp_offset))
+ return False;
+ }
if (psd->off_grp_sid != 0) {
+ tmp_offset = prs_offset(ps);
+ if(!prs_set_offset(ps, old_offset + psd->off_grp_sid))
+ return False;
+
if (UNMARSHALLING(ps)) {
/* reading */
- if(!prs_set_offset(ps, old_offset + psd->off_grp_sid))
- return False;
if((psd->grp_sid = (DOM_SID *)prs_alloc_mem(ps,sizeof(*psd->grp_sid))) == NULL)
return False;
}
- tmp_offset = ps->data_offset;
- ps->data_offset = psd->off_grp_sid;
-
if(!smb_io_dom_sid("grp_sid", psd->grp_sid, ps, depth))
return False;
- if(!prs_align(ps))
- return False;
+
+ max_offset = MAX(max_offset, prs_offset(ps));
- ps->data_offset = tmp_offset;
+ if (!prs_set_offset(ps,tmp_offset))
+ return False;
}
- max_offset = MAX(max_offset, prs_offset(ps));
-
if ((psd->type & SEC_DESC_SACL_PRESENT) && psd->off_sacl) {
+ tmp_offset = prs_offset(ps);
if(!prs_set_offset(ps, old_offset + psd->off_sacl))
return False;
if(!sec_io_acl("sacl", &psd->sacl, ps, depth))
return False;
- if(!prs_align(ps))
+ max_offset = MAX(max_offset, prs_offset(ps));
+ if (!prs_set_offset(ps,tmp_offset))
return False;
}
- max_offset = MAX(max_offset, prs_offset(ps));
if ((psd->type & SEC_DESC_DACL_PRESENT) && psd->off_dacl != 0) {
+ tmp_offset = prs_offset(ps);
if(!prs_set_offset(ps, old_offset + psd->off_dacl))
return False;
if(!sec_io_acl("dacl", &psd->dacl, ps, depth))
return False;
- if(!prs_align(ps))
+ max_offset = MAX(max_offset, prs_offset(ps));
+ if (!prs_set_offset(ps,tmp_offset))
return False;
}
- max_offset = MAX(max_offset, prs_offset(ps));
-
if(!prs_set_offset(ps, max_offset))
return False;
return True;
Reads or writes a SEC_DESC_BUF structure.
********************************************************************/
-BOOL sec_io_desc_buf(char *desc, SEC_DESC_BUF **ppsdb, prs_struct *ps, int depth)
+BOOL sec_io_desc_buf(const char *desc, SEC_DESC_BUF **ppsdb, prs_struct *ps, int depth)
{
uint32 off_len;
uint32 off_max_len;