rule vm_attach
}
rule_vm_attach () {
+ assert '! pgrep -f "sudo xm console $vm_fqdn"'
cat <<-EOF
NOTE: Ctrl-] pour se détacher de la console
EOF
}
rule_part_randomize () { # SYNTAX: $part # NOTE: à anticiper
- local part=$1
+ local part="$1"
eval "sudo dd if=/dev/urandom of=\$vm_dev_disk_$part"
}
rule_part_randomize_stat () { # SYNTAX: $part # DESCRIPTION: fait afficher la progression de rule_part_randomize
- local part=$1
+ local part="$1"
eval "pkill -USR1 -f \"^dd if=/dev/urandom of=\$vm_dev_disk_$part\""
}
rule__part_encrypted_format () { # SYNTAX: $part # DESCRIPTION: formatage d'une partition distincte de /
# NOTE: la clef de chiffrement est dérivée de celle de /,
# / doit être déchiffrée pour que cela fonctionne.
- local part=$1
- eval "local dev=\$vm_dev_disk_$part"
+ local part="$1"
+ eval "local dev=\"\$vm_dev_disk_$part\""
test ! -e /dev/mapper/${vm_lvm_lv}_root_deciphered ||
sudo /bin/sh -c "/lib/cryptsetup/scripts/decrypt_derived ${vm_lvm_lv}_root_deciphered |
cryptsetup luksFormat --hash=sha512 --key-size=512 \
--cipher=aes-xts-essiv:sha256 --key-file=- --align-payload=8 $dev"
}
rule__part_encrypted_mount () { # SYNTAX: $part
- local part=$1
- eval "local dev=\$vm_dev_disk_$part"
+ local part="$1"
+ eval "local dev=\"\$vm_dev_disk_$part\""
test -e /dev/mapper/${vm_lvm_lv}_${part}_deciphered ||
sudo /bin/sh -c "/lib/cryptsetup/scripts/decrypt_derived ${vm_lvm_lv}_root_deciphered |
cryptsetup luksOpen --key-file=- $dev ${vm_lvm_lv}_${part}_deciphered"
}
rule__part_encrypted_umount () { # SYNTAX: $part
- local part=$1
- eval "local dev=\$vm_dev_disk_$part"
+ local part="$1"
+ eval "local dev=\"\$vm_dev_disk_$part\""
test ! -e /dev/mapper/${vm_lvm_lv}_${part}_deciphered ||
sudo cryptsetup luksClose ${vm_lvm_lv}_${part}_deciphered
}