Skip to content

Commit 2d88cfb

Browse files
luks: make sure the configuration is valid JSON in clevis-luks-bind
That way we error out early and won't e.g. ask for the passphrase (which may take long), if we don't have to.
1 parent 620eb8f commit 2d88cfb

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/luks/clevis-luks-bind

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,11 @@ if ! CFG="${@:$((OPTIND++)):1}" || [ -z "$CFG" ]; then
8888
usage
8989
fi
9090

91+
# Check whether the config is valid JSON.
92+
if ! jose fmt --json="${CFG}" --object 2>/dev/null; then
93+
echo "Configuration is malformed; it should be valid JSON" >&2
94+
exit 1
95+
fi
9196

9297
if [ "${luks_type}" = "luks1" ] && [ -n "${TOKEN_ID}" ]; then
9398
echo "${DEV} is a LUKS1 device; -t is only supported in LUKS2" >&2

0 commit comments

Comments
 (0)