taylorthurlow/panda-motd

Not handling all possible output in last login component

Closed this issue · 0 comments

I just installed a Ubuntu 18.04 LTS and tried setting up panda-motd - but it crashed complaining about the last_login component not being able to parse a date. Upon inspection, the results of the command:

last --time-format=iso taylor

are

taylor   pts/2        tmux(14328).%2   2018-11-05T16:04:53-0800   gone - no logout
taylor   pts/2        tmux(14328).%1   2018-11-05T16:02:57-0800 - 2018-11-05T16:03:24-0800  (00:00)
taylor   pts/1        tmux(14328).%0   2018-11-05T16:00:25-0800   gone - no logout
taylor   pts/3        tmux(13667).%1   2018-11-05T16:00:09-0800 - 2018-11-05T16:00:22-0800  (00:00)
taylor   pts/1        tmux(13667).%0   2018-11-05T15:59:09-0800 - 2018-11-05T16:00:19-0800  (00:01)
taylor   pts/1        tmux(13582).%0   2018-11-05T15:59:01-0800 - 2018-11-05T15:59:08-0800  (00:00

The - in the gone - no logout section is what breaks the regex search. On top of that, we were basically assuming that that section of the log would only be "still logged in" or a valid date. I'm going to play with the regex a bit to get it to match the entire section, and handle whatever messages show up in that column.