4 Star 0 Fork 32

src-openEuler/hadoop

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
04-Enhance-access-control-for-RunJar.patch 2.30 KB
一键复制 编辑 原始数据 按行查看 历史
fandeyuan 提交于 2024-09-26 11:10 . fix CVE-2024-23454
From aafa13bb48274971780d564fc2f2471f0064f734 Mon Sep 17 00:00:00 2001
From: He Xiaoqiao <hexiaoqiao@apache.org>
Date: Mon, 15 Jan 2024 16:01:08 +0800
Subject: [PATCH] HADOOP-19031. Enhance access control for RunJar.
---
.../main/java/org/apache/hadoop/util/RunJar.java | 16 +++++++++-------
1 file changed, 9 insertions(+), 7 deletions(-)
diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/RunJar.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/RunJar.java
index c28e69f5..e527f602 100644
--- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/RunJar.java
+++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/RunJar.java
@@ -28,10 +28,14 @@ import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLClassLoader;
import java.nio.file.Files;
+import java.nio.file.attribute.FileAttribute;
+import java.nio.file.attribute.PosixFilePermission;
+import java.nio.file.attribute.PosixFilePermissions;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Enumeration;
import java.util.List;
+import java.util.Set;
import java.util.jar.JarEntry;
import java.util.jar.JarFile;
import java.util.jar.JarInputStream;
@@ -287,20 +291,18 @@ public class RunJar {
final File workDir;
try {
- workDir = File.createTempFile("hadoop-unjar", "", tmpDir);
- } catch (IOException ioe) {
+ FileAttribute<Set<PosixFilePermission>> perms = PosixFilePermissions
+ .asFileAttribute(PosixFilePermissions.fromString("rwx------"));
+ workDir = Files.createTempDirectory(tmpDir.toPath(), "hadoop-unjar", perms).toFile();
+ } catch (IOException | SecurityException e) {
// If user has insufficient perms to write to tmpDir, default
// "Permission denied" message doesn't specify a filename.
System.err.println("Error creating temp dir in java.io.tmpdir "
- + tmpDir + " due to " + ioe.getMessage());
+ + tmpDir + " due to " + e.getMessage());
System.exit(-1);
return;
}
- if (!workDir.delete()) {
- System.err.println("Delete failed for " + workDir);
- System.exit(-1);
- }
ensureDirectory(workDir);
ShutdownHookManager.get().addShutdownHook(
--
2.43.0
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/src-openeuler/hadoop.git
git@gitee.com:src-openeuler/hadoop.git
src-openeuler
hadoop
hadoop
master

搜索帮助