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

Samba Server: update vendor to 3.6.0

File:
1 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified vendor/current/source3/auth/auth_domain.c

    r594 r740  
    44   Copyright (C) Andrew Tridgell 1992-1998
    55   Copyright (C) Andrew Bartlett 2001
    6    
     6
    77   This program is free software; you can redistribute it and/or modify
    88   it under the terms of the GNU General Public License as published by
    99   the Free Software Foundation; either version 3 of the License, or
    1010   (at your option) any later version.
    11    
     11
    1212   This program is distributed in the hope that it will be useful,
    1313   but WITHOUT ANY WARRANTY; without even the implied warranty of
    1414   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    1515   GNU General Public License for more details.
    16    
     16
    1717   You should have received a copy of the GNU General Public License
    1818   along with this program.  If not, see <http://www.gnu.org/licenses/>.
     
    2020
    2121#include "includes.h"
     22#include "auth.h"
    2223#include "../libcli/auth/libcli_auth.h"
     24#include "../librpc/gen_ndr/ndr_netlogon.h"
     25#include "rpc_client/cli_pipe.h"
     26#include "rpc_client/cli_netlogon.h"
     27#include "secrets.h"
     28#include "passdb.h"
     29#include "libsmb/libsmb.h"
    2330
    2431#undef DBGC_CLASS
     
    111118                                                const char *dc_name,
    112119                                                struct sockaddr_storage *dc_ss,
    113                                                 struct rpc_pipe_client **pipe_ret,
    114                                                 bool *retry)
     120                                                struct rpc_pipe_client **pipe_ret)
    115121{
    116122        NTSTATUS result;
     
    139145                return NT_STATUS_NO_LOGON_SERVERS;
    140146        }
    141        
     147
    142148        /* Attempt connection */
    143         *retry = True;
    144149        result = cli_full_connection(cli, global_myname(), dc_name, dc_ss, 0,
    145                 "IPC$", "IPC", "", "", "", 0, Undefined, retry);
     150                "IPC$", "IPC", "", "", "", 0, Undefined);
    146151
    147152        if (!NT_STATUS_IS_OK(result)) {
     
    252257
    253258static NTSTATUS domain_client_validate(TALLOC_CTX *mem_ctx,
    254                                         const auth_usersupplied_info *user_info,
     259                                        const struct auth_usersupplied_info *user_info,
    255260                                        const char *domain,
    256261                                        uchar chal[8],
    257                                         auth_serversupplied_info **server_info,
     262                                        struct auth_serversupplied_info **server_info,
    258263                                        const char *dc_name,
    259264                                        struct sockaddr_storage *dc_ss)
     
    265270        NTSTATUS nt_status = NT_STATUS_NO_LOGON_SERVERS;
    266271        int i;
    267         bool retry = True;
    268272
    269273        /*
     
    276280
    277281        /* rety loop for robustness */
    278        
    279         for (i = 0; !NT_STATUS_IS_OK(nt_status) && retry && (i < 3); i++) {
     282
     283        for (i = 0; !NT_STATUS_IS_OK(nt_status) && (i < 3); i++) {
    280284                nt_status = connect_to_domain_password_server(&cli,
    281285                                                        domain,
    282286                                                        dc_name,
    283287                                                        dc_ss,
    284                                                         &netlogon_pipe,
    285                                                         &retry);
     288                                                        &netlogon_pipe);
    286289        }
    287290
     
    305308        nt_status = rpccli_netlogon_sam_network_logon(netlogon_pipe,
    306309                                                      mem_ctx,
    307                                                       user_info->logon_parameters,/* flags such as 'allow workstation logon' */
    308                                                       dc_name,                    /* server name */
    309                                                       user_info->smb_name,        /* user name logging on. */
    310                                                       user_info->client_domain,   /* domain name */
    311                                                       user_info->wksta_name,      /* workstation name */
    312                                                       chal,                       /* 8 byte challenge. */
    313                                                       3,                          /* validation level */
    314                                                       user_info->lm_resp,        /* lanman 24 byte response */
    315                                                       user_info->nt_resp,         /* nt 24 byte response */
    316                                                       &info3);                    /* info3 out */
     310                                                      user_info->logon_parameters,         /* flags such as 'allow workstation logon' */
     311                                                      dc_name,                             /* server name */
     312                                                      user_info->client.account_name,      /* user name logging on. */
     313                                                      user_info->client.domain_name,       /* domain name */
     314                                                      user_info->workstation_name,         /* workstation name */
     315                                                      chal,                                /* 8 byte challenge. */
     316                                                      3,                                   /* validation level */
     317                                                      user_info->password.response.lanman, /* lanman 24 byte response */
     318                                                      user_info->password.response.nt,     /* nt 24 byte response */
     319                                                      &info3);                             /* info3 out */
    317320
    318321        /* Let go as soon as possible so we avoid any potential deadlocks
    319322           with winbind lookup up users or groups. */
    320            
     323
    321324        TALLOC_FREE(mutex);
    322325
     
    324327                DEBUG(0,("domain_client_validate: unable to validate password "
    325328                         "for user %s in domain %s to Domain controller %s. "
    326                          "Error was %s.\n", user_info->smb_name,
    327                          user_info->client_domain, dc_name,
     329                         "Error was %s.\n", user_info->client.account_name,
     330                         user_info->client.domain_name, dc_name,
    328331                         nt_errstr(nt_status)));
    329332
     
    334337        } else {
    335338                nt_status = make_server_info_info3(mem_ctx,
    336                                                 user_info->smb_name,
    337                                                 domain,
    338                                                 server_info,
    339                                                 info3);
     339                                                   user_info->client.account_name,
     340                                                   domain,
     341                                                   server_info,
     342                                                   info3);
    340343
    341344                if (NT_STATUS_IS_OK(nt_status)) {
    342345                        (*server_info)->nss_token |= user_info->was_mapped;
    343 
    344                         if ( ! (*server_info)->guest) {
    345                                 /* if a real user check pam account restrictions */
    346                                 /* only really perfomed if "obey pam restriction" is true */
    347                                 nt_status = smb_pam_accountcheck((*server_info)->unix_name);
    348                                 if (  !NT_STATUS_IS_OK(nt_status)) {
    349                                         DEBUG(1, ("PAM account restriction prevents user login\n"));
    350                                         cli_shutdown(cli);
    351                                         TALLOC_FREE(info3);
    352                                         return nt_status;
    353                                 }
    354                         }
    355                 }
    356 
    357                 netsamlogon_cache_store(user_info->smb_name, info3);
    358                 TALLOC_FREE(info3);
     346                        netsamlogon_cache_store(user_info->client.account_name, info3);
     347                        TALLOC_FREE(info3);
     348                }
    359349        }
    360350
     
    374364                                        void *my_private_data,
    375365                                        TALLOC_CTX *mem_ctx,
    376                                         const auth_usersupplied_info *user_info,
    377                                         auth_serversupplied_info **server_info)
     366                                        const struct auth_usersupplied_info *user_info,
     367                                        struct auth_serversupplied_info **server_info)
    378368{
    379369        NTSTATUS nt_status = NT_STATUS_LOGON_FAILURE;
     
    393383        }
    394384
     385        DEBUG(10, ("Check auth for: [%s]\n", user_info->mapped.account_name));
     386
    395387        /*
    396388         * Check that the requested domain is not our own machine name.
     
    399391         */
    400392
    401         if(strequal(get_global_sam_name(), user_info->domain)) {
     393        if(strequal(get_global_sam_name(), user_info->mapped.domain_name)) {
    402394                DEBUG(3,("check_ntdomain_security: Requested domain was for this machine.\n"));
    403395                return NT_STATUS_NOT_IMPLEMENTED;
     
    408400        if ( !get_dc_name(domain, NULL, dc_name, &dc_ss) ) {
    409401                DEBUG(5,("check_ntdomain_security: unable to locate a DC for domain %s\n",
    410                         user_info->domain));
     402                        user_info->mapped.domain_name));
    411403                return NT_STATUS_NO_LOGON_SERVERS;
    412404        }
    413        
     405
    414406        nt_status = domain_client_validate(mem_ctx,
    415407                                        user_info,
     
    419411                                        dc_name,
    420412                                        &dc_ss);
    421                
     413
    422414        return nt_status;
    423415}
     
    426418static NTSTATUS auth_init_ntdomain(struct auth_context *auth_context, const char* param, auth_methods **auth_method)
    427419{
    428         if (!make_auth_methods(auth_context, auth_method)) {
     420        struct auth_methods *result;
     421
     422        result = TALLOC_ZERO_P(auth_context, struct auth_methods);
     423        if (result == NULL) {
    429424                return NT_STATUS_NO_MEMORY;
    430425        }
    431 
    432         (*auth_method)->name = "ntdomain";
    433         (*auth_method)->auth = check_ntdomain_security;
     426        result->name = "ntdomain";
     427        result->auth = check_ntdomain_security;
     428
     429        *auth_method = result;
    434430        return NT_STATUS_OK;
    435431}
     
    443439                                           void *my_private_data,
    444440                                           TALLOC_CTX *mem_ctx,
    445                                            const auth_usersupplied_info *user_info,
    446                                            auth_serversupplied_info **server_info)
     441                                           const struct auth_usersupplied_info *user_info,
     442                                           struct auth_serversupplied_info **server_info)
    447443{
    448444        NTSTATUS nt_status = NT_STATUS_LOGON_FAILURE;
     
    457453        }
    458454
     455        DEBUG(10, ("Check auth for: [%s]\n", user_info->mapped.account_name));
     456
    459457        /*
    460458         * Check that the requested domain is not our own machine name or domain name.
    461459         */
    462460
    463         if( strequal(get_global_sam_name(), user_info->domain)) {
     461        if( strequal(get_global_sam_name(), user_info->mapped.domain_name)) {
    464462                DEBUG(3,("check_trustdomain_security: Requested domain [%s] was for this machine.\n",
    465                         user_info->domain));
     463                        user_info->mapped.domain_name));
    466464                return NT_STATUS_NOT_IMPLEMENTED;
    467465        }
     
    471469           The logic is that if we know nothing about the domain, that
    472470           user is not known to us and does not exist */
    473        
    474         if ( !is_trusted_domain( user_info->domain ) )
     471
     472        if ( !is_trusted_domain( user_info->mapped.domain_name ) )
    475473                return NT_STATUS_NOT_IMPLEMENTED;
    476474
     
    480478         */
    481479
    482         if (!pdb_get_trusteddom_pw(user_info->domain, &trust_password,
     480        if (!pdb_get_trusteddom_pw(user_info->mapped.domain_name, &trust_password,
    483481                                   NULL, NULL)) {
    484482                DEBUG(0, ("check_trustdomain_security: could not fetch trust "
    485483                          "account password for domain %s\n",
    486                           user_info->domain));
     484                          user_info->mapped.domain_name));
    487485                return NT_STATUS_CANT_ACCESS_DOMAIN_INFO;
    488486        }
    489487
    490488#ifdef DEBUG_PASSWORD
    491         DEBUG(100, ("Trust password for domain %s is %s\n", user_info->domain,
     489        DEBUG(100, ("Trust password for domain %s is %s\n", user_info->mapped.domain_name,
    492490                    trust_password));
    493491#endif
     
    505503        /* use get_dc_name() for consistency even through we know that it will be
    506504           a netbios name */
    507            
    508         if ( !get_dc_name(user_info->domain, NULL, dc_name, &dc_ss) ) {
     505
     506        if ( !get_dc_name(user_info->mapped.domain_name, NULL, dc_name, &dc_ss) ) {
    509507                DEBUG(5,("check_trustdomain_security: unable to locate a DC for domain %s\n",
    510                         user_info->domain));
     508                        user_info->mapped.domain_name));
    511509                return NT_STATUS_NO_LOGON_SERVERS;
    512510        }
    513        
     511
    514512        nt_status = domain_client_validate(mem_ctx,
    515                                         user_info,
    516                                         user_info->domain,
    517                                         (uchar *)auth_context->challenge.data,
    518                                         server_info,
    519                                         dc_name,
    520                                         &dc_ss);
     513                                           user_info,
     514                                           user_info->mapped.domain_name,
     515                                           (uchar *)auth_context->challenge.data,
     516                                           server_info,
     517                                           dc_name,
     518                                           &dc_ss);
    521519
    522520        return nt_status;
     
    526524static NTSTATUS auth_init_trustdomain(struct auth_context *auth_context, const char* param, auth_methods **auth_method)
    527525{
    528         if (!make_auth_methods(auth_context, auth_method)) {
     526        struct auth_methods *result;
     527
     528        result = TALLOC_ZERO_P(auth_context, struct auth_methods);
     529        if (result == NULL) {
    529530                return NT_STATUS_NO_MEMORY;
    530531        }
    531 
    532         (*auth_method)->name = "trustdomain";
    533         (*auth_method)->auth = check_trustdomain_security;
     532        result->name = "trustdomain";
     533        result->auth = check_trustdomain_security;
     534
     535        *auth_method = result;
    534536        return NT_STATUS_OK;
    535537}
Note: See TracChangeset for help on using the changeset viewer.