Changeset 745 for trunk/server/source3/lib/sharesec.c
- Timestamp:
- Nov 27, 2012, 4:43:17 PM (13 years ago)
- Location:
- trunk/server
- Files:
-
- 2 edited
-
. (modified) (1 prop)
-
source3/lib/sharesec.c (modified) (21 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/server
- Property svn:mergeinfo changed
/vendor/current merged: 581,587,591,594,597,600,615,618,740
- Property svn:mergeinfo changed
-
trunk/server/source3/lib/sharesec.c
r414 r745 19 19 20 20 #include "includes.h" 21 22 23 24 25 21 26 22 27 /******************************************************************* … … 27 32 #define SHARE_DATABASE_VERSION_V1 1 28 33 #define SHARE_DATABASE_VERSION_V2 2 /* version id in little endian. */ 29 34 #define SHARE_DATABASE_VERSION_V3 3 /* canonicalized sharenames as lower case */ 35 36 #define SHARE_SECURITY_DB_KEY_PREFIX_STR "SECDESC/" 30 37 /* Map generic permissions to file object specific permissions */ 31 38 … … 38 45 } 39 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 40 132 bool share_info_db_init(void) 41 133 { 42 134 const char *vstring = "INFO/version"; 43 135 int32 vers_id; 136 137 44 138 45 139 if (share_db != NULL) { … … 56 150 57 151 vers_id = dbwrap_fetch_int32(share_db, vstring); 58 if (vers_id == SHARE_DATABASE_VERSION_V 2) {152 if (vers_id == SHARE_DATABASE_VERSION_V) { 59 153 return true; 60 154 } … … 67 161 68 162 vers_id = dbwrap_fetch_int32(share_db, vstring); 69 if (vers_id == SHARE_DATABASE_VERSION_V 2) {163 if (vers_id == SHARE_DATABASE_VERSION_V) { 70 164 /* 71 165 * Race condition … … 77 171 } 78 172 173 174 79 175 /* Cope with byte-reversed older versions of the db. */ 80 176 if ((vers_id == SHARE_DATABASE_VERSION_V1) || (IREV(vers_id) == SHARE_DATABASE_VERSION_V1)) { … … 90 186 91 187 if (vers_id != SHARE_DATABASE_VERSION_V2) { 92 int ret;93 188 ret = share_db->traverse(share_db, delete_fn, NULL); 94 189 if (ret < 0) { … … 103 198 } 104 199 200 201 202 203 204 205 206 207 208 209 210 211 212 105 213 if (share_db->transaction_commit(share_db) != 0) { 106 214 DEBUG(0, ("transaction_commit failed\n")); … … 123 231 ********************************************************************/ 124 232 125 SEC_DESC*get_share_security_default( TALLOC_CTX *ctx, size_t *psize, uint32 def_access)233 *get_share_security_default( TALLOC_CTX *ctx, size_t *psize, uint32 def_access) 126 234 { 127 235 uint32_t sa; 128 SEC_ACEace;129 SEC_ACL*psa = NULL;130 SEC_DESC*psd = NULL;236 ace; 237 *psa = NULL; 238 *psd = NULL; 131 239 uint32 spec_access = def_access; 132 240 … … 154 262 ********************************************************************/ 155 263 156 SEC_DESC*get_share_security( TALLOC_CTX *ctx, const char *servicename,264 *get_share_security( TALLOC_CTX *ctx, const char *servicename, 157 265 size_t *psize) 158 266 { 159 267 char *key; 160 SEC_DESC*psd = NULL;268 *psd = NULL; 161 269 TDB_DATA data; 270 162 271 NTSTATUS status; 163 272 273 274 275 276 164 277 if (!share_info_db_init()) { 278 165 279 return NULL; 166 280 } 167 281 168 if (!(key = talloc_asprintf(ctx, "SECDESC/%s", servicename))) { 282 if (!(key = talloc_asprintf(ctx, SHARE_SECURITY_DB_KEY_PREFIX_STR "%s", c_servicename))) { 283 TALLOC_FREE(c_servicename); 169 284 DEBUG(0, ("talloc_asprintf failed\n")); 170 285 return NULL; 171 286 } 287 288 172 289 173 290 data = dbwrap_fetch_bystring(share_db, talloc_tos(), key); … … 187 304 DEBUG(0, ("unmarshall_sec_desc failed: %s\n", 188 305 nt_errstr(status))); 189 return NULL; 190 } 191 192 if (psd) 193 *psize = ndr_size_security_descriptor(psd, NULL, 0); 306 return get_share_security_default(ctx, psize, 307 GENERIC_ALL_ACCESS); 308 } 309 310 if (psd) { 311 *psize = ndr_size_security_descriptor(psd, 0); 312 } else { 313 return get_share_security_default(ctx, psize, 314 GENERIC_ALL_ACCESS); 315 } 194 316 195 317 return psd; … … 200 322 ********************************************************************/ 201 323 202 bool set_share_security(const char *share_name, SEC_DESC*psd)203 { 204 TALLOC_CTX *frame ;324 bool set_share_security(const char *share_name, *psd) 325 { 326 TALLOC_CTX *frame; 205 327 char *key; 206 328 bool ret = False; 207 329 TDB_DATA blob; 208 330 NTSTATUS status; 331 332 333 334 335 209 336 210 337 if (!share_info_db_init()) { 211 return False; 212 } 213 214 frame = talloc_stackframe(); 338 goto out; 339 } 215 340 216 341 status = marshall_sec_desc(frame, psd, &blob.dptr, &blob.dsize); … … 222 347 } 223 348 224 if (!(key = talloc_asprintf(frame, "SECDESC/%s",share_name))) {349 if (!(key = talloc_asprintf(frame, share_name))) { 225 350 DEBUG(0, ("talloc_asprintf failed\n")); 226 351 goto out; … … 252 377 char *key; 253 378 NTSTATUS status; 379 380 381 382 383 254 384 255 385 if (!share_info_db_init()) { 386 256 387 return False; 257 388 } 258 389 259 if (!(key = talloc_asprintf(talloc_tos(), "SECDESC/%s", 260 servicename))) { 390 if (!(key = talloc_asprintf(talloc_tos(), SHARE_SECURITY_DB_KEY_PREFIX_STR "%s", 391 c_servicename))) { 392 TALLOC_FREE(c_servicename); 261 393 return False; 262 394 } … … 266 398 if (!NT_STATUS_IS_OK(status)) { 267 399 DEBUG(0, ("delete_share_security: Failed to delete entry for " 268 "share %s: %s\n", servicename, nt_errstr(status))); 400 "share %s: %s\n", c_servicename, nt_errstr(status))); 401 TALLOC_FREE(c_servicename); 269 402 return False; 270 403 } 271 404 405 272 406 return True; 273 407 } … … 277 411 ********************************************************************/ 278 412 279 bool share_access_check(const NT_USER_TOKEN *token, const char *sharename, 280 uint32 desired_access) 413 bool share_access_check(const struct security_token *token, 414 const char *sharename, 415 uint32 desired_access, 416 uint32_t *pgranted) 281 417 { 282 418 uint32 granted; 283 419 NTSTATUS status; 284 SEC_DESC*psd = NULL;420 *psd = NULL; 285 421 size_t sd_size; 286 422 … … 294 430 295 431 TALLOC_FREE(psd); 432 433 434 435 296 436 297 437 return NT_STATUS_IS_OK(status); … … 302 442 ***************************************************************************/ 303 443 304 bool parse_usershare_acl(TALLOC_CTX *ctx, const char *acl_str, SEC_DESC**ppsd)444 bool parse_usershare_acl(TALLOC_CTX *ctx, const char *acl_str, **ppsd) 305 445 { 306 446 size_t s_size = 0; 307 447 const char *pacl = acl_str; 308 448 int num_aces = 0; 309 SEC_ACE*ace_list = NULL;310 SEC_ACL*psa = NULL;311 SEC_DESC*psd = NULL;449 *ace_list = NULL; 450 *psa = NULL; 451 *psd = NULL; 312 452 size_t sd_size = 0; 313 453 int i; … … 317 457 /* If the acl string is blank return "Everyone:R" */ 318 458 if (!*acl_str) { 319 SEC_DESC*default_psd = get_share_security_default(ctx, &s_size, GENERIC_READ_ACCESS);459 *default_psd = get_share_security_default(ctx, &s_size, GENERIC_READ_ACCESS); 320 460 if (!default_psd) { 321 461 return False; … … 330 470 num_aces += count_chars(pacl,','); 331 471 332 ace_list = TALLOC_ARRAY(ctx, SEC_ACE, num_aces);472 ace_list = TALLOC_ARRAY(ctx, , num_aces); 333 473 if (!ace_list) { 334 474 return False; … … 339 479 uint32 g_access; 340 480 uint32 s_access; 341 DOM_SIDsid;481 sid; 342 482 char *sidstr; 343 483 enum security_ace_type type = SEC_ACE_TYPE_ACCESS_ALLOWED;
Note:
See TracChangeset
for help on using the changeset viewer.
