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/auth/auth.c

    r414 r740  
    1919
    2020#include "includes.h"
     21#include "auth.h"
     22#include "smbd/globals.h"
    2123
    2224#undef DBGC_CLASS
     
    2527static_decl_auth;
    2628
    27 static struct auth_init_function_entry *backends = NULL;
     29static struct auth_init_function_entry *auth_backends = NULL;
    2830
    2931static struct auth_init_function_entry *auth_find_backend_entry(const char *name);
     
    3133NTSTATUS smb_register_auth(int version, const char *name, auth_init_function init)
    3234{
    33         struct auth_init_function_entry *entry = backends;
     35        struct auth_init_function_entry *entry = auth_backends;
    3436
    3537        if (version != AUTH_INTERFACE_VERSION) {
     
    5557        entry->init = init;
    5658
    57         DLIST_ADD(backends, entry);
     59        DLIST_ADD(auth_backends, entry);
    5860        DEBUG(5,("Successfully added auth method '%s'\n", name));
    5961        return NT_STATUS_OK;
     
    6264static struct auth_init_function_entry *auth_find_backend_entry(const char *name)
    6365{
    64         struct auth_init_function_entry *entry = backends;
     66        struct auth_init_function_entry *entry = auth_backends;
    6567
    6668        while(entry) {
     
    7779****************************************************************************/
    7880
    79 static void get_ntlm_challenge(struct auth_context *auth_context,
     81static NTSTATUS get_ntlm_challenge(struct auth_context *auth_context,
    8082                               uint8_t chal[8])
    8183{
     
    8890                          auth_context->challenge_set_by));
    8991                memcpy(chal, auth_context->challenge.data, 8);
    90                 return;
     92                return NT_STATUS_OK;
    9193        }
    9294
     
    107109
    108110                challenge = auth_method->get_chal(auth_context, &auth_method->private_data,
    109                                         auth_context->mem_ctx);
     111                                                  auth_context);
    110112                if (!challenge.length) {
    111113                        DEBUG(3, ("auth_get_challenge: getting challenge from authentication method %s FAILED.\n",
     
    123125
    124126                generate_random_buffer(tmp, sizeof(tmp));
    125                 auth_context->challenge = data_blob_talloc(auth_context->mem_ctx,
     127                auth_context->challenge = data_blob_talloc(auth_context,
    126128                                                           tmp, sizeof(tmp));
    127129
     
    139141
    140142        memcpy(chal, auth_context->challenge.data, 8);
     143        return NT_STATUS_OK;
    141144}
    142145
     
    214217
    215218        DEBUG(3, ("check_ntlm_password:  Checking password for unmapped user [%s]\\[%s]@[%s] with the new password interface\n",
    216                   user_info->client_domain, user_info->smb_name, user_info->wksta_name));
     219                  user_info->client.domain_name, user_info->client.account_name, user_info->workstation_name));
    217220
    218221        DEBUG(3, ("check_ntlm_password:  mapped user is: [%s]\\[%s]@[%s]\n",
    219                   user_info->domain, user_info->internal_username, user_info->wksta_name));
     222                  user_info->mapped.domain_name, user_info->mapped.account_name, user_info->workstation_name));
    220223
    221224        if (auth_context->challenge.length != 8) {
     
    233236#ifdef DEBUG_PASSWORD
    234237        DEBUG(100, ("user_info has passwords of length %d and %d\n",
    235                     (int)user_info->lm_resp.length, (int)user_info->nt_resp.length));
     238                    (int)user_info->password.response.lanman.length, (int)user_info->password.response.nt.length));
    236239        DEBUG(100, ("lm:\n"));
    237         dump_data(100, user_info->lm_resp.data, user_info->lm_resp.length);
     240        dump_data(100, user_info->password.response.lanman.data, user_info->password.response.lanman.length);
    238241        DEBUG(100, ("nt:\n"));
    239         dump_data(100, user_info->nt_resp.data, user_info->nt_resp.length);
     242        dump_data(100, user_info->password.response.nt.data, user_info->password.response.nt.length);
    240243#endif
    241244
    242245        /* This needs to be sorted:  If it doesn't match, what should we do? */
    243         if (!check_domain_match(user_info->smb_name, user_info->domain))
     246        if (!check_domain_match(user_info->client.account_name, user_info->mapped.domain_name))
    244247                return NT_STATUS_LOGON_FAILURE;
    245248
     
    247250                NTSTATUS result;
    248251
    249                 mem_ctx = talloc_init("%s authentication for user %s\\%s", auth_method->name, 
    250                                             user_info->domain, user_info->smb_name);
     252                mem_ctx = talloc_init("%s authentication for user %s\\%s", auth_method->name,
     253                                      user_info->mapped.domain_name, user_info->client.account_name);
    251254
    252255                result = auth_method->auth(auth_context, auth_method->private_data, mem_ctx, user_info, server_info);
     
    263266                if (NT_STATUS_IS_OK(nt_status)) {
    264267                        DEBUG(3, ("check_ntlm_password: %s authentication for user [%s] succeeded\n",
    265                                   auth_method->name, user_info->smb_name));
     268                                  auth_method->name, user_info->client.account_name));
    266269                } else {
    267270                        DEBUG(5, ("check_ntlm_password: %s authentication for user [%s] FAILED with error %s\n",
    268                                   auth_method->name, user_info->smb_name, nt_errstr(nt_status)));
     271                                  auth_method->name, user_info->client.account_name, nt_errstr(nt_status)));
    269272                }
    270273
     
    284287                        /* We might not be root if we are an RPC call */
    285288                        become_root();
    286                         nt_status = smb_pam_accountcheck(unix_username);
     289                        nt_status = smb_pam_accountcheck(
     290                                unix_username,
     291                                smbd_server_conn->client_id.name);
    287292                        unbecome_root();
    288293
     
    298303                if (NT_STATUS_IS_OK(nt_status)) {
    299304                        DEBUG((*server_info)->guest ? 5 : 2,
    300                               ("check_ntlm_password:  %sauthentication for user [%s] -> [%s] -> [%s] succeeded\n", 
    301                                (*server_info)->guest ? "guest " : "", 
    302                                user_info->smb_name,
    303                                user_info->internal_username,
     305                              ("check_ntlm_password:  %sauthentication for user [%s] -> [%s] -> [%s] succeeded\n",
     306                               (*server_info)->guest ? "guest " : "",
     307                               user_info->client.account_name,
     308                               user_info->mapped.account_name,
    304309                               unix_username));
    305310                }
     
    310315        /* failed authentication; check for guest lapping */
    311316
    312         DEBUG(2, ("check_ntlm_password:  Authentication for user [%s] -> [%s] FAILED with error %s\n", 
    313                   user_info->smb_name, user_info->internal_username,
     317        DEBUG(2, ("check_ntlm_password:  Authentication for user [%s] -> [%s] FAILED with error %s\n",
     318                  user_info->client.account_name, user_info->mapped.account_name,
    314319                  nt_errstr(nt_status)));
    315         ZERO_STRUCTP(server_info); 
     320        ZERO_STRUCTP(server_info);
    316321
    317322        return nt_status;
     
    322327***************************************************************************/
    323328
    324 static void free_auth_context(struct auth_context **auth_context)
    325 {
    326         auth_methods *auth_method;
    327 
    328         if (*auth_context) {
    329                 /* Free private data of context's authentication methods */
    330                 for (auth_method = (*auth_context)->auth_method_list; auth_method; auth_method = auth_method->next) {
    331                         TALLOC_FREE(auth_method->private_data);
    332                 }
    333 
    334                 talloc_destroy((*auth_context)->mem_ctx);
    335                 *auth_context = NULL;
    336         }
     329static int auth_context_destructor(void *ptr)
     330{
     331        struct auth_context *ctx = talloc_get_type(ptr, struct auth_context);
     332        struct auth_methods *am;
     333
     334
     335        /* Free private data of context's authentication methods */
     336        for (am = ctx->auth_method_list; am; am = am->next) {
     337                TALLOC_FREE(am->private_data);
     338        }
     339
     340        return 0;
    337341}
    338342
     
    341345***************************************************************************/
    342346
    343 static NTSTATUS make_auth_context(struct auth_context **auth_context)
    344 {
    345         TALLOC_CTX *mem_ctx;
    346 
    347         mem_ctx = talloc_init("authentication context");
    348 
    349         *auth_context = TALLOC_P(mem_ctx, struct auth_context);
    350         if (!*auth_context) {
     347static NTSTATUS make_auth_context(TALLOC_CTX *mem_ctx,
     348                                  struct auth_context **auth_context)
     349{
     350        struct auth_context *ctx;
     351
     352        ctx = talloc_zero(mem_ctx, struct auth_context);
     353        if (!ctx) {
    351354                DEBUG(0,("make_auth_context: talloc failed!\n"));
    352                 talloc_destroy(mem_ctx);
    353355                return NT_STATUS_NO_MEMORY;
    354356        }
    355         ZERO_STRUCTP(*auth_context);
    356 
    357         (*auth_context)->mem_ctx = mem_ctx;
    358         (*auth_context)->check_ntlm_password = check_ntlm_password;
    359         (*auth_context)->get_ntlm_challenge = get_ntlm_challenge;
    360         (*auth_context)->free = free_auth_context;
    361 
     357
     358        ctx->check_ntlm_password = check_ntlm_password;
     359        ctx->get_ntlm_challenge = get_ntlm_challenge;
     360
     361        talloc_set_destructor((TALLOC_CTX *)ctx, auth_context_destructor);
     362
     363        *auth_context = ctx;
    362364        return NT_STATUS_OK;
    363365}
     
    421423***************************************************************************/
    422424
    423 static NTSTATUS make_auth_context_text_list(struct auth_context **auth_context, char **text_list)
     425static NTSTATUS make_auth_context_text_list(TALLOC_CTX *mem_ctx,
     426                                            struct auth_context **auth_context,
     427                                            char **text_list)
    424428{
    425429        auth_methods *list = NULL;
     
    432436        }
    433437
    434         if (!NT_STATUS_IS_OK(nt_status = make_auth_context(auth_context)))
     438        nt_status = make_auth_context(mem_ctx, auth_context);
     439
     440        if (!NT_STATUS_IS_OK(nt_status)) {
    435441                return nt_status;
     442        }
    436443
    437444        for (;*text_list; text_list++) {
     
    450457***************************************************************************/
    451458
    452 NTSTATUS make_auth_context_subsystem(struct auth_context **auth_context)
     459NTSTATUS make_auth_context_subsystem(TALLOC_CTX *mem_ctx,
     460                                     struct auth_context **auth_context)
    453461{
    454462        char **auth_method_list = NULL;
     
    521529        }
    522530
    523         nt_status = make_auth_context_text_list(auth_context,
     531        nt_status = make_auth_context_text_list(mem_ctx, auth_context,
    524532                                                auth_method_list);
    525533
     
    532540***************************************************************************/
    533541
    534 NTSTATUS make_auth_context_fixed(struct auth_context **auth_context, uchar chal[8])
     542NTSTATUS make_auth_context_fixed(TALLOC_CTX *mem_ctx,
     543                                 struct auth_context **auth_context,
     544                                 uchar chal[8])
    535545{
    536546        NTSTATUS nt_status;
    537         if (!NT_STATUS_IS_OK(nt_status = make_auth_context_subsystem(auth_context))) {
     547        nt_status = make_auth_context_subsystem(mem_ctx, auth_context);
     548        if (!NT_STATUS_IS_OK(nt_status)) {
    538549                return nt_status;
    539550        }
    540551
    541         (*auth_context)->challenge = data_blob_talloc((*auth_context)->mem_ctx, chal, 8);
     552        (*auth_context)->challenge = data_blob_talloc(*auth_context, chal, 8);
    542553        (*auth_context)->challenge_set_by = "fixed";
    543554        return nt_status;
Note: See TracChangeset for help on using the changeset viewer.