fleet/orbit/pkg/platform/platform_notwindows.go
Tomas Touceda 989e638cc0
Make creating dirs and files more secure by checking permissions (#1566)
* Add safe mkdirall and open

* Use secure as much as possible and merge gomodules for orbit to fleet

* Improve openfile and mkdirall to check for permissiveness instead of equality

* Don't shift

* Fix links

* Address review comments
2021-08-11 11:02:22 -03:00

28 lines
764 B
Go

//+build !windows
package platform
import (
"os"
"github.com/fleetdm/fleet/v4/orbit/pkg/constant"
"github.com/pkg/errors"
)
// ChmodExecutableDirectory sets the appropriate permissions on an executable
// file. On POSIX this is a normal chmod call.
func ChmodExecutableDirectory(path string) error {
if err := os.Chmod(path, constant.DefaultDirMode); err != nil {
return errors.Wrap(err, "chmod executable directory")
}
return nil
}
// ChmodExecutable sets the appropriate permissions on the parent directory of
// an executable file. On POSIX this is a regular chmod call.
func ChmodExecutable(path string) error {
if err := os.Chmod(path, constant.DefaultExecutableMode); err != nil {
return errors.Wrap(err, "chmod executable")
}
return nil
}