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/groupdb/mapping.c

    r414 r740  
    2222
    2323#include "includes.h"
     24#include "system/passwd.h"
     25#include "passdb.h"
    2426#include "groupdb/mapping.h"
     27#include "../libcli/security/security.h"
     28#include "lib/winbind_util.h"
     29#include <tdb.h>
    2530
    2631static const struct mapping_backend *backend;
     
    3136static bool init_group_mapping(void)
    3237{
    33         const char *backend_string;
    34 
    3538        if (backend != NULL) {
    3639                /* already initialised */
     
    3841        }
    3942
    40         /*
    41          * default to using the ldb backend. This parameter should
    42          * disappear in future versions of Samba3.
    43          *
    44          * But it's needed for cluster setups, because it's
    45          * not yet possible to distribute a ldb inside a cluster.
    46          */
    47         backend_string = lp_parm_const_string(-1, "groupdb", "backend", "ldb");
    48 
    49         if (strcmp(backend_string, "ldb") == 0) {
    50                 backend = groupdb_ldb_init();
    51         } else if (strcmp(backend_string, "tdb") == 0) {
    52                 backend = groupdb_tdb_init();
    53         } else {
    54                 DEBUG(0,("Unknown groupdb backend '%s'\n", backend_string));
    55                 smb_panic("Unknown groupdb backend");
    56         }
     43        backend = groupdb_tdb_init();
    5744
    5845        return backend != NULL;
     
    7057                return NT_STATUS_UNSUCCESSFUL;
    7158        }
    72        
     59
    7360        map.gid=gid;
    7461        if (!string_to_sid(&map.sid, sid)) {
     
    7663                return NT_STATUS_UNSUCCESSFUL;
    7764        }
    78        
     65
    7966        map.sid_name_use=sid_name_use;
    8067        fstrcpy(map.nt_name, nt_name);
     
    8471}
    8572
    86 static NTSTATUS alias_memberships(const DOM_SID *members, size_t num_members,
    87                                   DOM_SID **sids, size_t *num)
     73static NTSTATUS alias_memberships(const struct dom_sid *members, size_t num_members,
     74                                  struct dom_sid **sids, size_t *num)
    8875{
    8976        size_t i;
     
    10188
    10289struct aliasmem_closure {
    103         const DOM_SID *alias;
    104         DOM_SID **sids;
     90        const struct dom_sid *alias;
     91        struct dom_sid **sids;
    10592        size_t *num;
    10693};
     
    120107/* get a domain group from it's SID */
    121108
    122 bool get_domain_group_from_sid(DOM_SID sid, GROUP_MAP *map)
     109bool get_domain_group_from_sid(struct dom_sid sid, GROUP_MAP *map)
    123110{
    124111        struct group *grp;
    125112        bool ret;
    126        
     113
    127114        if(!init_group_mapping()) {
    128115                DEBUG(0,("failed to initialize group mapping\n"));
     
    133120
    134121        /* if the group is NOT in the database, it CAN NOT be a domain group */
    135        
     122
    136123        become_root();
    137124        ret = pdb_getgrsid(map, sid);
    138125        unbecome_root();
    139        
     126
    140127        /* special case check for rid 513 */
    141        
     128
    142129        if ( !ret ) {
    143130                uint32 rid;
    144                
     131
    145132                sid_peek_rid( &sid, &rid );
    146                
    147                 if ( rid == DOMAIN_GROUP_RID_USERS ) {
     133
     134                if ( rid == DOMAIN_RID_USERS ) {
    148135                        fstrcpy( map->nt_name, "None" );
    149136                        fstrcpy( map->comment, "Ordinary Users" );
     
    151138                        map->sid_name_use = SID_NAME_DOM_GRP;
    152139                        map->gid = (gid_t)-1;
    153                        
    154140                        return True;
    155141                }
    156                
    157142                return False;
    158143        }
    159144
    160         DEBUG(10, ("get_domain_group_from_sid: SID found in the TDB\n"));
     145        DEBUG(10, ("get_domain_group_from_sid: SID found in passdb\n"));
    161146
    162147        /* if it's not a domain group, continue */
     
    166151
    167152        DEBUG(10, ("get_domain_group_from_sid: SID is a domain group\n"));
    168        
     153
    169154        if (map->gid==-1) {
    170155                return False;
     
    172157
    173158        DEBUG(10, ("get_domain_group_from_sid: SID is mapped to gid:%lu\n",(unsigned long)map->gid));
    174        
     159
    175160        grp = getgrgid(map->gid);
    176161        if ( !grp ) {
     
    344329                        return -1;
    345330                }
    346                 add_script = talloc_string_sub(ctx,
    347                                 add_script, "%u", unix_user);
     331                add_script = talloc_string_sub2(ctx,
     332                                add_script, "%u", unix_user, true, false, true);
    348333                if (!add_script) {
    349334                        return -1;
     
    384369                        return -1;
    385370                }
    386                 del_script = talloc_string_sub(ctx,
    387                                 del_script, "%u", unix_user);
     371                del_script = talloc_string_sub2(ctx,
     372                                del_script, "%u", unix_user, true, false, true);
    388373                if (!del_script) {
    389374                        return -1;
     
    402387
    403388NTSTATUS pdb_default_getgrsid(struct pdb_methods *methods, GROUP_MAP *map,
    404                                  DOM_SID sid)
     389                                 struct dom_sid sid)
    405390{
    406391        if (!init_group_mapping()) {
     
    457442
    458443NTSTATUS pdb_default_delete_group_mapping_entry(struct pdb_methods *methods,
    459                                                    DOM_SID sid)
     444                                                   struct dom_sid sid)
    460445{
    461446        if (!init_group_mapping()) {
     
    468453
    469454NTSTATUS pdb_default_enum_group_mapping(struct pdb_methods *methods,
    470                                            const DOM_SID *sid, enum lsa_SidType sid_name_use,
     455                                           const struct dom_sid *sid, enum lsa_SidType sid_name_use,
    471456                                           GROUP_MAP **pp_rmap, size_t *p_num_entries,
    472457                                           bool unix_only)
     
    483468                                  const char *name, uint32 *rid)
    484469{
    485         DOM_SID sid;
     470        struct dom_sid sid;
    486471        enum lsa_SidType type;
    487472        uint32 new_rid;
     
    507492        }
    508493
     494        if (!pdb_new_rid(&new_rid)) {
     495                DEBUG(0, ("Could not allocate a RID.\n"));
     496                return NT_STATUS_ACCESS_DENIED;
     497        }
     498
     499        sid_compose(&sid, get_global_sam_sid(), new_rid);
     500
    509501        if (!winbind_allocate_gid(&gid)) {
    510                 DEBUG(3, ("Could not get a gid out of winbind\n"));
    511                 return NT_STATUS_ACCESS_DENIED;
    512         }
    513 
    514         if (!pdb_new_rid(&new_rid)) {
    515                 DEBUG(0, ("Could not allocate a RID -- wasted a gid :-(\n"));
     502                DEBUG(3, ("Could not get a gid out of winbind - "
     503                          "wasted a rid :-(\n"));
    516504                return NT_STATUS_ACCESS_DENIED;
    517505        }
     
    519507        DEBUG(10, ("Creating alias %s with gid %u and rid %u\n",
    520508                   name, (unsigned int)gid, (unsigned int)new_rid));
    521 
    522         sid_copy(&sid, get_global_sam_sid());
    523         sid_append_rid(&sid, new_rid);
    524509
    525510        map.gid = gid;
     
    543528
    544529NTSTATUS pdb_default_delete_alias(struct pdb_methods *methods,
    545                                   const DOM_SID *sid)
     530                                  const struct dom_sid *sid)
    546531{
    547532        return pdb_delete_group_mapping_entry(*sid);
     
    549534
    550535NTSTATUS pdb_default_get_aliasinfo(struct pdb_methods *methods,
    551                                    const DOM_SID *sid,
     536                                   const struct dom_sid *sid,
    552537                                   struct acct_info *info)
    553538{
     
    572557
    573558NTSTATUS pdb_default_set_aliasinfo(struct pdb_methods *methods,
    574                                    const DOM_SID *sid,
     559                                   const struct dom_sid *sid,
    575560                                   struct acct_info *info)
    576561{
     
    587572
    588573NTSTATUS pdb_default_add_aliasmem(struct pdb_methods *methods,
    589                                   const DOM_SID *alias, const DOM_SID *member)
     574                                  const struct dom_sid *alias, const struct dom_sid *member)
    590575{
    591576        if (!init_group_mapping()) {
     
    597582
    598583NTSTATUS pdb_default_del_aliasmem(struct pdb_methods *methods,
    599                                   const DOM_SID *alias, const DOM_SID *member)
     584                                  const struct dom_sid *alias, const struct dom_sid *member)
    600585{
    601586        if (!init_group_mapping()) {
     
    607592
    608593NTSTATUS pdb_default_enum_aliasmem(struct pdb_methods *methods,
    609                                    const DOM_SID *alias, TALLOC_CTX *mem_ctx,
    610                                    DOM_SID **pp_members, size_t *p_num_members)
     594                                   const struct dom_sid *alias, TALLOC_CTX *mem_ctx,
     595                                   struct dom_sid **pp_members, size_t *p_num_members)
    611596{
    612597        if (!init_group_mapping()) {
     
    620605NTSTATUS pdb_default_alias_memberships(struct pdb_methods *methods,
    621606                                       TALLOC_CTX *mem_ctx,
    622                                        const DOM_SID *domain_sid,
    623                                        const DOM_SID *members,
     607                                       const struct dom_sid *domain_sid,
     608                                       const struct dom_sid *members,
    624609                                       size_t num_members,
    625610                                       uint32 **pp_alias_rids,
    626611                                       size_t *p_num_alias_rids)
    627612{
    628         DOM_SID *alias_sids;
     613        struct dom_sid *alias_sids;
    629614        size_t i, num_alias_sids;
    630615        NTSTATUS result;
     
    672657
    673658NTSTATUS pdb_nop_getgrsid(struct pdb_methods *methods, GROUP_MAP *map,
    674                                  DOM_SID sid)
     659                                 struct dom_sid sid)
    675660{
    676661        return NT_STATUS_UNSUCCESSFUL;
     
    702687
    703688NTSTATUS pdb_nop_delete_group_mapping_entry(struct pdb_methods *methods,
    704                                                    DOM_SID sid)
     689                                                   struct dom_sid sid)
    705690{
    706691        return NT_STATUS_UNSUCCESSFUL;
     
    718703 These need to be redirected through pdb_interface.c
    719704****************************************************************************/
    720 bool pdb_get_dom_grp_info(const DOM_SID *sid, struct acct_info *info)
     705bool pdb_get_dom_grp_info(const struct dom_sid *sid, struct acct_info *info)
    721706{
    722707        GROUP_MAP map;
     
    736721}
    737722
    738 bool pdb_set_dom_grp_info(const DOM_SID *sid, const struct acct_info *info)
     723bool pdb_set_dom_grp_info(const struct dom_sid *sid, const struct acct_info *info)
    739724{
    740725        GROUP_MAP map;
     
    755740NTSTATUS pdb_create_builtin_alias(uint32 rid)
    756741{
    757         DOM_SID sid;
     742        struct dom_sid sid;
    758743        enum lsa_SidType type;
    759744        gid_t gid;
     
    765750
    766751        DEBUG(10, ("Trying to create builtin alias %d\n", rid));
    767        
     752
    768753        if ( !sid_compose( &sid, &global_sid_Builtin, rid ) ) {
    769754                return NT_STATUS_NO_SUCH_ALIAS;
    770755        }
    771        
     756
    772757        if ( (mem_ctx = talloc_new(NULL)) == NULL ) {
    773758                return NT_STATUS_NO_MEMORY;
    774759        }
    775        
     760
    776761        if ( !lookup_sid(mem_ctx, &sid, NULL, &name, &type) ) {
    777762                TALLOC_FREE( mem_ctx );
    778763                return NT_STATUS_NO_SUCH_ALIAS;
    779764        }
    780        
     765
    781766        /* validate RID so copy the name and move on */
    782                
     767
    783768        fstrcpy( groupname, name );
    784769        TALLOC_FREE( mem_ctx );
Note: See TracChangeset for help on using the changeset viewer.