[7191] in Athena Bugs
PS/2 kerberos changes
daemon@ATHENA.MIT.EDU (daemon@ATHENA.MIT.EDU)
Tue Feb 26 17:50:16 1991
To: bugs@ATHENA.MIT.EDU
Date: Tue, 26 Feb 91 17:49:55 EST
From: John Carr <jfc@ATHENA.MIT.EDU>
I missed the change for appl/bsd/login.c:
*** login.c~ Tue Feb 19 16:03:01 1991
--- login.c Mon Feb 25 13:01:27 1991
***************
*** 51,57 ****
#include <sys/param.h>
#ifndef VFS
#include <sys/quota.h>
! #endif VFS
#include <sys/stat.h>
#include <sys/time.h>
#include <sys/resource.h>
--- 51,57 ----
#include <sys/param.h>
#ifndef VFS
#include <sys/quota.h>
! #endif
#include <sys/stat.h>
#include <sys/time.h>
#include <sys/resource.h>
***************
*** 86,91 ****
--- 86,104 ----
#endif /* BIND_HACK */
#endif /* KERBEROS */
+ #ifdef POSIX
+ #include <termios.h>
+ #ifdef _AIX
+ #include <termio.h>
+ #endif
+ #endif
+
+ #if defined(POSIX) || defined(_AIX)
+ #include <stdlib.h>
+ #else
+ extern char *malloc();
+ #endif
+
#ifdef UIDGID_T
uid_t getuid();
#define uid_type uid_t
***************
*** 105,113 ****
#define LASTLOG "/usr/adm/lastlog"
#define BSHELL "/bin/sh"
! #ifdef VFS
#define QUOTAWARN "/usr/ucb/quota" /* warn user about quotas */
! #endif VFS
#define UT_HOSTSIZE sizeof(((struct utmp *)0)->ut_host)
#define UT_NAMESIZE sizeof(((struct utmp *)0)->ut_name)
--- 118,126 ----
#define LASTLOG "/usr/adm/lastlog"
#define BSHELL "/bin/sh"
! #ifndef OQUOTA
#define QUOTAWARN "/usr/ucb/quota" /* warn user about quotas */
! #endif
#define UT_HOSTSIZE sizeof(((struct utmp *)0)->ut_host)
#define UT_NAMESIZE sizeof(((struct utmp *)0)->ut_name)
***************
*** 119,126 ****
--- 132,141 ----
int timeout = 300;
struct passwd *pwd;
+
char term[64], *hostname, *username;
+ #ifndef POSIX
struct sgttyb sgttyb;
struct tchars tc = {
CINTR, CQUIT, CSTART, CSTOP, CEOT, CBRK
***************
*** 128,133 ****
--- 143,149 ----
struct ltchars ltc = {
CSUSP, CDSUSP, CRPRNT, CFLUSH, CWERASE, CLNEXT
};
+ #endif
extern int errno;
***************
*** 162,168 ****
}
main(argc, argv)
int argc;
! char **argv;
{
extern int optind;
extern char *optarg, **environ;
--- 178,184 ----
}
main(argc, argv)
int argc;
! register char **argv;
{
extern int optind;
extern char *optarg, **environ;
***************
*** 172,179 ****
int fflag, hflag, pflag, rflag, cnt;
int kflag, Kflag, eflag;
int quietlog, passwd_req, ioctlval;
sigtype timedout();
! char *domain, *salt, *envinit[1], *ttyn, *tty;
char tbuf[MAXPATHLEN + 2];
char *ttyname(), *stypeof(), *crypt(), *getpass();
time_t time();
--- 188,198 ----
int fflag, hflag, pflag, rflag, cnt;
int kflag, Kflag, eflag;
int quietlog, passwd_req, ioctlval;
+ #ifdef POSIX
+ struct termios tc;
+ #endif
sigtype timedout();
! char *domain, *salt, **envinit, *ttyn, *tty;
char tbuf[MAXPATHLEN + 2];
char *ttyname(), *stypeof(), *crypt(), *getpass();
time_t time();
***************
*** 183,193 ****
(void)alarm((u_int)timeout);
(void)signal(SIGQUIT, SIG_IGN);
(void)signal(SIGINT, SIG_IGN);
(void)setpriority(PRIO_PROCESS, 0, 0);
! #ifndef VFS
(void)quota(Q_SETUID, 0, 0, 0);
! #endif VFS
!
/*
* -p is used by getty to tell login not to destroy the environment
* -r is used by rlogind to cause the autologin protocol;
--- 202,215 ----
(void)alarm((u_int)timeout);
(void)signal(SIGQUIT, SIG_IGN);
(void)signal(SIGINT, SIG_IGN);
+ #ifdef _AIX
+ (void)setpriority(PRIO_PROCESS, 0, 20);
+ #else
(void)setpriority(PRIO_PROCESS, 0, 0);
! #endif
! #ifdef OQUOTA
(void)quota(Q_SETUID, 0, 0, 0);
! #endif
/*
* -p is used by getty to tell login not to destroy the environment
* -r is used by rlogind to cause the autologin protocol;
***************
*** 291,304 ****
argv += optind;
if (*argv)
username = *argv;
!
! #if !defined(_IBMR2)
ioctlval = 0;
(void)ioctl(0, TIOCLSET, (char *)&ioctlval);
(void)ioctl(0, TIOCNXCL, (char *)0);
(void)fcntl(0, F_SETFL, ioctlval);
#endif
(void)ioctl(0, TIOCGETP, (char *)&sgttyb);
/*
* If talking to an rlogin process, propagate the terminal type and
--- 313,329 ----
argv += optind;
if (*argv)
username = *argv;
! #if !defined(_AIX)
ioctlval = 0;
(void)ioctl(0, TIOCLSET, (char *)&ioctlval);
(void)ioctl(0, TIOCNXCL, (char *)0);
(void)fcntl(0, F_SETFL, ioctlval);
#endif
+ #ifdef POSIX
+ tcgetattr(0, &tc);
+ #else
(void)ioctl(0, TIOCGETP, (char *)&sgttyb);
+ #endif
/*
* If talking to an rlogin process, propagate the terminal type and
***************
*** 306,314 ****
*/
#ifdef KERBEROS
if (eflag)
! getstr(term, sizeof(term), "Terminal type");
#endif
if (rflag || kflag || Kflag || eflag)
doremoteterm(&sgttyb);
sgttyb.sg_erase = CERASE;
sgttyb.sg_kill = CKILL;
--- 331,346 ----
*/
#ifdef KERBEROS
if (eflag)
! getstr(term, sizeof(term), "Terminal type");
#endif
+ #ifdef POSIX
if (rflag || kflag || Kflag || eflag)
+ doremoteterm(&tc);
+ tc.c_cc[VERASE] = CERASE;
+ tc.c_cc[VKILL] = CKILL;
+ tcsetattr(0, TCSANOW, &tc);
+ #else
+ if (rflag || kflag || Kflag || eflag)
doremoteterm(&sgttyb);
sgttyb.sg_erase = CERASE;
sgttyb.sg_kill = CKILL;
***************
*** 315,320 ****
--- 347,353 ----
(void)ioctl(0, TIOCSLTC, (char *)<c);
(void)ioctl(0, TIOCSETC, (char *)&tc);
(void)ioctl(0, TIOCSETP, (char *)&sgttyb);
+ #endif
for (cnt = getdtablesize(); cnt > 2; cnt--)
(void) close(cnt);
***************
*** 386,395 ****
--- 419,436 ----
kpass_ok = 0;
lpass_ok = 0;
+ #ifdef _AIX
+ (void) setpriority(PRIO_PROCESS, 0, 16);
+ #else
(void) setpriority(PRIO_PROCESS, 0, -4);
+ #endif
if (read_long_pw_string(pp2, sizeof(pp2)-1, "Password: ", 0)) {
/* reading password failed... */
+ #ifdef _AIX
+ (void) setpriority(PRIO_PROCESS, 0, 16);
+ #else
(void) setpriority(PRIO_PROCESS, 0, 0);
+ #endif
goto bad_login;
}
if (!pwd) /* avoid doing useless work */
***************
*** 430,436 ****
--- 471,481 ----
realm,
DEFAULT_TKT_LIFE, pp2);
bzero (pp2, sizeof(pp2));
+ #ifdef _AIX
+ (void) setpriority(PRIO_PROCESS, 0, 20);
+ #else
(void) setpriority(PRIO_PROCESS, 0, 0);
+ #endif
switch (krbval) {
case INTK_OK:
kpass_ok = 1;
***************
*** 459,465 ****
--- 504,514 ----
}
} else {
(void) bzero (pp2, sizeof(pp2));
+ #ifdef _AIX
+ (void) setpriority(PRIO_PROCESS, 0, 20);
+ #else
(void) setpriority(PRIO_PROCESS, 0, 0);
+ #endif
}
/* Policy: If local password is good, user is good.
***************
*** 477,488 ****
if (krbflag)
dest_tkt(); /* clean up tickets if login fails */
#else
(void) setpriority(PRIO_PROCESS, 0, -4);
p = crypt(getpass("password:"), salt);
(void) setpriority(PRIO_PROCESS, 0, 0);
if (pwd && !strcmp(p, pwd->pw_passwd))
break;
! #endif KERBEROS
printf("Login incorrect\n");
if (++cnt >= 5) {
--- 526,545 ----
if (krbflag)
dest_tkt(); /* clean up tickets if login fails */
#else
+ #ifdef _AIX
+ (void) setpriority(PRIO_PROCESS, 0, 16);
+ #else
(void) setpriority(PRIO_PROCESS, 0, -4);
+ #endif
p = crypt(getpass("password:"), salt);
+ #ifdef _AIX
+ (void) setpriority(PRIO_PROCESS, 0, 20);
+ #else
(void) setpriority(PRIO_PROCESS, 0, 0);
+ #endif
if (pwd && !strcmp(p, pwd->pw_passwd))
break;
! #endif
printf("Login incorrect\n");
if (++cnt >= 5) {
***************
*** 499,505 ****
sleepexit(1);
}
}
-
/* committed to login -- turn off timeout */
(void)alarm((u_int)0);
--- 556,561 ----
***************
*** 517,523 ****
sleepexit(1);
}
! #ifndef VFS
if (quota(Q_SETUID, pwd->pw_uid, 0, 0) < 0 && errno != EINVAL) {
switch(errno) {
case EUSERS:
--- 573,579 ----
sleepexit(1);
}
! #ifdef OQUOTA
if (quota(Q_SETUID, pwd->pw_uid, 0, 0) < 0 && errno != EINVAL) {
switch(errno) {
case EUSERS:
***************
*** 533,539 ****
}
sleepexit(0);
}
! #endif /* !VFS */
if (chdir(pwd->pw_dir) < 0) {
printf("No directory %s!\n", pwd->pw_dir);
--- 589,595 ----
}
sleepexit(0);
}
! #endif
if (chdir(pwd->pw_dir) < 0) {
printf("No directory %s!\n", pwd->pw_dir);
***************
*** 582,588 ****
(void) initgroups(username, pwd->pw_gid);
! #ifndef VFS
quota(Q_DOWARN, pwd->pw_uid, (dev_t)-1, 0);
#endif
#ifdef KERBEROS
--- 638,644 ----
(void) initgroups(username, pwd->pw_gid);
! #ifdef OQUOTA
quota(Q_DOWARN, pwd->pw_uid, (dev_t)-1, 0);
#endif
#ifdef KERBEROS
***************
*** 594,600 ****
#else
(void)setuid((uid_type) pwd->pw_uid);
#endif /* KERBEROS */
-
if (*pwd->pw_shell == '\0')
pwd->pw_shell = BSHELL;
/* turn on new line discipline for the csh */
--- 650,655 ----
***************
*** 604,611 ****
(void)ioctl(0, TIOCSETD, (char *)&ioctlval);
#endif
}
-
/* destroy environment unless user has requested preservation */
if (!pflag)
environ = envinit;
(void)setenv("HOME", pwd->pw_dir, 1);
--- 659,670 ----
(void)ioctl(0, TIOCSETD, (char *)&ioctlval);
#endif
}
/* destroy environment unless user has requested preservation */
+ envinit = (char **)malloc (sizeof (char *));
+ if (envinit == 0) {
+ fprintf(stderr, "Can't malloc empty environment.\n");
+ sleepexit(1);
+ }
if (!pflag)
environ = envinit;
(void)setenv("HOME", pwd->pw_dir, 1);
***************
*** 619,625 ****
/* tkfile[0] is only set if we got tickets above */
if (tkfile[0])
(void) setenv(KRB_ENVIRON, tkfile, 1);
! #endif KERBEROS
if (tty[sizeof("tty")-1] == 'd')
syslog(LOG_INFO, "DIALUP %s, %s", tty, pwd->pw_name);
--- 678,684 ----
/* tkfile[0] is only set if we got tickets above */
if (tkfile[0])
(void) setenv(KRB_ENVIRON, tkfile, 1);
! #endif
if (tty[sizeof("tty")-1] == 'd')
syslog(LOG_INFO, "DIALUP %s, %s", tty, pwd->pw_name);
***************
*** 650,656 ****
kdata->pname, kdata->pinst,
kdata->prealm);
}
! #endif KERBEROS
else
syslog(LOG_NOTICE, "ROOT LOGIN %s", tty);
--- 709,715 ----
kdata->pname, kdata->pinst,
kdata->prealm);
}
! #endif
else
syslog(LOG_NOTICE, "ROOT LOGIN %s", tty);
***************
*** 660,666 ****
#ifdef KERBEROS
if (!krbflag)
printf("\nWarning: No Kerberos tickets obtained.\n\n");
! #endif KERBEROS
motd();
(void)sprintf(tbuf, "%s/%s", MAILDIR, pwd->pw_name);
if (stat(tbuf, &st) == 0 && st.st_size != 0)
--- 719,725 ----
#ifdef KERBEROS
if (!krbflag)
printf("\nWarning: No Kerberos tickets obtained.\n\n");
! #endif
motd();
(void)sprintf(tbuf, "%s/%s", MAILDIR, pwd->pw_name);
if (stat(tbuf, &st) == 0 && st.st_size != 0)
***************
*** 667,681 ****
printf("You have %smail.\n",
(st.st_mtime > st.st_atime) ? "new " : "");
}
!
! #ifdef VFS
if (! access( QUOTAWARN, X_OK)) (void) system(QUOTAWARN);
! #endif VFS
(void)signal(SIGALRM, SIG_DFL);
(void)signal(SIGQUIT, SIG_DFL);
(void)signal(SIGINT, SIG_DFL);
(void)signal(SIGTSTP, SIG_IGN);
-
tbuf[0] = '-';
(void) strcpy(tbuf + 1, (p = rindex(pwd->pw_shell, '/')) ?
p + 1 : pwd->pw_shell);
--- 726,738 ----
printf("You have %smail.\n",
(st.st_mtime > st.st_atime) ? "new " : "");
}
! #ifndef OQUOTA
if (! access( QUOTAWARN, X_OK)) (void) system(QUOTAWARN);
! #endif
(void)signal(SIGALRM, SIG_DFL);
(void)signal(SIGQUIT, SIG_DFL);
(void)signal(SIGINT, SIG_DFL);
(void)signal(SIGTSTP, SIG_IGN);
tbuf[0] = '-';
(void) strcpy(tbuf + 1, (p = rindex(pwd->pw_shell, '/')) ?
p + 1 : pwd->pw_shell);
***************
*** 773,779 ****
int quiet;
char *tty;
{
! #if !defined(_IBMR2)
struct lastlog ll;
int fd;
--- 830,836 ----
int quiet;
char *tty;
{
! #if !defined(_AIX)
struct lastlog ll;
int fd;
***************
*** 848,854 ****
long authoptions = 0L;
struct hostent *hp = gethostbyname(host);
static char lusername[UT_NAMESIZE+1];
- char *malloc();
/*
* Kerberos autologin protocol.
--- 905,910 ----
***************
*** 956,962 ****
--- 1012,1022 ----
#define NSPEEDS (sizeof(speeds) / sizeof(speeds[0]))
doremoteterm(tp)
+ #ifdef POSIX
+ struct termios *tp;
+ #else
struct sgttyb *tp;
+ #endif
{
register char *cp = index(term, '/'), **cpp;
char *speed;
***************
*** 969,979 ****
--- 1029,1053 ----
*cp++ = '\0';
for (cpp = speeds; cpp < &speeds[NSPEEDS]; cpp++)
if (strcmp(*cpp, speed) == 0) {
+ #ifdef POSIX
+ tp->c_cflag = (tp->c_cflag & ~CBAUD) | (cpp-speeds);
+ #else
tp->sg_ispeed = tp->sg_ospeed = cpp-speeds;
+ #endif
break;
}
}
+ #ifdef POSIX
+ /* set all standard echo, edit, and job control options */
+ tp->c_lflag = ECHO|ECHOE|ECHOK|ICANON|ISIG;
+ tp->c_iflag |= ICRNL|BRKINT;
+ #ifdef _AIX
+ /* I don't know what TAB3 does, but that's what AIX login sets. */
+ tp->c_oflag |= ONLCR|OPOST|TAB3;
+ #endif
+ #else
tp->sg_flags = ECHO|CRMOD|ANYP|XTABS;
+ #endif
}
sleepexit(eval)
***************
*** 1016,1028 ****
/* Leave */
exit(0);
}
! #endif KERBEROS
#if defined(_AIX) && defined(_IBMR2)
#include <sys/id.h>
/*
! * The RIOS has bizzarre ideas about changing uids around. They are
* such that the seteuid and setruid calls here fail. For this reason
* we are replacing the seteuid and setruid calls.
*
--- 1090,1102 ----
/* Leave */
exit(0);
}
! #endif
#if defined(_AIX) && defined(_IBMR2)
#include <sys/id.h>
/*
! * AIX 3.1 has bizzarre ideas about changing uids around. They are
* such that the seteuid and setruid calls here fail. For this reason
* we are replacing the seteuid and setruid calls.
*