From 3086c09b2b3888f4d99a7df3a959a07216953921 Mon Sep 17 00:00:00 2001 From: P. J. McDermott Date: Fri, 22 Aug 2014 17:58:46 -0400 Subject: prokit: Check for superuser privileges --- (limited to 'src') diff --git a/src/prokit.sh b/src/prokit.sh index b87d1ef..91e76c8 100644 --- a/src/prokit.sh +++ b/src/prokit.sh @@ -83,6 +83,7 @@ main() else cmd="${1}" shift + check_uid || error 1 "$(get_msg 'uid_0_req')" fi run_cmd "${cmd}" "${@}" @@ -90,4 +91,23 @@ main() return ${?} } +check_uid() +{ + local uname_s= + local uid= + + uname_s="$( (uname -s) 2>/dev/null)" || uname_s='unknown' + uid="$(id -u)" + + case "${uname_s}" in + 'Linux') + if [ ${uid} -ne 0 ]; then + return 1 + fi + ;; + esac + + return 0 +} + main "${@}" -- cgit v0.9.1