Is there a way for non-root processes to bind to “privileged” ports on Linux?

后端 未结 24 1273
予麋鹿
予麋鹿 2020-11-22 02:04

It\'s very annoying to have this limitation on my development box, when there won\'t ever be any users other than me.

I\'m aware of the standard workarounds, but non

24条回答
  •  梦如初夏
    2020-11-22 02:55

    With systemd, you just need to slightly modify your service to accept preactivated sockets.

    You can later use systemd socket activate.

    No capabilities, iptables or other tricks are needed.

    This is content of relevant systemd files from this example of simple python http server

    File httpd-true.service

    [Unit]
    Description=Httpd true 
    
    [Service]
    ExecStart=/usr/local/bin/httpd-true
    User=subsonic
    
    PrivateTmp=yes
    

    File httpd-true.socket

    [Unit]
    Description=HTTPD true
    
    [Socket]
    ListenStream=80
    
    [Install]
    WantedBy=default.target
    

提交回复
热议问题