Skip to Content.
Sympa Menu

sm-commit - [SM-Commit] GIT changes to master sorcery by Jaka Kranjc (30dcfb9958ba380aa6e753826b651c49439e5c5a)

sm-commit AT lists.ibiblio.org

Subject: Source Mage code commit list

List archive

Chronological Thread  
  • From: Jaka Kranjc <scm AT sourcemage.org>
  • To: sm-commit AT lists.ibiblio.org
  • Subject: [SM-Commit] GIT changes to master sorcery by Jaka Kranjc (30dcfb9958ba380aa6e753826b651c49439e5c5a)
  • Date: Thu, 4 Dec 2008 04:42:29 -0600

GIT changes to master sorcery by Jaka Kranjc <lynxlynxlynx AT sourcemage.org>:

ChangeLog | 3 +++
usr/sbin/alter | 18 ++++++++++++++++++
usr/sbin/cast | 2 ++
usr/sbin/cleanse | 21 +++++++++++++++++++++
usr/sbin/confmeld | 9 ++++++++-
usr/sbin/delve | 4 ++++
usr/sbin/dispel | 14 +++++++++-----
usr/sbin/resurrect | 19 +++++++++++++++++++
usr/sbin/scribe | 3 +++
usr/sbin/sorcery | 25 +++++++++++++++++++++++--
usr/sbin/summon | 3 +++
11 files changed, 113 insertions(+), 8 deletions(-)

New commits:
commit 30dcfb9958ba380aa6e753826b651c49439e5c5a
Author: Jaka Kranjc <lynxlynxlynx AT sourcemage.org>
Commit: Jaka Kranjc <lynxlynxlynx AT sourcemage.org>

*: validate commandline parameters before su-ing #7286

diff --git a/ChangeLog b/ChangeLog
index ecb8ca5..d093cde 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,6 @@
+2008-12-04 Jaka Kranjc <lynxlynxlynx AT sourcemage.org>
+ * *: validate commandline parameters before su-ing #7286
+
2008-12-03 Jaka Kranjc <lynxlynxlynx AT sourcemage.org>
* gaze: improved what/short when dealing with multiple spells #14839
changed the value of GAZE_VERBOSE for better readability
diff --git a/usr/sbin/alter b/usr/sbin/alter
index 4759998..65bd956 100755
--- a/usr/sbin/alter
+++ b/usr/sbin/alter
@@ -545,6 +545,21 @@ EOF

}

+function verify_parameters()
+{
+ while [[ $# -gt 0 ]]; do
+ case "$1" in
+ -m|--md5mend|-p|--prelink) true ;;
+ -s|--strip|-z|--strip-all) true ;;
+ -a|--alter) true ;;
+ -n|--spell|-v|--version) true ;;
+ -*) main ;;
+ *) true ;;
+ esac
+ shift
+ done
+}
+
#include sorcery configuration (and thus subroutines)
. /etc/sorcery/config

@@ -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

[[ $arguments ]] && confmeld_partial $arguments
@@ -300,7 +304,7 @@ function main()

[[ -d $CONFIG_STAGE_DIRECTORY ]] || mkdir -p $CONFIG_STAGE_DIRECTORY

- 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() {

rm -f $UPDATE_SCRIPT
@@ -1927,7 +1946,6 @@ main() {

}

-
. /etc/sorcery/config
if [ "$UID" == 0 ]; then
DIALOG='$DIALOGPROG --backtitle "Sorcery Spell Management Utility"
--stdout'
@@ -1943,8 +1961,11 @@ else
help
else
if [[ $1 == -v ]] || [[ $1 == --version ]] || [[ $1 == version ]]; then
- echo $( cat /etc/sorcery/version )
+ cat /etc/sorcery/version
else
+ # validate the rest of the parameters before su-ing
+ verify_parameters "$@"
+
echo "Enter the root password, please."
PARAMS=$(consolidate_params "$@")
exec su -c "sorcery $PARAMS" root
diff --git a/usr/sbin/summon b/usr/sbin/summon
index 899ee8f..bc85895 100755
--- a/usr/sbin/summon
+++ b/usr/sbin/summon
@@ -242,6 +242,9 @@ if [ "$UID" == 0 ] ; then
exit $rc
elif [[ $1 == -h ]] || [[ $1 == --help ]] ; then help
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 "summon $PARAMS" root



  • [SM-Commit] GIT changes to master sorcery by Jaka Kranjc (30dcfb9958ba380aa6e753826b651c49439e5c5a), Jaka Kranjc, 12/04/2008

Archive powered by MHonArc 2.6.24.

Top of Page