Pull request: all: rework file perms

Updates #3198.

Squashed commit of the following:

commit 3de1ecf4535220cdd769100ef0ea96c166419d12
Author: Ainar Garipov <A.Garipov@AdGuard.COM>
Date:   Fri May 28 18:39:52 2021 +0300

    all: imp chlog

commit f1a46efed917c9b70f047505449a816284d7c71e
Author: Ainar Garipov <A.Garipov@AdGuard.COM>
Date:   Fri May 28 18:13:55 2021 +0300

    all: rework file perms
This commit is contained in:
Ainar Garipov
2021-05-28 18:45:11 +03:00
parent 3be783bd34
commit f3687104dd
3 changed files with 16 additions and 2 deletions

View File

@@ -559,6 +559,15 @@ func (f *Filtering) updateIntl(filter *filter) (updated bool, err error) {
}
}()
// Change the default 0o600 permission to something more acceptable by
// end users.
//
// See https://github.com/AdguardTeam/AdGuardHome/issues/3198.
err = tmpFile.Chmod(0o644)
if err != nil {
return updated, fmt.Errorf("changing file mode: %w", err)
}
var reader io.Reader
if filepath.IsAbs(filter.URL) {
var f io.ReadCloser

View File

@@ -332,7 +332,7 @@ func tarGzFileUnpackOne(outDir string, tr *tar.Reader, hdr *tar.Header) (name st
return "", nil
}
err = os.Mkdir(outputName, os.FileMode(hdr.Mode&0o777))
err = os.Mkdir(outputName, os.FileMode(hdr.Mode&0o755))
if err != nil && !errors.Is(err, os.ErrExist) {
return "", fmt.Errorf("os.Mkdir(%q): %w", outputName, err)
}
@@ -352,7 +352,7 @@ func tarGzFileUnpackOne(outDir string, tr *tar.Reader, hdr *tar.Header) (name st
wc, err = os.OpenFile(
outputName,
os.O_WRONLY|os.O_CREATE|os.O_TRUNC,
os.FileMode(hdr.Mode&0o777),
os.FileMode(hdr.Mode&0o755),
)
if err != nil {
return "", fmt.Errorf("os.OpenFile(%s): %w", outputName, err)