Skip to content

Commit 459f3bd

Browse files
grondomergify[bot]
authored andcommitted
shell: inherit FLUX_F58_FORCE_ASCII from job
Problem: If a user sets FLUX_F58_FORCE_ASCII for a job, then job artifacts created by the job shell, such as environment variables, directories, and output files, should obey this variable and use ascii encoded F58. However, this is currently not the case since the job shell is using the environment inherited from the broker and/or IMP, not the job environment. Set up the job shell to inherit a subset of environment variables from the job environment early during startup. At first, add just FLUX_F58_FORCE_ASCII to this list.
1 parent 894cfdd commit 459f3bd

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

src/shell/shell.c

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1288,6 +1288,25 @@ static int shell_register_event_context (flux_shell_t *shell)
12881288
return 0;
12891289
}
12901290

1291+
/* Export a static list of environment variables from the job environment
1292+
* to the current shell environment. This is important for variables like
1293+
* FLUX_F58_FORCE_ASCII which should influence some shell behavior.
1294+
*/
1295+
static int shell_export_environment_from_job (flux_shell_t *shell)
1296+
{
1297+
const char *vars[] = {
1298+
"FLUX_F58_FORCE_ASCII",
1299+
NULL,
1300+
};
1301+
1302+
for (int i = 0; vars[i] != NULL; i++) {
1303+
const char *val = flux_shell_getenv (shell, vars[i]);
1304+
if (val && setenv (vars[i], val, 1) < 0)
1305+
return shell_log_errno ("setenv (%s)", vars[i]);
1306+
}
1307+
return 0;
1308+
}
1309+
12911310
int main (int argc, char *argv[])
12921311
{
12931312
flux_shell_t shell;
@@ -1325,6 +1344,9 @@ int main (int argc, char *argv[])
13251344
if (!(shell.info = shell_info_create (&shell)))
13261345
exit (1);
13271346

1347+
if (shell_export_environment_from_job (&shell) < 0)
1348+
exit (1);
1349+
13281350
if (shell_register_event_context (&shell) < 0)
13291351
shell_die (1, "failed to add standard shell event context");
13301352

0 commit comments

Comments
 (0)