nixops: Fix build by disabling the libvirt backend if package marked as insecure

With this change it's possible to override the libvirt package used if you absolutely need it.
This commit is contained in:
adisbladis 2021-02-08 16:00:53 +01:00
parent 94f2ba2ef3
commit 418af7d7aa
No known key found for this signature in database
GPG Key ID: 110BFAD44C6249B7
3 changed files with 31 additions and 2 deletions

View File

@ -18,6 +18,10 @@ buildPythonPackage rec {
nosetests nosetests
''; '';
passthru = {
inherit libvirt;
};
meta = with lib; { meta = with lib; {
homepage = "http://www.libvirt.org/"; homepage = "http://www.libvirt.org/";
description = "libvirt Python bindings"; description = "libvirt Python bindings";

View File

@ -22,9 +22,10 @@ python2Packages.buildPythonApplication {
pysqlite pysqlite
datadog datadog
digital-ocean digital-ocean
libvirt
typing typing
] ++ nixopsAzurePackages; ]
++ lib.optional (!libvirt.passthru.libvirt.meta.insecure or true) libvirt
++ nixopsAzurePackages;
checkPhase = checkPhase =
# Ensure, that there are no (python) import errors # Ensure, that there are no (python) import errors

View File

@ -0,0 +1,24 @@
diff --git a/nixops/backends/libvirtd.py b/nixops/backends/libvirtd.py
index bc5f4af7..edd1348b 100644
--- a/nixops/backends/libvirtd.py
+++ b/nixops/backends/libvirtd.py
@@ -8,12 +8,18 @@ import shutil
import string
import subprocess
import time
-import libvirt
from nixops.backends import MachineDefinition, MachineState
import nixops.known_hosts
import nixops.util
+try:
+ import libvirt
+except:
+ class libvirt(object):
+ def __getattribute__(self, name):
+ raise ValueError("The libvirt backend has been disabled because of security issues.")
+
# to prevent libvirt errors from appearing on screen, see
# https://www.redhat.com/archives/libvirt-users/2017-August/msg00011.html