in credentialproviderpackage/pkg/configurator/linux/linux.go [155:183]
func copyWithPermissons(srcpath, dstpath string, permission os.FileMode) (err error) {
r, err := os.Open(srcpath)
if err != nil {
return err
}
defer r.Close() // ok to ignore error: file was opened read-only.
w, err := os.Create(dstpath)
if err != nil {
return err
}
defer func() {
c := w.Close()
// Report the error from Close, if any.
// But do so only if there isn't already
// an outgoing error.
if c != nil && err == nil {
err = c
}
}()
_, err = io.Copy(w, r)
if err != nil {
return err
}
err = os.Chmod(dstpath, permission)
return err
}