session.c 17.2 KB
Newer Older
Linus Tolke's avatar
Linus Tolke committed
1
/*
Per Cederqvist's avatar
Per Cederqvist committed
2
 * $Id: session.c,v 0.16 1993/10/13 00:36:13 ceder Exp $
Linus Tolke's avatar
Linus Tolke committed
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
 * Copyright (C) 1991  Lysator Academic Computer Association.
 *
 * This file is part of the LysKOM server.
 * 
 * LysKOM is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License as published by 
 * the Free Software Foundation; either version 1, or (at your option) 
 * any later version.
 * 
 * LysKOM is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 * for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with LysKOM; see the file COPYING.  If not, write to
 * Lysator, c/o ISY, Linkoping University, S-581 83 Linkoping, SWEDEN,
 * or the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, 
 * MA 02139, USA.
 *
 * Please mail bug reports to bug-lyskom@lysator.liu.se. 
 */
Per Cederqvist's avatar
Per Cederqvist committed
25
26
27
28
29
30
/*
 * session.c
 *
 * Session control and miscellaneous.
 */

Per Cederqvist's avatar
Per Cederqvist committed
31
static char *rcsid = "$Id: session.c,v 0.16 1993/10/13 00:36:13 ceder Exp $";
32
33
#include "rcs.h"
USE(rcsid);
Per Cederqvist's avatar
Per Cederqvist committed
34

Per Cederqvist's avatar
Per Cederqvist committed
35
36
#include <stdio.h>
#include <setjmp.h>
Per Cederqvist's avatar
Per Cederqvist committed
37
#include <time.h>
Per Cederqvist's avatar
Per Cederqvist committed
38
#include <sys/types.h>
Per Cederqvist's avatar
Per Cederqvist committed
39
40
41
42
43
44
45
#ifndef HAVE_DIFFTIME
#  include "tmp-difftime.h"
#endif

#include "s-string.h"
#include "kom-types.h"
#include "services.h"
Per Cederqvist's avatar
Per Cederqvist committed
46
47
#include "com.h"
#include "connections.h"
Per Cederqvist's avatar
Per Cederqvist committed
48
49
50
51
#include "internal-connections.h"
#include "manipulate.h"
#include "lyskomd.h"
#include "kom-errno.h"
Per Cederqvist's avatar
Per Cederqvist committed
52
#include "log.h"
Per Cederqvist's avatar
Per Cederqvist committed
53
54
#include "cache.h"
#include "send-async.h"
Per Cederqvist's avatar
Per Cederqvist committed
55
#include "config.h"
Per Cederqvist's avatar
Per Cederqvist committed
56
#include "server/smalloc.h"
57
58
59
60
61
62
63
64
65
66

/*
 * Create an oldstyle username, user%host.domain@host.domain.
 * The RESULT must be initialized to a string (such as EMPTY_STRING).
 * A new string will be allocated in RESULT. (The old will be freed).
 */
static void
create_oldstyle_username(String *result,
			 Connection *connection)
{
67
    if ( s_strcpy(result, connection->username) != OK )
68
69
70
71
72
	restart_kom("create_oldstyle_username(): strcpy\n");

    if ( s_strcat(result, s_fcrea_str((const unsigned char *)"@")) != OK )
	restart_kom("create_oldstyle_username: s_strcat\n");

73
    if ( s_strcat(result, connection->hostname) != OK )
74
75
76
	restart_kom("prot_a_parse_packet: s_strcat II\n");
}

Per Cederqvist's avatar
Per Cederqvist committed
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
/*
 * This function is called whenever a person leaves a conf,
 * i e when he pepsi():s or logout():s.
 */

extern void
leave_conf(void)
{
    Membership * mship;

    if (active_connection->cwc != 0 )
    {
	if ((mship = locate_membership( active_connection->cwc, ACT_P ))
	    != NULL )
	{
	    time(&mship->last_time_read);
	    mark_person_as_changed (active_connection->pers_no);
	}
	else
	{
	    log("ERROR: leave_conf(): Can't find membership of cwc.\n");
	}
	
	cached_unlock_conf( active_connection->cwc );
	active_connection->cwc = 0;
    }
}

