From e80f4ddc3909c3716c5b71af2996b3f782e5ba56 Mon Sep 17 00:00:00 2001 From: Alejandro Mery Date: Tue, 3 Mar 2009 20:24:26 +0200 Subject: [PATCH] sde-package: enhanced package_parse() to support '*' and secured --- lib/sde-package.in | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/sde-package.in b/lib/sde-package.in index 0fbd34b..307b00b 100644 --- a/lib/sde-package.in +++ b/lib/sde-package.in @@ -33,19 +33,24 @@ package_confdir() { package_parse() { local ref= list= + try_list() { + eval "cd '$SDEROOT/package' && ls -1d $1/ 2> /dev/null" | + sed -e "s,^,$SDEROOT/package/," + } + for ref; do # sanitise - ref=$(echo "$ref" | tr 'A-Z' 'a-z') + ref=$(echo "$ref" | tr 'A-Z.; ' 'a-z___') if [ -d "$ref" ]; then list="$ref" elif expr "$ref" : '.*/' > /dev/null; then if [ -e "$ref" ]; then list="${ref%/*}" else - list=$(eval "ls -1d '$SDEROOT/package'/$ref/") + list=$(try_list "$ref") fi else - list=$(eval "ls -1d '$SDEROOT/package'/*/$ref/") + list=$(try_list "*/$ref") fi echo "$list" | while read dir; do