Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!sol.ctr.columbia.edu!ira.uka.de!fauern!opal!math.fu-berlin.de!fub!dobag.in-berlin.de!jac From: jac@dobag.in-berlin.de (Joerg Conradt) Newsgroups: comp.os.minix Subject: su with /usr/adm/sulog Message-ID: Date: 5 Apr 91 21:56:20 GMT Organization: Dobag Computer Systems Berlin Lines: 79 hello world, as the minix-su command doesn't record who used it and when, i added a procedure which makes the su like the su in SYS V, Rel 3. You have to add these includes: #include #include and (after the includes, in front of main) to define the file, the record is written to: #define SULOG "/usr/adm/sulog" After this there's the usual main-prg! In front of the line : " std_err("Sorry\n"); " you insert: sulist(0); And in front of the setgid(...) and setuid(...) you insert the following two lines: sulog(1); pwd = getpwnam(name); That's all you have to change in the programm. You have to add the follwing procedure at the end of the file and the su command will record all SUs. Of course only root is allowed to see or to modify the SULOG-file!!! Dont forget to exec "chmod 4755 su" and "chown root su" after compiling the new su, else it won't work, of course! Much fun with this su - and worse hacking! Joerg Conradt --- CUT HERE!! --- sulist(worked) /* Added by Joerg Conradt, Berlin, Germany */ int worked; /* on the 4th April 1991 */ { /* UUCP: jac@dobag.in-berlin.de */ register char *name; FILE *sudat; char *writein,*malloc(); struct passwd *getpwuid(); struct tm *ptr; time_t lt; writein = (char *) malloc(80); lt = time(NULL); ptr = localtime(<); strcpy (writein,"SU "); strncat (writein,asctime(ptr),strlen(asctime(ptr))-1); /* no /n */ if (worked == 0) { strcat (writein," - "); } else { strcat (writein," + "); } strcat (writein,ctermid()); strcat (writein," "); strcat (writein,*getpwuid(getuid())); strcat (writein,"-"); strcat (writein,name); strcat (writein,"\n"); if ( (sudat=fopen(SULOG,"a")) == 0) { /* append sulog */ std_err("su: Can't open sulog-file (fatal)\n"); exit (4); } if ( fputs(writein,sudat) == EOF ) { std_err("su: Can't write to sulog-file (fatal)\n"); exit (4); } fclose(sudat); chown(SULOG,0,0); chmod(SULOG,0600); } --- END --- -- UUCP: jac@dobag.in-berlin.de | - The number of viewers watching you is Alias Joerg Conradt | proportional to the stupidity of your 1000 Berlin 41 Germany | action. ++ 0307958397 | - "Murphy was an optimist"