Skip to content
Snippets Groups Projects
Commit 0213f9a0 authored by Morris Jette's avatar Morris Jette
Browse files

Export "SLURM*" env vars if --export=NONE

backport of commit 9b4f3634
parent ebaa4366
No related branches found
No related tags found
No related merge requests found
...@@ -1603,6 +1603,29 @@ void env_array_merge(char ***dest_array, const char **src_array) ...@@ -1603,6 +1603,29 @@ void env_array_merge(char ***dest_array, const char **src_array)
xfree(value); xfree(value);
} }
/*
* Merge the environment variables in src_array beginning with "SLURM" into the
* array dest_array. Any variables already found in dest_array will be
* overwritten with the value from src_array.
*/
void env_array_merge_slurm(char ***dest_array, const char **src_array)
{
char **ptr;
char name[256], *value;
if (src_array == NULL)
return;
value = xmalloc(ENV_BUFSIZE);
for (ptr = (char **)src_array; *ptr != NULL; ptr++) {
if (_env_array_entry_splitter(*ptr, name, sizeof(name),
value, ENV_BUFSIZE) &&
(strncmp(name, "SLURM", 5) == 0))
env_array_overwrite(dest_array, name, value);
}
xfree(value);
}
/* /*
* Strip out trailing carriage returns and newlines * Strip out trailing carriage returns and newlines
*/ */
......
...@@ -194,6 +194,13 @@ void env_unset_environment(void); ...@@ -194,6 +194,13 @@ void env_unset_environment(void);
*/ */
void env_array_merge(char ***dest_array, const char **src_array); void env_array_merge(char ***dest_array, const char **src_array);
/*
* Merge the environment variables in src_array beginning with "SLURM" into the
* array dest_array. Any variables already found in dest_array will be
* overwritten with the value from src_array.
*/
void env_array_merge_slurm(char ***dest_array, const char **src_array);
/* /*
* Copy env_array must be freed by env_array_free * Copy env_array must be freed by env_array_free
*/ */
......
...@@ -465,6 +465,8 @@ static int _fill_job_desc_from_opts(job_desc_msg_t *desc) ...@@ -465,6 +465,8 @@ static int _fill_job_desc_from_opts(job_desc_msg_t *desc)
env_array_merge(&desc->environment, (const char **)environ); env_array_merge(&desc->environment, (const char **)environ);
} else if (!strcasecmp(opt.export_env, "NONE")) { } else if (!strcasecmp(opt.export_env, "NONE")) {
desc->environment = env_array_create(); desc->environment = env_array_create();
env_array_merge_slurm(&desc->environment,
(const char **)environ);
opt.get_user_env_time = 0; opt.get_user_env_time = 0;
} else { } else {
_env_merge_filter(desc); _env_merge_filter(desc);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment