From 88fe5e85148771f0a137dd0031ef17694ac26e9a Mon Sep 17 00:00:00 2001 From: atx32 Date: Tue, 21 Jul 2026 18:15:34 -0500 Subject: [PATCH 1/6] Add service discovery over mDNS and associated config setting (default true) --- samba/DOCS.md | 7 +++++++ samba/Dockerfile | 2 +- samba/config.yaml | 5 ++++- samba/rootfs/etc/s6-overlay/s6-rc.d/smbd/finish | 10 ++++++++++ samba/rootfs/etc/s6-overlay/s6-rc.d/smbd/run | 15 +++++++++++++++ samba/translations/en.yaml | 3 +++ 6 files changed, 40 insertions(+), 2 deletions(-) diff --git a/samba/DOCS.md b/samba/DOCS.md index 7947d44e2..bda475da1 100644 --- a/samba/DOCS.md +++ b/samba/DOCS.md @@ -48,6 +48,7 @@ enabled_shares: - ssl compatibility_mode: false apple_compatibility_mode: true +mdns: true netbios: true local_master: true server_signing: "default" @@ -108,6 +109,12 @@ This can cause issues with file systems that do not support xattr such as exFAT. Defaults to `true`. +### Option: `mdns` + +Enable service discovery over mDNS. + +Defaults to `true`. + ### Option: `netbios` NetBIOS is a legacy network protocol for accessing SMB/CIFS shares. Enable for legacy clients older than Windows Vista (Windows 95/98/ME, Windows NT, diff --git a/samba/Dockerfile b/samba/Dockerfile index c7cd5390d..972be419b 100644 --- a/samba/Dockerfile +++ b/samba/Dockerfile @@ -6,7 +6,7 @@ ENV LANG C.UTF-8 # Setup base RUN \ - apk add --no-cache samba wsdd \ + apk add --no-cache samba wsdd glib \ && mkdir -p /var/lib/samba \ && touch \ /etc/samba/lmhosts \ diff --git a/samba/config.yaml b/samba/config.yaml index 51b16cc48..91a03a194 100644 --- a/samba/config.yaml +++ b/samba/config.yaml @@ -1,5 +1,5 @@ --- -version: 12.8.1 +version: 12.9.0 slug: samba name: Samba share description: Expose Home Assistant folders with SMB/CIFS @@ -9,6 +9,7 @@ arch: - amd64 hassio_api: true host_network: true +host_dbus: true image: homeassistant/{arch}-addon-samba init: false map: @@ -33,6 +34,7 @@ options: - ssl compatibility_mode: false apple_compatibility_mode: true + mdns: true netbios: true local_master: true server_signing: "default" @@ -57,6 +59,7 @@ schema: - "match(^(?i:(addons|addon_configs|backup|config|media|share|ssl))$)" compatibility_mode: bool apple_compatibility_mode: bool + mdns: bool netbios: bool local_master: bool server_signing: list(default|auto|mandatory|disabled) diff --git a/samba/rootfs/etc/s6-overlay/s6-rc.d/smbd/finish b/samba/rootfs/etc/s6-overlay/s6-rc.d/smbd/finish index e60184ba4..f6c344a86 100755 --- a/samba/rootfs/etc/s6-overlay/s6-rc.d/smbd/finish +++ b/samba/rootfs/etc/s6-overlay/s6-rc.d/smbd/finish @@ -14,6 +14,16 @@ bashio::log.info \ "Service ${service} exited with code ${exit_code_service}" \ "(by signal ${exit_code_signal})" +if bashio::config.true 'mdns'; then +bashio::log.info "Unregistering smb service in mDNS" +app_hostname=$(hostname) +gdbus call --system \ + --dest=org.freedesktop.resolve1 \ + --object-path=/org/freedesktop/resolve1 \ + --method=org.freedesktop.resolve1.Manager.UnregisterService \ + "/org/freedesktop/resolve1/dnssd/${app_hostname//-/_2d}" +fi + if [[ "${exit_code_service}" -eq 256 ]]; then if [[ "${exit_code_container}" -eq 0 ]]; then echo $((128 + exit_code_signal)) > /run/s6-linux-init-container-results/exitcode diff --git a/samba/rootfs/etc/s6-overlay/s6-rc.d/smbd/run b/samba/rootfs/etc/s6-overlay/s6-rc.d/smbd/run index 219d3d4eb..74e72647d 100755 --- a/samba/rootfs/etc/s6-overlay/s6-rc.d/smbd/run +++ b/samba/rootfs/etc/s6-overlay/s6-rc.d/smbd/run @@ -4,6 +4,21 @@ # ============================================================================== # Start smbd service # ============================================================================== +if bashio::config.true 'mdns'; then +bashio::log.info "Registering smb service in mDNS" +gdbus call --system \ + --dest org.freedesktop.resolve1 \ + --object-path /org/freedesktop/resolve1 \ + --method org.freedesktop.resolve1.Manager.RegisterService \ + $(hostname) \ + "%H" \ + "_smb._tcp" \ + 445 \ + 0 \ + 0 \ + [] +fi + exec smbd \ --foreground \ --debug-stdout \ diff --git a/samba/translations/en.yaml b/samba/translations/en.yaml index 43ba9a80d..1351eac5d 100644 --- a/samba/translations/en.yaml +++ b/samba/translations/en.yaml @@ -30,6 +30,9 @@ configuration: Enable Samba configurations to improve interoperability with Apple devices. May cause issues with file systems that do not support xattr such as exFAT. + mdns: + name: Enable DNS-SD/mDNS + description: Enable service discovery over mDNS. netbios: name: Enable NetBIOS over IP description: >- From 6ae2b7b0388e4462d7cd43e7a9e85ce323d2e124 Mon Sep 17 00:00:00 2001 From: atx32 Date: Tue, 21 Jul 2026 23:27:43 -0500 Subject: [PATCH 2/6] Update changelog for addition of service discovery. --- samba/CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/samba/CHANGELOG.md b/samba/CHANGELOG.md index 670d21482..82e983059 100644 --- a/samba/CHANGELOG.md +++ b/samba/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## 12.9.0 + +- Add service discovery over mDNS with a configuration option to disable. + ## 12.8.1 - Normalize stored `enabled_shares` values to lower case at startup. Values From 554940edcd12474f6a8d60f3f226ff3533364303 Mon Sep 17 00:00:00 2001 From: atx32 Date: Wed, 22 Jul 2026 08:40:14 -0500 Subject: [PATCH 3/6] Fix unquoted command substitution --- samba/rootfs/etc/s6-overlay/s6-rc.d/smbd/run | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samba/rootfs/etc/s6-overlay/s6-rc.d/smbd/run b/samba/rootfs/etc/s6-overlay/s6-rc.d/smbd/run index 74e72647d..ceeae38fe 100755 --- a/samba/rootfs/etc/s6-overlay/s6-rc.d/smbd/run +++ b/samba/rootfs/etc/s6-overlay/s6-rc.d/smbd/run @@ -10,7 +10,7 @@ gdbus call --system \ --dest org.freedesktop.resolve1 \ --object-path /org/freedesktop/resolve1 \ --method org.freedesktop.resolve1.Manager.RegisterService \ - $(hostname) \ + "$(hostname)" \ "%H" \ "_smb._tcp" \ 445 \ From 6236b6819ed4474fd4e7cd9e4190eefb34e7f1d3 Mon Sep 17 00:00:00 2001 From: atx32 Date: Wed, 29 Jul 2026 20:53:32 -0500 Subject: [PATCH 4/6] Update config descriptions and documentation, bump version --- samba/CHANGELOG.md | 4 ++++ samba/DOCS.md | 7 +++---- samba/config.yaml | 2 +- samba/translations/en.yaml | 3 +-- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/samba/CHANGELOG.md b/samba/CHANGELOG.md index 3db6c2fbe..b353e61d4 100644 --- a/samba/CHANGELOG.md +++ b/samba/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## 12.11.0 + +- Add service discovery using DNS-SD/mDNS controlled by the `network_discovery` configuration option added in 12.9.0. + ## 12.10.0 - Rename the `addons` and `addon_configs` shares to `local_apps` and `app_configs` to match Home Assistant's app terminology. Existing `enabled_shares` configurations are migrated automatically on start (extending the lower-case normalization added in 12.8.1). diff --git a/samba/DOCS.md b/samba/DOCS.md index 80be4ecb8..ae4c9db60 100644 --- a/samba/DOCS.md +++ b/samba/DOCS.md @@ -130,10 +130,9 @@ Defaults to `true`. ### Option: `network_discovery` -Advertise the host on the network using Web Services Dynamic Discovery, so it -appears automatically under Network in Windows File Explorer. Disable this if -you connect to the shares by hostname or IP address and do not want the host -to announce itself on the network. +Advertise the host on the network using DNS-SD/mDNS and WS-Discovery. Disable +this if you connect to the shares by hostname or IP address and do not want the +host to announce itself on the network. Disabling this has no effect on share availability; only on discovery. diff --git a/samba/config.yaml b/samba/config.yaml index ba6f5e89d..68e95904e 100644 --- a/samba/config.yaml +++ b/samba/config.yaml @@ -1,5 +1,5 @@ --- -version: 12.10.0 +version: 12.11.0 slug: samba name: Samba share description: Expose Home Assistant folders with SMB/CIFS diff --git a/samba/translations/en.yaml b/samba/translations/en.yaml index 1fa6c1e83..4a063211e 100644 --- a/samba/translations/en.yaml +++ b/samba/translations/en.yaml @@ -46,8 +46,7 @@ configuration: network_discovery: name: Enable network discovery description: >- - Advertise the host with Web Services Dynamic Discovery so it appears - automatically under Network in Windows File Explorer. Disable if you + Advertise the host with DNS-SD/mDNS and WS-Discovery. Disable if you connect by hostname or IP address and do not want the host to announce itself on the network. Shares stay reachable either way. server_signing: From 9732fc4b98718a8123e271524492c0c5c9a50433 Mon Sep 17 00:00:00 2001 From: atx32 Date: Fri, 31 Jul 2026 18:41:08 -0500 Subject: [PATCH 5/6] Add comment explaining object path encoding --- samba/rootfs/etc/s6-overlay/s6-rc.d/smbd/finish | 1 + 1 file changed, 1 insertion(+) diff --git a/samba/rootfs/etc/s6-overlay/s6-rc.d/smbd/finish b/samba/rootfs/etc/s6-overlay/s6-rc.d/smbd/finish index 9778c959b..912b016c6 100755 --- a/samba/rootfs/etc/s6-overlay/s6-rc.d/smbd/finish +++ b/samba/rootfs/etc/s6-overlay/s6-rc.d/smbd/finish @@ -17,6 +17,7 @@ bashio::log.info \ if bashio::config.true 'network_discovery'; then bashio::log.info "Unregistering smb service in mDNS" app_hostname=$(hostname) +# Fix object path encoding by replacing "-" with "_2d" gdbus call --system \ --dest=org.freedesktop.resolve1 \ --object-path=/org/freedesktop/resolve1 \ From 2bb1b37e6050e9cfa157dc8be2239b0fd8012690 Mon Sep 17 00:00:00 2001 From: atx32 Date: Mon, 3 Aug 2026 19:37:21 -0500 Subject: [PATCH 6/6] Change gdbus call formatting for consistency --- samba/rootfs/etc/s6-overlay/s6-rc.d/smbd/finish | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/samba/rootfs/etc/s6-overlay/s6-rc.d/smbd/finish b/samba/rootfs/etc/s6-overlay/s6-rc.d/smbd/finish index 912b016c6..b1e23fe7f 100755 --- a/samba/rootfs/etc/s6-overlay/s6-rc.d/smbd/finish +++ b/samba/rootfs/etc/s6-overlay/s6-rc.d/smbd/finish @@ -19,9 +19,9 @@ bashio::log.info "Unregistering smb service in mDNS" app_hostname=$(hostname) # Fix object path encoding by replacing "-" with "_2d" gdbus call --system \ - --dest=org.freedesktop.resolve1 \ - --object-path=/org/freedesktop/resolve1 \ - --method=org.freedesktop.resolve1.Manager.UnregisterService \ + --dest org.freedesktop.resolve1 \ + --object-path /org/freedesktop/resolve1 \ + --method org.freedesktop.resolve1.Manager.UnregisterService \ "/org/freedesktop/resolve1/dnssd/${app_hostname//-/_2d}" fi