OLD | NEW |
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 # Called as root after Keystone ticket promotion to change the owner, group, | 7 # Called as root after Keystone ticket promotion to change the owner, group, |
8 # and permissions on the application. The application bundle and its contents | 8 # and permissions on the application. The application bundle and its contents |
9 # are set to owner root, group wheel, and to be writable only by root, but | 9 # are set to owner root, group wheel, and to be writable only by root, but |
10 # readable and executable (when appropriate) by everyone. | 10 # readable and executable (when appropriate) by everyone. |
11 # | 11 # |
12 # Note that this script will be invoked with the real user ID set to the | 12 # Note that this script will be invoked with the real user ID set to the |
13 # user's ID, but the effective user ID set to 0 (root). bash -p is used on | 13 # user's ID, but the effective user ID set to 0 (root). bash -p is used on |
14 # the first line to prevent bash from setting the effective user ID to the | 14 # the first line to prevent bash from setting the effective user ID to the |
15 # real user ID (dropping root privileges). | 15 # real user ID (dropping root privileges). |
16 # | 16 # |
17 # WARNING: This script is NOT currently run when the Keystone ticket is | 17 # WARNING: This script is NOT currently run when the Keystone ticket is |
18 # promoted during application installation directly from the disk image, | 18 # promoted during application installation directly from the disk image, |
19 # because the installation process itself handles the same permission fix-ups | 19 # because the installation process itself handles the same permission fix-ups |
20 # that this script normally would. | 20 # that this script normally would. |
21 | 21 |
22 set -e | 22 set -e |
23 | 23 |
24 # This script runs as root, so be paranoid about things like ${PATH}. | 24 # This script runs as root, so be paranoid about things like ${PATH}. |
25 export PATH="/usr/bin:/usr/sbin:/bin:/sbin" | 25 export PATH="/usr/bin:/usr/sbin:/bin:/sbin" |
26 | 26 |
27 # Output the pid to stdout before doing anything else. See | 27 # Output the pid to stdout before doing anything else. See |
28 # chrome/browser/mac/authorization_util.h. | 28 # base/mac/authorization_util.h. |
29 echo "${$}" | 29 echo "${$}" |
30 | 30 |
31 if [ ${#} -ne 1 ] ; then | 31 if [ ${#} -ne 1 ] ; then |
32 echo "usage: ${0} APP" >& 2 | 32 echo "usage: ${0} APP" >& 2 |
33 exit 2 | 33 exit 2 |
34 fi | 34 fi |
35 | 35 |
36 APP="${1}" | 36 APP="${1}" |
37 | 37 |
38 # Make sure that APP is an absolute path and that it exists. | 38 # Make sure that APP is an absolute path and that it exists. |
39 if [ -z "${APP}" ] || [ "${APP:0:1}" != "/" ] || [ ! -d "${APP}" ] ; then | 39 if [ -z "${APP}" ] || [ "${APP:0:1}" != "/" ] || [ ! -d "${APP}" ] ; then |
40 echo "${0}: must provide an absolute path naming an extant directory" >& 2 | 40 echo "${0}: must provide an absolute path naming an extant directory" >& 2 |
41 exit 3 | 41 exit 3 |
42 fi | 42 fi |
43 | 43 |
44 OWNER_GROUP="root:wheel" | 44 OWNER_GROUP="root:wheel" |
45 chown -Rh "${OWNER_GROUP}" "${APP}" >& /dev/null | 45 chown -Rh "${OWNER_GROUP}" "${APP}" >& /dev/null |
46 | 46 |
47 CHMOD_MODE="a+rX,u+w,go-w" | 47 CHMOD_MODE="a+rX,u+w,go-w" |
48 chmod -R "${CHMOD_MODE}" "${APP}" >& /dev/null | 48 chmod -R "${CHMOD_MODE}" "${APP}" >& /dev/null |
49 | 49 |
50 # On the Mac, or at least on HFS+, symbolic link permissions are significant, | 50 # On the Mac, or at least on HFS+, symbolic link permissions are significant, |
51 # but chmod -R and -h can't be used together. Do another pass to fix the | 51 # but chmod -R and -h can't be used together. Do another pass to fix the |
52 # permissions on any symbolic links. | 52 # permissions on any symbolic links. |
53 find "${APP}" -type l -exec chmod -h "${CHMOD_MODE}" {} + >& /dev/null | 53 find "${APP}" -type l -exec chmod -h "${CHMOD_MODE}" {} + >& /dev/null |
54 | 54 |
55 exit 0 | 55 exit 0 |
OLD | NEW |