registries.toml could not be empty;hosts, resolv.conf, .dockerignore file could be empty
This commit is contained in:
parent
d42224c54a
commit
35a49a7a5f
@ -1 +1 @@
|
||||
0.9.6-9
|
||||
0.9.6-10
|
||||
|
||||
@ -1 +1 @@
|
||||
4b22d9293271f94da1231f8efe1fe1e80d7e608b
|
||||
b414e4354d73c69e624fd365df134ea0f80490df
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
|
||||
Name: isula-build
|
||||
Version: 0.9.6
|
||||
Release: 9
|
||||
Release: 10
|
||||
Summary: A tool to build container images
|
||||
License: Mulan PSL V2
|
||||
URL: https://gitee.com/openeuler/isula-build
|
||||
@ -85,6 +85,12 @@ fi
|
||||
/usr/share/bash-completion/completions/isula-build
|
||||
|
||||
%changelog
|
||||
* Tue Jul 26 2022 lujingxiao <lujingxiao@huawei.com> - 0.9.6-10
|
||||
- Type:bugfix
|
||||
- CVE:NA
|
||||
- SUG:restart
|
||||
- DESC:registries.toml could not be empty;hosts, resolv.conf, .dockerignore file could be empty
|
||||
|
||||
* Tue Jul 26 2022 xingweizheng <xingweizheng@huawei.com> - 0.9.6-9
|
||||
- Type:bugfix
|
||||
- CVE:NA
|
||||
|
||||
@ -0,0 +1,92 @@
|
||||
From dda31ed16ab7ae19bf07762f48d0863414ffd2da Mon Sep 17 00:00:00 2001
|
||||
From: xingweizheng <xingweizheng@huawei.com>
|
||||
Date: Mon, 25 Jul 2022 18:48:10 +0800
|
||||
Subject: [PATCH] registries.toml could not be empty;hosts, resolv.conf,
|
||||
.dockerignore file could be empty
|
||||
|
||||
---
|
||||
builder/dockerfile/parser/parser.go | 2 +-
|
||||
builder/dockerfile/run.go | 4 ++--
|
||||
cmd/daemon/before.go | 2 +-
|
||||
util/common.go | 17 +++++++++++++++++
|
||||
4 files changed, 21 insertions(+), 4 deletions(-)
|
||||
|
||||
diff --git a/builder/dockerfile/parser/parser.go b/builder/dockerfile/parser/parser.go
|
||||
index 1968fc1..2c34bbe 100644
|
||||
--- a/builder/dockerfile/parser/parser.go
|
||||
+++ b/builder/dockerfile/parser/parser.go
|
||||
@@ -304,7 +304,7 @@ func (df *dockerfile) ParseIgnore(dir string) ([]string, error) {
|
||||
}
|
||||
return ignores, errors.Wrap(err, "state dockerignore file failed")
|
||||
}
|
||||
- if err := util.CheckFileInfoAndSize(fullPath, constant.MaxFileSize); err != nil {
|
||||
+ if err := util.CheckFileAllowEmpty(fullPath, constant.MaxFileSize); err != nil {
|
||||
return ignores, err
|
||||
}
|
||||
|
||||
diff --git a/builder/dockerfile/run.go b/builder/dockerfile/run.go
|
||||
index 5b066fb..651897a 100644
|
||||
--- a/builder/dockerfile/run.go
|
||||
+++ b/builder/dockerfile/run.go
|
||||
@@ -171,7 +171,7 @@ func setupBindFiles(bundlePath string) (map[string]string, error) {
|
||||
}
|
||||
|
||||
func generateHosts(bundlePath string) (string, error) {
|
||||
- if err := util.CheckFileInfoAndSize(constant.HostsFilePath, constant.MaxFileSize); err != nil {
|
||||
+ if err := util.CheckFileAllowEmpty(constant.HostsFilePath, constant.MaxFileSize); err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
@@ -194,7 +194,7 @@ func generateHosts(bundlePath string) (string, error) {
|
||||
}
|
||||
|
||||
func generateResolv(bundlePath string) (string, error) {
|
||||
- if err := util.CheckFileInfoAndSize(constant.ResolvFilePath, constant.MaxFileSize); err != nil {
|
||||
+ if err := util.CheckFileAllowEmpty(constant.ResolvFilePath, constant.MaxFileSize); err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
diff --git a/cmd/daemon/before.go b/cmd/daemon/before.go
|
||||
index 1d28d9e..2ed19c9 100644
|
||||
--- a/cmd/daemon/before.go
|
||||
+++ b/cmd/daemon/before.go
|
||||
@@ -67,7 +67,7 @@ func validateConfigFileAndMerge(cmd *cobra.Command) error {
|
||||
mergeConfig func(cmd *cobra.Command) error
|
||||
}{
|
||||
{path: constant.StorageConfigPath, needed: false, mergeConfig: mergeStorageConfig},
|
||||
- {path: constant.RegistryConfigPath, needed: false, mergeConfig: nil},
|
||||
+ {path: constant.RegistryConfigPath, needed: true, mergeConfig: nil},
|
||||
// policy.json file must exists
|
||||
{path: constant.SignaturePolicyPath, needed: true, mergeConfig: nil},
|
||||
// main configuration comes last for the final merge operation
|
||||
diff --git a/util/common.go b/util/common.go
|
||||
index 42d81b8..a5d0df9 100644
|
||||
--- a/util/common.go
|
||||
+++ b/util/common.go
|
||||
@@ -111,6 +111,23 @@ func CheckFileInfoAndSize(path string, sizeLimit int64) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
+// CheckFileAllowEmpty same as CheckFileInfoAndSize, but allow file to be empty
|
||||
+func CheckFileAllowEmpty(path string, sizeLimit int64) error {
|
||||
+ f, err := os.Stat(filepath.Clean(path))
|
||||
+ if err != nil {
|
||||
+ return err
|
||||
+ }
|
||||
+ if !f.Mode().IsRegular() {
|
||||
+ return errors.Errorf("file %s should be a regular file", f.Name())
|
||||
+ }
|
||||
+
|
||||
+ if f.Size() > sizeLimit {
|
||||
+ return errors.Errorf("file %s size is: %d, exceeds limit %d", f.Name(), f.Size(), sizeLimit)
|
||||
+ }
|
||||
+
|
||||
+ return nil
|
||||
+}
|
||||
+
|
||||
// ParseServer will get registry address from input
|
||||
// if input is https://index.docker.io/v1
|
||||
// the result will be index.docker.io
|
||||
--
|
||||
2.27.0
|
||||
|
||||
@ -30,3 +30,4 @@ patch/0118-adapt-refactor-to-integration_coverage-and-auto-shfm.patch
|
||||
patch/0119-config-golangci-lint-to-lint-unit-test.patch
|
||||
patch/0120-make-isula-build-store-more-simple.patch
|
||||
patch/0121-print-first-and-second-error-when-dockerfile-not-fou.patch
|
||||
patch/0122-registries.toml-could-not-be-empty-hosts-resolv.conf.patch
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user