Skip to content

Commit

Permalink
No fallback magic if we cannot find home directory
Browse files Browse the repository at this point in the history
System temp would probably be fine, but let's be explicit about this.
  • Loading branch information
susji committed Sep 9, 2023
1 parent 27af9a9 commit 3d994cb
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions agentyesno.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func main() {
var timeout time.Duration
var fullkeys, easyyes bool

flag.StringVar(&listen, "listen", getsockpath(), "Path to `agentyesno` domain socket")
flag.StringVar(&listen, "listen", getsocketdefault(), "Path for our listening agent socket")
flag.StringVar(&agent, "agent", getagentdefault(), "Path to real SSH agent's domain socket")
flag.BoolVar(&fullkeys, "fullkeys", false, "Dump public keys on sign requests instead of digests")
flag.BoolVar(&easyyes, "easyyes", false, "Use `yes` instead of counter for permitting Sign requests")
Expand Down Expand Up @@ -203,11 +203,12 @@ func (a *AgentYesNo) Signers() ([]ssh.Signer, error) {
return a.agent.Signers()
}

func getsockpath() string {
func getsocketdefault() string {
sockdir, err := os.UserHomeDir()
if err != nil {
sockdir = os.TempDir()
log.Print("warning: unable to get home directory, using temp directory:", sockdir)
log.Print("warning: unable to get home directory: ", err)
log.Fatal("set the listening path manually to some safe location with `-listen`")
}
return path.Join(sockdir, ".agentyesno.socket")
}
Expand Down

0 comments on commit 3d994cb

Please sign in to comment.