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

Verifies bounded tar/gzip structure without extracting certificate data. More...

Functions

int certbotbot_tar_block (String source, String offset)
 Loads exactly one 512-byte block from the decoded tar stream.
 
int certbotbot_tar_octal (String start, String width)
 Parses one fixed-width header field as bounded ASCII octal.
 
int certbotbot_tar_text (String start, String width)
 Reads a NUL-terminated printable ASCII header field.
 
int certbotbot_tar_path (String path, String type)
 Enforces the canonical relative Certbot member-name subset.
 
int certbotbot_tar_link (String path, String target)
 Checks the canonical live-to-archive Certbot PEM link relationship.
 
int certbotbot_archive_validate (String archive)
 Checks bounded gzip/tar structure without extracting any data.
 

Variables

IndexedArray CERTBOTBOT_TAR_HEADER
 Numeric byte values for the currently inspected 512-byte block.
 

Detailed Description

Verifies bounded tar/gzip structure without extracting certificate data.

This pre-extraction format gate follows ADR-022. It reads raw 512-byte tar headers using GNU od and Bash 4.3, with no interpreted tar commands. The algorithm rejects unsupported extensions, unsafe paths and links, incomplete gzip streams, and inconsistent archive metadata. Successful format validation never authorizes account use or Certbot execution.

Function Documentation

◆ certbotbot_archive_validate()

int certbotbot_archive_validate ( String  archive)

Checks bounded gzip/tar structure without extracting any data.

A fresh private temporary directory stores the decoded data (maximum 32 MiB), which is inspected at precise tar header offsets. File bodies are skipped according to their validated byte lengths. Unsafe metadata, extensions, duplicates, symlink targets and permissions fail closed. No host Certbot paths, AWS calls, or credential files are accessed here. Temporary decoded data is removed on success and on ordinary failures.

Parameters
archiveReadable, non-symlink local .tar.gz file.
STDIN
Nothing is read from STDIN.
STDOUT
Nothing is written to STDOUT.
STDERR
Fixed safe diagnostics only.
Returns
Nothing is written to STDOUT.
Return values
0Format preflight passed; account and renewal safety not verified.
64Invalid archive argument.
65Archive malformed, oversized or unsupported.

◆ certbotbot_tar_block()

int certbotbot_tar_block ( String  source,
String  offset 
)

Loads exactly one 512-byte block from the decoded tar stream.

Parameters
sourcePath to the private decoded tar file.
offsetZero-based byte offset, divisible by 512.
STDIN
Nothing is read from STDIN.
STDOUT
Nothing is written to STDOUT.
STDERR
Nothing is written to STDERR.
Returns
Nothing is written to STDOUT.
Return values
0Block loaded into CERTBOTBOT_TAR_HEADER.
1Read failed or block was incomplete.

◆ certbotbot_tar_link()

int certbotbot_tar_link ( String  path,
String  target 
)

Checks the canonical live-to-archive Certbot PEM link relationship.

Parameters
pathCanonical live certificate link path.
targetSymbolic link target stored in the header.
STDIN
Nothing is read from STDIN.
STDOUT
Nothing is written to STDOUT.
STDERR
Nothing is written to STDERR.
Returns
Nothing is written to STDOUT.
Return values
0Corresponding regular archive PEM path stored in REPLY.
1Unexpected symlink form or mismatched certificate lineage.

◆ certbotbot_tar_octal()

int certbotbot_tar_octal ( String  start,
String  width 
)

Parses one fixed-width header field as bounded ASCII octal.

Parameters
startZero-based offset within the header.
widthLength of the field in bytes.
STDIN
Nothing is read from STDIN.
STDOUT
Nothing is written to STDOUT.
STDERR
Nothing is written to STDERR.
Returns
Nothing is written to STDOUT.
Return values
0Value stored in REPLY.
1Non-octal or malformed field.

◆ certbotbot_tar_path()

int certbotbot_tar_path ( String  path,
String  type 
)

Enforces the canonical relative Certbot member-name subset.

Parameters
pathRaw tar name, optionally beginning ./.
typeTar type as a numeric ASCII byte.
STDIN
Nothing is read from STDIN.
STDOUT
Nothing is written to STDOUT.
STDERR
Nothing is written to STDERR.
Returns
Nothing is written to STDOUT.
Return values
0Normalized name stored in REPLY.
1Invalid or unsupported path.

◆ certbotbot_tar_text()

int certbotbot_tar_text ( String  start,
String  width 
)

Reads a NUL-terminated printable ASCII header field.

Parameters
startZero-based offset.
widthField length.
STDIN
Nothing is read from STDIN.
STDOUT
Nothing is written to STDOUT.
STDERR
Nothing is written to STDERR.
Returns
Nothing is written to STDOUT.
Return values
0Field stored in REPLY.
1Invalid control byte or non-NUL content after terminator.

Variable Documentation

◆ CERTBOTBOT_TAR_HEADER

CERTBOTBOT_TAR_HEADER

Numeric byte values for the currently inspected 512-byte block.

Bash variable: read-write indexed_array