From 46c11ff7c08dc943c18017d6f63a8f9b039e1b3f Mon Sep 17 00:00:00 2001 From: Alexandre <44178713+alexbelgium@users.noreply.github.com> Date: Wed, 24 Sep 2025 14:52:25 +0200 Subject: [PATCH] Fix SMBv1 fallback when validating network shares --- .templates/00-smb_mounts.sh | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/.templates/00-smb_mounts.sh b/.templates/00-smb_mounts.sh index 25df7f132..205600a66 100755 --- a/.templates/00-smb_mounts.sh +++ b/.templates/00-smb_mounts.sh @@ -152,6 +152,8 @@ if bashio::config.has_value 'networkdisks'; then diskname="${diskname//\\//}" # replace \ with / diskname="${diskname##*/}" # Get only last part of the name MOUNTED=false + SMBVERS_FORCE="" + SECVERS_FORCE="" # Start echo "... mounting ($FSTYPE) $disk" @@ -216,9 +218,15 @@ if bashio::config.has_value 'networkdisks'; then continue elif echo "$OUTPUT" | grep -q "tree connect failed" || echo "$OUTPUT" | grep -q "NT_STATUS_CONNECTION_DISCONNECTED"; then echo "... testing path" - bashio::log.fatal "...... invalid or inaccessible SMB path. Script will stop." - touch ERRORCODE - continue + if smbclient -t 2 "$disk" -m NT1 -U "$USERNAME%$PASSWORD" -c "exit" $DOMAINCLIENT &> /dev/null; then + bashio::log.warning "...... share reachable only with legacy SMBv1 (NT1) negotiation. Forcing SMBv1 options." + SMBVERS_FORCE=",vers=1.0" + SECVERS_FORCE=",sec=ntlm" + else + bashio::log.fatal "...... invalid or inaccessible SMB path. Script will stop." + touch ERRORCODE + continue + fi elif ! echo "$OUTPUT" | grep -q "Disk"; then echo "... testing path" bashio::log.fatal "...... no shares found. Invalid or inaccessible SMB path?" @@ -262,6 +270,16 @@ if bashio::config.has_value 'networkdisks'; then SMBVERS="" fi + # Apply forced SMBv1 options when initial connection required NT1 fallback + if [[ -n "$SMBVERS_FORCE" ]]; then + if [[ -z "$SMBVERS" ]]; then + SMBVERS="$SMBVERS_FORCE" + fi + if [[ -z "$SECVERS" ]]; then + SECVERS="$SECVERS_FORCE" + fi + fi + # Test with different security versions ####################################### for SECVERS in "$SECVERS" ",sec=ntlmv2" ",sec=ntlmssp" ",sec=ntlmsspi" ",sec=krb5i" ",sec=krb5" ",sec=ntlm" ",sec=ntlmv2i"; do