home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / unix / volume15 / ultrix-modem / uchange.c < prev   
C/C++ Source or Header  |  1988-05-24  |  711b  |  36 lines

  1. /*
  2.  * Copyright (c) Dave Settle, Mar 1987
  3.  * Permission is granted to do anything with this program, except remove
  4.  * this copyright notice, or sell it for profit.
  5.  *
  6.  *
  7.  * change the ut_pid value from "old" to "new".
  8.  * Attempts to do all the things that "getty" appears to do.
  9.  */
  10.  
  11. #include <sys/types.h>
  12. #include <utmp.h>
  13.  
  14. struct utmp *utmp, *getutent();
  15.  
  16. uchange(old, new)
  17. {
  18.     setutent();
  19.     while(utmp = getutent()) {
  20.         if(utmp->ut_pid == old) {
  21.             utmp->ut_pid = new;
  22.             if(strcmp(utmp->ut_user, "getty")) 
  23.                 strcpy(utmp->ut_user, "modem");
  24.             else
  25.                 strcpy(utmp->ut_user, "getty");
  26.             pututline(utmp);
  27.             endutent();
  28.             return(1);
  29.         }
  30.     }
  31.     printf("Can't find utmp entry\n");
  32.     endutent();
  33.     return(1);
  34. }
  35.  
  36.