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

Side by Side Diff: remoting/host/installer/linux/debian/chrome-remote-desktop.init

Issue 15848019: Use sudo in remoting init.d script to get a clean per-user environment (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address comments Created 7 years, 6 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/bin/bash 1 #!/bin/bash
2 2
3 ### BEGIN INIT INFO 3 ### BEGIN INIT INFO
4 # Provides: chrome-remote-desktop 4 # Provides: chrome-remote-desktop
5 # Required-Start: $remote_fs $syslog 5 # Required-Start: $remote_fs $syslog
6 # Required-Stop: $remote_fs $syslog 6 # Required-Stop: $remote_fs $syslog
7 # Default-Start: 2 3 4 5 7 # Default-Start: 2 3 4 5
8 # Default-Stop: 0 1 6 8 # Default-Stop: 0 1 6
9 # Short-Description: Chrome Remote Desktop service 9 # Short-Description: Chrome Remote Desktop service
10 ### END INIT INFO 10 ### END INIT INFO
(...skipping 28 matching lines...) Expand all
39 sleep 1 39 sleep 1
40 time_left=$((time_left - 1)) 40 time_left=$((time_left - 1))
41 done 41 done
42 (kill -0 $pid 2>/dev/null) || return `wait $pid` 42 (kill -0 $pid 2>/dev/null) || return `wait $pid`
43 43
44 echo command \"$@\" has timed out >&2 44 echo command \"$@\" has timed out >&2
45 kill $pid 45 kill $pid
46 return 1 46 return 1
47 } 47 }
48 48
49 # Usage: run_and_ignore_error [-l] user program [args...]
Sergey Ulanov 2013/06/07 20:51:21 maybe better to use "--login" instead of -l.
Lambros 2013/06/11 01:41:02 Done.
50 # -l: Run program in a clean login shell (which requires backgrounding, since
Sergey Ulanov 2013/06/07 20:51:21 the backgrouding details is important here, so may
Lambros 2013/06/11 01:41:02 Done.
51 # the user's .profile or .login script might be run, which might contain
52 # blocking commands).
49 run_and_ignore_error() { 53 run_and_ignore_error() {
54 login_options=""
55 if [ "$1" = "-l" ]; then
56 login_options="-b -i"
57 shift
58 fi
59
50 user=$1 60 user=$1
51 shift 61 shift
52 exec=$1
53 shift
54 62
55 set +e 63 set +e
56 if [ "$(whoami)" = "$user" ]; then 64 if [ "$(whoami)" = "$user" ]; then
57 "$exec" "$@" 65 "$@"
58 else 66 else
59 shell="$(getent passwd "$user" | cut -d: -f7)" 67 sudo -u "$user" $login_options "$@"
60 USER="$user" LOGNAME="$user" SHELL="$shell" start-stop-daemon \
61 --chuid "$user" --exec "$exec" --start -- "$@"
62 fi 68 fi
63 } 69 }
64 70
65 do_start() { 71 do_start() {
66 log_begin_msg "Starting Chrome Remote Desktop host for $1..." 72 log_begin_msg "Starting Chrome Remote Desktop host for $1..."
67 run_and_ignore_error $1 "$HOST_PATH" --start 73 run_and_ignore_error -l $1 "$HOST_PATH" --start
68 log_end_msg $? 74 log_end_msg $?
69 } 75 }
70 76
71 do_stop() { 77 do_stop() {
72 log_begin_msg "Stopping Chrome Remote Desktop host for $1..." 78 log_begin_msg "Stopping Chrome Remote Desktop host for $1..."
73 run_with_timeout run_and_ignore_error $1 "$HOST_PATH" --stop 79 run_with_timeout run_and_ignore_error $1 "$HOST_PATH" --stop
74 log_end_msg $? 80 log_end_msg $?
75 } 81 }
76 82
77 do_reload() { 83 do_reload() {
78 log_begin_msg "Reloading Chrome Remote Desktop host configuration for $1..." 84 log_begin_msg "Reloading Chrome Remote Desktop host configuration for $1..."
79 run_and_ignore_error $1 "$HOST_PATH" --reload 85 run_and_ignore_error $1 "$HOST_PATH" --reload
80 log_end_msg $? 86 log_end_msg $?
81 } 87 }
82 88
83 do_restart() { 89 do_restart() {
84 log_begin_msg "Restarting Chrome Remote Desktop host for $1..." 90 log_begin_msg "Restarting Chrome Remote Desktop host for $1..."
85 run_and_ignore_error $1 "$HOST_PATH" --stop 91 run_and_ignore_error $1 "$HOST_PATH" --stop
86 run_and_ignore_error $1 "$HOST_PATH" --start 92 run_and_ignore_error -l $1 "$HOST_PATH" --start
87 log_end_msg $? 93 log_end_msg $?
88 } 94 }
89 95
90 for_each_user() { 96 for_each_user() {
91 for user in $USERS; do 97 for user in $USERS; do
92 $1 $user 98 $1 $user
93 done 99 done
94 } 100 }
95 101
96 case "$1" in 102 case "$1" in
(...skipping 13 matching lines...) Expand all
110 for_each_user do_restart 116 for_each_user do_restart
111 ;; 117 ;;
112 118
113 *) 119 *)
114 log_success_msg "Usage: /etc/init.d/chrome-remote-desktop" \ 120 log_success_msg "Usage: /etc/init.d/chrome-remote-desktop" \
115 "{start|stop|reload|force-reload|restart}" 121 "{start|stop|reload|force-reload|restart}"
116 exit 1 122 exit 1
117 esac 123 esac
118 124
119 exit 0 125 exit 0
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698