@@ -157,8 +157,8 @@ authenticate_and_authorize_connection(struct sesman_con *sc,
157
157
}
158
158
else
159
159
{
160
- LOG (LOG_LEVEL_INFO , "Access permitted for user: %s " ,
161
- username );
160
+ LOG (LOG_LEVEL_INFO , "Access permitted for user=%s uid=%d " ,
161
+ username , uid );
162
162
sc -> auth_info = auth_info ;
163
163
sc -> uid = uid ;
164
164
sc -> username = dup_username ;
@@ -210,6 +210,7 @@ allocate_and_start_session(struct auth_info *auth_info,
210
210
{
211
211
int pid = 0 ;
212
212
struct session_chain * temp = (struct session_chain * )NULL ;
213
+ enum scp_screate_status status ;
213
214
214
215
/* check to limit concurrent sessions */
215
216
if (session_get_count () >= (unsigned int )g_cfg -> sess .max_sessions )
@@ -238,70 +239,39 @@ allocate_and_start_session(struct auth_info *auth_info,
238
239
return E_SCP_SCREATE_NO_MEMORY ;
239
240
}
240
241
241
- pid = g_fork ( );
242
- if (pid == -1 )
242
+ status = session_start ( auth_info , params , & pid );
243
+ if (status == E_SCP_SCREATE_OK )
243
244
{
244
- LOG (LOG_LEVEL_ERROR ,
245
- "[session start] (display %d): Failed to fork for scp with "
246
- "errno: %d, description: %s" ,
247
- params -> display , g_get_errno (), g_get_strerror ());
248
- g_free (temp -> item );
249
- g_free (temp );
250
- return E_SCP_SCREATE_GENERAL_ERROR ;
251
- }
252
-
253
- if (pid == 0 )
254
- {
255
- /**
256
- * We're now forked from the main sesman process, so we
257
- * can close file descriptors that we no longer need */
245
+ if (ip_addr [0 ] != '\0' )
246
+ {
247
+ LOG (LOG_LEVEL_INFO , "++ created session: username %s, ip %s" ,
248
+ username , ip_addr );
249
+ }
250
+ else
251
+ {
252
+ LOG (LOG_LEVEL_INFO , "++ created session: username %s" , username );
253
+ }
258
254
259
- sesman_close_all (0 );
255
+ temp -> item -> pid = pid ;
256
+ temp -> item -> display = params -> display ;
257
+ temp -> item -> width = params -> width ;
258
+ temp -> item -> height = params -> height ;
259
+ temp -> item -> bpp = params -> bpp ;
260
+ temp -> item -> auth_info = auth_info ;
261
+ g_strncpy (temp -> item -> start_ip_addr , ip_addr ,
262
+ sizeof (temp -> item -> start_ip_addr ) - 1 );
263
+ temp -> item -> uid = params -> uid ;
264
+ temp -> item -> guid = params -> guid ;
260
265
261
- /* Wait objects created in a parent are not valid in a child */
262
- g_delete_wait_obj (g_reload_event );
263
- g_delete_wait_obj (g_sigchld_event );
264
- g_delete_wait_obj (g_term_event );
266
+ temp -> item -> start_time = g_time1 ();
265
267
266
- session_start (auth_info , params );
267
- g_exit (1 ); /* Should not get here */
268
- }
268
+ temp -> item -> type = params -> type ;
269
+ temp -> item -> status = SESMAN_SESSION_STATUS_ACTIVE ;
269
270
270
- if (ip_addr [0 ] != '\0' )
271
- {
272
- LOG (LOG_LEVEL_INFO , "++ created session: username %s, ip %s" ,
273
- username , ip_addr );
271
+ session_chain_add (temp );
274
272
}
275
- else
276
- {
277
- LOG (LOG_LEVEL_INFO , "++ created session: username %s" , username );
278
- }
279
-
280
- LOG (LOG_LEVEL_INFO , "Starting session: session_pid %d, "
281
- "display :%d.0, width %d, height %d, bpp %d, client ip %s, "
282
- "UID %d" ,
283
- pid , params -> display , params -> width , params -> height , params -> bpp ,
284
- ip_addr , params -> uid );
285
-
286
- temp -> item -> pid = pid ;
287
- temp -> item -> display = params -> display ;
288
- temp -> item -> width = params -> width ;
289
- temp -> item -> height = params -> height ;
290
- temp -> item -> bpp = params -> bpp ;
291
- temp -> item -> auth_info = auth_info ;
292
- g_strncpy (temp -> item -> start_ip_addr , ip_addr ,
293
- sizeof (temp -> item -> start_ip_addr ) - 1 );
294
- temp -> item -> uid = params -> uid ;
295
- temp -> item -> guid = params -> guid ;
296
-
297
- temp -> item -> start_time = g_time1 ();
298
273
299
- temp -> item -> type = params -> type ;
300
- temp -> item -> status = SESMAN_SESSION_STATUS_ACTIVE ;
301
-
302
- session_chain_add (temp );
303
-
304
- return E_SCP_SCREATE_OK ;
274
+ return status ;
305
275
}
306
276
307
277
/******************************************************************************/
@@ -489,6 +459,8 @@ process_create_session_request(struct sesman_con *sc)
489
459
// Parameters for a new session (if required). Filled in as
490
460
// we go along.
491
461
struct session_parameters sp = {0 };
462
+ const char * shellptr ;
463
+ const char * dirptr ;
492
464
enum scp_screate_status status = E_SCP_SCREATE_OK ;
493
465
494
466
int display = 0 ;
@@ -498,7 +470,7 @@ process_create_session_request(struct sesman_con *sc)
498
470
499
471
rv = scp_get_create_session_request (sc -> t ,
500
472
& sp .type , & sp .width , & sp .height ,
501
- & sp .bpp , & sp . shell , & sp . directory );
473
+ & sp .bpp , & shellptr , & dirptr );
502
474
503
475
if (rv == 0 )
504
476
{
@@ -509,8 +481,12 @@ process_create_session_request(struct sesman_con *sc)
509
481
else
510
482
{
511
483
LOG (LOG_LEVEL_INFO ,
512
- "Received request from %s to create a session for user %s" ,
513
- sc -> peername , sc -> username );
484
+ "Received request from %s to create a session for user %s"
485
+ " type=%s"
486
+ " geometry=%dx%d, bpp=%d, shell=\"%s\", dir=\"%s\"" ,
487
+ sc -> peername , sc -> username ,
488
+ SCP_SESSION_TYPE_TO_STR (sp .type ),
489
+ sp .width , sp .height , sp .bpp , shellptr , dirptr );
514
490
515
491
struct session_item * s_item =
516
492
session_get_bydata (sc -> uid , sp .type , sp .width , sp .height ,
@@ -546,9 +522,13 @@ process_create_session_request(struct sesman_con *sc)
546
522
guid = guid_new ();
547
523
display = session_get_available_display ();
548
524
549
- sp .guid = guid ;
550
525
sp .display = display ;
551
526
sp .uid = sc -> uid ;
527
+ sp .guid = guid ;
528
+ // These need to be copied so they are available
529
+ // when the sub-process closes all the connections
530
+ g_snprintf (sp .shell , sizeof (sp .shell ), "%s" , shellptr );
531
+ g_snprintf (sp .directory , sizeof (sp .directory ), "%s" , dirptr );
552
532
553
533
if (display == 0 )
554
534
{
@@ -696,4 +676,3 @@ scp_process(struct sesman_con *sc)
696
676
}
697
677
return rv ;
698
678
}
699
-
0 commit comments