/*
 * Log in as user pers_no. If ACTPERS is a supervisor of pers_no the login
 * will succeed regardless of the passwd. An logout() will automatically
 * be performed if ACTPERS is logged in.
 */
extern Success
111
112
login_old (Pers_no       pers_no,
	   const String  passwd)
Per Cederqvist's avatar
Per Cederqvist committed
113
114
115
116
{
    Person *pers_p;

    GET_P_STAT(pers_p, pers_no, FAILURE);
117

Per Cederqvist's avatar
Per Cederqvist committed
118
119
120
121
122
123
124
125
#if 0
    if ( !logins_allowed  && !pers_p->privileges.wheel)
    {
	kom_errno = KOM_LOGIN_DISALLOWED;
	return FAILURE;
    }
#endif
    
126
    if ( !is_supervisor(pers_no, NULL, ACTPERS, ACT_P)
Per Cederqvist's avatar
Per Cederqvist committed
127
128
129
130
131
132
133
134
	&& chk_passwd(pers_p->pwd, passwd) == FAILURE )
    {
	kom_errno = KOM_PWD;
	return FAILURE;
    }

    logout();	/*+++ How many tries are allowed before disconnection? */

135
136
    active_connection->invisible = FALSE;

Per Cederqvist's avatar
Per Cederqvist committed
137
138
139
140
141
142
143
144
145
    ACTPERS = pers_no;
    ACT_P   = pers_p;

    cached_lock_person(pers_no);
        
    pers_p->last_login = time(&active_connection->session_start);
    ++pers_p->sessions;

    s_strcpy(&pers_p->username, active_connection->username);
146
147
148
149
150
151

    /* A Person should have separate fields for ident_user and hostname.
       But for now, we use the syntax username(ident_user)@hostname. */

    if (!s_empty(active_connection->ident_user))
    {
Per Cederqvist's avatar
Per Cederqvist committed
152
	if ( s_strcat(&pers_p->username,
153
154
155
		      s_fcrea_str((const unsigned char *)"(")) != OK )
	    restart_kom("login: s_strcat (\n");

Per Cederqvist's avatar
Per Cederqvist committed
156
	if ( s_strcat(&pers_p->username, active_connection->ident_user) != OK )
157
158
	    restart_kom("login: s_strcat ident_user\n");

Per Cederqvist's avatar
Per Cederqvist committed
159
	if ( s_strcat(&pers_p->username,
160
161
162
163
		      s_fcrea_str((const unsigned char *)")")) != OK )
	    restart_kom("login: s_strcat )\n");
    }

Per Cederqvist's avatar
Per Cederqvist committed
164
    if ( s_strcat(&pers_p->username,
165
166
167
		  s_fcrea_str((const unsigned char *)"@")) != OK )
	restart_kom("prot_a_parse_packet: s_strcat\n");

Per Cederqvist's avatar
Per Cederqvist committed
168
    if ( s_strcat(&pers_p->username, active_connection->hostname) != OK )
169
170
	restart_kom("prot_a_parse_packet: s_strcat II\n");

Per Cederqvist's avatar
Per Cederqvist committed
171
172
173
174
175
176
177
    mark_person_as_changed( pers_no );
    
    async_login(ACTPERS, active_connection->session_no);
    
    return OK;
}

178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
/*
 * Log in as user pers_no. If ACTPERS is a supervisor of pers_no the login
 * will succeed regardless of the passwd. An logout() will automatically
 * be performed if ACTPERS is logged in.
 */
