'setcap' overwrites last capability. How do I set multiple capabilities?

7,389

And one last desperate syntax guess pays off:

# setcap cap_net_bind_service,cap_sys_boot=+ep /usr/bin/nodejs
# getcap /usr/bin/nodejs
/usr/bin/nodejs = cap_net_bind_service,cap_sys_boot+ep
Share:
7,389

Related videos on Youtube

JRob23123
Author by

JRob23123

Updated on September 18, 2022

Comments

  • JRob23123
    JRob23123 almost 2 years

    I want to give node.js the ability to listen on port 80, and shutdown the computer. Initially I tried these two commands in sequence:

    setcap cap_net_bind_service=+ep /usr/bin/nodejs
    setcap cap_sys_boot=+ep /usr/bin/nodejs
    

    Then my app was failing to bind to port 80. I checked with getcap:

    # getcap /usr/bin/nodejs
    /usr/bin/nodejs = cap_sys_boot+ep
    

    If I run setcap again for cap_net_bind_service:

    # getcap /usr/bin/nodejs
    /usr/bin/nodejs = cap_net_bind_service+ep
    

    I don't see anything in the man page http://linux.die.net/man/8/setcap about setting multiple capabilities, and try some things in desperation:

    # setcap cap_net_bind_service=+ep /usr/bin/nodejs cap_sys_boot=+ep /usr/bin/nodejs
    # getcap /usr/bin/nodejs
    /usr/bin/nodejs = cap_sys_boot+ep
    # setcap cap_net_bind_service=+ep cap_sys_boot=+ep /usr/bin/nodejs
    Failed to set capabilities on file `cap_sys_boot=+ep' (No such file or directory)
    

    How do I set multiple capabilities?­­­­­­­

  • ctrl-alt-delor
    ctrl-alt-delor about 9 years
    please tick. You have the correct answer.