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 */
*** 67,90 ****
#include <sys/loadavg.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
--- 69,88 ----
#include <sys/loadavg.h>
#include <limits.h>
#include <priv_utils.h>
/*
! * Use the full lengths from utmpx for user and line.
*/
static struct utmpx dummy;
#define NMAX (sizeof (dummy.ut_user))
#define LMAX (sizeof (dummy.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
*** 481,501 ****
continue;
if (sel_user && strncmp(ut->ut_name, sel_user, NMAX) != 0)
continue; /* we're looking for somebody else */
/* print login name of the user */
! PRINTF(("%-*.*s ", NMAX, NMAX, ut->ut_name));
/* print tty user is on */
if (lflag) {
! PRINTF(("%-*.*s", LMAX, LMAX, ut->ut_line));
} else {
if (ut->ut_line[0] == 'p' && ut->ut_line[1] == 't' &&
ut->ut_line[2] == 's' && ut->ut_line[3] == '/') {
PRINTF(("%-*.3s", LMAX, &ut->ut_line[4]));
} else {
! PRINTF(("%-*.*s", LMAX, LMAX, ut->ut_line));
}
}
/* print when the user logged in */
if (lflag) {
--- 479,500 ----
continue;
if (sel_user && strncmp(ut->ut_name, sel_user, NMAX) != 0)
continue; /* we're looking for somebody else */
/* print login name of the user */
! PRINTF(("%-*.*s ", LOGIN_WIDTH, NMAX, ut->ut_name));
/* print tty user is on */
if (lflag) {
! PRINTF(("%-*.*s", LINE_WIDTH, LMAX, ut->ut_line));
} else {
if (ut->ut_line[0] == 'p' && ut->ut_line[1] == 't' &&
ut->ut_line[2] == 's' && ut->ut_line[3] == '/') {
PRINTF(("%-*.3s", LMAX, &ut->ut_line[4]));
} else {
! PRINTF(("%-*.*s", LINE_WIDTH, LMAX,
! ut->ut_line));
}
}
/* print when the user logged in */
if (lflag) {