From 4afd6cb30902ac7c6f1db4009b5c39eee3d7f134 Mon Sep 17 00:00:00 2001 From: kingpanther13 <25392815+kingpanther13@users.noreply.github.com> Date: Wed, 15 Jul 2026 16:30:29 -0400 Subject: [PATCH] Samba: Normalize stored enabled_shares values to lower case (#4717) Values have always been validated case-insensitively and lower-cased at runtime before rendering smb.conf. Persisting the canonical lower-case form prepares for a future release that restricts the schema to the exact share names. Co-authored-by: kingpanther13 Co-authored-by: Claude Opus 4.8 (1M context) Co-authored-by: Stefan Agner --- samba/CHANGELOG.md | 6 ++++++ samba/config.yaml | 2 +- samba/rootfs/etc/s6-overlay/s6-rc.d/init-smbd/run | 15 +++++++++++++++ 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/samba/CHANGELOG.md b/samba/CHANGELOG.md index 0cf6c091d..670d21482 100644 --- a/samba/CHANGELOG.md +++ b/samba/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +## 12.8.1 + +- Normalize stored `enabled_shares` values to lower case at startup. Values + were already handled case-insensitively at runtime; this persists the + canonical form in preparation for a stricter schema in a future release. + ## 12.8.0 - Add configuration option to disable NetBIOS. When disabled, the nmbd service is not started and only port 445 is allowed (port 139 is blocked.) diff --git a/samba/config.yaml b/samba/config.yaml index e716065da..51b16cc48 100644 --- a/samba/config.yaml +++ b/samba/config.yaml @@ -1,5 +1,5 @@ --- -version: 12.8.0 +version: 12.8.1 slug: samba name: Samba share description: Expose Home Assistant folders with SMB/CIFS diff --git a/samba/rootfs/etc/s6-overlay/s6-rc.d/init-smbd/run b/samba/rootfs/etc/s6-overlay/s6-rc.d/init-smbd/run index d4b607ee8..8bf03527d 100755 --- a/samba/rootfs/etc/s6-overlay/s6-rc.d/init-smbd/run +++ b/samba/rootfs/etc/s6-overlay/s6-rc.d/init-smbd/run @@ -8,6 +8,8 @@ declare password declare username declare config_username declare samba_username +declare stored_options +declare migration_payload declare -a interfaces=() export HOSTNAME @@ -21,6 +23,19 @@ fi bashio::config.require "enabled_shares" "Samba is a tool for sharing folders. Starting it without sharing any folders defeats the purpose." +# Migrate stored enabled_shares values to lower case. Values have always +# been treated case-insensitively at runtime; persisting them lower case +# prepares for a future release that restricts the schema to the exact +# share names. +stored_options=$(bashio::api.supervisor GET /addons/self/info false | jq '.options') +if jq -e '(.enabled_shares // []) | any(. != ascii_downcase)' <<< "${stored_options}" > /dev/null; then + bashio::log.info "Migrating enabled_shares configuration values to lower case" + migration_payload=$(jq -c '{options: (.enabled_shares |= map(ascii_downcase))}' <<< "${stored_options}") + if ! bashio::api.supervisor POST /addons/self/options "${migration_payload}"; then + bashio::log.warning "Could not migrate enabled_shares values; will retry on next start" + fi +fi + # Read hostname from API or setting default "hassio" HOSTNAME=$(bashio::info.hostname) if bashio::var.is_empty "${HOSTNAME}"; then