Skip to content

Commit

Permalink
Avoid 'head' usage in scripts that may run in initramfs
Browse files Browse the repository at this point in the history
Ubuntu's busybox-initramfs package does not provide the `head` function.
Replace `head` usage with an equivalent `sed` command.
  • Loading branch information
dannf authored and sergio-correia committed Sep 18, 2020
1 parent 1285061 commit adaef40
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/luks/clevis-luks-bind.in
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ if [ "${luks_type}" = "luks1" ]; then
# have to wipe out the LUKSMeta slot priot to adding the new key.
first_free_cs_slot=$(cryptsetup luksDump "${DEV}" \
| sed -rn 's|^Key Slot ([0-7]): DISABLED$|\1|p' \
| head -n 1)
| sed -n 1p)
if [ -z "${first_free_cs_slot}" ]; then
echo "There are no more free slots in ${DEV}!" >&2
exit 1
Expand Down
2 changes: 1 addition & 1 deletion src/luks/clevis-luks-common-functions
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ clevis_luks_read_slot() {
local token_id
token_id=$(cryptsetup luksDump "${DEV}" \
| grep -E -B1 "^\s+Keyslot:\s+${SLT}$" \
| head -n 1 | sed -rn 's|^\s+([0-9]+): clevis|\1|p')
| sed -n 1p | sed -rn 's|^\s+([0-9]+): clevis|\1|p')
if [ -z "${token_id}" ]; then
echo "Cannot load data from ${DEV} slot:${SLT}. No token found!" >&2
return 1
Expand Down
2 changes: 1 addition & 1 deletion src/luks/systemd/dracut/clevis/module-setup.sh.in
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ install() {
/etc/services \
@libexecdir@/clevis-luks-askpass \
clevis-luks-common-functions \
head grep sed cut \
grep sed cut \
clevis-decrypt \
clevis-luks-list \
cryptsetup \
Expand Down

0 comments on commit adaef40

Please sign in to comment.