From: Ken Raeburn Date: Thu, 28 Jun 2001 12:35:20 +0000 (+0000) Subject: misc cleanup in dump-utmp X-Git-Tag: krb5-1.3-alpha1~1269 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=068249afb63d833e5dc6166fc95dedce99b855d7;p=krb5.git misc cleanup in dump-utmp git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@13525 dc483132-0cff-0310-8789-dd5450dbe970 --- diff --git a/src/util/pty/ChangeLog b/src/util/pty/ChangeLog index d598f954a..39797d41e 100644 --- a/src/util/pty/ChangeLog +++ b/src/util/pty/ChangeLog @@ -3,6 +3,13 @@ * 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 * libpty.h: Change variable line in prototype to tty_line to diff --git a/src/util/pty/dump-utmp.c b/src/util/pty/dump-utmp.c index 6847ac9bc..c72f5b5bc 100644 --- a/src/util/pty/dump-utmp.c +++ b/src/util/pty/dump-utmp.c @@ -89,7 +89,11 @@ print_ut(int all, const struct utmp *u) 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); @@ -113,7 +117,7 @@ print_ut(int all, const struct utmp *u) 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; @@ -194,10 +198,6 @@ main(int argc, char **argv) struct utmpx utx; #endif } u; - struct utmp *utp; -#ifdef UTMPX - struct utmpx *utxp; -#endif all = is_utmpx = do_getut = 0; recsize = sizeof(struct utmp); @@ -256,6 +256,7 @@ main(int argc, char **argv) if (is_utmpx) { #ifdef UTMPX #ifdef HAVE_UTMPXNAME + struct utmpx *utxp; utmpxname(fn); setutxent(); while ((utxp = getutxent()) != NULL) @@ -269,6 +270,7 @@ main(int argc, char **argv) #endif } else { #ifdef HAVE_UTMPNAME + struct utmp *utp; utmpname(fn); setutxent(); while ((utp = getutent()) != NULL)