Skip to content

[BUG] root permissions do not carry forward into execution  #3110

@ReillyBova

Description

@ReillyBova

Current Behavior:

I am using webpack to bind a dev server to the privileged port 443 on an M1 Macbook Air (Apple Silicon) running the latest version of Big Sur. In order to bind to the privileged port, my npm start script must be run with root permissions, so I execute sudo npm start. Unfortunately, the root permissions do not carry into the execution, and my server fails to bind to port 443 and throws an error that is identical to the error thrown when run without sudo:

✖ 「wds」:  Error: listen EACCES: permission denied 127.0.0.1:443
    at Server.setupListenHandle [as _listen2] (net.js:1301:21)
    at listenInCluster (net.js:1366:12)
    at GetAddrInfoReqWrap.doListen [as callback] (net.js:1503:7)
    at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:69:8) {

Expected Behavior:

I expect sudo npm run to have no issues binding to port 443 because it has root permissions. This is how it behaves when I backdate npm to 6.14.12.

Steps To Reproduce:

  1. Create an npm start script that tries to bind to a privileged port (e.g. 443)
  2. Run npm start with root permissions (e.g. sudo npm start if on a Mac)
  3. You should see an error
  4. Try binding to the same port directly in your terminal using root permissions
  5. You should not see an error
  6. Redo steps 1-3 using npm v6. Confirm no error is thrown.

I'm not sure how broad this issue is. Here are some open questions:

  1. Is this just related to binding to privileged ports?
  2. Is this just an M1 Apple Silicon problem?
  3. Is this just a Mac OS 11 problem?
  4. Is this an issue on all Mac OS versions?
  5. Is this an issue on all devices?
  6. Etc.

Environment:

  • OS macOS Big Sur 11.2.3
  • Node: 14.16.1
  • npm: 7.10.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    Bugthing that needs fixingNeeds Triageneeds review for next stepsRelease 7.xwork is associated with a specific npm 7 release

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions