From 30517a74502bd7a37957fe4d6f1346fde83d0899 Mon Sep 17 00:00:00 2001 From: kingpanther13 Date: Sat, 11 Jul 2026 08:07:09 -0400 Subject: [PATCH 1/3] 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 From 0cc746dc747b9ac26c09797c29f4610570b9639d Mon Sep 17 00:00:00 2001 From: kingpanther13 Date: Sat, 11 Jul 2026 08:08:06 -0400 Subject: [PATCH 2/3] Samba: Restrict enabled_shares schema to list() of share names The configuration UI offers the share names as a multi-select instead of an empty free-text suggestion list. Values must now be lower case; 12.7.2 migrated stored configs automatically. The startup migration and runtime lower-casing are removed as dead code. Co-Authored-By: Claude Opus 4.8 (1M context) --- samba/CHANGELOG.md | 8 ++++++++ samba/config.yaml | 4 ++-- .../rootfs/etc/s6-overlay/s6-rc.d/init-smbd/run | 16 ---------------- samba/translations/en.yaml | 10 ++-------- 4 files changed, 12 insertions(+), 26 deletions(-) diff --git a/samba/CHANGELOG.md b/samba/CHANGELOG.md index dcf1b3e8a..b256141ad 100644 --- a/samba/CHANGELOG.md +++ b/samba/CHANGELOG.md @@ -1,5 +1,13 @@ # Changelog +## 13.0.0 + +- BREAKING: `enabled_shares` values must now be lower case. The schema + restricts values to the exact share names and the configuration UI offers + them as a multi-select. Configs saved on 12.7.2 or later were migrated + automatically; older configs with non-lower-case values fail validation + with a clear error and must be re-selected. + ## 12.7.2 - Normalize stored `enabled_shares` values to lower case at startup. Values diff --git a/samba/config.yaml b/samba/config.yaml index d23431124..3dda6222c 100644 --- a/samba/config.yaml +++ b/samba/config.yaml @@ -1,5 +1,5 @@ --- -version: 12.7.2 +version: 13.0.0 slug: samba name: Samba share description: Expose Home Assistant folders with SMB/CIFS @@ -54,7 +54,7 @@ schema: workgroup: str local_master: bool enabled_shares: - - "match(^(?i:(addons|addon_configs|backup|config|media|share|ssl))$)" + - "list(addons|addon_configs|backup|config|media|share|ssl)" compatibility_mode: bool apple_compatibility_mode: bool server_signing: list(default|auto|mandatory|disabled) 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 8bf03527d..d9d0b4ab4 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,8 +8,6 @@ declare password declare username declare config_username declare samba_username -declare stored_options -declare migration_payload declare -a interfaces=() export HOSTNAME @@ -23,19 +21,6 @@ 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 @@ -64,7 +49,6 @@ fi jq --arg username "${samba_username}" \ ".interfaces = $(jq -c -n '$ARGS.positional' --args -- "${interfaces[@]}") | - .enabled_shares.[] |= ascii_downcase | .username = \$username" /data/options.json \ | tempio \ -template /usr/share/tempio/smb.gtpl \ diff --git a/samba/translations/en.yaml b/samba/translations/en.yaml index 7fee4e38d..f0b2ed3e7 100644 --- a/samba/translations/en.yaml +++ b/samba/translations/en.yaml @@ -15,14 +15,8 @@ configuration: name: Local master description: Enable to try and become a local master browser on a subnet. enabled_shares: - name: >- - Enabled Shares - allowed values are: - addons, addon_configs, backup, config, media, share, or ssl. - description: >- - List of file shares to make available. - Adding a share requires typing its name to add it. - The listed values are the only allowed values. - The configuration cannot be saved if any non-allowed value is in the list. + name: Enabled Shares + description: List of file shares to make available. compatibility_mode: name: Enable Compatibility Mode description: >- From df4c19150fd9b88a9841f4ed0b5560fa7ef8614e Mon Sep 17 00:00:00 2001 From: kingpanther13 Date: Wed, 15 Jul 2026 16:39:21 -0400 Subject: [PATCH 3/3] Samba: Remove startup lower-case migration superseded by strict schema With the list() schema the Supervisor rejects non-lower-case values before the add-on starts, so the startup migration from 12.8.1 can never run against a config that needs it. --- samba/rootfs/etc/s6-overlay/s6-rc.d/init-smbd/run | 15 --------------- 1 file changed, 15 deletions(-) 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 38705645c..d9d0b4ab4 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,8 +8,6 @@ declare password declare username declare config_username declare samba_username -declare stored_options -declare migration_payload declare -a interfaces=() export HOSTNAME @@ -23,19 +21,6 @@ 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