| OLD | NEW |
| 1 #!/bin/bash | 1 #!/bin/bash |
| 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 # This script is used to maintain the whitelist for package maintainer scripts. | 7 # This script is used to maintain the whitelist for package maintainer scripts. |
| 8 # If a package maintainer script is in the whitelist file then it is ok to skip | 8 # If a package maintainer script is in the whitelist file then it is ok to skip |
| 9 # running that maintainer script when installing the package. Otherwise there | 9 # running that maintainer script when installing the package. Otherwise there |
| 10 # should be an equivalent script that can perform those operation on a target | 10 # should be an equivalent script that can perform those operation on a target |
| (...skipping 29 matching lines...) Expand all Loading... |
| 40 given rootfs. This will show you the files in turn and give you | 40 given rootfs. This will show you the files in turn and give you |
| 41 the option to Skip/View/Whitelist/Create template for the script. | 41 the option to Skip/View/Whitelist/Create template for the script. |
| 42 If --file is given it will do the same for that one file. | 42 If --file is given it will do the same for that one file. |
| 43 check: Checks if the --file= is in the whitelist. | 43 check: Checks if the --file= is in the whitelist. |
| 44 " | 44 " |
| 45 | 45 |
| 46 # Parse command line | 46 # Parse command line |
| 47 FLAGS "$@" || exit 1 | 47 FLAGS "$@" || exit 1 |
| 48 eval set -- "${FLAGS_ARGV}" | 48 eval set -- "${FLAGS_ARGV}" |
| 49 | 49 |
| 50 # Returns true if the input file is whitelisted. | |
| 51 # | |
| 52 # $1 - The file to check | |
| 53 is_whitelisted() { | |
| 54 local file=$1 | |
| 55 local whitelist="$FLAGS_whitelist" | |
| 56 test -f "$whitelist" || return | |
| 57 | |
| 58 local checksum=$(md5sum "$file" | awk '{ print $1 }') | |
| 59 local count=$(grep -c "$checksum" "${whitelist}" || /bin/true) | |
| 60 test $count -ne 0 | |
| 61 } | |
| 62 | |
| 63 # Adds a the file at the given path to the whitelist. | 50 # Adds a the file at the given path to the whitelist. |
| 64 # | 51 # |
| 65 # $1 - Path to file to add to whitelist. | 52 # $1 - Path to file to add to whitelist. |
| 66 add_to_whitelist() { | 53 add_to_whitelist() { |
| 67 local path=$1 | 54 local path=$1 |
| 68 local whitelist="$FLAGS_whitelist" | 55 local whitelist="$FLAGS_whitelist" |
| 69 local file=$(basename "$path") | 56 local file=$(basename "$path") |
| 70 | 57 |
| 71 local checksum=$(md5sum "$path" | awk '{ print $1 }') | 58 local checksum=$(md5sum "$path" | awk '{ print $1 }') |
| 72 if [ ! -f "$whitelist" ]; then | 59 if [ ! -f "$whitelist" ]; then |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 214 if is_whitelisted "$FLAGS_file"; then | 201 if is_whitelisted "$FLAGS_file"; then |
| 215 echo "Whitelisted" | 202 echo "Whitelisted" |
| 216 else | 203 else |
| 217 echo "Not whitelisted" | 204 echo "Not whitelisted" |
| 218 fi | 205 fi |
| 219 ;; | 206 ;; |
| 220 *) | 207 *) |
| 221 echo "Unknown command." | 208 echo "Unknown command." |
| 222 ;; | 209 ;; |
| 223 esac | 210 esac |
| OLD | NEW |