1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114
| 385 static void 386 common_do_login(struct vsf_session* p_sess, const struct mystr* p_user_str, 387 int do_chroot, int anon) 388 { 389 int was_anon = anon; 390 const struct mystr* p_orig_user_str = p_user_str; 391 int newpid; 392 vsf_sysutil_install_null_sighandler(kVSFSysUtilSigCHLD); 393 394 priv_sock_send_result(p_sess->parent_fd, PRIV_SOCK_RESULT_OK); 395 if (!p_sess->control_use_ssl) 396 { 397 (void) vsf_sysutil_wait(); 398 } 399 else 400 { 401 p_sess->ssl_slave_active = 1; 402 } 403 404 handle_per_user_config(p_user_str); 405 406 p_sess->is_anonymous = anon; 407 priv_sock_close(p_sess); 408 priv_sock_init(p_sess); 409 vsf_sysutil_install_sighandler(kVSFSysUtilSigCHLD, handle_sigchld, 0, 1); 410 if (tunable_isolate_network && !tunable_port_promiscuous) 411 { 412 newpid = vsf_sysutil_fork_newnet(); 413 } 414 else 415 { 416 newpid = vsf_sysutil_fork(); 417 } 418 if (newpid == 0) 419 { 420 struct mystr guest_user_str = INIT_MYSTR; 421 struct mystr chroot_str = INIT_MYSTR; 422 struct mystr chdir_str = INIT_MYSTR; 423 struct mystr userdir_str = INIT_MYSTR; 424 unsigned int secutil_option = VSF_SECUTIL_OPTION_USE_GROUPS | 425 VSF_SECUTIL_OPTION_NO_PROCS; 426 427
431 vsf_set_die_if_parent_dies(); 432 priv_sock_set_child_context(p_sess); 433 if (tunable_guest_enable && !anon) 434 { 435 p_sess->is_guest = 1; 436 437 if (tunable_guest_username) 438 { 439 str_alloc_text(&guest_user_str, tunable_guest_username); 440 } 441 p_user_str = &guest_user_str; 442 if (!tunable_virtual_use_local_privs) 443 { 444 anon = 1; 445 do_chroot = 1; 446 } 447 } 448 if (do_chroot) 449 { 450 secutil_option |= VSF_SECUTIL_OPTION_CHROOT; 451 } 452 if (!anon) 453 { 454 secutil_option |= VSF_SECUTIL_OPTION_CHANGE_EUID; 455 } 456 if (!was_anon && tunable_allow_writeable_chroot) 457 { 458 secutil_option |= VSF_SECUTIL_OPTION_ALLOW_WRITEABLE_ROOT; 459 } 460 calculate_chdir_dir(was_anon, &userdir_str, &chroot_str, &chdir_str, 461 p_user_str, p_orig_user_str); 462 463 464 str_mkdir(&chroot_str, 0777); 465 466 chown(str_getbuf(&chroot_str),p_sess->guest_user_uid,p_sess->guest_user_uid); 467 468 469 vsf_secutil_change_credentials(p_user_str, &userdir_str, &chroot_str, 470 0, secutil_option); 471 if (!str_isempty(&chdir_str)) 472 { 473 (void) str_chdir(&chdir_str); 474 } 475 str_free(&guest_user_str); 476 str_free(&chroot_str); 477 str_free(&chdir_str); 478 str_free(&userdir_str); 479 p_sess->is_anonymous = anon; 480 seccomp_sandbox_init(); 481 seccomp_sandbox_setup_postlogin(p_sess); 482 seccomp_sandbox_lockdown(); 483 484 process_post_login(p_sess); 485 bug("should not get here: common_do_login"); 486 } 487 488 priv_sock_set_parent_context(p_sess); 489 if (tunable_ssl_enable) 490 { 491 ssl_comm_channel_set_producer_context(p_sess); 492 } 493 494 vsf_priv_parent_postlogin(p_sess); 495 bug("should not get here in common_do_login"); 496 }
|