summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorP. J. McDermott <pj@pehjota.net>2014-08-22 17:58:46 (EDT)
committer P. J. McDermott <pj@pehjota.net>2014-08-22 17:58:46 (EDT)
commit3086c09b2b3888f4d99a7df3a959a07216953921 (patch)
tree34cdf37f93ea306930759cf721a3f46e35e8ae97 /src
parentc538c3a709552912ebce960922c569d46def35ac (diff)
prokit: Check for superuser privileges
Diffstat (limited to 'src')
-rw-r--r--src/prokit.sh20
1 files changed, 20 insertions, 0 deletions
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 "${@}"