X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/64d66bca9b9816d0ff025fbee91d04b1d7211f13..02d7f4e820b65d83a5e3709dc14b6d72b9f5ab49:/services/crunch-run/git_mount.go diff --git a/services/crunch-run/git_mount.go b/services/crunch-run/git_mount.go index eacfdec918..c312a532e4 100644 --- a/services/crunch-run/git_mount.go +++ b/services/crunch-run/git_mount.go @@ -1,12 +1,18 @@ +// Copyright (C) The Arvados Authors. All rights reserved. +// +// SPDX-License-Identifier: AGPL-3.0 + package main import ( "fmt" "net/url" + "os" + "path/filepath" "regexp" "git.curoverse.com/arvados.git/sdk/go/arvados" - "gopkg.in/src-d/go-billy.v3/osfs" + "gopkg.in/src-d/go-billy.v4/osfs" git "gopkg.in/src-d/go-git.v4" git_config "gopkg.in/src-d/go-git.v4/config" git_plumbing "gopkg.in/src-d/go-git.v4/plumbing" @@ -34,6 +40,9 @@ func (gm gitMount) validate() error { if !repoUUIDre.MatchString(gm.UUID) { return fmt.Errorf("cannot mount git_tree with uuid %q -- must be a repository UUID", gm.UUID) } + if gm.Writable { + return fmt.Errorf("writable git_tree mount is not supported") + } return nil } @@ -73,7 +82,10 @@ func (gm gitMount) extractTree(ac IArvadosClient, dir string, token string) erro } err = repo.Fetch(&git.FetchOptions{ RemoteName: "origin", - Auth: git_http.NewBasicAuth("none", token), + Auth: &git_http.BasicAuth{ + Username: "none", + Password: token, + }, }) if err != nil { return fmt.Errorf("git fetch %q: %s", u.String(), err) @@ -88,5 +100,18 @@ func (gm gitMount) extractTree(ac IArvadosClient, dir string, token string) erro if err != nil { return fmt.Errorf("checkout failed: %s", err) } + err = filepath.Walk(dir, func(path string, info os.FileInfo, err error) error { + if err != nil { + return err + } + // copy user rx bits to group and other, in case + // prevailing umask is more restrictive than 022 + mode := info.Mode() + mode = mode | ((mode >> 3) & 050) | ((mode >> 6) & 5) + return os.Chmod(path, mode) + }) + if err != nil { + return fmt.Errorf("chmod -R %q: %s", dir, err) + } return nil }