Yubico / pam-u2f

Pluggable Authentication Module (PAM) for U2F and FIDO2
https://developers.yubico.com/pam-u2f/
BSD 2-Clause "Simplified" License
543 stars 78 forks source link

Timestamp debug logs #311

Closed Strykar closed 9 months ago

Strykar commented 9 months ago

Is your feature request related to a problem?

Sorta, see https://github.com/Yubico/pam-u2f/issues/310

I was trying to narrow down what was causing a 1-2 min delay in the U2F key cueing me for touch after entering a password via GDM. The lack of timestamps on the debug logs did not help as I could not discount pam-u2f as the cause until I setup some monitoring to confirm pam-u2f was not causing the delay.

Describe the solution that you'd like

Timestamp the debug logs set via PAM config.

Describe the alternatives that you've considered

$ cat ~/.bin/timestamp_logs.sh 
#!/bin/bash

LOGFILE="/var/log/pam_u2f_gdm.log"
TIMESTAMPED_LOGFILE="/var/log/timestamped_pam_u2f_gdm.log"

# Ensure the timestamped log file exists
touch "$TIMESTAMPED_LOGFILE"

# Function to append new lines with timestamps
append_with_timestamp() {
    while read -r line; do
        echo "$(date +"%Y-%m-%d %H:%M:%S") $line" >> "$TIMESTAMPED_LOGFILE"
    done
}

# Monitor the log file for new lines
tail -n0 -F "$LOGFILE" | append_with_timestamp &
LDVG commented 9 months ago

Closing with rationale in https://github.com/Yubico/pam-u2f/pull/312#issuecomment-1891518143