[4953] in Athena Bugs

home help back first fref pref prev next nref lref last post

getty tty name printing (from comp.bugs.4bsd)

daemon@ATHENA.MIT.EDU (Jonathan I. Kamens)
Sun May 20 13:05:51 1990

Date: Sun, 20 May 90 13:05:37 -0400
From: Jonathan I. Kamens <jik@pit-manager.MIT.EDU>
To: bugs@ATHENA.MIT.EDU
In article <5817@videovax.tv.tek.com>, bart@videovax.tv.tek.com (Bart
Massey) writes:
|> Program: /usr/src/etc/getty
|> Version: 4.3BSD "Tahoe"
|> Machine: VAX 11/750
|> 
|> It seems to me that the call to ttyname() near line 445 in putf() in
|> getty/main.c is both expensive and incorrect.  I think the proper way to
|> expand "%t" is using the tty name already determined and stored in
the global
|> "ttyn".  The reason I noticed it is that some of our ttys are symlinked, and
|> getty was printing the name of the tty, rather than the name of the link,
|> the latter having been passed as an argument to getty.  Also note that
|> ttyname() requires a scan of /dev/, and is thus pretty costly, even
|> considering the caches.
|> 
|> Is there some security reason that I shouldn't do the following?
|> 
|> 					Bart Massey
|> 					..tektronix!videovax.tv.tek.com!bart
|> 					..tektronix!reed.bitnet!bart
|> 
|> *** /tmp/,RCSt1022702	Fri May 18 17:24:19 1990
|> --- main.c	Fri May 18 17:24:02 1990
|> ***************
|> *** 429,438 ****
|>   putf(cp)
|>   	register char *cp;
|>   {
|> ! 	char *ttyn, *slash;
|>   	char datebuffer[60];
|>   	extern char editedhost[];
|> ! 	extern char *ttyname(), *rindex();
|>   
|>   	while (*cp) {
|>   		if (*cp != '%') {
|> --- 429,438 ----
|>   putf(cp)
|>   	register char *cp;
|>   {
|> ! 	char *slash;
|>   	char datebuffer[60];
|>   	extern char editedhost[];
|> ! 	extern char *rindex();
|>   
|>   	while (*cp) {
|>   		if (*cp != '%') {
|> ***************
|> *** 442,448 ****
|>   		switch (*++cp) {
|>   
|>   		case 't':
|> - 			ttyn = ttyname(0);
|>   			slash = rindex(ttyn, '/');
|>   			if (slash == (char *) 0)
|>   				puts(ttyn);
|> --- 442,447 ----

Jonathan Kamens			              USnail:
MIT Project Athena				11 Ashford Terrace
jik@Athena.MIT.EDU				Allston, MA  02134
Office: 617-253-8495			      Home: 617-782-0710

home help back first fref pref prev next nref lref last post