Changeset 988 for vendor/current/source3/libsmb/passchange.c
- Timestamp:
- Nov 24, 2016, 1:14:11 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
vendor/current/source3/libsmb/passchange.c
r740 r988 3 3 SMB client password change routine 4 4 Copyright (C) Andrew Tridgell 1994-1998 5 5 6 6 This program is free software; you can redistribute it and/or modify 7 7 it under the terms of the GNU General Public License as published by 8 8 the Free Software Foundation; either version 3 of the License, or 9 9 (at your option) any later version. 10 10 11 11 This program is distributed in the hope that it will be useful, 12 12 but WITHOUT ANY WARRANTY; without even the implied warranty of 13 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 14 GNU General Public License for more details. 15 15 16 16 You should have received a copy of the GNU General Public License 17 17 along with this program. If not, see <http://www.gnu.org/licenses/>. … … 25 25 #include "libsmb/clirap.h" 26 26 #include "libsmb/nmblib.h" 27 #include "../libcli/smb/smbXcli_base.h" 27 28 28 29 /************************************************************* … … 34 35 char **err_str) 35 36 { 36 struct nmb_name calling, called;37 37 struct cli_state *cli = NULL; 38 38 struct rpc_pipe_client *pipe_hnd = NULL; 39 struct sockaddr_storage ss;40 39 char *user, *domain, *p; 41 40 … … 58 57 *err_str = NULL; 59 58 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); 74 61 if (!NT_STATUS_IS_OK(result)) { 75 62 if (asprintf(err_str, "Unable to connect to SMB server on " … … 78 65 *err_str = NULL; 79 66 } 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()); 101 73 102 74 if (!NT_STATUS_IS_OK(result)) { … … 106 78 *err_str = NULL; 107 79 } 108 result = cli_nt_error(cli);109 80 cli_shutdown(cli); 110 81 return result; … … 127 98 !NT_STATUS_EQUAL(result, NT_STATUS_PASSWORD_EXPIRED)) { 128 99 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) { 130 101 *err_str = NULL; 131 102 } … … 147 118 if (asprintf(err_str, "machine %s rejected the session " 148 119 "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); 170 129 if (!NT_STATUS_IS_OK(result)) { 171 130 if (asprintf(err_str, "machine %s rejected the tconX on the " … … 181 140 182 141 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); 190 152 } else { 191 153 /* … … 198 160 */ 199 161 result = cli_rpc_pipe_open_noauth( 200 cli, &ndr_table_samr .syntax_id, &pipe_hnd);162 cli, &ndr_table_samr, &pipe_hnd); 201 163 } 202 164 … … 205 167 /* Use the old RAP method. */ 206 168 if (!cli_oem_change_password(cli, user_name, new_passwd, old_passwd)) { 169 result = cli_nt_error(cli); 207 170 if (asprintf(err_str, "machine %s rejected the " 208 171 "password change: Error was : %s.\n", 209 remote_machine, cli_errstr(cli)) == -1) {172 remote_machine, nt_errstr(result)) == -1) { 210 173 *err_str = NULL; 211 174 } 212 result = cli_nt_error(cli);213 175 cli_shutdown(cli); 214 176 return result; … … 221 183 *err_str = NULL; 222 184 } 223 result = cli_nt_error(cli);224 185 cli_shutdown(cli); 225 186 return result; … … 251 212 252 213 /* 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 259 214 result = NT_STATUS_UNSUCCESSFUL; 260 215 261 216 /* 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, 263 218 &pipe_hnd); 264 219 … … 296 251 return NT_STATUS_OK; 297 252 } 253 254 result = cli_nt_error(cli); 298 255 if (asprintf(err_str, "machine %s rejected the password " 299 256 "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 } 304 260 cli_shutdown(cli); 305 261 return result; … … 308 264 "failed. Error was %s, but LANMAN password " 309 265 "changes are disabled\n", 310 nt_errstr(result), remote_machine) == -1) {266 remote_machine, nt_errstr(result)) == -1) { 311 267 *err_str = NULL; 312 268 }
Note:
See TracChangeset
for help on using the changeset viewer.