summaryrefslogtreecommitdiffstats
path: root/remoting
diff options
context:
space:
mode:
authorjamiewalch@chromium.org <jamiewalch@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-04-26 04:53:00 +0000
committerjamiewalch@chromium.org <jamiewalch@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-04-26 04:53:00 +0000
commite6adb2de1d187bbe98d023559da006a4cec07d78 (patch)
tree05dcb39f09e5013dd1f7937d00b36ffc9b4b0f33 /remoting
parent81dd32100965a9e9c05e30b41d3683f222cd7c97 (diff)
downloadchromium_src-e6adb2de1d187bbe98d023559da006a4cec07d78.zip
chromium_src-e6adb2de1d187bbe98d023559da006a4cec07d78.tar.gz
chromium_src-e6adb2de1d187bbe98d023559da006a4cec07d78.tar.bz2
Don't use pgrep on OS X.
pgrep doesn't exist on some Mac OS X installations (OOtB 10.7, for example). BUG=235586 Review URL: https://chromiumcodereview.appspot.com/13868015 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@196616 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting')
-rwxr-xr-xremoting/host/installer/mac/Scripts/remoting_postflight.sh9
-rwxr-xr-xremoting/host/installer/mac/Scripts/remoting_preflight.sh17
2 files changed, 16 insertions, 10 deletions
diff --git a/remoting/host/installer/mac/Scripts/remoting_postflight.sh b/remoting/host/installer/mac/Scripts/remoting_postflight.sh
index eff02e4..2790e47 100755
--- a/remoting/host/installer/mac/Scripts/remoting_postflight.sh
+++ b/remoting/host/installer/mac/Scripts/remoting_postflight.sh
@@ -27,6 +27,13 @@ function on_error {
exit 1
}
+function find_login_window_for_user {
+ # This function mimics the behaviour of pgrep, which may not be installed
+ # on Mac OS X.
+ local user=$1
+ ps -ec -u "$user" -o comm,pid | awk '$1 == "loginwindow" { print $2; exit }'
+}
+
trap on_error ERR
trap 'rm -f "$USERS_TMP_FILE"' EXIT
@@ -99,7 +106,7 @@ if [[ -r "$USERS_TMP_FILE" ]]; then
# find the PID of a process which is running in that context. The
# loginwindow process is a good candidate since the user (if logged in to
# a session) will definitely be running it.
- pid="$(pgrep -n -x -u "$uid" loginwindow || true)"
+ pid="$(find_login_window_for_user "$uid")"
if [[ -n "$pid" ]]; then
launchctl bsexec "$pid" sudo -u "#$uid" launchctl load -w -S Aqua "$PLIST"
launchctl bsexec "$pid" sudo -u "#$uid" launchctl start "$SERVICE_NAME"
diff --git a/remoting/host/installer/mac/Scripts/remoting_preflight.sh b/remoting/host/installer/mac/Scripts/remoting_preflight.sh
index 1f98a9d..e8fcb56 100755
--- a/remoting/host/installer/mac/Scripts/remoting_preflight.sh
+++ b/remoting/host/installer/mac/Scripts/remoting_preflight.sh
@@ -22,6 +22,13 @@ function on_error {
logger An error occurred during Chrome Remote Desktop setup.
}
+function find_users_with_active_hosts {
+ ps -eo uid,command | awk -v script="$SCRIPT_FILE" '
+ $2 == "/bin/sh" && $3 == script && $4 == "--run-from-launchd" {
+ print $1
+ }'
+}
+
trap on_error ERR
logger Running Chrome Remote Desktop preflight script @@VERSION@@
@@ -36,15 +43,7 @@ fi
# postflight script.
rm -f "$USERS_TMP_FILE"
-# Escape '.' -> '\.' for regular-expression matching in pgrep, as pgrep doesn't
-# have any option for fixed-string matching.
-script_command_regex="${SCRIPT_FILE//./\\.} --run-from-launchd"
-
-# '-f' for full argument matching has to be used, as the executable command is
-# just '/bin/sh'.
-for pid in $(pgrep -f "$script_command_regex" || true); do
- # 'tail' is needed to strip the header from 'ps'.
- uid="$(ps -p "$pid" -o uid | tail -n 1)"
+for uid in $(find_users_with_active_hosts); do
if [[ -n "$uid" ]]; then
echo "$uid" >> "$USERS_TMP_FILE"
if [[ "$uid" = "0" ]]; then