#ifdef ournix #include "ournix.h" #endif char sccsID[] = "@(#) logout.c V1.1 Copyright Julian H. Stacey 5th March 1987\n" ; /* Author Julian Stacey. Running exepack on login.exe causes a "Packed file is corrupt message", when logout.exe tries to exec login.exe. This is irrespective of whether logout.exe is packed. Note that this message does not occur when login is run from autoexec.bat, or by hand, live. */ /* #define DEBUG */ #define WTMP "/usr/adm/wtmp" /* to store login name log. */ #define UTMP "/etc/utmp" /* to store who is logged in. */ #define OUT_SYS "\etc\logout.bat" /* save ram root script */ #include #include extern char *ctime() ; extern long time() ; /* char strings declared once to save space */ char sUTMP[] = UTMP ; char sWTMP[] = WTMP ; #ifdef DEBUG char cantopen[] = "%s: Cant open %s\n" ; #endif char **ARGV ; main(argc, argv) int argc ; char **argv; { /* char *p; int i; */ long log_time; FILE *wtmp, *utmp ; char jcommand[200]; ARGV = argv; #ifdef VSL /* { */ #include "../../include/vsl.h" #endif /* } */ (void) signal(SIGINT, SIG_IGN); time(&log_time) ; if ((wtmp = fopen(sWTMP,"a" )) == 0) { #ifdef DEBUG fprintf(stderr,cantopen,*ARGV,sWTMP); perror(*ARGV) #endif ; } else { fprintf(wtmp,"someone\tlogout\t%s", ctime(&log_time) ); (void) fclose(wtmp); } if ((utmp = fopen(sUTMP,"w" ) ) == 0) { #ifdef DEBUG fprintf(stderr,cantopen,*ARGV,sUTMP); perror(*ARGV) #endif ; } else { fprintf(utmp,"nobody logged in\n"); (void) fclose(utmp); } sprintf(jcommand,"command < %s",OUT_SYS); sprintf(jcommand,"cat /etc/motd"); (void) system(jcommand); if (chdir("/") != 0) { printf("Failed to cd / .\n"); printf("Reboot machine to get login prompt.\n"); while(1) ; } /* else execl("/usr/bin/local/login",(char *)0); */ else execlp("login",(char *)0); /* presumably should never get to here */ exit(1); }