forked from go-gitea/gitea
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'upstream/main'
* upstream/main: [skip ci] Updated translations via Crowdin Typo in config-cheat-sheet (go-gitea#21261) Use native inputs in whitespace dropdown (go-gitea#20980) [skip ci] Updated licenses and gitignores Use en-US as fallback when using other default language (go-gitea#21200) Make NuGet service index publicly accessible (go-gitea#21242) Save files in local storage as umask (go-gitea#21198) NPM Package Registry search API endpoint (go-gitea#20280) [skip ci] Updated translations via Crowdin Added search input field to issue filter (go-gitea#20623)
- Loading branch information
Showing
24 changed files
with
407 additions
and
77 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// Copyright 2022 The Gitea Authors. All rights reserved. | ||
// Use of this source code is governed by a MIT-style | ||
// license that can be found in the LICENSE file. | ||
|
||
//go:build !windows | ||
|
||
package util | ||
|
||
import ( | ||
"os" | ||
|
||
"golang.org/x/sys/unix" | ||
) | ||
|
||
var defaultUmask int | ||
|
||
func init() { | ||
// at the moment, the umask could only be gotten by calling unix.Umask(newUmask) | ||
// use 0o077 as temp new umask to reduce the risks if this umask is used anywhere else before the correct umask is recovered | ||
tempUmask := 0o077 | ||
defaultUmask = unix.Umask(tempUmask) | ||
unix.Umask(defaultUmask) | ||
} | ||
|
||
func ApplyUmask(f string, newMode os.FileMode) error { | ||
mod := newMode & ^os.FileMode(defaultUmask) | ||
return os.Chmod(f, mod) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// Copyright 2022 The Gitea Authors. All rights reserved. | ||
// Use of this source code is governed by a MIT-style | ||
// license that can be found in the LICENSE file. | ||
|
||
//go:build !windows | ||
|
||
package util | ||
|
||
import ( | ||
"os" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestApplyUmask(t *testing.T) { | ||
f, err := os.CreateTemp(t.TempDir(), "test-filemode-") | ||
assert.NoError(t, err) | ||
|
||
err = os.Chmod(f.Name(), 0o777) | ||
assert.NoError(t, err) | ||
st, err := os.Stat(f.Name()) | ||
assert.NoError(t, err) | ||
assert.EqualValues(t, 0o777, st.Mode().Perm()&0o777) | ||
|
||
oldDefaultUmask := defaultUmask | ||
defaultUmask = 0o037 | ||
defer func() { | ||
defaultUmask = oldDefaultUmask | ||
}() | ||
err = ApplyUmask(f.Name(), os.ModePerm) | ||
assert.NoError(t, err) | ||
st, err = os.Stat(f.Name()) | ||
assert.NoError(t, err) | ||
assert.EqualValues(t, 0o740, st.Mode().Perm()&0o777) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// Copyright 2022 The Gitea Authors. All rights reserved. | ||
// Use of this source code is governed by a MIT-style | ||
// license that can be found in the LICENSE file. | ||
|
||
//go:build windows | ||
|
||
package util | ||
|
||
import ( | ||
"os" | ||
) | ||
|
||
func ApplyUmask(f string, newMode os.FileMode) error { | ||
// do nothing for Windows, because Windows doesn't use umask | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# Copyright (c) 2006, 2010 Micah Cowan | ||
# | ||
# Redistribution of this program in any form, with or without | ||
# modifications, is permitted, provided that the above copyright is | ||
# retained in distributions of this program in source form. | ||
# | ||
# (This is a free, non-copyleft license compatible with pretty much any | ||
# other free or proprietary license, including the GPL. It's essentially | ||
# a scaled-down version of the "modified" BSD license.) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.