aboutsummaryrefslogtreecommitdiff
path: root/freerdp2-session.in
blob: 571330f528c59b7dfdd98b71c5fd71611a463c98 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#!/bin/bash

#
# Copyright © 2018 Mike Gabriel <mike.gabriel@das-netzwerkteam.de>
# Copyright © 2012 Canonical Ltd.
#
# This program is free software: you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 3, as
# published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranties of
# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
# PURPOSE.  See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program.  If not, see <http://www.gnu.org/licenses/>.
#
# Author: Mike Gabriel <mike.gabriel@das-netzwerkteam.de>
# Author lightdm-remote-session-freerdp (where we forked from): Ted Gould <ted@canonical.com>
#

NULL=
FREERDP2_OPTIONS=""

if [ -f /etc/default/lightdm-remote-session-freerdp2 ]; then
	. /etc/default/lightdm-remote-session-freerdp2
fi

socket="$HOME/.freerdp2-socket";
if [ -e "$socket" ]; then
	AUTH_INFO="$(socat unix-connect:"$socket" -)"
	AUTH_INFO_USER=$(echo "$AUTH_INFO" | awk '{ print $1 }')
	AUTH_INFO_PASSWORD=$(echo "$AUTH_INFO" | awk '{ print $2 }')
	AUTH_INFO_DOMAIN=$(echo "$AUTH_INFO" | awk '{ print $3 }')
	AUTH_INFO_HOST=$(echo "$AUTH_INFO" | awk '{ print $4 }')

	# FIXME: it seems, pulseaudio is not started at this point for the guest user
	# However, launching it here with pulseaudio -D feels wrong in the age of systemd

	# give the RDP server a little bit of time to recover from libpam-freerdp2's freerdp2-auth-check test connect.
	sleep 1

	FREERDP2_OPTIONS="/f				\
	                  /v:"${AUTH_INFO_HOST}"	\
	                  /u:"${AUTH_INFO_USER}"	\
	                  /d:"${AUTH_INFO_DOMAIN}"	\
	                  /from-stdin			\
	                  -toggle-fullscreen		\
	                  ${FREERDP2_OPTIONS}		\
	                  ${NULL}"

	logger -t $(basname $0) "xfreerdp called with options: ${FREERDP_OPTIONS}."


	# FIXME: get audio working... add /sound:sys:pulse to xfreerdp cmdline args...
	echo "$AUTH_INFO_PASSWORD" | /usr/bin/xfreerdp ${FREERDP_OPTIONS} 2>&1 \
	                           | logger -t lightdm-remote-session-freerdp2 -- \
	${NULL} &

	unset AUTH_INFO_PASSWORD

	# wait for another second to give the xfreerdp process to settle in process list
	sleep 1

	USERID=$(id -u)
	wait $(pgrep -u ${USERID} xfreerdp)

	# FIXME: possibly stop pulseaudio here with -k again (we have seen permissioned denied warnings, when doing this. Better approaches?)

else
	zenity --warning --text="Unable to locate FreeRDP socket"
fi;

rm -f "$socket"