summaryrefslogtreecommitdiff
path: root/whosocket.hs
diff options
context:
space:
mode:
authorjoe <joe@jerkface.net>2013-07-05 02:10:44 -0400
committerjoe <joe@jerkface.net>2013-07-05 02:10:44 -0400
commitd11e3db1db427cf8a2987e4ec5bb97288b808e2a (patch)
treeb087e6a6a1847741bc51379aa27d7e86b063a4c6 /whosocket.hs
parentbd521f4c86f9da67b9bf43d50d8a3ff4b6c2104e (diff)
refactor identifyTTY to match better how it will be used when integrated
Diffstat (limited to 'whosocket.hs')
-rw-r--r--whosocket.hs18
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
135identifyTTY uid inode = do 142identifyTTY 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