home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / unix / volume18 / diskhog2 / nohog.c < prev    next >
Encoding:
C/C++ Source or Header  |  1989-03-26  |  860 b   |  35 lines

  1. /*
  2.  * nohog.c: remove diskhog tag from /etc/hogs directory
  3.  *
  4.  * find out who the user is, and then remove the tag from the hogs directory.
  5.  *
  6.  * It's supposed to be proof against fraud, though I wouldn't care to put
  7.  * any money on it.
  8.  *
  9.  * runs suid root, so that the user can't just 'rm' the file.
  10.  *
  11.  * This program should NOT be accessible to diskhogs running the "diskhog"
  12.  * shell - i.e. don't link it to /diskhog or /usr/diskhog
  13.  */
  14. #include <sys/types.h> 
  15. #include <utmp.h>
  16. #include <stdio.h>
  17.  
  18. #include "diskhog.h"
  19. char *ttyname(); 
  20. struct utmp *getutline();
  21.  
  22. main(){
  23.     char *p;
  24.     struct utmp *utmp, mine;
  25.     int prefix = sizeof "/dev/";
  26.     chdir(DQUOTAS);
  27.     chdir("hogs");
  28.     p = ttyname(fileno(stderr));        /* find tty device */
  29.     strcpy(mine.ut_line, p + 5);
  30.     if(utmp = getutline(&mine))
  31.         unlink(utmp->ut_user);
  32.     else printf("who are you?\n");
  33.     return(0);
  34. }
  35.