mirror of
https://github.com/alexbelgium/hassio-addons.git
synced 2026-01-09 17:31:03 +01:00
Fix SMBv1 fallback when validating network shares
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user