mirror of
https://github.com/community-scripts/ProxmoxVE.git
synced 2026-05-03 23:45:59 +00:00
fix(build): sanitize mount_fs input — strip spaces and trailing commas (#13806)
User input like 'nfs, cifs' or 'nfs,' would produce invalid pct features strings like 'mount=nfs; cifs' (space breaks pct argument parsing) or 'mount=nfs;' (trailing semicolon). Fixes: - Whiptail dialog (Step 27): normalize input immediately after entry - load_vars_file validation: normalize before regex check, use stricter regex that rejects trailing/leading commas - FEATURES construction: defensive sanitize before building the mount= value (strip spaces, trailing commas/semicolons) All three layers ensure 'nfs, cifs' -> 'nfs,cifs' -> 'mount=nfs;cifs'
This commit is contained in:
committed by
GitHub
parent
88264fea10
commit
a5fc040deb
+18
-2
@@ -1211,7 +1211,11 @@ load_vars_file() {
|
|||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
var_mount_fs)
|
var_mount_fs)
|
||||||
if [[ ! "$var_val" =~ ^[a-zA-Z0-9,]+$ ]]; then
|
# Normalize: strip spaces, trailing commas
|
||||||
|
var_val="${var_val// /}"
|
||||||
|
var_val="${var_val%%,}"
|
||||||
|
var_val="${var_val##,}"
|
||||||
|
if [[ -n "$var_val" ]] && [[ ! "$var_val" =~ ^[a-zA-Z0-9]+(,[a-zA-Z0-9]+)*$ ]]; then
|
||||||
msg_warn "Invalid mount_fs value '$var_val' in $file (comma-separated fs names only, e.g. nfs,cifs), ignoring"
|
msg_warn "Invalid mount_fs value '$var_val' in $file (comma-separated fs names only, e.g. nfs,cifs), ignoring"
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
@@ -2668,6 +2672,10 @@ advanced_settings() {
|
|||||||
--ok-button "Next" --cancel-button "Back" \
|
--ok-button "Next" --cancel-button "Back" \
|
||||||
--inputbox "\nAllow specific filesystem mounts.\n\nComma-separated list: nfs, cifs, fuse, ext4, etc.\nLeave empty for defaults (none).\n\nCurrent: $mount_hint" 14 62 "$_mount_fs" \
|
--inputbox "\nAllow specific filesystem mounts.\n\nComma-separated list: nfs, cifs, fuse, ext4, etc.\nLeave empty for defaults (none).\n\nCurrent: $mount_hint" 14 62 "$_mount_fs" \
|
||||||
3>&1 1>&2 2>&3); then
|
3>&1 1>&2 2>&3); then
|
||||||
|
# Normalize: strip spaces and trailing/leading commas
|
||||||
|
result="${result// /}"
|
||||||
|
result="${result%%,}"
|
||||||
|
result="${result##,}"
|
||||||
_mount_fs="$result"
|
_mount_fs="$result"
|
||||||
((STEP++))
|
((STEP++))
|
||||||
else
|
else
|
||||||
@@ -3638,8 +3646,16 @@ build_container() {
|
|||||||
|
|
||||||
# Mount filesystem types (user configurable via advanced settings)
|
# Mount filesystem types (user configurable via advanced settings)
|
||||||
if [ -n "${ALLOW_MOUNT_FS:-}" ]; then
|
if [ -n "${ALLOW_MOUNT_FS:-}" ]; then
|
||||||
|
# Sanitize: strip spaces, trailing/leading commas, then convert commas to semicolons
|
||||||
|
local _mount_clean="${ALLOW_MOUNT_FS// /}"
|
||||||
|
_mount_clean="${_mount_clean%%,}"
|
||||||
|
_mount_clean="${_mount_clean##,}"
|
||||||
|
_mount_clean="${_mount_clean%%;}"
|
||||||
|
_mount_clean="${_mount_clean//,/;}"
|
||||||
|
if [ -n "$_mount_clean" ]; then
|
||||||
[ -n "$FEATURES" ] && FEATURES="$FEATURES,"
|
[ -n "$FEATURES" ] && FEATURES="$FEATURES,"
|
||||||
FEATURES="${FEATURES}mount=${ALLOW_MOUNT_FS//,/;}"
|
FEATURES="${FEATURES}mount=${_mount_clean}"
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Build PCT_OPTIONS as string for export
|
# Build PCT_OPTIONS as string for export
|
||||||
|
|||||||
Reference in New Issue
Block a user