summaryrefslogtreecommitdiff
path: root/libexec/telnetd
diff options
context:
space:
mode:
authorTodd C. Miller <millert@cvs.openbsd.org>2001-06-29 21:30:56 +0000
committerTodd C. Miller <millert@cvs.openbsd.org>2001-06-29 21:30:56 +0000
commitea3bfaf6702beee76da363cc49a89b0f791d2b72 (patch)
tree9b075050534252d0012dfd07954354deae8e6963 /libexec/telnetd
parent135ff5877badf7685592cfb68903fb765c3e7c2a (diff)
Add back gettytab reading but use cget* instead of the obsolescent gtget*
Diffstat (limited to 'libexec/telnetd')
-rw-r--r--libexec/telnetd/ext.h2
-rw-r--r--libexec/telnetd/sys_term.c11
-rw-r--r--libexec/telnetd/telnetd.812
-rw-r--r--libexec/telnetd/telnetd.c31
4 files changed, 50 insertions, 6 deletions
diff --git a/libexec/telnetd/ext.h b/libexec/telnetd/ext.h
index 8454a7a1c41..dba7049e543 100644
--- a/libexec/telnetd/ext.h
+++ b/libexec/telnetd/ext.h
@@ -55,7 +55,7 @@ extern int require_otp;
#ifdef AUTHENTICATION
extern int auth_level;
#endif
-extern const char *new_login;
+extern char *new_login;
extern slcfun slctab[NSLC + 1]; /* slc mapping table */
diff --git a/libexec/telnetd/sys_term.c b/libexec/telnetd/sys_term.c
index 67a0a5e7dbd..0b8d19a0dd3 100644
--- a/libexec/telnetd/sys_term.c
+++ b/libexec/telnetd/sys_term.c
@@ -179,7 +179,7 @@ char wtmpf[] = "/etc/wtmp";
int really_stream = 0;
# endif
- const char *new_login = _PATH_LOGIN;
+ char *new_login = NULL;
/*
* init_termbuf()
@@ -1273,6 +1273,8 @@ start_login(const char *host, int autologin, char *name)
struct arg_val argv;
char *user;
int save_errno;
+ char *buf;
+ extern char *gettytab[2], *gettyent;
#ifdef HAVE_UTMPX_H
int pid = getpid();
@@ -1347,6 +1349,13 @@ start_login(const char *host, int autologin, char *name)
addarg(&argv, "--");
addarg(&argv, strdup(user));
}
+ if (new_login == NULL && cgetent(&buf, gettytab, gettyent) >= 0) {
+ cgetstr(buf, "lo", &new_login);
+ cgetclose();
+ }
+ if (new_login == NULL)
+ new_login = _PATH_LOGIN;
+
if (getenv("USER")) {
/*
* Assume that login will set the USER variable
diff --git a/libexec/telnetd/telnetd.8 b/libexec/telnetd/telnetd.8
index ce47f4c1ee8..4cce01eacdd 100644
--- a/libexec/telnetd/telnetd.8
+++ b/libexec/telnetd/telnetd.8
@@ -33,7 +33,7 @@
.\"
.Dd June 1, 1994
.Dt TELNETD 8
-.Os BSD 4.2
+.Os
.Sh NAME
.Nm telnetd
.Nd DARPA
@@ -46,6 +46,7 @@ protocol server
.Op Fl S Ar tos
.Op Fl X Ar authtype
.Op Fl a Ar authmode
+.Op Fl g Ar gettyent
.Op Fl r Ns Ar lowpty-highpty
.Op Fl u Ar len
.Op Fl debug
@@ -184,6 +185,15 @@ have been idle for some period of time to determine
if the client is still there, so that idle connections
from machines that have crashed or can no longer
be reached may be cleaned up.
+.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
+.Dq default.
+.It Fl h
+Disables the printing of host-specific information before
+login has been completed.
.It Fl r Ar lowpty-highpty
This option is only enabled when
.Nm telnetd
diff --git a/libexec/telnetd/telnetd.c b/libexec/telnetd/telnetd.c
index 35f831d1152..daae16b4415 100644
--- a/libexec/telnetd/telnetd.c
+++ b/libexec/telnetd/telnetd.c
@@ -122,6 +122,8 @@ int lowpty = 0, highpty; /* low, high pty numbers */
int debug = 0;
int keepalive = 1;
char *progname;
+char *gettyent = "default";
+char *gettytab[2] = { "/etc/gettytab", NULL };
static void usage (void);
@@ -130,7 +132,7 @@ static void usage (void);
* that only the actual options that we support will be
* passed off to getopt().
*/
-char valid_opts[] = "Bd:hklnS:u:UL:y"
+char valid_opts[] = "Bd:g:hklnS:u:UL:y"
#ifdef AUTHENTICATION
"a:X:z"
#endif
@@ -243,6 +245,10 @@ main(int argc, char **argv)
#endif /* DIAGNOSTICS */
+ case 'g':
+ gettyent = optarg;
+ break;
+
case 'h':
hostinfo = 0;
break;
@@ -791,6 +797,7 @@ my_telnet(int f, int p, const char *host, const char *utmp_host,
int on = 1;
char *he;
char *IM;
+ char *buf;
int nfd;
int startslave_called = 0;
time_t timeout;
@@ -943,11 +950,29 @@ my_telnet(int f, int p, const char *host, const char *utmp_host,
if (getenv("USER"))
hostinfo = 0;
- IM = DEFAULT_IM;
- he = 0;
+ if (cgetent(&buf, gettytab, gettyent) >= 0) {
+ char *HN;
+
+ if (cgetstr(buf, "he", &he) <= 0)
+ he = NULL;
+ if (cgetstr(buf, "im", &IM) <= 0)
+ IM = "";
+ if (cgetstr(buf, "hn", &HN) > 0) {
+ strlcpy(host_name, HN, sizeof host_name);
+ free(HN);
+ }
+ cgetclose();
+ } else {
+ IM = DEFAULT_IM;
+ he = NULL;
+ }
edithost(he, host_name);
+ if (he)
+ free(he);
if (hostinfo && *IM)
putf(IM, ptyibuf2);
+ if (*IM)
+ free(IM);
if (pcc)
strncat(ptyibuf2, ptyip, pcc+1);