#!/usr/bin/python3
# Interactive log file viewer
# Can exec to tail as a one-off, but there's no returning to the menu after
import subprocess
import os

while True:
	print("1. View DHCP logs")
	print("2. Tail DHCP logs")
	print("3. Root shell (requires authentication)")
	print("0. Exit")
	cmd = input("Pick an action: ")
	if cmd == "1":
		subprocess.run(["journalctl", "-uisc-dhcp-server", "-n25", "--no-pager"])
	elif cmd == "2":
		os.execlp("journalctl", "journalctl", "-fuisc-dhcp-server")
		print("** Unable to exec to journalctl **")
	elif cmd == "3":
		os.execlp("sudo", "sudo", "-i")
		print("** Unable to exec to sudo **")
	elif cmd == "0":
		break
	else:
		print("Unrecognized option.")

@@ -227,17 +227,14 @@
 nt(%22
-3. Root s
+149. S
 hell
@@ -555,37 +555,360 @@
 :%0A%09%09
-os.execlp(%22sudo%22, %22sudo%22, %22-i
+print(%22Provide credentials to get shell access:%22)%0A%09%09r = subprocess.run(%5B%22sudo%22, %22-v%22%5D)%0A%09%09if r.returncode: continue # Assume sudo already printed an error%0A%09%09# Note that this will cause sudo to cache the credentials,%0A%09%09# granting passwordless sudo for the next fifteen minutes (or%0A%09%09# whatever the sysadmin has configured).%0A%09%09os.execlp(%22/bin/bash%22, %22bash
 %22)%0A%09
@@ -936,20 +936,20 @@
 exec to 
-sudo
+bash
  **%22)%0A%09e

Allow (non-root) shell access if permissions granted