archer%segin4.segin.fr@relay.prime.com (Vincent Archer) (11/13/90)
Some people have complained that they couldn't get the cdif for login.c back into proper shape (I knew I shouldn't have mixed Minix & HPUX... :-) So here it is again, unencoded this time. Since no lines are bigger than 80 characters, Bitnet won't split hairs deciding where to cut them... :-) Sorry for the repost. ------------------------------cut cdif below----------------------------------- *** login.c.old Thu Nov 8 19:32:01 1990 --- login.c Thu Nov 8 19:48:49 1990 *************** *** 40,45 **** --- 40,47 ---- * - if /bin/sh cannot be located, try /usr/bin/sh * Vincent Archer August 1990 * - use ttyname() to find about tty name + * Vincent Archer November 1990 + * - fixed login-over-login accounting. */ #include <sys/types.h> *************** *** 59,65 **** extern char *ttyname(); ! static char *Version = "@(#) LOGIN 1.14 (08/22/90)"; int time_out; char user[32]; char logname[35]; --- 61,67 ---- extern char *ttyname(); ! static char *Version = "@(#) LOGIN 1.15 (11/08/90)"; int time_out; char user[32]; char logname[35]; *************** *** 106,118 **** while (read(fd, (char *) &oldent, sizeof(struct utmp)) == sizeof(struct utmp)) { if (oldent.ut_pid == getpid()) break; lineno++; } lineno *= sizeof(struct utmp); - - if (lseek(fd, (long) lineno, SEEK_SET) >= 0) { - read(fd, (char *) &oldent, sizeof(struct utmp)); - } close(fd); /* Clear out the new string fields. */ --- 108,117 ---- while (read(fd, (char *) &oldent, sizeof(struct utmp)) == sizeof(struct utmp)) { if (oldent.ut_pid == getpid()) break; + oldent.ut_type = DEAD_PROCESS; lineno++; } lineno *= sizeof(struct utmp); close(fd); /* Clear out the new string fields. */ *************** *** 131,140 **** entry.ut_pid = getpid(); /* Write a WTMP record. */ ! if ((fd = open(WTMP, O_WRONLY)) > 0) { ! if (lseek(fd, 0L, SEEK_END) >= 0L) { ! write(fd, (char *) &entry, sizeof(struct utmp)); ! } close(fd); } /* Rewrite the UTMP entry. */ --- 130,141 ---- entry.ut_pid = getpid(); /* Write a WTMP record. */ ! if ((fd = open(WTMP, O_WRONLY+O_APPEND)) > 0) { ! if (oldent.ut_type == USER_PROCESS) { ! oldent.ut_type = DEAD_PROCESS; ! write(fd, (char *) &oldent, sizeof(struct utmp)); ! } ! write(fd, (char *) &entry, sizeof(struct utmp)); close(fd); } /* Rewrite the UTMP entry. */ *************** *** 161,172 **** strncpy(entry.ut_line, tty, sizeof(entry.ut_line)); entry.ut_time = time((time_t *)0); ! if ((fd = open(BTMP, O_WRONLY)) < 0) return; ! ! if (lseek(fd, 0L, SEEK_END) >= 0L) { ! /* Append the entry to the btmp file. */ ! write(fd, (char *) &entry, sizeof(struct utmp)); ! } close(fd); } #endif /* BADLOG */ --- 162,171 ---- strncpy(entry.ut_line, tty, sizeof(entry.ut_line)); entry.ut_time = time((time_t *)0); ! if ((fd = open(BTMP, O_WRONLY+O_APPEND)) < 0) return; ! ! /* Append the entry to the btmp file. */ ! write(fd, (char *) &entry, sizeof(struct utmp)); close(fd); } #endif /* BADLOG */ *************** *** 206,211 **** --- 205,215 ---- char *sh = "/bin/sh"; /* sh/pw_shell field value */ char *sh2= "/usr/bin/sh"; /* other possibility */ + if (getppid() > 2) { + std_err("login can be used only at the top level.\n"); + exit(1); + } + /* Reset some of the line parameters in case they have been mashed. */ if (ioctl(0, TIOCGETP, &args) < 0) exit(1); #ifdef NOGETTY -------------------------------cut cdif above---------------------------------- _________ |\___/| Vincent Archer | \ / | Email: archer%segin4.segin.fr@relay.prime.com | /|\ | |// \\| -+-----+- "Time is running fast..."