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

Unified Diff: bin/entdwife.sh

Issue 6874035: entd: require a per-entd-invocation session id in every request (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/entd.git@master
Patch Set: Allow a developer switch to disable session id' Created 9 years, 8 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 | callback_server.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: bin/entdwife.sh
diff --git a/bin/entdwife.sh b/bin/entdwife.sh
index 8fd3aa9baede9196ffc9aacde4e72b51382bba06..b602e5ab7fa3881faf3ea6f029604f6265c83347 100755
--- a/bin/entdwife.sh
+++ b/bin/entdwife.sh
@@ -258,10 +258,33 @@ cmd_start() {
return 1
fi
+ local session_path="$extension/session-id.json"
+ # Remove session-id file as it should be ignored when verifying
+ # the signature.
+ log "removing $session_path"
+ rm -f "$session_path"
+
if ! cmd_verify "$extension"; then
return 1
fi
+ # Remove session-id.json at exit to enable the extension to remain
+ # backward compatible with earlier versions of entd/entwife.
+ trap "rm -f $session_path" EXIT TERM
+
+ # Provide a way for a developer to disable session id to simplify
+ # iterating new extensions.
+ local local_session_id=""
+ if [ ! -r "/root/.disable-entd-session-id" ]; then
+ session_id=$(head -c 8 /dev/urandom | openssl md5)
+ fi
+
+ cat > "$session_path" <<EOF
+{
+ "session_id": "$session_id"
+}
+EOF
+
local root_ca_option=""
if [ -f "$extension/$ROOT_CA_FILE" ]; then
root_ca_option="--root-ca-file=$extension/$ROOT_CA_FILE"
@@ -269,9 +292,14 @@ cmd_start() {
local extid="$(basename $(dirname "$extension"))"
- exec "$FLAGS_entd" --utility="$FLAGS_utility" "$root_ca_option" \
+ # Run entd in the background and wait on it - this allows the
+ # shell interpreter to catch TERM signal and clean up session_path.
+ "$FLAGS_entd" --utility="$FLAGS_utility" "$root_ca_option" \
--policy="$extension/policy.js" --manifest="$extension/manifest.json" \
- --username="$FLAGS_username" --callback-origin=chrome-extension://"$extid"
+ --username="$FLAGS_username" --callback-origin=chrome-extension://"$extid" \
+ --session-id="$session_id" &
+ local pid=$!
+ wait $pid
}
cmd_disapprove() {
« no previous file with comments | « no previous file | callback_server.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698