mirror of
https://github.com/mudler/luet.git
synced 2025-08-12 04:32:11 +00:00
tarModifierWrapperFunc: Now use strings.HasPrefix for match path
This commit is contained in:
parent
cd903351b3
commit
c87db16d31
@ -305,10 +305,14 @@ func tarModifierWrapperFunc(dst, path string, header *tar.Header, content io.Rea
|
|||||||
// Check if exists
|
// Check if exists
|
||||||
if helpers.Exists(destPath) {
|
if helpers.Exists(destPath) {
|
||||||
for i := 1; i < 1000; i++ {
|
for i := 1; i < 1000; i++ {
|
||||||
name := filepath.Join(dst, filepath.Join(filepath.Dir(path), fmt.Sprintf("._cfg%04d_%s", i, filepath.Base(path))))
|
name := filepath.Join(filepath.Join(filepath.Dir(path),
|
||||||
|
fmt.Sprintf("._cfg%04d_%s", i, filepath.Base(path))))
|
||||||
|
|
||||||
if helpers.Exists(name) {
|
if helpers.Exists(name) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
Info(fmt.Sprintf("Found protected file %s. Creating %s.", destPath,
|
||||||
|
filepath.Join(dst, name)))
|
||||||
return &tar.Header{
|
return &tar.Header{
|
||||||
Mode: header.Mode,
|
Mode: header.Mode,
|
||||||
Typeflag: header.Typeflag,
|
Typeflag: header.Typeflag,
|
||||||
@ -326,11 +330,13 @@ func (a *PackageArtifact) GetProtectFiles() []string {
|
|||||||
ans := []string{}
|
ans := []string{}
|
||||||
|
|
||||||
if LuetCfg.GetConfigProtectConfFiles() != nil && len(LuetCfg.GetConfigProtectConfFiles()) > 0 {
|
if LuetCfg.GetConfigProtectConfFiles() != nil && len(LuetCfg.GetConfigProtectConfFiles()) > 0 {
|
||||||
for _, file := range a.Files {
|
|
||||||
|
|
||||||
|
for _, file := range a.Files {
|
||||||
for _, conf := range LuetCfg.GetConfigProtectConfFiles() {
|
for _, conf := range LuetCfg.GetConfigProtectConfFiles() {
|
||||||
for _, dir := range conf.Directories {
|
for _, dir := range conf.Directories {
|
||||||
if match, _ := filepath.Match(fmt.Sprintf("%s/*", dir), file); match {
|
// Note file is without / at begin.
|
||||||
|
if strings.HasPrefix("/"+file, filepath.Clean(dir)) {
|
||||||
|
// docker archive modifier works with path without / at begin.
|
||||||
ans = append(ans, file)
|
ans = append(ans, file)
|
||||||
goto nextFile
|
goto nextFile
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user