From 4d811afa622ba182da4f2f3a9213c34ea6542ec6 Mon Sep 17 00:00:00 2001
From: Morris Jette <jette@schedmd.com>
Date: Wed, 27 Aug 2014 14:35:35 -0700
Subject: [PATCH] restore full executable pathname for BGQ

BlueGene/Q's runjob command requires a fully qualified pathname,
so only for that machine type, resolve the name in srun. This
partitially reverts commit 57efc873079f7ef35b5eaca98effb825869dc6dc
but only for BGQ systems.
---
 src/common/proc_args.c | 11 +++++++++++
 src/srun/libsrun/opt.c | 16 ++++++++++++++++
 2 files changed, 27 insertions(+)

diff --git a/src/common/proc_args.c b/src/common/proc_args.c
index cbdd572a57f..450db18109a 100644
--- a/src/common/proc_args.c
+++ b/src/common/proc_args.c
@@ -795,8 +795,19 @@ search_path(char *cwd, char *cmd, bool check_current_dir, int access_mode)
 	ListIterator i        = NULL;
 	char *path, *fullpath = NULL;
 
+#if defined HAVE_BG && !defined HAVE_BG_L_P
+	/* BGQ's runjob command required a fully qualified path */
+	if ( (cmd[0] == '.' || cmd[0] == '/') &&
+	     (access(cmd, access_mode) == 0 ) ) {
+		if (cmd[0] == '.')
+			xstrfmtcat(fullpath, "%s/", cwd);
+		xstrcat(fullpath, cmd);
+		goto done;
+	}
+#else
 	if ((cmd[0] == '.') || (cmd[0] == '/'))
 		return NULL;
+#endif
 
 	l = _create_path_list();
 	if (l == NULL)
diff --git a/src/srun/libsrun/opt.c b/src/srun/libsrun/opt.c
index 7e4b73057ca..e5e261aa3e4 100644
--- a/src/srun/libsrun/opt.c
+++ b/src/srun/libsrun/opt.c
@@ -1780,7 +1780,23 @@ static void _opt_args(int argc, char **argv)
 	}
 	opt.argv[i] = NULL;	/* End of argv's (for possible execv) */
 
+#if defined HAVE_BG && !defined HAVE_BG_L_P
+	/* BGQ's runjob command required a fully qualified path */
+	if (!launch_g_handle_multi_prog_verify(command_pos) &&
+	    (opt.argc > command_pos)) {
+		char *fullpath;
+
+		if ((fullpath = search_path(opt.cwd,
+					    opt.argv[command_pos],
+					    false, X_OK))) {
+			xfree(opt.argv[command_pos]);
+			opt.argv[command_pos] = fullpath;
+		}
+	}
+#else
 	(void) launch_g_handle_multi_prog_verify(command_pos);
+#endif
+
 #if 0
 	for (i=0; i<opt.argc; i++)
 		info("%d is '%s'", i, opt.argv[i]);
-- 
GitLab