summaryrefslogtreecommitdiffhomepage
path: root/Role
diff options
context:
space:
mode:
authorJoey Hess <joeyh@joeyh.name>2017-04-30 12:23:33 -0400
committerJoey Hess <joeyh@joeyh.name>2017-04-30 12:25:31 -0400
commitd327ced452ecbefd819691e4b4caada41029fb87 (patch)
treea41db887b129c2bf94f1a613147489bb4173b2d9 /Role
parent9331a37b178c9142f5e864bbdc5434ea208946cc (diff)
downloaddebug-me-d327ced452ecbefd819691e4b4caada41029fb87.tar.gz
prevent terminal echo before user grants write access
And improve some messages.
Diffstat (limited to 'Role')
-rw-r--r--Role/Developer.hs43
1 files changed, 23 insertions, 20 deletions
diff --git a/Role/Developer.hs b/Role/Developer.hs
index fc54c9f..0277bed 100644
--- a/Role/Developer.hs
+++ b/Role/Developer.hs
@@ -58,26 +58,29 @@ developer dsv ichan ochan sid = withSessionLogger sid $ \logger -> do
"Using gpg to sign the debug-me session key."
spk <- myPublicKey sk (GpgSign True)
displayInControlWindow controlinput
- "Connecting to user ..."
- (devstate, startoutput) <- processSessionStart sk ochan logger dsv
- emitOutput startoutput
- displayInControlWindow controlinput
- "Waiting for the user to grant write access ..."
- res <- authUser spk ichan ochan devstate logger
- case res of
- Authed -> inRawMode $ void $ do
- displayInControlWindow controlinput
- "Write access granted. You can now type into the user's shell."
- displayInControlWindow controlinput
- "(And, you can type in this window to chat with the user.)"
- sendTtyInput ichan devstate logger
- `race` sendTtyOutput ochan devstate controlinput logger
- `race` sendControlOutput controloutput ichan devstate logger
- AuthFailed -> do
- displayInControlWindow controlinput
- "User did not grant access to their terminal. Watching session in read-only mode."
- watchSessionReadOnly ochan logger devstate
- SessionEnded -> hPutStrLn stderr "\n** This debug-me session has already ended."
+ "Connecting to the user's session ..."
+ inRawMode $ do
+ (devstate, startoutput) <- processSessionStart sk ochan logger dsv
+ emitOutput startoutput
+ displayInControlWindow controlinput
+ "Waiting for the user to check your Gnupg key and grant access ..."
+ authUser spk ichan ochan devstate logger
+ >>= go controlinput controloutput logger devstate
+ where
+ go controlinput controloutput logger devstate Authed = void $ do
+ displayInControlWindow controlinput
+ "Write access granted. You can now type into the user's shell."
+ displayInControlWindow controlinput
+ "(And, you can type in this window to chat with the user.)"
+ sendTtyInput ichan devstate logger
+ `race` sendTtyOutput ochan devstate controlinput logger
+ `race` sendControlOutput controloutput ichan devstate logger
+ go controlinput _controloutput logger devstate AuthFailed = do
+ displayInControlWindow controlinput
+ "User did not grant write access to their terminal. Watching session in read-only mode."
+ watchSessionReadOnly ochan logger devstate
+ go _ _ _ _ SessionEnded =
+ hPutStrLn stderr "\n** This debug-me session has already ended."
watchSessionReadOnly :: TMChan AnyMessage -> Logger -> TVar DeveloperState -> IO ()
watchSessionReadOnly ochan logger st = loop