Sign in

Search issue titles and bodies, change requests and comments. Private repositories you cannot read are not included.

vole
Site
Clone

Read only, no credentials:

https://rodent.software/vole.git

Write over SSH with a registered key:

git clone ssh://git@rodent.software/vole.git

Self-hosted forge that lives in your Git repo.

Run the exec verbs on a session, not an SSH channel

5ff8dfc964d8e05c5f5b7a8ec5e5f229178e5e4c · Keenan Nemetz · 16d ago · parent 22e290b0

Run the exec verbs on a session, not an SSH channel

Every handler behind the exec verb took an *xssh.Channel, and the two that
answer the exec request took the request too. That tied twenty functions to the
SSH transport, but the front door needs the same verbs, with the same access
rules, from a forced command that reaches the service over a local socket.

A Session is now what a verb runs on: stdin, stdout, a separate error stream,
Accept, CloseWrite, Exit, and Close. sshSession is the only implementation that
knows what an SSH channel is, so the handlers no longer name a transport and a
second one cannot become a second copy of the access rules.

No behaviour change. The handlers keep their names and bodies; the refusal and
exit-status paths move behind the interface, which is also what removes the
standalone exit helper. A new test drives vole-whoami and git-upload-pack over
SSH and over a session with no channel behind it, comparing stdout, stderr, and
the exit status of both.

server/ssh/run.go +6−8

@@ -27,8 +27,6 @@ import (
27 27 "strings"
28 28 "time"
29 29
30 xssh "golang.org/x/crypto/ssh"
31
32 30 "rodent.software/vole/ci/runs"
33 31 "rodent.software/vole/core/id"
34 32 "rodent.software/vole/forge/access"
@@ -100,7 +98,7 @@ func (s *Server) runIn(out io.Writer, name, runID string) (*runs.Run, bool) {
100 98 // questions in the same order, so a name that is refused for one is refused for the
101 99 // other with the same words: the account, the repository, the maintainer capability,
102 100 // and then the run.
103 func (s *Server) openRunFor(ch xssh.Channel, argv []string, user, usage string) (*runs.Run, string, bool) {
101 func (s *Server) openRunFor(ch Session, argv []string, user, usage string) (*runs.Run, string, bool) {
104 102 name, a, ok := s.openRunScope(ch, argv, user, usage)
105 103 if !ok {
106 104 return nil, "", false
@@ -134,7 +132,7 @@ func (s *Server) openRunForRead(out io.Writer, argv []string, user, usage string
134 132
135 133 // serveRunList answers the runs page as lines. The fields are tab-separated and fixed
136 134 // in order because the client formats them; they are the run page's own columns.
137 func (s *Server) serveRunList(ch xssh.Channel, argv []string, user string) int {
135 func (s *Server) serveRunList(ch Session, argv []string, user string) int {
138 136 if len(argv) != 6 {
139 137 fmt.Fprint(ch, "vole: usage: vole-run-list <repository> <status|-> <branch|-> <sha|-> <limit>\n")
140 138 return 129
@@ -205,7 +203,7 @@ func (s *Server) serveRunList(ch xssh.Channel, argv []string, user string) int {
205 203 // serveRunShow answers one run the way the run page does: what it ran, how it ended,
206 204 // the steps that ran, the attempts that have a log, and whether the result counts as
207 205 // a check. It is the page a failure is diagnosed on, in text.
208 func (s *Server) serveRunShow(ch xssh.Channel, argv []string, user string) int {
206 func (s *Server) serveRunShow(ch Session, argv []string, user string) int {
209 207 run, name, acl, ok := s.openRunForRead(ch, argv, user, "vole-run-show <repository> <run-id>")
210 208 if !ok {
211 209 return 129
@@ -322,7 +320,7 @@ func (s *Server) serveRunShow(ch xssh.Channel, argv []string, user string) int {
322 320 // bytes the runner wrote. The output is the data, so every refusal goes to the
323 321 // session's stderr; a caller that redirects stdout gets a log or an empty file, never
324 322 // an error message at the top of it.
325 func (s *Server) serveRunLog(ch xssh.Channel, argv []string, user string) int {
323 func (s *Server) serveRunLog(ch Session, argv []string, user string) int {
326 324 out := ch.Stderr()
327 325 if len(argv) != 5 {
328 326 fmt.Fprint(out, "vole: usage: vole-run-log <repository> <run-id> <attempt|0> <step|0>\n")
@@ -433,7 +431,7 @@ func (s *Server) serveRunLog(ch xssh.Channel, argv []string, user string) int {
433 431 return 0
434 432 }
435 433
436 func (s *Server) serveRunCancel(ch xssh.Channel, argv []string, user string) int {
434 func (s *Server) serveRunCancel(ch Session, argv []string, user string) int {
437 435 run, name, ok := s.openRunFor(ch, argv, user, "vole-run-cancel <repository> <run-id>")
438 436 if !ok {
439 437 return 129
@@ -473,7 +471,7 @@ func (s *Server) serveRunCancel(ch xssh.Channel, argv []string, user string) int
473 471 }
474 472 }
475 473
476 func (s *Server) serveRunRerun(ch xssh.Channel, argv []string, user string) int {
474 func (s *Server) serveRunRerun(ch Session, argv []string, user string) int {
477 475 run, name, ok := s.openRunFor(ch, argv, user, "vole-run-rerun <repository> <run-id>")
478 476 if !ok {
479 477 return 129