extern Success
login (Pers_no       pers_no,
       const String  passwd,
       Bool	     invisible)
{
    Person *pers_p;

    GET_P_STAT(pers_p, pers_no, FAILURE);

#if 0
    if ( !logins_allowed  && !pers_p->privileges.wheel)
    {
	kom_errno = KOM_LOGIN_DISALLOWED;
	return FAILURE;
    }
#endif
    
    if ( !is_supervisor(pers_no, NULL, ACTPERS, ACT_P)
	&& chk_passwd(pers_p->pwd, passwd) == FAILURE )
    {
	kom_errno = KOM_PWD;
	return FAILURE;
    }

    logout();	/*+++ How many tries are allowed before disconnection? */

209
210
    active_connection->invisible = !!invisible;		/* Normalize 17. */

211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
    ACTPERS = pers_no;
    ACT_P   = pers_p;

    cached_lock_person(pers_no);
        
    pers_p->last_login = time(&active_connection->session_start);
    ++pers_p->sessions;

    s_strcpy(&pers_p->username, active_connection->username);

    /* A Person should have separate fields for ident_user and hostname.
       But for now, we use the syntax username(ident_user)@hostname. */

    if (!s_empty(active_connection->ident_user))
    {
Per Cederqvist's avatar
Per Cederqvist committed
226
	if ( s_strcat(&pers_p->username,
227
228
229
		      s_fcrea_str((const unsigned char *)"(")) != OK )
	    restart_kom("login: s_strcat (\n");

Per Cederqvist's avatar
Per Cederqvist committed
230
	if ( s_strcat(&pers_p->username, active_connection->ident_user) != OK )
231
232
	    restart_kom("login: s_strcat ident_user\n");

Per Cederqvist's avatar
Per Cederqvist committed
233
	if ( s_strcat(&pers_p->username,
234
235
236
237
		      s_fcrea_str((const unsigned char *)")")) != OK )
	    restart_kom("login: s_strcat )\n");
    }

Per Cederqvist's avatar
Per Cederqvist committed
238
    if ( s_strcat(&pers_p->username,
239
240
241
		  s_fcrea_str((const unsigned char *)"@")) != OK )
	restart_kom("prot_a_parse_packet: s_strcat\n");

Per Cederqvist's avatar
Per Cederqvist committed
242
    if ( s_strcat(&pers_p->username, active_connection->hostname) != OK )
243
244
245
246
247
248
249
250
251
252
	restart_kom("prot_a_parse_packet: s_strcat II\n");

    mark_person_as_changed( pers_no );

    if (!active_connection->invisible)
	async_login(ACTPERS, active_connection->session_no);
    
    return OK;
}

Per Cederqvist's avatar
Per Cederqvist committed
253
254
255
256
257
258
259
260
261
262
263

/*
 * Log out. Does not disconnect the client. The person is also automatically
 * logged out if the connection is closed. Takes no action if noone is logged
 * in on this line. Never fails.
 */
extern Success
logout(	void )
{
    if ( ACTPERS != 0 )		/* Is he logged in? Then log him out. */
    {
264
	if (!active_connection->invisible)
265
266
267
268
	{
	    async_i_am_off( ACTPERS );
	    async_logout( ACTPERS, active_connection->session_no );
	}
Per Cederqvist's avatar
Per Cederqvist committed
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
	
	leave_conf();
	ACT_P->total_time_present +=
	    difftime(time(&ACT_P->last_login),
		     active_connection->session_start);

	cached_unlock_person( ACTPERS );
	mark_person_as_changed( ACTPERS );
    }
    
    
    s_clear(&active_connection -> what_am_i_doing);
    
    active_connection->person		= NULL;
    active_connection->cwc		= 0;
    active_connection->pers_no		= 0;
    active_connection->ena_level	= 0;
    
    return OK;
}


/*
 * Change Conference.
 *
 * You are not allowed to change to a conference unless you are a
 * member in the conference.
 *
 * You can pepsi(0) to indicate that you are no longer in a certain
 * conference.
 *
 * There are two reasons to use this call:
 *	1) Other persons want to know what you are doing.
 *	2) When the server checks that you have permission to
 *	   read a certain text it first checks if you current working
 *	   conference is a recipient of the text, since that is a
 *	   cheap test. If that test fails it will have to read in the
 *	   conference structs for the recipients of the text until it
 *	   finds an open one.
 *
 * In the future the server might read in the conference in advance when
 * someone pepsi's to it to allow faster response times.
 */
