add allow access wide symbolic links option (#66)

* add allow access wide symbolic links option

* Update README.md

* Update samba.sh
This commit is contained in:
Chopin Ngo 2017-08-18 04:18:01 +08:00 committed by David Personette
parent c72d17eee3
commit ec73b63ac7
2 changed files with 17 additions and 3 deletions

View File

@ -60,6 +60,7 @@ OR set local storage:
-w "<workgroup>" Configure the workgroup (domain) samba should use -w "<workgroup>" Configure the workgroup (domain) samba should use
required arg: "<workgroup>" required arg: "<workgroup>"
<workgroup> for samba <workgroup> for samba
-W Allow access wide symbolic links
The 'command' (if provided and valid) will be run instead of samba The 'command' (if provided and valid) will be run instead of samba
@ -69,6 +70,7 @@ ENVIRONMENT VARIABLES (only available with `docker run`)
* `NMBD` - As above, enable nmbd * `NMBD` - As above, enable nmbd
* `SMB` - As above, disabel SMB2 minimun version * `SMB` - As above, disabel SMB2 minimun version
* `TZ` - As above, set a zoneinfo timezone, IE `EST5EDT` * `TZ` - As above, set a zoneinfo timezone, IE `EST5EDT`
* `WIDELINKS` - As above, allow access wide symbolic links
* `WORKGROUP` - As above, set workgroup * `WORKGROUP` - As above, set workgroup
* `USERID` - Set the UID for the samba server * `USERID` - Set the UID for the samba server
* `GROUPID` - Set the GID for the samba server * `GROUPID` - Set the GID for the samba server
@ -110,4 +112,4 @@ Will get you the same settings as
## Issues ## Issues
If you have any problems with or questions about this image, please contact me If you have any problems with or questions about this image, please contact me
through a [GitHub issue](https://github.com/dperson/samba/issues). through a [GitHub issue](https://github.com/dperson/samba/issues).

View File

@ -143,6 +143,15 @@ workgroup() { local workgroup="${1}" file=/etc/samba/smb.conf
sed -i 's|^\( *workgroup = \).*|\1'"$workgroup"'|' $file sed -i 's|^\( *workgroup = \).*|\1'"$workgroup"'|' $file
} }
### widelinks: allow access wide symbolic links
# Arguments:
# none)
# Return: result
widelinks() { local file=/etc/samba/smb.conf \
replace='\1\n wide links = yes\n unix extensions = no'
sed -i 's/\(follow symlinks = yes\)/'"$replace"'/' $file
}
### usage: Help ### usage: Help
# Arguments: # Arguments:
# none) # none)
@ -181,6 +190,7 @@ Options (fields in '[]' are optional, '<>' are required):
-w \"<workgroup>\" Configure the workgroup (domain) samba should use -w \"<workgroup>\" Configure the workgroup (domain) samba should use
required arg: \"<workgroup>\" required arg: \"<workgroup>\"
<workgroup> for samba <workgroup> for samba
-W Allow access wide symbolic links
The 'command' (if provided and valid) will be run instead of samba The 'command' (if provided and valid) will be run instead of samba
" >&2 " >&2
@ -190,7 +200,7 @@ The 'command' (if provided and valid) will be run instead of samba
[[ "${USERID:-""}" =~ ^[0-9]+$ ]] && usermod -u $USERID -o smbuser [[ "${USERID:-""}" =~ ^[0-9]+$ ]] && usermod -u $USERID -o smbuser
[[ "${GROUPID:-""}" =~ ^[0-9]+$ ]] && groupmod -g $GROUPID -o users [[ "${GROUPID:-""}" =~ ^[0-9]+$ ]] && groupmod -g $GROUPID -o users
while getopts ":hc:i:nprs:St:u:w:" opt; do while getopts ":hc:i:nprs:St:u:Ww:" opt; do
case "$opt" in case "$opt" in
h) usage ;; h) usage ;;
c) charmap "$OPTARG" ;; c) charmap "$OPTARG" ;;
@ -203,6 +213,7 @@ while getopts ":hc:i:nprs:St:u:w:" opt; do
t) timezone "$OPTARG" ;; t) timezone "$OPTARG" ;;
u) eval user $(sed 's|;| |g' <<< $OPTARG) ;; u) eval user $(sed 's|;| |g' <<< $OPTARG) ;;
w) workgroup "$OPTARG" ;; w) workgroup "$OPTARG" ;;
W) widelinks ;;
"?") echo "Unknown option: -$OPTARG"; usage 1 ;; "?") echo "Unknown option: -$OPTARG"; usage 1 ;;
":") echo "No argument value for option: -$OPTARG"; usage 2 ;; ":") echo "No argument value for option: -$OPTARG"; usage 2 ;;
esac esac
@ -215,6 +226,7 @@ shift $(( OPTIND - 1 ))
[[ "${TZ:-""}" ]] && timezone "$TZ" [[ "${TZ:-""}" ]] && timezone "$TZ"
[[ "${SMB:-""}" ]] && smb [[ "${SMB:-""}" ]] && smb
[[ "${WORKGROUP:-""}" ]] && workgroup "$WORKGROUP" [[ "${WORKGROUP:-""}" ]] && workgroup "$WORKGROUP"
[[ "${WIDELINKS:-""}" ]] && widelinks
if [[ $# -ge 1 && -x $(which $1 2>&-) ]]; then if [[ $# -ge 1 && -x $(which $1 2>&-) ]]; then
exec "$@" exec "$@"
@ -226,4 +238,4 @@ elif ps -ef | egrep -v grep | grep -q smbd; then
else else
[[ ${NMBD:-""} ]] && ionice -c 3 nmbd -D [[ ${NMBD:-""} ]] && ionice -c 3 nmbd -D
exec ionice -c 3 smbd -FS </dev/null exec ionice -c 3 smbd -FS </dev/null
fi fi