fix: add fallback to lastlog2 for SSH login retrieval and remove unnecessary libptytty dependency
Some checks failed
Nix Format Check / check-format (push) Failing after 38s

This commit is contained in:
Menno van Leeuwen 2025-03-10 20:33:01 +01:00
parent 612a8bf7b1
commit 1cb4a9acc4
Signed by: vleeuwenmenno
SSH Key Fingerprint: SHA256:OJFmjANpakwD3F2Rsws4GLtbdz1TJ5tkQF0RZmF0TRE
2 changed files with 6 additions and 3 deletions

View File

@ -14,6 +14,12 @@ def get_last_ssh_login():
try: try:
result = subprocess.run(['lastlog', '-u', os.environ.get("USER", "")], result = subprocess.run(['lastlog', '-u', os.environ.get("USER", "")],
capture_output=True, text=True) capture_output=True, text=True)
# If lastlog didn't work try lastlog2
if result.returncode != 0:
result = subprocess.run(['lastlog2', os.environ.get("USER", "")],
capture_output=True, text=True)
if result.returncode == 0: if result.returncode == 0:
lines = result.stdout.strip().split('\n') lines = result.stdout.strip().split('\n')
if len(lines) >= 2: # Header line + data line if len(lines) >= 2: # Header line + data line

View File

@ -32,9 +32,6 @@
pipx pipx
devbox devbox
# OS independent and secure pty/tty and utmp/wtmp/lastlog
libptytty
# Development SDKs/Toolkits # Development SDKs/Toolkits
gcc gcc
pkg-config pkg-config