View | Details | Raw Unified | Return to bug 80732 | Differences between
and this patch

Collapse All | Expand All

(-)/usr/src/contrib/telnet/telnetd/ext.h (-2 / +1 lines)
Lines 112-119 Link Here
112
#endif
112
#endif
113
	process_slc(unsigned char, unsigned char, cc_t),
113
	process_slc(unsigned char, unsigned char, cc_t),
114
	ptyflush(void),
114
	ptyflush(void),
115
	putchr(int),
115
	putf(char *, char *, size_t),
116
	putf(char *, char *),
117
	recv_ayt(void),
116
	recv_ayt(void),
118
	send_do(int, int),
117
	send_do(int, int),
119
	send_dont(int, int),
118
	send_dont(int, int),
(-)/usr/src/contrib/telnet/telnetd/telnetd.c (-8 / +26 lines)
Lines 42-48 Link Here
42
#include "telnetd.h"
42
#include "telnetd.h"
43
#include "pathnames.h"
43
#include "pathnames.h"
44
44
45
#include <sys/mman.h>
46
#include <err.h>
45
#include <err.h>
47
#include <libutil.h>
46
#include <libutil.h>
48
#include <paths.h>
47
#include <paths.h>
Lines 740-745 Link Here
740
	char *HE;
739
	char *HE;
741
	char *HN;
740
	char *HN;
742
	char *IM;
741
	char *IM;
742
	char *IF;
743
	int nfd;
743
	int nfd;
744
744
745
	/*
745
	/*
Lines 900-921 Link Here
900
	 */
900
	 */
901
901
902
	if (getent(defent, "default") == 1) {
902
	if (getent(defent, "default") == 1) {
903
		char *cp=defstrs;
903
		char *cp = defstrs;
904
904
905
		HE = Getstr("he", &cp);
905
		HE = Getstr("he", &cp);
906
		HN = Getstr("hn", &cp);
906
		HN = Getstr("hn", &cp);
907
		IM = Getstr("im", &cp);
907
		IF = Getstr("if", &cp);
908
		if (HN && *HN)
908
		if (HN != NULL && *HN != 0)
909
			(void) strlcpy(host_name, HN, sizeof(host_name));
909
			(void) strlcpy(host_name, HN, sizeof(host_name));
910
		if (IM == 0)
910
		if (IF != NULL) {
911
			IM = strdup("");
911
			int if_fd;
912
913
			if ((if_fd = open(IF, O_RDONLY)) != -1) {
914
				struct stat if_fst;
915
916
				fstat(if_fd, &if_fst);
917
				IM = malloc(if_fst.st_size + 1);
918
				read(if_fd, IM, if_fst.st_size);
919
				IM[if_fst.st_size] = 0;
920
				close(if_fd);
921
			} else {
922
				IF = NULL;
923
			}
924
		}
925
		if (IF == NULL) {
926
			IM = Getstr("im", &cp);
927
			if (IM == NULL)
928
				IM = strdup("");
929
		}
912
	} else {
930
	} else {
913
		IM = strdup(DEFAULT_IM);
931
		IM = strdup(DEFAULT_IM);
914
		HE = 0;
932
		HE = NULL;
915
	}
933
	}
916
	edithost(HE, host_name);
934
	edithost(HE, host_name);
917
	if (hostinfo && *IM)
935
	if (hostinfo && *IM)
918
		putf(IM, ptyibuf2);
936
		putf(IM, ptyibuf2, BUFSIZ);
919
937
920
	if (pcc)
938
	if (pcc)
921
		(void) strncat(ptyibuf2, ptyip, pcc+1);
939
		(void) strncat(ptyibuf2, ptyip, pcc+1);
(-)/usr/src/contrib/telnet/telnetd/utility.c (-50 / +23 lines)
Lines 66-76 Link Here
66
 * also flush the pty input buffer (by dropping its data) if it becomes
66
 * also flush the pty input buffer (by dropping its data) if it becomes
67
 * too full.
67
 * too full.
68
 */
68
 */
69
69
void
70
    void
