bin/148915: [patch] fix telnetd if and im options to behave like
getty
Dan Ponte
dcp at theamigan.net
Sun Jul 25 01:50:02 UTC 2010
>Number: 148915
>Category: bin
>Synopsis: [patch] fix telnetd if and im options to behave like getty
>Confidential: no
>Severity: non-critical
>Priority: medium
>Responsible: freebsd-bugs
>State: open
>Quarter:
>Keywords:
>Date-Required:
>Class: sw-bug
>Submitter-Id: current-users
>Arrival-Date: Sun Jul 25 01:50:01 UTC 2010
>Closed-Date:
>Last-Modified:
>Originator: Dan Ponte
>Release: FreeBSD 8.1-PRERELEASE amd64
>Organization:
D3ath D3sk Records
>Environment:
System: FreeBSD fez.theamigan.net 8.1-PRERELEASE FreeBSD 8.1-PRERELEASE #2: Wed Jul 14 14:05:35 EDT 2010 root at fez.theamigan.net:/usr/obj/usr/src/sys/FEZ8 amd64
>Description:
This patch fixes telnetd to behave exactly as getty does when
if and im are encountered. If both are encountered, if= outputs before
im=. Otherwise, whichever is set in gettytab is output.
This patch improves upon bin/80732 and bin/23562 to make telnetd's handling
of these options similar to getty's. It also makes sure that %h works inside
the issue file (which requires the putf() to occur after the hostname editing
is complete).
>How-To-Repeat:
>Fix:
Apply the following patch to src/contrib/telnet/telnetd/telnetd.c.
--- telnetd.c.diff begins here ---
--- telnetd.c.orig 2009-08-03 04:13:06.000000000 -0400
+++ telnetd.c 2010-07-24 19:58:11.000000000 -0400
@@ -742,6 +742,8 @@
char *HE;
char *HN;
char *IM;
+ char *IF = NULL;
+ char issbuf[BUFSIZ];
int nfd;
/*
@@ -907,17 +909,47 @@
HE = Getstr("he", &cp);
HN = Getstr("hn", &cp);
IM = Getstr("im", &cp);
+ IF = Getstr("if", &cp);
+
if (HN && *HN)
(void) strlcpy(host_name, HN, sizeof(host_name));
- if (IM == 0)
+ else
+ gethostname(host_name, sizeof(host_name));
+
+ if(IM == NULL)
IM = strdup("");
+
+
} else {
IM = strdup(DEFAULT_IM);
HE = 0;
}
edithost(HE, host_name);
+
+ bzero(issbuf, sizeof(issbuf));
+
+ if (IF != NULL) {
+ int tfd;
+ struct stat tst;
+ char *tbf;
+
+ tfd = open(IF, O_RDONLY);
+ if (tfd == -1) {
+ IF = NULL;
+ } else {
+ fstat(tfd, &tst);
+ tbf = (char*)mmap(NULL, tst.st_size, PROT_READ,
+ 0, tfd, 0);
+ strlcpy(issbuf, tbf, sizeof(issbuf));
+ munmap(tbf, tst.st_size);
+ close(tfd);
+ }
+ }
+
if (hostinfo && *IM)
- putf(IM, ptyibuf2);
+ strlcat(issbuf, IM, sizeof(issbuf));
+
+ putf(issbuf, ptyibuf2);
if (pcc)
(void) strncat(ptyibuf2, ptyip, pcc+1);
--- telnetd.c.diff ends here ---
Thanks.
-Dan
>Release-Note:
>Audit-Trail:
>Unformatted:
More information about the freebsd-bugs
mailing list