3557 * often shell based logins, and many shells mask SIGTERM (but are
3558 * responsive to SIGHUP) we first HUP and then shortly thereafter
3559 * kill -9.
3560 */
3561 (void) fork_with_timeout("/usr/sbin/killall HUP", 1, 5);
3562 (void) fork_with_timeout("/usr/sbin/killall KILL", 1, 5);
3563
3564 /*
3565 * Note the selection of user id's 0, 1 and 15, subsequently
3566 * inverted by -v. 15 is reserved for dladmd. Yes, this is a
3567 * kludge-- a better policy is needed.
3568 *
3569 * Note that fork_with_timeout will only wait out the 1 second
3570 * "grace time" if pkill actually returns 0. So if there are
3571 * no matches, this will run to completion much more quickly.
3572 */
3573 (void) fork_with_timeout("/usr/bin/pkill -TERM -v -u 0,1,15", 1, 5);
3574 (void) fork_with_timeout("/usr/bin/pkill -KILL -v -u 0,1,15", 1, 5);
3575 }
3576
3577 static void
3578 do_uadmin(void)
3579 {
3580 const char * const resetting = "/etc/svc/volatile/resetting";
3581 int fd;
3582 struct statvfs vfs;
3583 time_t now;
3584 struct tm nowtm;
3585 char down_buf[256], time_buf[256];
3586 uintptr_t mdep;
3587 #if defined(__i386)
3588 grub_boot_args_t fbarg;
3589 #endif /* __i386 */
3590
3591 mdep = NULL;
3592 fd = creat(resetting, 0777);
3593 if (fd >= 0)
3594 startd_close(fd);
3595 else
3596 uu_warn("Could not create \"%s\"", resetting);
3623 fork_with_timeout("/usr/lib/acct/closewtmp", 0, 5);
3624
3625 /*
3626 * For patches which may be installed as the system is shutting
3627 * down, we need to ensure, one more time, that the boot archive
3628 * really is up to date.
3629 */
3630 if (getzoneid() == 0 && access("/usr/sbin/bootadm", X_OK) == 0)
3631 fork_with_timeout("/usr/sbin/bootadm -ea update_all", 0, 3600);
3632
3633 /*
3634 * Right now, fast reboot is supported only on i386.
3635 * scf_is_fastboot_default() should take care of it.
3636 * If somehow we got there on unsupported platform -
3637 * print warning and fall back to regular reboot.
3638 */
3639 if (halting == AD_FASTREBOOT) {
3640 #if defined(__i386)
3641 int rc;
3642
3643 if ((rc = grub_get_boot_args(&fbarg, NULL,
3644 GRUB_ENTRY_DEFAULT)) == 0) {
3645 mdep = (uintptr_t)&fbarg.gba_bootargs;
3646 } else {
3647 /*
3648 * Failed to read GRUB menu, fall back to normal reboot
3649 */
3650 halting = AD_BOOT;
3651 uu_warn("Failed to process GRUB menu entry "
3652 "for fast reboot.\n\t%s\n"
3653 "Falling back to regular reboot.\n",
3654 grub_strerror(rc));
3655 }
3656 #else /* __i386 */
3657 halting = AD_BOOT;
3658 uu_warn("Fast reboot configured, but not supported by "
3659 "this ISA\n");
3660 #endif /* __i386 */
3661 }
3662
3663 fork_with_timeout("/sbin/umountall -l", 0, 5);
3664 fork_with_timeout("/sbin/umount /tmp /var/adm /var/run /var "
|
3557 * often shell based logins, and many shells mask SIGTERM (but are
3558 * responsive to SIGHUP) we first HUP and then shortly thereafter
3559 * kill -9.
3560 */
3561 (void) fork_with_timeout("/usr/sbin/killall HUP", 1, 5);
3562 (void) fork_with_timeout("/usr/sbin/killall KILL", 1, 5);
3563
3564 /*
3565 * Note the selection of user id's 0, 1 and 15, subsequently
3566 * inverted by -v. 15 is reserved for dladmd. Yes, this is a
3567 * kludge-- a better policy is needed.
3568 *
3569 * Note that fork_with_timeout will only wait out the 1 second
3570 * "grace time" if pkill actually returns 0. So if there are
3571 * no matches, this will run to completion much more quickly.
3572 */
3573 (void) fork_with_timeout("/usr/bin/pkill -TERM -v -u 0,1,15", 1, 5);
3574 (void) fork_with_timeout("/usr/bin/pkill -KILL -v -u 0,1,15", 1, 5);
3575 }
3576
3577 static int
3578 exec_cmd(char * invoke, char * output)
3579 {
3580 FILE * cmd = popen(invoke, "r");
3581 if (! cmd)
3582 return 0;
3583 fgets(output, 512, cmd);
3584 if (! *output) {
3585 pclose(cmd);
3586 return 0;
3587 }
3588 output[strlen(output) - 2] = '\0';
3589 pclose(cmd);
3590 return 1;
3591 }
3592
3593 static void
3594 do_uadmin(void)
3595 {
3596 const char * const resetting = "/etc/svc/volatile/resetting";
3597 int fd;
3598 struct statvfs vfs;
3599 time_t now;
3600 struct tm nowtm;
3601 char down_buf[256], time_buf[256];
3602 uintptr_t mdep;
3603 #if defined(__i386)
3604 grub_boot_args_t fbarg;
3605 #endif /* __i386 */
3606
3607 mdep = NULL;
3608 fd = creat(resetting, 0777);
3609 if (fd >= 0)
3610 startd_close(fd);
3611 else
3612 uu_warn("Could not create \"%s\"", resetting);
3639 fork_with_timeout("/usr/lib/acct/closewtmp", 0, 5);
3640
3641 /*
3642 * For patches which may be installed as the system is shutting
3643 * down, we need to ensure, one more time, that the boot archive
3644 * really is up to date.
3645 */
3646 if (getzoneid() == 0 && access("/usr/sbin/bootadm", X_OK) == 0)
3647 fork_with_timeout("/usr/sbin/bootadm -ea update_all", 0, 3600);
3648
3649 /*
3650 * Right now, fast reboot is supported only on i386.
3651 * scf_is_fastboot_default() should take care of it.
3652 * If somehow we got there on unsupported platform -
3653 * print warning and fall back to regular reboot.
3654 */
3655 if (halting == AD_FASTREBOOT) {
3656 #if defined(__i386)
3657 int rc;
3658
3659 if ((rc = exec_cmd("/sbin/grubadm --number -1 --get-opts",
3660 fbarg.gba_bootargs)) == 0) {
3661 mdep = (uintptr_t)&fbarg.gba_bootargs;
3662 } else {
3663 /*
3664 * Failed to read GRUB menu, fall back to normal reboot
3665 */
3666 halting = AD_BOOT;
3667 uu_warn("Failed to process GRUB menu entry "
3668 "for fast reboot.\n\t%s\n"
3669 "Falling back to regular reboot.\n",
3670 grub_strerror(rc));
3671 }
3672 #else /* __i386 */
3673 halting = AD_BOOT;
3674 uu_warn("Fast reboot configured, but not supported by "
3675 "this ISA\n");
3676 #endif /* __i386 */
3677 }
3678
3679 fork_with_timeout("/sbin/umountall -l", 0, 5);
3680 fork_with_timeout("/sbin/umount /tmp /var/adm /var/run /var "
|