Skip to content

Commit 0114816

Browse files
nmodi1npalm
andauthored
fix: Safer chown call in runner scripts for custom AMIs (#4654)
Updated the install-runner and start-runner scripts to call `chown` on explicit path instead of just using the current directory. The current script will work for most users, however, this change will make it more safer and avoid risk of unintended changes. For example, if the `cd /opt/actions-runner` call in the template file (`images/start-runner.sh`) is missed, the script will change owner of the root directory (`/`) instead. --------- Co-authored-by: Niek Palm <[email protected]>
1 parent a00a427 commit 0114816

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

modules/runners/templates/install-runner.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,5 +70,5 @@ if [[ "$os_id" =~ ^ubuntu.* ]]; then
7070
fi
7171

7272
echo "Set file ownership of action runner"
73-
chown -R "$user_name":"$user_name" .
73+
chown -R "$user_name":"$user_name" /opt/actions-runner
7474
chown -R "$user_name":"$user_name" /opt/hostedtoolcache

modules/runners/templates/start-runner.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ if [[ "$run_as" == "root" ]]; then
190190
export RUNNER_ALLOW_RUNASROOT=1
191191
fi
192192

193-
chown -R $run_as .
193+
chown -R $run_as /opt/actions-runner
194194

195195
info_arch=$(uname -p)
196196
info_os=$( ( lsb_release -ds || cat /etc/*release || uname -om ) 2>/dev/null | head -n1 | cut -d "=" -f2- | tr -d '"')

0 commit comments

Comments
 (0)