services/device/devicex: fix devicex for Darwin multi-user mode

Darwin and Linux su commands are different. Adjust the devicex command
for this reality.

Change-Id: If9b0001875409e0e9e4e796fd0c8b459c26366ec
diff --git a/services/device/devicex b/services/device/devicex
index 8166373..e288dbe 100755
--- a/services/device/devicex
+++ b/services/device/devicex
@@ -85,7 +85,14 @@
   local -r devmgr_user=$(getdevowner)
   if [[ "${devmgr_user}" == $(whoami) ]]; then
     "$@"
-  else
+  elif [[ "$(uname)" == "Darwin" ]]; then
+     # We use su -u on Darwin because Darwin su is different from Linux su
+      # and is not found in GCE or EC2 images.
+    sudo -u "${devmgr_user}" \
+         V23_NAMESPACE="${V23_NAMESPACE}" \
+         V23_DEVICE_DIR="${V23_DEVICE_DIR}" \
+         "$@"
+  else 
     # We use sudo/su rather than just sudo -u because the latter is often
     # set up to require a password in common GCE and EC2 images.
     sudo V23_NAMESPACE="${V23_NAMESPACE}"  V23_DEVICE_DIR="${V23_DEVICE_DIR}" \
@@ -336,7 +343,7 @@
     exit 1
   fi
   local -r BIN_INSTALL="${V23_DEVICE_DIR}/bin"
-    run "${BIN_INSTALL}/deviced" start
+    run "${BIN_INSTALL}/deviced" start  
 }
 
 ###############################################################################
diff --git a/services/device/mgmt_v23_test.go b/services/device/mgmt_v23_test.go
index bed7179..23345a4 100644
--- a/services/device/mgmt_v23_test.go
+++ b/services/device/mgmt_v23_test.go
@@ -28,7 +28,8 @@
 //
 // NB: the accounts provided as arguments to this test must already exist.
 // Also, the --v23.tests.shell-on-fail flag is useful to enable debugging
-// output.
+// output. Note that this flag does not work for some shells. Set
+// $SHELL in that case.
 
 package device_test