Ignore:
Timestamp:
Nov 27, 2012, 4:43:17 PM (13 years ago)
Author:
Silvan Scherrer
Message:

Samba Server: updated trunk to 3.6.0

Location:
trunk/server
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/server

  • trunk/server/source3/auth/auth_server.c

    r414 r745  
    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"
     23#include "system/passwd.h"
     24#include "smbd/smbd.h"
     25#include "libsmb/libsmb.h"
    2226
    2327#undef DBGC_CLASS
     
    136140        */
    137141
    138         if (!NT_STATUS_IS_OK(cli_session_setup(cli, "", "", 0, "", 0,
    139                                                ""))) {
     142        status = cli_session_setup(cli, "", "", 0, "", 0, "");
     143        if (!NT_STATUS_IS_OK(status)) {
    140144                TALLOC_FREE(mutex);
    141145                DEBUG(0,("%s rejected the initial session setup (%s)\n",
    142                          desthost, cli_errstr(cli)));
     146                         desthost, nt_errstr(status)));
    143147                cli_shutdown(cli);
    144148                return NULL;
     
    207211                interval.tv_usec = 0;
    208212
    209                 if (event_add_idle(smbd_event_context(), result, interval,
     213                if (event_add_idle(server_event_context(), result, interval,
    210214                                   "server_security_keepalive",
    211215                                   send_server_keepalive,
     
    229233{
    230234        struct cli_state *cli = server_cryptkey(mem_ctx);
    231        
     235
    232236        if (cli) {
    233237                DEBUG(3,("using password server validation\n"));
     
    237241                           unless 'encrypt passwords = no' */
    238242                        DEBUG(5,("make_auth_info_server: Server is unencrypted, no challenge available..\n"));
    239                        
     243
    240244                        /* However, it is still a perfectly fine connection
    241245                           to pass that unencrypted password over */
     
    256260                /* The return must be allocated on the caller's mem_ctx, as our own will be
    257261                   destoyed just after the call. */
    258                 return data_blob_talloc(auth_context->mem_ctx, cli->secblob.data,8);
     262                return data_blob_talloc((TALLOC_CTX *)auth_context, cli->secblob.data,8);
    259263        } else {
    260264                return data_blob_null;
     
    271275                                         void *my_private_data,
    272276                                         TALLOC_CTX *mem_ctx,
    273                                          const auth_usersupplied_info *user_info,
    274                                          auth_serversupplied_info **server_info)
    275 {
    276         struct server_security_state *state = talloc_get_type_abort(
    277                 my_private_data, struct server_security_state);
    278         struct cli_state *cli;
     277                                         const struct auth_usersupplied_info *user_info,
     278                                         struct auth_serversupplied_info **server_info)
     279{
     280        struct server_security_state *state = NULL;
     281        struct cli_state *cli = NULL;
    279282        static bool tested_password_server = False;
    280283        static bool bad_password_server = False;
     
    282285        bool locally_made_cli = False;
    283286
     287        DEBUG(10, ("check_smbserver_security: Check auth for: [%s]\n",
     288                user_info->mapped.account_name));
     289
     290        if (my_private_data == NULL) {
     291                DEBUG(10,("check_smbserver_security: "
     292                        "password server is not connected\n"));
     293                return NT_STATUS_LOGON_FAILURE;
     294        }
     295
     296        state = talloc_get_type_abort(my_private_data, struct server_security_state);
    284297        cli = state->cli;
    285        
     298
    286299        if (cli) {
    287300        } else {
     
    294307                return NT_STATUS_LOGON_FAILURE;
    295308        } 
    296        
     309
    297310        if ((cli->sec_mode & NEGOTIATE_SECURITY_CHALLENGE_RESPONSE) == 0) {
    298                 if (user_info->encrypted) {
     311                if (user_info->password_state != AUTH_PASSWORD_PLAIN) {
    299312                        DEBUG(1,("password server %s is plaintext, but we are encrypted. This just can't work :-(\n", cli->desthost));
    300313                        return NT_STATUS_LOGON_FAILURE;         
     
    325338                memset(badpass, 0x1f, sizeof(badpass));
    326339
    327                 if((user_info->nt_resp.length == sizeof(badpass)) &&
    328                    !memcmp(badpass, user_info->nt_resp.data, sizeof(badpass))) {
     340                if((user_info->password.response.nt.length == sizeof(badpass)) &&
     341                   !memcmp(badpass, user_info->password.response.nt.data, sizeof(badpass))) {
    329342                        /*
    330343                         * Very unlikely, our random bad password is the same as the users
     
    347360                                                      (char *)badpass,
    348361                                                      sizeof(badpass),
    349                                                       user_info->domain))) {
     362                                                      user_info->mapped.domain_name))) {
    350363
    351364                        /*
     
    390403         * not guest enabled, we can try with the real password.
    391404         */
    392 
    393         if (!user_info->encrypted) {
     405        switch (user_info->password_state) {
     406        case AUTH_PASSWORD_PLAIN:
    394407                /* Plaintext available */
    395408                nt_status = cli_session_setup(
    396                         cli, user_info->smb_name,
    397                         (char *)user_info->plaintext_password.data,
    398                         user_info->plaintext_password.length,
    399                         NULL, 0, user_info->domain);
    400 
    401         } else {
     409                        cli, user_info->client.account_name,
     410                        user_info->password.plaintext,
     411                        strlen(user_info->password.plaintext),
     412                        NULL, 0, user_info->mapped.domain_name);
     413                break;
     414
     415        /* currently the hash values include a challenge-response as well */
     416        case AUTH_PASSWORD_HASH:
     417        case AUTH_PASSWORD_RESPONSE:
    402418                nt_status = cli_session_setup(
    403                         cli, user_info->smb_name,
    404                         (char *)user_info->lm_resp.data,
    405                         user_info->lm_resp.length,
    406                         (char *)user_info->nt_resp.data,
    407                         user_info->nt_resp.length,
    408                         user_info->domain);
     419                        cli, user_info->client.account_name,
     420                        (char *)user_info->password.response.lanman.data,
     421                        user_info->password.response.lanman.length,
     422                        (char *)user_info->password.response.nt.data,
     423                        user_info->password.response.nt.length,
     424                        user_info->mapped.domain_name);
     425                break;
     426        default:
     427                DEBUG(0,("user_info constructed for user '%s' was invalid - password_state=%u invalid.\n",user_info->mapped.account_name, user_info->password_state));
     428                nt_status = NT_STATUS_INTERNAL_ERROR;
    409429        }
    410430
     
    415435
    416436        /* if logged in as guest then reject */
    417         if ((SVAL(cli->inbuf,smb_vwv2) & 1) != 0) {
     437        if (cli->is_guestlogin) {
    418438                DEBUG(1,("password server %s gave us guest only\n", cli->desthost));
    419439                nt_status = NT_STATUS_LOGON_FAILURE;
     
    423443
    424444        if (NT_STATUS_IS_OK(nt_status)) {
    425                 fstring real_username;
    426                 struct passwd *pass;
    427 
    428                 if ( (pass = smb_getpwnam( NULL, user_info->internal_username,
    429                         real_username, True )) != NULL )
     445                char *real_username = NULL;
     446                struct passwd *pass = NULL;
     447
     448                if ( (pass = smb_getpwnam(talloc_tos(), user_info->mapped.account_name,
     449                        &real_username, True )) != NULL )
    430450                {
    431                         /* if a real user check pam account restrictions */
    432                         /* only really perfomed if "obey pam restriction" is true */
    433                         nt_status = smb_pam_accountcheck(pass->pw_name);
    434                         if (  !NT_STATUS_IS_OK(nt_status)) {
    435                                 DEBUG(1, ("PAM account restriction prevents user login\n"));
    436                         } else {
    437 
    438                                 nt_status = make_server_info_pw(server_info, pass->pw_name, pass);
    439                         }
     451                        nt_status = make_server_info_pw(server_info, pass->pw_name, pass);
    440452                        TALLOC_FREE(pass);
     453                        TALLOC_FREE(real_username);
    441454                }
    442455                else
     
    455468static NTSTATUS auth_init_smbserver(struct auth_context *auth_context, const char* param, auth_methods **auth_method)
    456469{
    457         if (!make_auth_methods(auth_context, auth_method)) {
     470        struct auth_methods *result;
     471
     472        result = TALLOC_ZERO_P(auth_context, struct auth_methods);
     473        if (result == NULL) {
    458474                return NT_STATUS_NO_MEMORY;
    459475        }
    460         (*auth_method)->name = "smbserver";
    461         (*auth_method)->auth = check_smbserver_security;
    462         (*auth_method)->get_chal = auth_get_challenge_server;
     476        result->name = "smbserver";
     477        result->auth = check_smbserver_security;
     478        result->get_chal = auth_get_challenge_server;
     479
     480        *auth_method = result;
    463481        return NT_STATUS_OK;
    464482}
Note: See TracChangeset for help on using the changeset viewer.