Skip to content

Commit

Permalink
X11 fowarding - handle DISPLAY if screen number not present.
Browse files Browse the repository at this point in the history
X11 forwarding doesn't care about the screen number, so handle DISPLAY
environment variables without that present correctly.

E.g., both "localhost:10.0" and "localhost:10" are now handled, whereas
previously only the first form would have been accepted.

Bug 6532.
  • Loading branch information
naterini authored and wickberg committed Feb 23, 2019
1 parent 1cc1faa commit 55d1927
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
2 changes: 2 additions & 0 deletions NEWS
Expand Up @@ -26,6 +26,8 @@ documents those changes that are of interest to users and administrators.
-- Fix sacct verbose about time and states queried.
-- burst_buffer/cray - allow 'scancel --hurry <jobid>' to tear down a burst
buffer that is currently staging data out.
-- X11 forwarding - allow setup if the DISPLAY environment variable lacks
a screen number. (Permit both "localhost:10.0" and "localhost:10".)

* Changes in Slurm 18.08.5-2
============================
Expand Down
16 changes: 10 additions & 6 deletions src/common/x11_util.c
Expand Up @@ -95,21 +95,25 @@ extern int x11_get_display_port(void)
exit(-1);
}

/*
* Parse out port number
* Example: localhost/unix:89.0 or localhost/unix:89
*/
port_split = strchr(display, ':');
if (!port_split) {
error("Error parsing DISPLAY environment variable. "
"Cannot use X11 forwarding.");
exit(-1);
}

/*
* Handle the "screen" portion of the display port.
* Xorg does not require a screen to be specified, defaults to 0.
*/
port_split++;
port_period = strchr(port_split, '.');
if (!port_period) {
error("Error parsing DISPLAY environment variable. "
"Cannot use X11 forwarding.");
exit(-1);
}
*port_period = '\0';
if (port_period)
*port_period = '\0';

port = atoi(port_split) + X11_TCP_PORT_OFFSET;

Expand Down

0 comments on commit 55d1927

Please sign in to comment.