Closed eckdanny closed 11 months ago
I would advocate against this change. While it may solve the problem, it compromises security by allowing a non-root user access to a directory that should be reserved for root.
I think this would best solved at image build-time by adding following cmd to Dockerfile(s):
chgrp 1000 /usr/local/bin && chmod g+w /usr/local/bin
I maintain a suite of private org-level images which extend docker.io/_/node:{18,20}, and that's what I did.
Proper ACLs (via
setfacl
) would be probably be best, but unlikely that'll be available for all targets/upstreams. Unless maintainers are opposed to granting group=node write perms to /usr/local/bin, i don't think there's a simpler way.
@meyfa If you know of a better way, happy to resubmit
After symlinking into $HOME/bin
, corepack {prepare,use,...}
commands behave exactly how we'd like for the non-root user. Playing with the Dockerfile-debian.template a bit:
&& rm yarn-v$YARN_VERSION.tar.gz.asc yarn-v$YARN_VERSION.tar.gz \
+ && NODE_HOME="$(getent passwd node | cut -d: -f6)" \
+ && mkdir -p $NODE_HOME/bin && ln -s "$(which corepack)" $NODE_HOME/bin/corepack \
+ && echo 'export PATH="$HOME/bin:$PATH"' >>$NODE_HOME/.bashrc && chown -R node:node $NODE_HOME/bin \
# smoke test
&& yarn --version
achieves desired outcome. (The PATH precedence stuff is already in /home/node/.profile
but the entrypoint is not a login shell so that's why I append to .bashrc
)
Thoughts?
Description
Makes
gid=1000
(the non-root usernode
's group id) the owning group of/usr/local/bin
. This enables the non-root user to perform operations likecorepack {enable,prepare,...}
without permission errors.Closes 1732.
Testing Details
manual: (see Q about testing in checklist section)
Example Output(if appropriate)
Types of changes
Checklist
tests? I don't see how to run a suite