X-Git-Url: https://git.josue.xyz/?p=webi-installers%2F.git;a=blobdiff_plain;f=setcap-netbind%2FREADME.md;h=6169094300a89be249c48637550305e78b9d0912;hp=47431ab4478d652cdd48eff1a7ed7dc0e177a6e2;hb=85a5689dbb79c3c0bead61586c294cfd1585a1d1;hpb=46af5a3ca3b22ed8716b6a97e06cc6fbcba1d9c3 diff --git a/setcap-netbind/README.md b/setcap-netbind/README.md index 47431ab..6169094 100644 --- a/setcap-netbind/README.md +++ b/setcap-netbind/README.md @@ -1,23 +1,64 @@ --- title: setcap-netbind -homepage: https://github.com/webinstall/webi-installers/setcap-netbind/README.md +homepage: https://github.com/webinstall/webi-installers/setcap-netbind/ tagline: | setcap-netbind: Give a binary the ability to bind to privileged ports. --- -setcap-netbind will grant the specified program the ability to listen on +## Cheat Sheet + +> Because no one can ever remember `setcap 'cap_net_bind_service=+ep'`. +> Everybody has to look it up. Every. Time. +> +> Well... not anymore. +> +> `setcap-netbind` does that ^^, plus it follows links - which is nice. + +Gives a command permission to run on privileged ports (80, 443, etc). + +```txt +Usage: + sudo setcap-netbind + +Example: + sudo setcap-netbind node +``` + +`setcap-netbind` will grant the specified program the ability to listen on privileged ports, such as 80 (http) and 443 (https) without root privileges or -sudo. It seeks out the specified binary in your path and reads down symlinks to -make usage as painless as possible. +`sudo`. It seeks out the specified binary in your path and reads down symlinks +to make usage as painless as possible. -## Cheat Sheet +**_Note_**: Capability binding is specific to a particular binary file. You'll +need to rerun `setcap-netbind ` each time you upgrade or reinstall a +command. + +# How to use plain setcap + +These two commands are equivalent: ```bash sudo setcap-netbind node ``` -This is the same as running the full command: - ```bash -sudo setcap 'cap_net_bind_service=+ep' $(readlink -f $(which node)) +sudo setcap 'cap_net_bind_service=+ep' "$(readlink -f "$(command -v node)")" ``` + +The benefit of `setcap-netbind` is simply that it's easier to remember (and will +auto-complete with tab), and it will follow symbolic links. \ +(`setcap` will not work on symlinks - probably as a security measure) + +