-
Notifications
You must be signed in to change notification settings - Fork 78
fix: set owner of Node.js dependencies #1196
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @qwersem Thanks for your contribution!
PR titles need to follow an appropriate structure, since they are used as part of the commits message in UDB, I changed the title from "Set owner of Node.js dependencies" to "fix: set owner of Node.js dependencies" so it passes the CI. If you prefer any other, feel free to change it.
I'm very unaware of the problem you described, so I'll let others chime in to approve.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1196 +/- ##
=======================================
Coverage 46.05% 46.05%
=======================================
Files 11 11
Lines 4942 4942
Branches 1345 1345
=======================================
Hits 2276 2276
Misses 2666 2666
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
@AFOliveira thanks |
|
This doesn't seem like a bug that should be fixed in this repository. Do all other node.js repos have this workaround? What provokes it, and are we doing something wrong that leads to these ownership states? Is it because we're pretending to be root within the container? |
|
As @ThinkOpenly mentions, I think you are trying to solve a container problem here. If that's the case, we should probably figure out a solution that does something with the Dockerfile rather than try to adjust settings out of context. |
|
@ThinkOpenly , I encountered this problem when unprivileged shell |
|
Do all other node.js repos have this workaround? |
|
What provokes it, and are we doing something wrong that leads to these ownership states? Is it because we're pretending to be root within the container? I think it depends on how provided package was deployed. If we compare a couple of $ git clone https://github.com/riscv-software-src/riscv-unified-db.git
$ docker run -it -v $PWD:$PWD -w "$PWD" riscvintl/udb:0.9 bash
$ wget https://registry.npmjs.org/yauzl/-/yauzl-2.10.0.tgz
$ tar --same-owner -xvzf yauzl-2.10.0.tgz
$ ls -l package/
total 84
-rw-rw-r-- 1 ubuntu ubuntu 1077 Apr 23 2018 LICENSE
-rw-rw-r-- 1 ubuntu ubuntu 31177 Jul 3 2018 README.md
-rw-r--r-- 1 root root 7872 Oct 26 1985 fd-slicer.js
-rw-rw-r-- 1 ubuntu ubuntu 33069 Jul 3 2018 index.js
-rw-rw-r-- 1 ubuntu ubuntu 881 Jul 3 2018 package.json
# OWNER IS UBUNTU
$ wget https://registry.npmjs.org/yauzl/-/yauzl-3.0.0.tgz
$ tar --same-owner -xvzf yauzl-3.0.0.tgz
$ ls -l package/
total 88
-rw-r--r-- 1 root root 1077 Oct 26 1985 LICENSE
-rw-r--r-- 1 root root 33238 Oct 26 1985 README.md
-rw-r--r-- 1 root root 7872 Oct 26 1985 fd-slicer.js
-rw-r--r-- 1 root root 33427 Oct 26 1985 index.js
-rw-r--r-- 1 root root 737 Oct 26 1985 package.json
# OWNER IS ROOT
$ cat /etc/passwd
root:x:0:0:root:/root:/bin/bash
ubuntu:x:1000:1000:Ubuntu:/home/ubuntu:/bin/bashLooks like $ npm i --verbose
...
npm http fetch GET 200 https://registry.npmjs.org/yauzl/-/yauzl-2.10.0.tgz 808ms (cache miss)
...
$ ll node_modules/yauzl/
total 92
drwxr-xr-x 2 root root 4096 Oct 28 18:01 ./
drwxr-xr-x 359 root root 12288 Oct 28 18:01 ../
-rw-r--r-- 1 ubuntu ubuntu 1077 Oct 28 18:01 LICENSE
-rw-r--r-- 1 ubuntu ubuntu 31177 Oct 28 18:01 README.md
-rw-r--r-- 1 ubuntu ubuntu 33069 Oct 28 18:01 index.js
-rw-r--r-- 1 ubuntu ubuntu 881 Oct 28 18:01 package.jso
# OWNER IS UBUNTU
$ npm i yauzl # v3.2.0 is the last version
$ ll node_modules/yauzl/
total 124
drwxr-xr-x 2 root root 4096 Oct 28 18:17 ./
drwxr-xr-x 345 root root 12288 Oct 28 18:17 ../
-rw-r--r-- 1 root root 1077 Oct 28 18:17 LICENSE
-rw-r--r-- 1 root root 46785 Oct 28 18:17 README.md
-rw-r--r-- 1 root root 8677 Oct 28 18:17 fd-slicer.js
-rw-r--r-- 1 root root 38952 Oct 28 18:17 index.js
-rw-r--r-- 1 root root 776 Oct 28 18:17 package.json
# OWNER IS ROOT |
|
@dhower-qc , We can install packages during to image build with |
ea2ea28 to
621f602
Compare
Few files in a node_modules/ folder belong to user who doesn’t exist in a host environmnet when `npm` installs external packages inside container. This change explicitly sets the owner for these files. Signed-off-by: Evgeny Semenov <[email protected]>
621f602 to
1a24992
Compare
|
I was working on it for other reasons, but I think #1220 will resolve this. |
|
@jordancarlin, agree with you, Global |
Few files in a node_modules/ folder belongs to user who doesn’t exist in a host environmnet when
npminstalls external packages inside container. This change explicitly sets the owner for these files.Steps to reproduce the issue