From 26e277768f95d5636af9e8f480c2dd29d31ddb37 Mon Sep 17 00:00:00 2001 From: Pudong Zheng Date: Thu, 17 Feb 2022 18:35:40 +0000 Subject: [PATCH] Fix dotfiles permission --- components/supervisor/pkg/supervisor/supervisor.go | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/components/supervisor/pkg/supervisor/supervisor.go b/components/supervisor/pkg/supervisor/supervisor.go index 91f121d415767e..a7816dce5844f7 100644 --- a/components/supervisor/pkg/supervisor/supervisor.go +++ b/components/supervisor/pkg/supervisor/supervisor.go @@ -44,7 +44,6 @@ import ( "github.com/gitpod-io/gitpod/common-go/analytics" "github.com/gitpod-io/gitpod/common-go/log" "github.com/gitpod-io/gitpod/common-go/pprof" - "github.com/gitpod-io/gitpod/common-go/process" csapi "github.com/gitpod-io/gitpod/content-service/api" "github.com/gitpod-io/gitpod/content-service/pkg/executor" "github.com/gitpod-io/gitpod/content-service/pkg/git" @@ -429,7 +428,7 @@ func installDotfiles(ctx context.Context, cfg *Config, tokenService *InMemoryTok client := &git.Client{ AuthProvider: authProvider, AuthMethod: git.BasicAuth, - Location: "/home/gitpod/.dotfiles", + Location: dotfilePath, RemoteURI: repo, } done <- client.Clone(ctx) @@ -444,6 +443,13 @@ func installDotfiles(ctx context.Context, cfg *Config, tokenService *InMemoryTok return xerrors.Errorf("dotfiles repo clone did not finish within two minutes") } + filepath.Walk(dotfilePath, func(name string, info os.FileInfo, err error) error { + if err == nil { + err = os.Chown(name, gitpodUID, gitpodGID) + } + return err + }) + // at this point we have the dotfile repo cloned, let's try and install it var candidates = []string{ "install.sh", @@ -487,9 +493,7 @@ func installDotfiles(ctx context.Context, cfg *Config, tokenService *InMemoryTok select { case err = <-done: - if err != nil && !process.IsNotChildProcess(err) { - return err - } + return err case <-time.After(120 * time.Second): cmd.Process.Kill() return xerrors.Errorf("installation process %s tool longer than 120 seconds", fn)