Skip to content

Commit 073b355

Browse files
Enable NSS wrapper only if /tmp is writable (#3)
Issue The container will fail if `readOnlyRootFilesystem=true` and no volume is mounted in `/tmp`. This is the case in NuoDB Helm charts with `nuocollector-config` and `backup-hooks` containers. Changes Enable NSS wrapper only if `/tmp` is writable.
1 parent 900eb33 commit 073b355

File tree

1 file changed

+14
-11
lines changed

1 file changed

+14
-11
lines changed

docker/entrypoint.sh

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,22 @@ gid="$(id -g)"
1515
case "${uid}:${gid}" in
1616
(0:0|"$NUODB_DEFAULT_UID":0) : ;;
1717
(*:0|"$NUODB_DEFAULT_UID":*)
18-
# Replace uid:gid for nuodb user
19-
sed "s/^nuodb:x:${NUODB_DEFAULT_UID}:0:/nuodb:x:${uid}:${gid}:/" /etc/passwd.nuodb > /tmp/passwd
18+
# Check if /tmp is writable
19+
if test -w /tmp/passwd; then
20+
# Replace uid:gid for nuodb user
21+
sed "s/^nuodb:x:${NUODB_DEFAULT_UID}:0:/nuodb:x:${uid}:${gid}:/" /etc/passwd.nuodb > /tmp/passwd
2022

21-
# Copy /etc/group and add nuodb group if necessary
22-
cp /etc/group /tmp/group
23-
if [ "$gid" != 0 ]; then
24-
echo "nuodb:x:${gid}:" >> /tmp/group
25-
fi
23+
# Copy /etc/group and add nuodb group if necessary
24+
cp /etc/group /tmp/group
25+
if [ "$gid" != 0 ]; then
26+
echo "nuodb:x:${gid}:" >> /tmp/group
27+
fi
2628

27-
# Enable nss_wrapper
28-
export LD_PRELOAD=libnss_wrapper.so
29-
export NSS_WRAPPER_PASSWD=/tmp/passwd
30-
export NSS_WRAPPER_GROUP=/tmp/group
29+
# Enable nss_wrapper
30+
export LD_PRELOAD=libnss_wrapper.so
31+
export NSS_WRAPPER_PASSWD=/tmp/passwd
32+
export NSS_WRAPPER_GROUP=/tmp/group
33+
fi
3134
;;
3235
(*)
3336
echo "ERROR: Unexpected user and group ID: ${uid}:${gid}"

0 commit comments

Comments
 (0)