/******************************************************************************/ #if0 staticint
sesexec_scp_data_in(struct trans *self)
{ int rv; int available;
/******************************************************************************/ staticint
sesexec_eicp_data_in(struct trans *self)
{ int rv; int available;
/******************************************************************************/ /** *Informsthemainloopaterminationsignalhasbeenreceived
*/ staticvoid
set_term_event(int sig)
{ /* Don't try to use a wait obj in a child process */ if (g_getpid() == g_pid)
{
g_set_wait_obj(g_term_event);
}
}
/******************************************************************************/ /** *Informsthemainloopachildexitingsignalhasbeenreceived
*/ staticvoid
set_sigchld_event(int sig)
{ /* Don't try to use a wait obj in a child process */ if (g_getpid() == g_pid)
{
g_set_wait_obj(g_sigchld_event);
}
}
/******************************************************************************/ int
sesexec_is_term(void)
{ return g_terminate_loop || g_is_wait_obj_set(g_term_event);
}
if (g_obj_wait(robjs, robjs_count, NULL, 0, -1) != 0)
{ /* should not get here */
LOG(LOG_LEVEL_WARNING, "sesexec_main_loop: " "Unexpected error from g_obj_wait()");
g_sleep(100); continue;
}
if (g_is_wait_obj_set(g_term_event)) /* term */
{
g_reset_wait_obj(g_term_event); if (session_active(g_session_data))
{ // Ask the active session to terminate
LOG(LOG_LEVEL_INFO, "sesexec_main_loop: " "sesexec asked to terminate. " "Terminating active session");
session_send_term(g_session_data);
} else
{ // Terminate immediately
LOG(LOG_LEVEL_INFO, "sesexec_main_loop: " "sesexec asked to terminate. " "No session is active");
sesexec_terminate_main_loop(0); continue;
}
}
if (g_is_wait_obj_set(g_sigchld_event)) /* SIGCHLD */
{
g_reset_wait_obj(g_sigchld_event);
// See whether the session goes from active to inactive // after processing SIGCHLD int session_was_active = session_active(g_session_data);
process_sigchld_event(); if (session_was_active && !session_active(g_session_data))
{ // We've finished the session. Tell sesman and // finish up.
(void)ercp_send_session_finished_event(g_ecp_trans);
if (s == NULL || s[0] == '\0')
{
g_snprintf(errstr, errstr_size, "Can't read EICP_FD environment variable"); return -1;
}
for (p = s ; isdigit(*p) ; ++p)
{
;
}
if (*p != '\0')
{
g_snprintf(errstr, errstr_size, "EICP_FD has non-digit char '%c'", *p); return -1;
}
if ((p - s) > 4)
{
g_snprintf(errstr, errstr_size, "EICP_FD has too many digits"); return -1;
}
fd = g_atoi(s); if (!g_file_is_open(fd))
{
g_snprintf(errstr, errstr_size, "EICP_FD %d is not open", fd); return -1;
}
return fd;
}
/******************************************************************************/ int
main(int argc, char **argv)
{ int error = 1; struct startup_params startup_params = {0}; int errored_argc; int eicp_fd; char eicp_errstr[128]; /* *ChecktheEICPtransportfiledescriptorisprovidedandopen *beforeopeninganylogfiles,configfiles,etc.Wethenopen
* log files, and log errors at that point */
eicp_fd = get_eicp_fd(eicp_errstr, sizeof(eicp_errstr));
g_init("xrdp-sesexec");
//g_sleep(15 * 1000);
errored_argc = process_params(argc, argv, &startup_params); if (errored_argc > 0)
{
g_writeln("Unknown option: %s", argv[errored_argc]);
} /* starting logging subsystem *
* For historic reasons, we share a log file with sesman */ elseif (start_logging(startup_params.sesman_ini) == 0)
{ /* reading config *
* For historic reasons, we share a config with sesman */ if ((g_cfg = config_read(startup_params.sesman_ini)) == NULL)
{
LOG(LOG_LEVEL_ALWAYS, "error reading config %s: %s",
startup_params.sesman_ini, g_get_strerror());
} elseif (eicp_fd < 0)
{
LOG(LOG_LEVEL_ERROR, "%s", eicp_errstr);
} else
{ char text[128];
// No need to terminate on SIGINT for sesexec. This can // also make it hard to debug sessions. //g_signal_user_interrupt(set_term_event);
g_signal_terminate(set_term_event); /* SIGTERM */
g_signal_pipe(sig_no_op); /* SIGPIPE */
g_signal_child_stop(set_sigchld_event);
/* Set up an EICP process handler
* Errors are logged by this call if necessary */
g_ecp_trans = eicp_init_trans_from_fd(eicp_fd,
TRANS_TYPE_SERVER,
sesexec_is_term); if (g_ecp_trans != NULL)
{
g_ecp_trans->trans_data_in = sesexec_eicp_data_in;
g_ecp_trans->callback_data = NULL;
/* start program main loop */
LOG(LOG_LEVEL_INFO, "starting xrdp-sesexec with pid %d", g_pid);
error = sesexec_main_loop();
trans_delete(g_ecp_trans);
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.