extern Success
pepsi (Conf_no		conference)		
{
    Who_info	 info = EMPTY_WHO_INFO;
    
    CHK_LOGIN(FAILURE);
    if (  conference != 0 )
    {
	CHK_EXIST(conference, FAILURE);

	if ( locate_membership( conference, ACT_P) == NULL )
	{
	    kom_errno = KOM_NOT_MEMBER;
	    return FAILURE;
	}
    }

    leave_conf();
    
    active_connection->cwc = conference;
    if ( conference != 0 )
	cached_lock_conf( conference );

335
336
337
338
339
340
    if (!active_connection->invisible)
    {
	info.person = ACTPERS;
	info.what_am_i_doing = active_connection->what_am_i_doing;
	info.working_conference = conference;
	info.session_no = active_connection->session_no;
341
342
343
344

	/* Bug compatibility. */
	create_oldstyle_username(&info.username, active_connection);

345
	async_i_am_on(info);
346
347

	s_clear(&info.username);
348
    }
Per Cederqvist's avatar
Per Cederqvist committed
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
    
    return OK;
}


/*
 * Tell the server what you are doing. This string is sent to anyone
 * who does a 'who_is_on()'.
 */
extern Success
change_what_i_am_doing (String  what_am_i_doing)
{
    Who_info info = EMPTY_WHO_INFO; 

    if ( s_strlen( what_am_i_doing ) > WHAT_DO_LEN )
    {
	s_clear ( &what_am_i_doing );
	kom_errno = KOM_LONG_STR;
	return FAILURE;
    }
    
    s_clear ( &active_connection->what_am_i_doing );
    active_connection->what_am_i_doing = what_am_i_doing;

373
374
375
376
    if (!active_connection->invisible)
    {
	info.person = ACTPERS;
	info.what_am_i_doing = active_connection->what_am_i_doing;
377
	create_oldstyle_username(&info.username, active_connection);
378
379
	info.working_conference = active_connection->cwc;
	info.session_no = active_connection->session_no;
Per Cederqvist's avatar
Per Cederqvist committed
380
    
381
	async_i_am_on(info);
382
383

	s_clear(&info.username);
384
    }
Per Cederqvist's avatar
Per Cederqvist committed
385
386
387
388

    return OK;
}

389

Per Cederqvist's avatar
Per Cederqvist committed
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
/*
 * Get info about what all the currently logged in persons are doing.
 */
extern Success
who_is_on( Who_info_list *result )
{
    Connection *cptr;
    int 	    no_of_clients = 0;
    int		    i;
    Session_no      session;
    
    cptr = active_connection;
    
    for ( session = 0; (session = traverse_connections(session)) != 0; )
    {
	cptr = get_conn_by_number(session);

407
	if ( cptr->person != NULL && cptr->invisible == FALSE )
Per Cederqvist's avatar
Per Cederqvist committed
408
409
410
411
412
413
414
415
416
417
418
	    ++no_of_clients;
    }

    result->no_of_persons = no_of_clients;
    result->info = tmp_alloc ( no_of_clients * sizeof(Who_info));

    for ( session = 0, i = 0;
	 i < no_of_clients && (session = traverse_connections(session)) != 0; )
    {
	cptr = get_conn_by_number(session);

419
	if ( cptr->person != NULL && cptr->invisible == FALSE )
Per Cederqvist's avatar
Per Cederqvist committed
420
421
422
423
	{
	    result->info[ i ] = EMPTY_WHO_INFO;
	    result->info[ i ].person = cptr->pers_no;
	    result->info[ i ].what_am_i_doing = cptr->what_am_i_doing;
424
425
426
427

	    /* Backward compatibility: Old clients want the username to be
	       user%host@host. result->info[i].username is free()d in
	       prot_a_output_who_info_list() in prot-a-output.c. */
428
	    create_oldstyle_username(&result->info[i].username, cptr);
429

Per Cederqvist's avatar
Per Cederqvist committed
430
431
432
433
434
435
436
437
438
439
440
441
442
	    result->info[ i ].working_conference = cptr->cwc;
	    result->info[ i ].session_no = cptr->session_no;
	    ++i;
	}
    }

    if ( i != no_of_clients )
	log("who_is_on: i == %d, no_of_clients == %d\n",
	    i, no_of_clients);

    return OK;
}

