[Pm-utils] [PATCH 04/17] Verify ownership of pm-utils sourced or executed files

Victor Lowther victor.lowther at gmail.com
Sat Feb 9 18:31:08 PST 2008


When sourcing or executing something that is a part of pm-utils, make sure
we user running pm-utils owns it instead of just checking that it exists.
---
 pm/functions.in |   14 +++++++-------
 1 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/pm/functions.in b/pm/functions.in
index 0ebef00..df632c8 100644
--- a/pm/functions.in
+++ b/pm/functions.in
@@ -30,14 +30,14 @@ SLEEP_FUNCTIONS="${PM_UTILS_LIBDIR}/module.d/${SLEEP_MODULE}"
 # Use c sort order
 export LC_COLLATE=C
 
-[ -f "${PM_UTILS_LIBDIR}"/defaults ] && . "${PM_UTILS_LIBDIR}"/defaults
+[ -O "${PM_UTILS_LIBDIR}"/defaults ] && . "${PM_UTILS_LIBDIR}"/defaults
 set +a
 
 
 source_configs()
 {
 	for cfg in "${PM_UTILS_ETCDIR}"/config.d/*[!~] ; do
-		[ -f "$cfg" ] || continue
+		[ -O "$cfg" ] || continue
 		set -a
 		. "${cfg}"
 		set +a
@@ -119,7 +119,7 @@ find_hooks() {
 	local base
 
 	for base in $(for f in $syshooks/*[!~] $phooks/*[!~];
-		do [ -f "$f" ] && echo ${f##*/} ; done | sort | uniq) ;
+		do [ -O "$f" ] && echo ${f##*/} ; done | sort | uniq) ;
 	do
 		if [ -x "$syshooks/$base" ]; then
 			echo $syshooks/$base
@@ -175,7 +175,7 @@ get_power_status()
 	return $RETVAL
 }
 
-[ -f "${SLEEP_FUNCTIONS}" ] || { 
+[ -O "${SLEEP_FUNCTIONS}" ] || { 
 	echo "Requested sleep module $SLEEP_MODULE not available."
 	exit 1
 }
@@ -262,7 +262,7 @@ modunload()
 modreload()
 {
 	for x in ${STORAGEDIR}/module:* ; do
-		[ -f "${x}" ] && modprobe "${x##*:}" >/dev/null 2>&1
+		[ -O "${x}" ] && modprobe "${x##*:}" >/dev/null 2>&1
 	done
 }
 
@@ -287,7 +287,7 @@ stopservice()
 
 restartservice()
 {
-	[ -f "${STORAGEDIR}/service:$1" ] && service "$1" start
+	[ -O "${STORAGEDIR}/service:$1" ] && service "$1" start
 }
 
 savestate()
@@ -297,5 +297,5 @@ savestate()
 
 restorestate()
 {
-	cat "${STORAGEDIR}/state:${1}"
+	[ -O "${STORAGEDIR}/state:${1}" ] && cat "${STORAGEDIR}/state:${1}"
 }
-- 
1.5.3.8



More information about the Pm-utils mailing list