xrdp is originally made for Linux, handling setlogin/getlogin is not enough for *BSD.
Some programs like mysql fail to get actual username.
Also, this may cause a security issue like FreeBSD-SA-02:07.k5su due to setlogin system call.
The patch is for FreeBSD but probably also helpful for other BSDs.
Note: my patch is licensed unde a BSD license because some ideas are from OpenSSH.