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

Unified Diff: src/scripts/common.sh

Issue 542097: Move is_whitelisted to the common script so that all users get the previous fix (Closed)
Patch Set: Fix silent failure case Created 10 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | src/scripts/dpkg_no_scripts.sh » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/scripts/common.sh
diff --git a/src/scripts/common.sh b/src/scripts/common.sh
index bad8dd42aa33b465319c2a7fdd84b050c21eee79..2a3c5d25a5cc66e7e24601746efc6e6cc2169dae 100644
--- a/src/scripts/common.sh
+++ b/src/scripts/common.sh
@@ -190,3 +190,17 @@ function install_if_missing {
sudo apt-get --yes --force-yes install $PKG_NAME
fi
}
+
+# Returns true if the input file is whitelisted.
+#
+# $1 - The file to check
+is_whitelisted() {
+ local file=$1
+ local whitelist="$FLAGS_whitelist"
+ test -f "$whitelist" || (echo "Whitelist file missing ($whitelist)" && exit 1)
+
+ local checksum=$(md5sum "$file" | awk '{ print $1 }')
+ local count=$(sed -e "s/#.*$//" "${whitelist}" | grep -c "$checksum" \
+ || /bin/true)
+ test $count -ne 0
+}
« no previous file with comments | « no previous file | src/scripts/dpkg_no_scripts.sh » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698