-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replace uses of os.Create with os2.Create within backup/restore workf…
…lows This abstracts this ever so slightly into a new `os2.Create` to replace usages of `os.Create` across packages. I didn't want to address every single use of `os.Create` within this PR, but ideally we'd review other uses and swap them to use this version. This prevents files from being created and written with world read/write privileges. I strongly don't think any of these cases, that behavior was intentional, rather implicit due to using `os.Create` which internally uses 0666 permissions. Fixes #17647 Signed-off-by: Matt Robenolt <[email protected]>
- Loading branch information
1 parent
9c6c380
commit 851c238
Showing
5 changed files
with
33 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/* | ||
Copyright 2025 The Vitess Authors. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package os2 | ||
|
||
import "os" | ||
|
||
// Create is identical to os.Create except uses 0660 permission | ||
// rather than 0666, to exclude world read/write bit. | ||
func Create(name string) (*os.File, error) { | ||
return os.OpenFile(name, os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0660) | ||
} |
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