Compare commits
1 Commits
password_p
...
initcpio
Author | SHA1 | Date | |
---|---|---|---|
5b69dc7c95
|
2
Cargo.lock
generated
2
Cargo.lock
generated
@@ -377,7 +377,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "fido2luks"
|
name = "fido2luks"
|
||||||
version = "0.2.16"
|
version = "0.2.15"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"ctap_hmac",
|
"ctap_hmac",
|
||||||
"failure",
|
"failure",
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "fido2luks"
|
name = "fido2luks"
|
||||||
version = "0.2.16"
|
version = "0.2.15"
|
||||||
authors = ["shimunn <shimun@shimun.net>"]
|
authors = ["shimunn <shimun@shimun.net>"]
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
|
|
||||||
|
5
PKGBUILD
5
PKGBUILD
@@ -17,10 +17,13 @@ pkgver() {
|
|||||||
|
|
||||||
build() {
|
build() {
|
||||||
cargo build --release --locked --all-features --target-dir=target
|
cargo build --release --locked --all-features --target-dir=target
|
||||||
|
target/release/${pkgname} completions target
|
||||||
}
|
}
|
||||||
|
|
||||||
package() {
|
package() {
|
||||||
install -Dm 755 target/release/${pkgname} -t "${pkgdir}/usr/bin"
|
install -Dm 755 target/release/${pkgname} -t "${pkgdir}/usr/bin"
|
||||||
install -Dm 755 ../pam_mount/fido2luksmounthelper.sh -t "${pkgdir}/usr/bin"
|
install -Dm 755 ../pam_mount/fido2luksmounthelper.sh -t "${pkgdir}/usr/bin"
|
||||||
install -Dm 644 ../fido2luks.bash "${pkgdir}/usr/share/bash-completion/completions/fido2luks"
|
install -Dm 644 target/fido2luks.bash "${pkgdir}/usr/share/bash-completion/completions/fido2luks"
|
||||||
|
install -Dm 755 ../initcpio/hook.sh "${pkgdir}/usr/lib/initcpio/install/fido2luks"
|
||||||
|
install -Dm 755 ../initcpio/hook.sh "${pkgdir}/usr/lib/initcpio/hooks/fido2luks"
|
||||||
}
|
}
|
||||||
|
74
initcpio/hook.sh
Normal file
74
initcpio/hook.sh
Normal file
@@ -0,0 +1,74 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -ax
|
||||||
|
|
||||||
|
exit_with() {
|
||||||
|
echo "$1" >&2
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
validate() {
|
||||||
|
[ ! -e /etc/fido2luks.conf ] && exit_with "/etc/fido2luks.conf does not exist! Please configure first"
|
||||||
|
. /etc/fido2luks.conf
|
||||||
|
[ ! -e "$FIDO2LUKS_DEVICE" ] && exit_with "FIDO2LUKS_DEVICE='$FIDO2LUKS_DEVICE' does not exist!"
|
||||||
|
[ -z "$FIDO2LUKS_CREDENTIAL_ID" ] && exit_with "FIDO2LUKS_CREDENTIAL_ID must be set!"
|
||||||
|
[ -z "$FIDO2LUKS_MAPPER_NAME" ] && exit_with "FIDO2LUKS_MAPPER_NAME must be set!"
|
||||||
|
}
|
||||||
|
|
||||||
|
build() {
|
||||||
|
local mod
|
||||||
|
add_binary "cryptsetup"
|
||||||
|
add_module "dm-crypt"
|
||||||
|
add_module "dm-integrity"
|
||||||
|
if [[ $CRYPTO_MODULES ]]; then
|
||||||
|
for mod in $CRYPTO_MODULES; do
|
||||||
|
add_module "$mod"
|
||||||
|
done
|
||||||
|
else
|
||||||
|
add_all_modules "/crypto/"
|
||||||
|
fi
|
||||||
|
|
||||||
|
add_binary "dmsetup"
|
||||||
|
add_file "/usr/lib/udev/rules.d/10-dm.rules"
|
||||||
|
add_file "/usr/lib/udev/rules.d/13-dm-disk.rules"
|
||||||
|
add_file "/usr/lib/udev/rules.d/95-dm-notify.rules"
|
||||||
|
add_file "/usr/lib/initcpio/udev/11-dm-initramfs.rules" "/usr/lib/udev/rules.d/11-dm-initramfs.rules"
|
||||||
|
|
||||||
|
add_systemd_unit "systemd-ask-password-console.path"
|
||||||
|
add_systemd_unit "systemd-ask-password-console.service"
|
||||||
|
|
||||||
|
# cryptsetup calls pthread_create(), which dlopen()s libgcc_s.so.1
|
||||||
|
add_binary "/usr/lib/libgcc_s.so.1"
|
||||||
|
|
||||||
|
# add mkswap for creating swap space on the fly (see 'swap' in crypttab(5))
|
||||||
|
add_binary "mkswap"
|
||||||
|
|
||||||
|
[[ -f /etc/crypttab.initramfs ]] && add_file "/etc/crypttab.initramfs" "/etc/crypttab"
|
||||||
|
|
||||||
|
validate
|
||||||
|
add_file "/etc/fido2luks.conf" "/etc/fido2luks.conf"
|
||||||
|
add_binary "fido2luks"
|
||||||
|
add_runscipt
|
||||||
|
}
|
||||||
|
|
||||||
|
run_hook() {
|
||||||
|
modprobe -a -q dm-crypt
|
||||||
|
. /etc/fido2luks.conf
|
||||||
|
if [ -z "$FIDO2LUKS_PASSWORD_HELPER" ]; then
|
||||||
|
export FIDO2LUKS_PASSWORD_HELPER="systemd-ask-password 'FIDO2 password salt for $FIDO2LUKS_DEVICE'"
|
||||||
|
fi
|
||||||
|
fido2luks open
|
||||||
|
}
|
||||||
|
|
||||||
|
help() {
|
||||||
|
cat <<HELPEOF
|
||||||
|
This hook allows for an encrypted root device with systemd initramfs.
|
||||||
|
|
||||||
|
See the manpage of systemd-cryptsetup-generator(8) for available kernel
|
||||||
|
command line options. Alternatively, if the file /etc/crypttab.initramfs
|
||||||
|
exists, it will be added to the initramfs as /etc/crypttab. See the
|
||||||
|
crypttab(5) manpage for more information on crypttab syntax.
|
||||||
|
HELPEOF
|
||||||
|
}
|
||||||
|
|
||||||
|
# vim: set ft=sh ts=4 sw=4 et:
|
14
initcpio/keyscript.sh
Executable file
14
initcpio/keyscript.sh
Executable file
@@ -0,0 +1,14 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
set -a
|
||||||
|
. /etc/fido2luks.conf
|
||||||
|
|
||||||
|
if [ -z "$FIDO2LUKS_PASSWORD_HELPER" ]; then
|
||||||
|
MSG="FIDO2 password salt for $CRYPTTAB_NAME"
|
||||||
|
export FIDO2LUKS_PASSWORD_HELPER="systemd-ask-password '$MSG'"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$FIDO2LUKS_USE_TOKEN" -eq 1 ]; then
|
||||||
|
export FIDO2LUKS_CREDENTIAL_ID="$FIDO2LUKS_CREDENTIAL_ID,$(fido2luks token list --csv $CRYPTTAB_SOURCE)"
|
||||||
|
fi
|
||||||
|
|
||||||
|
fido2luks print-secret --bin
|
@@ -177,10 +177,10 @@ pub fn run_cli() -> Fido2LuksResult<()> {
|
|||||||
)),
|
)),
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
let secret = |q: &str, verify: bool| -> Fido2LuksResult<([u8; 32], FidoCredential)> {
|
let secret = |verify: bool| -> Fido2LuksResult<([u8; 32], FidoCredential)> {
|
||||||
derive_secret(
|
derive_secret(
|
||||||
&credentials.ids.0,
|
&credentials.ids.0,
|
||||||
&salt(q, verify)?,
|
&salt("Password", verify)?,
|
||||||
authenticator.await_time,
|
authenticator.await_time,
|
||||||
pin.as_deref(),
|
pin.as_deref(),
|
||||||
)
|
)
|
||||||
@@ -190,7 +190,7 @@ pub fn run_cli() -> Fido2LuksResult<()> {
|
|||||||
match &args.command {
|
match &args.command {
|
||||||
Command::AddKey { exclusive, .. } => {
|
Command::AddKey { exclusive, .. } => {
|
||||||
let (existing_secret, _) = other_secret("Current password", false)?;
|
let (existing_secret, _) = other_secret("Current password", false)?;
|
||||||
let (new_secret, cred) = secret("Password to be added", true)?;
|
let (new_secret, cred) = secret(true)?;
|
||||||
let added_slot = luks_dev.add_key(
|
let added_slot = luks_dev.add_key(
|
||||||
&new_secret,
|
&new_secret,
|
||||||
&existing_secret[..],
|
&existing_secret[..],
|
||||||
@@ -215,7 +215,7 @@ pub fn run_cli() -> Fido2LuksResult<()> {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
Command::ReplaceKey { add_password, .. } => {
|
Command::ReplaceKey { add_password, .. } => {
|
||||||
let (existing_secret, _) = secret("Current password", false)?;
|
let (existing_secret, _) = secret(false)?;
|
||||||
let (replacement_secret, cred) = other_secret("Replacement password", true)?;
|
let (replacement_secret, cred) = other_secret("Replacement password", true)?;
|
||||||
let slot = if *add_password {
|
let slot = if *add_password {
|
||||||
luks_dev.add_key(
|
luks_dev.add_key(
|
||||||
|
Reference in New Issue
Block a user