Bug 148915 - [patch] fix telnetd(8) if and im options to behave like getty
Summary: [patch] fix telnetd(8) if and im options to behave like getty
Status: Open
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: 8.1-PRERELEASE
Hardware: Any Any
: Normal Affects Only Me
Assignee: freebsd-bugs mailing list
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-07-25 02:50 UTC by Dan Ponte
Modified: 2018-01-03 05:16 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Dan Ponte 2010-07-25 02:50:01 UTC
	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).

Fix: Apply the following patch to src/contrib/telnet/telnetd/telnetd.c.



Thanks.
-Dan--hVfq98OleKzYfHvLQiilyG1XY6lNOQcfnrzVWKZZVDQ2L4vE
Content-Type: text/plain; name="telnetd.c.diff"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename="telnetd.c.diff"

--- 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);
Comment 1 Eitan Adler freebsd_committer freebsd_triage 2017-12-31 08:00:40 UTC
For bugs matching the following criteria:

Status: In Progress Changed: (is less than) 2014-06-01

Reset to default assignee and clear in-progress tags.

Mail being skipped