443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
/*
 * Get info about what all the currently logged in persons are doing.
 */
extern Success
who_is_on_ident( Who_info_ident_list *result )
{
    Connection *cptr;
    int 	    no_of_clients = 0;
    int		    i;
    Session_no      session;
    
    cptr = active_connection;
    
    for ( session = 0; (session = traverse_connections(session)) != 0; )
    {
	cptr = get_conn_by_number(session);

460
	if ( cptr->person != NULL && cptr->invisible == FALSE )
461
462
463
464
	    ++no_of_clients;
    }

    result->no_of_persons = no_of_clients;
465
    result->info = tmp_alloc ( no_of_clients * sizeof(Who_info_ident));
466
467
468
469
470
471

    for ( session = 0, i = 0;
	 i < no_of_clients && (session = traverse_connections(session)) != 0; )
    {
	cptr = get_conn_by_number(session);

472
	if ( cptr->person != NULL && cptr->invisible == FALSE )
473
	{
Per Cederqvist's avatar
Per Cederqvist committed
474
	    result->info[i] = EMPTY_WHO_INFO_IDENT;
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
	    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].ident_user = cptr->ident_user;
	    result->info[i].working_conference = cptr->cwc;
	    result->info[i].session_no = cptr->session_no;
	    ++i;
	}
    }

    if ( i != no_of_clients )
	log("who_is_on_ident: i == %d, no_of_clients == %d\n",
	    i, no_of_clients);

    return OK;
}

Per Cederqvist's avatar
Per Cederqvist committed
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514

extern  Success
get_session_info  (Session_no session_no,
		   Session_info *result)
{
    Connection *cptr;

    CHK_LOGIN(FAILURE);

    cptr = get_conn_by_number(session_no);

    if ( cptr != NULL )
    {
	*result = EMPTY_SESSION_INFO;
	result->person = cptr->pers_no;
	result->what_am_i_doing = cptr->what_am_i_doing;
	result->working_conference = cptr->cwc;
	result->session = cptr->session_no;
	result->connection_time = cptr->session_start;
	result->idle_time = difftime(time(NULL),
				     cptr->last_request);

515
516
	/* Backward compatibility. result->username is free()d in
	   prot_a_reply() prot-a.c. */
517
	create_oldstyle_username(&result->username, cptr);
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539

	return OK;
    }
    else
    {
	kom_errno = KOM_UNDEF_SESSION;
	return FAILURE;
    }
}

extern  Success
get_session_info_ident  (Session_no session_no,
			 Session_info_ident *result)
{
    Connection *cptr;

    CHK_LOGIN(FAILURE);

    cptr = get_conn_by_number(session_no);

    if ( cptr != NULL )
    {
Per Cederqvist's avatar
Per Cederqvist committed
540
	*result = EMPTY_SESSION_INFO_IDENT;
541
542
543
544
545
546
547
548
549
550
551
	result->person = cptr->pers_no;
	result->what_am_i_doing = cptr->what_am_i_doing;
	result->working_conference = cptr->cwc;
	result->session = cptr->session_no;
	result->connection_time = cptr->session_start;
	result->idle_time = difftime(time(NULL),
				     cptr->last_request);
	result->username = cptr->username;
	result->hostname = cptr->hostname;
	result->ident_user = cptr->ident_user;

Per Cederqvist's avatar
Per Cederqvist committed
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
	return OK;
    }
    else
    {
	kom_errno = KOM_UNDEF_SESSION;
	return FAILURE;
    }
}

extern  Success
who_am_i (Session_no *session_no)
{
    *session_no = active_connection->session_no;
    return OK;
}



