clevis-luks-askpass.service does not decrypt with a loop way

Bug #1965867 reported by zhechen
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
clevis (Ubuntu)
New
Undecided
Unassigned

Bug Description

host envrioment:
   version: ubuntu-20.04.2 LTS
   kernel: 5.4.0-1043
   clevis-systemd: 12-1ubuntu2.2(amd64)

We want to mount the data disk automatically in NBDE way(ref: https://semanticlab.net/sysadmin/encryption/Network-bound-disk-encryption-in-ubuntu-20.04/), but it's failure when the tang server was temporarily inaccessible. and I found clevis-luks-askpass.service was not send request repeately! It does not meet our expectations.

The error message after reboot host:

  Mar 22 04:37:45 cz-ubuntu20 clevis-luks-askpass[509]: + TS=2022_03_22_04_37_45
  Mar 22 04:37:45 cz-ubuntu20 clevis-luks-askpass[509]: + echo '2022_03_22_04_37_45 [info] clevis unlock done..'
  Mar 22 04:37:45 cz-ubuntu20 clevis-luks-askpass[509]: + '[' true == true ']'
  Mar 22 04:37:45 cz-ubuntu20 clevis-luks-askpass[509]: + '[' false == true ']'
  Mar 22 04:37:45 cz-ubuntu20 clevis-luks-askpass[509]: + (( todo++ ))
  Mar 22 04:37:45 cz-ubuntu20 systemd[1]: clevis-luks-askpass.service: Main process exited, code=exited, status=1/FAILURE
  Mar 22 04:37:45 cz-ubuntu20 systemd[1]: clevis-luks-askpass.service: Failed with result 'exit-code'.

And there is a problem with the following code:

  // /usr/lib/x86_64-linux-gnu/clevis-luks-askpass
    1 #!/bin/bash -e
  ...
  ...
  108 [ "$metadata" == true ] || continue
  109 [ "$unlocked" == true ] && continue
  110 ((todo++)) # -> exit here
  111 done
  112
  113 if [ $todo -eq 0 ] || [ "$loop" != true ]; then
  114 break;
  115 fi

because clevis-luks-askpass enable '-e' at first line, and '((todo++))' return 1, so exit at line 110.

we can use the following method to fix this error:

  110 todo=$((todo+1))
    or
  110 ((todo=todo+1))

information type: Private Security → Public
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.