Changeset 253 for trunk/lib


Ignore:
Timestamp:
06/12/11 22:27:42 (13 years ago)
Author:
tim
Message:

added preliminary interface to security descriptors in pyregfi
misc bug fixes

Location:
trunk/lib
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/regfi.c

    r252 r253  
    403403
    404404
    405 char* regfi_sid2str(WINSEC_DOM_SID* sid)
    406 {
    407   uint32_t i, size = WINSEC_MAX_SUBAUTHS*11 + 24;
    408   uint32_t left = size;
    409   uint8_t comps = sid->num_auths;
    410   char* ret_val = malloc(size);
    411  
    412   if(ret_val == NULL)
    413     return NULL;
    414 
    415   if(comps > WINSEC_MAX_SUBAUTHS)
    416     comps = WINSEC_MAX_SUBAUTHS;
    417 
    418   left -= sprintf(ret_val, "S-%u-%u", sid->sid_rev_num, sid->id_auth[5]);
    419 
    420   for (i = 0; i < comps; i++)
    421     left -= snprintf(ret_val+(size-left), left, "-%u", sid->sub_auths[i]);
    422 
    423   return ret_val;
    424 }
    425 
    426 
    427405char* regfi_get_acl(WINSEC_ACL* acl)
    428406{
     
    440418  for (i = 0; i < acl->num_aces && !failed; i++)
    441419  {
    442     sid_str = regfi_sid2str(acl->aces[i]->trustee);
     420    sid_str = winsec_sid2str(acl->aces[i]->trustee);
    443421    type_str = regfi_ace_type2str(acl->aces[i]->type);
    444422    perms_str = regfi_ace_perms2str(acl->aces[i]->access_mask);
     
    505483char* regfi_get_owner(WINSEC_DESC *sec_desc)
    506484{
    507   return regfi_sid2str(sec_desc->owner_sid);
     485  return winsec_sid2str(sec_desc->owner_sid);
    508486}
    509487
     
    511489char* regfi_get_group(WINSEC_DESC *sec_desc)
    512490{
    513   return regfi_sid2str(sec_desc->grp_sid);
     491  return winsec_sid2str(sec_desc->grp_sid);
    514492}
    515493
     
    15001478    }
    15011479  }
     1480  else
     1481    ret_val = talloc_reference(NULL, ret_val);
    15021482
    15031483 unlock:
     
    20672047
    20682048  return regfi_load_sk(file, key->sk_off + REGFI_REGF_SIZE, true);
     2049}
     2050
     2051
     2052/******************************************************************************
     2053 *****************************************************************************/
     2054const REGFI_SK* regfi_next_sk(REGFI_FILE* file, const REGFI_SK* sk)
     2055{
     2056  if(sk == NULL || sk->next_sk_off == REGFI_OFFSET_NONE)
     2057    return NULL;
     2058
     2059  return regfi_load_sk(file, sk->next_sk_off + REGFI_REGF_SIZE, true);
     2060}
     2061
     2062
     2063/******************************************************************************
     2064 *****************************************************************************/
     2065const REGFI_SK* regfi_prev_sk(REGFI_FILE* file, const REGFI_SK* sk)
     2066{
     2067  if(sk == NULL || sk->prev_sk_off == REGFI_OFFSET_NONE)
     2068    return NULL;
     2069
     2070  return regfi_load_sk(file, sk->prev_sk_off + REGFI_REGF_SIZE, true);
    20692071}
    20702072
  • trunk/lib/winsec.c

    r169 r253  
    226226  ret_val->size = SVAL(buf, 0x2);
    227227  ret_val->access_mask = IVAL(buf, 0x4);
    228 
     228  ret_val->obj_guid = NULL;
     229  ret_val->inh_guid = NULL;
     230 
    229231  offset = 0x8;
    230232
     
    246248      offset += sizeof(WINSEC_UUID);
    247249    }
    248     else
    249       ret_val->obj_guid = NULL;
    250250
    251251    if(ret_val->obj_flags & WINSEC_ACE_OBJECT_INHERITED_PRESENT)
     
    260260      offset += sizeof(WINSEC_UUID);
    261261    }
    262     else
    263       ret_val->inh_guid = NULL;
    264262  }
    265263
     
    410408
    411409/******************************************************************************
     410 ******************************************************************************/
     411char* winsec_sid2str(const WINSEC_DOM_SID* sid)
     412{
     413  uint32_t i, size = WINSEC_MAX_SUBAUTHS*11 + 24;
     414  uint32_t left = size;
     415  uint8_t comps = sid->num_auths;
     416  char* ret_val = malloc(size);
     417 
     418  if(ret_val == NULL)
     419    return NULL;
     420
     421  if(comps > WINSEC_MAX_SUBAUTHS)
     422    comps = WINSEC_MAX_SUBAUTHS;
     423
     424  left -= sprintf(ret_val, "S-%u-%u", sid->sid_rev_num, sid->id_auth[5]);
     425
     426  for (i = 0; i < comps; i++)
     427    left -= snprintf(ret_val+(size-left), left, "-%u", sid->sub_auths[i]);
     428
     429  return ret_val;
     430}
     431
     432
     433/******************************************************************************
    412434 * Compares two WINSEC_DESC structures.
    413435 ******************************************************************************/
Note: See TracChangeset for help on using the changeset viewer.