diff options
author | Jaime Martinez <jmartinez@gitlab.com> | 2021-04-13 02:21:44 +0300 |
---|---|---|
committer | Jaime Martinez <jmartinez@gitlab.com> | 2021-04-13 04:14:16 +0300 |
commit | c10549ed34d7a00ea087aa2076e47620fa980397 (patch) | |
tree | 183bb4563c2dd3612789f799eaadcf095c3bc6bb | |
parent | 34e1518038a8164c090ccfbfc30ebc7850e62cf0 (diff) |
Remove root from AllowedPaths
-rw-r--r-- | internal/config/config.go | 1 | ||||
-rw-r--r-- | internal/httpfs/http_fs.go | 7 | ||||
-rw-r--r-- | internal/vfs/zip/vfs.go | 2 |
3 files changed, 1 insertions, 9 deletions
diff --git a/internal/config/config.go b/internal/config/config.go index 6de66bcf..20a9ad8b 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -338,7 +338,6 @@ func loadConfig() *Config { // To be removed after we roll-out zip architecture completely https://gitlab.com/gitlab-org/gitlab-pages/-/issues/561 if config.Daemon.InplaceChroot { config.Zip.ChrootPath = *pagesRoot - config.Zip.AllowedPaths = append(config.Zip.AllowedPaths, "/") } validateConfig(config) diff --git a/internal/httpfs/http_fs.go b/internal/httpfs/http_fs.go index 1ce90057..cd2edb83 100644 --- a/internal/httpfs/http_fs.go +++ b/internal/httpfs/http_fs.go @@ -55,13 +55,6 @@ func (p *fileSystemPaths) Open(name string) (http.File, error) { return nil, err } for _, allowedPath := range p.allowedPaths { - // TODO: this is a temporary workaround for https://gitlab.com/gitlab-org/gitlab/-/issues/326117#note_546346101 - // where daemon-inplace-chroot=true fails to serve zip archives when pages_serve_with_zip_file_protocol is enabled - // To be removed after we roll-out zip architecture completely https://gitlab.com/gitlab-org/gitlab-pages/-/issues/561 - if allowedPath == "/" { - return os.Open(absPath) - } - if strings.HasPrefix(absPath, allowedPath+"/") { return os.Open(absPath) } diff --git a/internal/vfs/zip/vfs.go b/internal/vfs/zip/vfs.go index fc83fca2..e8cae63c 100644 --- a/internal/vfs/zip/vfs.go +++ b/internal/vfs/zip/vfs.go @@ -262,5 +262,5 @@ func (fs *zipVFS) removeChrootPath(path string) string { return path } - return strings.ReplaceAll(path, fs.chrootPath, "") + return strings.Replace(path, fs.chrootPath, "", 1) } |