From 622e6be85a9585c78ba0ded979e8e3079e5b82e5 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 52f32eaf..05d327b7 100755 --- a/scripts/qemu-guest +++ b/scripts/qemu-guest @@ -353,29 +353,16 @@ _netdev_hwaddr() $(( $HWADDR % 256 )) } -## -## 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=() QEMU_PID= -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"