title: How to avoid using sudo for certain programs under xrdp in Raspbian?
body: <p>Background: I look after the Raspberry Pi version of Scratch for the Foundation. Mostly this is a matter of Smalltalk programming, VM developing and some very frustrating moments with shell scripts.</p>
  
  <p>Right now I'm baffled and annoyed by what seems likely to be a unix permissions or related issue when using xrdp to connect to a Pi from any other machine. I know that it's not a problem directly with theSqueak VM since google has revealed quite a few other applications having similar looking issues. Part of my problem is that I don't know enough about this area to really know what to search for to narrow things down.</p>
  
  <p>So, problem description - 
  The current Scratch system runs on the Squeak Cog VM (see <a href="https://github.com/OpenSmalltalk/opensmalltalk-vm" rel="nofollow">https://github.com/OpenSmalltalk/opensmalltalk-vm</a>), which amongst other things uses pthreads and needs to set the thread priority. That used to be something that required modifying some config but more recent (Raspbian) kernels have no problem with it.</p>
  
  <p><em>Except</em> when using xrdp, which is a pain because I mostly work with my Pi via xrdp to my iMac. To handle this I have to prepend a 'sudo -E' which is tolerable for a developer but not really good for general users. 
  I have a similar problem with a trivial file copying command used in the VM make process as well, and that doesn't use any thread stuff nor priority work, but does require me to <code>sudo make</code> in a terminal window.</p>
  
  <p>As an experiment I tried using tightvnc, to see if anything might work better. After reading the full install instructions (<a href="https://www.raspberrypi.org/documentation/remote-access/vnc/" rel="nofollow">https://www.raspberrypi.org/documentation/remote-access/vnc/</a>) and adding the auto-startup init.d script etc, it seemed like maybe we were in luck because the sudo isn't needed! Hooray! Of course, I was a bit disappointed by the seemingly slower display handling, but never mind.</p>
  
  <p>Sadly this isn't even close to the end of the story. I've recently been working on completing the support for the X composition input window system that allows Japanese and other non-Latin1 type language users to enter characters more easily. It's pretty clever, once you've installed iBus, Anthy, many fonts and done some setup. But, while it works perfectly well on a Pi with a direct display, and fine on an xrdp display (with the sudo to allow Scratch to run in the first place, of course) it simply won't work via vnc with or without a sudo.</p>
  
  <p>Googling shows a large number of other applications having problems in odd ways with the relevant XCreateIC() call (see <a href="https://github.com/OpenSmalltalk/opensmalltalk-vm/blob/Cog/platforms/unix/vm-display-X11/sqUnixX11.c" rel="nofollow">https://github.com/OpenSmalltalk/opensmalltalk-vm/blob/Cog/platforms/unix/vm-display-X11/sqUnixX11.c</a> line:1659 for our usage) but nothing I can make much connection to vnc for. To add to the annoyance the combo window appears ok for Terminals!</p>
  
  <p>To summarise-
  direct display - no problems for either the pthread priority or the compo window
  xrdp - needs sudo for pthreads priority but the compo window works ok
  vnc - doesn't need sudo for pthread priority but compo window doesn't work.</p>
  
  <p>What I need: help with finding out what causes these problems and maybe even solutions. A way to configure xrdp to not require 'sudo' would be nice. </p>