Changeset 740 for vendor/current/source3/utils/sharesec.c
- Timestamp:
- Nov 14, 2012, 12:59:34 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
vendor/current/source3/utils/sharesec.c
r414 r740 24 24 25 25 #include "includes.h" 26 #include "popt_common.h" 27 #include "../libcli/security/security.h" 28 #include "passdb/machine_sid.h" 26 29 27 30 static TALLOC_CTX *ctx; … … 65 68 ********************************************************************/ 66 69 67 static void print_ace(FILE *f, SEC_ACE*ace)70 static void print_ace(FILE *f, struct security_ace *ace) 68 71 { 69 72 const struct perm_value *v; … … 125 128 ********************************************************************/ 126 129 127 static void sec_desc_print(FILE *f, SEC_DESC*sd)130 static void sec_desc_print(FILE *f, struct security_descriptor *sd) 128 131 { 129 132 uint32 i; … … 139 142 /* Print aces */ 140 143 for (i = 0; sd->dacl && i < sd->dacl->num_aces; i++) { 141 SEC_ACE*ace = &sd->dacl->aces[i];144 struct security_ace *ace = &sd->dacl->aces[i]; 142 145 fprintf(f, "ACL:"); 143 146 print_ace(f, ace); … … 150 153 ********************************************************************/ 151 154 152 static bool parse_ace( SEC_ACE*ace, const char *orig_str)155 static bool parse_ace(struct security_ace *ace, const char *orig_str) 153 156 { 154 157 char *p; … … 158 161 unsigned int aflags = 0; 159 162 unsigned int amask = 0; 160 DOM_SIDsid;163 struct dom_sid sid; 161 164 uint32_t mask; 162 165 const struct perm_value *v; … … 295 298 ********************************************************************/ 296 299 297 static SEC_DESC* parse_acl_string(TALLOC_CTX *mem_ctx, const char *szACL, size_t *sd_size )298 { 299 SEC_DESC*sd = NULL;300 SEC_ACE*ace;301 SEC_ACL*theacl;300 static struct security_descriptor* parse_acl_string(TALLOC_CTX *mem_ctx, const char *szACL, size_t *sd_size ) 301 { 302 struct security_descriptor *sd = NULL; 303 struct security_ace *ace; 304 struct security_acl *theacl; 302 305 int num_ace; 303 306 const char *pacl; … … 310 313 num_ace = count_chars( pacl, ',' ) + 1; 311 314 312 if ( !(ace = TALLOC_ZERO_ARRAY( mem_ctx, SEC_ACE, num_ace )) )315 if ( !(ace = TALLOC_ZERO_ARRAY( mem_ctx, struct security_ace, num_ace )) ) 313 316 return NULL; 314 317 … … 330 333 return NULL; 331 334 332 sd = make_sec_desc( mem_ctx, S EC_DESC_REVISION, SEC_DESC_SELF_RELATIVE,335 sd = make_sec_desc( mem_ctx, SD_REVISION, SEC_DESC_SELF_RELATIVE, 333 336 NULL, NULL, NULL, theacl, sd_size); 334 337 … … 336 339 } 337 340 338 /* add an ACE to a list of ACEs in a SEC_ACL*/339 static bool add_ace(TALLOC_CTX *mem_ctx, SEC_ACL **the_acl, SEC_ACE*ace)340 { 341 SEC_ACL*new_ace;342 SEC_ACE*aces;341 /* add an ACE to a list of ACEs in a struct security_acl */ 342 static bool add_ace(TALLOC_CTX *mem_ctx, struct security_acl **the_acl, struct security_ace *ace) 343 { 344 struct security_acl *new_ace; 345 struct security_ace *aces; 343 346 if (! *the_acl) { 344 347 return (((*the_acl) = make_sec_acl(mem_ctx, 3, 1, ace)) != NULL); 345 348 } 346 349 347 if (!(aces = SMB_CALLOC_ARRAY(SEC_ACE, 1+(*the_acl)->num_aces))) { 348 return False; 349 } 350 memcpy(aces, (*the_acl)->aces, (*the_acl)->num_aces * sizeof(SEC_ACE)); 351 memcpy(aces+(*the_acl)->num_aces, ace, sizeof(SEC_ACE)); 350 if (!(aces = SMB_CALLOC_ARRAY(struct security_ace, 1+(*the_acl)->num_aces))) { 351 return False; 352 } 353 memcpy(aces, (*the_acl)->aces, (*the_acl)->num_aces * sizeof(struct 354 security_ace)); 355 memcpy(aces+(*the_acl)->num_aces, ace, sizeof(struct security_ace)); 352 356 new_ace = make_sec_acl(mem_ctx,(*the_acl)->revision,1+(*the_acl)->num_aces, aces); 353 357 SAFE_FREE(aces); … … 361 365 allowed ACEs. */ 362 366 363 static int ace_compare( SEC_ACE *ace1, SEC_ACE*ace2)367 static int ace_compare(struct security_ace *ace1, struct security_ace *ace2) 364 368 { 365 369 if (sec_ace_equal(ace1, ace2)) … … 369 373 return ace2->type - ace1->type; 370 374 371 if ( sid_compare(&ace1->trustee, &ace2->trustee))372 return sid_compare(&ace1->trustee, &ace2->trustee);375 if (dom_sid_compare(&ace1->trustee, &ace2->trustee)) 376 return dom_sid_compare(&ace1->trustee, &ace2->trustee); 373 377 374 378 if (ace1->flags != ace2->flags) … … 381 385 return ace1->size - ace2->size; 382 386 383 return memcmp(ace1, ace2, sizeof( SEC_ACE));384 } 385 386 static void sort_acl( SEC_ACL*the_acl)387 return memcmp(ace1, ace2, sizeof(struct security_ace)); 388 } 389 390 static void sort_acl(struct security_acl *the_acl) 387 391 { 388 392 uint32 i; 389 393 if (!the_acl) return; 390 394 391 qsort(the_acl->aces, the_acl->num_aces, sizeof(the_acl->aces[0]), QSORT_CASTace_compare);395 TYPESAFE_QSORT(the_acl->aces, the_acl->num_aces, ace_compare); 392 396 393 397 for (i=1;i<the_acl->num_aces;) { … … 407 411 static int change_share_sec(TALLOC_CTX *mem_ctx, const char *sharename, char *the_acl, enum acl_mode mode) 408 412 { 409 SEC_DESC*sd = NULL;410 SEC_DESC*old = NULL;413 struct security_descriptor *sd = NULL; 414 struct security_descriptor *old = NULL; 411 415 size_t sd_size = 0; 412 416 uint32 i, j; … … 458 462 459 463 for (j=0;old->dacl && j<old->dacl->num_aces;j++) { 460 if ( sid_equal(&sd->dacl->aces[i].trustee,464 if (dom_sid_equal(&sd->dacl->aces[i].trustee, 461 465 &old->dacl->aces[j].trustee)) { 462 466 old->dacl->aces[j] = sd->dacl->aces[i]; … … 541 545 542 546 /* set default debug level to 1 regardless of what smb.conf sets */ 543 setup_logging( "sharesec", True ); 544 DEBUGLEVEL_CLASS[DBGC_ALL] = 1; 545 dbf = x_stderr; 546 x_setbuf( x_stderr, NULL ); 547 setup_logging( "sharesec", DEBUG_STDERR); 548 549 load_case_tables(); 550 551 lp_set_cmdline("log level", "1"); 547 552 548 553 pc = poptGetContext("sharesec", argc, argv, long_options, 0); … … 592 597 setlinebuf(stdout); 593 598 594 load_case_tables(); 595 596 lp_load( get_dyn_CONFIGFILE(), False, False, False, True ); 599 lp_load_with_registry_shares( get_dyn_CONFIGFILE(), False, False, False, 600 True ); 597 601 598 602 /* check for initializing secrets.tdb first */ 599 603 600 604 if ( initialize_sid ) { 601 DOM_SID*sid = get_global_sam_sid();605 struct dom_sid *sid = get_global_sam_sid(); 602 606 603 607 if ( !sid ) {
Note:
See TracChangeset
for help on using the changeset viewer.