runasroot.sh revision 9a2e9d56a7114a58b1836316152600105a5d3d9b
## @file
# VirtualBox privileged execution helper script for Linux and Solaris
#
#
# Copyright (C) 2009-2011 Oracle Corporation
#
# This file is part of VirtualBox Open Source Edition (OSE), as
# available from http://www.virtualbox.org. This file is free software;
# General Public License (GPL) as published by the Free Software
# Foundation, in version 2 as it comes in the "COPYING" file of the
# VirtualBox OSE distribution. VirtualBox OSE is distributed in the
# hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
#
# Deal with differing "which" semantics on Linux and Solaris
}
exit 1
fi
;;
*)
echo >&2
echo "Attempt to execute COMMAND with root privileges, displaying DESCRIPTION if" >&2
echo "possible and displaying ADVICE if possible if no su(1)-like tool is available." >&2
exit 1
;;
esac
DESCRIPTION=$1
COMMAND=$2
ADVICE=$3
GKSU_SWITCHES="-au root"
;;
*)
;;
esac
eval "\"$KDESUDO\" --comment \"$DESCRIPTION\" -- $COMMAND"
exit
;;
esac
# Older gksu does not grok --description nor '--' and multiple args.
# @todo which versions do?
# "$GKSU" --description "$DESCRIPTION" -- "$@"
# Note that $GKSU_SWITCHES is NOT quoted in the following
exit
;;
esac
;;
esac # $DISPLAY
# pkexec may work for ssh console sessions as well if the right agents
# are installed. However it is very generic and does not allow for any
# custom messages. Thus it comes after gksu.
exit
;;
esac
# The ultimate fallback is running 'su -' within an xterm. We use the
# title of the xterm to tell what is going on.
case "$GNOME_TERMINAL" in ?*)
exit
;;
esac
exit
;;
esac
;;
esac
esac # $DISPLAY
# Failure...
echo "Unable to locate 'pkexec', 'gksu' or 'su+xterm'. $ADVICE" >&2
;;
*)
echo "Unable to locate 'pkexec'. $ADVICE" >&2
;;
esac
exit 1