- Timestamp:
- 01/06/07 20:25:45 (18 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/doc/devel/references.txt
r64 r76 8 8 http://www.microsoft.com/technet/archive/winntas/tips/winntmag/inreg.mspx 9 9 10 - 10 - Misc references for windows registry permissions and ownership: 11 http://msdn2.microsoft.com/en-gb/library/ms724878.aspx 12 http://technet2.microsoft.com/WindowsServer/en/library/86cf2457-4f17-43f8-a2ab-7f4e2e5659091033.mspx?mfr=true 13 http://msdn2.microsoft.com/en-gb/library/aa374892.aspx 14 15 - ACL/ACE flags information 16 http://support.microsoft.com/kb/220167 17 http://msdn2.microsoft.com/en-us/library/aa772242.aspx -
trunk/lib/regfio.c
r72 r76 85 85 86 86 87 /* XXX: this could probably be more efficient */ 87 /* XXX: need a better reference on the meaning of each flag. */ 88 /* For more info, see: 89 * http://msdn2.microsoft.com/en-us/library/aa772242.aspx 90 */ 88 91 char* regfio_ace_flags2str(uint8 flags) 89 92 { 90 char* flg_output = malloc(21*sizeof(char)); 91 int some = 0; 92 93 if(flg_output == NULL) 94 return NULL; 95 96 flg_output[0] = '\0'; 93 static const char* flag_map[32] = 94 { "OI", 95 "CI", 96 "NP", 97 "IO", 98 "IA", 99 NULL, 100 NULL, 101 NULL, 102 }; 103 104 char* ret_val = malloc(35*sizeof(char)); 105 char* fo = ret_val; 106 uint32 i; 107 uint8 f; 108 109 if(ret_val == NULL) 110 return NULL; 111 112 fo[0] = '\0'; 97 113 if (!flags) 98 return flg_output; 99 100 if (flags & 0x01) { 101 if (some) strcat(flg_output, " "); 102 some = 1; 103 strcat(flg_output, "OI"); 104 } 105 if (flags & 0x02) { 106 if (some) strcat(flg_output, " "); 107 some = 1; 108 strcat(flg_output, "CI"); 109 } 110 if (flags & 0x04) { 111 if (some) strcat(flg_output, " "); 112 some = 1; 113 strcat(flg_output, "NP"); 114 } 115 if (flags & 0x08) { 116 if (some) strcat(flg_output, " "); 117 some = 1; 118 strcat(flg_output, "IO"); 119 } 120 if (flags & 0x10) { 121 if (some) strcat(flg_output, " "); 122 some = 1; 123 strcat(flg_output, "IA"); 124 } 125 /* XXX: Is this check right? 0xF == 1|2|4|8, which makes it redundant... */ 114 return ret_val; 115 116 for(i=0; i < 8; i++) 117 { 118 f = (1<<i); 119 if((flags & f) && (flag_map[i] != NULL)) 120 { 121 strcpy(fo, flag_map[i]); 122 fo += strlen(flag_map[i]); 123 *(fo++) = ' '; 124 flags ^= f; 125 } 126 } 127 128 /* Any remaining unknown flags are added at the end in hex. */ 129 if(flags != 0) 130 sprintf(fo, "0x%.2X ", flags); 131 132 /* Chop off the last space if we've written anything to ret_val */ 133 if(fo != ret_val) 134 fo[-1] = '\0'; 135 136 /* XXX: what was this old VI flag for?? 137 XXX: Is this check right? 0xF == 1|2|4|8, which makes it redundant... 126 138 if (flags == 0xF) { 127 139 if (some) strcat(flg_output, " "); … … 129 141 strcat(flg_output, "VI"); 130 142 } 131 132 return flg_output; 143 */ 144 145 return ret_val; 133 146 } 134 147 … … 136 149 char* regfio_ace_perms2str(uint32 perms) 137 150 { 138 char* ret_val = malloc(9*sizeof(char)); 151 uint32 i, p; 152 /* This is more than is needed by a fair margin. */ 153 char* ret_val = malloc(350*sizeof(char)); 154 char* r = ret_val; 155 156 /* Each represents one of 32 permissions bits. NULL is for undefined/reserved bits. 157 * For more information, see: 158 * http://msdn2.microsoft.com/en-gb/library/aa374892.aspx 159 * http://msdn2.microsoft.com/en-gb/library/ms724878.aspx 160 */ 161 static const char* perm_map[32] = 162 {/* object-specific permissions (registry keys, in this case) */ 163 "QRY_VAL", /* KEY_QUERY_VALUE */ 164 "SET_VAL", /* KEY_SET_VALUE */ 165 "CREATE_KEY", /* KEY_CREATE_SUB_KEY */ 166 "ENUM_KEYS", /* KEY_ENUMERATE_SUB_KEYS */ 167 "NOTIFY", /* KEY_NOTIFY */ 168 "CREATE_LNK", /* KEY_CREATE_LINK - Reserved for system use. */ 169 NULL, 170 NULL, 171 "WOW64_64", /* KEY_WOW64_64KEY */ 172 "WOW64_32", /* KEY_WOW64_32KEY */ 173 NULL, 174 NULL, 175 NULL, 176 NULL, 177 NULL, 178 NULL, 179 /* standard access rights */ 180 "DELETE", /* DELETE */ 181 "R_CONT", /* READ_CONTROL */ 182 "W_DAC", /* WRITE_DAC */ 183 "W_OWNER", /* WRITE_OWNER */ 184 "SYNC", /* SYNCHRONIZE - Shouldn't be set in registries */ 185 NULL, 186 NULL, 187 NULL, 188 /* other generic */ 189 "SYS_SEC", /* ACCESS_SYSTEM_SECURITY */ 190 "MAX_ALLWD", /* MAXIMUM_ALLOWED */ 191 NULL, 192 NULL, 193 "GEN_A", /* GENERIC_ALL */ 194 "GEN_X", /* GENERIC_EXECUTE */ 195 "GEN_W", /* GENERIC_WRITE */ 196 "GEN_R", /* GENERIC_READ */ 197 }; 198 199 139 200 if(ret_val == NULL) 140 201 return NULL; 141 202 142 /* XXX: this should probably be parsed better */ 143 sprintf(ret_val, "%.8X", perms); 203 r[0] = '\0'; 204 for(i=0; i < 32; i++) 205 { 206 p = (1<<i); 207 if((perms & p) && (perm_map[i] != NULL)) 208 { 209 strcpy(r, perm_map[i]); 210 r += strlen(perm_map[i]); 211 *(r++) = ' '; 212 perms ^= p; 213 } 214 } 215 216 /* Any remaining unknown permission bits are added at the end in hex. */ 217 if(perms != 0) 218 sprintf(r, "0x%.8X ", perms); 219 220 /* Chop off the last space if we've written anything to ret_val */ 221 if(r != ret_val) 222 r[-1] = '\0'; 144 223 145 224 return ret_val;
Note: See TracChangeset
for help on using the changeset viewer.