Add support for Samba veto files (#783)

* Add support for Samba veto files

* Clean up if statement per review

* Update CHANGELOG.md
This commit is contained in:
Alpha Tango
2019-10-16 14:42:59 -04:00
committed by Pascal Vizeli
parent ab639b7427
commit 714bcfb34d
5 changed files with 41 additions and 2 deletions

View File

@@ -1,5 +1,9 @@
# Changelog
## 9.0
- New option `veto_files` to limit writing of specified files to the share
## 8.3
- Fixes a bug in warning log message, causing start failure

View File

@@ -38,6 +38,11 @@ Add-on configuration:
"10.0.0.0/8",
"172.16.0.0/12",
"192.168.0.0/16"
],
"veto_files": [
"._*",
".DS_Store",
"Thumbs.db"
]
}
```
@@ -57,7 +62,9 @@ Change WORKGROUP to reflect your network needs.
List of hosts/networks allowed to access your configuration.
### Option: `veto_files` (optional)
List of files that are neither visible nor accessible. Useful to stop clients from littering the share with temporary hidden files (ex: macOS .DS_Store, Windows Thumbs.db)
## Known issues and limitations

View File

@@ -1,6 +1,6 @@
{
"name": "Samba share",
"version": "8.3",
"version": "9.0",
"slug": "samba",
"description": "Expose Hass.io folders with SMB/CIFS",
"url": "https://home-assistant.io/addons/samba/",
@@ -30,6 +30,13 @@
"10.0.0.0/8",
"172.16.0.0/12",
"192.168.0.0/16"
],
"veto_files": [
"._*",
".DS_Store",
"Thumbs.db",
"icon?",
".Trashes"
]
},
"schema": {
@@ -39,7 +46,10 @@
"interface": "str",
"allow_hosts": [
"str"
],
"veto_files": [
"str"
]
},
"image": "homeassistant/{arch}-addon-samba"
}
}

View File

@@ -5,6 +5,12 @@ INTERFACE=$(bashio::config 'interface')
ALLOW_HOSTS=$(bashio::config "allow_hosts | join(\" \")")
USERNAME=$(bashio::config 'username')
PASSWORD=$(bashio::config 'password')
DELETE_VETO_FILES="no"
VETO_FILES=$(bashio::config "veto_files | join(\"/\")")
if bashio::config.has_value 'veto_files'; then
VETO_FILES="/$VETO_FILES/"
DELETE_VETO_FILES="yes"
fi
WAIT_PIDS=()
@@ -27,6 +33,8 @@ sed -i "s|%%NAME%%|${NAME}|g" /etc/smb.conf
sed -i "s|%%INTERFACE%%|${INTERFACE}|g" /etc/smb.conf
sed -i "s|%%USERNAME%%|${USERNAME}|g" /etc/smb.conf
sed -i "s#%%ALLOW_HOSTS%%#${ALLOW_HOSTS}#g" /etc/smb.conf
sed -i "s|%%VETO_FILES%%|${VETO_FILES}|g" /etc/smb.conf
sed -i "s|%%DELETE_VETO_FILES%%|${DELETE_VETO_FILES}|g" /etc/smb.conf
# Init users
addgroup "${USERNAME}"

View File

@@ -23,6 +23,8 @@
valid users = %%USERNAME%%
force user = root
force group = root
veto files = %%VETO_FILES%%
delete veto files = %%DELETE_VETO_FILES%%
[addons]
browseable = yes
@@ -32,6 +34,8 @@
valid users = %%USERNAME%%
force user = root
force group = root
veto files = %%VETO_FILES%%
delete veto files = %%DELETE_VETO_FILES%%
[ssl]
browseable = yes
@@ -41,6 +45,8 @@
valid users = %%USERNAME%%
force user = root
force group = root
veto files = %%VETO_FILES%%
delete veto files = %%DELETE_VETO_FILES%%
[share]
browseable = yes
@@ -50,6 +56,8 @@
valid users = %%USERNAME%%
force user = root
force group = root
veto files = %%VETO_FILES%%
delete veto files = %%DELETE_VETO_FILES%%
[backup]
browseable = yes
@@ -59,3 +67,5 @@
valid users = %%USERNAME%%
force user = root
force group = root
veto files = %%VETO_FILES%%
delete veto files = %%DELETE_VETO_FILES%%