mirror of
https://github.com/retspen/webvirtcloud
synced 2026-12-03 09:26:03 +00:00
fix(virtsecrets): a secret in use is not deleted by its UUID in capitals
libvirt finds a secret by its UUID in capitals too, but its users were looked up by the UUID as posted: a secret a VM's disk or a pool named was deleted, and that VM or pool no longer started. They are now looked up by the secret's own UUID. A usage with a control character made the page fail (lxml refuses it in XML text) and libvirt dropped a line break silently; the form refuses both. An empty value set later showed libvirt's "value in virSecretSetValue must not be NULL"; it is refused in words.
This commit is contained in:
parent
159049736d
commit
b7724928fd
8 changed files with 104 additions and 49 deletions
|
|
@ -6,12 +6,21 @@ class AddSecret(forms.Form):
|
|||
usage_type = forms.ChoiceField(
|
||||
choices=(("ceph", "Ceph"), ("iscsi", "iSCSI"), ("volume", _("Volume")), ("tls", "TLS"), ("vtpm", "vTPM")),
|
||||
)
|
||||
usage = forms.CharField()
|
||||
usage = forms.CharField(strip=False) # stripped once checked: a line break at its end too
|
||||
# a password keeps its spaces; none defines the secret without a value
|
||||
value = forms.CharField(required=False, strip=False)
|
||||
ephemeral = forms.BooleanField(required=False)
|
||||
private = forms.BooleanField(required=False)
|
||||
|
||||
def clean_usage(self):
|
||||
usage = self.cleaned_data["usage"]
|
||||
# XML text cannot hold them, and libvirt drops a line break
|
||||
if any(ord(char) < 32 for char in usage):
|
||||
raise forms.ValidationError(_("The usage cannot have control characters or line breaks"))
|
||||
if not usage.strip():
|
||||
raise forms.ValidationError(self.fields["usage"].error_messages["required"], code="required")
|
||||
return usage.strip()
|
||||
|
||||
|
||||
# what a secret's usage and value are, per usage type, for the page's labels
|
||||
USAGE_TEXTS = {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue