Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions samba/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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).
Expand Down
7 changes: 3 additions & 4 deletions samba/DOCS.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
2 changes: 1 addition & 1 deletion samba/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down
3 changes: 2 additions & 1 deletion samba/config.yaml
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -9,6 +9,7 @@ arch:
- amd64
hassio_api: true
host_network: true
host_dbus: true

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doing this directly from the app works, but it doesn't seem a good approach. It exposes much more attack surface to the app then necessary.

Ideally we extend the app configuration schema to allow service announcements, and let Supervisor handle the interaction with the host OS. We can take the arguments of org.freedesktop.resolve1.Manager.RegisterService as inspiration for the config API. See also my comment in #4468 (comment).

@atx32 atx32 Jul 31, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have to admit what you are proposing is beyond my current capabilities. I would argue that both the ssh and matter_server apps have host_dbus: true, so I'm not sure why samba should be treated differently. If you're still not in favor of using D-Bus, I'll have to defer to someone more skilled to implement your preference.

image: homeassistant/{arch}-addon-samba
init: false
map:
Expand Down
11 changes: 11 additions & 0 deletions samba/rootfs/etc/s6-overlay/s6-rc.d/smbd/finish
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,17 @@ bashio::log.info \
"Service ${service} exited with code ${exit_code_service}" \
"(by signal ${exit_code_signal})"

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 \
--method org.freedesktop.resolve1.Manager.UnregisterService \
"/org/freedesktop/resolve1/dnssd/${app_hostname//-/_2d}"
fi

if [[ "${exit_code_service}" -eq 256 ]]; then
# SIGTERM (15) is how s6-overlay brings the service down during a normal
# container shutdown; halt the supervision tree but keep the container exit
Expand Down
15 changes: 15 additions & 0 deletions samba/rootfs/etc/s6-overlay/s6-rc.d/smbd/run
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,21 @@
# ==============================================================================
# Start smbd service
# ==============================================================================
if bashio::config.true 'network_discovery'; 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 \
Expand Down
3 changes: 1 addition & 2 deletions samba/translations/en.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Loading