Changeset 745 for trunk/server/source3/auth/auth_server.c
- Timestamp:
- Nov 27, 2012, 4:43:17 PM (13 years ago)
- Location:
- trunk/server
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/server
- Property svn:mergeinfo changed
/vendor/current merged: 581,587,591,594,597,600,615,618,740
- Property svn:mergeinfo changed
-
trunk/server/source3/auth/auth_server.c
r414 r745 9 9 the Free Software Foundation; either version 3 of the License, or 10 10 (at your option) any later version. 11 11 12 12 This program is distributed in the hope that it will be useful, 13 13 but WITHOUT ANY WARRANTY; without even the implied warranty of 14 14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 15 GNU General Public License for more details. 16 16 17 17 You should have received a copy of the GNU General Public License 18 18 along with this program. If not, see <http://www.gnu.org/licenses/>. … … 20 20 21 21 #include "includes.h" 22 #include "auth.h" 23 #include "system/passwd.h" 24 #include "smbd/smbd.h" 25 #include "libsmb/libsmb.h" 22 26 23 27 #undef DBGC_CLASS … … 136 140 */ 137 141 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)) { 140 144 TALLOC_FREE(mutex); 141 145 DEBUG(0,("%s rejected the initial session setup (%s)\n", 142 desthost, cli_errstr(cli)));146 desthost, nt_errstr(status))); 143 147 cli_shutdown(cli); 144 148 return NULL; … … 207 211 interval.tv_usec = 0; 208 212 209 if (event_add_idle(s mbd_event_context(), result, interval,213 if (event_add_idle(server_event_context(), result, interval, 210 214 "server_security_keepalive", 211 215 send_server_keepalive, … … 229 233 { 230 234 struct cli_state *cli = server_cryptkey(mem_ctx); 231 235 232 236 if (cli) { 233 237 DEBUG(3,("using password server validation\n")); … … 237 241 unless 'encrypt passwords = no' */ 238 242 DEBUG(5,("make_auth_info_server: Server is unencrypted, no challenge available..\n")); 239 243 240 244 /* However, it is still a perfectly fine connection 241 245 to pass that unencrypted password over */ … … 256 260 /* The return must be allocated on the caller's mem_ctx, as our own will be 257 261 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); 259 263 } else { 260 264 return data_blob_null; … … 271 275 void *my_private_data, 272 276 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; 279 282 static bool tested_password_server = False; 280 283 static bool bad_password_server = False; … … 282 285 bool locally_made_cli = False; 283 286 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); 284 297 cli = state->cli; 285 298 286 299 if (cli) { 287 300 } else { … … 294 307 return NT_STATUS_LOGON_FAILURE; 295 308 } 296 309 297 310 if ((cli->sec_mode & NEGOTIATE_SECURITY_CHALLENGE_RESPONSE) == 0) { 298 if (user_info-> encrypted) {311 if (user_info->password_state != AUTH_PASSWORD_PLAIN) { 299 312 DEBUG(1,("password server %s is plaintext, but we are encrypted. This just can't work :-(\n", cli->desthost)); 300 313 return NT_STATUS_LOGON_FAILURE; … … 325 338 memset(badpass, 0x1f, sizeof(badpass)); 326 339 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))) { 329 342 /* 330 343 * Very unlikely, our random bad password is the same as the users … … 347 360 (char *)badpass, 348 361 sizeof(badpass), 349 user_info-> domain))) {362 user_info->mapped.domain_name))) { 350 363 351 364 /* … … 390 403 * not guest enabled, we can try with the real password. 391 404 */ 392 393 if (!user_info->encrypted) {405 switch (user_info->password_state) { 406 case AUTH_PASSWORD_PLAIN: 394 407 /* Plaintext available */ 395 408 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: 402 418 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; 409 429 } 410 430 … … 415 435 416 436 /* if logged in as guest then reject */ 417 if ( (SVAL(cli->inbuf,smb_vwv2) & 1) != 0) {437 if (cli->is_guestlogin) { 418 438 DEBUG(1,("password server %s gave us guest only\n", cli->desthost)); 419 439 nt_status = NT_STATUS_LOGON_FAILURE; … … 423 443 424 444 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 ) 430 450 { 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); 440 452 TALLOC_FREE(pass); 453 TALLOC_FREE(real_username); 441 454 } 442 455 else … … 455 468 static NTSTATUS auth_init_smbserver(struct auth_context *auth_context, const char* param, auth_methods **auth_method) 456 469 { 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) { 458 474 return NT_STATUS_NO_MEMORY; 459 475 } 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; 463 481 return NT_STATUS_OK; 464 482 }
Note:
See TracChangeset
for help on using the changeset viewer.