The Proxmox VE Helper Scripts use a modular architecture with multiple function libraries that work together to create and configure LXC containers and VMs.
# File Format: Simple key=value pairs# Purpose: Store global user defaults# Security: Sanitized values, whitelist validation# Comments and blank lines are ignored# Line format: var_name=value# No spaces around the equals sign# String values do not need quoting (but may be quoted)[CONTENT]var_cpu=4var_ram=2048var_disk=20var_hostname=mydefaultvar_brg=vmbr0var_gateway=192.168.1.1
# App-specific defaults for PiHole (pihole)# Generated on 2024-11-28T15:32:00Z# These override user defaults when installing piholevar_unprivileged=1var_cpu=2var_ram=1024var_disk=10var_brg=vmbr0var_net=vethvar_gateway=192.168.1.1var_hostname=piholevar_timezone=Europe/Berlinvar_container_storage=localvar_template_storage=localvar_tags=dns,pihole
When a container is being created, variables are resolved in this order:
Step 1: Read ENVIRONMENT VARIABLES ├─ Check if var_cpu is already set in shell environment ├─ Check if var_ram is already set └─ ...all var_* variablesStep 2: Load APP-SPECIFIC DEFAULTS ├─ Check if /usr/local/community-scripts/defaults/pihole.vars exists ├─ Load all var_* from that file └─ These override built-ins but NOT environment variablesStep 3: Load USER GLOBAL DEFAULTS ├─ Check if /usr/local/community-scripts/default.vars exists ├─ Load all var_* from that file └─ These override built-ins but NOT app-specificStep 4: Use BUILT-IN DEFAULTS └─ Hardcoded in script (lowest priority)
# Only specific variables allowedif ! _is_whitelisted_key "$key"; then skip_this_variablefi# Values sanitizedif ! val="$(_sanitize_value "$value")"; then reject_entire_linefi
2. Safe File Parsing
# ❌ DANGEROUS (OLD)source /path/to/config.conf# Could execute: rm -rf / or any code# ✅ SAFE (NEW)load_vars_file "/path/to/config.conf"# Only reads var_name=value pairs, no execution
# Only these variables can be configuredvar_cpu, var_ram, var_disk, var_brg, ...var_hostname, var_pw, var_ssh, ...# NOT allowed:var_malicious, var_hack, custom_var, ...
Purpose: Remove dangerous characters/patterns from configuration valuesReturns:
0 (success) + sanitized value on stdout
1 (failure) + nothing if dangerous
Dangerous Patterns:
Pattern
Threat
Example
$(...)
Command substitution
$(rm -rf /)
` `
Command substitution
`whoami`
;
Command separator
value; rm -rf /
&
Background execution
value & malicious
<(
Process substitution
<(cat /etc/passwd)
The configuration system uses a whitelist approach combined with value sanitization to prevent code injection attacks. Never use source or eval with user-provided configuration files.