program running on tty needs access to xwindow (no graphical user logged in)
The title sort of says it all, but let me explain my situation a bit more. Let me warn you that although I have done some semi-complex things with linux I'm still a newbie who doesnít understand anything except those few explicit things I've had to figure out (and sometimes I don't really understand them :p)
I have an application being installed by an RPM which must run in the background at all times, and must come up at bootup even if no one has logged in. I ended up deciding to create a user and automatically log that user on tty7 (which moved graphical mode to tty8). The user has a line in his bash_profile that has him run our app and has very limited permissions other then sudo rights to run the app. I remember that there was a reason that I opted for having a user logged in rather then just putting my application in rc.5 to be run at bootup, something to do with other programs not being configured correctly when I attempted it that way, but I honestly can't recall what the reason was any more.
Anyways this method has been working for some time, but I'm running into some trouble with xhost. When the computer boots up it logs on the user I created to tty7 as it should and the user attempts to run the APP; at which point I get the error "GTX-WARNING: cannot open display." Our application is not graphical, but it does use Java timers which I believe have to plug into the XHost.
I originally had this problem on my personal laptop which I ultimately fixed by putting "xhost +" in the bashrc file, but I updated our RPM yesterday and now I get the same issue installing the RPM on a fresh install of RHEL 5.2. I'm not so eager to have our RPM implement the "xhost +" solution for obvious reasons.
Anyways here what I know playing on the tty7 (the automatically logged on user).
1) The DISPLAY variable is not set by default. I tried setting it to :0.0 but not surprisingly it doesnít work
2) running xhost complains either that it cannot open display "", or that "xlib: connection to display :0.0 refused" if I try setting DISPLAY first
3) startx fails because I cannot access display :0.0 (even though DISPLAY isn't set)
4) If I switch to tty8 (graphical mode) and log in then switch back to tty7 and run my application it runs perfectly. Only problem is the app usually will have to run when no one is logged in.
So what is happening? I understand that text modes are not supposed to be able to access xhost, but my rpm was working with this solution for some time before it broke. There must be some way to fix this without using the "xhost +local" solution that I see when I try to Google the problem, otherwise it wouldn't have worked before.
As a side note my RPM is copying over the users home directory. I mention this incase there is some hidden boot file like .bash_profile or .bashrc that I might be copying over that causes trouble. I don't think that the case sense I've compared the files and they look identical to what they should, but I really don't know whatís happening so I'll give you all the information I can think of.
help, advice, or links to someplace that can provide the same are appreciated. Thank you