[1837] in Kerberos-V5-bugs
ss-962301 - krlogind and other fixes
daemon@ATHENA.MIT.EDU (Doug Engert)
Fri Mar 15 15:04:45 1996
Date: Fri, 15 Mar 1996 14:04:15 -0600
From: Doug Engert <DEEngert@anl.gov>
To: krb5-bugs@MIT.EDU
I have gotten some of the Kerberos 5 snapshot ss-962301 running on AIX 4.1.4
HPUX 10.0 and Solaris 2.4. This includes the basic clients, krlogin
and krlogind, and have just touched telnet.
Only minimal testing has been done, but without some of these fixes,
the AIX 4.1.4 system would crash! Blinking lights and everything ;-)
I would like to report the following bugs/fixes. A context diff file
is attached:
./src/util/pty/init_slave.c - Change the ifdefs around the tests for
streams. AIX 4.1.4 has streams, but unlike many of the other systems
which also have streams, it automaticly pushed the ldterm, ptem and
tioc stream modules on to the stream. Thus the pushs are not needed.
The ifdef for the sun was moved so only the sun systems would push the
ttcompat module. The HPUX also has streams, and needs the push.
(Based on previous versions, this should also work on the SGI.)
./src/util/pty/open_ctty.c - The test to see if the controlling
terminal is working was moved from this module to the open_slave.c
module after the pty_initialize_slave routine. For the
open("/dev/tty") to work, the stream must be functioning. The HP
failed this test originally.
./src/util/pty/open_slave.c - The return value from pty_open_ctty is
returned, and the test to see that the controlling terminal is working
was added after the call to pty_initialize_slave. The #ifdef
HAVE_REVOKE was moved, so that ptyint_void_association was not called
twice in a row. ptyint_void_association did a setsid(), and it should
only do this once.
./src/util/pty/void_assoc.c - A test was added for TIOCNOTTY. One of
the systems does not have it, and would not compile.
./src/appl/bsd/krlogind.c - The AIX 4.1.4 system would crash somewhere
in login.krb5. Rather then debuging login.krb5, I would rather see the
vendor's login used if possible.
The AIX and HP systems both support "login -f -p", and so ifdefs were
added for USE_LOGIN_F (which was manually added during the configure)
to use the vendor's login. This requires passing the terminal type as
an environment variable, rather then via the input stream, and skipping
a number of changes to the terminal.
Since the init_slave.c issues many of the same termio changes, it was
not clear why they are needed in krlogind. Looks like some additional
cleanup is needed. Also the ISIG is turned off. login.krb5 turns it
back on, but the vendor's logins did not. This area need to be looked
at more closely.
The use of the USE_LOGIN_F still allows the "-L" option to be used
when calling krlogind.
The test for TIOCPKT were also modified, since it was not very
portable. The same test was also added in the middle of the protocol
routine, since the original "#ifdef sun" was not appropriate. If the
TIOCPKT is on, then the protocol routine need to check the first byte
of every read from the slave.
The HP required TIOCTTY to be set if the TIOCPKT was to work. This
test was also added.
A test was added for TIOCGPGRP since one of the systems did not have
it, and would not compile.
./appl/telnet/libtelnet/forward.c - the same code as in the
appl/bsd/forward.c was added to us the process ID as part of the
cache name, rather then the UID. This is implements session based
caches rather then a UID based cache. This is very important what
forwarding a ticket which will be converted to a DCE context. The DCE
code removes the original cache, so it better not be shared.
./appl/telnet/telnetd/Makefile.in - The -DLOGIN_CAP_F was changed to
-ULOGIN_CAP_F. The login on the systems I am working with don't
understand "-F". There should be a better test of this.
./lib/gssapi/mechglue/mglueP.h - When compiling on the HP, NULL was
not defined by any of the include files included by any of the routines
in this directory. So any #ifndef NULL was added.
Douglas E. Engert
Systems Programming
Argonne National Laboratory
9700 South Cass Avenue
Argonne, Illinois 60439
(708) 252-5444
Internet: DEEngert@anl.gov
*** ./appl/bsd/,krlogind.c Fri Jan 19 11:34:14 1996
--- ./appl/bsd/krlogind.c Fri Mar 15 10:31:59 1996
***************
*** 265,270 ****
--- 265,275 ----
#endif /* DO_NOT_USE_K_LOGIN */
#endif /* LOGIN_PROGRAM */
+ #ifdef USE_LOGIN_F
+ #undef LOGIN_PROGRAM
+ #define LOGIN_PROGRAM "/bin/login"
+ #endif
+
char *login_program = LOGIN_PROGRAM;
#define MAXRETRIES 4
***************
*** 617,625 ****
fatal(f, error_message(retval));
exit(1);
}
!
#if defined(POSIX_TERMIOS) && !defined(ultrix)
tcgetattr(t,&new_termio);
new_termio.c_lflag &= ~(ICANON|ECHO|ISIG|IEXTEN);
/* so that login can read the authenticator */
--- 622,636 ----
fatal(f, error_message(retval));
exit(1);
}
!
#if defined(POSIX_TERMIOS) && !defined(ultrix)
+
+ #ifndef USE_LOGIN_F
+ /* The pty_initialize_slave called from pty_open_slave
+ * does some of this as well. If we use the vendors
+ * login, we should not turn off the ISIG! DEE
+ */
tcgetattr(t,&new_termio);
new_termio.c_lflag &= ~(ICANON|ECHO|ISIG|IEXTEN);
/* so that login can read the authenticator */
***************
*** 629,634 ****
--- 640,646 ----
new_termio.c_cc[VMIN] = 1;
new_termio.c_cc[VTIME] = 0;
tcsetattr(t,TCSANOW,&new_termio);
+ #endif /* USE_LOGIN_F */
#else
(void)ioctl(t, TIOCGETP, &b);
b.sg_flags = RAW|ANYP;
***************
*** 708,713 ****
--- 720,743 ----
}
#endif
+ #ifdef USE_LOGIN_F
+ /* use the vendors login, which has -p and -f. Tested on
+ * AIX 4.1.4 and HPUX 10
+ */
+ {
+ char *cp;
+ if ((cp = strchr(term,'/')))
+ *cp = '\0';
+ setenv("TERM",term, 1);
+ }
+
+ if (passwd_req)
+ execl(login_program, "login", "-p", "-h", rhost_name,
+ lusername, 0);
+ else
+ execl(login_program, "login", "-p", "-h", rhost_name,
+ "-f", lusername, 0);
+ #else
#ifdef DO_NOT_USE_K_LOGIN
execl(login_program, "login", "-r", rhost_name, 0);
#else
***************
*** 716,721 ****
--- 746,752 ----
else
execl(login_program, "login", "-h", rhost_name, "-e", lusername, 0);
#endif
+ #endif /* USE_LOGIN_F */
fatalperror(2, login_program);
/*NOTREACHED*/
***************
*** 727,733 ****
** turning off echo on the slave side ...
** The master blocks here until it reads a byte.
*/
!
(void) close(syncpipe[1]);
if (read(syncpipe[0], &c, 1) != 1) {
/*
--- 758,764 ----
** turning off echo on the slave side ...
** The master blocks here until it reads a byte.
*/
!
(void) close(syncpipe[1]);
if (read(syncpipe[0], &c, 1) != 1) {
/*
***************
*** 738,744 ****
}
close(syncpipe[0]);
!
#if defined(KERBEROS)
if (do_encrypt) {
if (((*des_write)(f, SECURE_MESSAGE, sizeof(SECURE_MESSAGE))) < 0){
--- 769,775 ----
}
close(syncpipe[0]);
!
#if defined(KERBEROS)
if (do_encrypt) {
if (((*des_write)(f, SECURE_MESSAGE, sizeof(SECURE_MESSAGE))) < 0){
***************
*** 759,767 ****
(void) fcntl(p,F_SETFL,fcntl(p,F_GETFL,0) | O_NDELAY);
/*** XXX -- make this portable ***/
! #if defined(TIOCPKT) && !defined(__svr4__) || defined(solaris20)
! ioctl(p, TIOCPKT, &on);
#endif
#ifdef POSIX_SIGNALS
sa.sa_handler = SIG_IGN;
--- 790,805 ----
(void) fcntl(p,F_SETFL,fcntl(p,F_GETFL,0) | O_NDELAY);
/*** XXX -- make this portable ***/
! /* #if defined(TIOCPKT) && !defined(__svr4__) || defined(solaris20) */
! /* not clear about the __svr4__ comment above. */
! /* turn on the packet mode, see the ifdef in protocol about this */
! #ifdef TIOCPKT
! #ifdef TIOCTTY
! /* HP need TIOCTTY set for TIOCPKT to work */
! ioctl(p, TIOCTTY, &on);
#endif
+ ioctl(p, TIOCPKT, &on);
+ #endif TIOCPKT
#ifdef POSIX_SIGNALS
sa.sa_handler = SIG_IGN;
***************
*** 770,781 ****
--- 808,824 ----
signal(SIGTSTP, SIG_IGN);
#endif
+ #if 0
+ /* this should have been done in the open_slave, not here */
#ifdef hpux
setpgrp2(0, 0);
#else
setpgrp(0, 0);
#endif
+ #endif
+ #ifndef USE_LOGIN_F
+ /* login -p -f finds TERM in environment */
#ifdef DO_NOT_USE_K_LOGIN
/* Pass down rusername and lusername to login. */
(void) write(p, rusername, strlen(rusername) +1);
***************
*** 789,794 ****
--- 832,839 ----
sprintf(buferror,"Cannot write slave pty %s ",line);
fatalperror(f,buferror);
}
+ #endif /* USE_LOGIN_F */
+
protocol(f, p);
signal(SIGCHLD, SIG_IGN);
cleanup();
***************
*** 827,834 ****
--- 872,881 ----
w.ws_xpixel = ntohs(w.ws_xpixel);
w.ws_ypixel = ntohs(w.ws_ypixel);
(void)ioctl(pty, TIOCSWINSZ, &w);
+ #ifdef TIOCGPGRP
if (ioctl(pty, TIOCGPGRP, &pgrp) >= 0)
(void) killpg(pgrp, SIGWINCH);
+ #endif /* TIOCGPGRP */
#endif
return (4+sizeof (w));
}
***************
*** 944,952 ****
pcc = 0;
else if (pcc <= 0)
break;
else if (pibuf[0] == 0)
pbp++, pcc--;
! #ifndef sun
else {
if (pkcontrol(pibuf[0])) {
pibuf[0] |= oobdata[0];
--- 991,1005 ----
pcc = 0;
else if (pcc <= 0)
break;
+ /* this section should only be included if TIOCKPT is in effect.
+ * When in packet mode, a leading byte has the control information
+ * See the TIOCKPT comments above */
+
+ #ifdef TIOCKPT
else if (pibuf[0] == 0)
pbp++, pcc--;
!
! /* #if !defined(sun) && !defined(hpux) */
else {
if (pkcontrol(pibuf[0])) {
pibuf[0] |= oobdata[0];
***************
*** 954,960 ****
}
pcc = 0;
}
! #endif
}
if (FD_ISSET(f, &obits) && pcc > 0) {
cc = (*des_write)(f, pbp, pcc);
--- 1007,1013 ----
}
pcc = 0;
}
! #endif /* TIOCKPT */
}
if (FD_ISSET(f, &obits) && pcc > 0) {
cc = (*des_write)(f, pbp, pcc);
***************
*** 1091,1096 ****
--- 1144,1155 ----
}
#endif
}
+ #ifdef USE_LOGIN_F
+ /* can't allow lusername to look like a parameter to login */
+ if (lusername[0] == '-')
+ fatal(netf, "Invalid local user name");
+ #endif
+
/* The kerberos authenticated request must pass ruserok also
if asked for. */
*** ./appl/telnet/libtelnet/,forward.c Tue Jan 9 21:35:32 1996
--- ./appl/telnet/libtelnet/forward.c Tue Mar 12 16:07:57 1996
***************
*** 53,65 ****
if (retval = krb5_rd_cred(context, auth_context, inbuf, &creds, NULL))
return(retval);
! if (*line) {
! /* code from appl/bsd/login.c since it will do the same */
! sprintf(ccname, "FILE:/tmp/krb5cc_%s", strrchr(line, '/')+1);
! } else {
! /* since default will be based on uid and we haven't changed yet */
! sprintf(ccname, "FILE:/tmp/krb5cc_%d", pwd->pw_uid);
! }
setenv(KRB5_ENV_CCNAME, ccname, 1);
if (retval = krb5_cc_resolve(context, ccname, &ccache))
--- 53,65 ----
if (retval = krb5_rd_cred(context, auth_context, inbuf, &creds, NULL))
return(retval);
! /* Set the KRB5CCNAME ENV variable to keep sessions
! * seperate. Use the process id of this process which is
! * the rlogind or rshd. Set the environment variable as well.
! */
!
! sprintf(ccname, "FILE:/tmp/krb5cc_p%d", getpid());
!
setenv(KRB5_ENV_CCNAME, ccname, 1);
if (retval = krb5_cc_resolve(context, ccname, &ccache))
*** ./appl/telnet/telnetd/,Makefile.in Mon Aug 7 09:20:52 1995
--- ./appl/telnet/telnetd/Makefile.in Wed Mar 13 07:21:13 1996
***************
*** 22,28 ****
LOCAL_LIBRARIES=-lpty
DEPLOCAL_LIBRARIES=$(TOPLIBD)/../util/pty/libpty.a
! AUTH_DEF=-DAUTHENTICATION -DKRB5 -DFORWARD -UNO_LOGIN_F -DLOGIN_CAP_F -DLOGIN_PROGRAM=KRB5_PATH_LOGIN
OTHERDEFS=-DKLUDGELINEMODE -DDIAGNOSTICS -DENV_HACK -DOLD_ENVIRON
LOCALINCLUDES=-I.. -I$(srcdir)/..
CFLAGS = $(CCOPTS) $(AUTH_DEF) $(OTHERDEFS) $(DEFS) $(LOCALINCLUDES)
--- 22,28 ----
LOCAL_LIBRARIES=-lpty
DEPLOCAL_LIBRARIES=$(TOPLIBD)/../util/pty/libpty.a
! AUTH_DEF=-DAUTHENTICATION -DKRB5 -DFORWARD -UNO_LOGIN_F -ULOGIN_CAP_F -DLOGIN_PROGRAM=KRB5_PATH_LOGIN
OTHERDEFS=-DKLUDGELINEMODE -DDIAGNOSTICS -DENV_HACK -DOLD_ENVIRON
LOCALINCLUDES=-I.. -I$(srcdir)/..
CFLAGS = $(CCOPTS) $(AUTH_DEF) $(OTHERDEFS) $(DEFS) $(LOCALINCLUDES)
*** ./lib/gssapi/mechglue/,mglueP.h Tue Jan 23 02:14:23 1996
--- ./lib/gssapi/mechglue/mglueP.h Wed Mar 13 06:36:26 1996
***************
*** 12,17 ****
--- 12,21 ----
#include "mechglue.h"
#include <sys/types.h>
+ #ifndef NULL
+ #define NULL 0
+ #endif
+
/*
* Array of context IDs typed by mechanism OID
*/
*** ./util/pty/,void_assoc.c Fri Jan 19 11:37:59 1996
--- ./util/pty/void_assoc.c Mon Mar 11 14:43:42 1996
***************
*** 28,37 ****
--- 28,39 ----
(void) setsid();
#endif
+ #ifdef TIOCNOTTY
/* Void tty association first */
if ((con_fd = open("/dev/tty", O_RDWR)) >= 0) {
ioctl(con_fd, TIOCNOTTY, 0);
close(con_fd);
}
+ #endif
return 0;
}
*** ./util/pty/,open_slave.c Fri Jan 19 11:37:58 1996
--- ./util/pty/open_slave.c Fri Mar 15 06:34:50 1996
***************
*** 26,31 ****
--- 26,32 ----
const char *slave;
int *fd;
{
+ int testfd;
int vfd;
long retval;
#ifdef POSIX_SIGNALS
***************
*** 65,84 ****
(void) close(vfd);
#endif
if ( (retval = ptyint_void_association()) != 0)
return retval;
- #ifdef HAVE_REVOKE
if (revoke (slave) < 0 ) {
return PTY_OPEN_SLAVE_REVOKEFAIL;
}
#endif /*HAVE_REVOKE*/
/* Open the pty for real. */
! if (( retval = pty_open_ctty ( slave, fd)) != 0 ) {
! return PTY_OPEN_SLAVE_OPENFAIL;
! }
! return pty_initialize_slave (*fd);
}
--- 66,100 ----
(void) close(vfd);
#endif
+ #ifdef HAVE_REVOKE
+ /* moved ifdef HAVE_REVOKE, since pty_open_ctty calls
+ * ptyint_void_association as first thing so only do once
+ */
if ( (retval = ptyint_void_association()) != 0)
return retval;
if (revoke (slave) < 0 ) {
return PTY_OPEN_SLAVE_REVOKEFAIL;
}
#endif /*HAVE_REVOKE*/
/* Open the pty for real. */
!
! if (( retval = pty_open_ctty ( slave, fd)) != 0 )
! return retval;
!
! if ((retval = pty_initialize_slave (*fd)) != 0)
! return retval;
!
! testfd = open("/dev/tty", O_RDWR|O_NDELAY);
! if ( testfd < 0 )
! {
! close(*fd);
! *fd = -1;
! return PTY_OPEN_SLAVE_NOCTTY;
! }
! close(testfd);
! return 0;
}
*** ./util/pty/,open_ctty.c Fri Jan 19 11:37:57 1996
--- ./util/pty/open_ctty.c Fri Mar 15 06:28:03 1996
***************
*** 62,67 ****
--- 62,71 ----
ioctl(*fd, TIOCSCTTY, 0); /* Don't check return.*/
#endif /* TIOCSTTY */
+ #if 0
+ /* should wait till all of the stream stuff is done before testing
+ * if this is a terminal (testing DEE)
+ */
testfd = open("/dev/tty", O_RDWR|O_NDELAY);
if ( testfd < 0 )
{
***************
*** 70,74 ****
--- 74,79 ----
return PTY_OPEN_SLAVE_NOCTTY;
}
close(testfd);
+ #endif
return 0;
}
*** ./util/pty/,init_slave.c Fri Aug 11 15:13:59 1995
--- ./util/pty/init_slave.c Fri Mar 15 06:15:59 1996
***************
*** 37,42 ****
--- 37,44 ----
#endif
+ #if !defined(_AIX)
+ /* AIX 4.1.4 automaticly pushes the correct stream modules */
#ifdef HAVE_STREAMS
#ifdef HAVE_LINE_PUSH
while (ioctl (fd, I_POP, 0) == 0); /*Clear out any old lined's*/
***************
*** 47,63 ****
return PTY_OPEN_SLAVE_LINE_PUSHFAIL;
}
#else /*No line_push */
- #ifdef sun
if (ioctl(fd, I_PUSH, "ptem") < 0)
return PTY_OPEN_SLAVE_PUSH_FAIL;
if (ioctl(fd, I_PUSH, "ldterm") < 0)
return PTY_OPEN_SLAVE_PUSH_FAIL;
if (ioctl(fd, I_PUSH, "ttcompat") < 0)
return PTY_OPEN_SLAVE_PUSH_FAIL;
#endif /*SUN*/
#endif /*LINE_PUSH*/
#endif /*HAVE_STREAMS*/
/*
* Under Ultrix 3.0, the pgrp of the slave pty terminal
--- 49,66 ----
return PTY_OPEN_SLAVE_LINE_PUSHFAIL;
}
#else /*No line_push */
if (ioctl(fd, I_PUSH, "ptem") < 0)
return PTY_OPEN_SLAVE_PUSH_FAIL;
if (ioctl(fd, I_PUSH, "ldterm") < 0)
return PTY_OPEN_SLAVE_PUSH_FAIL;
+ #ifdef sun
if (ioctl(fd, I_PUSH, "ttcompat") < 0)
return PTY_OPEN_SLAVE_PUSH_FAIL;
#endif /*SUN*/
#endif /*LINE_PUSH*/
#endif /*HAVE_STREAMS*/
+ #endif /* _AIX */
/*
* Under Ultrix 3.0, the pgrp of the slave pty terminal
- --------------------------------------------------------------