]> git.sesse.net Git - linux-dallas-multipass/commitdiff
When a smartcard error occurs, disconnect to avoid sticky errors.
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Mon, 16 Nov 2020 20:04:56 +0000 (21:04 +0100)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Mon, 16 Nov 2020 20:04:56 +0000 (21:04 +0100)
multipass.rs

index 073e929216c9265a56952b3ecaaac19ec0d26e9e..8423cd9646939e39beadb590e227889380a37e9a 100644 (file)
@@ -354,7 +354,13 @@ fn run_apdu(reader_name: &str, apdus: Vec<Vec<u8>>) -> Result<hyper::Body, Box<d
 
        let mut response_json : Vec<serde_json::Value> = Vec::new();
         for apdu in apdus {
 
        let mut response_json : Vec<serde_json::Value> = Vec::new();
         for apdu in apdus {
-               let reply = &transmit_apdu(card.as_mut().unwrap(), &apdu)?;
+               let reply = match transmit_apdu(card.as_mut().unwrap(), &apdu) {
+                       Ok(r) => r,
+                       Err(err) => {
+                               *card = None;  // Clean up.
+                               return Err(err);
+                       }
+               };
                response_json.push(json!({
                        "apdu": reply
                }));
                response_json.push(json!({
                        "apdu": reply
                }));