Shorten path for XDG_CONFIG_HOME and clean dir

In Linux socket paths are limited to 108 char length.
/var/tmp/vm/$UID/.config will be too long in some cases.
So we use /var/tmp/vm/$UID

/var/tmp/vm must be
- cleaned on startup
- created with sticky-bit (used by different users)
This commit is contained in:
Raphael Dannecker 2025-02-18 14:16:56 +01:00
parent bde276d962
commit 97b9ba8d97
4 changed files with 5 additions and 5 deletions

View file

@ -13,12 +13,12 @@ slp=false
shutdownVMs(){ shutdownVMs(){
local VM local VM
for VM in $(sudo -u $usr XDG_RUNTIME_DIR="/run/user/$uid" \ for VM in $(sudo -u $usr XDG_RUNTIME_DIR="/run/user/$uid" \
XDG_CONFIG_HOME="/var/tmp/vm/$uid/.config" \ XDG_CONFIG_HOME="/var/tmp/vm/$uid" \
XDG_CACHE_HOME="/var/cache/user/$uid/" \ XDG_CACHE_HOME="/var/cache/user/$uid/" \
virsh list --state-running | \ virsh list --state-running | \
sed -nE "s/.*\s+(\S+)\s+running/\1/p") ; do sed -nE "s/.*\s+(\S+)\s+running/\1/p") ; do
sudo -u $usr XDG_RUNTIME_DIR="/run/user/$uid" \ sudo -u $usr XDG_RUNTIME_DIR="/run/user/$uid" \
XDG_CONFIG_HOME="/var/tmp/vm/$uid/.config" \ XDG_CONFIG_HOME="/var/tmp/vm/$uid" \
XDG_CACHE_HOME="/var/cache/user/$uid/" \ XDG_CACHE_HOME="/var/cache/user/$uid/" \
virsh destroy "$VM" 2>&1 | systemd-cat || true virsh destroy "$VM" 2>&1 | systemd-cat || true
slp=true slp=true

View file

@ -5,7 +5,7 @@
set -eu set -eu
## Imporant for all virsh libvirt calls: ## Imporant for all virsh libvirt calls:
export XDG_CONFIG_HOME="/var/tmp/vm/${UID}/.config" export XDG_CONFIG_HOME="/var/tmp/vm/${UID}"
menu=(standard "CLI Standard Debian GNU/Linux NFS" menu=(standard "CLI Standard Debian GNU/Linux NFS"
standard-ram "CLI Standard Debian GNU/Linux RAM" standard-ram "CLI Standard Debian GNU/Linux RAM"

View file

@ -295,7 +295,7 @@ if [[ "${PERSISTENT}" == 1 ]] && [[ ! -f "${VM_DIR_PERSISTENT}/${VM_NAME}.qcow2"
fi fi
# because virsh has problems with long pathnames, using diffent configdir # because virsh has problems with long pathnames, using diffent configdir
export XDG_CONFIG_HOME="/var/tmp/vm/${UID}/.config" export XDG_CONFIG_HOME="/var/tmp/vm/${UID}"
if ! virsh --connect="${QEMU}" list | grep "${VM_NAME}-clone"; then if ! virsh --connect="${QEMU}" list | grep "${VM_NAME}-clone"; then
echo "VM not yet running." echo "VM not yet running."

View file

@ -144,7 +144,7 @@
ansible.builtin.copy: ansible.builtin.copy:
dest: /etc/tmpfiles.d/clean-vm.conf dest: /etc/tmpfiles.d/clean-vm.conf
content: | content: |
R! /var/tmp/vm D /var/tmp/vm 1777 root root -
- name: Install squid - name: Install squid
apt: apt: