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_unix.c

    r414 r745  
    33   Password and authentication handling
    44   Copyright (C) Andrew Bartlett              2001
    5    
     5
    66   This program is free software; you can redistribute it and/or modify
    77   it under the terms of the GNU General Public License as published by
    88   the Free Software Foundation; either version 3 of the License, or
    99   (at your option) any later version.
    10    
     10
    1111   This program is distributed in the hope that it will be useful,
    1212   but WITHOUT ANY WARRANTY; without even the implied warranty of
    1313   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    1414   GNU General Public License for more details.
    15    
     15
    1616   You should have received a copy of the GNU General Public License
    1717   along with this program.  If not, see <http://www.gnu.org/licenses/>.
     
    1919
    2020#include "includes.h"
     21#include "auth.h"
     22#include "system/passwd.h"
     23#include "smbd/globals.h"
    2124
    2225#undef DBGC_CLASS
    2326#define DBGC_CLASS DBGC_AUTH
    24 
    25 /**
    26  * update the encrypted smbpasswd file from the plaintext username and password
    27  * 
    28  *  this ugly hack needs to die, but not quite yet, I think people still use it...
    29  **/
    30 static bool update_smbpassword_file(const char *user, const char *password)
    31 {
    32         struct samu     *sampass;
    33         bool            ret;
    34        
    35         if ( !(sampass = samu_new( NULL )) ) {
    36                 return False;
    37         }
    38        
    39         become_root();
    40         ret = pdb_getsampwnam(sampass, user);
    41         unbecome_root();
    42 
    43         if(ret == False) {
    44                 DEBUG(0,("pdb_getsampwnam returned NULL\n"));
    45                 TALLOC_FREE(sampass);
    46                 return False;
    47         }
    48 
    49         /*
    50          * Remove the account disabled flag - we are updating the
    51          * users password from a login.
    52          */
    53         if (!pdb_set_acct_ctrl(sampass, pdb_get_acct_ctrl(sampass) & ~ACB_DISABLED, PDB_CHANGED)) {
    54                 TALLOC_FREE(sampass);
    55                 return False;
    56         }
    57 
    58         if (!pdb_set_plaintext_passwd (sampass, password)) {
    59                 TALLOC_FREE(sampass);
    60                 return False;
    61         }
    62 
    63         /* Now write it into the file. */
    64         become_root();
    65 
    66         ret = NT_STATUS_IS_OK(pdb_update_sam_account (sampass));
    67 
    68         unbecome_root();
    69 
    70         if (ret) {
    71                 DEBUG(3,("pdb_update_sam_account returned %d\n",ret));
    72         }
    73 
    74         TALLOC_FREE(sampass);
    75         return ret;
    76 }
    77 
    7827
    7928/** Check a plaintext username/password
     
    8635                             void *my_private_data,
    8736                             TALLOC_CTX *mem_ctx,
    88                              const auth_usersupplied_info *user_info,
    89                              auth_serversupplied_info **server_info)
     37                             const struct auth_usersupplied_info *user_info,
     38                             struct auth_serversupplied_info **server_info)
    9039{
    9140        NTSTATUS nt_status;
    9241        struct passwd *pass = NULL;
    9342
     43        DEBUG(10, ("Check auth for: [%s]\n", user_info->mapped.account_name));
     44
    9445        become_root();
    95         pass = Get_Pwnam_alloc(talloc_tos(), user_info->internal_username);
     46        pass = Get_Pwnam_alloc(talloc_tos(), user_info->mapped.account_name);
    9647
    97        
    9848        /** @todo This call assumes a ASCII password, no charset transformation is
    9949            done.  We may need to revisit this **/
    10050        nt_status = pass_check(pass,
    101                                 pass ? pass->pw_name : user_info->internal_username,
    102                                 (char *)user_info->plaintext_password.data,
    103                                 user_info->plaintext_password.length-1,
    104                                 lp_update_encrypted() ?
    105                                 update_smbpassword_file : NULL,
    106                                 True);
    107        
     51                                pass ? pass->pw_name : user_info->mapped.account_name,
     52                               smbd_server_conn->client_id.name,
     53                                user_info->password.plaintext,
     54                                true);
     55
    10856        unbecome_root();
    10957
    11058        if (NT_STATUS_IS_OK(nt_status)) {
    11159                if (pass) {
    112                         /* if a real user check pam account restrictions */
    113                         /* only really perfomed if "obey pam restriction" is true */
    114                         nt_status = smb_pam_accountcheck(pass->pw_name);
    115                         if (  !NT_STATUS_IS_OK(nt_status)) {
    116                                 DEBUG(1, ("PAM account restriction prevents user login\n"));
    117                         } else {
    118                                 make_server_info_pw(server_info, pass->pw_name, pass);
    119                         }
     60                        make_server_info_pw(server_info, pass->pw_name, pass);
    12061                } else {
    12162                        /* we need to do somthing more useful here */
     
    13172static NTSTATUS auth_init_unix(struct auth_context *auth_context, const char* param, auth_methods **auth_method)
    13273{
    133         if (!make_auth_methods(auth_context, auth_method)) {
     74        struct auth_methods *result;
     75
     76        result = TALLOC_ZERO_P(auth_context, struct auth_methods);
     77        if (result == NULL) {
    13478                return NT_STATUS_NO_MEMORY;
    13579        }
     80        result->name = "unix";
     81        result->auth = check_unix_security;
    13682
    137         (*auth_method)->name = "unix";
    138         (*auth_method)->auth = check_unix_security;
     83        *auth_method = result;
    13984        return NT_STATUS_OK;
    14085}
Note: See TracChangeset for help on using the changeset viewer.