From 30517a74502bd7a37957fe4d6f1346fde83d0899 Mon Sep 17 00:00:00 2001 From: kingpanther13 Date: Sat, 11 Jul 2026 08:07:09 -0400 Subject: [PATCH] Samba: Normalize stored enabled_shares values to lower case 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: Claude Opus 4.8 (1M context) --- 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 dadaaf19d..dcf1b3e8a 100644 --- a/samba/CHANGELOG.md +++ b/samba/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +## 12.7.2 + +- 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.7.1 - Enabled kernel oplocks in smb.conf to ensure changes made to files on disk are available immediately via SMBD. This covers all shares except backup, and media as the contents shouldn't be changed by the server once they're written in those shares. diff --git a/samba/config.yaml b/samba/config.yaml index 00bdbc2aa..d23431124 100644 --- a/samba/config.yaml +++ b/samba/config.yaml @@ -1,5 +1,5 @@ --- -version: 12.7.1 +version: 12.7.2 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