Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions docs/book/src/usage/start.rst
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,8 @@ If you used poetry to install dependencies, you should launch cape with the foll

$ sudo -u cape poetry run python3 cuckoo.py

If you get any dependency-related error, make sure you execute the **extra/libvirt_installer.sh** script::
If you get any dependency-related error, make sure the cape service is using the python environment configured by the installer.

$ sudo -u cape poetry run extra/libvirt_installer.sh

Troubleshooting
===============
Expand Down
9 changes: 7 additions & 2 deletions installer/cape2.sh
Original file line number Diff line number Diff line change
Expand Up @@ -891,6 +891,7 @@ function install_libvirt() {
cd "libvirt-python-${LIB_VERSION}"
sudo chown -R ${USER}:${USER} "/tmp/libvirt-python-${LIB_VERSION}"
'
sudo apt-get install -y locate && sudo updatedb # used by install_libvirt
temp_libvirt_so_path=$(locate libvirt-qemu.so | head -n1 | awk '{print $1;}')
temp_export_path=$(locate libvirt.pc | head -n1 | awk '{print $1;}')
libvirt_so_path="${temp_libvirt_so_path%/*}/"
Expand All @@ -903,12 +904,14 @@ function install_libvirt() {
export PKG_CONFIG_PATH=$export_path

# Run build and install within the project environment
# We use sudo -u cape ... to install into the user's environment managed by poetry/uv
# We use sudo -u cape ... to install into the user's environment managed by poetry/uv/pip
if [ "$USE_UV" = "true" ] || [ "$USE_UV" = "True" ]; then
# sudo -u ${USER} bash -c "export PKG_CONFIG_PATH=$export_path; cd $CAPE_ROOT && $PYTHON_MGR pip install /tmp/libvirt-python-${LIB_VERSION}"
sudo -u ${USER} bash -c "export PKG_CONFIG_PATH=$export_path; cd $CAPE_ROOT && $PYTHON_MGR pip install libvirt-python==${LIB_VERSION}"
else
elif [ "$PYTHON_MGR" = "/etc/poetry/bin/poetry" ]; then
sudo -u ${USER} bash -c "export PKG_CONFIG_PATH=$export_path; $PYTHON_MGR --directory $CAPE_ROOT $PYTHON_MGR_CMD pip install libvirt-python==${LIB_VERSION}"
else
sudo -u ${USER} bash -c "export PKG_CONFIG_PATH=$export_path; pip3 install libvirt-python==${LIB_VERSION}"
fi
}

Expand Down Expand Up @@ -1888,6 +1891,8 @@ case "$COMMAND" in
install_IntroVirt;;
'passivedns')
install_passivedns;;
'libvirt')
install_libvirt;;
*)
usage;;
esac
Expand Down
2 changes: 1 addition & 1 deletion lib/cuckoo/common/abstracts.py
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@ class LibVirtMachinery(Machinery):
def __init__(self):
if not HAVE_LIBVIRT:
raise CuckooDependencyError(
"Unable to import libvirt. Ensure that you properly installed it by running: cd /opt/CAPEv2/ ; sudo -u cape poetry run extra/libvirt_installer.sh"
"Unable to import libvirt. Ensure cape is being run from the same python environment configured by the installer script."
)

super().__init__()
Expand Down
4 changes: 2 additions & 2 deletions lib/cuckoo/core/startup.py
Original file line number Diff line number Diff line change
Expand Up @@ -332,8 +332,8 @@ def check_snapshot_state():
from xml.etree import ElementTree
except ImportError:
raise CuckooStartupError(
"The 'libvirt-python' library is required for KVM/QEMU machinery but is not installed. "
"Please install it (e.g., 'cd /opt/CAPEv2/ ; sudo -u cape /etc/poetry/bin/poetry run extra/libvirt_installer.sh')."
"The 'libvirt-python' library is required for KVM/QEMU machinery but could not be imported. "
"Please ensure that CAPE is being launched by the same Python environment configured by the install script."
)

machinery_config = Config(cuckoo.cuckoo.machinery)
Expand Down
2 changes: 1 addition & 1 deletion web/guac/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

LIBVIRT_AVAILABLE = True
except ImportError:
print("Missed python-libvirt. Use extra/libvirt_installer.sh")
print("Unable to import python-libvirt. Check that the CAPE python environment has it installed.")
LIBVIRT_AVAILABLE = False

machinery = Config().cuckoo.machinery
Expand Down