privfile

package
v0.222.0 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2026 License: MIT Imports: 8 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package privfile restricts a file that holds secrets to the current user.

On Unix the permission bits (0600) written by the caller already do that and these functions do nothing. On Windows a mode has no effect on the ACL, so the inherited entries are removed and only the current user is granted access (icacls); a failure is an error, never a silently left-open file.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Prepare

func Prepare(path string) error

Prepare gives the current user full control of an EXISTING path, so a file a previous Secure(…, Read) made read-only can be rewritten. Absent files and non-Windows are no-ops.

func Secure

func Secure(path string, access Access) error

Secure removes the inherited ACL entries of path and grants only the current user the given access. A no-op outside Windows.

Types

type Access

type Access string

Access is the right the current user keeps on a secured file (an icacls grant code).

const (
	// Read leaves the owner a read-only file (a private key nobody rewrites in place).
	Read Access = "R"
	// Full leaves the owner full control (a file that is edited or rewritten later).
	Full Access = "F"
)

Jump to

Keyboard shortcuts

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