Frage

I have a snap application.

I'd like to run it on port 80 within ghci for local debugging purposes. Normally I'd run sudo ./main -p 80 on the compiled binary to achieve this, but within ghci I get a permission denied.

*Main> :main -p 80
Initializing app @ /
Initializing heist @ /heist
...loaded 35 templates from /Users/dmj/blah/templates
Initializing CookieSession @ /sess

Listening on http://0.0.0.0:80/
Error on startup:
bind: permission denied (Permission denied)

Shutting down...

It works on non-privileged ports.

*Main> :main -p 8000
Initializing app @ /
Initializing heist @ /heist
...loaded 35 templates from /Users/dmj/blah
Initializing CookieSession @ /sess
Initializing db @ /auth
Initializing acid-state @ /acid

Listening on http://0.0.0.0:8000/
War es hilfreich?

Lösung

See this post for another way: Is there a way for non-root processes to bind to "privileged" ports on Linux?

sudo setcap 'cap_net_bind_service=+ep' /usr/bin/ncat

Just substitute '/usr/bin/ncat' for your full path to ghci, and it should work.

(I am sure you have been nagged many times about how bad an idea it is to do any prolonged work as root.... Also, this is a Linux specific solution, so if you are working on a Mac or other *nix, this won't work for you).

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top