#endif
}
+static int log_external_activation(int r, const char *volume) {
+ assert(volume);
+
+ log_notice_errno(r, "Volume '%s' has been activated externally while we have been trying to activate it.", volume);
+ return 0;
+}
+
static int measured_crypt_activate_by_volume_key(
struct crypt_device *cd,
const char *name,
/* A wrapper around crypt_activate_by_volume_key() which also measures to a PCR if that's requested. */
r = crypt_activate_by_volume_key(cd, name, volume_key, volume_key_size, flags);
+ if (r == -EEXIST) /* volume is already active */
+ return log_external_activation(r, name);
if (r < 0)
return r;
return measured_crypt_activate_by_volume_key(cd, name, vk, vks, flags);
shortcut:
- return crypt_activate_by_passphrase(cd, name, keyslot, passphrase, passphrase_size, flags);
+ r = crypt_activate_by_passphrase(cd, name, keyslot, passphrase, passphrase_size, flags);
+ if (r == -EEXIST) /* volume is already active */
+ return log_external_activation(r, name);
+ return r;
}
static int attach_tcrypt(
r = crypt_activate_by_token_pin(cd, name, type, CRYPT_ANY_TOKEN, /* pin=*/ NULL, /* pin_size= */ 0, userdata, activation_flags);
if (r > 0) /* returns unlocked keyslot id on success */
return 0;
+ if (r == -EEXIST) /* volume is already active */
+ return log_external_activation(r, name);
if (r != -ENOANO) /* needs pin or pin is wrong */
return r;
r = crypt_activate_by_token_pin(cd, name, type, CRYPT_ANY_TOKEN, *p, strlen(*p), userdata, activation_flags);
if (r > 0) /* returns unlocked keyslot id on success */
return 0;
+ if (r == -EEXIST) /* volume is already active */
+ return log_external_activation(r, name);
if (r != -ENOANO) /* needs pin or pin is wrong */
return r;
}
r = crypt_activate_by_token_pin(cd, name, type, CRYPT_ANY_TOKEN, *p, strlen(*p), userdata, activation_flags);
if (r > 0) /* returns unlocked keyslot id on success */
return 0;
+ if (r == -EEXIST) /* volume is already active */
+ return log_external_activation(r, name);
if (r != -ENOANO) /* needs pin or pin is wrong */
return r;
}
r = crypt_activate_by_token_pin(cd, name, "systemd-pkcs11", CRYPT_ANY_TOKEN, NULL, 0, ¶ms, flags);
if (r > 0) /* returns unlocked keyslot id on success */
r = 0;
+ if (r == -EEXIST) /* volume is already active */
+ r = log_external_activation(r, name);
return r;
#else
"luks2-pin",
"cryptsetup.luks2-pin");
if (r >= 0) {
- log_debug("Volume %s activated with LUKS token id %i.", volume, r);
+ log_debug("Volume %s activated with a LUKS token.", volume);
return 0;
}