securefile

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package securefile creates and checks files that hold secrets: the CLI config, which holds the private key and passphrase in cleartext, and the KeePass export.

Create writes them at 0600 and RepairMode fixes the default config (a --config path is only reported, through Exposure). On Windows a protected ACL granting only the caller, SYSTEM and Administrators replaces 0600. A mode or ACL still loose after tightening, or a file someone else owns, is written anyway and the caller warns through Exposure; only a target that is not a regular file is refused. Where the file is stored is the user's choice; SECURITY.md says which places permissions cannot protect.

securefile_unix.go and securefile_windows.go implement the same platform functions, listed in securefile.go; their helpers live in posixmode and winacl.

The package writes nothing to the terminal, so it can sit below util.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Create

func Create(path string) (_ *os.File, err error)

Create creates or truncates path as a regular file owned by the caller, mode 0600 or its Windows ACL equivalent.

func Exposure

func Exposure(path string) (detail, fix string, exposed bool)

Exposure reports whether others can reach path, how, and the command that fixes it, without touching it. A missing path is not exposed. A file someone else owns has no fix command, since its owner can always undo one: it is reported as "owned by NAME", fix "".

func RepairMode

func RepairMode(path string, mode os.FileMode) error

RepairMode tightens path to mode when anyone but the owner can reach it; a missing path is fine. Only the default config path and its directory reach this.

Types

This section is empty.

Directories

Path Synopsis
Package posixmode holds the permission-bit helpers behind securefile on Unix.
Package posixmode holds the permission-bit helpers behind securefile on Unix.
Package winacl holds the Windows ACL helpers behind securefile: the caller's SIDs, the private descriptor that stands in for 0600, and the check that a DACL exposes nobody else, which reads the DACL through the SDDL parser in sddl.go.
Package winacl holds the Windows ACL helpers behind securefile: the caller's SIDs, the private descriptor that stands in for 0600, and the check that a DACL exposes nobody else, which reads the DACL through the SDDL parser in sddl.go.

Jump to

Keyboard shortcuts

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