check / check (push) Waiting to run
The passphrase and mnemonic prompts open /dev/tty and ask there, so `echo v | secret add s1 --force`, `secret encrypt` and `secret decrypt` with piped input ask at a terminal instead of failing. Only a process with no controlling terminal still gets the error naming the variable to set. `secret init` and `secret vault create` no longer write a newline to stderr after the mnemonic. On SIGINT or SIGTERM, Entry() restores the settings of /dev/tty instead of stdin, since that is where the prompt turns echo off. The two tests that pin the no-terminal message run the binary in a new session, so it has no terminal wherever the tests run. Unverified by a test: the echo restore after Ctrl-C, checked by hand. Model: opus-5-5
39 lines
1.4 KiB
Go
39 lines
1.4 KiB
Go
// Package secret provides core types and constants for the secret application.
|
|
package secret
|
|
|
|
import "os"
|
|
|
|
const (
|
|
// AppID is the unique identifier for this application
|
|
AppID = "berlin.sneak.pkg.secret"
|
|
|
|
// EnvStateDir is the environment variable for specifying the state directory
|
|
EnvStateDir = "SB_SECRET_STATE_DIR"
|
|
// EnvMnemonic is the environment variable for providing the mnemonic phrase
|
|
EnvMnemonic = "SB_SECRET_MNEMONIC"
|
|
// EnvUnlockPassphrase is the environment variable for providing the unlock passphrase
|
|
//nolint:gosec // G101: env var name, not a credential
|
|
EnvUnlockPassphrase = "SB_UNLOCK_PASSPHRASE"
|
|
// EnvGPGKeyID is the environment variable for providing the GPG key ID
|
|
EnvGPGKeyID = "SB_GPG_KEY_ID"
|
|
|
|
// TerminalPath opens the controlling terminal of the process that opens
|
|
// it, where the passphrase and mnemonic prompts ask.
|
|
TerminalPath = "/dev/tty"
|
|
|
|
// UnlockerTimeFormat is the layout of the time, in UTC, in the name of a
|
|
// new unlocker's directory. It runs to the nanosecond, so that every new
|
|
// unlocker, even one added right after another, gets a directory of its
|
|
// own.
|
|
UnlockerTimeFormat = "2006-01-02.15.04.05.000000000"
|
|
)
|
|
|
|
// File system permission constants
|
|
const (
|
|
// DirPerms is the permission used for directories (read-write-execute for owner only)
|
|
DirPerms os.FileMode = 0o700
|
|
|
|
// FilePerms is the permission used for sensitive files (read-write for owner only)
|
|
FilePerms os.FileMode = 0o600
|
|
)
|