Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-pages.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJaime Martinez <jmartinez@gitlab.com>2021-01-12 05:42:46 +0300
committerJaime Martinez <jmartinez@gitlab.com>2021-02-02 08:06:26 +0300
commitdd3499cd07e539c237b8f84a2cc918ed98c677fe (patch)
treedbf3c480bb82a8fe22f2b6757f29ccd5e7670c40
parente7d71ae540f433eb8dbbfef64118674f7e76e473 (diff)
Ensure pages-root is abs
MkdirAll in jail so the full pages-root path is created
-rw-r--r--Makefile.util.mk2
-rw-r--r--daemon.go13
-rw-r--r--internal/jail/jail.go2
-rw-r--r--internal/jail/jail_test.go3
4 files changed, 13 insertions, 7 deletions
diff --git a/Makefile.util.mk b/Makefile.util.mk
index 4f190ea4..da29e0c8 100644
--- a/Makefile.util.mk
+++ b/Makefile.util.mk
@@ -17,7 +17,7 @@ race: .GOPATH/.ok gitlab-pages
CGO_ENABLED=1 go test -race $(if $V,-v) $(allpackages)
acceptance: .GOPATH/.ok gitlab-pages
- go test $(if $V,-v) ./test/acceptance 2>&1 | tee tests.out
+ go test $(if $V,-v) ./test/acceptance ${ARGS} 2>&1 | tee tests.out
bench: .GOPATH/.ok gitlab-pages
go test -bench=. -run=^$$ $(allpackages)
diff --git a/daemon.go b/daemon.go
index 383af376..86de6fc8 100644
--- a/daemon.go
+++ b/daemon.go
@@ -274,10 +274,17 @@ func jailDaemon(pagesRoot string, cmd *exec.Cmd) (*jail.Jail, error) {
// func ensureRootPagesRoot()
func daemonize(config appConfig, uid, gid uint, inPlace bool, pagesRoot string) error {
+ // ensure pagesRoot is an absolute path
+ pagesRoot, err := filepath.Abs(pagesRoot)
+ if err != nil {
+ return err
+ }
+
log.WithFields(log.Fields{
- "uid": uid,
- "gid": gid,
- "in-place": inPlace,
+ "uid": uid,
+ "gid": gid,
+ "in-place": inPlace,
+ "pages-root": pagesRoot,
}).Info("running the daemon as unprivileged user")
cmd, err := daemonReexec(uid, gid, daemonRunProgram)
diff --git a/internal/jail/jail.go b/internal/jail/jail.go
index 13b39374..13c6c76d 100644
--- a/internal/jail/jail.go
+++ b/internal/jail/jail.go
@@ -78,7 +78,7 @@ func (j *Jail) Build() error {
}
for _, dir := range j.directories {
- if err := os.Mkdir(dir.path, dir.mode); err != nil {
+ if err := os.MkdirAll(dir.path, dir.mode); err != nil {
j.removeAll()
return fmt.Errorf("can't create directory %q. %s", dir.path, err)
}
diff --git a/internal/jail/jail_test.go b/internal/jail/jail_test.go
index 75150da3..ed52c39b 100644
--- a/internal/jail/jail_test.go
+++ b/internal/jail/jail_test.go
@@ -160,9 +160,8 @@ func TestJailWithFiles(t *testing.T) {
directories: []string{"/tmp", "/tmp/foo", "/bar"},
},
{
- name: "Missing direcories in path",
+ name: "Missing directories in path creates them",
directories: []string{"/tmp/foo/bar"},
- error: true,
},
{
name: "copy /etc/resolv.conf",