From 19d8101fab07d9fd1827a61bff11926a423f73c5 Mon Sep 17 00:00:00 2001 From: George Hopkins Date: Tue, 8 Feb 2022 16:04:33 +0100 Subject: [PATCH] scripts: Run QEMU as normal user To run QEMU as normal user, we store the files in the appropriate user directory (if available). Signed-off-by: George Hopkins --- scripts/qemu-guest | 21 ++++----------------- 1 file changed, 4 insertions(+), 17 deletions(-) diff --git a/scripts/qemu-guest b/scripts/qemu-guest index 47336338..14cbfd45 100755 --- a/scripts/qemu-guest +++ b/scripts/qemu-guest @@ -339,28 +339,15 @@ _ideid_2_unit() printf '%d' "$UNIT" } -## -## ARE WE ROOT? -## -if [ $( id -u ) != 0 ]; then - if [ -x $( which sudo ) ]; then - echo "Trying to get root privileges..." 1>&2 - exec sudo "$0" "$@" - exit 2 - fi - - echo "Please run as root" 1>&2 - exit 1 -fi - ## ## MAIN ## QEMU_BASE_ARGS=() QEMU_ARGS=() -SOCK_MONITOR="/run/$( basename "$0" )-$$_monitor.socket" -SOCK_SERIAL="/run/$( basename "$0" )-$$_serial.socket" -PIDFILE="/run/$( basename "$0" )-$$_qemu.pid" +RUNTIME_DIR="${XDG_RUNTIME_DIR:-/run}" +SOCK_MONITOR="$RUNTIME_DIR/$( basename "$0" )-$$_monitor.socket" +SOCK_SERIAL="$RUNTIME_DIR/$( basename "$0" )-$$_serial.socket" +PIDFILE="$RUNTIME_DIR/$( basename "$0" )-$$_qemu.pid" TEMP="/tmp/$( basename "$0" )-$$" ARG_MACHINETYPE="x86pc"