mirror of
https://github.com/koverstreet/bcachefs-tools.git
synced 2025-12-10 00:00:24 +03:00
key: Pass --keyname and --accept-cached to systemd-ask-password
Before asking for a passphrase, mount.bcachefs searches for an existing key in the keyring containing a passphrase for the filesystem. This means that the user only has to enter the passphrase once when mounting the filesystem multiple times. However, if the key appears in between the check and the time when systemd-ask-password queries the user for a password, the existing key will not be reused. Also, when multiple instances of mount.bcachefs are started in parallel for the same filesystem (such as during boot), each of them will see that the key is not in the keyring and start an instance of systemd-ask-password, meaning that the user will be queried multiple times. Fix the race condition by passing the --keyname and --accept-cached options to systemd-ask-password which also makes it try itself to retreive a cached password from the keyring before querying the user for a password.
This commit is contained in:
parent
e5f4be87a8
commit
69cb6428ba
@ -159,6 +159,8 @@ impl Passphrase {
|
||||
let output = Command::new("systemd-ask-password")
|
||||
.arg("--icon=drive-harddisk")
|
||||
.arg(format!("--id=bcachefs:{}", uuid.as_hyphenated()))
|
||||
.arg(format!("--keyname={}", uuid.as_hyphenated()))
|
||||
.arg("--accept-cached")
|
||||
.arg("-n")
|
||||
.arg("Enter passphrase: ")
|
||||
.stdin(Stdio::inherit())
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user