if (!x_running)
{
LOG(LOG_LEVEL_DEBUG, "Did not find a running X server at %s", text);
g_sprintf(text, "/tmp/.X%d-lock", display);
x_running = g_file_exist(text);
}
if (!x_running) /* check 59xx */
{
LOG(LOG_LEVEL_DEBUG, "Did not find a running X server at %s", text); if ((sck = g_tcp_socket()) != -1)
{
g_sprintf(text, "59%2.2d", display);
x_running = g_tcp_bind(sck, text);
g_tcp_close(sck);
}
}
if (!x_running) /* check 60xx */
{
LOG(LOG_LEVEL_DEBUG, "Did not find a running X server at %s", text); if ((sck = g_tcp_socket()) != -1)
{
g_sprintf(text, "60%2.2d", display);
x_running = g_tcp_bind(sck, text);
g_tcp_close(sck);
}
}
if (!x_running) /* check 62xx */
{
LOG(LOG_LEVEL_DEBUG, "Did not find a running X server at %s", text); if ((sck = g_tcp_socket()) != -1)
{
g_sprintf(text, "62%2.2d", display);
x_running = g_tcp_bind(sck, text);
g_tcp_close(sck);
}
}
if (x_running)
{
LOG(LOG_LEVEL_INFO, "Found X server running at %s", text);
}
*cnt = 0;
displays = g_new(unsignedint, session_list_get_count() + 1); if (displays == NULL)
{
LOG(LOG_LEVEL_ERROR, "Can't allocate memory for display list");
} elseif (g_session_list != NULL)
{ int i;
for (i = 0 ; i < g_session_list->count ; ++i)
{ conststruct session_item *si;
si = (conststruct session_item *)list_get_item(g_session_list, i); if (SESSION_IN_USE(si) && si->display >= 0)
{
displays[(*cnt)++] = si->display;
}
}
qsort(displays, *cnt, sizeof(displays[0]), icmp);
}
return displays;
}
/******************************************************************************/ int
session_list_get_available_display(void)
{ int rv = -1; unsignedint max_alloc = 0;
// Find all displays already allocated. We do this to prevent // unnecessary file system accesses, and also to prevent us allocating // the same display number to two callers who call in quick // succession i.e. if the first caller has not created its X server // by the time we service the second request unsignedint *allocated_displays = get_sorted_session_displays(&max_alloc); if (allocated_displays != NULL)
{ unsignedint i = 0; unsignedint display;
for (display = g_cfg->sess.x11_display_offset;
display <= g_cfg->sess.max_display_number;
++display)
{ // Have we already allocated this one? while (i < max_alloc && display > allocated_displays[i])
{
++i;
} if (i < max_alloc && display == allocated_displays[i])
{ continue; // Already allocated
}
if (!x_server_running_check_ports(display))
{ break;
}
}
g_free(allocated_displays);
if (display > g_cfg->sess.max_display_number)
{
LOG(LOG_LEVEL_ERROR, "X server -- no display in range (%d to %d) is available",
g_cfg->sess.x11_display_offset,
g_cfg->sess.max_display_number);
} else
{
rv = display;
}
}
if ((policy & SESMAN_CFG_SESS_POLICY_DEFAULT) != 0)
{ /* Before xrdp v0.9.14, the default *sessionpolicyvariedbytype.Ifthisisneededagain
* in the future, here is the place to add it */
policy = SESMAN_CFG_SESS_POLICY_U | SESMAN_CFG_SESS_POLICY_B;
}
/* 'Separate' policy never matches */ if (policy & SESMAN_CFG_SESS_POLICY_SEPARATE)
{
LOG(LOG_LEVEL_DEBUG, "%s: No matches possible", __func__); return NULL;
}
for (i = 0 ; i < g_session_list->count ; ++i)
{ struct session_item *si;
si = (struct session_item *)list_get_item(g_session_list, i); if (!SESSION_IN_USE(si))
{ continue;
}
LOG(LOG_LEVEL_DEBUG, "%s: No matches found", __func__); return NULL;
}
/******************************************************************************/ struct scp_session_info *
session_list_get_byuid(uid_t uid, unsignedint *cnt, unsignedint flags)
{ int i; struct scp_session_info *sess; int count; int index;
count = 0;
LOG(LOG_LEVEL_DEBUG, "searching for session by UID: %d", uid);
for (i = 0 ; i < g_session_list->count ; ++i)
{ conststruct session_item *si;
si = (conststruct session_item *)list_get_item(g_session_list, i); if (SESSION_IN_USE(si) && uid == si->uid)
{
count++;
}
}
if (count == 0)
{
(*cnt) = 0; return0;
}
/* malloc() an array of disconnected sessions */
sess = g_new0(struct scp_session_info, count);
if (sess == 0)
{
(*cnt) = 0; return0;
}
index = 0; for (i = 0 ; i < g_session_list->count ; ++i)
{ conststruct session_item *si;
si = (conststruct session_item *)list_get_item(g_session_list, i);
/******************************************************************************/ void
free_session_info_list(struct scp_session_info *sesslist, unsignedint cnt)
{ if (sesslist != NULL && cnt > 0)
{ unsignedint i; for (i = 0 ; i < cnt ; ++i)
{
g_free(sesslist[i].start_ip_addr);
}
}
g_free(sesslist);
}
/******************************************************************************/ int
session_list_get_wait_objs(tbus robjs[], int *robjs_count)
{ int i;
for (i = 0 ; i < g_session_list->count; ++i)
{ conststruct session_item *si;
si = (conststruct session_item *)list_get_item(g_session_list, i); if (SESSION_IN_USE(si))
{
robjs[(*robjs_count)++] = si->sesexec_trans->sck;
}
}
return0;
}
/******************************************************************************/ int
session_list_check_wait_objs(void)
{ int i = 0;
while (i < g_session_list->count)
{ struct session_item *si;
si = (struct session_item *)list_get_item(g_session_list, i); if (SESSION_IN_USE(si))
{ if (trans_check_wait_objs(si->sesexec_trans) != 0)
{
LOG(LOG_LEVEL_ERROR, "sesman_check_wait_objs: " "trans_check_wait_objs failed, removing trans");
si->sesexec_trans->status = TRANS_STATUS_DOWN;
}
}
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.