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

Side by Side Diff: chrome/installer/mac/keystone_install.sh

Issue 10377173: Do Keychain reauthorization at update time (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 7 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 #!/bin/bash -p 1 #!/bin/bash -p
2 2
3 # Copyright (c) 2011 The Chromium Authors. All rights reserved. 3 # Copyright (c) 2012 The Chromium 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 # usage: keystone_install.sh update_dmg_mount_point 7 # usage: keystone_install.sh update_dmg_mount_point
8 # 8 #
9 # Called by the Keystone system to update the installed application with a new 9 # Called by the Keystone system to update the installed application with a new
10 # version from a disk image. 10 # version from a disk image.
11 # 11 #
12 # Environment variables: 12 # Environment variables:
13 # GOOGLE_CHROME_UPDATER_DEBUG 13 # GOOGLE_CHROME_UPDATER_DEBUG
(...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after
406 readonly FRAMEWORK_NAME="${PRODUCT_NAME} Framework" 406 readonly FRAMEWORK_NAME="${PRODUCT_NAME} Framework"
407 readonly FRAMEWORK_DIR="${FRAMEWORK_NAME}.framework" 407 readonly FRAMEWORK_DIR="${FRAMEWORK_NAME}.framework"
408 readonly PATCH_DIR=".patch" 408 readonly PATCH_DIR=".patch"
409 readonly CONTENTS_DIR="Contents" 409 readonly CONTENTS_DIR="Contents"
410 readonly APP_PLIST="${CONTENTS_DIR}/Info" 410 readonly APP_PLIST="${CONTENTS_DIR}/Info"
411 readonly VERSIONS_DIR="${CONTENTS_DIR}/Versions" 411 readonly VERSIONS_DIR="${CONTENTS_DIR}/Versions"
412 readonly UNROOTED_BRAND_PLIST="Library/Google/Google Chrome Brand" 412 readonly UNROOTED_BRAND_PLIST="Library/Google/Google Chrome Brand"
413 readonly UNROOTED_DEBUG_FILE="Library/Google/Google Chrome Updater Debug" 413 readonly UNROOTED_DEBUG_FILE="Library/Google/Google Chrome Updater Debug"
414 414
415 readonly APP_VERSION_KEY="CFBundleShortVersionString" 415 readonly APP_VERSION_KEY="CFBundleShortVersionString"
416 readonly APP_BUNDLEID_KEY="CFBundleIdentifier"
416 readonly KS_VERSION_KEY="KSVersion" 417 readonly KS_VERSION_KEY="KSVersion"
417 readonly KS_PRODUCT_KEY="KSProductID" 418 readonly KS_PRODUCT_KEY="KSProductID"
418 readonly KS_URL_KEY="KSUpdateURL" 419 readonly KS_URL_KEY="KSUpdateURL"
419 readonly KS_CHANNEL_KEY="KSChannelID" 420 readonly KS_CHANNEL_KEY="KSChannelID"
420 readonly KS_BRAND_KEY="KSBrandID" 421 readonly KS_BRAND_KEY="KSBrandID"
421 422
422 readonly QUARANTINE_ATTR="com.apple.quarantine" 423 readonly QUARANTINE_ATTR="com.apple.quarantine"
424 readonly KEYCHAIN_REAUTHORIZE_DIR=".keychain_reauthorize"
423 425
424 # Don't use rsync -a, because -a expands to -rlptgoD. -g and -o copy owners 426 # Don't use rsync -a, because -a expands to -rlptgoD. -g and -o copy owners
425 # and groups, respectively, from the source, and that is undesirable in this 427 # and groups, respectively, from the source, and that is undesirable in this
426 # case. -D copies devices and special files; copying devices only works 428 # case. -D copies devices and special files; copying devices only works
427 # when running as root, so for consistency between privileged and 429 # when running as root, so for consistency between privileged and
428 # unprivileged operation, this option is omitted as well. 430 # unprivileged operation, this option is omitted as well.
429 # -I, --ignore-times don't skip files that match in size and mod-time 431 # -I, --ignore-times don't skip files that match in size and mod-time
430 # -l, --links copy symlinks as symlinks 432 # -l, --links copy symlinks as symlinks
431 # -r, --recursive recurse into directories 433 # -r, --recursive recurse into directories
432 # -p, --perms preserve permissions 434 # -p, --perms preserve permissions
(...skipping 828 matching lines...) Expand 10 before | Expand all | Expand 10 after
1261 if [[ ${os_major} -gt 10 ]] || 1263 if [[ ${os_major} -gt 10 ]] ||
1262 ([[ ${os_major} -eq 10 ]] && [[ ${os_minor} -ge 6 ]]); then 1264 ([[ ${os_major} -eq 10 ]] && [[ ${os_minor} -ge 6 ]]); then
1263 # On 10.6, xattr supports -r for recursive operation. 1265 # On 10.6, xattr supports -r for recursive operation.
1264 xattr -d -r "${QUARANTINE_ATTR}" "${installed_app}" 2> /dev/null 1266 xattr -d -r "${QUARANTINE_ATTR}" "${installed_app}" 2> /dev/null
1265 else 1267 else
1266 # On earlier systems, xattr doesn't support -r, so run xattr via find. 1268 # On earlier systems, xattr doesn't support -r, so run xattr via find.
1267 find "${installed_app}" -exec xattr -d "${QUARANTINE_ATTR}" {} + \ 1269 find "${installed_app}" -exec xattr -d "${QUARANTINE_ATTR}" {} + \
1268 2> /dev/null 1270 2> /dev/null
1269 fi 1271 fi
1270 1272
1273 # Do Keychain reauthorization. This involves running a stub executable on
1274 # the dmg that loads the newly-updated framework and jumps to it to perform
1275 # the reauthorization. The stub executable can be signed by the old
1276 # certificate even after the rest of Chrome switches to the new certificate,
1277 # so it still has access to the old Keychain items. The stub executable is
1278 # an unbundled flat file executable whose name matches the real
1279 # application's bundle identifier, so it's permitted access to the Keychain
1280 # items. Doing a reauthorization step at update time reauthorizes Keychain
1281 # items for users who never bother restarting Chrome, and provides a
1282 # mechanism to continue doing reauthorizations even after the certificate
1283 # changes. However, it only works for non-system ticket installations of
1284 # Chrome, because the updater runs as root when on a system ticket, and root
1285 # can't access individual user Keychains.
1286 #
1287 # Even if the reauthorization tool is launched, it doesn't necessarily try
1288 # to do anything. It will only attempt to perform a reauthorization if one
1289 # hasn't yet been done at update time.
1290 note "maybe reauthorizing Keychain"
1291
1292 if [[ -z "${system_ticket}" ]]; then
1293 local new_bundleid_app
1294 new_bundleid_app="$(defaults read "${installed_app_plist}" \
1295 "${APP_BUNDLEID_KEY}" || true)"
1296 note "new_bundleid_app = ${new_bundleid_app}"
1297
1298 local keychain_reauthorize_dir="\
1299 ${update_dmg_mount_point}/${KEYCHAIN_REAUTHORIZE_DIR}"
1300 local keychain_reauthorize_path="\
1301 ${keychain_reauthorize_dir}/${new_bundleid_app}"
1302 note "keychain_reauthorize_path = ${keychain_reauthorize_path}"
1303
1304 if [[ -x "${keychain_reauthorize_path}" ]]; then
1305 local framework_dir="${new_versioned_dir}/${FRAMEWORK_DIR}"
1306 local framework_code_path="${framework_dir}/${FRAMEWORK_NAME}"
1307 note "framework_code_path = ${framework_code_path}"
1308
1309 if [[ -f "${framework_code_path}" ]]; then
1310 note "reauthorizing Keychain"
1311 "${keychain_reauthorize_path}" "${framework_code_path}"
1312 fi
1313 fi
1314 else
1315 note "system ticket, not reauthorizing Keychain"
1316 fi
1317
1271 # Great success! 1318 # Great success!
1272 note "done!" 1319 note "done!"
1273 1320
1274 trap - EXIT 1321 trap - EXIT
1275 1322
1276 return 0 1323 return 0
1277 } 1324 }
1278 1325
1279 # Check "less than" instead of "not equal to" in case Keystone ever changes to 1326 # Check "less than" instead of "not equal to" in case Keystone ever changes to
1280 # pass more arguments. 1327 # pass more arguments.
1281 if [[ ${#} -lt 1 ]]; then 1328 if [[ ${#} -lt 1 ]]; then
1282 usage 1329 usage
1283 exit 2 1330 exit 2
1284 fi 1331 fi
1285 1332
1286 main "${@}" 1333 main "${@}"
1287 exit ${?} 1334 exit ${?}
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698