From 9ed3a300a63e6380e61dd9cebc4b8c1262a1629c Mon Sep 17 00:00:00 2001
From: Tim Shaw <tshaw@schedmd.com>
Date: Thu, 13 Jul 2017 11:44:38 -0600
Subject: [PATCH] Modify srun --pty option to use configured SrunPortRange
 range

bug 3979
---
 NEWS                | 1 +
 src/srun/srun_pty.c | 8 +++++++-
 2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/NEWS b/NEWS
index 06e6f7368d1..6f938776232 100644
--- a/NEWS
+++ b/NEWS
@@ -10,6 +10,7 @@ documents those changes that are of interest to users and administrators.
  -- Set job/step start and end times to 0 when using --truncate and start > end.
  -- Make srun --pty option ignore EINTR allowing windows to resize.
  -- When resuming node only send one message to the slurmdbd.
+ -- Modify srun --pty option to use configured SrunPorts range.
 
 * Changes in Slurm 17.02.6
 ==========================
diff --git a/src/srun/srun_pty.c b/src/srun/srun_pty.c
index e9a433a7e8f..081aa549ab3 100644
--- a/src/srun/srun_pty.c
+++ b/src/srun/srun_pty.c
@@ -94,8 +94,14 @@ void pty_thread_create(srun_job_t *job)
 {
 	slurm_addr_t pty_addr;
 	pthread_attr_t attr;
+	uint16_t *ports;
 
-	if ((job->pty_fd = slurm_init_msg_engine_port(0)) < 0) {
+	if ((ports = slurm_get_srun_port_range()))
+		job->pty_fd = slurm_init_msg_engine_ports(ports);
+	else
+		job->pty_fd = slurm_init_msg_engine_port(0);
+
+	if (job->pty_fd < 0) {
 		error("init_msg_engine_port: %m");
 		return;
 	}
-- 
GitLab