Skip to content

Commit

Permalink
Pipe timeout deadline is now 60 seconds (#26)
Browse files Browse the repository at this point in the history
Allows for user interaction such as inputting a Windows Hello PIN
  • Loading branch information
ndbeals authored Dec 24, 2022
1 parent ab05c58 commit 6188012
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion internal/sshagent/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package sshagent

import (
"encoding/binary"
"errors"
"fmt"
"time"

Expand Down Expand Up @@ -38,12 +39,18 @@ func QueryAgent(pipeName string, buf []byte) (result []byte, err error) {
return genericFail, nil
}

conn.SetDeadline(time.Now().Add(time.Second * 60)) // Update deadline
// <https://github.com/openssh/openssh-portable/blob/4e636cf/PROTOCOL.agent>
// first 4 bytes are messageSizeBuf uint32
messageSizeBuf := make([]byte, 4)
_, err = conn.Read(messageSizeBuf)
if err != nil {
fmt.Printf("Cannot read message size from pipe %s: %s\n", pipeName, err.Error())
switch {
case errors.Is(err, winio.ErrTimeout):
fmt.Printf("Timeout waiting for user input %s: %s\n", pipeName, err.Error())
default:
fmt.Printf("Cannot read message size from pipe %s: %s\n", pipeName, err.Error())
}
return genericFail, nil
}
messageSize := binary.BigEndian.Uint32(messageSizeBuf)
Expand Down

0 comments on commit 6188012

Please sign in to comment.