46 lines
885 B
Python
Executable file
46 lines
885 B
Python
Executable file
#!/usr/bin/env python3
|
|
|
|
import os, sys, cgitb
|
|
from dotenv import load_dotenv
|
|
|
|
# Log errors to disk only
|
|
cgitb.enable(display=0, logdir="/var/log/gemini", format="plain")
|
|
|
|
# Load config
|
|
load_dotenv()
|
|
msg_file = os.getenv("MESSSAGE_FILE")
|
|
admin_fp = os.getenv("ADMIN_CERT")
|
|
|
|
# Load CGI vars
|
|
cert_fp = os.getenv("TLS_CLIENT_HASH")
|
|
action = os.getenv("QUERY_STRING")
|
|
|
|
if None == cert_fp :
|
|
# Prompt for client cert
|
|
print("60 Admin only\r")
|
|
sys.exit()
|
|
|
|
if admin_fp != cert_fp :
|
|
# Incorrect cert
|
|
print("61 Admin only\r")
|
|
sys.exit()
|
|
|
|
print("20 text/gemini; lang=en-GB\r")
|
|
|
|
if "del" == action :
|
|
f = open("/home/mark/gemini-msg", "w")
|
|
f.write("")
|
|
|
|
print("# Messages Deleted")
|
|
|
|
else :
|
|
f = open("/home/mark/gemini-msg", "r")
|
|
|
|
print("# Recieved Messages\n")
|
|
|
|
print( f.read() )
|
|
f.close()
|
|
|
|
print("=>.. Back")
|
|
print("=>read.cgi?del Delete")
|