Subject: Bug#876: Problem with numeric user id

From: brian <[email-masked]>
Date: Sat, 16 May 2015 14:05:11 -0500

Package: x2goserver
Version:  4.01.19

Server Fedora 21 x2goserver-4.0.1.19-1.fc21.x86_64
Client Fedora 20 x2goclient-4.0.3.1-1.fc20.x86_64

I had this working fine, and then one day the client would hang in a 
greyed out manner waiting to connect.  Several hours of tracing through 
the scripts, I learned the server x2gostartagent script was simply 
infinite looping through sessions and 
/usr/lib64/x2go/x2gosqlitewrapper.pl insertsession was rejecting them all.

I suspected the problem may be when I changed my user id on the server 
from alpha-numeric to all numeric...  Yes I know traditional UNIX/Linux 
user ids are supposed to start with at least 1 alpha character, but 
working for a large corp where MS Active Directory runs everything, they 
have successfully standardized all Windows and Linux user accounts to 6 
digit numerics.  You don't have to convince me this was a BAD idea, but 
way above my pay grade.  So when I changed my server to match (and yes 
Fedora will accept a numeric user id even without AD authentication, but 
it will warn against it), the failure started.  One more test I ran a 
connect as 'root' and it connected right away, so I knew where the 
problem was.

Digging through x2gosqlitewrapper.pl I noticed a lot of perl regex and 
found the sanitizer function, line 67.  When I replaced it with
  if ($string =~ /^([a-zA-Z0-9\_] ....  <adding the 0-9 to the match> 
everything started working again.

Diff file attached.
67c67
<                       if ($string =~ /^([a-zA-Z\_][a-zA-Z0-9\_\-\.\@]{0,47}[\$]?)\-([\d]{2,4})\-([\d]{9,12})\_[a-zA-Z0-9\_\-\.]*\_dp[\d]{1,2}$/) {
---
>                       if ($string =~ /^([a-zA-Z0-9\_][a-zA-Z0-9\_\-\.\@]{0,47}[\$]?)\-([\d]{2,4})\-([\d]{9,12})\_[a-zA-Z0-9\_\-\.]*\_dp[\d]{1,2}$/) {