judge: use /dev/null

This commit is contained in:
undefined committed 2021-03-04 13:41:10 +08:00
1 parent e670f703f1
commit e3355aa43c
4 files changed
+16 -9

No files matched your search

+7 -4
View File
@@ -10,6 +10,7 @@ import { Logger } from './log';
const logger = new Logger('sandbox');
const env = ['PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', 'HOME=/w'];
const axios = Axios.create({ baseURL: getConfig('sandbox_host') });
let callId = 0;
const statusMap = {
'Time Limit Exceeded': STATUS.STATUS_TIME_LIMIT_EXCEEDED,
@@ -90,9 +91,10 @@ export async function runMultiple(execute) {
body.cmd[0].files[1] = null;
body.cmd[1].files[0] = null;
body.cmd[1].files[1] = null;
if (argv['show-sandbox-call']) logger.debug(JSON.stringify(body));
const id = callId++;
if (argv['show-sandbox-call']) logger.debug('%d %s', id, JSON.stringify(body));
res = await axios.post('/run', body);
if (argv['show-sandbox-call']) logger.debug(JSON.stringify(res.data));
if (argv['show-sandbox-call']) logger.debug('%d %s', id, JSON.stringify(res.data));
} catch (e) {
throw new SystemError('Sandbox Error');
}
@@ -111,9 +113,10 @@ export async function run(execute, params?) {
if (typeof execute === 'object') return await runMultiple(execute);
try {
const body = { cmd: [proc({ execute, ...params })] };
if (argv['show-sandbox-call']) logger.debug(JSON.stringify(body));
const id = callId++;
if (argv['show-sandbox-call']) logger.debug('%d %s', id, JSON.stringify(body));
const res = await axios.post('/run', body);
if (argv['show-sandbox-call']) logger.debug(JSON.stringify(res.data));
if (argv['show-sandbox-call']) logger.debug('%d %s', id, JSON.stringify(res.data));
[result] = res.data;
} catch (e) {
// FIXME request body larger than maxBodyLength limit