This repository has been archived on 2022-02-23. You can view files and clone it, but cannot push or open issues or pull requests.
2020-04-26 22:08:08 +00:00
|
|
|
#! /bin/bash
|
|
|
|
|
2020-04-27 15:23:42 +00:00
|
|
|
# Auto-detect owner of forgehook-backend on current system
|
2020-04-27 14:27:45 +00:00
|
|
|
# stat has different syntax on various system so we use find
|
2020-04-27 15:23:42 +00:00
|
|
|
owner=$(find /usr/local/bin/forgehook-backend -maxdepth 0 -printf '%u')
|
2020-04-27 14:54:55 +00:00
|
|
|
if [[ $? != 0 ]]; then
|
2020-04-27 15:23:42 +00:00
|
|
|
echo "FATAL ERROR: forgehook-backend not found in /usr/local/bin"
|
2020-04-27 14:54:55 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
2020-04-27 14:27:45 +00:00
|
|
|
|
|
|
|
# Start the backend escalating privileges to its owner
|
|
|
|
# TODO: introduce timeout on a dummy sudo to check sudo rules
|
|
|
|
# are setup properly
|
2020-04-27 15:23:42 +00:00
|
|
|
sudo -u "$owner" forgehook-backend $@
|