Skip to content

Commit

Permalink
Also lock down backup and restore directories
Browse files Browse the repository at this point in the history
This constricts from an os.ModePerm, which is 0777 down to 0770,
similarly just dropping the world bits.

Signed-off-by: Matt Robenolt <matt@ydekproductions.com>
  • Loading branch information
mattrobenolt committed Jan 29, 2025
1 parent 851c238 commit af6e1be
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion go/vt/mysqlctl/builtinbackupengine.go
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ func (fe *FileEntry) open(cnf *Mycnf, readOnly bool) (*os.File, error) {
}
} else {
dir := path.Dir(name)
if err := os.MkdirAll(dir, os.ModePerm); err != nil {
if err := os.MkdirAll(dir, 0770); err != nil {
return nil, vterrors.Wrapf(err, "cannot create destination directory %v", dir)
}
if fd, err = os2.Create(name); err != nil {
Expand Down
4 changes: 2 additions & 2 deletions go/vt/mysqlctl/filebackupstorage/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,13 +173,13 @@ func (fbs *FileBackupStorage) ListBackups(ctx context.Context, dir string) ([]ba
func (fbs *FileBackupStorage) StartBackup(ctx context.Context, dir, name string) (backupstorage.BackupHandle, error) {
// Make sure the directory exists.
p := path.Join(FileBackupStorageRoot, dir)
if err := os.MkdirAll(p, os.ModePerm); err != nil {
if err := os.MkdirAll(p, 0770); err != nil {
return nil, err
}

// Create the subdirectory for this named backup.
p = path.Join(p, name)
if err := os.Mkdir(p, os.ModePerm); err != nil {
if err := os.Mkdir(p, 0770); err != nil {
return nil, err
}

Expand Down

0 comments on commit af6e1be

Please sign in to comment.