1

I'm experiencing inconsistent $DISPLAY variables on my OEL6 servers which have caused quite a bit of trouble with socket files.

I have found surprisingly little on what actually sets the environment variable $DISPLAY, I know what it does(more-or-less) and how to manually set it in the shell, What I don't know is HOW it is set when the system is starting.

so

How and Where is the GDM environment variable $DISPLAY set and how can I force GDM to :0.0?

Note: I am NOT looking for export DISPLAY=:0.0 as that will not be of any use in this case.

ChrisK
  • 63
  • 1
  • 11
  • As far as I know, it is not set when the system is 'booting' per-se, but it set's for every x-session you start, under your user environment. To the best I could remember, it starts from the first available number, sequentially speaking. If you left an x-session running somewhere, with display set the 0.0, you would get 0.1. for the next session you started, but it has been ages since I touched an x-interface on any server. So take my words with a big grain of salt – MelBurslan Feb 18 '16 at 22:05
  • The problem is it's always after a reboot and it starts on :1.0 not :0.1 as it should. I'm trying to find out where it gets the 1 from because as far as I know it should be :0.* unless you are starting another xserver or if you are using ssh ( :10.0) – ChrisK Feb 19 '16 at 14:06
  • also changed to starting rather than booting. – ChrisK Feb 19 '16 at 14:09

1 Answers1

3

In man X(7) there is section Display Names which states:

On POSIX systems, the default display name is stored in your DISPLAY environment variable. This variable is set automatically by the xterm terminal emulator.

and next:

Finally, most X programs accept a command line option of -display displayname to temporarily override the contents of DISPLAY. This is most commonly used to pop windows on another person's screen or as part of a "remote shell" command to start an xterm pointing back to your display.

man for Xserver(1) we have information about Options:

:displaynumber The X server runs as the given displaynumber, which by default is 0. If multiple X servers are to run simultaneously on a host, each must have a unique display number. See the DISPLAY NAMES section of the X(7) manual page to learn how to specify which display number clients should try to use.

Take a look at: /etc/gdm/Init/Default (available on ArchLinux, so not sure if in RHEL syststem it is available).

Some more findings. DISPLAY is set by xinit program. xinit.c has this:

if (argc > 0 && (argv[0][0] == ':' && isdigit(argv[0][1])))
    displayNum = *argv;
else
    displayNum = *sptr++ = default_display;

(...)

static void
set_environment(void)
{
    if (setenv("DISPLAY", displayNum, TRUE) == -1)
        Fatal("unable to set DISPLAY");
}

So xinit can set default value or take it from option passed to xinit when it was run. xinit(1):

       xinit [ [ client ] options ... ] [ -- [ server ] [ display ] options ... ]

And one more. environment variable can be set by PAM. Eg. /etc/security/pam_env.conf

# Set the DISPLAY variable if it seems reasonable
#DISPLAY                DEFAULT=${REMOTEHOST}:0.0 OVERRIDE=${DISPLAY}
Artur Szymczak
  • 1,913
  • 12
  • 12
  • In `etc/gdm/Init/Default' it sets $DISPLAY based on the variable $GDM_PARENT_DISPLAY. So that means it's gpd^ that is setting the incorrect value. Would it be possible to include $GDM_PARENT DISPLAY in your answer? – ChrisK Feb 23 '16 at 16:18
  • 1
    /etc/security/pam_env.conf is just what I needed. Thanks. – ChrisK Feb 29 '16 at 16:36