Print this page
2989 Eliminate use of LOGNAME_MAX in ON
1166 useradd have warning with name more 8 chars
*** 17,26 ****
--- 17,28 ----
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
+ * Copyright (c) 2013 Gary Mills
+ *
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
*** 66,89 ****
#include <unistd.h>
#include <limits.h>
#include <priv_utils.h>
/*
! * 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 */
! static struct utmpx dummy;
! #define NMAX (sizeof (dummy.ut_user))
! #define LMAX (sizeof (dummy.ut_line))
! #endif /* UTMPX_NAMELEN */
#define DIV60(t) ((t+30)/60) /* x/60 rounded */
#ifdef ERR
#undef ERR
#endif
--- 68,86 ----
#include <unistd.h>
#include <limits.h>
#include <priv_utils.h>
/*
! * Use the full lengths from utmpx for user and line.
*/
! #define NMAX (sizeof (((struct utmpx *)0)->ut_user))
! #define LMAX (sizeof (((struct utmpx *)0)->ut_line))
+ /* Print minimum field widths. */
+ #define LOGIN_WIDTH 8
+ #define LINE_WIDTH 12
+
#define DIV60(t) ((t+30)/60) /* x/60 rounded */
#ifdef ERR
#undef ERR
#endif
*** 471,484 ****
continue;
if (sel_user && strncmp(ut->ut_name, sel_user, NMAX) != 0)
continue; /* we're looking for somebody else */
if (lflag) { /* -l flag format (w command) */
/* print login name of the user */
! (void) printf("%-*.*s ", NMAX, NMAX, ut->ut_name);
/* print tty user is on */
! (void) printf("%-*.*s", LMAX, LMAX, ut->ut_line);
/* print when the user logged in */
tim = ut->ut_xtime;
(void) prtat(&tim);
--- 468,483 ----
continue;
if (sel_user && strncmp(ut->ut_name, sel_user, NMAX) != 0)
continue; /* we're looking for somebody else */
if (lflag) { /* -l flag format (w command) */
/* print login name of the user */
! (void) printf("%-*.*s ", LOGIN_WIDTH, (int)NMAX,
! ut->ut_name);
/* print tty user is on */
! (void) printf("%-*.*s", LINE_WIDTH, (int)LMAX,
! ut->ut_line);
/* print when the user logged in */
tim = ut->ut_xtime;
(void) prtat(&tim);
*** 492,503 ****
showtotals(findhash((pid_t)ut->ut_pid));
} else { /* standard whodo format */
tim = ut->ut_xtime;
tm = localtime(&tim);
(void) printf("\n%-*.*s %-*.*s %2.1d:%2.2d\n",
! LMAX, LMAX, ut->ut_line,
! NMAX, NMAX, ut->ut_name, tm->tm_hour, tm->tm_min);
showproc(findhash((pid_t)ut->ut_pid));
}
}
return (0);
--- 491,503 ----
showtotals(findhash((pid_t)ut->ut_pid));
} else { /* standard whodo format */
tim = ut->ut_xtime;
tm = localtime(&tim);
(void) printf("\n%-*.*s %-*.*s %2.1d:%2.2d\n",
! LINE_WIDTH, (int)LMAX, ut->ut_line,
! LOGIN_WIDTH, (int)NMAX, ut->ut_name, tm->tm_hour,
! tm->tm_min);
showproc(findhash((pid_t)ut->ut_pid));
}
}
return (0);
*** 518,531 ****
if (up->p_state == VISITED) /* we already been here */
return;
/* print the data for this process */
if (up->p_state == ZOMBIE)
(void) printf(" %-*.*s %5d %4.1ld:%2.2ld %s\n",
! LMAX, LMAX, " ?", (int)up->p_upid, 0L, 0L, "<defunct>");
else if (up->p_state != NONE) {
(void) printf(" %-*.*s %5d %4.1ld:%2.2ld %s\n",
! LMAX, LMAX, getty(up->p_ttyd), (int)up->p_upid,
up->p_time / 60L, up->p_time % 60L,
up->p_comm);
}
up->p_state = VISITED;
--- 518,532 ----
if (up->p_state == VISITED) /* we already been here */
return;
/* print the data for this process */
if (up->p_state == ZOMBIE)
(void) printf(" %-*.*s %5d %4.1ld:%2.2ld %s\n",
! LINE_WIDTH, (int)LMAX, " ?", (int)up->p_upid, 0L, 0L,
! "<defunct>");
else if (up->p_state != NONE) {
(void) printf(" %-*.*s %5d %4.1ld:%2.2ld %s\n",
! LINE_WIDTH, (int)LMAX, getty(up->p_ttyd), (int)up->p_upid,
up->p_time / 60L, up->p_time % 60L,
up->p_comm);
}
up->p_state = VISITED;