Browse Source

fix permission denied when postmapping file not owned by root

Fabian Peter Hammerle 4 years ago
parent
commit
d148634031
2 changed files with 10 additions and 1 deletions
  1. 6 0
      CHANGELOG.md
  2. 4 1
      postfix.sh

+ 6 - 0
CHANGELOG.md

@@ -5,6 +5,12 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
 and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
 
 ## [Unreleased]
+### Fixed
+- fix permission denied / `EACCES` error
+  when `$POSTMAP_PATHS` contains path to file not owned by root.
+  keep `postmap` from changing uid/gid to file owner
+  as user might not have write perms on dir
+  (e.g., due to mount with `dockerd --userns-remap`).
 
 ## [1.0.2] - 2019-12-21
 ### Fixed

+ 4 - 1
postfix.sh

@@ -3,7 +3,10 @@
 set -e
 
 echo "$POSTMAP_PATHS" | while IFS= read -r postmap_path; do
-    [ -z "$postmap_path" ] || (set -x; postmap "$postmap_path")
+    # by default, postmap runs setresuid(file owner).
+    # disable via -o cause file owner might not have write perms on dir
+    # (e.g., due to dockerd --userns-remap).
+    [ -z "$postmap_path" ] || (set -x; postmap -o "$postmap_path")
 done
 
 set -x