Skip to content

Commit 9296e2e

Browse files
committed
use Giuseppe's forked newuidmap/newgidmap
Applies shadow-maint/shadow#132 so that we don't need to have CAP_SYS_ADMIN. See also genuinetools#170 . Signed-off-by: Akihiro Suda <[email protected]>
1 parent 24a1046 commit 9296e2e

File tree

1 file changed

+34
-10
lines changed

1 file changed

+34
-10
lines changed

Dockerfile

+34-10
Original file line numberDiff line numberDiff line change
@@ -22,20 +22,44 @@ COPY . .
2222
RUN go get -u github.com/jteeuwen/go-bindata/...
2323
RUN make static && mv img /usr/bin/img
2424

25-
FROM alpine
25+
# We don't use the Alpine shadow pkg bacause:
26+
# 1. Alpine shadow makes SUID `su` executable without password: https://github.com/gliderlabs/docker-alpine/issues/430
27+
# (but note that the SUID binary is not executable after unsharing the usernamespace. so this issue is not critical)
28+
# 2. As of early October 2018, the upstream shadow newuidmap/newgidmap depends on CAP_SYS_ADMIN.
29+
# So we need to apply https://github.com/shadow-maint/shadow/pull/132 .
30+
FROM alpine AS idmap
31+
RUN apk add --no-cache autoconf automake build-base byacc gettext gettext-dev gcc git libcap-dev libtool libxslt
32+
RUN git clone https://github.com/giuseppe/shadow.git \
33+
&& cd shadow \
34+
&& git checkout 336cead97d87be6c4828521f50a992e76a17e442 \
35+
&& ./autogen.sh --disable-nls --disable-man --without-audit --without-selinux --without-acl --without-attr --without-tcb --without-nscd \
36+
&& make \
37+
&& cp src/newuidmap src/newgidmap /usr/bin
38+
39+
FROM alpine AS base
2640
MAINTAINER Jessica Frazelle <[email protected]>
27-
RUN apk add --no-cache \
28-
bash \
29-
git \
30-
shadow \
31-
shadow-uidmap \
32-
strace
41+
RUN apk add --no-cache git
3342
COPY --from=img /usr/bin/img /usr/bin/img
3443
COPY --from=runc /usr/bin/runc /usr/bin/runc
35-
ENV HOME /home/user
36-
RUN useradd --create-home --home-dir $HOME user \
37-
&& chown -R user:user $HOME /run /tmp
44+
COPY --from=idmap /usr/bin/newuidmap /usr/bin/newuidmap
45+
COPY --from=idmap /usr/bin/newgidmap /usr/bin/newgidmap
46+
RUN chmod u+s /usr/bin/newuidmap /usr/bin/newgidmap \
47+
&& adduser -D -u 1000 user \
48+
&& mkdir -p /run/user/1000 \
49+
&& chown -R user /run/user/1000 /home/user \
50+
&& echo user:100000:65536 | tee /etc/subuid | tee /etc/subgid
51+
# As of v3.8.1, Alpine does not set SUID bit on the busybox version of /bin/su.
52+
# However, future version may set SUID bit on /bin/su.
53+
# We lock the root account so as to disable su completely.
54+
RUN passwd -l root
55+
56+
FROM base AS debug
57+
RUN apk add --no-cache bash strace
58+
59+
FROM base AS release
3860
USER user
3961
ENV USER user
62+
ENV HOME /home/user
63+
ENV XDG_RUNTIME_DIR=/run/user/1000
4064
ENTRYPOINT [ "img" ]
4165
CMD [ "--help" ]

0 commit comments

Comments
 (0)