Skip to content

Commit 803e798

Browse files
committed
为某些二进制文件增加可执行权限检查
1 parent ca54854 commit 803e798

1 file changed

Lines changed: 25 additions & 3 deletions

File tree

src/extension.ts

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1018,12 +1018,34 @@ async function InitComponents(context: vscode.ExtensionContext): Promise<boolean
10181018

10191019
LogDumper.getInstance();
10201020

1021-
// chmod +x for 7za
1021+
// set exec permission for built-in tools
10221022
if (os.platform() != 'win32') {
1023+
1024+
const exelist: string[] = [
1025+
resManager.Get7za().path,
1026+
];
1027+
1028+
new File(resManager.getUnifyBuilderExe().dir)
1029+
.GetList(undefined, File.EXCLUDE_ALL_FILTER)
1030+
.forEach((f) => {
1031+
if (!f.suffix) { // nosuffix file is an exe file
1032+
exelist.push(f.path);
1033+
}
1034+
});
1035+
10231036
try {
1024-
ChildProcess.execSync(`chmod +x "${resManager.Get7za().path}"`);
1037+
for (const exePath of exelist) {
1038+
try {
1039+
fs.accessSync(exePath, fs.constants.R_OK | fs.constants.X_OK);
1040+
} catch (error) {
1041+
const cmd = `chmod +x "${exePath}"`;
1042+
GlobalEvent.emit('globalLog.append', cmd);
1043+
ChildProcess.execSync(cmd);
1044+
}
1045+
}
10251046
} catch (error) {
1026-
GlobalEvent.emit('msg', ExceptionToMessage(error, 'Error'));
1047+
GlobalEvent.emit('globalLog', ExceptionToMessage(error, 'Error'));
1048+
GlobalEvent.emit('globalLog.show');
10271049
}
10281050
}
10291051

0 commit comments

Comments
 (0)