Home | History | Annotate | Download | only in image_signing
      1 #!/bin/bash
      2 
      3 # Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
      4 # Use of this source code is governed by a BSD-style license that can be
      5 # found in the LICENSE file.
      6 
      7 # Abort on error.
      8 set -e
      9 
     10 # Load common constants and variables.
     11 . "$(dirname "$0")/common.sh"
     12 
     13 usage() {
     14     echo "Usage $PROG image [config]"
     15 }
     16 
     17 main() {
     18     # We want to catch all the discrepancies, not just the first one.
     19     # So, any time we find one, we set testfail=1 and continue.
     20     # When finished we will use testfail to determine our exit value.
     21     local testfail=0
     22 
     23     if [ $# -ne 1 ] && [ $# -ne 2 ]; then
     24         usage
     25         exit 1
     26     fi
     27 
     28     local image="$1"
     29 
     30     # Default config location: same name/directory as this script,
     31     # with a .config file extension, ie ensure_no_nonrelease_files.config.
     32     local configfile="$(dirname "$0")/${0/%.sh/.config}"
     33     # Or, maybe a config was provided on the command line.
     34     if [ $# -eq 2 ]; then
     35         configfile="$2"
     36     fi
     37     # Either way, load test-expectations data from config.
     38     . "$configfile" || return 1
     39 
     40     local rootfs=$(make_temp_dir)
     41     mount_image_partition_ro "$image" 3 "$rootfs"
     42 
     43     for file in ${RELEASE_FILE_BLACKLIST[@]}; do
     44         if [ -e "$rootfs/$file" ]; then
     45             echo "FAIL: $file exists in this image!"
     46             ls -al "$rootfs/$file"
     47             testfail=1
     48         fi
     49     done
     50 
     51     # Verify that session_manager isn't configured to pass additional
     52     # environment variables or command-line arguments to Chrome.
     53     local config_path="$rootfs/etc/chrome_dev.conf"
     54     local matches=$(grep -s "^[^#]" "${config_path}")
     55     if [ -n "$matches" ]; then
     56         echo "FAIL: Found commands in $config_path:"
     57         echo "$matches"
     58         testfail=1
     59     fi
     60 
     61     exit $testfail
     62 }
     63 main "$@"
     64