I want to use an SDL-based program to display graphics on the console, without having to log on from the console, and without running the program as root. For example, I want to be able to run it via ssh. The target OS is raspbian.
Here is a short example in python to illustrate the problem:
import os, pygame os.environ['SDL_VIDEODRIVER'] = 'fbcon' pygame.init() s = pygame.display.set_mode() print "Success"
This works (runs to completion, does not throw exceptions) if I run it from the console, and it works via ssh if I run it as root.
I have checked that my user is in the audio and video groups.
I have used strace to see what is different between running it from the console (which works), running it as root via ssh (also works), and running it as a regular user via ssh (doesn't work).
The first difference was that my user did not have permission to access /dev/tty0. I created a new group (tty0), put my user in that group, and added a udev rule to give that group access to /dev/tty0.
The strace output diverges at this ioctl call - the failure is show here; ioctl returns 0 when the program is run from the console or run from ssh as root:
open("/dev/tty", O_RDWR) = 4 ioctl(4, VT_GETSTATE, 0xbeaa01f8) = -1 EINVAL (Invalid argument)
(The addresses also differ, but that isn't important.)
Given that my program works when it runs as root, I think this means I have a permissions problem. How do I give the necessary permissions to my user to be able to run this program without logging on at the console (and without running as root)?