Skip to content
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

Adding server port ask for root password #96

Closed
cancerberoSgx opened this issue Jul 15, 2018 · 18 comments
Closed

Adding server port ask for root password #96

cancerberoSgx opened this issue Jul 15, 2018 · 18 comments
Labels

Comments

@cancerberoSgx
Copy link
Contributor

This works in my system (arch linux, node 10, latest puppeteteer, jest, etc)

  launch: {
    args: ['--no-sandbox'],
  },
  server: {
    command: `node dist/test-scripts/server-mocks/server1.js`,
  }

But if I add the port number, (high number like 3001 and not busy) then the test interrupts and the terminal ask for my root password like sudo. Is that normal? I'm not entering my root password for running a test, at all and I know in my system my user has permissions to open / close it...

I'm able to run the command manually OK. I tried with headless: false, --disable-setuid-sandbox and
--usedPortAction: 'error' but with no luck,

DO you think this is a problem with sandbox ? I wanted to report this since recent security incidents in npmjs.org - sore is nothing but just in case.

Will try to reproduce the issue in jest-dev-server. Any tip / help is appreciated. Thanks - good work, keep it up

@CyrilQuandalle
Copy link

Hi,
I have the same issue, even if I change the rights on the npm root folder it is still asking me for my root password.
Is there any workaround that you have found @cancerberoSgx ?

@gregberge
Copy link
Member

I think it is a problem in your server. You should try to run "npm start" without Jest Puppeteer and see what's going on. The requirement of a root password can be multiple things: a usage of a restricted port, the execution rights of the process...

This issue is not relative to Jest Puppeteer but I let it opened if someone want to help.

@cancerberoSgx
Copy link
Contributor Author

cancerberoSgx commented Aug 15, 2018

@neoziro I wouldn't be so sure about "This issue is not relative to Jest Puppeteer". I use lots of different servers, using the same terminal, user, port, interface, groups, interfaces both for puppeteer and also other servers on top of jest and never had this problem. Did you tried to reproduce the issue in arch linux at least ? is as easy as providing the configuration I just did in my first comment. I had reproduce it using arch linux and manjaro linux (archlinux - based distribution). Both are very popular linux distros BTW. Will try to see if the same happens on debian or other distros but unfortunately don't have much time to invest on this. Thanks.
@CyrilQuandalle no I didn't found any workaround for this

@CyrilQuandalle
Copy link

CyrilQuandalle commented Aug 16, 2018

Thank you for your answer @cancerberoSgx, @neoziro ;-)
I ended up using npm-run-all to run my tasks in parallele: starting the server and running the tests with race condition options to kill the server at the end of the tests ;-)

@BenoitZugmeyer
Copy link

I have the same issue. This is because jest-dev-server is using find-process to find the process with a given port, and find-process is using the command sudo netstat -tunlp.

This is really unfortunate, this project seemed nice but I really can't enter my root password every time I need to run tests. I guess setting config.usedPortAction = 'ignore' should not run find-process at all, so no sudo would be needed.

@gregberge
Copy link
Member

@BenoitZugmeyer good catch thanks, so it is actually a bug.

@gregberge gregberge added bug and removed help wanted labels Sep 4, 2018
@rs-8
Copy link

rs-8 commented Sep 7, 2018

I have the same. config.usedPortAction = 'ignore' this doesnt work for me. So how can i fix that?

@gregberge gregberge added bug 🐛 and removed bug labels Sep 23, 2018
@cancerberoSgx
Copy link
Contributor Author

Any news on this ? Why is it jest-puppeteer scanning my processes ? IMO, As the user I expect to be responsible of providing the port number, if it's busy is my problem. This tool should just open the server on that port and that's it. Thanks.

@yaniv-li
Copy link

I workaround (hack) would be to put
global.process.getuid = () => 0;
at the top of the jest-puppeteer.config.js file before module.export
if it has no implications for your tests.
If it has just copy the function before global.process._getuid = global.process.getuid;
and resign it after the server starts at the beginning of your test.

cancerberoSgx added a commit to cancerberoSgx/jest-puppeteer that referenced this issue Nov 6, 2018
@mzedeler
Copy link
Contributor

mzedeler commented Nov 8, 2018

I don't understand why this was closed. I would expect jest-puppeteers server setting to work out of the box with no password prompt if usedPortAction is set to error. Right now it prompts me for my password, even when the port is available(?!?).

@gregberge
Copy link
Member

I think it is not possible to test if port is used without sudo. In fact it is because I had never experienced this issue on Mac.

Anyway I can't do anything for it, you should investigate in find-process package and try to patch it to avoid this.

@mzedeler
Copy link
Contributor

mzedeler commented Nov 8, 2018

I can't see how that is necessary, unless you either want to bind to ports numbered less than 1024 or want to get the process id of the process listening to the port.

Here is a tiny POC:

node -e "server = require('net').createServer(() => {}); server.on('error', console.log); server.listen(5433);"
{ Error: listen EADDRINUSE :::5433
...

(I have something on that port.)

@mzedeler
Copy link
Contributor

mzedeler commented Nov 8, 2018

If usedPortAction is set to error, it won't ever be required to get the process id of the listening process.

@gregberge
Copy link
Member

Yes you are right, could you submit a fix?

@mzedeler
Copy link
Contributor

mzedeler commented Nov 8, 2018

Ok. I'm on it :-)

@mzedeler
Copy link
Contributor

mzedeler commented Nov 8, 2018

@neoziro - I suppose the fix goes into jest-dev-server, not jest-puppeteer.

@gregberge
Copy link
Member

Of course 😉, but it is in the same repo.

mzedeler added a commit to mzedeler/jest-puppeteer that referenced this issue Nov 8, 2018
@mzedeler
Copy link
Contributor

mzedeler commented Nov 8, 2018

#149

I haven't had time to test it yet, but I'd like to know if this is the right direction, I'm taking.

gregberge pushed a commit that referenced this issue Nov 11, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

7 participants