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

Creates private workspaces and stages validated Certbot archives. More...

Functions

int certbotbot_workspace_create ()
 Creates a new owned 0700 workspace on the local filesystem.
 
int certbotbot_archive_restore (String archive, String workspace)
 Restores supported archive bytes into an inactive config directory.
 

Detailed Description

Creates private workspaces and stages validated Certbot archives.

This adapter implements the inactive restoration boundary in ADR-022. It never extracts into the host's /etc/letsencrypt directory, evaluates restored content, calls Certbot, or accesses S3. A preflighted archive is copied into a new private staging directory before GNU tar sees its bytes. The orchestrator owns removal of the workspace after the full operation.

Function Documentation

◆ certbotbot_archive_restore()

int certbotbot_archive_restore ( String  archive,
String  workspace 
)

Restores supported archive bytes into an inactive config directory.

Accepts an owned, canonical, empty-target workspace with mode 0700. Copies the archive into a fresh 0700 child, validates that precise copy before extraction, and extracts it under an inactive staging root with GNU tar without stored ownership. Since archive validation has already rejected group/world-writable and unsafe member modes, safe original file/directory permissions are retained inside the private staging tree instead of being silently narrowed by the caller's umask on each restore/republication. This preserves unselected lineages' permission metadata under ADR-030. On success, a rename installs the staging directory at WORKSPACE/config; on any error only adapter-owned staging is removed. The workspace and unrelated files are preserved. No secret data or untrusted tar error text is printed.

The format validator accepts only constrained member types and links. The extractor confirms the resulting filesystem contains only regular files, directories, and resolvable symlinks, and no group/world-writable data. Caller must still verify registered ACME account and renewal configuration (including execution hooks and path remapping).

Parameters
archiveReadable non-symlink archive path.
workspaceCanonical new absolute directory, owned and mode 0700.
STDIN
Nothing is read from STDIN.
STDOUT
Nothing is written to STDOUT.
STDERR
Fixed safe diagnostics; tar output is suppressed.
Returns
Nothing is written to STDOUT.
Return values
0An isolated WORKSPACE/config directory was prepared.
64Invalid workspace, arguments, or existing target.
65Archive failed format or post-extraction checks.
74Local extraction or staging failed.
Examples
certbotbot_archive_restore "$workspace/downloaded.tar.gz" "$workspace" ||
exit $?
# Verify account, hooks, and canonical renewal path mapping next.
int certbotbot_archive_restore(String archive, String workspace)
Restores supported archive bytes into an inactive config directory.

◆ certbotbot_workspace_create()

int certbotbot_workspace_create ( )

Creates a new owned 0700 workspace on the local filesystem.

A fresh directory is allocated using mktemp, with a private umask. Ownership and final lifecycle cleanup belong to the invoking process. This helper does not delete any previously created workspace.

STDIN
Nothing is read from STDIN.
STDOUT
One absolute workspace pathname followed by a newline on success.
STDERR
A fixed diagnostic on failure.
Returns
An absolute pathname to one new private workspace.
Return values
0The private workspace was created.
74A private workspace could not be allocated.
Examples
workspace="$(certbotbot_workspace_create)" || exit $?
# The caller must delete only its owned workspace when finished.