#!/bin/sh

# /usr/bin/gksu: ktsuss wrapper

PATH="${PATH}:/sbin:/usr/sbin:/usr/local/sbin"

help() {
	cat <<- EOF
	Usage: gksu [OPTION] command [COMMAND ARGUMENTS]
	Run a command as another user
	
	OPTIONS:
	        -u, --user USER      Runs the command as the given user
	        -h, --help           Show this help
	EOF
}

case $1 in
	-h | --help | "" )
	help
	exit
	;;
	-u | --user )
	USER="$2"
	shift 2
	;;
	* )
	USER="root"
	;;
esac

CMD="$@"

if [ -x "`type -path ktsuss`" ]; then
  KTSUSS="`type -path ktsuss` -u $USER"
else
  echo "$(basename $0): \`ktsuss' command not found"
  exit 1
fi

eval "$KTSUSS" "$CMD"