diff options
| author | Dmitry Vyukov <dvyukov@google.com> | 2017-07-03 14:00:47 +0200 |
|---|---|---|
| committer | Dmitry Vyukov <dvyukov@google.com> | 2017-07-03 14:00:47 +0200 |
| commit | a7b199253f7a517fd62f36a5d632efee3bac737e (patch) | |
| tree | 9f981ff2814ed7389e973c02376f8b2618224be2 /pkg/db/db.go | |
| parent | 1438a6de8130467a2fcde187ba80b8a616f8daa0 (diff) | |
all: use consistent file permissions
Currently we have unix permissions for new files/dirs
hardcoded throughout the code base. Some places use 0644,
some - 0640, some - 0600 and a variety of other constants.
Introduce osutil.MkdirAll/WriteFile that use the default
permissions and use them throughout the code base.
This makes permissions consistent and also allows to easily
change the permissions later if we change our minds.
Also merge pkg/fileutil into pkg/osutil as they become
dependent on each other. The line between them was poorly
defined anyway as both operate on files.
Diffstat (limited to 'pkg/db/db.go')
| -rw-r--r-- | pkg/db/db.go | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/pkg/db/db.go b/pkg/db/db.go index 0277cb3d1..1ab76a29d 100644 --- a/pkg/db/db.go +++ b/pkg/db/db.go @@ -19,6 +19,7 @@ import ( "os" . "github.com/google/syzkaller/pkg/log" + "github.com/google/syzkaller/pkg/osutil" ) type DB struct { @@ -38,7 +39,7 @@ func Open(filename string) (*DB, error) { db := &DB{ filename: filename, } - f, err := os.OpenFile(db.filename, os.O_RDONLY|os.O_CREATE, 0640) + f, err := os.OpenFile(db.filename, os.O_RDONLY|os.O_CREATE, osutil.DefaultFilePerm) if err != nil { return nil, err } @@ -79,7 +80,7 @@ func (db *DB) Flush() error { if db.pending == nil { return nil } - f, err := os.OpenFile(db.filename, os.O_WRONLY|os.O_APPEND|os.O_CREATE, 0640) + f, err := os.OpenFile(db.filename, os.O_WRONLY|os.O_APPEND|os.O_CREATE, osutil.DefaultFilePerm) if err != nil { return err } |
