Skip to content

Commit

Permalink
Protecting paths when using module_get_path()
Browse files Browse the repository at this point in the history
  • Loading branch information
Bishop Bettini committed Aug 5, 2014
1 parent 654e43c commit 43bc773
Show file tree
Hide file tree
Showing 17 changed files with 31 additions and 31 deletions.
4 changes: 2 additions & 2 deletions break/source.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@

# Loads functions
function break_load() {
source $(module_get_path break)/functions.sh
source "$(module_get_path break)"/functions.sh
}

# This function is responsible for putting the module in a useable state by
# setting some defaults.
function break_post_load() {
break_interval=7200
break_conf_path=${HOME}/.break
break_conf_path="${HOME}"/.break
}
6 changes: 3 additions & 3 deletions conf/auto/source.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@

# Loads the functions that extend the conf API and the conf overloads.
function conf_auto_load() {
source $(module_get_path conf_auto)/functions.sh
source $(module_get_path conf_auto)/conf.sh
source "$(module_get_path conf_auto)"/functions.sh
source "$(module_get_path conf_auto)"/conf.sh
}

# Sets conf_auto_conf_path and loads the module configuration.
Expand All @@ -22,5 +22,5 @@ function conf_auto_load() {
# details.
# @calls conf_load()
function conf_auto_post_load() {
conf_auto_conf_path="$HOME/.conf_auto"
conf_auto_conf_path="${HOME}"/.conf_auto
}
4 changes: 2 additions & 2 deletions conf/source.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@
# This function should be called when the module is loaded. It will load
# functions it depends on.
function conf_load() {
source $(module_get_path conf)/functions.sh
source $(module_get_path conf)/module.sh
source "$(module_get_path conf)"/functions.sh
source "$(module_get_path conf)"/module.sh
}
2 changes: 1 addition & 1 deletion docs/bashdoc/source.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ function docs_bashdoc_for_module() {
local path="$docs_path/modules/$module_name"
local module_path="$(module_get_path $module_name)"

$(module_get_path docs_bashdoc)/current/bashdoc.sh \
"$(module_get_path docs_bashdoc)"/current/bashdoc.sh \
-p $module_name \
-o $path \
`find "$module_path" \( -name bashunit -prune \) -o \( -type f -name "*.sh" -print \)`
Expand Down
4 changes: 2 additions & 2 deletions docs/source.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ function docs() {

export docs_path
export docs_template_path
$(module_get_path docs)/bwdocs/doc.pl $(module_get_path docs)/..
"$(module_get_path docs)"/bwdocs/doc.pl "$(module_get_path docs)"/..

rst2html "$(module_get_path module)/docs/guide.rst" > "$docs_path/bashworks_guide.html"
}
Expand All @@ -46,5 +46,5 @@ function docs_test() {
export docs_template_path
export docs_template_debug
export docs_debug
$(module_get_path docs)/bwdocs/doc.pl $(module_get_path docs)/bwdocs/example
"$(module_get_path docs)"/bwdocs/doc.pl "$(module_get_path docs)"/bwdocs/example
}
2 changes: 1 addition & 1 deletion hack/source.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# @License Apache

function hack_load() {
source $(module_get_path hack)/functions.sh
source "$(module_get_path hack)"/functions.sh
}

function hack_post_load() {
Expand Down
2 changes: 1 addition & 1 deletion mlog/source.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

# Loads Bashinator!
function mlog_load() {
source $(module_get_path mlog)/bashinator-0.3.sh
source "$(module_get_path mlog)"/bashinator-0.3.sh
}

# Log a message with a given security.
Expand Down
4 changes: 2 additions & 2 deletions module/source.sh
Original file line number Diff line number Diff line change
Expand Up @@ -343,9 +343,9 @@ function module_unset() {
# location on the file system.
# This function is used by any module _load() function.
# Example usage:
# source $(module_get_path yourmodule)/functions.sh
# source "$(module_get_path yourmodule)"/functions.sh
# Example submodule usage:
# source $(module_get_path yourmodule_submodule)/functions.sh
# source "$(module_get_path yourmodule_submodule)"/functions.sh
# @param Module name
function module_get_path() {
echo ${module_paths[$1]}
Expand Down
2 changes: 1 addition & 1 deletion mpd/source.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

# Declares module configuration variable names.
function mpd_load() {
source $(module_get_path mpd)/functions.sh
source "$(module_get_path mpd)"/functions.sh
}

# It sets some defaults and load the user configuration data.
Expand Down
8 changes: 4 additions & 4 deletions mtests/bashunit/source.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@

# Sources mtest addons for bashunit.
function mtests_bashunit_load() {
source $(module_get_path mtests_bashunit)/runner.sh
source $(module_get_path mtests_bashunit)/assertions.sh
source "$(module_get_path mtests_bashunit)"/runner.sh
source "$(module_get_path mtests_bashunit)"/assertions.sh
}

# Sets up environment variables required by bashunit:
Expand All @@ -30,7 +30,7 @@ function mtests_bashunit_post_load() {
# @polite Will try yourmodule_mtests_basshunit()
# @calls ResultColletor(), RunAll(), Run(), $BASHUNIT_OUTPUTTER
function mtests_bashunit() {
local bashunit_dir=$(module_get_path mtests)/bashunit/current
local bashunit_dir="$(module_get_path mtests)"/bashunit/current
local module_name=$1

local module_overload="${module_name}_mtests_bashunit"
Expand All @@ -42,7 +42,7 @@ function mtests_bashunit() {
fi
fi

local module_path=$(module_get_path $module_name)
local module_path="$(module_get_path $module_name)"

if [[ ! -d $module_path/bashunit ]]; then
return 1
Expand Down
4 changes: 2 additions & 2 deletions mtests/shunit/source.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ function mtests_shunit_pre_load() {

# Loads shUnitPlus.
function mtests_shunit_load() {
source $(module_get_path mtests_shunit)/current/shUnitPlus >/dev/null 2>&1
source "$(module_get_path mtests_shunit)"/current/shUnitPlus >/dev/null 2>&1
}

# Runs the test suites of a module.
Expand All @@ -30,7 +30,7 @@ function mtests_shunit() {
fi
fi

local module_path=$(module_get_path $module_name)
local module_path="$(module_get_path $module_name)"

if [[ ! -d $module_path/shunit ]]; then
return 1
Expand Down
4 changes: 2 additions & 2 deletions os/home/source.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ export os_home_current_prefix=""

# Loads functions and conf overloads.
function os_home_load() {
source $(module_get_path os_home)/functions.sh
source $(module_get_path os_home)/conf.sh
source "$(module_get_path os_home)"/functions.sh
source "$(module_get_path os_home)"/conf.sh
}

# Sets $os_home_current_prefix to the first subdirectory of $os_home_repo that
Expand Down
4 changes: 2 additions & 2 deletions os/pkg/source.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@

function os_pkg_source() {
if [[ -n `which emerge` ]]; then
source $(module_get_path os_pkg)/gentoo.sh
source "$(module_get_path os_pkg)"/gentoo.sh
elif [[ -d /usr/ports ]]; then
source $(module_get_path os_pkg)/bsd.sh
source "$(module_get_path os_pkg)"/bsd.sh
fi
}
2 changes: 1 addition & 1 deletion os/volume/source.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
# This function should be called when the module is loaded, it will
# take care of loading the conf and function submodules.
function os_volume_load() {
source $(module_get_path os_volume)/functions.sh
source "$(module_get_path os_volume)"/functions.sh
}

# This function is responsible of preparing the module in a useable state
Expand Down
2 changes: 1 addition & 1 deletion todo/source.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@

# Sources required functions.
function todo_load() {
source $(module_get_path todo)/functions.sh
source "$(module_get_path todo)"/functions.sh
}
4 changes: 2 additions & 2 deletions vcs/source.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

# Sources functions and aliases.
function vcs_load() {
source $(module_get_path vcs)/aliases.sh
source "$(module_get_path vcs)"/aliases.sh
}

# Sets variable defaultts.
Expand Down Expand Up @@ -43,7 +43,7 @@ function vcs() {
mlog debug "Checking for $vcs_type in $vcs_src_path"
if [[ -d ".$vcs_type" ]]; then
mlog debug "Found $vcs_type in $vcs_src_path"
source $(module_get_path vcs)/${vcs_type}.sh
source "$(module_get_path vcs)"/${vcs_type}.sh
fi
done
fi
Expand Down
4 changes: 2 additions & 2 deletions vps/source.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ function vps_pre_load() {

# Source module functions and util-vserver functions
function vps_load() {
source $(module_get_path vps)/functions.sh
source $(module_get_path vps)/conf.sh
source "$(module_get_path vps)"/functions.sh
source "$(module_get_path vps)"/conf.sh

: ${UTIL_VSERVER_VARS:=/usr/lib/util-vserver/util-vserver-vars}
test -e "$UTIL_VSERVER_VARS" || {
Expand Down

0 comments on commit 43bc773

Please sign in to comment.