Skip to content

Commit

Permalink
[improve][sec] Add group pulsar and add user pulsar to it instead of …
Browse files Browse the repository at this point in the history
…root (#21084)

### Motivation

Currently, the user pulsar is in the root group, it would be better to use the non-root group to keep more safety. 

### Modifications

- Add group pulsar (GID 10000) 
- Add user pulsar (UID 10000) to group pulsar
  • Loading branch information
yaalsn authored Dec 7, 2023
1 parent ab77ca2 commit f25b082
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
9 changes: 7 additions & 2 deletions docker/pulsar/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,12 @@ RUN mkdir /pulsar && chmod g+w /pulsar

ENV PULSAR_ROOT_LOGGER=INFO,CONSOLE

COPY --from=pulsar /pulsar /pulsar
RUN groupadd -g 10000 pulsar && \
useradd -r -u 10000 -g pulsar pulsar

COPY --from=pulsar --chown=10000:10000 /pulsar /pulsar
RUN chown pulsar:pulsar /pulsar

WORKDIR /pulsar

ARG PULSAR_CLIENT_PYTHON_VERSION
Expand All @@ -106,4 +111,4 @@ RUN chmod +x /pulsar/bin/install-pulsar-client.sh
RUN /pulsar/bin/install-pulsar-client.sh

# The UID must be non-zero. Otherwise, it is arbitrary. No logic should rely on its specific value.
USER 10000
USER 10000:10000
6 changes: 3 additions & 3 deletions tests/docker-images/java-test-image/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@

FROM ubuntu:22.04

RUN groupadd -g 10001 pulsar
RUN adduser -u 10000 --gid 10001 --disabled-login --disabled-password --gecos '' pulsar
RUN groupadd -g 10000 pulsar && \
useradd -r -u 10000 -g pulsar pulsar

ARG PULSAR_TARBALL=target/pulsar-server-distribution-bin.tar.gz
ADD ${PULSAR_TARBALL} /
Expand Down Expand Up @@ -76,7 +76,7 @@ COPY target/java-test-functions.jar /pulsar/examples/

ENV PULSAR_ROOT_LOGGER=INFO,CONSOLE

RUN chown -R pulsar:0 /pulsar && chmod -R g=u /pulsar
RUN chown -R pulsar:pulsar /pulsar

# cleanup
RUN apt-get -y --purge autoremove \
Expand Down
4 changes: 0 additions & 4 deletions tests/docker-images/latest-version-image/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,6 @@ FROM apachepulsar/pulsar:latest
# However, any processes exec'ing into the containers will run as root, by default.
USER root

# We need to define the user in order for supervisord to work correctly
# We don't need a user defined in the public docker image, though.
RUN adduser -u 10000 --gid 0 --disabled-login --disabled-password --gecos '' pulsar

RUN rm -rf /var/lib/apt/lists/* && apt update

RUN apt-get clean && apt-get update && apt-get install -y supervisor vim procps curl
Expand Down

0 comments on commit f25b082

Please sign in to comment.