diff --git a/CHANGELOG.md b/CHANGELOG.md index f4ab832..ca2484e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,18 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ### Fixed +- **Fixed chown syntax error in perms function** (samba.sh:122) + - Changed `smbuser.` to `smbuser:smb` for correct group assignment + +- **Fixed paths with spaces handling in perms function** (samba.sh:121) + - Replaced `for` loop with `while IFS= read -r` to correctly handle paths containing spaces + +- **Fixed unquoted variables in import function** (samba.sh:112-113) + - Added quotes around `$file` variable to prevent word splitting issues + +- **Removed /etc from VOLUME declaration** (Dockerfile:83) + - `/etc` is too broad and can cause unexpected behavior with system configurations + - **Share-specific parameters not overriding global settings** ([#issue](https://github.com/upagge/samba/issues)) **Problem**: When creating public shares with guest write access, the `-G` parameters for individual shares did not override the global `force user` and `force group` settings from the base `smb.conf`. diff --git a/Dockerfile b/Dockerfile index 3001052..7e226a4 100644 --- a/Dockerfile +++ b/Dockerfile @@ -80,6 +80,6 @@ EXPOSE 137/udp 138/udp 139 445 HEALTHCHECK --interval=60s --timeout=15s --start-period=10s --retries=3 \ CMD smbclient -L \\localhost -U % -m SMB3 || exit 1 -VOLUME ["/etc", "/var/cache/samba", "/var/lib/samba", "/var/log/samba", "/run/samba"] +VOLUME ["/var/cache/samba", "/var/lib/samba", "/var/log/samba", "/run/samba"] ENTRYPOINT ["/sbin/tini", "--", "/usr/bin/samba.sh"] diff --git a/samba.sh b/samba.sh index 8a65eb3..ef8f023 100755 --- a/samba.sh +++ b/samba.sh @@ -109,8 +109,8 @@ include() { local includefile="$1" import() { local file="$1" name id while read name id; do grep -q "^$name:" /etc/passwd || adduser -D -H -u "$id" "$name" - done < <(cut -d: -f1,2 $file | sed 's/:/ /') - pdbedit -i smbpasswd:$file + done < <(cut -d: -f1,2 "$file" | sed 's/:/ /') + pdbedit -i "smbpasswd:$file" } ### perms: fix ownership and permissions of share paths @@ -118,11 +118,12 @@ import() { local file="$1" name id # none) # Return: result perms() { local i - for i in $(awk -F ' = ' '/ path = / {print $2}' "$SMB_CONF"); do - chown -Rh smbuser. "$i" + while IFS= read -r i; do + [[ -z "$i" ]] && continue + chown -Rh smbuser:smb "$i" find "$i" -type d ! -perm 775 -exec chmod 775 {} \; find "$i" -type f ! -perm 0664 -exec chmod 0664 {} \; - done + done < <(awk -F ' = ' '/ path = / {print $2}' "$SMB_CONF") } export -f perms