Skip to content

Commit

Permalink
Dockerfiles: fix checking existence of requested group
Browse files Browse the repository at this point in the history
Besides that egrep is deprecated, the command was intended to be run
against /etc/groups, but acted on stdin.

getent is a much cleaner way to do the check anyway.

Signed-off-by: Yann Dirson <[email protected]>
Cc: Simone Conti <[email protected]>
  • Loading branch information
ydirson committed Nov 10, 2023
1 parent 1b37ef1 commit 2fe411b
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Dockerfile-7.x
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ RUN bash -c ' \
if [ -z "${CUSTOM_BUILDER_GID}" ]; then \
CUSTOM_BUILDER_GID="${CUSTOM_BUILDER_UID}"; \
fi; \
if ! egrep -q "^.*:.:${CUSTOM_BUILDER_GID}:"; then \
if ! getent group "${CUSTOM_BUILDER_GID}" >/dev/null; then \
groupadd -g "${CUSTOM_BUILDER_GID}" builder; \
fi; \
useradd -u "${CUSTOM_BUILDER_UID}" -g "${CUSTOM_BUILDER_GID}" builder; \
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile-8.x
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ RUN bash -c ' \
if [ -z "${CUSTOM_BUILDER_GID}" ]; then \
CUSTOM_BUILDER_GID="${CUSTOM_BUILDER_UID}"; \
fi; \
if ! egrep -q "^.*:.:${CUSTOM_BUILDER_GID}:"; then \
if ! getent group "${CUSTOM_BUILDER_GID}" >/dev/null; then \
groupadd -g "${CUSTOM_BUILDER_GID}" builder; \
fi; \
useradd -u "${CUSTOM_BUILDER_UID}" -g "${CUSTOM_BUILDER_GID}" builder; \
Expand Down

0 comments on commit 2fe411b

Please sign in to comment.