From c2d6529b839ffb6e92e90f6f99425ee6107a0dba Mon Sep 17 00:00:00 2001 From: joe Date: Thu, 13 Mar 2014 17:14:25 -0400 Subject: Fixed exit off-by-4 error in utmp parsing. Stopped filtering DEAD_PROCESS in case we want to use the data for special handling of screen ttys. --- consolation.hs | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'consolation.hs') diff --git a/consolation.hs b/consolation.hs index 640b51c2..0c6e907a 100644 --- a/consolation.hs +++ b/consolation.hs @@ -19,7 +19,7 @@ import qualified Data.Text.IO as Text import qualified Network.BSD as BSD import WaitForSignal ( waitForTermSignal ) -import UTmp ( users2, utmp_file, UtmpRecord(..) ) +import UTmp ( users2, utmp_file, UtmpRecord(..), UT_Type(USER_PROCESS) ) import FGConsole ( monitorTTY ) data ConsoleState = ConsoleState @@ -33,7 +33,13 @@ newConsoleState = atomically $ onLogin cs start = \e -> do us <- UTmp.users2 - let m = foldl' (\m x -> Map.insert (utmpTty x) x m) Map.empty us + let (m,cruft) = + foldl' (\(m,cruft) x -> + if utmpType x==USER_PROCESS + then (Map.insert (utmpTty x) x m,cruft) + else (m,Map.insert (utmpTty x) x cruft)) + (Map.empty,Map.empty) + us newborn <- atomically $ do old <- readTVar (csUtmp cs) -- swapTVar (csUtmp cs) m newborn <- flip Traversable.mapM (m Map.\\ old) @@ -89,9 +95,11 @@ newCon log activeTTY utmp = do flip (maybe $ return ()) u $ \u -> do jid <- ujid u log $ status (resource u) tty tu <> " " <> jid <> " pid=" <> tshow (utmpPid u) - <> if istty (resource u) - then " host=" <> tshow (utmpHost u) - else "" + <> (if istty (resource u) + then " host=" <> tshow (utmpHost u) + else "") + <> " session=" <> tshow (utmpSession u) + <> " addr=" <> utmpRemoteAddr u loop tty tu (Just u) where bstatus r ttynum mtu -- cgit v1.2.3