From b1f1e60c4db7b4287edc18370c043cff019ea018 Mon Sep 17 00:00:00 2001 From: Petr Lautrbach Date: Wed, 16 Sep 2009 21:55:04 +0200 Subject: [PATCH] tuned.initscript: fixed usage and insuficient rights (#523385) --- tuned.initscript | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/tuned.initscript b/tuned.initscript index 5465a0d..50608d1 100755 --- a/tuned.initscript +++ b/tuned.initscript @@ -29,6 +29,10 @@ config="/etc/tuned.conf" lockfile=/var/lock/subsys/$prog start () { + if [ $UID -ne 0 ] ; then + echo "User had insufficient privilege." + exit 4 + fi [ -x $exec ] || exit 5 [ -f $config ] || exit 6 echo -n $"Starting $prog: " @@ -39,6 +43,10 @@ start () { } stop () { + if [ $UID -ne 0 ] ; then + echo "User had insufficient privilege." + exit 4 + fi echo -n $"Stopping $prog: " killproc $prog retval=$? @@ -68,6 +76,15 @@ rh_status_q() { rh_status >/dev/null 2>&1 } +usage() { + echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload}" +} + +if [ $# -eq 0 ]; then + usage + exit 0 +fi + case "$1" in start) rh_status_q && exit 0 @@ -95,7 +112,7 @@ case "$1" in restart ;; *) - echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload}" + usage exit 2 esac exit $?