extern  Success
disconnect (Session_no session_no)
{
    Connection *cptr;

    if ( session_no != active_connection->session_no )
	CHK_LOGIN(FAILURE);

    cptr = get_conn_by_number(session_no);

    if ( cptr != NULL )
    {
582
	if ( is_supervisor(cptr->pers_no, NULL, ACTPERS, ACT_P)
Per Cederqvist's avatar
Per Cederqvist committed
583
584
	    || session_no == active_connection->session_no )
	{
585
	    add_to_kill_list(cptr);
Per Cederqvist's avatar
Per Cederqvist committed
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
	    return OK;
	}
	else
	{
	    kom_errno = KOM_PERM;
	    return FAILURE;
	}
    }
    else
    {
	kom_errno = KOM_UNDEF_SESSION;
	return FAILURE;
    }
}


/* Get less info */
extern Success
who_is_on_old( Who_info_list_old *result )
{
    Connection *cptr;
    int 	    no_of_clients = 0;
    int		    i;
    Session_no	    session = 0;

    
    while ( (session = traverse_connections(session)) != 0)
    {
	cptr = get_conn_by_number(session);

616
	if ( cptr->person != NULL && cptr->invisible == FALSE )
Per Cederqvist's avatar
Per Cederqvist committed
617
618
619
620
621
622
623
624
625
626
627
	    ++no_of_clients;
    }

    result->no_of_persons = no_of_clients;
    result->info = tmp_alloc ( no_of_clients * sizeof(Who_info));

    for (session = 0, i = 0;
	 i < no_of_clients && (session = traverse_connections(session)) != 0;)
    {
	cptr = get_conn_by_number(session);

628
	if ( cptr->person != NULL && cptr->invisible == FALSE )
Per Cederqvist's avatar
Per Cederqvist committed
629
630
631
632
633
634
635
636
637
638
	{
	    result->info[ i ] = EMPTY_WHO_INFO_OLD;
	    result->info[ i ].person = cptr->pers_no;
	    result->info[ i ].what_am_i_doing = cptr->what_am_i_doing;
	    result->info[ i ].working_conference = cptr->cwc;
	    ++i;
	}
    }
    
    if ( i != no_of_clients )
639
	log("who_is_on_old: i == %d, no_of_clients == %d\n",
Per Cederqvist's avatar
Per Cederqvist committed
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
	    i, no_of_clients);

    return OK;
}

/*
 * Ask the server what it thinks the time is.
 */
extern Success
get_time( time_t *clock )
{
    time(clock);
    
    return OK;
}



/*
 * Set ena_level. 0 means don't use any privileges. ///
 */
extern Success
enable (u_char ena_level)
{
    CHK_LOGIN(FAILURE);
    active_connection->ena_level = ena_level;
    return OK;
}
Per Cederqvist's avatar
Per Cederqvist committed
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727

extern  Success
set_client_version (const String client_name,
		    const String client_version)
{
    if (s_strlen(client_name) > CONF_NAME_LEN
	|| s_strlen(client_version) > CONF_NAME_LEN)
    {
	kom_errno = KOM_LONG_STR;
	return FAILURE;
    }

    s_strcpy(&active_connection->client_name, client_name);
    s_strcpy(&active_connection->client_version, client_version);
    return OK;
}

extern  Success
get_client_name (Session_no session_no,
		 String *result)
{
    Connection *cptr;

    CHK_LOGIN(FAILURE);

    cptr = get_conn_by_number(session_no);

    if ( cptr != NULL )
    {
	*result = cptr->client_name;
	return OK;
    }
    else
    {
	kom_errno = KOM_UNDEF_SESSION;
	return FAILURE;
    }
}

extern  Success
get_client_version (Session_no session_no,
		    String *result)
{
    Connection *cptr;

    CHK_LOGIN(FAILURE);

    cptr = get_conn_by_number(session_no);

    if ( cptr != NULL )
    {
	*result = cptr->client_version;
	return OK;
    }
    else
    {
	kom_errno = KOM_UNDEF_SESSION;
	return FAILURE;
    }
}