- Timestamp:
- 09/04/05 17:04:58 (19 years ago)
- Location:
- trunk/lib
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/lib/regfio.c
r41 r53 29 29 30 30 31 /*******************************************************************32 *33 * TODO : Right now this code basically ignores classnames.34 *35 ******************************************************************/36 37 31 /* Registry types mapping */ 38 32 const VAL_STR reg_type_names[] = … … 79 73 80 74 75 /* Security descriptor parsing functions */ 76 77 const char* regfio_ace_type2str(uint8 type) 78 { 79 static const char* map[7] 80 = {"ALLOW", "DENY", "AUDIT", "ALARM", 81 "ALLOW CPD", "OBJ ALLOW", "OBJ DENY"}; 82 if(type < 7) 83 return map[type]; 84 else 85 /* XXX: would be nice to return the unknown integer value. 86 * However, as it is a const string, it can't be free()ed later on, 87 * so that would need to change. 88 */ 89 return "UNKNOWN"; 90 } 91 92 93 /* XXX: this could probably be more efficient */ 94 char* regfio_ace_flags2str(uint8 flags) 95 { 96 char* flg_output = malloc(21*sizeof(char)); 97 int some = 0; 98 99 if(flg_output == NULL) 100 return NULL; 101 102 flg_output[0] = '\0'; 103 if (!flags) 104 return flg_output; 105 106 if (flags & 0x01) { 107 if (some) strcat(flg_output, " "); 108 some = 1; 109 strcat(flg_output, "OI"); 110 } 111 if (flags & 0x02) { 112 if (some) strcat(flg_output, " "); 113 some = 1; 114 strcat(flg_output, "CI"); 115 } 116 if (flags & 0x04) { 117 if (some) strcat(flg_output, " "); 118 some = 1; 119 strcat(flg_output, "NP"); 120 } 121 if (flags & 0x08) { 122 if (some) strcat(flg_output, " "); 123 some = 1; 124 strcat(flg_output, "IO"); 125 } 126 if (flags & 0x10) { 127 if (some) strcat(flg_output, " "); 128 some = 1; 129 strcat(flg_output, "IA"); 130 } 131 if (flags == 0xF) { 132 if (some) strcat(flg_output, " "); 133 some = 1; 134 strcat(flg_output, "VI"); 135 } 136 137 return flg_output; 138 } 139 140 141 char* regfio_ace_perms2str(uint32 perms) 142 { 143 char* ret_val = malloc(9*sizeof(char)); 144 if(ret_val == NULL) 145 return NULL; 146 147 /* XXX: this should probably be parsed better */ 148 sprintf(ret_val, "%.8X", perms); 149 150 return ret_val; 151 } 152 153 154 char* regfio_sid2str(DOM_SID* sid) 155 { 156 uint32 i, size = MAXSUBAUTHS*11 + 24; 157 uint32 left = size; 158 uint8 comps = sid->num_auths; 159 char* ret_val = malloc(size); 160 161 if(ret_val == NULL) 162 return NULL; 163 164 if(comps > MAXSUBAUTHS) 165 comps = MAXSUBAUTHS; 166 167 left -= sprintf(ret_val, "S-%u-%u", sid->sid_rev_num, sid->id_auth[5]); 168 169 for (i = 0; i < comps; i++) 170 left -= snprintf(ret_val+(size-left), left, "-%u", sid->sub_auths[i]); 171 172 return ret_val; 173 } 174 175 176 char* regfio_get_acl(SEC_ACL* acl) 177 { 178 uint32 i, extra, size = 0; 179 const char* type_str; 180 char* flags_str; 181 char* perms_str; 182 char* sid_str; 183 char* ret_val = NULL; 184 char* ace_delim = ""; 185 char field_delim = ':'; 186 187 for (i = 0; i < acl->num_aces; i++) 188 { 189 sid_str = regfio_sid2str(&acl->ace[i].trustee); 190 type_str = regfio_ace_type2str(acl->ace[i].type); 191 perms_str = regfio_ace_perms2str(acl->ace[i].info.mask); 192 flags_str = regfio_ace_flags2str(acl->ace[i].flags); 193 194 if(flags_str == NULL || perms_str == NULL 195 || type_str == NULL || sid_str == NULL) 196 return NULL; 197 198 /* XXX: this is slow */ 199 extra = strlen(sid_str) + strlen(type_str) 200 + strlen(perms_str) + strlen(flags_str)+5; 201 ret_val = realloc(ret_val, size+extra); 202 if(ret_val == NULL) 203 return NULL; 204 size += snprintf(ret_val+size, extra, "%s%s%c%s%c%s%c%s", 205 ace_delim,sid_str, 206 field_delim,type_str, 207 field_delim,perms_str, 208 field_delim,flags_str); 209 ace_delim = "|"; 210 free(sid_str); 211 free(perms_str); 212 free(flags_str); 213 } 214 215 return ret_val; 216 } 217 218 219 char* regfio_get_sacl(SEC_DESC *sec_desc) 220 { 221 if (sec_desc->sacl) 222 return regfio_get_acl(sec_desc->sacl); 223 else 224 return NULL; 225 } 226 227 228 char* regfio_get_dacl(SEC_DESC *sec_desc) 229 { 230 if (sec_desc->dacl) 231 return regfio_get_acl(sec_desc->dacl); 232 else 233 return NULL; 234 } 235 236 237 char* regfio_get_owner(SEC_DESC *sec_desc) 238 { 239 return regfio_sid2str(sec_desc->owner_sid); 240 } 241 242 243 char* regfio_get_group(SEC_DESC *sec_desc) 244 { 245 return regfio_sid2str(sec_desc->grp_sid); 246 } 247 248 249 81 250 /******************************************************************* 82 251 *******************************************************************/ … … 117 286 /* make sure this is an hbin header */ 118 287 119 if ( strncmp( hdr, "hbin", HBIN_HDR_SIZE ) != 0 ) {288 if ( strncmp( (char*)hdr, "hbin", HBIN_HDR_SIZE ) != 0 ) { 120 289 /*DEBUG(0,("read_block: invalid block header!\n"));*/ 121 290 return -1; … … 161 330 /******************************************************************* 162 331 *******************************************************************/ 163 static bool prs_regf_block( const char *desc, prs_struct *ps, int depth, REGF_FILE *file ) 332 static bool prs_regf_block(const char *desc, prs_struct *ps, 333 int depth, REGF_FILE *file) 164 334 { 165 335 depth++; 166 336 167 if ( !prs_uint8s( true, "header", ps, depth, file->header, sizeof( file->header )))337 if(!prs_uint8s(true, "header", ps, depth, file->header, sizeof(file->header))) 168 338 return false; 169 339 … … 220 390 /******************************************************************* 221 391 *******************************************************************/ 222 static bool prs_hbin_block( const char *desc, prs_struct *ps, int depth, REGF_HBIN *hbin ) 392 static bool prs_hbin_block(const char *desc, prs_struct *ps, 393 int depth, REGF_HBIN *hbin) 223 394 { 224 395 uint32 block_size2; … … 226 397 depth++; 227 398 228 if ( !prs_uint8s( true, "header", ps, depth, hbin->header, sizeof( hbin->header )))399 if(!prs_uint8s(true, "header", ps, depth, hbin->header, sizeof(hbin->header))) 229 400 return false; 230 401 … … 336 507 return false; 337 508 338 if ( !prs_uint8s( true, "name", ps, depth, nk->keyname, name_length))339 return false; 340 341 if ( ps->io )509 if(!prs_uint8s(true, "name", ps, depth, (uint8*)nk->keyname, name_length)) 510 return false; 511 512 if(ps->io) 342 513 nk->keyname[name_length] = '\0'; 343 514 } … … 583 754 /******************************************************************* 584 755 *******************************************************************/ 585 static bool hbin_prs_lf_records( const char *desc, REGF_HBIN *hbin, int depth, REGF_NK_REC *nk ) 756 static bool hbin_prs_lf_records(const char *desc, REGF_HBIN *hbin, 757 int depth, REGF_NK_REC *nk) 586 758 { 587 759 int i; … … 609 781 return false; 610 782 611 if ( !prs_uint8s( true, "header", &hbin->ps, depth, lf->header, sizeof( lf->header )) ) 783 if(!prs_uint8s(true, "header", &hbin->ps, depth, 784 lf->header, sizeof(lf->header))) 612 785 return false; 613 786 … … 662 835 return false; 663 836 664 if ( !prs_uint8s( true, "header", ps, depth, sk->header, sizeof( sk->header )))837 if (!prs_uint8s(true, "header", ps, depth, sk->header, sizeof(sk->header))) 665 838 return false; 666 839 if ( !prs_uint16( "tag", ps, depth, &tag)) … … 743 916 return false; 744 917 } 745 if ( !prs_uint8s( true, "name", ps, depth, vk->valuename, name_length ) ) 918 if ( !prs_uint8s(true, "name", ps, depth, 919 (uint8*)vk->valuename, name_length) ) 746 920 return false; 747 921 } … … 1017 1191 static bool next_record( REGF_HBIN *hbin, const char *hdr, bool *eob ) 1018 1192 { 1019 charheader[REC_HDR_SIZE] = "";1193 uint8 header[REC_HDR_SIZE] = ""; 1020 1194 uint32 record_size; 1021 1195 uint32 curr_off, block_size; -
trunk/lib/smb_deps.c
r42 r53 427 427 Stream an array of uint8s. Length is number of uint8s. 428 428 ********************************************************************/ 429 bool prs_uint8s(bool charmode, const char *name, prs_struct *ps, int depth, uint8 *data8s, int len) 429 bool prs_uint8s(bool charmode, const char *name, prs_struct *ps, int depth, 430 uint8* data8s, int len) 430 431 { 431 432 int i;
Note: See TracChangeset
for help on using the changeset viewer.