diff options
-rw-r--r-- | locale/en_US.sh | 3 | ||||
-rw-r--r-- | src/prokit.sh | 20 |
2 files changed, 23 insertions, 0 deletions
diff --git a/locale/en_US.sh b/locale/en_US.sh index d39cf1b..efeaea5 100644 --- a/locale/en_US.sh +++ b/locale/en_US.sh @@ -21,6 +21,9 @@ msg_prokit_opt_h_summary='print this help message' msg_prokit_opt_V_summary='print version information' +# src/prokit.sh +msg_prokit_uid_0_req='Must be run as the superuser' + # lib/fd.sh msg_prokit_emfile='Too many open files' msg_prokit_cant_fopen='Cannot open file' 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 "${@}" |