Merge remote-tracking branch 'origin/main'

This commit is contained in:
Elizabeth Cray 2023-10-07 00:29:24 +00:00
commit 1bff1109b8
4 changed files with 90 additions and 0 deletions

Binary file not shown.

9
auth/gem.html Normal file
View File

@ -0,0 +1,9 @@
<div class="row">
<div class="col">Enable Web Proxy</div>
<div class="col">
<label class="switch">
<input type="checkbox" id="gemini-proxy" checked>
<span class="slider round"></span>
</label>
</div>
</div>

View File

@ -37,4 +37,16 @@ function returnSuccess($success, $refreshToken = ""){
));
exit();
}
function getUsers(){
return explode("\n", shell_exec("cut -d: -f1 /etc/passwd"));
}
function userExists($user){
return in_array($user, getUsers());
}
function geminiProxy($user, $action){
return shell_exec("/usr/bin/sudo /etc/ttyserver/bin/toggleProxy ".$action." \"".$user."\"");
}
?>

69
tools/toggleProxy Executable file
View File

@ -0,0 +1,69 @@
#!/bin/bash
# $1 - get / enable / disable
# $2 - optional username
ru=$USER
if [ "$EUID" != 0 ]; then
# Only for running user
if [ "$2" != "$USER" ]; then
echo "Cannot run for user other than yourself without superuser privileges."
exit 0
fi
else
# Run for specified user
if [ "$2" != "" ]; then
ru=$2
else
ru="root"
fi
fi
hd="$(eval echo ~$ru)/public_gemini"
if [ "$1" == "get" ]; then
if [ -d "$hd" ]; then
# gemini dir exists
if [ -r "$hd/.serve_ok" ]; then
echo "enabled"
else
echo "disabled"
fi
else
echo "no_exist"
fi
elif [ "$1" == "enable" ]; then
if [ -d "$hd" ]; then
if [ -r "$hd/.serve_ok" ]; then
echo "done"
else
touch "$hd/.serve_ok"
chown "$ru" "$hd/.serve_ok"
echo "done"
fi
else
mkdir "$hd"
touch "$hd/.serve_ok"
chown "$ru" -R "$hd"
echo "done"
fi
elif [ "$1" == "disable" ]; then
if [ -d "$hd" ]; then
if [ -w "$hd/.serve_ok" ]; then
rm "$hd/.serve_ok"
echo "done"
else
if [ -r "$hd/.serve_ok" ]; then
echo "no_perm"
else
echo "done"
fi
fi
else
echo "no_dir"
fi
else
# TODO: display command help guide
echo "TODO"
fi