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

gitlab.com/gitlab-org/gitaly.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames Fargher <jfargher@gitlab.com>2023-02-07 06:38:49 +0300
committerJames Fargher <jfargher@gitlab.com>2023-02-08 22:50:38 +0300
commit5cf02f580e6eafb00c93631803d9627e6a579e83 (patch)
tree8675c12376a25ee2a42fcbec12f9bbccc3d777dc /internal/streamcache
parent3060313e355e2fe711f6964a44ae5335fb68a76c (diff)
Extract file and executable permissions
Bulk update all file and executable permissions to use the new perm package. Strictly speaking changing os.ModePerm to perm.PublicFile is a permission change (it goes from executable to normal), but since ModePerm is only used in tests this should be safe.
Diffstat (limited to 'internal/streamcache')
-rw-r--r--internal/streamcache/cache_test.go6
-rw-r--r--internal/streamcache/filestore.go2
-rw-r--r--internal/streamcache/filestore_test.go4
3 files changed, 6 insertions, 6 deletions
diff --git a/internal/streamcache/cache_test.go b/internal/streamcache/cache_test.go
index 46aab75b9..9a2bb3603 100644
--- a/internal/streamcache/cache_test.go
+++ b/internal/streamcache/cache_test.go
@@ -377,7 +377,7 @@ func TestCache_unWriteableFile(t *testing.T) {
defer c.Stop()
c.(*cache).createFile = func() (namedWriteCloser, error) {
- return os.OpenFile(filepath.Join(tmp, "unwriteable"), os.O_RDONLY|os.O_CREATE|os.O_EXCL, 0o644)
+ return os.OpenFile(filepath.Join(tmp, "unwriteable"), os.O_RDONLY|os.O_CREATE|os.O_EXCL, perm.SharedFile)
}
r, created, err := c.FindOrCreate("key", func(w io.Writer) error {
@@ -404,7 +404,7 @@ func TestCache_unCloseableFile(t *testing.T) {
defer c.Stop()
c.(*cache).createFile = func() (namedWriteCloser, error) {
- f, err := os.OpenFile(filepath.Join(tmp, "uncloseable"), os.O_WRONLY|os.O_CREATE|os.O_EXCL, 0o644)
+ f, err := os.OpenFile(filepath.Join(tmp, "uncloseable"), os.O_WRONLY|os.O_CREATE|os.O_EXCL, perm.SharedFile)
if err != nil {
return nil, err
}
@@ -430,7 +430,7 @@ func TestCache_cannotOpenFileForReading(t *testing.T) {
defer c.Stop()
c.(*cache).createFile = func() (namedWriteCloser, error) {
- f, err := os.OpenFile(filepath.Join(tmp, "unopenable"), os.O_WRONLY|os.O_CREATE|os.O_EXCL, 0o644)
+ f, err := os.OpenFile(filepath.Join(tmp, "unopenable"), os.O_WRONLY|os.O_CREATE|os.O_EXCL, perm.SharedFile)
if err != nil {
return nil, err
}
diff --git a/internal/streamcache/filestore.go b/internal/streamcache/filestore.go
index acb756dab..03b623320 100644
--- a/internal/streamcache/filestore.go
+++ b/internal/streamcache/filestore.go
@@ -111,7 +111,7 @@ func (fs *filestore) Create() (namedWriteCloser, error) {
return nil, fmt.Errorf("Create: mkdir: %w", err)
}
- f, err := os.OpenFile(path, os.O_WRONLY|os.O_CREATE|os.O_EXCL, 0o644)
+ f, err := os.OpenFile(path, os.O_WRONLY|os.O_CREATE|os.O_EXCL, perm.SharedFile)
if err != nil {
return nil, fmt.Errorf("Create: %w", err)
}
diff --git a/internal/streamcache/filestore_test.go b/internal/streamcache/filestore_test.go
index adcae98d6..cad141872 100644
--- a/internal/streamcache/filestore_test.go
+++ b/internal/streamcache/filestore_test.go
@@ -110,7 +110,7 @@ func TestFilestoreCleanwalk(t *testing.T) {
file := filepath.Join(dir2, "file")
require.NoError(t, os.Mkdir(dir1, perm.SharedDir))
require.NoError(t, os.Mkdir(dir2, perm.SharedDir))
- require.NoError(t, os.WriteFile(file, nil, 0o644))
+ require.NoError(t, os.WriteFile(file, nil, perm.SharedFile))
require.NoError(t, os.Chmod(dir2, 0), "create dir with pathological permissions")
require.NoError(t, fs.cleanWalk(time.Now().Add(time.Hour)))
@@ -119,7 +119,7 @@ func TestFilestoreCleanwalk(t *testing.T) {
fi, err := os.Stat(d)
require.NoError(t, err, "directories do not get deleted")
- const mask = 0o700
+ const mask = perm.PrivateExecutable
require.True(t, fi.Mode()&mask >= mask, "unexpected file mode %o", fi.Mode())
}