mirror of
https://github.com/alexbelgium/hassio-addons.git
synced 2026-06-21 06:49:13 +02:00
Merge pull request #2125 from alexbelgium/codex/fix-issue-2124-in-hassio-addons
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"
|
||||||
@@ -215,10 +217,10 @@ if bashio::config.has_value 'networkdisks'; then
|
|||||||
fi
|
fi
|
||||||
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 "... using SMBv1"
|
||||||
bashio::log.fatal "...... invalid or inaccessible SMB path. Script will stop."
|
bashio::log.warning "...... share reachable only with legacy SMBv1 (NT1) negotiation. Forcing SMBv1 options."
|
||||||
touch ERRORCODE
|
SMBVERS_FORCE=",vers=1.0"
|
||||||
continue
|
SECVERS_FORCE=",sec=ntlm"
|
||||||
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 +264,25 @@ 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
|
||||||
|
|
||||||
|
# Ensure the Samba client allows SMBv1 when those options are required
|
||||||
|
if [[ "${SMBVERS}${SMBVERS_FORCE}" == *"vers=1.0"* ]]; then
|
||||||
|
if [[ -f /etc/samba/smb.conf ]]; then
|
||||||
|
bashio::log.warning "...... enabling SMBv1 support in Samba client configuration"
|
||||||
|
sed -i '/\[global\]/!b;n;/client min protocol = NT1/!a\
|
||||||
|
client min protocol = NT1' /etc/samba/smb.conf
|
||||||
|
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