certbotbot
Reference documentation for a modular Bash project
Loading...
Searching...
No Matches
Functions | Variables
filename.bash File Reference

Resolves safe archive key templates using released mktext. More...

Functions

int certbotbot_filename_error (String message)
 Reports an untrusted-input failure without echoing its raw value.
 
int certbotbot_filename_date ()
 Obtains one fully validated UTC date and its padded components.
 
int certbotbot_filename_render (String template)
 Lexically renders and validates one single-component tar.gz key.
 
int certbotbot_filename_resolve ()
 Freezes the effective current and optionally requested backup key.
 

Variables

String CERTBOTBOT_BACKUP_KEY
 The validated dated key, empty while backup naming is not requested.
 

Detailed Description

Resolves safe archive key templates using released mktext.

Implements ADR-032 without interpreting user templates as shell code. S3_KEY remains strictly literal. Only an explicitly chosen current template, an explicitly provided backup template, or a future enabled dated backup requires a UTC clock lookup. One validated date is frozen for the call. The renderer receives a caller-owned associative array of nonsecret values. This module never reads, writes, enumerates, or deletes remote objects.

Function Documentation

◆ certbotbot_filename_date()

int certbotbot_filename_date ( )

Obtains one fully validated UTC date and its padded components.

Calls date once, not once per token. The numeric calendar checks guard malformed or replaced date implementations, including invalid leap days. The values are shell-local, never exported or derived from archive data.

STDIN
Nothing is read from STDIN.
STDOUT
Nothing is written to STDOUT.
STDERR
A static diagnostic on failure.
Returns
Date through CERTBOTBOT_FILENAME_DATE/YEAR/MONTH/DOM variables.
Return values
0A consistent UTC snapshot was captured.
64Clock unavailable or date invalid.

◆ certbotbot_filename_error()

int certbotbot_filename_error ( String  message)

Reports an untrusted-input failure without echoing its raw value.

Parameters
messageFixed nonsecret diagnostic text.
STDIN
Nothing is read from STDIN.
STDOUT
Nothing is written to STDOUT.
STDERR
A fixed diagnostic.
Returns
Nothing is written to STDOUT.
Return values
64Invalid filename, date, or rendering configuration.

◆ certbotbot_filename_render()

int certbotbot_filename_render ( String  template)

Lexically renders and validates one single-component tar.gz key.

The template grammar is deliberately narrower than generic mktext: only uppercase exact {YEAR}, {MONTH}, and {DOM} are supported. Replacing accepted macros with safe placeholders before validating the remaining characters rejects unknown macros, brace nesting, paths, whitespace, shell-looking syntax, traversal, and leading punctuation. The final name has separate constraints: 255 ASCII bytes maximum and exact .tar.gz suffix. mktext's single substitution pass never recursively renders values.

Parameters
templateUntrusted operator-specified template.
STDIN
The caller supplies no STDIN; the helper pipes its template to mktext.
STDOUT
Nothing is written to STDOUT.
STDERR
Fixed diagnostics only.
Returns
Validated, rendered key in REPLY.
Return values
0One safe gzip-tar basename produced.
64Unsafe template or unavailable/failed renderer.

◆ certbotbot_filename_resolve()

int certbotbot_filename_resolve ( )

Freezes the effective current and optionally requested backup key.

Ordinary MVP literal keys bypass mktext and clock reads. When needed, the UTC snapshot is computed just once and reused by both templates. The current selected key is replaced before the S3 fetch; the same variable is passed to the publisher later in the invocation. Backup resolution alone never authorizes an extra PutObject.

STDIN
Nothing is read from STDIN.
STDOUT
Nothing is written to STDOUT.
STDERR
Fixed error on unsafe or colliding names.
Returns
Frozen CERTBOTBOT_S3_KEY and optional CERTBOTBOT_BACKUP_KEY.
Return values
0Filename resolution succeeded.
64Date/template/key collision failure before S3.

Variable Documentation

◆ CERTBOTBOT_BACKUP_KEY

CERTBOTBOT_BACKUP_KEY

The validated dated key, empty while backup naming is not requested.

Bash variable: read-write string