In the timestamp record, include the start time of the terminal

session leader for tty-based timestamps or the start time of the
parent process for ppid-based timestamps.  Idea from Duncan Overbruck.
This commit is contained in:
Todd C. Miller
2017-12-16 05:53:05 -07:00
parent 5cec5734cc
commit 1709dc7f77
8 changed files with 379 additions and 68 deletions

View File

@@ -90,10 +90,15 @@ ts_match_record(struct timestamp_entry *key, struct timestamp_entry *entry)
/* verify parent pid */
if (entry->u.ppid != key->u.ppid)
debug_return_bool(false);
if (sudo_timespeccmp(&entry->start_time, &key->start_time, !=))
debug_return_bool(false);
break;
break;
case TS_TTY:
if (entry->u.ttydev != key->u.ttydev)
debug_return_bool(false);
if (sudo_timespeccmp(&entry->start_time, &key->start_time, !=))
debug_return_bool(false);
break;
default:
/* unknown record type, ignore it */
@@ -334,6 +339,8 @@ ts_init_key(struct timestamp_entry *entry, struct passwd *pw, int flags,
/* tty-based time stamp */
entry->type = TS_TTY;
entry->u.ttydev = sb.st_rdev;
if (entry->sid != -1)
get_starttime(entry->sid, &entry->start_time);
break;
}
/* FALLTHROUGH */
@@ -341,6 +348,7 @@ ts_init_key(struct timestamp_entry *entry, struct passwd *pw, int flags,
/* ppid-based time stamp */
entry->type = TS_PPID;
entry->u.ppid = getppid();
get_starttime(entry->u.ppid, &entry->start_time);
break;
default:
/* global time stamp */