From c591203a7028d0844145531863b4dafe0440a175 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 22 Feb 2026 16:52:23 +0000 Subject: [PATCH 2/4] Fix 4 critical issues in SMB/NFS mount script 1. Mountpoint name collisions: check if /mnt/$diskname already exists before mounting and skip with warning if it does 2. test_mount() readonly false positive: verify mountpoint is actually mounted before reporting readonly status 3. Independent retries: save original MOUNTOPTIONS and use as base for each noserverino/noperm retry independently 4. Hostname support: accept hostnames (not just IPv4) in CIFS/NFS path validation, FSTYPE detection, and server extraction Co-authored-by: alexbelgium <44178713+alexbelgium@users.noreply.github.com> --- .templates/00-smb_mounts.sh | 33 ++++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/.templates/00-smb_mounts.sh b/.templates/00-smb_mounts.sh index 0034ff9c2..8ef7ada85 100755 --- a/.templates/00-smb_mounts.sh +++ b/.templates/00-smb_mounts.sh @@ -47,9 +47,11 @@ test_mount() { return 0 fi - if [[ "$FSTYPE" == "cifs" && "$MOUNTOPTIONS" != *"noserverino"* ]]; then + local orig_mountoptions="$MOUNTOPTIONS" + + if [[ "$FSTYPE" == "cifs" && "$orig_mountoptions" != *"noserverino"* ]]; then echo "... retrying mount with noserverino" - MOUNTOPTIONS="${MOUNTOPTIONS},noserverino" + MOUNTOPTIONS="${orig_mountoptions},noserverino" umount "$mountpoint" 2>/dev/null || true if mount_drive "$MOUNTOPTIONS"; then @@ -60,9 +62,9 @@ test_mount() { fi fi - if [[ "$FSTYPE" == "cifs" && "$MOUNTOPTIONS" != *"noperm"* ]]; then + if [[ "$FSTYPE" == "cifs" && "$orig_mountoptions" != *"noperm"* ]]; then echo "... retrying mount with noperm" - MOUNTOPTIONS="${MOUNTOPTIONS},noperm" + MOUNTOPTIONS="${orig_mountoptions},noperm" umount "$mountpoint" 2>/dev/null || true if mount_drive "$MOUNTOPTIONS"; then @@ -73,7 +75,11 @@ test_mount() { fi fi - MOUNTED="readonly" + if mountpoint -q "$mountpoint"; then + MOUNTED="readonly" + else + MOUNTED=false + fi return 0 } @@ -226,12 +232,12 @@ if bashio::config.has_value 'networkdisks'; then if [[ "$disk" =~ ^nfs:// ]]; then FSTYPE="nfs" disk="${disk#nfs://}" - elif [[ "$disk" =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+:/.+ ]]; then + elif [[ "$disk" =~ ^[^/][^:]*:/.+ ]]; then FSTYPE="nfs" fi if [[ "$FSTYPE" == "cifs" ]]; then - server="$(echo "$disk" | grep -E -o "[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+" | head -n 1)" + server="$(echo "$disk" | sed -E 's|^//([^/]+)/.*|\1|')" else server="${disk%%:*}" fi @@ -240,6 +246,11 @@ if bashio::config.has_value 'networkdisks'; then diskname="${diskname//\\//}" diskname="${diskname##*/}" + if [[ -d "/mnt/$diskname" ]]; then + bashio::log.warning "...... mount point /mnt/$diskname already exists (name collision for $disk). Skipping this share." + continue + fi + ERRORCODE_FILE="/tmp/mount_error_${diskname//[^a-zA-Z0-9._-]/_}.log" : >"$ERRORCODE_FILE" || true @@ -253,14 +264,14 @@ if bashio::config.has_value 'networkdisks'; then echo "... mounting ($FSTYPE) $disk" if [[ "$FSTYPE" == "cifs" ]]; then - if [[ ! "$disk" =~ ^//[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+/.+ ]]; then - bashio::log.fatal "...... invalid CIFS path \"$disk\". Use //123.12.12.12/sharedfolder,//123.12.12.12/sharedfolder2" + if [[ ! "$disk" =~ ^//[^/]+/.+ ]]; then + bashio::log.fatal "...... invalid CIFS path \"$disk\". Use //server/sharedfolder or //123.12.12.12/sharedfolder" echo "Invalid CIFS path structure: $disk" >"$ERRORCODE_FILE" || true continue fi else - if [[ ! "$disk" =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+:/.+ ]]; then - bashio::log.fatal "...... invalid NFS path \"$disk\". Use 123.12.12.12:/export/path" + if [[ ! "$disk" =~ ^[^:]+:/.+ ]]; then + bashio::log.fatal "...... invalid NFS path \"$disk\". Use server:/export/path or 123.12.12.12:/export/path" echo "Invalid NFS path structure: $disk" >"$ERRORCODE_FILE" || true continue fi From 367410d2b75e9e62e7814a88f6e4891733ce3d45 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 22 Feb 2026 16:53:18 +0000 Subject: [PATCH 3/4] Address code review: use mountpoint -q for collision check, tighten NFS regex Co-authored-by: alexbelgium <44178713+alexbelgium@users.noreply.github.com> --- .templates/00-smb_mounts.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.templates/00-smb_mounts.sh b/.templates/00-smb_mounts.sh index 8ef7ada85..f31693e43 100755 --- a/.templates/00-smb_mounts.sh +++ b/.templates/00-smb_mounts.sh @@ -232,7 +232,7 @@ if bashio::config.has_value 'networkdisks'; then if [[ "$disk" =~ ^nfs:// ]]; then FSTYPE="nfs" disk="${disk#nfs://}" - elif [[ "$disk" =~ ^[^/][^:]*:/.+ ]]; then + elif [[ "$disk" =~ ^[^/:]+:/.+ ]]; then FSTYPE="nfs" fi @@ -246,8 +246,8 @@ if bashio::config.has_value 'networkdisks'; then diskname="${diskname//\\//}" diskname="${diskname##*/}" - if [[ -d "/mnt/$diskname" ]]; then - bashio::log.warning "...... mount point /mnt/$diskname already exists (name collision for $disk). Skipping this share." + if mountpoint -q "/mnt/$diskname" 2>/dev/null; then + bashio::log.warning "...... mount point /mnt/$diskname already in use (name collision for $disk). Skipping this share." continue fi @@ -270,7 +270,7 @@ if bashio::config.has_value 'networkdisks'; then continue fi else - if [[ ! "$disk" =~ ^[^:]+:/.+ ]]; then + if [[ ! "$disk" =~ ^[^/:]+:/.+ ]]; then bashio::log.fatal "...... invalid NFS path \"$disk\". Use server:/export/path or 123.12.12.12:/export/path" echo "Invalid NFS path structure: $disk" >"$ERRORCODE_FILE" || true continue From 89b4cdebef2c16ed52baabd333bad8742d8de04e Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 22 Feb 2026 16:58:07 +0000 Subject: [PATCH 4/4] Revert CIFS path validation to IP-only per maintainer request Co-authored-by: alexbelgium <44178713+alexbelgium@users.noreply.github.com> --- .templates/00-smb_mounts.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.templates/00-smb_mounts.sh b/.templates/00-smb_mounts.sh index f31693e43..50d902710 100755 --- a/.templates/00-smb_mounts.sh +++ b/.templates/00-smb_mounts.sh @@ -237,7 +237,7 @@ if bashio::config.has_value 'networkdisks'; then fi if [[ "$FSTYPE" == "cifs" ]]; then - server="$(echo "$disk" | sed -E 's|^//([^/]+)/.*|\1|')" + server="$(echo "$disk" | grep -E -o "[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+" | head -n 1)" else server="${disk%%:*}" fi @@ -264,8 +264,8 @@ if bashio::config.has_value 'networkdisks'; then echo "... mounting ($FSTYPE) $disk" if [[ "$FSTYPE" == "cifs" ]]; then - if [[ ! "$disk" =~ ^//[^/]+/.+ ]]; then - bashio::log.fatal "...... invalid CIFS path \"$disk\". Use //server/sharedfolder or //123.12.12.12/sharedfolder" + if [[ ! "$disk" =~ ^//[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+/.+ ]]; then + bashio::log.fatal "...... invalid CIFS path \"$disk\". Use //123.12.12.12/sharedfolder,//123.12.12.12/sharedfolder2" echo "Invalid CIFS path structure: $disk" >"$ERRORCODE_FILE" || true continue fi