Ignore:
Timestamp:
Nov 14, 2012, 12:59:34 PM (13 years ago)
Author:
Silvan Scherrer
Message:

Samba Server: update vendor to 3.6.0

File:
1 edited

Legend:

Unmodified
Added
Removed
  • vendor/current/source3/utils/sharesec.c

    r414 r740  
    2424
    2525#include "includes.h"
     26#include "popt_common.h"
     27#include "../libcli/security/security.h"
     28#include "passdb/machine_sid.h"
    2629
    2730static TALLOC_CTX *ctx;
     
    6568********************************************************************/
    6669
    67 static void print_ace(FILE *f, SEC_ACE *ace)
     70static void print_ace(FILE *f, struct security_ace *ace)
    6871{
    6972        const struct perm_value *v;
     
    125128********************************************************************/
    126129
    127 static void sec_desc_print(FILE *f, SEC_DESC *sd)
     130static void sec_desc_print(FILE *f, struct security_descriptor *sd)
    128131{
    129132        uint32 i;
     
    139142        /* Print aces */
    140143        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];
    142145                fprintf(f, "ACL:");
    143146                print_ace(f, ace);
     
    150153********************************************************************/
    151154
    152 static bool parse_ace(SEC_ACE *ace, const char *orig_str)
     155static bool parse_ace(struct security_ace *ace, const char *orig_str)
    153156{
    154157        char *p;
     
    158161        unsigned int aflags = 0;
    159162        unsigned int amask = 0;
    160         DOM_SID sid;
     163        struct dom_sid sid;
    161164        uint32_t mask;
    162165        const struct perm_value *v;
     
    295298********************************************************************/
    296299
    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;
     300static 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;
    302305        int num_ace;
    303306        const char *pacl;
     
    310313        num_ace = count_chars( pacl, ',' ) + 1;
    311314
    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 )) )
    313316                return NULL;
    314317
     
    330333                return NULL;
    331334
    332         sd = make_sec_desc( mem_ctx, SEC_DESC_REVISION, SEC_DESC_SELF_RELATIVE,
     335        sd = make_sec_desc( mem_ctx, SD_REVISION, SEC_DESC_SELF_RELATIVE,
    333336                NULL, NULL, NULL, theacl, sd_size);
    334337
     
    336339}
    337340
    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 */
     342static 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;
    343346        if (! *the_acl) {
    344347                return (((*the_acl) = make_sec_acl(mem_ctx, 3, 1, ace)) != NULL);
    345348        }
    346349
    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));
    352356        new_ace = make_sec_acl(mem_ctx,(*the_acl)->revision,1+(*the_acl)->num_aces, aces);
    353357        SAFE_FREE(aces);
     
    361365   allowed ACEs. */
    362366
    363 static int ace_compare(SEC_ACE *ace1, SEC_ACE *ace2)
     367static int ace_compare(struct security_ace *ace1, struct security_ace *ace2)
    364368{
    365369        if (sec_ace_equal(ace1, ace2))
     
    369373                return ace2->type - ace1->type;
    370374
    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);
    373377
    374378        if (ace1->flags != ace2->flags)
     
    381385                return ace1->size - ace2->size;
    382386
    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
     390static void sort_acl(struct security_acl *the_acl)
    387391{
    388392        uint32 i;
    389393        if (!the_acl) return;
    390394
    391         qsort(the_acl->aces, the_acl->num_aces, sizeof(the_acl->aces[0]), QSORT_CAST ace_compare);
     395        TYPESAFE_QSORT(the_acl->aces, the_acl->num_aces, ace_compare);
    392396
    393397        for (i=1;i<the_acl->num_aces;) {
     
    407411static int change_share_sec(TALLOC_CTX *mem_ctx, const char *sharename, char *the_acl, enum acl_mode mode)
    408412{
    409         SEC_DESC *sd = NULL;
    410         SEC_DESC *old = NULL;
     413        struct security_descriptor *sd = NULL;
     414        struct security_descriptor *old = NULL;
    411415        size_t sd_size = 0;
    412416        uint32 i, j;
     
    458462
    459463                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,
    461465                        &old->dacl->aces[j].trustee)) {
    462466                        old->dacl->aces[j] = sd->dacl->aces[i];
     
    541545
    542546        /* 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");
    547552
    548553        pc = poptGetContext("sharesec", argc, argv, long_options, 0);
     
    592597        setlinebuf(stdout);
    593598
    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 );
    597601
    598602        /* check for initializing secrets.tdb first */
    599603
    600604        if ( initialize_sid ) {
    601                 DOM_SID *sid = get_global_sam_sid();
     605                struct dom_sid *sid = get_global_sam_sid();
    602606
    603607                if ( !sid ) {
Note: See TracChangeset for help on using the changeset viewer.