feat: apply sealed installation plans without interactive setup
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
package safeio
|
||||
|
||||
import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
)
|
||||
|
||||
// PublishCanonicalNewFile durably publishes complete bytes without replacing an existing
|
||||
// target. A crash before publication can leave a private temporary file, never a partial target.
|
||||
func PublishCanonicalNewFile(path string, contents []byte, mode os.FileMode) error {
|
||||
if ValidateCanonicalPath(path) != nil || ValidatePrivateDirectory(filepath.Dir(path)) != nil || (mode != 0o600 && mode != 0o644) {
|
||||
return ErrUnsafeFile
|
||||
}
|
||||
return publishCanonicalNewFile(path, contents, mode)
|
||||
}
|
||||
Reference in New Issue
Block a user