浏览代码

docker: Add support for setting umask (#9429)

Add support for setting umask value in the Docker `entrypoint.sh`
script. This is useful when
not syncing permissions and working with groups, and needing umask
values like `002` instead of `022`.
Beat Reichenbach 1 年之前
父节点
当前提交
c4dfb66d84
共有 2 个文件被更改,包括 6 次插入1 次删除
  1. 3 0
      README-Docker.md
  2. 3 1
      script/docker-entrypoint.sh

+ 3 - 0
README-Docker.md

@@ -15,6 +15,9 @@ To grant Syncthing additional capabilities without running as root, use the
 `PCAP` environment variable with the same syntax as that for `setcap(8)`.
 For example, `PCAP=cap_chown,cap_fowner+ep`.
 
+To set a different umask value, use the `UMASK` environment variable. For
+example `UMASK=002`.
+
 ## Example Usage
 
 **Docker cli**

+ 3 - 1
script/docker-entrypoint.sh

@@ -2,9 +2,11 @@
 
 set -eu
 
+[ -n "${UMASK:-}" ] && umask "$UMASK"
+
 if [ "$(id -u)" = '0' ]; then
   binary="$1"
-  if [ "${PCAP:-}" == "" ] ; then
+  if [ -z "${PCAP:-}" ]; then
     # If Syncthing should have no extra capabilities, make sure to remove them
     # from the binary. This will fail with an error if there are no
     # capabilities to remove, hence the || true etc.