sesman: move auth/pam calls to main process

master
Jay Sorg 8 years ago committed by jsorg71
parent 43899b7e0c
commit 4b8a33e087

@ -40,6 +40,7 @@ scp_v0_process(struct SCP_CONNECTION *c, struct SCP_SESSION *s)
tbus data; tbus data;
struct session_item *s_item; struct session_item *s_item;
int errorcode = 0; int errorcode = 0;
bool_t do_auth_end = 1;
data = auth_userpass(s->username, s->password, &errorcode); data = auth_userpass(s->username, s->password, &errorcode);
@ -135,6 +136,9 @@ scp_v0_process(struct SCP_CONNECTION *c, struct SCP_SESSION *s)
log_message(LOG_LEVEL_INFO, "starting Xorg session..."); log_message(LOG_LEVEL_INFO, "starting Xorg session...");
display = session_start(data, SESMAN_SESSION_TYPE_XORG, c, s); display = session_start(data, SESMAN_SESSION_TYPE_XORG, c, s);
} }
/* if the session started up ok, auth_end will be called on
sig child */
do_auth_end = display == 0;
} }
else else
{ {
@ -155,5 +159,8 @@ scp_v0_process(struct SCP_CONNECTION *c, struct SCP_SESSION *s)
{ {
scp_v0s_deny_connection(c); scp_v0s_deny_connection(c);
} }
if (do_auth_end)
{
auth_end(data); auth_end(data);
} }
}

@ -42,7 +42,7 @@ void
scp_v1_process(struct SCP_CONNECTION *c, struct SCP_SESSION *s) scp_v1_process(struct SCP_CONNECTION *c, struct SCP_SESSION *s)
{ {
long data; long data;
int display; int display = 0;
int retries; int retries;
int current_try; int current_try;
enum SCP_SERVER_STATES_E e; enum SCP_SERVER_STATES_E e;
@ -50,6 +50,7 @@ scp_v1_process(struct SCP_CONNECTION *c, struct SCP_SESSION *s)
struct session_item *sitem; struct session_item *sitem;
int scount; int scount;
SCP_SID sid; SCP_SID sid;
bool_t do_auth_end = 1;
retries = g_cfg->sec.login_retry; retries = g_cfg->sec.login_retry;
current_try = retries; current_try = retries;
@ -128,14 +129,20 @@ scp_v1_process(struct SCP_CONNECTION *c, struct SCP_SESSION *s)
log_message(LOG_LEVEL_INFO, "starting Xvnc session..."); log_message(LOG_LEVEL_INFO, "starting Xvnc session...");
display = session_start(data, SESMAN_SESSION_TYPE_XVNC, c, s); display = session_start(data, SESMAN_SESSION_TYPE_XVNC, c, s);
} }
else else if (SCP_SESSION_TYPE_XRDP == s->type)
{ {
log_message(LOG_LEVEL_INFO, "starting X11rdp session..."); log_message(LOG_LEVEL_INFO, "starting X11rdp session...");
display = session_start(data, SESMAN_SESSION_TYPE_XRDP, c, s); display = session_start(data, SESMAN_SESSION_TYPE_XRDP, c, s);
} }
else if (SCP_SESSION_TYPE_XORG == s->type)
{
log_message(LOG_LEVEL_INFO, "starting Xorg session...");
display = session_start(data, SESMAN_SESSION_TYPE_XORG, c, s);
}
/* if the session started up ok, auth_end will be called on
sig child */
do_auth_end = display == 0;
e = scp_v1s_connect_new_session(c, display); e = scp_v1s_connect_new_session(c, display);
switch (e) switch (e)
{ {
case SCP_SERVER_STATE_OK: case SCP_SERVER_STATE_OK:
@ -201,7 +208,10 @@ scp_v1_process(struct SCP_CONNECTION *c, struct SCP_SESSION *s)
} }
/* cleanup */ /* cleanup */
if (do_auth_end)
{
auth_end(data); auth_end(data);
}
g_free(slist); g_free(slist);
} }

@ -456,6 +456,7 @@ session_start_fork(tbus data, tui8 type, struct SCP_CONNECTION *c,
return 0; return 0;
} }
auth_start_session(data, display);
pid = g_fork(); /* parent is fork from tcp accept, pid = g_fork(); /* parent is fork from tcp accept,
child forks X and wm, then becomes scp */ child forks X and wm, then becomes scp */
@ -498,7 +499,6 @@ session_start_fork(tbus data, tui8 type, struct SCP_CONNECTION *c,
g_getpid()); g_getpid());
} }
#endif #endif
auth_start_session(data, display);
window_manager_pid = g_fork(); /* parent becomes X, window_manager_pid = g_fork(); /* parent becomes X,
child forks wm, and waits, todo */ child forks wm, and waits, todo */
if (window_manager_pid == -1) if (window_manager_pid == -1)
@ -787,8 +787,6 @@ session_start_fork(tbus data, tui8 type, struct SCP_CONNECTION *c,
g_waitpid(window_manager_pid); g_waitpid(window_manager_pid);
log_message(LOG_LEVEL_ALWAYS, "window manager (pid %d) did " log_message(LOG_LEVEL_ALWAYS, "window manager (pid %d) did "
"exit, cleaning up session", window_manager_pid); "exit, cleaning up session", window_manager_pid);
auth_stop_session(data);
auth_end(data);
g_sigterm(display_pid); g_sigterm(display_pid);
g_sigterm(chansrv_pid); g_sigterm(chansrv_pid);
g_deinit(); g_deinit();
@ -918,6 +916,8 @@ session_kill(int pid)
if (tmp->item->pid == pid) if (tmp->item->pid == pid)
{ {
auth_stop_session(tmp->item->data);
auth_end(tmp->item->data);
/* deleting the session */ /* deleting the session */
log_message(LOG_LEVEL_INFO, "++ terminated session: username %s, display :%d.0, session_pid %d, ip %s", tmp->item->name, tmp->item->display, tmp->item->pid, tmp->item->client_ip); log_message(LOG_LEVEL_INFO, "++ terminated session: username %s, display :%d.0, session_pid %d, ip %s", tmp->item->name, tmp->item->display, tmp->item->pid, tmp->item->client_ip);
g_free(tmp->item); g_free(tmp->item);

Loading…
Cancel
Save