Skip to content

Commit

Permalink
Explicitly provide env vars instead of inheriting them from parent (#703
Browse files Browse the repository at this point in the history
)
  • Loading branch information
Brikaa authored Feb 8, 2025
1 parent 6ef0cdf commit 1d55a41
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 14 deletions.
8 changes: 3 additions & 5 deletions api/src/job.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,9 @@ class Job {
'/box/submission',
'-E',
'HOME=/tmp',
'-e',
...this.runtime.env_vars.flat_map(v => ['-E', v]),
'-E',
`PISTON_LANGUAGE=${this.runtime.language}`,
`--dir=${this.runtime.pkgdir}`,
`--dir=/etc:noexec`,
`--processes=${this.runtime.max_process_count}`,
Expand All @@ -177,10 +179,6 @@ class Job {
...args,
],
{
env: {
...this.runtime.env_vars,
PISTON_LANGUAGE: this.runtime.language,
},
stdio: 'pipe',
}
);
Expand Down
10 changes: 1 addition & 9 deletions api/src/runtime.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,15 +178,7 @@ class Runtime {
const env_file = path.join(this.pkgdir, '.env');
const env_content = fss.read_file_sync(env_file).toString();

this._env_vars = {};

env_content
.trim()
.split('\n')
.map(line => line.split('=', 2))
.forEach(([key, val]) => {
this._env_vars[key.trim()] = val.trim();
});
this._env_vars = env_content.trim().split('\n');
}

return this._env_vars;
Expand Down

0 comments on commit 1d55a41

Please sign in to comment.