feature: add setcap-netbind
authorRyan Burnette <ryan.burnette@gmail.com>
Sun, 25 Jul 2021 14:50:55 +0000 (10:50 -0400)
committerAJ ONeal <aj@therootcompany.com>
Sun, 21 Nov 2021 04:57:59 +0000 (04:57 +0000)
setcap-netbind/README.md [new file with mode: 0644]
setcap-netbind/install.sh [new file with mode: 0644]
setcap-netbind/setcap-netbind.sh [new file with mode: 0644]
vps-utils/README.md
vps-utils/cap-net-bind.sh [changed from file to symlink]

diff --git a/setcap-netbind/README.md b/setcap-netbind/README.md
new file mode 100644 (file)
index 0000000..47431ab
--- /dev/null
@@ -0,0 +1,23 @@
+---
+title: setcap-netbind
+homepage: https://github.com/webinstall/webi-installers/setcap-netbind/README.md
+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
+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.
+
+## Cheat Sheet
+
+```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))
+```
diff --git a/setcap-netbind/install.sh b/setcap-netbind/install.sh
new file mode 100644 (file)
index 0000000..b30f73b
--- /dev/null
@@ -0,0 +1,10 @@
+#!/bin/bash
+
+{
+    set -e
+    set -u
+
+    rm -f "$HOME/.local/bin/setcap-netbind"
+    webi_download "$WEBI_HOST/packages/setcap-netbind/setcap-netbind.sh" "$HOME/.local/bin/setcap-netbind"
+    chmod a+x "$HOME/.local/bin/setcap-netbind"
+}
diff --git a/setcap-netbind/setcap-netbind.sh b/setcap-netbind/setcap-netbind.sh
new file mode 100644 (file)
index 0000000..08f1fea
--- /dev/null
@@ -0,0 +1,17 @@
+#!/bin/bash
+
+{
+    set -e
+    set -u
+
+    my_bin="$1"
+    if [ -z "$(which $my_bin)" ]; then
+        echo "'$my_bin' not found"
+        exit 1
+    fi
+    my_sudo=""
+    if [ -n "$(command -v sudo)" ]; then
+        my_sudo=sudo
+    fi
+    $my_sudo setcap 'cap_net_bind_service=+ep' $(readlink -f $(which $my_bin))
+}
index 5d49555c0c415c596c81607063ea4af35189f3c3..a81dd2cccab3f7faeee1c02a3bd73a90f03b0ae3 100644 (file)
@@ -8,16 +8,16 @@ tagline: |
 ## Cheat Sheet
 
 > VPS Utils includes shortcut commands for some common tasks, including
-> `cap-net-bind`, 'vps-addswap', and 'myip'
+> `setcap-netbind`, 'vps-addswap', and 'myip'
 
-**cap-net-bind**:
+**setcap-netbind**:
 
-`cap-net-bind` will give the specified program the ability to listen on
+`setcap-netbind` will give the specified program the ability to listen on
 privileged ports, such as 80 (http) and 443 (https) without `root` privileges or
 `sudo`.
 
 ```bash
-sudo cap-net-bind node
+sudo setcap-netbind node
 ```
 
 This is the same as running the full command:
deleted file mode 100644 (file)
index 08f1fea56df743dca26ac95f542b93ea566f3f2b..0000000000000000000000000000000000000000
+++ /dev/null
@@ -1,17 +0,0 @@
-#!/bin/bash
-
-{
-    set -e
-    set -u
-
-    my_bin="$1"
-    if [ -z "$(which $my_bin)" ]; then
-        echo "'$my_bin' not found"
-        exit 1
-    fi
-    my_sudo=""
-    if [ -n "$(command -v sudo)" ]; then
-        my_sudo=sudo
-    fi
-    $my_sudo setcap 'cap_net_bind_service=+ep' $(readlink -f $(which $my_bin))
-}
new file mode 120000 (symlink)
index 0000000000000000000000000000000000000000..5ea063cc80fcd8cc4964cb6791154765db96f1b2
--- /dev/null
@@ -0,0 +1 @@
+../setcap-netbind/setcap-netbind.sh
\ No newline at end of file