Skip to content

Dracut module issue detecting TANG for "rd.neednet" injection #468

@Sxderp

Description

@Sxderp

I was configuring network based decryption on my system and noticed the system was not decrypting. I've set it up before and was pretty baffled. I narrowed it down to the lack of "rd.neednet" being present on the commandline. Why I asked, that should be automatic. Turns out there is some issue with the check. I'm /guessing/ it has to do with "hardware" (this is a VM, with a networked disk) speed.

This is the questionable line of code.

if clevis luks list -d "${dev}" | grep -q tang; then

I hacked up the module-setup.sh to figure out what was going on. I added these lines:

clevis luks list -d "${dev}" | grep tang >> "${initdir}/clevis.log"
echo $? >> "${initdir}/clevis.log"
echo "==" >> "${initdir}/clevis.log"
clevis luks list -d "${dev}" | grep -q tang >> "${initdir}/clevis.log"
echo $? >> "${initdir}/clevis.log"

This is what I got:

2: sss '{"t":1,"pins":{"tang":[{"url":"http://tang1.cos.gatech.edu"},{"url":"http://tang2.cos.gatech.edu"},{"url":"http://tang3.cos.gatech.edu"}]}}'
0
==
141

From a "quick google" it seems like the exit code 141 is because "pipefail" is set (dracut sets it??) and grep -q terminates as soon as a match is found but the previous command is still running / printing to the pipe.

Some solutions:

  1. Unset and set pipefail. This would need to check if pipefail was already set, you don't want to set pipefail on when it wasn't set.
  2. Use a subshell. Either for the full function or parts. This allows for more control over pipefail and not needing to worry about reset.
  3. Use process redirection if grep -q tang <(clevis luks list -d "${dev}")
  4. Don't use -q and just redirect the grep output to /dev/null

--

Just for some further clarity. I do believe that my having additional unlockers is partially to blame. But I think that should be a supported configuration.

Here is the full output of the list.

[root@cos-4x12752 60clevis-pin-tang]# clevis luks list -d /dev/sda3
2: sss '{"t":1,"pins":{"tang":[{"url":"http://tang1.cos.gatech.edu"},{"url":"http://tang2.cos.gatech.edu"},{"url":"http://tang3.cos.gatech.edu"}]}}'
3: tpm2 '{"hash":"sha256","key":"ecc","pcr_bank":"sha256","pcr_ids":"0,1,7"}'

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions