Skip to content

Commit 1d55a41

Browse files
authored
Explicitly provide env vars instead of inheriting them from parent (#703)
1 parent 6ef0cdf commit 1d55a41

File tree

2 files changed

+4
-14
lines changed

2 files changed

+4
-14
lines changed

api/src/job.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,9 @@ class Job {
158158
'/box/submission',
159159
'-E',
160160
'HOME=/tmp',
161-
'-e',
161+
...this.runtime.env_vars.flat_map(v => ['-E', v]),
162+
'-E',
163+
`PISTON_LANGUAGE=${this.runtime.language}`,
162164
`--dir=${this.runtime.pkgdir}`,
163165
`--dir=/etc:noexec`,
164166
`--processes=${this.runtime.max_process_count}`,
@@ -177,10 +179,6 @@ class Job {
177179
...args,
178180
],
179181
{
180-
env: {
181-
...this.runtime.env_vars,
182-
PISTON_LANGUAGE: this.runtime.language,
183-
},
184182
stdio: 'pipe',
185183
}
186184
);

api/src/runtime.js

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -178,15 +178,7 @@ class Runtime {
178178
const env_file = path.join(this.pkgdir, '.env');
179179
const env_content = fss.read_file_sync(env_file).toString();
180180

181-
this._env_vars = {};
182-
183-
env_content
184-
.trim()
185-
.split('\n')
186-
.map(line => line.split('=', 2))
187-
.forEach(([key, val]) => {
188-
this._env_vars[key.trim()] = val.trim();
189-
});
181+
this._env_vars = env_content.trim().split('\n');
190182
}
191183

192184
return this._env_vars;

0 commit comments

Comments
 (0)