Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nixos/luksroot: Implement keyFileTimeout (for non-systemd initrd) #369628

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 13 additions & 10 deletions nixos/modules/system/boot/luksroot.nix
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,11 @@ let
if ! dev_exist $target; then
echo -n "Waiting $secs seconds for $desc..."
local success=false;
for try in $(seq $secs); do
local try=0
while [ $try -lt $secs ] ; do
echo -n "."
sleep 1
try=$((try+1))
if dev_exist $target; then
success=true
break
Expand All @@ -61,9 +63,11 @@ let
if [ $? != 0 ]; then
echo -n "Waiting $secs seconds for YubiKey to appear..."
local success=false
for try in $(seq $secs); do
echo -n .
local try=0
while [ $try -lt $secs ] ; do
echo -n "."
sleep 1
try=$((try+1))
ykinfo -v 1>/dev/null 2>&1
if [ $? == 0 ]; then
success=true
Expand All @@ -88,9 +92,11 @@ let
if [ $? != 0 ]; then
echo -n "Waiting $secs seconds for GPG Card to appear"
local success=false
for try in $(seq $secs); do
echo -n .
local try=0
while [ $try -lt $secs ] ; do
echo -n "."
sleep 1
try=$((try+1))
gpg --card-status > /dev/null 2> /dev/null
if [ $? == 0 ]; then
success=true
Expand Down Expand Up @@ -224,7 +230,8 @@ let
# LUKS
open_normally() {
${if (dev.keyFile != null) then ''
if wait_target "key file" ${dev.keyFile}; then
local timeout=${optionalString (dev.keyFileTimeout != null) (toString dev.keyFileTimeout)}
if wait_target "key file" ${dev.keyFile} "$timeout"; then
${csopen} --key-file=${dev.keyFile} \
${optionalString (dev.keyFileSize != null) "--keyfile-size=${toString dev.keyFileSize}"} \
${optionalString (dev.keyFileOffset != null) "--keyfile-offset=${toString dev.keyFileOffset}"}
Expand Down Expand Up @@ -964,10 +971,6 @@ in
message = "boot.initrd.luks.devices.<name>.bypassWorkqueues is not supported for kernels older than 5.9";
}

{ assertion = !config.boot.initrd.systemd.enable -> all (x: x.keyFileTimeout == null) (attrValues luks.devices);
message = "boot.initrd.luks.devices.<name>.keyFileTimeout is only supported for systemd initrd";
}

{ assertion = config.boot.initrd.systemd.enable -> all (dev: !dev.fallbackToPassword) (attrValues luks.devices);
message = "boot.initrd.luks.devices.<name>.fallbackToPassword is implied by systemd stage 1.";
}
Expand Down
Loading