mirror of
https://github.com/openai/codex.git
synced 2026-10-30 19:18:49 +00:00
fix: do not grant "node" user sudo access when using run_in_container.sh
This commit is contained in:
@@ -20,7 +20,6 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||
less \
|
||||
man-db \
|
||||
procps \
|
||||
sudo \
|
||||
unzip \
|
||||
ripgrep \
|
||||
zsh \
|
||||
@@ -50,7 +49,5 @@ RUN npm install -g codex.tgz \
|
||||
# Copy and set up firewall script
|
||||
COPY scripts/init_firewall.sh /usr/local/bin/
|
||||
USER root
|
||||
RUN chmod +x /usr/local/bin/init_firewall.sh && \
|
||||
echo "node ALL=(root) NOPASSWD: /usr/local/bin/init_firewall.sh" > /etc/sudoers.d/node-firewall && \
|
||||
chmod 0440 /etc/sudoers.d/node-firewall
|
||||
RUN chmod +x /usr/local/bin/init_firewall.sh
|
||||
USER node
|
||||
|
||||
@@ -57,8 +57,10 @@ docker run --name "$CONTAINER_NAME" -d \
|
||||
codex \
|
||||
sleep infinity
|
||||
|
||||
# Initialize the firewall inside the container.
|
||||
docker exec "$CONTAINER_NAME" bash -c "sudo /usr/local/bin/init_firewall.sh"
|
||||
# Initialize the firewall inside the container with root privileges. We avoid
|
||||
# using sudo inside the container altogether by invoking the script directly
|
||||
# as the root user via docker exec.
|
||||
docker exec --user root "$CONTAINER_NAME" /usr/local/bin/init_firewall.sh
|
||||
|
||||
# Execute the provided command in the container, ensuring it runs in the work directory.
|
||||
# We use a parameterized bash command to safely handle the command and directory.
|
||||
|
||||
Reference in New Issue
Block a user