fix: resolve bugs in samba.sh and Dockerfile
- Fix chown syntax: changed 'smbuser.' to 'smbuser:smb' for correct group assignment - Fix paths with spaces in perms(): use 'while read' instead of 'for' loop - Add quotes to $file variable in import() to prevent word splitting - Remove /etc from VOLUME declaration (too broad, causes unexpected behavior) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
12
CHANGELOG.md
12
CHANGELOG.md
@@ -8,6 +8,18 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
|||||||
|
|
||||||
### Fixed
|
### 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))
|
- **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`.
|
**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`.
|
||||||
|
|||||||
@@ -80,6 +80,6 @@ EXPOSE 137/udp 138/udp 139 445
|
|||||||
HEALTHCHECK --interval=60s --timeout=15s --start-period=10s --retries=3 \
|
HEALTHCHECK --interval=60s --timeout=15s --start-period=10s --retries=3 \
|
||||||
CMD smbclient -L \\localhost -U % -m SMB3 || exit 1
|
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"]
|
ENTRYPOINT ["/sbin/tini", "--", "/usr/bin/samba.sh"]
|
||||||
|
|||||||
11
samba.sh
11
samba.sh
@@ -109,8 +109,8 @@ include() { local includefile="$1"
|
|||||||
import() { local file="$1" name id
|
import() { local file="$1" name id
|
||||||
while read name id; do
|
while read name id; do
|
||||||
grep -q "^$name:" /etc/passwd || adduser -D -H -u "$id" "$name"
|
grep -q "^$name:" /etc/passwd || adduser -D -H -u "$id" "$name"
|
||||||
done < <(cut -d: -f1,2 $file | sed 's/:/ /')
|
done < <(cut -d: -f1,2 "$file" | sed 's/:/ /')
|
||||||
pdbedit -i smbpasswd:$file
|
pdbedit -i "smbpasswd:$file"
|
||||||
}
|
}
|
||||||
|
|
||||||
### perms: fix ownership and permissions of share paths
|
### perms: fix ownership and permissions of share paths
|
||||||
@@ -118,11 +118,12 @@ import() { local file="$1" name id
|
|||||||
# none)
|
# none)
|
||||||
# Return: result
|
# Return: result
|
||||||
perms() { local i
|
perms() { local i
|
||||||
for i in $(awk -F ' = ' '/ path = / {print $2}' "$SMB_CONF"); do
|
while IFS= read -r i; do
|
||||||
chown -Rh smbuser. "$i"
|
[[ -z "$i" ]] && continue
|
||||||
|
chown -Rh smbuser:smb "$i"
|
||||||
find "$i" -type d ! -perm 775 -exec chmod 775 {} \;
|
find "$i" -type d ! -perm 775 -exec chmod 775 {} \;
|
||||||
find "$i" -type f ! -perm 0664 -exec chmod 0664 {} \;
|
find "$i" -type f ! -perm 0664 -exec chmod 0664 {} \;
|
||||||
done
|
done < <(awk -F ' = ' '/ path = / {print $2}' "$SMB_CONF")
|
||||||
}
|
}
|
||||||
export -f perms
|
export -f perms
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user