Skip to content

Commit

Permalink
Added root check function to smf_import.
Browse files Browse the repository at this point in the history
  • Loading branch information
szaydel committed Apr 4, 2013
1 parent 144505f commit cd6a396
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion tools/smf_import
Expand Up @@ -7,6 +7,17 @@ set -e

SVCCFG="${ROOT}/projects/illumos/usr/src/cmd/svc/svccfg/svccfg-native"

function check_root () {

## If UID or EUID are not 0, we return 1, otherwise we return 0.
if [[ ! ${UID} -eq 0 && ! ${EUID} -eq 0 ]] ; then
echo "FATAL: $0 was not executed by root. User must be root."
return 1
else
return 0
fi
}

rdmnt=$1
if [ -z "${rdmnt}" ] || [ ! -d "${rdmnt}" ]; then
echo "FATAL: Invalid ramdisk root '${rdmnt}'"
Expand All @@ -24,7 +35,7 @@ if [[ ! -x ${SVCCFG} ]]; then
exit 1
fi

# TODO check that we're root
check_root || exit 1 ## If not running as root, bail.

REPO_DB=${rdmnt}/etc/svc/repository.db
export SVCCFG_CHECKHASH=1
Expand Down

0 comments on commit cd6a396

Please sign in to comment.