@@ -98,7 +98,7 @@ func newSessionRPCServer(cfg *sessionRpcServerConfig) (*sessionRpcServer,
98
98
99
99
// start all the components necessary for the sessionRpcServer to start serving
100
100
// requests. This includes resuming all non-revoked sessions.
101
- func (s * sessionRpcServer ) start () error {
101
+ func (s * sessionRpcServer ) start (ctx context. Context ) error {
102
102
// Start up all previously created sessions.
103
103
sessions , err := s .cfg .db .ListSessions (nil )
104
104
if err != nil {
@@ -135,7 +135,6 @@ func (s *sessionRpcServer) start() error {
135
135
continue
136
136
}
137
137
138
- ctx := context .Background ()
139
138
ctxc , cancel := context .WithTimeout (
140
139
ctx , defaultConnectTimeout ,
141
140
)
@@ -147,7 +146,7 @@ func (s *sessionRpcServer) start() error {
147
146
cancel ()
148
147
if err != nil {
149
148
log .Errorf ("error activating autopilot " +
150
- "session (%x) with the client" , key ,
149
+ "session (%x) with the client: %v " , key ,
151
150
err )
152
151
153
152
if perm {
@@ -164,7 +163,7 @@ func (s *sessionRpcServer) start() error {
164
163
}
165
164
}
166
165
167
- if err := s .resumeSession (sess ); err != nil {
166
+ if err := s .resumeSession (ctx , sess ); err != nil {
168
167
log .Errorf ("error resuming session (%x): %v" , key , err )
169
168
}
170
169
}
@@ -190,7 +189,7 @@ func (s *sessionRpcServer) stop() error {
190
189
}
191
190
192
191
// AddSession adds and starts a new Terminal Connect session.
193
- func (s * sessionRpcServer ) AddSession (_ context.Context ,
192
+ func (s * sessionRpcServer ) AddSession (ctx context.Context ,
194
193
req * litrpc.AddSessionRequest ) (* litrpc.AddSessionResponse , error ) {
195
194
196
195
expiry := time .Unix (int64 (req .ExpiryTimestampSeconds ), 0 )
@@ -335,7 +334,7 @@ func (s *sessionRpcServer) AddSession(_ context.Context,
335
334
return nil , fmt .Errorf ("error storing session: %v" , err )
336
335
}
337
336
338
- if err := s .resumeSession (sess ); err != nil {
337
+ if err := s .resumeSession (ctx , sess ); err != nil {
339
338
return nil , fmt .Errorf ("error starting session: %v" , err )
340
339
}
341
340
@@ -351,7 +350,9 @@ func (s *sessionRpcServer) AddSession(_ context.Context,
351
350
352
351
// resumeSession tries to start an existing session if it is not expired, not
353
352
// 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
+
355
356
pubKey := sess .LocalPublicKey
356
357
pubKeyBytes := pubKey .SerializeCompressed ()
357
358
@@ -423,15 +424,15 @@ func (s *sessionRpcServer) resumeSession(sess *session.Session) error {
423
424
})
424
425
425
426
mac , err := s .cfg .superMacBaker (
426
- context . Background () , sess .MacaroonRootKey ,
427
+ ctx , sess .MacaroonRootKey ,
427
428
& session.MacaroonRecipe {
428
429
Permissions : permissions ,
429
430
Caveats : caveats ,
430
431
},
431
432
)
432
433
if err != nil {
433
434
log .Debugf ("Not resuming session %x. Could not bake " +
434
- "the necessary macaroon: %w " , pubKeyBytes , err )
435
+ "the necessary macaroon: %v " , pubKeyBytes , err )
435
436
return nil
436
437
}
437
438
@@ -516,7 +517,6 @@ func (s *sessionRpcServer) resumeSession(sess *session.Session) error {
516
517
}
517
518
518
519
if s .cfg .autopilot != nil {
519
- ctx := context .Background ()
520
520
ctxc , cancel := context .WithTimeout (
521
521
ctx , defaultConnectTimeout ,
522
522
)
@@ -1246,7 +1246,7 @@ func (s *sessionRpcServer) AddAutopilotSession(ctx context.Context,
1246
1246
return nil , fmt .Errorf ("error storing session: %v" , err )
1247
1247
}
1248
1248
1249
- if err := s .resumeSession (sess ); err != nil {
1249
+ if err := s .resumeSession (ctx , sess ); err != nil {
1250
1250
return nil , fmt .Errorf ("error starting session: %v" , err )
1251
1251
}
1252
1252
0 commit comments