Ignore:
Timestamp:
Nov 24, 2016, 1:14:11 PM (9 years ago)
Author:
Silvan Scherrer
Message:

Samba Server: update vendor to version 4.4.3

File:
1 edited

Legend:

Unmodified
Added
Removed
  • vendor/current/source3/libsmb/passchange.c

    r740 r988  
    33   SMB client password change routine
    44   Copyright (C) Andrew Tridgell 1994-1998
    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/>.
     
    2525#include "libsmb/clirap.h"
    2626#include "libsmb/nmblib.h"
     27#include "../libcli/smb/smbXcli_base.h"
    2728
    2829/*************************************************************
     
    3435                                char **err_str)
    3536{
    36         struct nmb_name calling, called;
    3737        struct cli_state *cli = NULL;
    3838        struct rpc_pipe_client *pipe_hnd = NULL;
    39         struct sockaddr_storage ss;
    4039        char *user, *domain, *p;
    4140
     
    5857        *err_str = NULL;
    5958
    60         if(!resolve_name( remote_machine, &ss, 0x20, false)) {
    61                 if (asprintf(err_str, "Unable to find an IP address for machine "
    62                          "%s.\n", remote_machine) == -1) {
    63                         *err_str = NULL;
    64                 }
    65                 return NT_STATUS_UNSUCCESSFUL;
    66         }
    67 
    68         cli = cli_initialise();
    69         if (!cli) {
    70                 return NT_STATUS_NO_MEMORY;
    71         }
    72 
    73         result = cli_connect(cli, remote_machine, &ss);
     59        result = cli_connect_nb(remote_machine, NULL, 0, 0x20, NULL,
     60                                SMB_SIGNING_IPC_DEFAULT, 0, &cli);
    7461        if (!NT_STATUS_IS_OK(result)) {
    7562                if (asprintf(err_str, "Unable to connect to SMB server on "
     
    7865                        *err_str = NULL;
    7966                }
    80                 cli_shutdown(cli);
    81                 return result;
    82         }
    83 
    84         make_nmb_name(&calling, global_myname() , 0x0);
    85         make_nmb_name(&called , remote_machine, 0x20);
    86 
    87         if (!cli_session_request(cli, &calling, &called)) {
    88                 if (asprintf(err_str, "machine %s rejected the session setup. "
    89                          "Error was : %s.\n",
    90                          remote_machine, cli_errstr(cli)) == -1) {
    91                         *err_str = NULL;
    92                 }
    93                 result = cli_nt_error(cli);
    94                 cli_shutdown(cli);
    95                 return result;
    96         }
    97 
    98         cli->protocol = PROTOCOL_NT1;
    99 
    100         result = cli_negprot(cli);
     67                return result;
     68        }
     69
     70        result = smbXcli_negprot(cli->conn, cli->timeout,
     71                                 lp_client_ipc_min_protocol(),
     72                                 lp_client_ipc_max_protocol());
    10173
    10274        if (!NT_STATUS_IS_OK(result)) {
     
    10678                        *err_str = NULL;
    10779                }
    108                 result = cli_nt_error(cli);
    10980                cli_shutdown(cli);
    11081                return result;
     
    12798                    !NT_STATUS_EQUAL(result, NT_STATUS_PASSWORD_EXPIRED)) {
    12899                        if (asprintf(err_str, "Could not connect to machine %s: "
    129                                  "%s\n", remote_machine, cli_errstr(cli)) == -1) {
     100                                 "%s\n", remote_machine, nt_errstr(result)) == -1) {
    130101                                *err_str = NULL;
    131102                        }
     
    147118                        if (asprintf(err_str, "machine %s rejected the session "
    148119                                 "setup. Error was : %s.\n",       
    149                                  remote_machine, cli_errstr(cli)) == -1) {
    150                                 *err_str = NULL;
    151                         }
    152                         cli_shutdown(cli);
    153                         return result;
    154                 }
    155 
    156                 result = cli_init_creds(cli, "", "", NULL);
    157                 if (!NT_STATUS_IS_OK(result)) {
    158                         cli_shutdown(cli);
    159                         return result;
    160                 }
    161         } else {
    162                 result = cli_init_creds(cli, user, domain, old_passwd);
    163                 if (!NT_STATUS_IS_OK(result)) {
    164                         cli_shutdown(cli);
    165                         return result;
    166                 }
    167         }
    168 
    169         result = cli_tcon_andx(cli, "IPC$", "IPC", "", 1);
     120                                 remote_machine, nt_errstr(result)) == -1) {
     121                                *err_str = NULL;
     122                        }
     123                        cli_shutdown(cli);
     124                        return result;
     125                }
     126        }
     127
     128        result = cli_tree_connect(cli, "IPC$", "IPC", "", 1);
    170129        if (!NT_STATUS_IS_OK(result)) {
    171130                if (asprintf(err_str, "machine %s rejected the tconX on the "
     
    181140
    182141        if (!pass_must_change) {
    183                 result = cli_rpc_pipe_open_ntlmssp(cli,
    184                                                    &ndr_table_samr.syntax_id,
    185                                                    NCACN_NP,
    186                                                    DCERPC_AUTH_LEVEL_PRIVACY,
    187                                                    domain, user,
    188                                                    old_passwd,
    189                                                    &pipe_hnd);
     142                result = cli_rpc_pipe_open_generic_auth(cli,
     143                                                        &ndr_table_samr,
     144                                                        NCACN_NP,
     145                                                        CRED_DONT_USE_KERBEROS,
     146                                                        DCERPC_AUTH_TYPE_NTLMSSP,
     147                                                        DCERPC_AUTH_LEVEL_PRIVACY,
     148                                                        remote_machine,
     149                                                        domain, user,
     150                                                        old_passwd,
     151                                                        &pipe_hnd);
    190152        } else {
    191153                /*
     
    198160                 */
    199161                result = cli_rpc_pipe_open_noauth(
    200                         cli, &ndr_table_samr.syntax_id, &pipe_hnd);
     162                        cli, &ndr_table_samr, &pipe_hnd);
    201163        }
    202164
     
    205167                        /* Use the old RAP method. */
    206168                        if (!cli_oem_change_password(cli, user_name, new_passwd, old_passwd)) {
     169                                result = cli_nt_error(cli);
    207170                                if (asprintf(err_str, "machine %s rejected the "
    208171                                         "password change: Error was : %s.\n",
    209                                          remote_machine, cli_errstr(cli)) == -1) {
     172                                         remote_machine, nt_errstr(result)) == -1) {
    210173                                        *err_str = NULL;
    211174                                }
    212                                 result = cli_nt_error(cli);
    213175                                cli_shutdown(cli);
    214176                                return result;
     
    221183                                *err_str = NULL;
    222184                        }
    223                         result = cli_nt_error(cli);
    224185                        cli_shutdown(cli);
    225186                        return result;
     
    251212
    252213        /* Try anonymous NTLMSSP... */
    253         result = cli_init_creds(cli, "", "", NULL);
    254         if (!NT_STATUS_IS_OK(result)) {
    255                 cli_shutdown(cli);
    256                 return result;
    257         }
    258 
    259214        result = NT_STATUS_UNSUCCESSFUL;
    260215
    261216        /* OK, this is ugly, but... try an anonymous pipe. */
    262         result = cli_rpc_pipe_open_noauth(cli, &ndr_table_samr.syntax_id,
     217        result = cli_rpc_pipe_open_noauth(cli, &ndr_table_samr,
    263218                                          &pipe_hnd);
    264219
     
    296251                                return NT_STATUS_OK;
    297252                        }
     253
     254                        result = cli_nt_error(cli);
    298255                        if (asprintf(err_str, "machine %s rejected the password "
    299256                                 "change: Error was : %s.\n",
    300                                  remote_machine, cli_errstr(cli)) == -1) {
    301                                 *err_str = NULL;
    302                         }
    303                         result = cli_nt_error(cli);
     257                                 remote_machine, nt_errstr(result)) == -1) {
     258                                *err_str = NULL;
     259                        }
    304260                        cli_shutdown(cli);
    305261                        return result;
     
    308264                                 "failed. Error was %s, but LANMAN password "
    309265                                 "changes are disabled\n",
    310                                 nt_errstr(result), remote_machine) == -1) {
     266                                remote_machine, nt_errstr(result)) == -1) {
    311267                                *err_str = NULL;
    312268                        }
Note: See TracChangeset for help on using the changeset viewer.