mirror of
https://github.com/alexbelgium/hassio-addons.git
synced 2026-06-19 05:49:12 +02: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//\\//}" # replace \ with /
|
||||||
diskname="${diskname##*/}" # Get only last part of the name
|
diskname="${diskname##*/}" # Get only last part of the name
|
||||||
MOUNTED=false
|
MOUNTED=false
|
||||||
|
SMBVERS_FORCE=""
|
||||||
|
SECVERS_FORCE=""
|
||||||
|
|
||||||
# Start
|
# Start
|
||||||
echo "... mounting ($FSTYPE) $disk"
|
echo "... mounting ($FSTYPE) $disk"
|
||||||
@@ -216,9 +218,15 @@ if bashio::config.has_value 'networkdisks'; then
|
|||||||
continue
|
continue
|
||||||
elif echo "$OUTPUT" | grep -q "tree connect failed" || echo "$OUTPUT" | grep -q "NT_STATUS_CONNECTION_DISCONNECTED"; then
|
elif echo "$OUTPUT" | grep -q "tree connect failed" || echo "$OUTPUT" | grep -q "NT_STATUS_CONNECTION_DISCONNECTED"; then
|
||||||
echo "... testing path"
|
echo "... testing path"
|
||||||
bashio::log.fatal "...... invalid or inaccessible SMB path. Script will stop."
|
if smbclient -t 2 "$disk" -m NT1 -U "$USERNAME%$PASSWORD" -c "exit" $DOMAINCLIENT &> /dev/null; then
|
||||||
touch ERRORCODE
|
bashio::log.warning "...... share reachable only with legacy SMBv1 (NT1) negotiation. Forcing SMBv1 options."
|
||||||
continue
|
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
|
elif ! echo "$OUTPUT" | grep -q "Disk"; then
|
||||||
echo "... testing path"
|
echo "... testing path"
|
||||||
bashio::log.fatal "...... no shares found. Invalid or inaccessible SMB path?"
|
bashio::log.fatal "...... no shares found. Invalid or inaccessible SMB path?"
|
||||||
@@ -262,6 +270,16 @@ if bashio::config.has_value 'networkdisks'; then
|
|||||||
SMBVERS=""
|
SMBVERS=""
|
||||||
fi
|
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
|
# Test with different security versions
|
||||||
#######################################
|
#######################################
|
||||||
for SECVERS in "$SECVERS" ",sec=ntlmv2" ",sec=ntlmssp" ",sec=ntlmsspi" ",sec=krb5i" ",sec=krb5" ",sec=ntlm" ",sec=ntlmv2i"; do
|
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