[6581] in Athena Bugs
/bin/login... CONTEXT diffs this time...
daemon@ATHENA.MIT.EDU (daemon@ATHENA.MIT.EDU)
Tue Dec 11 17:00:17 1990
From: vanharen@ATHENA.MIT.EDU
Date: Tue, 11 Dec 90 16:59:56 -0500
To: bugs@ATHENA.MIT.EDU
Oops... last time I didn't send a context diff. This one is. Sorry
'bout that. Once again:
Below is a context diff on login.c. Changes include putting
comments around statements after #endif's, the fix to the
writable-strings problem, and no_remote support (#ifdef'ed on
NOREMOTE, though I recommend removing these #ifdef's, since
no_create is not #ifdef'ed, and I think that this should be a
supported configuration for private ws's -- but I digress).
==============================================================================
*** /tmp/,RCSt1004340 Tue Dec 11 16:51:06 1990
--- login.c Tue Dec 11 16:09:22 1990
***************
*** 18,28 ****
char copyright[] =
"@(#) Copyright (c) 1980 Regents of the University of California.\n\
All rights reserved.\n";
! #endif not lint
#ifndef lint
static char sccsid[] = "@(#)login.c 5.15 (Berkeley) 4/12/86";
! #endif not lint
/*
* login [ name ]
--- 18,28 ----
char copyright[] =
"@(#) Copyright (c) 1980 Regents of the University of California.\n\
All rights reserved.\n";
! #endif /* not lint */
#ifndef lint
static char sccsid[] = "@(#)login.c 5.15 (Berkeley) 4/12/86";
! #endif /* not lint */
/*
* login [ name ]
***************
*** 35,41 ****
#include <sys/param.h>
#ifndef VFS
#include <sys/quota.h>
! #endif !VFS
#include <sys/stat.h>
#include <sys/time.h>
#include <sys/resource.h>
--- 35,41 ----
#include <sys/param.h>
#ifndef VFS
#include <sys/quota.h>
! #endif /* !VFS */
#include <sys/stat.h>
#include <sys/time.h>
#include <sys/resource.h>
***************
*** 83,89 ****
#ifdef VFS
#define QUOTAWARN "/usr/ucb/quota" /* warn user about quotas */
! #endif VFS
#ifndef KRB_REALM
#define KRB_REALM "ATHENA.MIT.EDU"
--- 83,89 ----
#ifdef VFS
#define QUOTAWARN "/usr/ucb/quota" /* warn user about quotas */
! #endif /* VFS */
#ifndef KRB_REALM
#define KRB_REALM "ATHENA.MIT.EDU"
***************
*** 111,116 ****
--- 111,119 ----
char noattach[] = "/etc/noattach";
char go_register[] = "/usr/etc/go_register";
char get_motd[] = "/bin/athena/get_message";
+ #ifdef NOREMOTE
+ char noremote[] = "/etc/noremote";
+ #endif
/* uid, gid, etc. used to be -1; guess what setreuid does with that --asp */
#ifdef POSIX
***************
*** 142,148 ****
struct passwd newuser = {"\0\0\0\0\0\0\0\0", "*", START_UID, MIT_GID, 0,
NULL, NULL, "/mit/\0\0\0\0\0\0\0\0", NULL };
! #endif POSIX
struct sgttyb ttyb;
struct utmp utmp;
--- 145,151 ----
struct passwd newuser = {"\0\0\0\0\0\0\0\0", "*", START_UID, MIT_GID, 0,
NULL, NULL, "/mit/\0\0\0\0\0\0\0\0", NULL };
! #endif /* POSIX */
struct sgttyb ttyb;
struct utmp utmp;
***************
*** 187,192 ****
--- 190,198 ----
int attachable = FALSE; /* True if /etc/noattach doesn't exist */
int attachedflag = FALSE; /* True if homedir attached */
int errorprtflag = FALSE; /* True if login error already printed */
+ #ifdef NOREMOTE
+ int no_remote = FALSE; /* True if /etc/noremote exists */
+ #endif
char rusername[NMAX+1], lusername[NMAX+1];
char rpassword[NMAX+1];
char name[NMAX+1];
***************
*** 207,212 ****
--- 213,221 ----
long salt;
int ldisc = 0, zero = 0, found = 0, i;
char **envnew;
+ #ifdef NOREMOTE
+ FILE *nrfd;
+ #endif
signal(SIGALRM, timedout);
alarm(timeout);
***************
*** 215,221 ****
setpriority(PRIO_PROCESS, 0, 0);
#ifndef VFS
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;
--- 224,230 ----
setpriority(PRIO_PROCESS, 0, 0);
#ifndef VFS
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;
***************
*** 332,337 ****
--- 341,349 ----
invalid = FALSE;
inhibitflag = !access(inhibit,F_OK);
attachable = access(noattach, F_OK);
+ #ifdef NOREMOTE
+ no_remote = !access(noremote, F_OK);
+ #endif
do {
errorprtflag = 0;
ldisc = 0;
***************
*** 395,402 ****
--- 407,433 ----
pp = getlongpass("Password:");
if (!found) /* check if we can create an entry */
+ #ifndef NOREMOTE
if (inhibitflag)
+ #else
+ if (inhibitflag
+ || (no_remote
+ && (hflag || rflag || kflag || Kflag)))
+ {
invalid = TRUE;
+ fprintf(stderr, "You are not allowed to login here.\n");
+
+ if ((nrfd = fopen(noremote, "r")) != 0) {
+ while ((c = getc(nrfd)) != EOF)
+ putchar(c);
+ fflush(stdout);
+ fclose(nrfd);
+ }
+
+ errorprtflag = TRUE;
+ goto leavethis;
+ }
+ #endif
else /* we are allowed to create an entry */
pwd = &newuser;
***************
*** 667,673 ****
(void) dest_tkt();
exit(0);
}
! #endif VFS
time(&utmp.ut_time);
t = ttyslot();
if (t > 0 && (f = open("/etc/utmp", O_WRONLY)) >= 0) {
--- 698,704 ----
(void) dest_tkt();
exit(0);
}
! #endif /* VFS */
time(&utmp.ut_time);
t = ttyslot();
if (t > 0 && (f = open("/etc/utmp", O_WRONLY)) >= 0) {
***************
*** 720,726 ****
initgroups(name, pwd->pw_gid);
#ifndef VFS
quota(Q_DOWARN, pwd->pw_uid, (dev_t)-1, 0);
! #endif !VFS
/* This call MUST succeed */
if(setuid(pwd->pw_uid) < 0) {
--- 751,757 ----
initgroups(name, pwd->pw_gid);
#ifndef VFS
quota(Q_DOWARN, pwd->pw_uid, (dev_t)-1, 0);
! #endif /* !VFS */
/* This call MUST succeed */
if(setuid(pwd->pw_uid) < 0) {
***************
*** 766,771 ****
--- 797,808 ----
} else {
syslog(LOG_NOTICE, "ROOT LOGIN %s", tty);
}
+ #ifdef NOREMOTE
+ else {
+ syslog(LOG_INFO, "User %s logged in on %s", pwd->pw_name, tty);
+ }
+ #endif
+
if (!quietlog) {
struct stat st;
***************
*** 777,783 ****
}
#ifdef VFS
if (! access( QUOTAWARN, X_OK)) system(QUOTAWARN);
! #endif VFS
signal(SIGALRM, SIG_DFL);
signal(SIGQUIT, SIG_DFL);
signal(SIGINT, SIG_DFL);
--- 814,820 ----
}
#ifdef VFS
if (! access( QUOTAWARN, X_OK)) system(QUOTAWARN);
! #endif /* VFS */
signal(SIGALRM, SIG_DFL);
signal(SIGQUIT, SIG_DFL);
signal(SIGINT, SIG_DFL);
***************
*** 1103,1109 ****
strcat(environ[index], value);
environ[++index] = NULL;
}
! #endif ultrix
/*
* This routine handles cleanup stuff, notification service, and the like.
--- 1140,1146 ----
strcat(environ[index], value);
environ[++index] = NULL;
}
! #endif /* ultrix */
/*
* This routine handles cleanup stuff, notification service, and the like.
***************
*** 1294,1304 ****
while (wait(0) != pid)
;
}
! #endif notdef
return;
#ifdef notdef
printf("Couldn't detach home directory!\n");
! #endif notdef
}
isremotedir(dname)
--- 1331,1341 ----
while (wait(0) != pid)
;
}
! #endif /* notdef */
return;
#ifdef notdef
printf("Couldn't detach home directory!\n");
! #endif /* notdef */
}
isremotedir(dname)
***************
*** 1644,1652 ****
init_wgfile()
{
! char *wgfile;
! wgfile = "/tmp/wg.XXXXXX";
mktemp(wgfile);
--- 1681,1689 ----
init_wgfile()
{
! char wgfile[15];
! strcpy(wgfile, "/tmp/wg.XXXXXX");
mktemp(wgfile);