Merge branch 'master' into websocket

This commit is contained in:
Thomas Hobson 2021-09-22 08:21:31 +12:00 committed by GitHub
commit 7d05f4e305
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
47 changed files with 672 additions and 48 deletions

View file

@ -13,7 +13,7 @@ RUN apt-get update && \
libncurses6 libncurses5 libedit-dev libseccomp-dev rename procps python3 \
libreadline-dev libblas-dev liblapack-dev libpcre3-dev libarpack2-dev \
libfftw3-dev libglpk-dev libqhull-dev libqrupdate-dev libsuitesparse-dev \
libsundials-dev && \
libsundials-dev libpcre2-dev && \
rm -rf /var/lib/apt/lists/*
RUN sed -i '/en_US.UTF-8/s/^# //g' /etc/locale.gen && locale-gen

View file

@ -59,6 +59,13 @@ class Job {
for (const file of this.files) {
let file_path = path.join(this.dir, file.name);
const rel = path.relative(this.dir, file_path);
if(rel.startsWith(".."))
throw Error(`File path "${file.name}" tries to escape parent directory: ${rel}`)
await fs.mkdir(path.dirname(file_path), {recursive: true, mode: 0o700})
await fs.chown(path.dirname(file_path), this.uid, this.gid);
await fs.write_file(file_path, file.content);
await fs.chown(file_path, this.uid, this.gid);
@ -155,7 +162,7 @@ class Job {
proc.on('exit', (code, signal) => {
exit_cleanup();
resolve({ stdout, stderr, code, signal, output });
resolve({stdout, stderr, code, signal, output });
});
proc.on('error', err => {
@ -332,10 +339,8 @@ class Job {
async cleanup() {
logger.info(`Cleaning up job uuid=${this.uuid}`);
await Promise.all([
this.cleanup_processes(),
this.cleanup_filesystem(),
]);
await this.cleanup_processes();
await this.cleanup_filesystem();
}
}