Print this page
2989 Eliminate use of LOGNAME_MAX in ON
1166 useradd have warning with name more 8 chars

*** 21,36 **** /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ /* All Rights Reserved */ /* * Copyright 2006 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ - #pragma ident "%Z%%M% %I% %E% SMI" - /* * This program analyzes information found in /var/adm/utmpx * * Additionally information is gathered from /etc/inittab * if requested. --- 21,36 ---- /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ /* All Rights Reserved */ /* + * Copyright (c) 2013 Gary Mills + * * Copyright 2006 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ /* * This program analyzes information found in /var/adm/utmpx * * Additionally information is gathered from /etc/inittab * if requested.
*** 98,120 **** static void dump(void); static struct utmpx *utmpp; /* pointer for getutxent() */ /* ! * utmpx defines wider fields for user and line. For compatibility of output, ! * we are limiting these to the old maximums in utmp. Define UTMPX_NAMELEN ! * to use the full lengths. */ - #ifndef UTMPX_NAMELEN - /* XXX - utmp - fix name length */ - #define NMAX (_POSIX_LOGIN_NAME_MAX - 1) - #define LMAX 12 - #else /* UTMPX_NAMELEN */ #define NMAX (sizeof (utmpp->ut_user)) #define LMAX (sizeof (utmpp->ut_line)) - #endif static char comment[BUFSIZ]; /* holds inittab comment */ static char errmsg[BUFSIZ]; /* used in snprintf for errors */ static int fildes; /* file descriptor for inittab */ static int Hopt = 0; /* 1 = who -H */ static char *inittab; /* ptr to inittab contents */ --- 98,116 ---- static void dump(void); static struct utmpx *utmpp; /* pointer for getutxent() */ /* ! * Use the full lengths from utmpx for user and line. */ #define NMAX (sizeof (utmpp->ut_user)) #define LMAX (sizeof (utmpp->ut_line)) + /* Print minimum field widths. */ + #define LOGIN_WIDTH 8 + #define LINE_WIDTH 12 + static char comment[BUFSIZ]; /* holds inittab comment */ static char errmsg[BUFSIZ]; /* used in snprintf for errors */ static int fildes; /* file descriptor for inittab */ static int Hopt = 0; /* 1 = who -H */ static char *inittab; /* ptr to inittab contents */
*** 166,176 **** stbufp = &stbuf; /* * Strip off path name of this command */ ! for (i = strlen(argv[0]); i >= 0 && argv[0][i] != '/'; --i); if (i >= 0) argv[0] += i+1; program = argv[0]; /* --- 162,173 ---- stbufp = &stbuf; /* * Strip off path name of this command */ ! for (i = strlen(argv[0]); i >= 0 && argv[0][i] != '/'; --i) ! ; if (i >= 0) argv[0] += i+1; program = argv[0]; /*
*** 507,517 **** /* * XCU4 - Use non user macro for correct user count */ if (((totlusrs - 1) % number) == 0 && totlusrs > 1) (void) printf("\n"); ! (void) printf("%-*s ", NMAX, user); return; } pexit = (int)' '; --- 504,514 ---- /* * XCU4 - Use non user macro for correct user count */ if (((totlusrs - 1) % number) == 0 && totlusrs > 1) (void) printf("\n"); ! (void) printf("%-*.*s ", LOGIN_WIDTH, NMAX, user); return; } pexit = (int)' ';
*** 563,573 **** w = ' '; /* * Print the TERSE portion of the output */ ! (void) printf("%-*s %c %-12s %s", NMAX, user, w, device, time_buf); if (!terse) { /* * Stat device for idle time * (Don't complain if you can't) --- 560,571 ---- w = ' '; /* * Print the TERSE portion of the output */ ! (void) printf("%-*.*s %c %-12s %s", LOGIN_WIDTH, NMAX, user, ! w, device, time_buf); if (!terse) { /* * Stat device for idle time * (Don't complain if you can't)
*** 624,634 **** * Look for a line beginning with * utmpp->ut_id */ while ((rc = strncmp(utmpp->ut_id, iinit, strcspn(iinit, ":"))) != 0) { ! for (; *iinit != '\n'; iinit++); iinit++; /* * Wrap once if necessary to * find entry in inittab --- 622,633 ---- * Look for a line beginning with * utmpp->ut_id */ while ((rc = strncmp(utmpp->ut_id, iinit, strcspn(iinit, ":"))) != 0) { ! for (; *iinit != '\n'; iinit++) ! ; iinit++; /* * Wrap once if necessary to * find entry in inittab
*** 644,657 **** if (*iinit != '\0') { /* * We found our entry */ for (iinit++; *iinit != '#' && ! *iinit != '\n'; iinit++); if (*iinit == '#') { for (iinit++; *iinit == ' ' || ! *iinit == '\t'; iinit++); for (rc = 0; *iinit != '\n'; iinit++) comment[rc++] = *iinit; comment[rc] = '\0'; } else (void) strcpy(comment, " "); --- 643,658 ---- if (*iinit != '\0') { /* * We found our entry */ for (iinit++; *iinit != '#' && ! *iinit != '\n'; iinit++) ! ; if (*iinit == '#') { for (iinit++; *iinit == ' ' || ! *iinit == '\t'; iinit++) ! ; for (rc = 0; *iinit != '\n'; iinit++) comment[rc++] = *iinit; comment[rc] = '\0'; } else (void) strcpy(comment, " ");
*** 754,764 **** */ if (validtype[utmpp->ut_type]) { #ifdef XPG4 if (utmpp->ut_type == LOGIN_PROCESS) { if ((utmpp->ut_line[0] == '\0') || ! (strcmp(utmpp->ut_user, "LOGIN") != 0)) continue; } #endif /* XPG4 */ dump(); } --- 755,766 ---- */ if (validtype[utmpp->ut_type]) { #ifdef XPG4 if (utmpp->ut_type == LOGIN_PROCESS) { if ((utmpp->ut_line[0] == '\0') || ! (strcmp(utmpp->ut_user, ! "LOGIN") != 0)) continue; } #endif /* XPG4 */ dump(); }