@@ -98,7 +98,7 @@ func newSessionRPCServer(cfg *sessionRpcServerConfig) (*sessionRpcServer,
9898
9999// start all the components necessary for the sessionRpcServer to start serving
100100// requests. This includes resuming all non-revoked sessions.
101- func (s * sessionRpcServer ) start () error {
101+ func (s * sessionRpcServer ) start (ctx context. Context ) error {
102102 // Start up all previously created sessions.
103103 sessions , err := s .cfg .db .ListSessions (nil )
104104 if err != nil {
@@ -135,7 +135,6 @@ func (s *sessionRpcServer) start() error {
135135 continue
136136 }
137137
138- ctx := context .Background ()
139138 ctxc , cancel := context .WithTimeout (
140139 ctx , defaultConnectTimeout ,
141140 )
@@ -147,7 +146,7 @@ func (s *sessionRpcServer) start() error {
147146 cancel ()
148147 if err != nil {
149148 log .Errorf ("error activating autopilot " +
150- "session (%x) with the client" , key ,
149+ "session (%x) with the client: %v " , key ,
151150 err )
152151
153152 if perm {
@@ -164,7 +163,7 @@ func (s *sessionRpcServer) start() error {
164163 }
165164 }
166165
167- if err := s .resumeSession (sess ); err != nil {
166+ if err := s .resumeSession (ctx , sess ); err != nil {
168167 log .Errorf ("error resuming session (%x): %v" , key , err )
169168 }
170169 }
@@ -190,7 +189,7 @@ func (s *sessionRpcServer) stop() error {
190189}
191190
192191// AddSession adds and starts a new Terminal Connect session.
193- func (s * sessionRpcServer ) AddSession (_ context.Context ,
192+ func (s * sessionRpcServer ) AddSession (ctx context.Context ,
194193 req * litrpc.AddSessionRequest ) (* litrpc.AddSessionResponse , error ) {
195194
196195 expiry := time .Unix (int64 (req .ExpiryTimestampSeconds ), 0 )
@@ -335,7 +334,7 @@ func (s *sessionRpcServer) AddSession(_ context.Context,
335334 return nil , fmt .Errorf ("error storing session: %v" , err )
336335 }
337336
338- if err := s .resumeSession (sess ); err != nil {
337+ if err := s .resumeSession (ctx , sess ); err != nil {
339338 return nil , fmt .Errorf ("error starting session: %v" , err )
340339 }
341340
@@ -351,7 +350,9 @@ func (s *sessionRpcServer) AddSession(_ context.Context,
351350
352351// resumeSession tries to start an existing session if it is not expired, not
353352// revoked and a LiT session.
354- func (s * sessionRpcServer ) resumeSession (sess * session.Session ) error {
353+ func (s * sessionRpcServer ) resumeSession (ctx context.Context ,
354+ sess * session.Session ) error {
355+
355356 pubKey := sess .LocalPublicKey
356357 pubKeyBytes := pubKey .SerializeCompressed ()
357358
@@ -423,15 +424,15 @@ func (s *sessionRpcServer) resumeSession(sess *session.Session) error {
423424 })
424425
425426 mac , err := s .cfg .superMacBaker (
426- context . Background () , sess .MacaroonRootKey ,
427+ ctx , sess .MacaroonRootKey ,
427428 & session.MacaroonRecipe {
428429 Permissions : permissions ,
429430 Caveats : caveats ,
430431 },
431432 )
432433 if err != nil {
433434 log .Debugf ("Not resuming session %x. Could not bake " +
434- "the necessary macaroon: %w " , pubKeyBytes , err )
435+ "the necessary macaroon: %v " , pubKeyBytes , err )
435436 return nil
436437 }
437438
@@ -516,7 +517,6 @@ func (s *sessionRpcServer) resumeSession(sess *session.Session) error {
516517 }
517518
518519 if s .cfg .autopilot != nil {
519- ctx := context .Background ()
520520 ctxc , cancel := context .WithTimeout (
521521 ctx , defaultConnectTimeout ,
522522 )
@@ -1246,7 +1246,7 @@ func (s *sessionRpcServer) AddAutopilotSession(ctx context.Context,
12461246 return nil , fmt .Errorf ("error storing session: %v" , err )
12471247 }
12481248
1249- if err := s .resumeSession (sess ); err != nil {
1249+ if err := s .resumeSession (ctx , sess ); err != nil {
12501250 return nil , fmt .Errorf ("error starting session: %v" , err )
12511251 }
12521252
0 commit comments