Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(36)

Side by Side Diff: init

Issue 6724018: use crossystem for developer mode and nonchrome detection (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/initramfs.git@master
Patch Set: Created 9 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 554 matching lines...) Expand 10 before | Expand all | Expand 10 after
565 log "About to switch root" 565 log "About to switch root"
566 stop_log_file 566 stop_log_file
567 exec switch_root -c /dev/console "$NEWROOT_MNT" /sbin/init 567 exec switch_root -c /dev/console "$NEWROOT_MNT" /sbin/init
568 568
569 # This should not really happen. 569 # This should not really happen.
570 log "Failed to switch root." 570 log "Failed to switch root."
571 save_log_file 571 save_log_file
572 return 1 572 return 1
573 } 573 }
574 574
575 is_nonchrome() {
576 crossystem mainfw_type?nonchrome
gauravsh 2011/03/23 02:25:18 it wasn't clear to me what exactly this does. Does
Randall Spangler 2011/03/23 15:54:17 Yes. (New feature of crossystem)
577 }
578
575 is_developer_mode() { 579 is_developer_mode() {
576 # See Firmware High-Level Spec for details on CHSW values 580 # Legacy/unsupported systems are mapped to developer mode.
577 CHSW=$(cat /sys/devices/platform/chromeos_acpi/CHSW) 581 is_nonchrome && return 0
578 # If the switch is unsupported, treat as developer mode. 582 # Otherwise the exit status will be accurate.
579 [ -z "$CHSW" ] && return 0 583 crossystem devsw_boot?1
580 if [ $CHSW -gt 0 -a $((CHSW & 32)) -eq 32 ]; then
581 return 0
582 fi
583 return 1
584 } 584 }
585 585
586 lock_tpm() { 586 lock_tpm() {
587 if [ -z "$TPM_B_LOCKED" ]; then 587 if [ -z "$TPM_B_LOCKED" ]; then
588 # Depending on the system, the tpm may need to be started. 588 # Depending on the system, the tpm may need to be started.
589 # Don't fail if it doesn't work though. 589 # Don't fail if it doesn't work though.
590 tpmc startup 590 tpmc startup
591 tpmc ctest 591 tpmc ctest
592 if ! tpmc block; then 592 if ! tpmc block; then
593 log "An unrecoverable error occurred with your security device" 593 if is_nonchrome; then
594 log "Please power down and try again." 594 log "No security chip appears to exist in this non-Chrome device."
595 dlog "Failed to lock bGlobalLock." 595 log "The security of your experience will suffer."
596 on_error 596 # Forge onward.
597 return 1 # Never reached. 597 else
598 log "An unrecoverable error occurred with your security device"
599 log "Please power down and try again."
600 dlog "Failed to lock bGlobalLock."
601 on_error
602 return 1 # Never reached.
603 fi
598 fi 604 fi
599 TPM_B_LOCKED=y 605 TPM_B_LOCKED=y
600 fi 606 fi
601 if [ -z "$TPM_PP_LOCKED" ]; then 607 if [ -z "$TPM_PP_LOCKED" ]; then
602 # TODO: tpmc pplock if appropriate 608 # TODO: tpmc pplock if appropriate
603 TPM_PP_LOCKED=y 609 TPM_PP_LOCKED=y
604 fi 610 fi
605 return 0 611 return 0
606 } 612 }
607 613
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
683 # USB device is unmounted, we can remove it now. 689 # USB device is unmounted, we can remove it now.
684 unmount_usb || on_error 690 unmount_usb || on_error
685 # Switch to the new root 691 # Switch to the new root
686 use_new_root || on_error 692 use_new_root || on_error
687 on_error # !! Never reached. !! 693 on_error # !! Never reached. !!
688 fi 694 fi
689 695
690 # If not, we must be a recovery kernel. 696 # If not, we must be a recovery kernel.
691 NEWROOT_MNT="$USB_MNT" 697 NEWROOT_MNT="$USB_MNT"
692 698
699 if is_nonchrome; then
700 log "Your computer does not appear to a Chrome computer!"
701 log " "
702 log "Your experience with Chromium OS will be suboptimal."
703 log " "
704 fi
705
693 # Always lock the TPM. If a NVRAM reset is ever needed, we can change it. 706 # Always lock the TPM. If a NVRAM reset is ever needed, we can change it.
694 lock_tpm || on_error 707 lock_tpm || on_error
695 708
696 # Perform a full device mapper root validation to avoid any unexpected 709 # Perform a full device mapper root validation to avoid any unexpected
697 # failures during postinst. It also allows us to detect if the root is 710 # failures during postinst. It also allows us to detect if the root is
698 # intentionally mismatched - such as during Chromium OS recovery with a 711 # intentionally mismatched - such as during Chromium OS recovery with a
699 # Chrome OS recovery kernel. 712 # Chrome OS recovery kernel.
700 if ! validate_recovery_root; then 713 if ! validate_recovery_root; then
701 is_developer_mode || on_error 714 is_developer_mode || on_error
702 find_developer_root || on_error 715 find_developer_root || on_error
(...skipping 26 matching lines...) Expand all
729 exit 0 742 exit 0
730 } 743 }
731 744
732 # Make this source-able for testing. 745 # Make this source-able for testing.
733 if [ "$0" = "/init" ]; then 746 if [ "$0" = "/init" ]; then
734 main "$@" 747 main "$@"
735 # Should never reach here. 748 # Should never reach here.
736 exit 1 749 exit 1
737 fi 750 fi
738 751
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698