The dmcrypt startup scripts fail severely if its waiting for a USB key and there are more than one crypt-targets configured. The reason is wrong file descriptor handling. PATCH attached. Ending in errors like this: * Skipping invalid line in /etc/conf.d/dmcrypt: ='/key' /lib/rcscripts/addons/dm-crypt-start.sh: line 285: =/key: No such file or directory * source "" for crypt-test2 missing, skipping... Reproducible: Always Steps to Reproduce: 1. Have more than one target configured in /etc/conf.d/dmcrypt that need a keyfile from removable media 2. start dmcrypt with the removable media missing 3. boom Actual Results: The script fails to configure most of the devices. Expected Results: The sctip should wait until the timeout happens Its clear to me why this is happening: the main loop that parses /etc/conf.d/dmcrypt connects that file to stdin. Now if we need a keyfile and the mount fails we enter the read_abort() function which reads one character from stdin. But stdin is not connected to the terminal but to /etc/conf.d/dmcrypt so it gets many "wrong" answers until it finds a "y" or "n" in the file. (You can see many lines on the screen showing the "Stop waiting after 22 attempts (mount failed)? (yes/No)" message...) After that parsing of the current line fails because the line is incomplete ending in an error like this: "/lib/rcscripts/addons/dm-crypt-start.sh: line 285: =/key: No such file or directory" (The line has been "read away" by the read_abort function until the first "y", the complete line in my file is "key='/key'") The solution is to use another filedescriptor for reading /etc/conf.d/dmcrypt that 0. (Patch will be attached)
Created attachment 193791 [details, diff] dm-crypt-start.sh.patch
was fixed here: https://sources.gentoo.org/sys-fs/cryptsetup/files/1.0.6-r2-dm-crypt-start.sh?r1=1.1&r2=1.2 and then improved upon here: https://sources.gentoo.org/sys-fs/cryptsetup/files/1.5.1-dmcrypt.rc?r1=1.2&r2=1.3 *** This bug has been marked as a duplicate of bug 243216 ***