-
-
Notifications
You must be signed in to change notification settings - Fork 31.7k
Mac Installer: npm and npx created with wrong permissions #57548
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
Comments
This is especially bad because To fix it one has to:
|
It's doing exactly what you told it to, right? Don't change your umask if you don't want that. It's like the old joke about a man who goes to visit his MD. "Doc, it bleeds when I cut myself." "Then stop doing that!" |
I am not sure where your hostile attitude comes from, but I hope you are having a nice day. Currently, the NodeJS installer respects the umask configured for users apps only for
This is inconsistent: It should either respect the umask configured for users apps for all files or none. Let’s see what the docs say: Set a custom umask in macOS — Umask for user apps
Yes, an installer is an app, so one might argue that it should respect the umask for user apps. On the other hand, one could argue that an installer is a special kind of app. The NodeJS installer only supports System-wide installation. Therefore, the installed binaries should have read and execute permissions for owner, group, and other so that they are accessible System-wide, i.e. by all users. |
One can also set the unmask for system processes but that should not be used by an installer either. |
npm, npx and corepack are all created the exact same way. I suspect you installed multiple versions over each other. Note how the timestamps and group names are different. Apropos umask: if someone wants to install node and cut out group or other, they should be able to. You don't like what it did to your local install but that's entirely self-inflicted, it's classic PEBKAC. |
They are not.
No, the installer is responsible. $ curl -sO https://nodejs.org/dist/v22.14.0/node-v22.14.0.pkg
$ shasum node-v22.14.0.pkg
f1d93dde78a2353afa56d750a4a205172d91606c node-v22.14.0.pkg
$ pkgutil --expand node-v22.14.0.pkg node22
$ tree -I Distribution -I Resources --noreport node22
node22
├── node-v22.14.0.pkg
│ ├── Bom
│ ├── PackageInfo
│ └── Payload
└── npm-v10.9.2.pkg
├── Bom
├── PackageInfo
├── Payload
└── Scripts
├── postinstall
└── preinstall
$ cat node22/npm-v10.9.2.pkg/Scripts/postinstall
#!/bin/sh
cd /usr/local/bin || exit 1
ln -sf ../lib/node_modules/npm/bin/npm-cli.js npm
ln -sf ../lib/node_modules/npm/bin/npx-cli.js npx $ tar -tvf node22/node-v22.14.0.pkg/Payload | grep 'bin/node'
-rwxr-xr-x 1 0 0 220243216 Feb 11 05:31 ./usr/local/bin/node
$ tar -tvf node22/npm-v10.9.2.pkg/Payload | grep 'npm-cli'
-rwxr-xr-x 1 0 0 54 Oct 8 09:19 ./usr/local/lib/node_modules/npm/bin/npm-cli.js
$ tar -tvf node22/npm-v10.9.2.pkg/Payload | grep 'npx-cli'
-rwxr-xr-x 1 0 0 2921 Oct 8 09:20 ./usr/local/lib/node_modules/npm/bin/npx-cli.js All files are copied with the correct permissions, but the That is why everything is fine exept for the A fix would be: #!/bin/sh
cd /usr/local/bin || exit 1
umask 022
ln -sf ../lib/node_modules/npm/bin/npm-cli.js npm
ln -sf ../lib/node_modules/npm/bin/npx-cli.js npx |
I think it's worth asking the question whether this |
$ tar -tvf node22/node-v22.14.0.pkg/Payload | grep './usr/local/bin'
drwxr-xr-x 4 0 0 0 Feb 11 05:31 ./usr/local/bin
-rwxr-xr-x 1 0 0 220243216 Feb 11 05:31 ./usr/local/bin/node
lrwxr-xr-x 1 0 0 45 Feb 11 05:31 ./usr/local/bin/corepack -> ../lib/node_modules/corepack/dist/corepack.js
unlink $(MACOSOUTDIR)/dist/node/usr/local/bin/npm
unlink $(MACOSOUTDIR)/dist/node/usr/local/bin/npx
$(NODE) tools/license2rtf.mjs < LICENSE > \
$(MACOSOUTDIR)/installer/productbuild/Resources/license.rtf
cp doc/osx_installer_logo.png $(MACOSOUTDIR)/installer/productbuild/Resources
pkgbuild --version $(FULLVERSION) \
--identifier org.nodejs.node.pkg \
--root $(MACOSOUTDIR)/dist/node $(MACOSOUTDIR)/pkgs/node-$(FULLVERSION).pkg
pkgbuild --version $(NPMVERSION) \
--identifier org.nodejs.npm.pkg \
--scripts ./tools/macos-installer/pkgbuild/npm/scripts \
--root $(MACOSOUTDIR)/dist/npm \
$(MACOSOUTDIR)/pkgs/npm-$(NPMVERSION).pkg Notice the unlink, maybe it should be changed to: pkgbuild --version $(FULLVERSION) \
--identifier org.nodejs.node.pkg \
--root $(MACOSOUTDIR)/dist/node $(MACOSOUTDIR)/pkgs/node-$(FULLVERSION).pkg
// add the two links again here
pkgbuild --version $(NPMVERSION) \
--identifier org.nodejs.npm.pkg \
--scripts ./tools/macos-installer/pkgbuild/npm/scripts \
--root $(MACOSOUTDIR)/dist/npm \
$(MACOSOUTDIR)/pkgs/npm-$(NPMVERSION).pkg |
Fixes: nodejs#57660 Fixes: nodejs#57548. Signed-off-by: Sebastian Davids <[email protected]>
see #57661 (comment) |
Uh oh!
There was an error while loading. Please reload this page.
Version
22.14.0
Platform
What steps will reproduce the bug?
Set a custom umask in macOS - Apple Support
Verify
Download the installer:
https://nodejs.org/dist/v22.14.0/node-v22.14.0.pkg
Execute the installer.
How often does it reproduce? Is there a required condition?
Always.
What is the expected behavior? Why is that the expected behavior?
The symlinks have the correct permissions:
rwxr-xr-x
What do you see instead?
The symlinks have the incorrect permission:
rwx------
Additional information
I think all macOS installer versions are affected.
So this might have to be backported…
The text was updated successfully, but these errors were encountered: