Print this page
3124 Remove any existing references to utmp, use utmpx instead


  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 /*
  22  * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
  23  * Use is subject to license terms.
  24  */
  25 
  26 /*      Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T     */
  27 /*        All Rights Reserved   */
  28 
  29 /*
  30  * Portions of such source code were derived from Berkeley 4.3 BSD
  31  * under license from the Regents of the University of California.
  32  */
  33 
  34 #pragma ident   "%Z%%M% %I%     %E% SMI"
  35 
  36 /*
  37  * utmpd        - utmp daemon
  38  *
  39  *              This program receives requests from  pututxline(3)
  40  *              via a named pipe to watch the process to make sure it cleans up
  41  *              its utmpx entry on termination.
  42  *              The program keeps a list of procs
  43  *              and uses poll() on their /proc files to detect termination.
  44  *              Also the  program periodically scans the /etc/utmpx file for
  45  *              processes that aren't in the table so they can be watched.
  46  *
  47  *              If utmpd doesn't hear back over the pipe from pututline(3) that
  48  *              the process has removed its entry it cleans the entry when the
  49  *              the process terminates.
  50  *              The AT&T Copyright above is there since we borrowed the pipe
  51  *              mechanism from init(1m).
  52  */
  53 
  54 
  55 #include        <sys/types.h>


 942                 }
 943         }
 944         endutxent();
 945 }
 946 
 947 
 948 /*
 949  * clean_utmpx_ent      - Clean a utmpx entry
 950  */
 951 
 952 static void
 953 clean_utmpx_ent(u)
 954         struct utmpx *u;
 955 {
 956         dprintf(("      clean_utmpx_ent: %d\n", (int)u->ut_pid));
 957         u->ut_type = DEAD_PROCESS;
 958         (void) time(&u->ut_xtime);
 959         (void) pututxline(u);
 960         updwtmpx(WTMPX_FILE, u);
 961         /*
 962          * XXX update wtmp for ! nonuser entries?
 963          */
 964 }
 965 
 966 /*
 967  *              *** Error Handling and Debugging Routines ***
 968  */
 969 
 970 /*
 971  * fatal - Catastrophic failure
 972  */
 973 
 974 static void
 975 fatal(char *str)
 976 {
 977         int oerrno = errno;
 978 
 979         syslog(LOG_ALERT, "%s", str);
 980         if (Debug == 1) {
 981                 if ((errno = oerrno) != 0)
 982                         perror(prog_name);




  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 /*
  22  * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
  23  * Use is subject to license terms.
  24  */
  25 
  26 /*      Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T     */
  27 /*        All Rights Reserved   */
  28 
  29 /*
  30  * Portions of such source code were derived from Berkeley 4.3 BSD
  31  * under license from the Regents of the University of California.
  32  */
  33 


  34 /*
  35  * utmpd        - utmp daemon
  36  *
  37  *              This program receives requests from  pututxline(3)
  38  *              via a named pipe to watch the process to make sure it cleans up
  39  *              its utmpx entry on termination.
  40  *              The program keeps a list of procs
  41  *              and uses poll() on their /proc files to detect termination.
  42  *              Also the  program periodically scans the /etc/utmpx file for
  43  *              processes that aren't in the table so they can be watched.
  44  *
  45  *              If utmpd doesn't hear back over the pipe from pututline(3) that
  46  *              the process has removed its entry it cleans the entry when the
  47  *              the process terminates.
  48  *              The AT&T Copyright above is there since we borrowed the pipe
  49  *              mechanism from init(1m).
  50  */
  51 
  52 
  53 #include        <sys/types.h>


 940                 }
 941         }
 942         endutxent();
 943 }
 944 
 945 
 946 /*
 947  * clean_utmpx_ent      - Clean a utmpx entry
 948  */
 949 
 950 static void
 951 clean_utmpx_ent(u)
 952         struct utmpx *u;
 953 {
 954         dprintf(("      clean_utmpx_ent: %d\n", (int)u->ut_pid));
 955         u->ut_type = DEAD_PROCESS;
 956         (void) time(&u->ut_xtime);
 957         (void) pututxline(u);
 958         updwtmpx(WTMPX_FILE, u);
 959         /*
 960          * XXX update wtmp for ! nonuserx entries?
 961          */
 962 }
 963 
 964 /*
 965  *              *** Error Handling and Debugging Routines ***
 966  */
 967 
 968 /*
 969  * fatal - Catastrophic failure
 970  */
 971 
 972 static void
 973 fatal(char *str)
 974 {
 975         int oerrno = errno;
 976 
 977         syslog(LOG_ALERT, "%s", str);
 978         if (Debug == 1) {
 979                 if ((errno = oerrno) != 0)
 980                         perror(prog_name);