-
-
Notifications
You must be signed in to change notification settings - Fork 62
git fetcher fails if opts.uid is used to drop privileges #105
Comments
Nice! This is good sleuthing. This seems focused enough, too, that it might be a good starter issue, since it sounds like the primary fix is to make sure perms are correct on that tmp dir? |
This bug has left NPM 5.x.x broken since no global installs can be made. Is this scheduled to be fixed? |
This is a major blocker for my company |
It's a blocker for me too. |
update: I'm working on this now. It's important to point out that the |
Well you can't run |
update 2: this fell by the wayside and I'm unlikely to tackle it for a while, so if any brave soul wants to take it on, please be my guest! |
Hi all! So, I'm a total noob on node.js, but since this is a blocker bug for us, I figured I might just take a look anyway... :-) When look at cacache it looks like it should be doing this for us. Is that the correct interpretation of those docs? Based on that, I figured it might either be that |
@kjetilk I would be very surprised if cacache were causing this. I'm pretty sure the issue is between |
OK, thanks a lot for the quick response, @zkat ! That's good to know! |
As reported in zkat#105 `pacote` does not set permissions on temporary directories for git fetcher when opts.uid is used to drop privileges (e.g. when using sudo). This fix passes in the uid and gid to cacache as options. No checking is required as cacache checks these options before using them.
I created a PR with a fix that "works for me". I found this issue via the older issue: npm/npm#16898 (edit): Tested with:
|
💯 need this fix |
As reported in #105 `pacote` does not set permissions on temporary directories for git fetcher when opts.uid is used to drop privileges (e.g. when using sudo). This fix passes in the uid and gid to cacache as options. No checking is required as cacache checks these options before using them.
The git fetcher goes wrong if
opts.uid
is used to drop privileges, whichnpm
does by default when running undersudo
.Reproduction steps:
sudo
privileges. (I usedlxc launch ubuntu:16.04 pacote-test
followed bylxc exec pacote-test su - ubuntu
.)nvm
and usednvm install 8.1.3
followed bynvm use 8.1.3
.)package.json
:sudo PATH="$PATH" sh -c 'npm i'
. (ThePATH
andsh
wrangling is to work aroundsudo
's defaults so that it can find npm, and you may not need them in all setups.) This says:This happens because the fetcher makes a temporary
git-clone-...
directory and then tries to rungit clone
inside that, but it doesn't chown/chgrp the temporary directory toopts.uid
andopts.gid
, sogit clone
can't write to it. I think chown/chgrping the temporary directory would fix this.(This came up in the context of building snaps. At the moment our builders run
snapcraft
as root undersudo
, which is mostly fine because they're running in a throwaway container anyway; but it causes us to run into this bug. We may switch to running as non-root to work around it.)The text was updated successfully, but these errors were encountered: