mirror of
https://github.com/compiler-explorer/compiler-explorer.git
synced 2025-12-27 10:33:59 -05:00
Expose the naming convention of the jailing process (#8211)
To allow resolc to correctly find in-sandbox named artifacts See #8164
This commit is contained in:
@@ -32,6 +32,7 @@ import type {ParseFiltersAndOutputOptions} from '../../types/features/filters.in
|
||||
import type {Language} from '../../types/languages.interfaces.js';
|
||||
import {assert} from '../assert.js';
|
||||
import {BaseCompiler} from '../base-compiler.js';
|
||||
import {maybeRemapJailedDir} from '../exec.js';
|
||||
import {PolkaVMAsmParser} from '../parsers/asm-parser-polkavm.js';
|
||||
import {ResolcRiscVAsmParser} from '../parsers/asm-parser-resolc-riscv.js';
|
||||
import {changeExtension} from '../utils.js';
|
||||
@@ -132,7 +133,7 @@ export class ResolcCompiler extends BaseCompiler {
|
||||
}
|
||||
|
||||
private getOutputFilenameWithExtension(dirPath: string, extension: string): string {
|
||||
const basenamePrefix = dirPath.split(path.sep).join('_');
|
||||
const basenamePrefix = maybeRemapJailedDir(dirPath).split(path.sep).join('_');
|
||||
const contractName = this.inputIs(InputKind.Solidity)
|
||||
? this.getSolidityContractName(dirPath)
|
||||
: this.getYulContractName(dirPath);
|
||||
|
||||
17
lib/exec.ts
17
lib/exec.ts
@@ -243,6 +243,8 @@ export function getFirejailProfileFilePath(profileName: string): string {
|
||||
return profilePath;
|
||||
}
|
||||
|
||||
const jailedHomeDir = '/app';
|
||||
|
||||
export function getNsJailOptions(
|
||||
configName: string,
|
||||
command: string,
|
||||
@@ -257,26 +259,25 @@ export function getNsJailOptions(
|
||||
jailingOptions.push(`--time_limit=${Math.round((options.timeoutMs + ExtraWallClockLeewayMs) / 1000)}`);
|
||||
}
|
||||
|
||||
const homeDir = '/app';
|
||||
let filenameTransform: FilenameTransformFunc | undefined;
|
||||
if (options.customCwd) {
|
||||
let replacement = options.customCwd;
|
||||
if (options.appHome) {
|
||||
replacement = options.appHome;
|
||||
const relativeCwd = path.join(homeDir, path.relative(options.appHome, options.customCwd));
|
||||
jailingOptions.push('--cwd', relativeCwd, '--bindmount', `${options.appHome}:${homeDir}`);
|
||||
const relativeCwd = path.join(jailedHomeDir, path.relative(options.appHome, options.customCwd));
|
||||
jailingOptions.push('--cwd', relativeCwd, '--bindmount', `${options.appHome}:${jailedHomeDir}`);
|
||||
} else {
|
||||
jailingOptions.push('--cwd', homeDir, '--bindmount', `${options.customCwd}:${homeDir}`);
|
||||
jailingOptions.push('--cwd', jailedHomeDir, '--bindmount', `${options.customCwd}:${jailedHomeDir}`);
|
||||
}
|
||||
|
||||
filenameTransform = opt => opt.replaceAll(replacement, '/app');
|
||||
filenameTransform = opt => opt.replaceAll(replacement, jailedHomeDir);
|
||||
args = args.map(filenameTransform);
|
||||
delete options.customCwd;
|
||||
}
|
||||
|
||||
const transform = filenameTransform || (x => x);
|
||||
|
||||
const env: Record<string, string> = {...options.env, HOME: homeDir};
|
||||
const env: Record<string, string> = {...options.env, HOME: jailedHomeDir};
|
||||
if (options.ldPath) {
|
||||
const ldPaths = options.ldPath.filter(Boolean).map(path => transform(path));
|
||||
jailingOptions.push(`--env=LD_LIBRARY_PATH=${ldPaths.join(path.delimiter)}`);
|
||||
@@ -678,3 +679,7 @@ export async function execute(
|
||||
const unbuffered = await maybeUnbuffer(command, args);
|
||||
return await dispatchEntry(unbuffered.command, unbuffered.args, options);
|
||||
}
|
||||
|
||||
export function maybeRemapJailedDir(customCwd: string): string {
|
||||
return execProps('executionType', 'none') == 'nsjail' ? jailedHomeDir : customCwd;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user