@@ -565,6 +580,9 @@ elif [[ "$1" == -h ]] ||
[[ -z "$1" ]]; then
main "$1"
else
+ # validate the parameters before su-ing, since we may still drop out
+ verify_parameters "$@"
+
echo "Enter the root password, please." 1>&2
PARAMS=$(consolidate_params "$@")
exec su -c "alter $PARAMS" root
diff --git a/usr/sbin/cast b/usr/sbin/cast
index 5efda5f..48af4a5 100755
--- a/usr/sbin/cast
+++ b/usr/sbin/cast
@@ -881,6 +881,8 @@ if [ $# -eq 0 ]; then help | $PAGER
elif [[ $1 == -h ]] || [[ $1 == --help ]] ; then help
elif [ "$UID" -gt 0 ]; then
+ # validate the parameters before su-ing, since we may still drop out
+ process_parameters "$@"
echo "Enter the root password, please."
PARAMS=$(consolidate_params "$@")
diff --git a/usr/sbin/cleanse b/usr/sbin/cleanse
index a9e66dc..ccd360b 100755
--- a/usr/sbin/cleanse
+++ b/usr/sbin/cleanse
@@ -166,6 +166,24 @@ function args()
return ${rc:-0}
}
+function verify_parameters()
+{
+ while [[ $# -gt 0 ]]; do
+ case $1 in
+ --delint|--prune|--tablet)
+ case $2 in
+ full|doit|coalesce) shift ;;
+ esac
+ ;;
+ --fix|--nofix|--nofix_quick) true ;;
+ --sweep_all|--sweep|--logs) true ;;
+ --tablet_spell|--packages) true ;;
+ -*) usage $*; exit 1 ;;
+ esac
+ shift
+ done
+}
+
#-------------------
## Find stale dependency entries, with full it'll look at off entries too
## @param full if set, looks at off dependencies as well as on
@@ -1070,6 +1088,9 @@ else
usage
exit 0
fi
+ # validate the parameters before su-ing, since we may still drop out
+ verify_parameters "$@"
+
message "You must be root to run this command."
message "Switching to root user..."
PARAMS=$(consolidate_params "$@")
diff --git a/usr/sbin/confmeld b/usr/sbin/confmeld
index a6fd65d..bb8724c 100755
--- a/usr/sbin/confmeld
+++ b/usr/sbin/confmeld
@@ -264,6 +264,9 @@ function confmeld_all()
function process_parameters()
{
local subroutine arguments
+ local mode=$1
+ shift
+
while [[ -n $1 ]]; do
if [[ ${1:0:1} == "-" ]]; then
case "$1" in
@@ -281,6 +284,7 @@ function process_parameters()
fi
shift
done
+ [[ $mode == check-only ]] && return 0
$subroutine
- process_parameters "$@"
+ process_parameters normal "$@"
confmeld_all
}
@@ -308,6 +312,9 @@ function main()
. /etc/sorcery/config
if [ "$UID" -gt 0 ]; then
+ # validate the parameters before su-ing, since we may still drop out
+ process_parameters check-only "$@"
+
echo "Enter the root password, please."
exec su -c "confmeld $@" root
else
diff --git a/usr/sbin/delve b/usr/sbin/delve
index 92be8c1..5f0365e 100755
--- a/usr/sbin/delve
+++ b/usr/sbin/delve
@@ -378,6 +378,7 @@ function process_parameters() {
failure) STATES="$STATES $param" ;;
end) STATES="$STATES $param" ;;
all) ALL=on ;;
+ -*) help ;;
*) SPELL=$param ;;
esac
done
@@ -451,6 +452,9 @@ function main() {
if [ $# -eq 0 ]; then help | $PAGER
elif [[ $1 == -h ]] || [[ $1 == --help ]] ; then help
elif [ "$UID" -gt 0 ]; then
+ # validate the parameters before su-ing, since we may still drop out
+ process_parameters "$@"
+
echo "Enter the root password, please."
PARAMS=$(consolidate_params "$@")
exec su -c "delve $PARAMS" root
diff --git a/usr/sbin/dispel b/usr/sbin/dispel
index abcce03..0ab0f7b 100755
--- a/usr/sbin/dispel
+++ b/usr/sbin/dispel
@@ -155,11 +155,6 @@ function process_parameters() {
shift
fi
done
- # handle downgrading specially, since we also want to pass some of the
flags
- # but can't rely on input being ordered correctly
- if [[ -n $DOWNGRADE_SPELL ]]; then
- downgrade $DOWNGRADE_SPELL $DOWNGRADE_VERSION
- fi
}
function validate_param() {
@@ -585,6 +580,12 @@ function dispel_depends_engine() {
function main() {
process_parameters "$@"
+ # handle downgrading specially, since we also want to pass some of the
flags
+ # but can't rely on input being ordered correctly
+ # having this block here allows process_parameters to be used for input
verification
+ if [[ -n $DOWNGRADE_SPELL ]]; then
+ downgrade $DOWNGRADE_SPELL $DOWNGRADE_VERSION
+ fi
SPELLS=`strip_parameters "$@"`
if [[ $NONORPHAN_DEFAULT ]] ||
@@ -626,6 +627,9 @@ elif [ "$UID" == 0 ]; then
cleanup_tmp_dir $TMP_DIR
exit $rc
else
+ # validate the parameters before su-ing, since we may still drop out
+ process_parameters "$@"
+
echo "Enter the root password, please." 1>&2
PARAMS=$(consolidate_params "$@")
exec su -c "dispel $PARAMS" root
diff --git a/usr/sbin/resurrect b/usr/sbin/resurrect
index 2614506..5a9055f 100755
--- a/usr/sbin/resurrect
+++ b/usr/sbin/resurrect
@@ -224,6 +224,22 @@ function is_resurrectable() {
}
#---------------------------------------------------------------------
+## Make sure the parameters are ok. Used for verification before the
+## user is asked for the su password to avoid futile su-ing.
+#---------------------------------------------------------------------
+function verify_parameters() {
+ while [[ -n $1 ]]; do
+ if [[ ${1:0:1} == "-" ]]; then
+ case "$1" in
+ --latest|-l|--from|-f|--check|-c|--version|-v|--nosustain) true ;;
+ --help|-h|*) help ;;
+ esac
+ fi
+ shift
+ done
+}
+
+#---------------------------------------------------------------------
## Parse the arguments and start resurrecting. If the version is
## specified, the -l option is ignored. If -f is specified, -v and -l
## are ignored. If -c is specified, everything else is ignored.
@@ -285,6 +301,9 @@ function main() {
. /etc/sorcery/config
if [[ $UID -gt 0 ]]; then
+ # validate the parameters before su-ing, since we may still drop out
+ verify_parameters $*
+
echo "Enter the root password, please."
exec su -c "resurrect $@" root
else
diff --git a/usr/sbin/scribe b/usr/sbin/scribe
index f5b383a..aac01bb 100755
--- a/usr/sbin/scribe
+++ b/usr/sbin/scribe
@@ -797,6 +797,9 @@ reindex-version) scribe_reindex_version $@ ;;
. /etc/sorcery/config
+# validate the parameters before potentially su-ing
+find_function $*
+
#check if root. If not, become root
if [ "$UID" == 0 ] ; then
if [[ $NICE != "0" ]] ; then
diff --git a/usr/sbin/sorcery b/usr/sbin/sorcery
index 840895a..5b599cb 100755
--- a/usr/sbin/sorcery
+++ b/usr/sbin/sorcery
@@ -1895,6 +1895,25 @@ sorcery_queue_remove() {
lock_commit_transaction "$INSTALL_QUEUE"
}
+#---------------------------------------------------------------------
+## Make sure the parameters are ok. Used for verification before the
+## user is asked for the su password to avoid futile su-ing.
+#---------------------------------------------------------------------
+verify_parameters() {
+ [[ -z $1 ]] && return 0
+
+ case $1 in
+ -u|update|-s|system-update|-g|upgrade) true ;;
+ -q|queue|queue-security) true ;;
+ -r|rebuild|-rr|rebuild-reconfigure) true ;;
+ add-queue|remove-queue|review-queue) true ;;
+ hold|unhold|exile|unexile) true ;;
+ default*) true ;;
+ *) help ;;
+ esac
+}
+
+
main() {