[3152] in Kerberos-V5-bugs
telnet/789: Support INIT stanza in telnet config file; canonicalize DISPLAY setting
daemon@ATHENA.MIT.EDU (Jonathan Kamens)
Tue Nov 23 16:57:08 1999
Resent-From: gnats@rt-11.MIT.EDU (GNATS Management)
Resent-To: hartmans@MIT.EDU
Resent-Reply-To: krb5-bugs@MIT.EDU, jik@kamens.brookline.ma.us
Message-Id: <199911232157.QAA21178@jik2.kamens.brookline.ma.us>
Date: Tue, 23 Nov 1999 16:57:16 -0500
From: Jonathan Kamens <jik@kamens.brookline.ma.us>
Reply-To: jik@kamens.brookline.ma.us
To: krb5-bugs@MIT.EDU
Cc: jik@kamens.brookline.ma.us
>Number: 789
>Category: telnet
>Synopsis: Support INIT stanza in telnet config file; canonicalize DISPLAY setting
>Confidential: yes
>Severity: non-critical
>Priority: medium
>Responsible: hartmans
>State: open
>Class: sw-bug
>Submitter-Id: unknown
>Arrival-Date: Tue Nov 23 16:57:00 EST 1999
>Last-Modified:
>Originator: Jonathan Kamens
>Organization:
>Release: krb5-1.1
>Environment:
System: Linux jik2 2.2.12-20 #14 Thu Nov 18 20:57:02 EST 1999 i686 unknown
Architecture: i686
>Description:
The patches below contain two bug fixes and one enhancement
(sorry for bundling them all together, but that's how they are
in my tree and I don't have time to split them up; it
shouldn't be difficult for you to to do if you think it's
necessary):
1) Check the return value of gethostname() when using it to
determine what to send to the remost host as the DISPLAY
environment variable setting.
2) Canonicalize the DISPLAY setting, if possible, so that it
will be correct even when someone uses telnet to connect to a
host in a different domain.
3) Support an INIT stanza in the telnet RC file
>How-To-Repeat:
>Fix:
Index: ./src/appl/telnet/telnet/commands.c
--- commands.c 1999/11/23 19:51:09 1.1.1.1
+++ commands.c 1999/11/23 19:51:47 1.3
@@ -1727,12 +1727,19 @@
char hbuf[256+1];
char *cp2 = strchr((char *)ep->value, ':');
- gethostname(hbuf, 256);
- hbuf[256] = '\0';
- cp = (char *)malloc(strlen(hbuf) + strlen(cp2) + 1);
- sprintf((char *)cp, "%s%s", hbuf, cp2);
- free(ep->value);
- ep->value = (unsigned char *)cp;
+ if (gethostname(hbuf, 256) == 0) {
+ struct hostent *host;
+
+ hbuf[256] = '\0';
+ host = gethostbyname(hbuf);
+ if (host)
+ strncpy(hbuf, host->h_name, sizeof(hbuf));
+ hbuf[256] = '\0';
+ cp = (char *)malloc(strlen(hbuf) + strlen(cp2) + 1);
+ sprintf((char *)cp, "%s%s", hbuf, cp2);
+ free(ep->value);
+ ep->value = (unsigned char *)cp;
+ }
}
/*
* If USER is not defined, but LOGNAME is, then add
@@ -2835,6 +2842,11 @@
return 0;
}
+void init_cmdrc()
+{
+ cmdrc("INIT", "INITIALIZE");
+}
+
static char *rcname = 0;
static char rcbuf[128];
@@ -2907,7 +2919,7 @@
continue;
}
/*
- * This should never happen...
+ * This can happen in the INIT stanza
*/
if (c->needconnect && !connected) {
printf("?Need to be connected first for %s.\r\n", margv[0]);
Index: ./src/appl/telnet/telnet/externs.h
--- externs.h 1999/11/23 19:51:09 1.1.1.1
+++ externs.h 1999/11/23 19:51:47 1.3
@@ -256,6 +256,7 @@
extern void
command P((int, char *, int)),
+ init_cmdrc P((void)),
Dump P((int, unsigned char *, int)),
init_3270 P((void)),
printoption P((char *, int, int)),
Index: ./src/appl/telnet/telnet/main.c
--- main.c 1999/11/23 19:51:09 1.1.1.1
+++ main.c 1999/11/23 19:51:47 1.3
@@ -71,6 +71,8 @@
#if defined(TN3270)
init_3270();
#endif
+
+ init_cmdrc();
}
void
>Audit-Trail:
>Unformatted: