Ignore:
Timestamp:
May 27, 2009, 11:39:15 AM (16 years ago)
Author:
Herwig Bauernfeind
Message:

Update 3.2 branch to 3.2.9

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/samba-3.2.x/source/auth/auth_util.c

    r149 r233  
    548548        gid_t *gids;
    549549        auth_serversupplied_info *result;
    550         int i;
    551         size_t num_gids;
    552         DOM_SID unix_group_sid;
    553550        const char *username = pdb_get_username(sampass);
    554551        NTSTATUS status;
     
    566563
    567564        result->sam_account = sampass;
    568         /* Ensure thaat the sampass will be freed with the result */
    569         talloc_steal(result, sampass);
    570565        result->unix_name = pwd->pw_name;
    571566        /* Ensure that we keep pwd->pw_name, because we will free pwd below */
     
    617612        }
    618613
    619         /* Add the "Unix Group" SID for each gid to catch mapped groups
    620            and their Unix equivalent.  This is to solve the backwards
    621            compatibility problem of 'valid users = +ntadmin' where
    622            ntadmin has been paired with "Domain Admins" in the group
    623            mapping table.  Otherwise smb.conf would need to be changed
    624            to 'valid user = "Domain Admins"'.  --jerry */
    625        
    626         num_gids = result->num_sids;
    627         for ( i=0; i<num_gids; i++ ) {
    628                 if ( !gid_to_unix_groups_sid( gids[i], &unix_group_sid ) ) {
    629                         DEBUG(1,("make_server_info_sam: Failed to create SID "
    630                                 "for gid %d!\n", gids[i]));
    631                         continue;
    632                 }
    633                 status = add_sid_to_array_unique(result, &unix_group_sid,
    634                                                  &result->sids,
    635                                                  &result->num_sids);
    636                 if (!NT_STATUS_IS_OK(status)) {
    637                         result->sam_account = NULL; /* Don't free on error exit. */
    638                         TALLOC_FREE(result);
    639                         return status;
    640                 }
    641         }
    642 
    643614        /* For now we throw away the gids and convert via sid_to_gid
    644615         * later. This needs fixing, but I'd like to get the code straight and
     
    651622
    652623        *server_info = result;
     624        /* Ensure thaat the sampass will be freed with the result */
     625        talloc_steal(result, sampass);
    653626
    654627        return NT_STATUS_OK;
     
    701674        NTSTATUS status;
    702675        size_t i;
    703        
    704 
    705         mem_ctx = talloc_new(NULL);
    706         if (mem_ctx == NULL) {
    707                 DEBUG(0, ("talloc_new failed\n"));
    708                 return NT_STATUS_NO_MEMORY;
    709         }
     676        struct dom_sid tmp_sid;
    710677
    711678        /*
     
    736703
    737704        if (!NT_STATUS_IS_OK(status)) {
    738                 TALLOC_FREE(mem_ctx);
    739705                return status;
    740706        }
     
    759725                                        &server_info->n_groups);
    760726        }
    761        
     727
     728        if (!uid_to_unix_users_sid(server_info->uid, &tmp_sid)) {
     729                DEBUG(1,("create_local_token: Failed to create SID "
     730                        "for uid %d!\n", server_info->uid));
     731        }
     732        add_sid_to_array_unique(server_info->ptok, &tmp_sid,
     733                                &server_info->ptok->user_sids,
     734                                &server_info->ptok->num_sids);
     735
     736        if (!gid_to_unix_groups_sid( server_info->gid, &tmp_sid)) {
     737                DEBUG(1,("create_local_token: Failed to create SID "
     738                        "for gid %d!\n", server_info->gid));
     739        }
     740        add_sid_to_array_unique(server_info->ptok, &tmp_sid,
     741                                &server_info->ptok->user_sids,
     742                                &server_info->ptok->num_sids);
     743
     744        for ( i=0; i<server_info->n_groups; i++ ) {
     745                if (!gid_to_unix_groups_sid( server_info->groups[i], &tmp_sid ) ) {
     746                        DEBUG(1,("create_local_token: Failed to create SID "
     747                                "for gid %d!\n", server_info->groups[i]));
     748                        continue;
     749                }
     750                add_sid_to_array_unique(server_info->ptok, &tmp_sid,
     751                                        &server_info->ptok->user_sids,
     752                                        &server_info->ptok->num_sids);
     753        }
     754
    762755        debug_nt_user_token(DBGC_AUTH, 10, server_info->ptok);
     756        debug_unix_user_token(DBGC_AUTH, 10,
     757                              server_info->uid,
     758                              server_info->gid,
     759                              server_info->n_groups,
     760                              server_info->groups);
     761
     762        mem_ctx = talloc_new(NULL);
     763        if (mem_ctx == NULL) {
     764                DEBUG(0, ("talloc_new failed\n"));
     765                return NT_STATUS_NO_MEMORY;
     766        }
    763767
    764768        status = log_nt_token(mem_ctx, server_info->ptok);
     
    769773
    770774/*
    771  * Create an artificial NT token given just a username. (Initially indended
     775 * Create an artificial NT token given just a username. (Initially intended
    772776 * for force user)
    773777 *
     
    822826        }
    823827
    824         if (!sid_to_uid(&user_sid, uid)) {
    825                 DEBUG(1, ("sid_to_uid for %s (%s) failed\n",
    826                           username, sid_string_dbg(&user_sid)));
    827                 goto done;
    828         }
    829 
    830828        if (sid_check_is_in_our_domain(&user_sid)) {
    831829                bool ret;
     
    884882
    885883        unix_user:
     884
     885                if (!sid_to_uid(&user_sid, uid)) {
     886                        DEBUG(1, ("sid_to_uid for %s (%s) failed\n",
     887                                  username, sid_string_dbg(&user_sid)));
     888                        goto done;
     889                }
    886890
    887891                uid_to_unix_users_sid(*uid, &user_sid);
Note: See TracChangeset for help on using the changeset viewer.