Date: Sat, 7 May 2005 13:22:07 GMT From: Rostislav Krasny <rosti.bsd@gmail.com> To: freebsd-gnats-submit@FreeBSD.org Subject: bin/80732: [PATCH]: getty(8) and telnetd(8) ignore the 'if' option of gettytab(5) and don't print initial message from a file (by default /etc/issue) before the login prompt Message-ID: <200505071322.j47DM7DA062105@www.freebsd.org> Resent-Message-ID: <200505071330.j47DU2xq000858@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
>Number: 80732
>Category: bin
>Synopsis: [PATCH]: getty(8) and telnetd(8) ignore the 'if' option of gettytab(5) and don't print initial message from a file (by default /etc/issue) before the login prompt
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: freebsd-bugs
>State: open
>Quarter:
>Keywords:
>Date-Required:
>Class: sw-bug
>Submitter-Id: current-users
>Arrival-Date: Sat May 07 13:30:02 GMT 2005
>Closed-Date:
>Last-Modified:
>Originator: Rostislav Krasny
>Release: 5.4-RC4
>Organization:
>Environment:
FreeBSD mercury 5.4-RC4 FreeBSD 5.4-RC4 #0: Sun May 1 23:22:09 IDT 2005 root@mercury:/usr/obj/usr/src/sys/MYKERNEL i386
>Description:
By default /etc/gettytab have following lines:
default:\
:cb:ce:ck:lc:fd#1000:im=\r\n%s/%m (%h) (%t)\r\n\r\n:sp#1200:\
:if=/etc/issue:
The 'if' option specifies a text file that their contents will be processed like contents of a 'im' gettytab(5) option. Both getty(8) and telnetd(8) ignore the 'if' option, the first because of a bug in the code and the second because it is not implemented. However, the telnetd(8) manual page states that it is implemented.
>How-To-Repeat:
Just create the /etc/issue file with some text in it and see how telnetd(8) and getty(8) work. You don't have to reboot when you test getty(8). Instead you can press [Ctrl]+[D] to restart getty(8) or [Enter] to just make it reprint the full login prompt. Also, you might need to enable inetd(8) and eding an /etc/inetd.conf to make telnetd working.
>Fix:
--- main.c.orig Sat May 7 03:52:29 2005
+++ /usr/src/libexec/getty/main.c Sat May 7 12:48:11 2005
@@ -184,7 +184,7 @@
main(int argc, char *argv[])
{
extern char **environ;
- int first_sleep = 1, first_time = 1;
+ int first_sleep = 1;
struct rlimit limit;
int rval;
@@ -312,24 +312,22 @@
putpad(CL);
edithost(HE);
- /* if this is the first time through this, and an
- issue file has been given, then send it */
- if (first_time && IF) {
- int fd;
+ if (!(PL && PP)) {
+ int fd = -1;
- if ((fd = open(IF, O_RDONLY)) != -1) {
- char * cp;
-
- while ((cp = getline(fd)) != NULL) {
- putf(cp);
+ if (IF) {
+ if ((fd = open(IF, O_RDONLY)) != -1) {
+ char * cp;
+
+ while ((cp = getline(fd)) != NULL)
+ putf(cp);
+ close(fd);
}
- close(fd);
}
+ if (fd == -1 && IM && *IM)
+ putf(IM);
}
- first_time = 0;
- if (IM && *IM && !(PL && PP))
- putf(IM);
if (setjmp(timeout)) {
cfsetispeed(&tmode, B0);
cfsetospeed(&tmode, B0);
--- telnetd.c.orig Sat May 7 01:57:16 2005
+++ /usr/src/contrib/telnet/telnetd/telnetd.c Sat May 7 15:08:11 2005
@@ -740,6 +740,7 @@
char *HE;
char *HN;
char *IM;
+ char *IF;
int nfd;
/*
@@ -900,18 +901,36 @@
*/
if (getent(defent, "default") == 1) {
- char *cp=defstrs;
+ char *cp = defstrs;
HE = Getstr("he", &cp);
HN = Getstr("hn", &cp);
- IM = Getstr("im", &cp);
- if (HN && *HN)
+ IF = Getstr("if", &cp);
+ if (HN != NULL && *HN != 0)
(void) strlcpy(host_name, HN, sizeof(host_name));
- if (IM == 0)
- IM = strdup("");
+ if (IF != NULL) {
+ int if_fd;
+
+ if ((if_fd = open(IF, O_RDONLY)) != -1) {
+ struct stat if_fst;
+
+ fstat(if_fd, &if_fst);
+ IM = malloc(if_fst.st_size + 1);
+ read(if_fd, IM, if_fst.st_size);
+ IM[if_fst.st_size] = 0;
+ close(if_fd);
+ } else {
+ IF = NULL;
+ }
+ }
+ if (IF == NULL) {
+ IM = Getstr("im", &cp);
+ if (IM == NULL)
+ IM = strdup("");
+ }
} else {
IM = strdup(DEFAULT_IM);
- HE = 0;
+ HE = NULL;
}
edithost(HE, host_name);
if (hostinfo && *IM)
>Release-Note:
>Audit-Trail:
>Unformatted:
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200505071322.j47DM7DA062105>
