btrfs: reduce permissions on plugin directories
Disallow traversal into directories that may contain unpacked or mounted image filesystems. Signed-off-by: Derek McGowan <derek@mcg.dev> Signed-off-by: Samuel Karp <skarp@amazon.com>
This commit is contained in:
parent
6886c6a2ec
commit
7c621e1fcc
@ -51,11 +51,15 @@ type snapshotter struct {
|
||||
// root needs to be a mount point of btrfs.
|
||||
func NewSnapshotter(root string) (snapshots.Snapshotter, error) {
|
||||
// If directory does not exist, create it
|
||||
if _, err := os.Stat(root); err != nil {
|
||||
if st, err := os.Stat(root); err != nil {
|
||||
if !os.IsNotExist(err) {
|
||||
return nil, err
|
||||
}
|
||||
if err := os.Mkdir(root, 0755); err != nil {
|
||||
if err := os.Mkdir(root, 0700); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
} else if st.Mode()&os.ModePerm != 0700 {
|
||||
if err := os.Chmod(root, 0700); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user