S
S
Svyatoslav Khusamov2016-08-02 10:55:54
linux
Svyatoslav Khusamov, 2016-08-02 10:55:54

How to give a user access to port 80 in Linux?

A program that tries to occupy port 80 (for example, apache) can be run as root.
But it can't be run as a different user. Error No privileges for this operation.
How to give the user access to these privileges?
Don't suggest the sudo command as I need to get rid of the need to enter any passwords.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
M
Mikhail Osher, 2016-08-02
@khusamov

➜  ~ sudo cat /etc/sudoers | grep miraage
miraage ALL=(ALL) NOPASSWD: ALL

Do the same in your file, except substitute your username.

D
D', 2016-08-02
@Denormalization

Use sudo with the option to run without a password.

M
Mystray, 2016-08-02
@Mystray

Well, the answer is googled.

Now for the caveats:
  • You will need at least a 2.6.24 kernel
  • This won't work if your file is a script. (ie, uses a #! line to launch an interpreter). In this case, as far I as understand, you'd have to apply the capability to the interpreter executable itself, which of course is a security nightmare, since any program using that interpreter will have the capability. I wasn't able to find any clean, easy way to work around this problem.
  • Linux will disable LD_LIBRARY_PATH on any program that has elevated privileges like setcap or suid. So if your program uses its own .../lib/, you might have to look into another option like port forwarding.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question