diff options
Diffstat (limited to 'whosocket.hs')
-rw-r--r-- | whosocket.hs | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/whosocket.hs b/whosocket.hs index 420b707a..97912eff 100644 --- a/whosocket.hs +++ b/whosocket.hs | |||
@@ -41,8 +41,15 @@ whosocket addr_str port_str = do | |||
41 | r <- getLocalPeerCred' addr | 41 | r <- getLocalPeerCred' addr |
42 | -- putStrLn $ "r{"++show addr++"} = " ++ show r | 42 | -- putStrLn $ "r{"++show addr++"} = " ++ show r |
43 | 43 | ||
44 | us <- UTmp.users | ||
45 | let filterTTYs (_,tty,pid) = | ||
46 | if L.take 3 tty == "tty" | ||
47 | then Just (tty,pid) | ||
48 | else Nothing | ||
49 | tty_pids = mapMaybe filterTTYs us | ||
50 | |||
44 | tty <- maybe (return Nothing) | 51 | tty <- maybe (return Nothing) |
45 | (uncurry identifyTTY) | 52 | (uncurry $ identifyTTY tty_pids) |
46 | r | 53 | r |
47 | putStrLn $ "uid = " ++ show (fmap fst r) | 54 | putStrLn $ "uid = " ++ show (fmap fst r) |
48 | L.putStrLn $ "tty = " <++?> tty | 55 | L.putStrLn $ "tty = " <++?> tty |
@@ -132,18 +139,11 @@ ttyToXorgs tty_pids = do | |||
132 | let dts = catMaybes dts' | 139 | let dts = catMaybes dts' |
133 | return dts | 140 | return dts |
134 | 141 | ||
135 | identifyTTY uid inode = do | 142 | identifyTTY tty_pids uid inode = do |
136 | pid <- scanProc (show uid) (L.unpack inode) | 143 | pid <- scanProc (show uid) (L.unpack inode) |
137 | -- putStrLn $ "scanProc --> "++show pid | 144 | -- putStrLn $ "scanProc --> "++show pid |
138 | flip (maybe (return Nothing)) pid $ \(pid,ttydev) -> do | 145 | flip (maybe (return Nothing)) pid $ \(pid,ttydev) -> do |
139 | tty <- ttyOrDisplay pid ttydev | 146 | tty <- ttyOrDisplay pid ttydev |
140 | |||
141 | us <- users | ||
142 | let filterTTYs (_,tty,pid) = | ||
143 | if L.take 3 tty == "tty" | ||
144 | then Just (tty,pid) | ||
145 | else Nothing | ||
146 | tty_pids = mapMaybe filterTTYs us | ||
147 | -- putStrLn $ "users = " ++ show tty_pids | 147 | -- putStrLn $ "users = " ++ show tty_pids |
148 | dts <- ttyToXorgs tty_pids | 148 | dts <- ttyToXorgs tty_pids |
149 | 149 | ||