#!/bin/sh

## Copyright (C) 2012 - 2025 ENCRYPTED SUPPORT LLC <adrelanos@whonix.org>
## See the file COPYING for copying conditions.

if [ "$(id -un)" = 'sysmaint' ] \
   && ! printf '%s\n' 'sysmaint-session' | grep -- '^sysmaint-session' >/dev/null 2>/dev/null \
   && [ ! -f '/usr/share/qubes/marker-vm' ]; then
   TERMINAL_WRAPPER_NO_COMMAND_ECHO='true'
   export TERMINAL_WRAPPER_NO_COMMAND_ECHO
   TERMINAL_WRAPPER_NO_FINISH_MSG='true'
   export TERMINAL_WRAPPER_NO_FINISH_MSG
   xfwm4 &
   sleep 1
   /usr/libexec/helper-scripts/terminal-wrapper 'echo' '-e' \
      'You are attempting to log into the sysmaint user without using' \
      '\nthe sysmaint graphical session. This is potentially dangerous and' \
      '\nhas been disabled for safety.'
   exit 1
fi
