summaryrefslogtreecommitdiffstats
path: root/utils
diff options
context:
space:
mode:
authorJeremy Kerr <jk@ozlabs.org>2015-09-11 12:40:16 +0800
committerJeremy Kerr <jk@ozlabs.org>2015-09-11 12:53:33 +0800
commitd6f3931ec79f9c9cbcf9daef1f1d0957cb07ffa5 (patch)
tree849bb25610caa141f16f2678000d269ee4af5a92 /utils
parente22d1340b96d3e22a92e8fcaabdcd2d494c1bea9 (diff)
downloadpetitboot-d6f3931ec79f9c9cbcf9daef1f1d0957cb07ffa5.zip
petitboot-d6f3931ec79f9c9cbcf9daef1f1d0957cb07ffa5.tar.gz
pb-plugin: Don't execute metadata files
Rather than sourcing a plugin's metadata file, explicitly parse variables. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
Diffstat (limited to 'utils')
-rwxr-xr-xutils/pb-plugin32
1 files changed, 25 insertions, 7 deletions
diff --git a/utils/pb-plugin b/utils/pb-plugin
index fcb7383..e107f96 100755
--- a/utils/pb-plugin
+++ b/utils/pb-plugin
@@ -64,6 +64,27 @@ plugin_info()
echo " (version $PLUGIN_VERSION)"
}
+parse_meta()
+{
+ local file name value IFS
+
+ file=$1
+
+ IFS='='
+ while read -r name value
+ do
+ # Ensure we have a sensible variable name
+ echo "$name" | grep -q '^PLUGIN_[A-Z_]*$' || continue
+
+ # we know that $name has no quoting/expansion chars, but we
+ # may need to do some basic surrounding-quote removal for
+ # $value, without evaluating it
+ value=$(echo "$value" | sed "s/^\([\"']\)\(.*\)\1\$/\2/g")
+
+ export $name="$value"
+ done < $file
+}
+
# How the ABI versioning works:
#
# - This script has an ABI defined ($plugin_abi)
@@ -187,7 +208,7 @@ do_install()
exit 1
fi
- . $__dest/$plugin_meta_path
+ parse_meta $__dest/$plugin_meta_path
if ! plugin_abi_check
then
@@ -229,7 +250,7 @@ do_scan_mount()
fi
(
- . $__meta_tmp/$plugin_meta_path
+ parse_meta $__meta_tmp/$plugin_meta_path
plugin_abi_check || exit 1
@@ -371,7 +392,7 @@ do_create()
fi
# Sanity check metadata file
- . $meta_file
+ parse_meta $meta_file
errors=0
warnings=0
@@ -501,10 +522,7 @@ do_lint()
lint_fatal "No metadata file present (expecting" \
"$plugin_meta_path)"
- (sh -e "$__dest/$plugin_meta_path") >/dev/null 2>&1 ||
- lint_err "Plugin metadata file has shell errors"
-
- . "$__dest/$plugin_meta_path"
+ parse_meta "$__dest/$plugin_meta_path"
lint_metadata
for executable in ${PLUGIN_EXECUTABLES}
OpenPOWER on IntegriCloud