Skip to content

Commit f95fca0

Browse files
committed
btrfs: reduce permissions on plugin directories
Disallow traversal into directories that may contain unpacked or mounted image filesystems. Signed-off-by: Derek McGowan <[email protected]> Signed-off-by: Samuel Karp <[email protected]> (cherry picked from commit 7c621e1)
1 parent 68119b4 commit f95fca0

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

snapshots/btrfs/btrfs.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,15 @@ type snapshotter struct {
5050
// root needs to be a mount point of btrfs.
5151
func NewSnapshotter(root string) (snapshots.Snapshotter, error) {
5252
// If directory does not exist, create it
53-
if _, err := os.Stat(root); err != nil {
53+
if st, err := os.Stat(root); err != nil {
5454
if !os.IsNotExist(err) {
5555
return nil, err
5656
}
57-
if err := os.Mkdir(root, 0755); err != nil {
57+
if err := os.Mkdir(root, 0700); err != nil {
58+
return nil, err
59+
}
60+
} else if st.Mode()&os.ModePerm != 0700 {
61+
if err := os.Chmod(root, 0700); err != nil {
5862
return nil, err
5963
}
6064
}

0 commit comments

Comments
 (0)