Update protobuf to 2.27.1

Test: cd external/rust/crates && atest --host -c
Change-Id: Iaae5fc30f1bd87b2d4a92ee1ae07bc18e1bc50d4
diff --git a/regenerate.sh b/regenerate.sh
index 672106e..0173496 100755
--- a/regenerate.sh
+++ b/regenerate.sh
@@ -1,6 +1,6 @@
 #!/bin/sh -ex
 
-cd $(dirname $0)
+cd "$(dirname "$0")"
 
 die() {
     echo "$@" >&2
@@ -9,29 +9,35 @@
 
 protoc_ver=$(protoc --version)
 case "$protoc_ver" in
-    "libprotoc 3"*) ;;
-    *)
-        die "you need to use protobuf 3 to regenerate .rs from .proto"
+"libprotoc 3"*) ;;
+*)
+    die "you need to use protobuf 3 to regenerate .rs from .proto"
     ;;
 esac
 
 cargo build --manifest-path=../protobuf-codegen/Cargo.toml
+cargo build --manifest-path=../protoc-bin-vendored/Cargo.toml --bin protoc-bin-which
 
-where_am_i=$(cd ..; pwd)
+PROTOC=$(cargo run --manifest-path=../protoc-bin-vendored/Cargo.toml --bin protoc-bin-which)
+
+where_am_i=$(
+    cd ..
+    pwd
+)
 
 rm -rf tmp-generated
 mkdir tmp-generated
 
-case `uname` in
-    Linux)
-        exe_suffix=""
+case $(uname) in
+Linux)
+    exe_suffix=""
     ;;
-    MSYS_NT*)
-        exe_suffix=".exe"
+MSYS_NT*)
+    exe_suffix=".exe"
     ;;
 esac
 
-protoc \
+"$PROTOC" \
     --plugin=protoc-gen-rust="$where_am_i/target/debug/protoc-gen-rust$exe_suffix" \
     --rust_out tmp-generated \
     --rust_opt 'serde_derive=true inside_protobuf=true' \
@@ -45,13 +51,14 @@
 mv tmp-generated/*.rs src/well_known_types/
 (
     cd src/well_known_types
-    exec > mod.rs
+    exec >mod.rs
     echo "// This file is generated. Do not edit"
     echo '//! Generated code for "well known types"'
     echo "//!"
     echo "//! [This document](https://developers.google.com/protocol-buffers/docs/reference/google.protobuf) describes these types."
 
     mod_list() {
+        # shellcheck disable=SC2010
         ls | grep -v mod.rs | sed -e 's,\.rs$,,'
     }
 
@@ -59,7 +66,7 @@
     mod_list | sed -e 's,^,mod ,; s,$,;,'
 
     echo
-    mod_list | while read mod; do
+    mod_list | while read -r mod; do
         echo "pub use self::$mod::*;"
     done
 )