70
ttloop(void)
71
ttloop()
72
{
71
{
73
74
    DIAG(TD_REPORT, output_data("td: ttloop\r\n"));
72
    DIAG(TD_REPORT, output_data("td: ttloop\r\n"));
75
    if (nfrontp - nbackp > 0) {
73
    if (nfrontp - nbackp > 0) {
76
	netflush();
74
	netflush();
Lines 393-414 Link Here
393
	editedhost[sizeof editedhost - 1] = '\0';
391
	editedhost[sizeof editedhost - 1] = '\0';
394
}
392
}
395
393
396
static char *putlocation;
397
398
static void
399
putstr(const char *s)
400
{
401
402
	while (*s)
403
		putchr(*s++);
404
}
405
406
void
407
putchr(int cc)
408
{
409
	*putlocation++ = cc;
410
}
411
412
#ifdef __FreeBSD__
394
#ifdef __FreeBSD__
413
static char fmtstr[] = { "%+" };
395
static char fmtstr[] = { "%+" };
414
#else
396
#else
Lines 416-426 Link Here
416
#endif
398
#endif
417
399
418
void
400
void
419
putf(char *cp, char *where)
401
putf(char *cp, char *where, size_t where_size)
420
{
402
{
421
	char *slash;
403
	char *slash;
422
	time_t t;
404
	time_t t;
423
	char db[100];
405
	char db[100];
406
	char ch_str[2] = {0, 0};
424
#ifdef __FreeBSD__
407
#ifdef __FreeBSD__
425
	static struct utsname kerninfo;
408
	static struct utsname kerninfo;
426
409
Lines 428-446 Link Here
428
		uname(&kerninfo);
411
		uname(&kerninfo);
429
#endif
412
#endif
430
413
431
	putlocation = where;
414
	while (*cp != 0) {
432
415
		if (*cp == '\n') {
433
	while (*cp) {
416
			strlcat(where, "\r\n", where_size);
434
		if (*cp =='\n') {
435
			putstr("\r\n");
436
			cp++;
437
			continue;
438
		} else if (*cp != '%') {
417
		} else if (*cp != '%') {
439
			putchr(*cp++);
418
			*ch_str = *cp;
440
			continue;
419
			strlcat(where, ch_str, where_size);
441
		}
420
		} else switch (*++cp) {
442
		switch (*++cp) {
443
444
		case 't':
421
		case 't':
445
#ifdef	STREAMSPTY
422
#ifdef	STREAMSPTY
446
			/* names are like /dev/pts/2 -- we want pts/2 */
423
			/* names are like /dev/pts/2 -- we want pts/2 */
Lines 448-493 Link Here
448
#else
425
#else
449
			slash = strrchr(line, '/');
426
			slash = strrchr(line, '/');
450
#endif
427
#endif
451
			if (slash == (char *) 0)
428
			if (slash == NULL)
452
				putstr(line);
429
				strlcat(where, line, where_size);
453
			else
430
			else
454
				putstr(&slash[1]);
431
				strlcat(where, &slash[1], where_size);
455
			break;
432
			break;
456
457
		case 'h':
433
		case 'h':
458
			putstr(editedhost);
434
			strlcat(where, editedhost, where_size);
459
			break;
435
			break;
460
461
		case 'd':
436
		case 'd':
462
#ifdef __FreeBSD__
437
#ifdef __FreeBSD__
463
			setlocale(LC_TIME, "");
438
			setlocale(LC_TIME, "");
464
#endif
439
#endif
465
			(void)time(&t);
440
			(void)time(&t);
466
			(void)strftime(db, sizeof(db), fmtstr, localtime(&t));
441
			(void)strftime(db, sizeof(db), fmtstr, localtime(&t));
467
			putstr(db);
442
			strlcat(where, db, where_size);
468
			break;
443
			break;
469
470
#ifdef __FreeBSD__
444
#ifdef __FreeBSD__
471
		case 's':
445
		case 's':
472
			putstr(kerninfo.sysname);
446
			strlcat(where, kerninfo.sysname, where_size);
473
			break;
447
			break;
474
475
		case 'm':
448
		case 'm':
476
			putstr(kerninfo.machine);
449
			strlcat(where, kerninfo.machine, where_size);
477
			break;
450
			break;
478
479
		case 'r':
451
		case 'r':
480
			putstr(kerninfo.release);
452
			strlcat(where, kerninfo.release, where_size);
481
			break;
453
			break;
482
483
		case 'v':
454
		case 'v':
484
			putstr(kerninfo.version);
455
			strlcat(where, kerninfo.version, where_size);
485
			break;
456
			break;
486
#endif
457
#endif
487
488
		case '%':
458
		case '%':
489
			putchr('%');
459
			*ch_str = '%';
460
			strlcat(where, ch_str, where_size);
490
			break;
461
			break;
462
		case 0:
463
			return;
491
		}
464
		}
492
		cp++;
465
		cp++;
493
	}
466
	}

Return to bug 80732