aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/cgi-bin/get.sh
diff options
context:
space:
mode:
Diffstat (limited to '')
-rwxr-xr-xcgi-bin/get.sh17
1 files changed, 17 insertions, 0 deletions
diff --git a/cgi-bin/get.sh b/cgi-bin/get.sh
new file mode 100755
index 0000000..ea4f4ce
--- /dev/null
+++ b/cgi-bin/get.sh
@@ -0,0 +1,17 @@
+#!/usr/bin/env bash
+
+set -o errexit -o nounset -o pipefail
+
+script_dir="$( dirname -- "${BASH_SOURCE[0]}" )"
+script_dir="$( cd -- "$script_dir" && pwd )"
+readonly script_dir
+
+# Python's http.server runs CGI scripts under user nobody.
+# This is not what we want unfortunately.
+# The best solution I could find so far is to create an entry in
+# /etc/sudoers.d, allowing the nobody user to run the real scripts w/ sudo.
+if [ "$( id --user --name )" == nobody ]; then
+ sudo --non-interactive --preserve-env "$script_dir/get.py"
+else
+ "$script_dir/get.py"
+fi