Subject: bin/1792: More telnetd configurability
To: None <gnats-bugs@gnats.netbsd.org>
From: Thorsten Lockert <tholo@SigmaSoft.COM>
List: netbsd-bugs
Date: 11/25/1995 21:04:16
>Number:         1792
>Category:       bin
>Synopsis:       telnetd cannot use a different login program or banner easily
>Confidential:   no
>Severity:       non-critical
>Priority:       high
>Responsible:    bin-bug-people (Utility Bug People)
>State:          open
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Sun Nov 26 00:20:01 1995
>Last-Modified:
>Originator:     Thorsten Lockert
>Organization:
SigmaSoft, Th. Lockert
>Release:        1.1ALPHA
>Environment:
System: NetBSD gandalf.sigmasoft.com 1.1 NetBSD 1.1 (GANDALF) #0: Sat Nov 25 00:32:13 PST 1995 tholo@gandalf.sigmasoft.com:/usr/src/sys/arch/i386/compile/GANDALF i386


>Description:
	It is not possible to easily specify a different banner or login
	program on incoming telnet connections.

>How-To-Repeat:
	Try to make telnetd use a different program on login.

>Fix:
	It would be nice if it were possible to specify another entry
	from /etc/gettytab than "default" for use by telnetd(8).

	The following patch implements just that functionality:

diff -u src/libexec/telnetd/sys_term.c.old sys/libexec/telnetd/sys_term.c
--- src/libexec/telnetd/sys_term.c.old	Fri Oct 13 18:06:23 1995
+++ src/libexec/telnetd/sys_term.c	Sat Nov 25 20:55:36 1995
@@ -1499,6 +1499,8 @@
 	register char **argv;
 	char **addarg();
 	extern char *getenv();
+	extern char *getstr();
+	char *loginprog;
 #ifdef	UTMPX
 	register int pid = getpid();
 	struct utmpx utmpx;
@@ -1693,10 +1695,13 @@
 		close(pty);
 #endif
 	closelog();
-	execv(_PATH_LOGIN, argv);
+	loginprog = getstr("lo");
+	if (loginprog == NULL)
+	    	loginprog = _PATH_LOGIN;
+	execv(loginprog, argv);
 
-	syslog(LOG_ERR, "%s: %m\n", _PATH_LOGIN);
-	fatalperror(net, _PATH_LOGIN);
+	syslog(LOG_ERR, "%s: %m\n", loginprog);
+	fatalperror(net, loginprog);
 	/*NOTREACHED*/
 }
 
diff -u src/libexec/telnetd/telnetd.8.old src/libexec/telnetd/telnetd.8
--- src/libexec/telnetd/telnetd.8.old	Fri Oct 13 18:06:24 1995
+++ src/libexec/telnetd/telnetd.8	Sat Nov 25 20:54:25 1995
@@ -49,6 +49,7 @@
 .Op Fl X Ar authtype
 .Op Fl a Ar authmode
 .Op Fl edebug
+.Op Fl g Ar gettyent
 .Op Fl r Ns Ar lowpty-highpty
 .Op Fl u Ar len
 .Op Fl debug Op Ar port
@@ -188,6 +189,12 @@
 has been compiled with support for data encryption, then the
 .Fl edebug
 option may be used to enable encryption debugging code.
+.It Fl g Ar gettyent
+Specifies which entry from
+.Pa /etc/gettytab
+should be used to get banner strings, login program and
+other information.  The default entry is
+.Dv default.
 .It Fl h
 Disables the printing of host-specific information before
 login has been completed.
diff -u /usr/src/libexec/telnetd/telnetd.c.old src/libexec/telnetd/telnetd.c
--- src/libexec/telnetd/telnetd.c.old	Fri Oct 13 18:06:25 1995
+++ src/libexec/telnetd/telnetd.c	Sat Nov 25 20:47:52 1995
@@ -124,6 +124,7 @@
 
 int debug = 0;
 int keepalive = 1;
+char *gettyname = "default";
 char *progname;
 
 extern void usage P((void));
@@ -134,7 +135,7 @@
  * passed off to getopt().
  */
 char valid_opts[] = {
-	'd', ':', 'h', 'k', 'n', 'S', ':', 'u', ':', 'U',
+	'd', ':', 'g', ':', 'h', 'k', 'n', 'S', ':', 'u', ':', 'U',
 #ifdef	AUTHENTICATION
 	'a', ':', 'X', ':',
 #endif
@@ -253,6 +254,9 @@
 			break;
 #endif /* DIAGNOSTICS */
 
+		case 'g':
+			gettyname = optarg;
+			break;
 
 		case 'h':
 			hostinfo = 0;
@@ -1086,7 +1090,7 @@
 		hostinfo = 0;
 #endif
 
-	if (getent(defent, "default") == 1) {
+	if (getent(defent, gettyname) == 1) {
 		char *getstr();
 		char *cp=defstrs;
 
>Audit-Trail:
>Unformatted: