1 Star 0 Fork 58

gnaygnil/docker

forked from src-openEuler/docker 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
0017-hookspec-canonicalize-hook-path-before-valida.patch 1.66 KB
一键复制 编辑 原始数据 按行查看 历史
gnaygnil 提交于 2020-02-13 15:36 . docker: Fixed build error and URL
From fe67259fd158b8193db31fad83f2dc3d3d3bc5c4 Mon Sep 17 00:00:00 2001
From: lujingxiao <lujingxiao@huawei.com>
Date: Sat, 19 Jan 2019 11:17:38 +0800
Subject: [PATCH 017/111] hookspec: canonicalize hook path before
validation
reason:hook programs must put under hook directory, but if we refer
them with a symbolic link path in hookspecs, docker daemon refuse
to run. so we just canonicalize path first before check.
Change-Id: I68d3757f26d7df05eb048e686368eca061cb06a9
Signed-off-by: zhangyuyun <zhangyuyun@huawei.com>
Signed-off-by: xiadanni <xiadanni@huawei.com>
Signed-off-by: lujingxiao <lujingxiao@huawei.com>
---
components/engine/daemon/container.go | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
diff --git a/components/engine/daemon/container.go b/components/engine/daemon/container.go
index a8cb950f44..06a19bb4c8 100644
--- a/components/engine/daemon/container.go
+++ b/components/engine/daemon/container.go
@@ -366,8 +366,17 @@ func (daemon *Daemon) validateHookPath(path string) error {
return fmt.Errorf("Hook path %q must be an absolute path", path)
}
- if !filepath.HasPrefix(path, daemon.hookStore) {
- return fmt.Errorf("hook program must be put under %q", daemon.hookStore)
+ realPath, err := filepath.EvalSymlinks(path)
+ if err != nil {
+ if !strings.Contains(err.Error(), "no such file or directory") {
+ return fmt.Errorf("failed to canonicalise path for %s: %s", path, err)
+ }
+ // for backward compatibility
+ realPath = path
+ }
+
+ if !filepath.HasPrefix(realPath, daemon.hookStore) {
+ return fmt.Errorf("hook path %q isn't right, hook program must be put under %q", path, daemon.hookStore)
}
return nil
}
--
2.17.1
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/gnaygnil/docker.git
git@gitee.com:gnaygnil/docker.git
gnaygnil
docker
docker
master

搜索帮助