From ec73b63ac79bf830cade47b961ee0945c4ba1a7c Mon Sep 17 00:00:00 2001 From: Chopin Ngo Date: Fri, 18 Aug 2017 04:18:01 +0800 Subject: [PATCH] add allow access wide symbolic links option (#66) * add allow access wide symbolic links option * Update README.md * Update samba.sh --- README.md | 4 +++- samba.sh | 16 ++++++++++++++-- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index ee4babf..c00c3e5 100644 --- a/README.md +++ b/README.md @@ -60,6 +60,7 @@ OR set local storage: -w "" Configure the workgroup (domain) samba should use required arg: "" for samba + -W Allow access wide symbolic links 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 * `SMB` - As above, disabel SMB2 minimun version * `TZ` - As above, set a zoneinfo timezone, IE `EST5EDT` + * `WIDELINKS` - As above, allow access wide symbolic links * `WORKGROUP` - As above, set workgroup * `USERID` - Set the UID for the samba server * `GROUPID` - Set the GID for the samba server @@ -110,4 +112,4 @@ Will get you the same settings as ## Issues If you have any problems with or questions about this image, please contact me -through a [GitHub issue](https://github.com/dperson/samba/issues). \ No newline at end of file +through a [GitHub issue](https://github.com/dperson/samba/issues). diff --git a/samba.sh b/samba.sh index 21242d3..40eaeec 100755 --- a/samba.sh +++ b/samba.sh @@ -143,6 +143,15 @@ workgroup() { local workgroup="${1}" file=/etc/samba/smb.conf 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 # Arguments: # none) @@ -181,6 +190,7 @@ Options (fields in '[]' are optional, '<>' are required): -w \"\" Configure the workgroup (domain) samba should use required arg: \"\" for samba + -W Allow access wide symbolic links The 'command' (if provided and valid) will be run instead of samba " >&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 [[ "${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 h) usage ;; c) charmap "$OPTARG" ;; @@ -203,6 +213,7 @@ while getopts ":hc:i:nprs:St:u:w:" opt; do t) timezone "$OPTARG" ;; u) eval user $(sed 's|;| |g' <<< $OPTARG) ;; w) workgroup "$OPTARG" ;; + W) widelinks ;; "?") echo "Unknown option: -$OPTARG"; usage 1 ;; ":") echo "No argument value for option: -$OPTARG"; usage 2 ;; esac @@ -215,6 +226,7 @@ shift $(( OPTIND - 1 )) [[ "${TZ:-""}" ]] && timezone "$TZ" [[ "${SMB:-""}" ]] && smb [[ "${WORKGROUP:-""}" ]] && workgroup "$WORKGROUP" +[[ "${WIDELINKS:-""}" ]] && widelinks if [[ $# -ge 1 && -x $(which $1 2>&-) ]]; then exec "$@" @@ -226,4 +238,4 @@ elif ps -ef | egrep -v grep | grep -q smbd; then else [[ ${NMBD:-""} ]] && ionice -c 3 nmbd -D exec ionice -c 3 smbd -FS