diff --git a/ssh/serve.go b/ssh/serve.go index 750dc64..4ecc5db 100644 --- a/ssh/serve.go +++ b/ssh/serve.go @@ -187,8 +187,6 @@ func handleExec(d *db.DB, channel ssh.Channel, req *ssh.Request, extensions map[ repoMetadata, err = d.GetRepo(repoMetadata) - repoPath := git.GetRepoPath(&repoUser.ID, &repoMetadata.ID) - if err != nil { req.Reply(false, nil) fmt.Fprintf(channel.Stderr(), "repo not found: %v\n", err) @@ -197,6 +195,8 @@ func handleExec(d *db.DB, channel ssh.Channel, req *ssh.Request, extensions map[ return } + repoPath := git.GetRepoPath(&repoUser.ID, &repoMetadata.ID) + // Authorization: does sshUser have access to repoPath? if (repoMetadata.IsPrivate || strings.Contains(command.Command, "upload")) && *repoMetadata.UserID != userID { fmt.Println("unauthorized")