Ubuntu – Connect to X Windows with username with spaces

active-directoryrdpsambaUbuntux11

I have an Ubuntu server 16.04.01 LTS, which I want to use as desktop for remote users connecting from thin clients and via RDP from Windows machines.

For Ubuntu-local users, this works, I can connect both from the thin client (HP t520) as well as from Windows machine via mstsc.

However, the main idea is to connect Active directory users from thin clients, replacing the Windows server terminal services infrastructure.

And the existing AD structure uses spaces in username field: firstname lastname format.

I installed the relevant winbind and samba services, and this works on ssh logins.

I can connect with AD username, the home directory is created upon first login under /home/DOMAIN/firstname lastname/ and I can use everything OK from ssh connection.

However, on connecting via mstsc RDP/thin client to access GUI, I have the problem of xhost and other services stumbling on the spaces in usernames:

xhost:  bad hostname "lastname"
X Error of failed request:  BadValue (integer parameter out of range for operation)
  Major opcode of failed request:  109 (X_ChangeHosts)
  Value in failed request:  0x5
  Serial number of failed request:  6
  Current serial number in output stream:  8
localuser:firstname being added to access control list
xhost:  bad hostname "lastname"
X Error of failed request:  BadValue (integer parameter out of range for operation)
  Major opcode of failed request:  109 (X_ChangeHosts)
  Value in failed request:  0x5
  Serial number of failed request:  6
  Current serial number in output stream:  8
openConnection: connect: No such file or directory
cannot connect to brltty at :0
/etc/xrdp/startwm.sh: 3: [: x: unexpected operator
/bin/bash: /home/DOMAIN/firstname: No such file or directory

Any way of changing how xhost quotes usernames, or any other way I can make this work?

(I tried using \ when specifying username, when connecting: firstname\ lastname, but this doesn't help)

Best Answer

Try "\040" with no commas instead of a space.