Skip to content

Commit

Permalink
Merge pull request #23 from gabriel-samfira/fix-selinux-unit-file
Browse files Browse the repository at this point in the history
Fix SELinux security context on unit file
  • Loading branch information
gabriel-samfira committed Feb 16, 2024
2 parents ceeb0b7 + b2898e9 commit bbe4930
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions cloudconfig/templates.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,10 @@ SVC_NAME=$(cat /home/{{ .RunnerUsername }}/actions-runner/.service)
sendStatus "generating systemd unit file"
getRunnerFile "systemd/unit-file?runAsUser={{ .RunnerUsername }}" "$SVC_NAME" || fail "failed to get service file"
sudo mv $SVC_NAME /etc/systemd/system/ || fail "failed to move service file"
sudo chown root:root /etc/systemd/system/$SVC_NAME || fail "failed to change owner"
if [ -e "/sys/fs/selinux" ];then
sudo chcon -h system_u:object_r:systemd_unit_file_t:s0 /etc/systemd/system/$SVC_NAME || fail "failed to change selinux context"
fi
sendStatus "enabling runner service"
cp /home/{{ .RunnerUsername }}/actions-runner/bin/runsvc.sh /home/{{ .RunnerUsername }}/actions-runner/ || fail "failed to copy runsvc.sh"
Expand Down Expand Up @@ -202,8 +206,7 @@ sudo ./svc.sh install {{ .RunnerUsername }} || fail "failed to install service"
{{- end}}
if [ -e "/sys/fs/selinux" ];then
sudo chcon -h user_u:object_r:bin_t /home/runner/ || fail "failed to change selinux context"
sudo chcon -R -h {{ .RunnerUsername }}:object_r:bin_t /home/runner/* || fail "failed to change selinux context"
sudo chcon -R -h user_u:object_r:bin_t:s0 /home/runner/ || fail "failed to change selinux context"
fi
AGENT_ID=""
Expand Down

0 comments on commit bbe4930

Please sign in to comment.