Documentation
¶
Index ¶
- Constants
- Variables
- type File
- func (f *File) Commit(data []byte, mode os.FileMode) error
- func (f *File) ContainsAny(markers ...string) (bool, error)
- func (f *File) EnsureParent() error
- func (f *File) Location() string
- func (f *File) MetadataSecure(want os.FileMode) (bool, error)
- func (f *File) OpenLock() (*os.File, error)
- func (f *File) ParentPresent() (bool, error)
- func (f *File) ProbeWritable(mode os.FileMode) error
- func (f *File) PurgeBackups() error
- func (f *File) Read() ([]byte, bool, os.FileMode, error)
- func (f *File) RelativePath() string
- func (f *File) Remove() error
- func (f *File) RequireResolvedPath(expected string) error
- func (f *File) ResolvedPath() (string, error)
- func (f *File) RestoreSnapshot() error
- type Home
- func (h *Home) ApplyMetadata(file *os.File, mode os.FileMode, directory bool) error
- func (h *Home) Close() error
- func (h *Home) EnsureParent(relativePath string) error
- func (h *Home) GOOS() string
- func (h *Home) Getenv(name string) string
- func (h *Home) MetadataSecure(file *os.File, want os.FileMode) (bool, error)
- func (h *Home) Open(relativePath, backupPrefix string, maxBytes int64) (*File, error)
- func (h *Home) Path() string
- func (h *Home) User() *user.User
- func (h *Home) Username() string
- func (h *Home) VerifyOwner(f *os.File, name string) error
Constants ¶
const ( MaxBytes = 1 << 20 FileMode = os.FileMode(0o600) ParentMode = os.FileMode(0o700) )
Variables ¶
var ( ErrTargetUnusable = errors.New("secure user file: target unusable") ErrNoTargetUser = errors.New("secure user file: no enforceable target user") ErrAbsoluteSymlink = fmt.Errorf("secure user file: absolute symlink: %w", ErrTargetUnusable) ErrSymlinkLoop = fmt.Errorf("secure user file: symlink chain too deep: %w", ErrTargetUnusable) ErrDanglingSymlink = fmt.Errorf("secure user file: symlink target does not exist: %w", ErrTargetUnusable) ErrWriteUnverified = errors.New("secure user file: write could not be verified or rolled back") )
Functions ¶
This section is empty.
Types ¶
type File ¶
type File struct {
// contains filtered or unexported fields
}
File owns safe byte and metadata operations for one relative path.
func (*File) ContainsAny ¶
ContainsAny reports whether a bounded, identity-checked leaf contains any marker without requiring mutation ownership of that leaf.
func (*File) EnsureParent ¶
EnsureParent creates and pins this file's parent directories.
func (*File) MetadataSecure ¶
MetadataSecure verifies the current leaf's platform permission boundary.
func (*File) ParentPresent ¶
ParentPresent reports whether every parent is an existing real directory.
func (*File) ProbeWritable ¶
ProbeWritable verifies that a secure temporary sibling can be created and removed without changing the managed leaf.
func (*File) PurgeBackups ¶
func (*File) RelativePath ¶
RelativePath returns the cleaned path beneath the pinned home.
func (*File) RequireResolvedPath ¶
RequireResolvedPath pins future operations to a previously recorded leaf.
func (*File) ResolvedPath ¶
ResolvedPath returns the normalized home-relative leaf used by the latest successful mutation, or the leaf currently selected by the symlink chain.
func (*File) RestoreSnapshot ¶
type Home ¶
type Home struct {
// contains filtered or unexported fields
}
Home pins all managed file operations beneath one resolved user's home.
func (*Home) ApplyMetadata ¶
ApplyMetadata applies the platform's target-user ownership and permission contract to an already-open file or directory.
func (*Home) EnsureParent ¶
EnsureParent creates missing parent components without traversing symlinks.
func (*Home) MetadataSecure ¶
MetadataSecure verifies the platform permission boundary on an open handle.