Skip to content
Snippets Groups Projects
Commit d254296c authored by Philip D. Eckert's avatar Philip D. Eckert Committed by jette
Browse files

here it is

Moe,

Here it is, I have added a subroutine to env.c to
unset the user's environment and then called it
from sbatch in main. I also removed the comment
from the sbatch man page indicating that it
wasn't working the same for a regular user as
it did for Moab. It should now be functionally
the same.

I think there is still a difference between how
sbatch functions with an environment in a file
than it does from when Moab excve'd the environment.
However, I'm not sure what it would be at this
point.

Again,  for so many iterations....

Phil
parent 16e6fcd6
No related branches found
No related tags found
No related merge requests found
......@@ -384,9 +384,7 @@ assumed. Export environment variables defined in <\fIfilename\fR> or
read from <\fIfd\fR> to the job's execution environment. The
content is one or more environment variable definitions of the form
NAME=value, each separated by a null character. This allows the use
of special characters in environment definitions.(Note: primarily for use
with Moab. outside of Moab, variables in the user's working environment
may supercede the variables specified in the file.)
of special characters in environment definitions.
.TP
\fB\-F\fR, \fB\-\-nodefile\fR=<\fInode file\fR>
......
......@@ -81,6 +81,7 @@ strong_alias(env_array_append, slurm_env_array_append);
strong_alias(env_array_append_fmt, slurm_env_array_append_fmt);
strong_alias(env_array_overwrite, slurm_env_array_overwrite);
strong_alias(env_array_overwrite_fmt, slurm_env_array_overwrite_fmt);
strong_alias(env_unset_environment, slurm_env_unset_environment);
#define ENV_BUFSIZE (256 * 1024)
......@@ -1526,6 +1527,33 @@ void env_array_set_environment(char **env_array)
}
}
/*
* Unset all of the environment variables in a user's current
* environment.
*
* (Note: becuae the environ array is decrementing with each
* unsetenv, only increment the ptr on a failure to unset.)
*/
void env_unset_environment(void)
{
extern char **environ;
int rc = 0;
char **ptr;
char name[256], *value;
value = xmalloc(ENV_BUFSIZE);
for (ptr = (char **)environ; *ptr != NULL; ) {
if ((_env_array_entry_splitter(*ptr, name, sizeof(name),
value, ENV_BUFSIZE)) &&
(unsetenv(name) != -1))
rc = 1;
else
ptr++;
}
xfree(value);
}
/*
* Merge all of the environment variables in src_array into the
* array dest_array. Any variables already found in dest_array
......
......@@ -180,6 +180,12 @@ env_array_for_step(char ***dest,
*/
char **env_array_create(void);
/*
* Unset all of the environment variables in a user's current
* environment.
*/
void env_unset_environment(void);
/*
* Merge all of the environment variables in src_array into the
* array dest_array. Any variables already found in dest_array
......
......@@ -137,6 +137,13 @@ int main(int argc, char *argv[])
(void) _set_rlimit_env();
}
/*
* if the environment is coming from a file, the
* environment at execution startup, must be unset.
*/
if (opt.export_file != NULL)
env_unset_environment();
_set_prio_process_env();
_set_spank_env();
_set_submit_dir_env();
......
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