Print this page
10142 smatch fix for who


  13  * When distributing Covered Code, include this CDDL HEADER in each
  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 /*      Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T     */
  22 /*        All Rights Reserved   */
  23 
  24 
  25 /*
  26  * Copyright (c) 2013 Gary Mills
  27  *
  28  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
  29  * Use is subject to license terms.
  30  */
  31 
  32 /*




  33  *      This program analyzes information found in /var/adm/utmpx
  34  *
  35  *      Additionally information is gathered from /etc/inittab
  36  *      if requested.
  37  *
  38  *
  39  *      Syntax:
  40  *
  41  *              who am i        Displays info on yourself
  42  *
  43  *              who -a          Displays information about All
  44  *                              entries in /var/adm/utmpx
  45  *
  46  *              who -b          Displays info on last boot
  47  *
  48  *              who -d          Displays info on DEAD PROCESSES
  49  *
  50  *              who -H          Displays HEADERS for output
  51  *
  52  *              who -l          Displays info on LOGIN entries


 681                     pexit);
 682                 if (optcnt == 1 && !validtype[USER_PROCESS]) {
 683                         (void) printf("\n");
 684                         exit(0);
 685                 }
 686         }
 687 
 688         /*
 689          *      Handle BOOT_TIME process -  If no alt. file - Only one!
 690          */
 691         if (utmpp->ut_type == BOOT_TIME) {
 692                 if (optcnt == 1 && !validtype[USER_PROCESS]) {
 693                         (void) printf("\n");
 694                         exit(0);
 695                 }
 696         }
 697 
 698         /*
 699          *      Get remote host from utmpx structure
 700          */
 701         if (utmpp && utmpp->ut_host[0])
 702                 (void) printf("\t(%.*s)", sizeof (utmpp->ut_host),
 703                     utmpp->ut_host);
 704 
 705         /*
 706          *      Now, put on the trailing EOL
 707          */
 708         (void) printf("\n");
 709 }
 710 
 711 static void
 712 process()
 713 {
 714         struct passwd *pwp;
 715         int i = 0;
 716         char *ttname;
 717 
 718         /*
 719          *      Loop over each entry in /var/adm/utmpx
 720          */
 721 




  13  * When distributing Covered Code, include this CDDL HEADER in each
  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 /*      Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T     */
  22 /*        All Rights Reserved   */
  23 
  24 
  25 /*
  26  * Copyright (c) 2013 Gary Mills
  27  *
  28  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
  29  * Use is subject to license terms.
  30  */
  31 
  32 /*
  33  * Copyright (c) 2018, Joyent, Inc.
  34  */
  35 
  36 /*
  37  *      This program analyzes information found in /var/adm/utmpx
  38  *
  39  *      Additionally information is gathered from /etc/inittab
  40  *      if requested.
  41  *
  42  *
  43  *      Syntax:
  44  *
  45  *              who am i        Displays info on yourself
  46  *
  47  *              who -a          Displays information about All
  48  *                              entries in /var/adm/utmpx
  49  *
  50  *              who -b          Displays info on last boot
  51  *
  52  *              who -d          Displays info on DEAD PROCESSES
  53  *
  54  *              who -H          Displays HEADERS for output
  55  *
  56  *              who -l          Displays info on LOGIN entries


 685                     pexit);
 686                 if (optcnt == 1 && !validtype[USER_PROCESS]) {
 687                         (void) printf("\n");
 688                         exit(0);
 689                 }
 690         }
 691 
 692         /*
 693          *      Handle BOOT_TIME process -  If no alt. file - Only one!
 694          */
 695         if (utmpp->ut_type == BOOT_TIME) {
 696                 if (optcnt == 1 && !validtype[USER_PROCESS]) {
 697                         (void) printf("\n");
 698                         exit(0);
 699                 }
 700         }
 701 
 702         /*
 703          *      Get remote host from utmpx structure
 704          */
 705         if (utmpp->ut_host[0])
 706                 (void) printf("\t(%.*s)", sizeof (utmpp->ut_host),
 707                     utmpp->ut_host);
 708 
 709         /*
 710          *      Now, put on the trailing EOL
 711          */
 712         (void) printf("\n");
 713 }
 714 
 715 static void
 716 process()
 717 {
 718         struct passwd *pwp;
 719         int i = 0;
 720         char *ttname;
 721 
 722         /*
 723          *      Loop over each entry in /var/adm/utmpx
 724          */
 725