diff --git a/src/tests/dbus-tests/test_70_encrypted.py b/src/tests/dbus-tests/test_70_encrypted.py index b986054c6..d1197c6f3 100644 --- a/src/tests/dbus-tests/test_70_encrypted.py +++ b/src/tests/dbus-tests/test_70_encrypted.py @@ -786,5 +786,21 @@ def test_open_close(self): objects = udisks.GetManagedObjects(dbus_interface='org.freedesktop.DBus.ObjectManager') self.assertNotIn(str(crypt_path), objects.keys()) + # unlock with keyfile contents + d = dbus.Dictionary(signature='sv') + d['keyfile_contents'] = self.str_to_ay(self.passphrase, False) + crypt_path = self.loop.Unlock("", d, + dbus_interface=self.iface_prefix + '.Encrypted') + self.assertIsNotNone(crypt_path) + crypt_dev = self.bus.get_object(self.iface_prefix, crypt_path) + self.assertIsNotNone(crypt_dev) + + dbus_cleartext = self.get_property(self.loop, '.Encrypted', 'CleartextDevice') + dbus_cleartext.assertEqual(str(crypt_path)) + dbus_type = self.get_property(self.loop, '.Encrypted', 'HintEncryptionType') + dbus_type.assertEqual("BITLK") + + self.loop.Lock(self.no_options, dbus_interface=self.iface_prefix + '.Encrypted') + del UdisksEncryptedTest # skip UdisksEncryptedTest diff --git a/src/udiskslinuxencrypted.c b/src/udiskslinuxencrypted.c index 9bcbd2f04..d62f3e566 100644 --- a/src/udiskslinuxencrypted.c +++ b/src/udiskslinuxencrypted.c @@ -465,8 +465,8 @@ handle_unlock (UDisksEncrypted *encrypted, goto out; } - /* fallback mechanism: keyfile_contents (for LUKS) -> passphrase -> crypttab_passphrase -> TCRYPT keyfiles -> error (no key) */ - if (is_luks && udisks_variant_lookup_binary (options, "keyfile_contents", &effective_passphrase)) + /* fallback mechanism: keyfile_contents (for LUKS and BITLK) -> passphrase -> crypttab_passphrase -> TCRYPT keyfiles -> error (no key) */ + if ((is_luks || is_bitlk) && udisks_variant_lookup_binary (options, "keyfile_contents", &effective_passphrase)) { /* effective_passphrase was set to keyfile_contents, nothing more to do here */ }