| OLD | NEW |
| 1 #!/bin/sh -x | 1 #!/bin/sh -x |
| 2 | 2 |
| 3 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. | 3 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. |
| 4 # Use of this source code is governed by a BSD-style license that can be | 4 # Use of this source code is governed by a BSD-style license that can be |
| 5 # found in the LICENSE file. | 5 # found in the LICENSE file. |
| 6 # | 6 # |
| 7 # /init script for use in factory install shim. Requires busybox in | 7 # /init script for use in factory install shim. Requires busybox in |
| 8 # /bin/busybox, and a symlink from /bin/sh -> busybox. | 8 # /bin/busybox, and a symlink from /bin/sh -> busybox. |
| 9 | 9 |
| 10 # USB card partition and mount point. | 10 # USB card partition and mount point. |
| (...skipping 638 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 649 log "About to switch root" | 649 log "About to switch root" |
| 650 stop_log_file | 650 stop_log_file |
| 651 exec switch_root -c /dev/console "$NEWROOT_MNT" /sbin/init | 651 exec switch_root -c /dev/console "$NEWROOT_MNT" /sbin/init |
| 652 | 652 |
| 653 # This should not really happen. | 653 # This should not really happen. |
| 654 log "Failed to switch root." | 654 log "Failed to switch root." |
| 655 save_log_file | 655 save_log_file |
| 656 return 1 | 656 return 1 |
| 657 } | 657 } |
| 658 | 658 |
| 659 is_nonchrome() { |
| 660 crossystem mainfw_type?nonchrome |
| 661 } |
| 662 |
| 659 is_developer_mode() { | 663 is_developer_mode() { |
| 660 # See Firmware High-Level Spec for details on CHSW values | 664 # Legacy/unsupported systems are mapped to developer mode. |
| 661 CHSW=$(cat /sys/devices/platform/chromeos_acpi/CHSW) | 665 is_nonchrome && return 0 |
| 662 # If the switch is unsupported, treat as developer mode. | 666 # Otherwise the exit status will be accurate. |
| 663 [ -z "$CHSW" ] && return 0 | 667 crossystem devsw_boot?1 |
| 664 if [ $CHSW -gt 0 -a $((CHSW & 32)) -eq 32 ]; then | |
| 665 return 0 | |
| 666 fi | |
| 667 return 1 | |
| 668 } | 668 } |
| 669 | 669 |
| 670 lock_tpm() { | 670 lock_tpm() { |
| 671 if [ -z "$TPM_B_LOCKED" ]; then | 671 if [ -z "$TPM_B_LOCKED" ]; then |
| 672 # Depending on the system, the tpm may need to be started. | 672 # Depending on the system, the tpm may need to be started. |
| 673 # Don't fail if it doesn't work though. | 673 # Don't fail if it doesn't work though. |
| 674 tpmc startup | 674 tpmc startup |
| 675 tpmc ctest | 675 tpmc ctest |
| 676 if ! tpmc block; then | 676 if ! tpmc block; then |
| 677 log "An unrecoverable error occurred with your security device" | 677 if is_nonchrome; then |
| 678 log "Please power down and try again." | 678 log "No security chip appears to exist in this non-Chrome device." |
| 679 dlog "Failed to lock bGlobalLock." | 679 log "The security of your experience will suffer." |
| 680 on_error | 680 # Forge onward. |
| 681 return 1 # Never reached. | 681 else |
| 682 log "An unrecoverable error occurred with your security device" |
| 683 log "Please power down and try again." |
| 684 dlog "Failed to lock bGlobalLock." |
| 685 on_error |
| 686 return 1 # Never reached. |
| 687 fi |
| 682 fi | 688 fi |
| 683 TPM_B_LOCKED=y | 689 TPM_B_LOCKED=y |
| 684 fi | 690 fi |
| 685 if [ -z "$TPM_PP_LOCKED" ]; then | 691 if [ -z "$TPM_PP_LOCKED" ]; then |
| 686 # TODO: tpmc pplock if appropriate | 692 # TODO: tpmc pplock if appropriate |
| 687 TPM_PP_LOCKED=y | 693 TPM_PP_LOCKED=y |
| 688 fi | 694 fi |
| 689 return 0 | 695 return 0 |
| 690 } | 696 } |
| 691 | 697 |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 767 # USB device is unmounted, we can remove it now. | 773 # USB device is unmounted, we can remove it now. |
| 768 unmount_usb || on_error | 774 unmount_usb || on_error |
| 769 # Switch to the new root | 775 # Switch to the new root |
| 770 use_new_root || on_error | 776 use_new_root || on_error |
| 771 on_error # !! Never reached. !! | 777 on_error # !! Never reached. !! |
| 772 fi | 778 fi |
| 773 | 779 |
| 774 # If not, we must be a recovery kernel. | 780 # If not, we must be a recovery kernel. |
| 775 NEWROOT_MNT="$USB_MNT" | 781 NEWROOT_MNT="$USB_MNT" |
| 776 | 782 |
| 783 if is_nonchrome; then |
| 784 log " " |
| 785 log "Your computer does not appear to a Chrome computer!" |
| 786 log " " |
| 787 log "Your experience with Chromium OS will be suboptimal." |
| 788 log " " |
| 789 fi |
| 790 |
| 777 # Always lock the TPM. If a NVRAM reset is ever needed, we can change it. | 791 # Always lock the TPM. If a NVRAM reset is ever needed, we can change it. |
| 778 lock_tpm || on_error | 792 lock_tpm || on_error |
| 779 | 793 |
| 780 # Perform a full device mapper root validation to avoid any unexpected | 794 # Perform a full device mapper root validation to avoid any unexpected |
| 781 # failures during postinst. It also allows us to detect if the root is | 795 # failures during postinst. It also allows us to detect if the root is |
| 782 # intentionally mismatched - such as during Chromium OS recovery with a | 796 # intentionally mismatched - such as during Chromium OS recovery with a |
| 783 # Chrome OS recovery kernel. | 797 # Chrome OS recovery kernel. |
| 784 if ! validate_recovery_root; then | 798 if ! validate_recovery_root; then |
| 785 is_developer_mode || on_error | 799 is_developer_mode || on_error |
| 786 find_developer_root || find_shim_root || on_error | 800 find_developer_root || find_shim_root || on_error |
| (...skipping 26 matching lines...) Expand all Loading... |
| 813 exit 0 | 827 exit 0 |
| 814 } | 828 } |
| 815 | 829 |
| 816 # Make this source-able for testing. | 830 # Make this source-able for testing. |
| 817 if [ "$0" = "/init" ]; then | 831 if [ "$0" = "/init" ]; then |
| 818 main "$@" | 832 main "$@" |
| 819 # Should never reach here. | 833 # Should never reach here. |
| 820 exit 1 | 834 exit 1 |
| 821 fi | 835 fi |
| 822 | 836 |
| OLD | NEW |