- Timestamp:
- 09/04/05 17:04:58 (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/reglookup.c
r52 r53 146 146 { 147 147 case REG_SZ: 148 if (print_verbose)149 fprintf(stderr, "Len: %d\n", len);150 151 148 ascii_max = sizeof(char)*len; 152 149 ascii = malloc(ascii_max+4); … … 263 260 264 261 return NULL; 265 }266 267 268 /* Security descriptor print functions */269 /* XXX: these functions should be moved out into regfio library */270 const char* ace_type2str(uint8 type)271 {272 static const char* map[7]273 = {"ALLOW", "DENY", "AUDIT", "ALARM",274 "ALLOW CPD", "OBJ ALLOW", "OBJ DENY"};275 if(type < 7)276 return map[type];277 else278 return "UNKNOWN";279 }280 281 282 char* ace_flags2str(uint8 flags)283 {284 char* flg_output = malloc(21*sizeof(char));285 int some = 0;286 287 if(flg_output == NULL)288 return NULL;289 290 flg_output[0] = '\0';291 if (!flags)292 return flg_output;293 294 if (flags & 0x01) {295 if (some) strcat(flg_output, " ");296 some = 1;297 strcat(flg_output, "OI");298 }299 if (flags & 0x02) {300 if (some) strcat(flg_output, " ");301 some = 1;302 strcat(flg_output, "CI");303 }304 if (flags & 0x04) {305 if (some) strcat(flg_output, " ");306 some = 1;307 strcat(flg_output, "NP");308 }309 if (flags & 0x08) {310 if (some) strcat(flg_output, " ");311 some = 1;312 strcat(flg_output, "IO");313 }314 if (flags & 0x10) {315 if (some) strcat(flg_output, " ");316 some = 1;317 strcat(flg_output, "IA");318 }319 if (flags == 0xF) {320 if (some) strcat(flg_output, " ");321 some = 1;322 strcat(flg_output, "VI");323 }324 325 return flg_output;326 }327 328 329 char* ace_perms2str(uint32 perms)330 {331 char* ret_val = malloc(9*sizeof(char));332 sprintf(ret_val, "%.8X", perms);333 334 return ret_val;335 }336 337 338 char* sid2str(DOM_SID* sid)339 {340 uint32 i, size = MAXSUBAUTHS*11 + 24;341 uint32 left = size;342 uint8 comps = sid->num_auths;343 char* ret_val = malloc(size);344 345 if(ret_val == NULL)346 return NULL;347 348 if(comps > MAXSUBAUTHS)349 comps = MAXSUBAUTHS;350 351 left -= sprintf(ret_val, "S-%u-%u", sid->sid_rev_num, sid->id_auth[5]);352 353 for (i = 0; i < comps; i++)354 left -= snprintf(ret_val+(size-left), left, "-%u", sid->sub_auths[i]);355 356 return ret_val;357 }358 359 360 char* get_acl(SEC_ACL* acl)361 {362 uint32 i, extra, size = 0;363 const char* type_str;364 char* flags_str;365 char* perms_str;366 char* sid_str;367 char* ret_val = NULL;368 char* ace_delim = "";369 char field_delim = ':';370 371 for (i = 0; i < acl->num_aces; i++)372 {373 /* XXX: check for NULL */374 sid_str = sid2str(&acl->ace[i].trustee);375 type_str = ace_type2str(acl->ace[i].type);376 perms_str = ace_perms2str(acl->ace[i].info.mask);377 flags_str = ace_flags2str(acl->ace[i].flags);378 379 /* XXX: this is slow */380 extra = strlen(sid_str) + strlen(type_str)381 + strlen(perms_str) + strlen(flags_str)+5;382 ret_val = realloc(ret_val, size+extra);383 if(ret_val == NULL)384 return NULL;385 size += snprintf(ret_val+size, extra, "%s%s%c%s%c%s%c%s",386 ace_delim,sid_str,387 field_delim,type_str,388 field_delim,perms_str,389 field_delim,flags_str);390 ace_delim = "|";391 free(sid_str);392 free(perms_str);393 free(flags_str);394 }395 396 return ret_val;397 }398 399 400 char* get_sacl(SEC_DESC *sec_desc)401 {402 if (sec_desc->sacl)403 return get_acl(sec_desc->sacl);404 else405 return NULL;406 }407 408 409 char* get_dacl(SEC_DESC *sec_desc)410 {411 if (sec_desc->dacl)412 return get_acl(sec_desc->dacl);413 else414 return NULL;415 }416 417 418 char* get_owner(SEC_DESC *sec_desc)419 {420 return sid2str(sec_desc->owner_sid);421 }422 423 424 char* get_group(SEC_DESC *sec_desc)425 {426 return sid2str(sec_desc->grp_sid);427 262 } 428 263 … … 607 442 if(print_security) 608 443 { 609 owner = get_owner(k->sec_desc->sec_desc);610 group = get_group(k->sec_desc->sec_desc);611 sacl = get_sacl(k->sec_desc->sec_desc);612 dacl = get_dacl(k->sec_desc->sec_desc);444 owner = regfio_get_owner(k->sec_desc->sec_desc); 445 group = regfio_get_group(k->sec_desc->sec_desc); 446 sacl = regfio_get_sacl(k->sec_desc->sec_desc); 447 dacl = regfio_get_dacl(k->sec_desc->sec_desc); 613 448 if(owner == NULL) 614 449 owner = empty_str; … … 709 544 uint32 prefix_len; 710 545 char* cur_str = NULL; 546 char* path = NULL; 711 547 bool found_cur = true; 712 548 uint32 i; … … 754 590 && strcasecmp(sub->values[i].valuename, cur_str) == 0) 755 591 { 756 /* XXX: fix mem leak with stack2Path return value */ 757 printValue(&sub->values[i], stack2Path(nk_stack)); 592 path = stack2Path(nk_stack); 593 printValue(&sub->values[i], path); 594 if(path != NULL) 595 free(path); 758 596 return 0; 759 597 } … … 788 626 " <REGISTRY_FILE>\n"); 789 627 /* XXX: replace version string with Subversion property? */ 790 fprintf(stderr, "Version: 0.2 \n");628 fprintf(stderr, "Version: 0.2.1\n"); 791 629 fprintf(stderr, "Options:\n"); 792 630 fprintf(stderr, "\t-v\t sets verbose mode.\n");
Note: See TracChangeset
for help on using the changeset viewer.