Commit d710fb15 authored by Per Cederqvist's avatar Per Cederqvist
Browse files

All users of the hostname updated to get it from the isc_scb.

(login_old): Set login_time, not connect_time.
(login): Ditto.
(logout): Use login_time, not connect_time.
(who_is_on): Removed dead code.
(who_is_on_ident): Ditto.
(who_is_on_dynamic): Removed dead code.  Don't include sessions
	until the handshake is completed.
(get_session_info): Don't include sessions until the handshake is
	completed.
(get_session_info): Use connect_time, not login_time, as the
	connection_time.
(get_static_session_info): Don't include sessions until the
	handshake is completed.  Use connect_time, not login_time, as
	the connection_time.
(get_session_info_ident): Ditto.
(disconnect): Don't include sessions until the handshake is
	completed.
(get_client_name): Ditto.
(get_client_version): Ditto.
parent 2b56a954
/*
* $Id: session.c,v 0.69 2003/08/02 20:44:09 ceder Exp $
* $Id: session.c,v 0.70 2003/08/05 09:50:43 ceder Exp $
* Copyright (C) 1991-1994, 1996-2002 Lysator Academic Computer Association.
*
* This file is part of the LysKOM server.
......@@ -73,13 +73,13 @@ create_oldstyle_username(String *result,
Connection *connection)
{
if ( s_strcpy(result, connection->username) != OK )
restart_kom("create_oldstyle_username(): strcpy\n");
restart_kom("create_oldstyle_username(): s_strcpy\n");
if ( s_strcat(result, s_fcrea_str("@")) != OK )
restart_kom("create_oldstyle_username: s_strcat\n");
if ( s_strcat(result, connection->hostname) != OK )
restart_kom("prot_a_parse_packet: s_strcat II\n");
if ( s_strcat(result, connection->isc_session->remote) != OK )
restart_kom("create_oldstyle_username: s_strcat II\n");
}
/*
......@@ -143,7 +143,7 @@ login_old (Pers_no pers_no,
cached_lock_person(pers_no);
pers_p->last_login = current_time.tv_sec;
active_connection->session_start = current_time;
active_connection->login_time = current_time;
++pers_p->sessions;
s_strcpy(&pers_p->username, active_connection->username);
......@@ -154,20 +154,21 @@ login_old (Pers_no pers_no,
if (!s_empty(active_connection->ident_user))
{
if ( s_strcat(&pers_p->username, s_fcrea_str("(")) != OK )
restart_kom("login: s_strcat (\n");
restart_kom("login_old: s_strcat (\n");
if ( s_strcat(&pers_p->username, active_connection->ident_user) != OK )
restart_kom("login: s_strcat ident_user\n");
restart_kom("login_old: s_strcat ident_user\n");
if ( s_strcat(&pers_p->username, s_fcrea_str(")")) != OK )
restart_kom("login: s_strcat )\n");
restart_kom("login_old: s_strcat )\n");
}
if ( s_strcat(&pers_p->username, s_fcrea_str("@")) != OK )
restart_kom("prot_a_parse_packet: s_strcat\n");
restart_kom("login_old: s_strcat\n");
if ( s_strcat(&pers_p->username, active_connection->hostname) != OK )
restart_kom("prot_a_parse_packet: s_strcat II\n");
if (s_strcat(&pers_p->username,
active_connection->isc_session->remote) != OK)
restart_kom("login_old: s_strcat II\n");
mark_person_as_changed( pers_no );
......@@ -231,7 +232,7 @@ login (Pers_no pers_no,
cached_lock_person(pers_no);
pers_p->last_login = current_time.tv_sec;
active_connection->session_start = current_time;
active_connection->login_time = current_time;
s_strcpy(&pers_p->username, active_connection->username);
......@@ -252,10 +253,11 @@ login (Pers_no pers_no,
}
if ( s_strcat(&pers_p->username, s_fcrea_str("@")) != OK )
restart_kom("prot_a_parse_packet: s_strcat\n");
restart_kom("login: s_strcat\n");
if ( s_strcat(&pers_p->username, active_connection->hostname) != OK )
restart_kom("prot_a_parse_packet: s_strcat II\n");
if (s_strcat(&pers_p->username,
active_connection->isc_session->remote) != OK)
restart_kom("login: s_strcat II\n");
mark_person_as_changed( pers_no );
......@@ -295,7 +297,8 @@ logout( void )
leave_conf(active_connection);
ACT_P->last_login = current_time.tv_sec;
ACT_P->total_time_present +=
timeval_diff_sec(current_time, active_connection->session_start);
timeval_diff_sec(current_time, active_connection->login_time);
active_connection->login_time = current_time;
cached_unlock_person( ACTPERS );
mark_person_as_changed( ACTPERS );
......@@ -436,7 +439,6 @@ who_is_on( Who_info_list *result )
CHK_CONNECTION(FAILURE);
cptr = active_connection;
session = traverse_connections(0);
while (session != 0)
{
......@@ -496,7 +498,6 @@ who_is_on_ident( Who_info_ident_list *result )
CHK_CONNECTION(FAILURE);
cptr = active_connection;
session = traverse_connections(0);
while (session != 0)
{
......@@ -523,7 +524,7 @@ who_is_on_ident( Who_info_ident_list *result )
result->info[i].person = cptr->pers_no;
result->info[i].what_am_i_doing = cptr->what_am_i_doing;
result->info[i].username = cptr->username;
result->info[i].hostname = cptr->hostname;
result->info[i].hostname = cptr->isc_session->remote;
result->info[i].ident_user = cptr->ident_user;
result->info[i].working_conference = filter_conf_no(
cptr->cwc, active_connection);
......@@ -557,18 +558,20 @@ who_is_on_dynamic(int want_visible,
int include_it = 0;
CHK_CONNECTION(FAILURE);
cptr = active_connection;
session = traverse_connections(0);
while (session != 0)
{
cptr = get_conn_by_number(session);
if (cptr->person == NULL || cptr->flags.invisible == TRUE)
if (!handshake_ok(cptr, 0))
include_it = 0;
else if (cptr->person == NULL || cptr->flags.invisible == TRUE)
include_it = want_invisible;
else
include_it = want_visible;
if (active_last != 0
&& include_it
&& timeval_diff_sec(current_time, cptr->active_time) > active_last
&& cptr->flags.user_active_used)
include_it = 0;
......@@ -588,12 +591,15 @@ who_is_on_dynamic(int want_visible,
{
cptr = get_conn_by_number(session);
if (cptr->person == NULL || cptr->flags.invisible == TRUE)
if (!handshake_ok(cptr, 0))
include_it = 0;
else if (cptr->person == NULL || cptr->flags.invisible == TRUE)
include_it = want_invisible;
else
include_it = want_visible;
if (active_last != 0
&& include_it
&& timeval_diff_sec(current_time, cptr->active_time) > active_last
&& cptr->flags.user_active_used)
include_it = 0;
......@@ -641,7 +647,7 @@ get_session_info (Session_no session_no,
cptr = get_conn_by_number(session_no);
if ( cptr != NULL )
if (cptr != NULL && handshake_ok(cptr, 0))
{
init_session_info(result);
result->person = cptr->pers_no;
......@@ -649,7 +655,7 @@ get_session_info (Session_no session_no,
result->working_conference = filter_conf_no(cptr->cwc,
active_connection);
result->session = cptr->session_no;
result->connection_time = cptr->session_start.tv_sec;
result->connection_time = cptr->connect_time.tv_sec;
result->idle_time = timeval_diff_sec(current_time, cptr->active_time);
/* Backward compatibility. result->username is free()d in
......@@ -677,14 +683,14 @@ get_static_session_info (Session_no session_no,
cptr = get_conn_by_number(session_no);
if ( cptr != NULL )
if (cptr != NULL && handshake_ok(cptr, 0))
{
init_static_session_info(result);
result->username = cptr->username;
result->hostname = cptr->hostname;
result->hostname = cptr->isc_session->remote;
result->ident_user = cptr->ident_user;
result->connection_time = cptr->session_start.tv_sec;
result->connection_time = cptr->connect_time.tv_sec;
return OK;
}
......@@ -707,7 +713,7 @@ get_session_info_ident (Session_no session_no,
cptr = get_conn_by_number(session_no);
if ( cptr != NULL )
if (cptr != NULL && handshake_ok(cptr, 0))
{
init_session_info_ident(result);
result->person = cptr->pers_no;
......@@ -715,10 +721,10 @@ get_session_info_ident (Session_no session_no,
result->working_conference = filter_conf_no(cptr->cwc,
active_connection);
result->session = cptr->session_no;
result->connection_time = cptr->session_start.tv_sec;
result->connection_time = cptr->connect_time.tv_sec;
result->idle_time = timeval_diff_sec(current_time, cptr->active_time);
result->username = cptr->username;
result->hostname = cptr->hostname;
result->hostname = cptr->isc_session->remote;
result->ident_user = cptr->ident_user;
return OK;
......@@ -753,7 +759,7 @@ disconnect (Session_no session_no)
cptr = get_conn_by_number(session_no);
if ( cptr != NULL )
if (cptr != NULL && handshake_ok(cptr, 0))
{
if ( session_no == active_connection->session_no ||
session_no == 0 ||
......@@ -892,7 +898,7 @@ get_client_name (Session_no session_no,
cptr = get_conn_by_number(session_no);
if ( cptr != NULL )
if (cptr != NULL && handshake_ok(cptr, 0))
{
*result = cptr->client_name;
return OK;
......@@ -916,7 +922,7 @@ get_client_version (Session_no session_no,
cptr = get_conn_by_number(session_no);
if ( cptr != NULL )
if (cptr != NULL && handshake_ok(cptr, 0))
{
*result = cptr->client_version;
return OK;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment