diff options
author | Ken Raeburn <raeburn@mit.edu> | 2001-06-28 12:35:20 +0000 |
---|---|---|
committer | Ken Raeburn <raeburn@mit.edu> | 2001-06-28 12:35:20 +0000 |
commit | 068249afb63d833e5dc6166fc95dedce99b855d7 (patch) | |
tree | 17df4589abdd60daa6178e0d58038b9619ddbe39 /src/util/pty | |
parent | 31a93cf9b57145b1cf92119d736247aa832340f2 (diff) | |
download | krb5-068249afb63d833e5dc6166fc95dedce99b855d7.tar.gz krb5-068249afb63d833e5dc6166fc95dedce99b855d7.tar.xz krb5-068249afb63d833e5dc6166fc95dedce99b855d7.zip |
misc cleanup in dump-utmp
git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@13525 dc483132-0cff-0310-8789-dd5450dbe970
Diffstat (limited to 'src/util/pty')
-rw-r--r-- | src/util/pty/ChangeLog | 7 | ||||
-rw-r--r-- | src/util/pty/dump-utmp.c | 12 |
2 files changed, 14 insertions, 5 deletions
diff --git a/src/util/pty/ChangeLog b/src/util/pty/ChangeLog index d598f954a4..39797d41ef 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 <epeisach@mit.edu> * 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 6847ac9bce..c72f5b5bc5 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) |