michael@0: #!/bin/sh michael@0: michael@0: # Copyright (c) 2012 The Chromium Authors. All rights reserved. michael@0: # Use of this source code is governed by a BSD-style license that can be michael@0: # found in the LICENSE file. michael@0: michael@0: BUILDTYPE="${BUILDTYPE:-Debug}" michael@0: CHROME_SRC_DIR="${CHROME_SRC_DIR:-$(dirname -- $(readlink -fn -- "$0"))/..}" michael@0: CHROME_OUT_DIR="${CHROME_SRC_DIR}/out/${BUILDTYPE}" michael@0: CHROME_SANDBOX_BUILD_PATH="${CHROME_OUT_DIR}/chrome_sandbox" michael@0: CHROME_SANDBOX_INST_PATH="/usr/local/sbin/chrome-devel-sandbox" michael@0: CHROME_SANDBOX_INST_DIR=$(dirname -- "$CHROME_SANDBOX_INST_PATH") michael@0: michael@0: TARGET_DIR_TYPE=$(stat -f -c %t -- "${CHROME_SANDBOX_INST_DIR}" 2>/dev/null) michael@0: if [ $? -ne 0 ]; then michael@0: echo "Could not get status of ${CHROME_SANDBOX_INST_DIR}" michael@0: exit 1 michael@0: fi michael@0: michael@0: # Make sure the path is not on NFS. michael@0: if [ "${TARGET_DIR_TYPE}" = "6969" ]; then michael@0: echo "Please make sure ${CHROME_SANDBOX_INST_PATH} is not on NFS!" michael@0: exit 1 michael@0: fi michael@0: michael@0: installsandbox() { michael@0: echo "(using sudo so you may be asked for your password)" michael@0: sudo -- cp "${CHROME_SANDBOX_BUILD_PATH}" \ michael@0: "${CHROME_SANDBOX_INST_PATH}" && michael@0: sudo -- chown root:root "${CHROME_SANDBOX_INST_PATH}" && michael@0: sudo -- chmod 4755 "${CHROME_SANDBOX_INST_PATH}" michael@0: return $? michael@0: } michael@0: michael@0: if [ ! -d "${CHROME_OUT_DIR}" ]; then michael@0: echo -n "${CHROME_OUT_DIR} does not exist. Use \"BUILDTYPE=Release ${0}\" " michael@0: echo "If you are building in Release mode" michael@0: exit 1 michael@0: fi michael@0: michael@0: if [ ! -f "${CHROME_SANDBOX_BUILD_PATH}" ]; then michael@0: echo -n "Could not find ${CHROME_SANDBOX_BUILD_PATH}, " michael@0: echo "please make sure you build the chrome_sandbox target" michael@0: exit 1 michael@0: fi michael@0: michael@0: if [ ! -f "${CHROME_SANDBOX_INST_PATH}" ]; then michael@0: echo -n "Could not find ${CHROME_SANDBOX_INST_PATH}, " michael@0: echo "installing it now." michael@0: installsandbox michael@0: fi michael@0: michael@0: if [ ! -f "${CHROME_SANDBOX_INST_PATH}" ]; then michael@0: echo "Failed to install ${CHROME_SANDBOX_INST_PATH}" michael@0: exit 1 michael@0: fi michael@0: michael@0: CURRENT_API=$("${CHROME_SANDBOX_BUILD_PATH}" --get-api) michael@0: INSTALLED_API=$("${CHROME_SANDBOX_INST_PATH}" --get-api) michael@0: michael@0: if [ "${CURRENT_API}" != "${INSTALLED_API}" ]; then michael@0: echo "Your installed setuid sandbox is too old, installing it now." michael@0: if ! installsandbox; then michael@0: echo "Failed to install ${CHROME_SANDBOX_INST_PATH}" michael@0: exit 1 michael@0: fi michael@0: else michael@0: echo "Your setuid sandbox is up to date" michael@0: if [ "${CHROME_DEVEL_SANDBOX}" != "${CHROME_SANDBOX_INST_PATH}" ]; then michael@0: echo -n "Make sure you have \"export " michael@0: echo -n "CHROME_DEVEL_SANDBOX=${CHROME_SANDBOX_INST_PATH}\" " michael@0: echo "somewhere in your .bashrc" michael@0: echo "This variable is currently: ${CHROME_DEVEL_SANDBOX:-empty}" michael@0: fi michael@0: fi