How do I run my application as superuser from Eclipse?

后端 未结 9 1546
闹比i
闹比i 2020-11-29 09:35

I\'m running in to an error when I try to run my server application from Eclipse. The error is java.net.BindException: Permission denied. I think this is be

9条回答
  •  温柔的废话
    2020-11-29 09:51

    You may go this way

    1. create a Makefile with javac calls
    2. add the following line:
    setcap 'cap_net_admin=+ep' Server
    
    1. configure sudo to allow your Eclipse user to run setcap.

    So you will have a transparent debugging (no sudo wrapper - gdb ok). Cons: it is a local security breach.

    Solution:

    put this to /opt/my-stupid-eclipse

    #!/bin/sh

    setcap 'cap_net_admin=+ep cap_net_raw=+ep' $1

    chmod +x this script and whitelist it on sudo config.

    username ALL=(ALL) NOPASSWD: /opt/my-stupid-eclipse

    Add it to your makefile, specify path to your Server binary.

    Now you have pretty strange but secure script, that cannot be changed by other users... and still a little breach for replacing Server binary with any malicious code, that will gain caps, so no filename check/stricts will help.. can $1 be contaminated with bash commands, no? Guess, no.

提交回复
热议问题