credfile

package
v3.0.0-dev.10 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 20, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package credfile keeps files in one private directory held open as a root: the custody the credential store's file needs, and the one package of this module that names the atomic-file dependency.

Its errors keep the dependency's text, save the mode refusal's, and wrap only this package's sentinels and the platform's errno, never the dependency's values, so nothing a consumer matches with errors.Is or errors.As ties it to that dependency's next major.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNotPrivate is a directory with group or other access or another owner.
	ErrNotPrivate = errors.New("creds: the credential directory is not private to this process")
	// ErrNotSynced is an Open failure that left the directory in place; calling Open
	// again is safe.
	ErrNotSynced = errors.New("creds: the credential directory's parent was not synced; opening it again is safe")
)

Functions

This section is empty.

Types

type Dir

type Dir struct {
	// contains filtered or unexported fields
}

Dir is one private directory under a retained root handle.

func Open

func Open(dir string, logger *slog.Logger) (*Dir, error)

Open establishes custody of one directory level: created at 0700 where absent, refused with ErrNotPrivate where it pre-exists with group or other access or another owner, and then held as a root whose own handle is checked again, because opening the root by name re-resolves the path the custody check vouched for. A failure matching ErrNotSynced leaves the directory in place, and calling Open again is safe. Every call into the dependency carries logger, since the dependency otherwise logs to a sink this library does not own.

func (*Dir) Read

func (d *Dir) Read(ctx context.Context, name string) (data []byte, found bool, err error)

Read answers name's bytes, and false with no error where the directory holds no such file.

func (*Dir) Write

func (d *Dir) Write(ctx context.Context, name string, data []byte) (bool, error)

Write replaces name with data atomically at the private mode and reports whether the write was proved durable. A false with a nil error means the data is at the name and may not survive a crash.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL