* update_utmp.c (pty_update_utmp): Don't copy host if it's a null
pointer.
+ * dump-utmp.c (print_ut): Use size of ut_name field, not ut_user,
+ which may not exist, for width when printing ut_name field value.
+ Specify width when printing hostname, it may be unterminated.
+ (main): Move utp and utxp declarations closer to their usages, and
+ make both conditionalized so they're not declared if they're not
+ used.
+
2001-06-21 Ezra Peisach <epeisach@mit.edu>
* libpty.h: Change variable line in prototype to tty_line to
return;
#endif
+#ifdef HAVE_STRUCT_UTMP_UT_USER
lu = sizeof(u->ut_user);
+#else
+ lu = sizeof(u->ut_name);
+#endif
ll = sizeof(u->ut_line);
printf("%-*.*s:", lu, lu, u->ut_name);
printf("%-*.*s:", ll, ll, u->ut_line);
printf(" %s", ctime(&u->ut_time) + 4);
#ifdef HAVE_STRUCT_UTMP_UT_HOST
if (u->ut_host[0])
- printf(" %s\n", u->ut_host);
+ printf(" %.*s\n", (int) sizeof(u->ut_host), u->ut_host);
#endif
return;
struct utmpx utx;
#endif
} u;
- struct utmp *utp;
-#ifdef UTMPX
- struct utmpx *utxp;
-#endif
all = is_utmpx = do_getut = 0;
recsize = sizeof(struct utmp);
if (is_utmpx) {
#ifdef UTMPX
#ifdef HAVE_UTMPXNAME
+ struct utmpx *utxp;
utmpxname(fn);
setutxent();
while ((utxp = getutxent()) != NULL)
#endif
} else {
#ifdef HAVE_UTMPNAME
+ struct utmp *utp;
utmpname(fn);
setutxent();
while ((utp = getutent()) != NULL)