Commit 4f1f5922 authored by Per Cederqvist's avatar Per Cederqvist

Support for invisible sessions and the Ident protocol (RFC 931).

Renamed login() to login_old().
Added login(), get_session_info_ident() and who_is_on_ident().
parent 36480f4d
Wed Apr 1 22:02:55 1992 Per Cederqvist (ceder@lysator)
* connections.h (Connection): New field: invisible.
* session.c, fncdef.txt (login_old): New name for the function
login().
* fncdef.txt (login): New function with a parameter for invisible
use.
* session.c, fncdef.txt (login): New function with invisibility
support.
* session.c (logout, pepsi, change_what_i_am_doing): Don't send
asynchronous messages if the session is invisible.
* connections.h (Connection): New field: ident_user.
* connections.h (Res_type): New types: rt_session_info_ident and
rt_who_info_ident_list.
* connections.c (login_request): Set ident_user.
* fncdef.txt (who_is_on_ident, get_session_info_ident): New
functions that behaves like who_is_on and get_session_info, but
also returns the ident name.
* internal_conections.c (EMPTY_CONNECTION, new_client,
kill_client): Set/free ident_user and invisible.
* prot_a_output.c (prot_a_output_who_info_ident,
prot_a_output_who_info_ident_list,
prot_a_output_session_info_ident): New functions.
* prot-a.c (reply): rt_who_info_ident_list and
rt_session_info_ident: New reply types.
* session.c (login_old): Generate the a proper (but not
1.1.0-compatible) string in username.
* session.c (who_is_on, get_session_info): Generate username.
* session.c (who_is_on_ident, get_session_info_ident): New functions.
* prot-a.c (prot_a_reply): Free username when returning a
session_info.
It is allocated in get_session_info() in session.c.
* prot-a-output.c (prot_a_output_who_info_list): Free username
when returning a who_info_list.
Tue Mar 31 23:48:47 1992 Per Cederqvist (ceder@robert)
* rfc931.[hc]: New file.
......
/*
* $Id: connections.c,v 0.12 1992/02/26 18:45:19 ceder Exp $
* $Id: connections.c,v 0.13 1992/04/01 20:50:37 ceder Exp $
* Copyright (C) 1991 Lysator Academic Computer Association.
*
* This file is part of the LysKOM server.
......@@ -30,7 +30,7 @@
* Created by Willf|r 31/3-90. Mostly written by ceder.
*/
static char *rcsid = "$Id: connections.c,v 0.12 1992/02/26 18:45:19 ceder Exp $";
static char *rcsid = "$Id: connections.c,v 0.13 1992/04/01 20:50:37 ceder Exp $";
#include <errno.h>
......@@ -65,6 +65,7 @@ static char *rcsid = "$Id: connections.c,v 0.12 1992/02/26 18:45:19 ceder Exp $"
#include "mux.h"
#include "mux-parse.h"
#include "internal-connections.h"
#include "rfc931.h"
ISCMCB * kom_server_mcb = NULL;
Connection * active_connection = NULL;
......@@ -712,7 +713,13 @@ login_request(ISCECB *event)
cp = new_client();
cp->mux = event->session->udg;
s_crea_str(&cp->hostname, event->session->info.tcp.hostname);
/* Get the real user name, as returned by the Ident protocol
(rfc 931). */
realuser = ger_real_username(event->session);
if (realuser != NULL)
s_crea_str(&cp->ident_user, realuser);
mux_addclient(event->session->udg, 0, cp);
BUG(("\n[Client %d from %s", cp->session_no,
......
/*
* $Id: connections.h,v 0.7 1992/02/26 18:45:18 ceder Exp $
* $Id: connections.h,v 0.8 1992/04/01 20:50:40 ceder Exp $
* Copyright (C) 1991 Lysator Academic Computer Association.
*
* This file is part of the LysKOM server.
......@@ -23,7 +23,7 @@
* Please mail bug reports to bug-lyskom@lysator.liu.se.
*/
/*
* $Id: connections.h,v 0.7 1992/02/26 18:45:18 ceder Exp $
* $Id: connections.h,v 0.8 1992/04/01 20:50:40 ceder Exp $
*
* connections.h -- The top level of the communication packet.
*
......@@ -55,6 +55,8 @@ typedef struct connection {
u_char ena_level; /* Enable level */
String username; /* Userid and hostname. */
String hostname; /* Real hostname */
String ident_user; /* Real username */
Bool invisible; /* Is this session invisible? */
/* The following are used by server/connections.c */
......@@ -149,11 +151,19 @@ typedef enum {
rt_time_date,
rt_session_info,
rt_session_no,
rt_text_no
rt_text_no,
rt_session_info_ident,
rt_who_info_ident_list
} Res_type;
/*
* The result from a call is stored in this union.
*
* The pointers in these structures are normally set to point into
* data from the cache, and should thus not be free()d. In those cases
* where this actually contains newly allocated memory (and it is not
* allocated via tmp_alloc()) it should be free()d in prot_a_reply() in
* prot-a.c.
*/
typedef union {
u_long number;
......
/*
* $Id: internal-connections.c,v 0.7 1991/11/10 19:02:31 linus Exp $
* $Id: internal-connections.c,v 0.8 1992/04/01 20:50:42 ceder Exp $
* Copyright (C) 1991 Lysator Academic Computer Association.
*
* This file is part of the LysKOM server.
......@@ -28,7 +28,7 @@
* Abstract routines on the data type Connection.
*/
static char *rcsid = "$Id: internal-connections.c,v 0.7 1991/11/10 19:02:31 linus Exp $";
static char *rcsid = "$Id: internal-connections.c,v 0.8 1992/04/01 20:50:42 ceder Exp $";
#include "exp.h"
......@@ -49,13 +49,21 @@ INTERNAL Session_no no_of_connection_attempts = 0;
INTERNAL Connection *last_conn = NULL;
INTERNAL const Connection EMPTY_CONNECTION =
((Connection){0, NULL, NULL, 0, NULL, NO_TIME, 0,
EMPTY_STRING_i, 0, EMPTY_STRING_i, EMPTY_STRING_i,
((Connection){0, NULL, NULL,
/* Things used by services.c */
0, NULL, NO_TIME, 0,
EMPTY_STRING_i, 0,
EMPTY_STRING_i, EMPTY_STRING_i, EMPTY_STRING_i,
FALSE,
/* Used by server/connections.c */
NULL, '\0',
0, 0, 0, 0, 0, 0, 0,
/* Gather data... */
0, 0, 0, 0, EMPTY_STRING_i, EMPTY_STRING_i,
EMPTY_STRING_i, NULL, NULL, DEFAULT_PRIV_BITS_i,
NULL_CONF_TYPE_i, EMPTY_tm_i, EMPTY_STRING_i, 0, FALSE,
NULL_CONF_TYPE_i, EMPTY_tm_i,
/* Protocol independent... */
EMPTY_STRING_i, 0, FALSE,
NO_TIME,
0, FALSE});
......@@ -109,6 +117,8 @@ new_client(void)
c->what_am_i_doing = EMPTY_STRING;
c->ena_level = 0;
c->username = EMPTY_STRING;
c->ident_user = EMPTY_STRING;
c->invisible = FALSE;
c->kill_me = FALSE;
return c;
......@@ -154,6 +164,7 @@ kill_client(Connection *cp)
s_clear(&cp->what_am_i_doing);
s_clear(&cp->username);
s_clear(&cp->hostname);
s_clear(&cp->ident_user);
if ( cp->mux != NULL )
{
......
/*
* $Id: prot-a-output.c,v 0.7 1991/11/16 03:30:08 ceder Exp $
* $Id: prot-a-output.c,v 0.8 1992/04/01 20:50:44 ceder Exp $
* Copyright (C) 1991 Lysator Academic Computer Association.
*
* This file is part of the LysKOM server.
......@@ -28,7 +28,7 @@
* Written by ceder 1990-07-13
*/
static char *rcsid = "$Id: prot-a-output.c,v 0.7 1991/11/16 03:30:08 ceder Exp $";
static char *rcsid = "$Id: prot-a-output.c,v 0.8 1992/04/01 20:50:44 ceder Exp $";
#include <kom-types.h>
......@@ -257,10 +257,10 @@ prot_a_output_text_list(Connection *fp,
else
mux_printf(fp, " *");
}
void
prot_a_output_who_info(Connection *fp,
Who_info *info)
static void
prot_a_output_who_info_ident(Connection *fp,
Who_info_ident *info)
{
mux_printf(fp, " %lu %lu %lu",
(u_long)info->person,
......@@ -269,6 +269,26 @@ prot_a_output_who_info(Connection *fp,
prot_a_output_string(fp, info->what_am_i_doing);
prot_a_output_string(fp, info->username);
prot_a_output_string(fp, info->hostname);
prot_a_output_string(fp, info->ident_user);
}
static void
prot_a_output_who_info(Connection *fp,
Who_info *info)
{
String user_host_host = EMPTY_STRING;
mux_printf(fp, " %lu %lu %lu",
(u_long)info->person,
(u_long)info->working_conference,
(u_long)info->session_no);
prot_a_output_string(fp, info->what_am_i_doing);
prot_a_output_string(fp, user_host_host);
s_clear(&user_host_host);
}
......@@ -286,6 +306,30 @@ prot_a_output_who_info_list(Connection *fp,
for ( i = 0; i < info.no_of_persons; i++ )
{
prot_a_output_who_info(fp, &info.info[ i ]);
/* The username is specially alloced in who_is_on() in
session.c. */
s_clear(&info.info[i].username);
}
mux_printf(fp, " }");
}
else
mux_printf(fp, " *");
}
void
prot_a_output_who_info_ident_list(Connection *fp,
Who_info_ident_list info)
{
int i;
mux_printf(fp, " %lu", (u_long)info.no_of_persons);
if ( info.info != NULL && info.no_of_persons > 0 )
{
mux_printf(fp, " {");
for ( i = 0; i < info.no_of_persons; i++ )
{
prot_a_output_who_info_ident(fp, &info.info[ i ]);
}
mux_printf(fp, " }");
}
......@@ -333,6 +377,24 @@ prot_a_output_session_info(Connection *fp,
mux_printf(fp, " %lu", (u_long)info->idle_time);
prot_a_output_time(fp, info->connection_time);
}
void
prot_a_output_session_info_ident(Connection *fp,
Session_info *info)
{
mux_printf(fp, " %lu %lu %lu",
(u_long)info->person,
(u_long)info->working_conference,
(u_long)info->session);
prot_a_output_string(fp, info->what_am_i_doing);
prot_a_output_string(fp, info->username);
prot_a_output_string(fp, info->hostname);
prot_a_output_string(fp, info->ident_user);
mux_printf(fp, " %lu", (u_long)info->idle_time);
prot_a_output_time(fp, info->connection_time);
}
void
prot_a_output_info(Connection *fp,
......
/*
* $Id: prot-a-output.h,v 0.4 1991/11/16 03:30:07 ceder Exp $
* $Id: prot-a-output.h,v 0.5 1992/04/01 20:50:46 ceder Exp $
* Copyright (C) 1991 Lysator Academic Computer Association.
*
* This file is part of the LysKOM server.
......@@ -23,7 +23,7 @@
* Please mail bug reports to bug-lyskom@lysator.liu.se.
*/
/*
* $Id: prot-a-output.h,v 0.4 1991/11/16 03:30:07 ceder Exp $
* $Id: prot-a-output.h,v 0.5 1992/04/01 20:50:46 ceder Exp $
*
*/
extern void
......@@ -76,6 +76,9 @@ prot_a_output_who_info_list(Connection *fp,
Who_info_list info);
extern void
prot_a_output_who_info_ident_list(Connection *fp,
Who_info_ident_list info)
extern void
prot_a_output_who_info_list_old(Connection *fp,
Who_info_list_old info);
......@@ -83,6 +86,10 @@ void
prot_a_output_session_info(Connection *fp,
Session_info *info);
void
prot_a_output_session_info_ident(Connection *fp,
Session_info *info);
extern void
prot_a_output_string(Connection *fp,
String str);
......
/*
* $Id: prot-a.c,v 0.12 1991/12/17 23:07:40 ceder Exp $
* $Id: prot-a.c,v 0.13 1992/04/01 20:50:49 ceder Exp $
* Copyright (C) 1991 Lysator Academic Computer Association.
*
* This file is part of the LysKOM server.
......@@ -26,7 +26,7 @@
* Protocol A.
*/
static char *rcsid = "$Id: prot-a.c,v 0.12 1991/12/17 23:07:40 ceder Exp $";
static char *rcsid = "$Id: prot-a.c,v 0.13 1992/04/01 20:50:49 ceder Exp $";
#include <stdio.h>
......@@ -133,6 +133,10 @@ prot_a_reply(Connection *client,
case rt_session_info:
prot_a_output_session_info(client,
&res->session_info);
/* Clear username, since it is allocated (in get_session_info()
in session.c). See comment abover the definition of
typedef Result_holder in connections.h. */
s_clear(&res->session_info->username);
BUG(("={Session_info not listed}\n"));
break;
......@@ -165,6 +169,18 @@ prot_a_reply(Connection *client,
prot_a_output_text_no (client, res->text_no);
BUG(("=(Text_no)%d\n", res->text_no));
break;
case rt_who_info_ident_list:
prot_a_output_who_info_ident_list(client,
res->who_info_ident_list);
BUG(("={Who_info_ident_list not listed}\n"));
break;
case rt_session_info_ident:
prot_a_output_session_info_ident(client,
&res->session_info);
BUG(("={Session_info_ident not listed}\n"));
break;
}
mux_putc('\n', client);
}
......@@ -237,7 +253,7 @@ prot_a_is_legal_fnc(Call_header fnc)
{
switch(fnc)
{
case call_fnc_login:
case call_fnc_login_old:
case call_fnc_logout:
case call_fnc_pepsi:
case call_fnc_change_name:
......@@ -299,6 +315,9 @@ prot_a_is_legal_fnc(Call_header fnc)
case call_fnc_create_anonymous_text:
case call_fnc_find_next_text_no:
case call_fnc_find_previous_text_no:
case call_fnc_who_is_on_ident:
case call_fnc_get_session_info_ident:
case call_fnc_login:
return TRUE;
default:
......@@ -320,13 +339,6 @@ prot_a_parse_packet(Connection *client)
client->c_string0 = EMPTY_STRING; /* "A5B" as first input. */
/* Protokoll B will not suffer from this... */
if ( s_strcat(&client->username,
s_fcrea_str((const unsigned char *)"@")) != OK )
restart_kom("prot_a_parse_packet: s_strcat\n");
if ( s_strcat(&client->username, client->hostname) != OK )
restart_kom("prot_a_parse_packet: s_strcat II\n");
mux_printf(client, "LysKOM\n");
mux_flush(client);
BUG(("[Client %d is logged on]\n", client->session_no));
......
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