Skip to content

Commit

Permalink
[RTT-5714] Add temporary hack to get a virtual monitor in RDP mode
Browse files Browse the repository at this point in the history
The hack consists of running a local RDP connection via xfreerdp,
which results in creating a virtual monitor with a defined resolution.
Anabot is not able to work properly without it in RDP mode, as
dogtail tracebacks due to some reportedly negative widget coordinates
or dimensions.

It is supposed to be only a temporary workaround and should be removed
when there's a proper solution (when RHEL-64694 is fixed).
  • Loading branch information
jikortus committed Nov 8, 2024
1 parent ca02d44 commit f2246ed
Show file tree
Hide file tree
Showing 89 changed files with 858 additions and 0 deletions.
3 changes: 3 additions & 0 deletions anabot-prepare.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,6 @@ Categories=System;
Exec=anaconda
NoDisplay=true
EOF


cp -r /opt/xfreerdp-hack/$(uname -m)/* /
1 change: 1 addition & 0 deletions etc/systemd/system/anabot.service.wants/xfreerdp.service
14 changes: 14 additions & 0 deletions etc/systemd/system/xfreerdp.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[Unit]
Description=xfreerdp-dummy
After=anaconda.service
After=anabot-prepare.service
Before=anabot.service
Before=anabot-direct.service

[Service]
ExecStart=/opt/xfreerdp.sh
Environment=HOME=/root

[Install]
WantedBy=anabot.service
WantedBy=anabot-direct.service
Binary file added xfreerdp-hack/aarch64/usr/bin/Xvfb
Binary file not shown.
Binary file added xfreerdp-hack/aarch64/usr/bin/mcookie
Binary file not shown.
Binary file added xfreerdp-hack/aarch64/usr/bin/xauth
Binary file not shown.
Binary file added xfreerdp-hack/aarch64/usr/bin/xfreerdp
Binary file not shown.
Binary file added xfreerdp-hack/aarch64/usr/bin/xkbcomp
Binary file not shown.
200 changes: 200 additions & 0 deletions xfreerdp-hack/aarch64/usr/bin/xvfb-run
Original file line number Diff line number Diff line change
@@ -0,0 +1,200 @@
#!/usr/bin/sh
# --- T2-COPYRIGHT-NOTE-BEGIN ---
# This copyright note is auto-generated by ./scripts/Create-CopyPatch.
#
# T2 SDE: package/.../xorg-server/xvfb-run.sh
# Copyright (C) 2005 The T2 SDE Project
# Copyright (C) XXXX - 2005 Debian
#
# More information can be found in the files COPYING and README.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; version 2 of the License. A copy of the
# GNU General Public License can be found in the file COPYING.
# --- T2-COPYRIGHT-NOTE-END ---

# $Id$
# from: http://necrotic.deadbeast.net/xsf/XFree86/trunk/debian/local/xvfb-run

# This script starts an instance of Xvfb, the "fake" X server, runs a command
# with that server available, and kills the X server when done. The return
# value of the command becomes the return value of this script.
#
# If anyone is using this to build a Debian package, make sure the package
# Build-Depends on xvfb, xbase-clients, and xfonts-base.

set -e

PROGNAME=xvfb-run
SERVERNUM=99
AUTHFILE=
ERRORFILE=/dev/null
STARTWAIT=3
XVFBARGS="-screen 0 640x480x24"
LISTENTCP="-nolisten tcp"
XAUTHPROTO=.

# Query the terminal to establish a default number of columns to use for
# displaying messages to the user. This is used only as a fallback in the event
# the COLUMNS variable is not set. ($COLUMNS can react to SIGWINCH while the
# script is running, and this cannot, only being calculated once.)
DEFCOLUMNS=$(stty size 2>/dev/null | awk '{print $2}') || true
if ! expr "$DEFCOLUMNS" : "[[:digit:]]\+$" >/dev/null 2>&1; then
DEFCOLUMNS=80
fi

# Display a message, wrapping lines at the terminal width.
message () {
echo "$PROGNAME: $*" | fmt -t -w ${COLUMNS:-$DEFCOLUMNS}
}

# Display an error message.
error () {
message "error: $*" >&2
}

# Display a usage message.
usage () {
if [ -n "$*" ]; then
message "usage error: $*"
fi
cat <<EOF
Usage: $PROGNAME [OPTION ...] COMMAND
Run COMMAND (usually an X client) in a virtual X server environment.
Options:
-a --auto-servernum try to get a free server number, starting at
--server-num (deprecated, use --auto-display
instead)
-d --auto-display use the X server to find a display number
automatically
-e FILE --error-file=FILE file used to store xauth errors and Xvfb
output (default: $ERRORFILE)
-f FILE --auth-file=FILE file used to store auth cookie
(default: ./.Xauthority)
-h --help display this usage message and exit
-n NUM --server-num=NUM server number to use (default: $SERVERNUM)
-l --listen-tcp enable TCP port listening in the X server
-p PROTO --xauth-protocol=PROTO X authority protocol name to use
(default: xauth command's default)
-s ARGS --server-args=ARGS arguments (other than server number and
"-nolisten tcp") to pass to the Xvfb server
(default: "$XVFBARGS")
-w DELAY --wait=DELAY delay in seconds to wait for Xvfb to start
before running COMMAND (default: $STARTWAIT)
EOF
}

# Find a free server number by looking at .X*-lock files in /tmp.
find_free_servernum() {
# Sadly, the "local" keyword is not POSIX. Leave the next line commented in
# the hope Debian Policy eventually changes to allow it in /bin/sh scripts
# anyway.
#local i

i=$SERVERNUM
while [ -f /tmp/.X$i-lock ]; do
i=$(($i + 1))
done
echo $i
}

# Parse the command line.
ARGS=$(getopt --options +ade:f:hn:lp:s:w: \
--long auto-servernum,error-file:,auth-file:,help,server-num:,listen-tcp,xauth-protocol:,server-args:,wait: \
--name "$PROGNAME" -- "$@")
GETOPT_STATUS=$?

if [ $GETOPT_STATUS -ne 0 ]; then
error "internal error; getopt exited with status $GETOPT_STATUS"
exit 6
fi

eval set -- "$ARGS"

while :; do
case "$1" in
-a|--auto-servernum) SERVERNUM=$(find_free_servernum) ;;
-d|--auto-display) AUTO_DISPLAY=1 ;;
-e|--error-file) ERRORFILE="$2"; shift ;;
-f|--auth-file) AUTHFILE="$2"; shift ;;
-h|--help) SHOWHELP="yes" ;;
-n|--server-num) SERVERNUM="$2"; shift ;;
-l|--listen-tcp) LISTENTCP="-listen tcp" ;;
-p|--xauth-protocol) XAUTHPROTO="$2"; shift ;;
-s|--server-args) XVFBARGS="$2"; shift ;;
-w|--wait) STARTWAIT="$2"; shift ;;
--) shift; break ;;
*) error "internal error; getopt permitted \"$1\" unexpectedly"
exit 6
;;
esac
shift
done

if [ "$SHOWHELP" ]; then
usage
exit 0
fi

if [ -z "$*" ]; then
usage "need a command to run" >&2
exit 2
fi

if ! type xauth >/dev/null; then
error "xauth command not found"
exit 3
fi

# Set up the temp dir for the pid and X authorization file
XVFB_RUN_TMPDIR="$(mktemp --directory --tmpdir $PROGNAME.XXXXXX)"
# If the user did not specify an X authorization file to use, set up a temporary
# directory to house one.
if [ -z "$AUTHFILE" ]; then
AUTHFILE=$(mktemp -p "$XVFB_RUN_TMPDIR" Xauthority.XXXXXX)
fi

# Start Xvfb.
MCOOKIE=$(mcookie)

if [ -z "$AUTO_DISPLAY" ]; then
# Old style using a pre-computed SERVERNUM
XAUTHORITY=$AUTHFILE Xvfb ":$SERVERNUM" $XVFBARGS $LISTENTCP >>"$ERRORFILE" \
2>&1 &
XVFBPID=$!
else
# New style using Xvfb to provide a free display
PIDFILE=$(mktemp -p "$XVFB_RUN_TMPDIR" pid.XXXXXX)
SERVERNUM=$(XAUTHORITY=$AUTHFILE Xvfb -displayfd 1 $XVFBARGS $LISTENTCP \
2>"$ERRORFILE" & echo $! > $PIDFILE)
XVFBPID=$(cat $PIDFILE)
fi
sleep "$STARTWAIT"

XAUTHORITY=$AUTHFILE xauth source - << EOF >>"$ERRORFILE" 2>&1
add :$SERVERNUM $XAUTHPROTO $MCOOKIE
EOF

# Start the command and save its exit status.
set +e
DISPLAY=:$SERVERNUM XAUTHORITY=$AUTHFILE "$@" 2>&1
RETVAL=$?
set -e

# Kill Xvfb now that the command has exited.
kill $XVFBPID

# Clean up.
XAUTHORITY=$AUTHFILE xauth remove ":$SERVERNUM" >"$ERRORFILE" 2>&1
if [ -n "$XVFB_RUN_TMPDIR" ]; then
if ! rm -r "$XVFB_RUN_TMPDIR"; then
error "problem while cleaning up temporary directory"
exit 5
fi
fi

# Return the executed command's exit status.
exit $RETVAL

# vim:set ai et sts=4 sw=4 tw=80:
1 change: 1 addition & 0 deletions xfreerdp-hack/aarch64/usr/lib64/libXdmcp.so.6
Binary file not shown.
1 change: 1 addition & 0 deletions xfreerdp-hack/aarch64/usr/lib64/libXfont2.so.2
Binary file not shown.
1 change: 1 addition & 0 deletions xfreerdp-hack/aarch64/usr/lib64/libXmuu.so.1
Binary file added xfreerdp-hack/aarch64/usr/lib64/libXmuu.so.1.0.0
Binary file not shown.
1 change: 1 addition & 0 deletions xfreerdp-hack/aarch64/usr/lib64/libavahi-client.so.3
Binary file not shown.
1 change: 1 addition & 0 deletions xfreerdp-hack/aarch64/usr/lib64/libavahi-common.so.3
Binary file not shown.
1 change: 1 addition & 0 deletions xfreerdp-hack/aarch64/usr/lib64/libfontenc.so.1
Binary file not shown.
1 change: 1 addition & 0 deletions xfreerdp-hack/aarch64/usr/lib64/libunwind-aarch64.so.8
Binary file not shown.
1 change: 1 addition & 0 deletions xfreerdp-hack/aarch64/usr/lib64/libunwind.so.8
Binary file not shown.
Binary file added xfreerdp-hack/ppc64le/usr/bin/Xvfb
Binary file not shown.
Binary file added xfreerdp-hack/ppc64le/usr/bin/mcookie
Binary file not shown.
1 change: 1 addition & 0 deletions xfreerdp-hack/ppc64le/usr/bin/ppc
1 change: 1 addition & 0 deletions xfreerdp-hack/ppc64le/usr/bin/ppc32
1 change: 1 addition & 0 deletions xfreerdp-hack/ppc64le/usr/bin/ppc64
Binary file added xfreerdp-hack/ppc64le/usr/bin/xauth
Binary file not shown.
Binary file added xfreerdp-hack/ppc64le/usr/bin/xfreerdp
Binary file not shown.
Binary file added xfreerdp-hack/ppc64le/usr/bin/xkbcomp
Binary file not shown.
Loading

0 comments on commit f2246ed

Please sign in to comment.