- Timestamp:
- 04/29/08 16:38:27 (17 years ago)
- Location:
- trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/regfi.h
r108 r109 182 182 typedef struct _regf_sk_rec 183 183 { 184 struct _regf_sk_rec* next;185 struct _regf_sk_rec* prev;186 184 REGF_HBIN* hbin; /* pointer to HBIN record (in memory) containing 187 185 * this nk record … … 215 213 /* link in the other records here */ 216 214 REGF_VK_REC** values; 217 REGF_SK_REC* sec_desc;218 215 REGF_HASH_LIST* subkeys; 219 216 … … 264 261 range_list* hbins; 265 262 range_list* unalloc_cells; 266 lru_cache* sk_recs;267 263 268 264 /* file format information */ … … 295 291 REGF_FILE* f; 296 292 void_stack* key_positions; 293 lru_cache* sk_recs; 297 294 REGF_NK_REC* cur_key; 298 295 uint32 cur_subkey; … … 336 333 const char** path); 337 334 const REGF_NK_REC* regfi_iterator_cur_key(REGFI_ITERATOR* i); 335 const REGF_SK_REC* regfi_iterator_cur_sk(REGFI_ITERATOR* i); 338 336 const REGF_NK_REC* regfi_iterator_first_subkey(REGFI_ITERATOR* i); 339 337 const REGF_NK_REC* regfi_iterator_cur_subkey(REGFI_ITERATOR* i); -
trunk/lib/regfi.c
r108 r109 681 681 682 682 683 683 684 /******************************************************************* 684 685 static REGF_SK_REC* find_sk_record_by_sec_desc( REGF_FILE *file, SEC_DESC *sd ) 686 { 687 REGF_SK_REC *p; 688 689 for ( p=file->sec_desc_list; p; p=p->next ) { 690 if ( sec_desc_equal( p->sec_desc, sd ) ) 691 return p; 692 } 693 694 695 return NULL; 696 } 697 *******************************************************************/ 698 699 /******************************************************************* 700 * TODO: Need to add full key and SK record caching using a 685 * TODO: Need to add full key caching using a 701 686 * custom cache structure. 702 687 *******************************************************************/ 703 REGF_NK_REC* regfi_load_key(REGF_FILE *file, uint32 offset, bool strict)688 REGF_NK_REC* regfi_load_key(REGF_FILE* file, uint32 offset, bool strict) 704 689 { 705 690 REGF_HBIN* hbin; … … 780 765 } 781 766 782 /* get the security descriptor. First look if we have already parsed it */783 if((nk->sk_off!=REGF_OFFSET_NONE)784 && !(nk->sec_desc = (REGF_SK_REC*)lru_cache_find(file->sk_recs,785 &nk->sk_off, 4)))786 {787 sub_hbin = hbin;788 if(!regfi_offset_in_hbin(hbin, nk->sk_off))789 sub_hbin = regfi_lookup_hbin(file, nk->sk_off);790 791 if(sub_hbin == NULL)792 {793 free(nk);794 /* TODO: need convenient way to free nk->values and nk->subkeys deeply795 * in all cases.796 */797 return NULL;798 }799 800 off = nk->sk_off + REGF_BLOCKSIZE;801 max_length = sub_hbin->block_size + sub_hbin->file_off - off;802 nk->sec_desc = regfi_parse_sk(file, off, max_length, true);803 if(strict && nk->sec_desc == NULL)804 {805 free(nk);806 /* TODO: need convenient way to free nk->values and nk->subkeys deeply807 * in all cases.808 */809 return NULL;810 }811 nk->sec_desc->sk_off = nk->sk_off;812 813 lru_cache_update(file->sk_recs, &nk->sk_off, 4, nk->sec_desc);814 }815 816 767 return nk; 817 768 } … … 903 854 } 904 855 905 /* TODO: come up with a better secret. */906 rb->sk_recs = lru_cache_create(127, 0xDEADBEEF, true);907 908 856 rla = true; 909 857 hbin_off = REGF_BLOCKSIZE; … … 942 890 range_list_free(file->unalloc_cells); 943 891 944 lru_cache_destroy(file->sk_recs);945 946 892 free(file); 947 893 … … 1038 984 } 1039 985 986 /* TODO: come up with a better secret. */ 987 ret_val->sk_recs = lru_cache_create(127, 0xDEADBEEF, true); 988 1040 989 ret_val->f = fh; 1041 990 ret_val->cur_key = root; … … 1062 1011 } 1063 1012 1013 lru_cache_destroy(i->sk_recs); 1014 1064 1015 free(i); 1065 1016 } … … 1201 1152 return i->cur_key; 1202 1153 } 1154 1155 1156 /****************************************************************************** 1157 *****************************************************************************/ 1158 const REGF_SK_REC* regfi_iterator_cur_sk(REGFI_ITERATOR* i) 1159 { 1160 REGF_SK_REC* ret_val; 1161 REGF_HBIN* hbin; 1162 uint32 max_length, off; 1163 1164 if(i->cur_key == NULL) 1165 return NULL; 1166 1167 /* First look if we have already parsed it */ 1168 if((i->cur_key->sk_off!=REGF_OFFSET_NONE) 1169 && !(ret_val =(REGF_SK_REC*)lru_cache_find(i->sk_recs, 1170 &i->cur_key->sk_off, 4))) 1171 { 1172 hbin = regfi_lookup_hbin(i->f, i->cur_key->sk_off); 1173 1174 if(hbin == NULL) 1175 return NULL; 1176 1177 off = i->cur_key->sk_off + REGF_BLOCKSIZE; 1178 max_length = hbin->block_size + hbin->file_off - off; 1179 ret_val = regfi_parse_sk(i->f, off, max_length, true); 1180 if(ret_val == NULL) 1181 return NULL; 1182 1183 ret_val->sk_off = i->cur_key->sk_off; 1184 lru_cache_update(i->sk_recs, &i->cur_key->sk_off, 4, ret_val); 1185 } 1186 1187 return ret_val; 1188 } 1189 1203 1190 1204 1191 -
trunk/src/reglookup.c
r107 r109 44 44 45 45 /* Other globals */ 46 REGF_FILE* f; 46 47 const char* key_special_chars = ",\"\\/"; 47 48 const char* subfield_special_chars = ",\"\\|"; … … 621 622 622 623 623 void printKey( const REGF_NK_REC* k, char* full_path)624 void printKey(REGFI_ITERATOR* i, char* full_path) 624 625 { 625 626 static char empty_str[1] = ""; … … 631 632 time_t tmp_time[1]; 632 633 struct tm* tmp_time_s = NULL; 634 const REGF_SK_REC* sk; 635 const REGF_NK_REC* k = regfi_iterator_cur_key(i); 633 636 634 637 *tmp_time = nt_time_to_unix(&k->mtime); … … 636 639 strftime(mtime, sizeof(mtime), "%Y-%m-%d %H:%M:%S", tmp_time_s); 637 640 638 if(print_security )639 { 640 owner = regfi_get_owner( k->sec_desc->sec_desc);641 group = regfi_get_group( k->sec_desc->sec_desc);642 sacl = regfi_get_sacl( k->sec_desc->sec_desc);643 dacl = regfi_get_dacl( k->sec_desc->sec_desc);641 if(print_security && (sk=regfi_iterator_cur_sk(i))) 642 { 643 owner = regfi_get_owner(sk->sec_desc); 644 group = regfi_get_group(sk->sec_desc); 645 sacl = regfi_get_sacl(sk->sec_desc); 646 dacl = regfi_get_dacl(sk->sec_desc); 644 647 if(owner == NULL) 645 648 owner = empty_str; … … 692 695 693 696 if(!type_filter_enabled || (key_type == type_filter)) 694 printKey( cur, path);697 printKey(iter, path); 695 698 if(!type_filter_enabled || (key_type != type_filter)) 696 699 printValueList(iter, path); … … 838 841 { 839 842 char** path = NULL; 840 REGF_FILE* f;841 843 REGFI_ITERATOR* iter; 842 844 int retr_path_ret;
Note: See TracChangeset
for help on using the changeset viewer.