From e82bc5223192fc2a7270aec53aed951ba4a24cae Mon Sep 17 00:00:00 2001 From: Alf Wachsmann Date: Fri, 20 Aug 2004 05:05:14 +0000 Subject: [PATCH] kdb-enhancement-20040820 FIXES 6355 - It resolves all IP addresses to names unless the "-numeric" parameter is used. This is the same behavior as "fs listcells [-numeric]" - If the "-numeric" parameter is used, IP address will be printed in dotted decimal form instead of a 8 digit hex string. - A new parameter "-long" allows to print all information for all entries in the log. This is the same info you get for entry XYZ when called with "-key XYZ" only you get this for _all_ keys. The output is slow if not also called together with "-numeric --- src/kauth/kdb.c | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/src/kauth/kdb.c b/src/kauth/kdb.c index 875d877..de5aab4 100644 --- a/src/kauth/kdb.c +++ b/src/kauth/kdb.c @@ -50,7 +50,31 @@ cmdproc(register struct cmd_syndesc *as, afs_int32 arock) printf("Printing all entries found in %s\n", dbmfile); for (key = dbm_firstkey(kdb); key.dptr; key = afs_dbm_nextkey(kdb, key), cnt++) { - printf("\t%s\n", key.dptr); + if (as->parms[2].items) { + data = dbm_fetch(kdb, key); + if (!data.dptr) { + fprintf(stderr, "%s: no entry exists\n", ti->data); + continue; + } + if (data.dsize != sizeof(kalog_elt)) { + fprintf(stderr, "%s: data came out corrupt\n", ti->data); + continue; + } + memcpy(&rdata, data.dptr, sizeof(kalog_elt)); + if (! as->parms[3].items) { + char *hostName; + hostName = hostutil_GetNameByINet(rdata.host); + printf("%s: last operation from host %s at %s", key.dptr, + hostName, ctime(&rdata.last_use)); + } else { + char *hostIP; + hostIP = afs_inet_ntoa(rdata.host); + printf("%s: last operation from host %s at %s", key.dptr, + hostIP, ctime(&rdata.last_use)); + } + } else { + printf("\t%s\n", key.dptr); + } } printf("%d entries were found\n", cnt); } else { @@ -91,6 +115,8 @@ main(int argc, char **argv) cmd_AddParm(ts, "-dbmfile", CMD_SINGLE, CMD_OPTIONAL, dbmfile_help); cmd_AddParm(ts, "-key", CMD_SINGLE, CMD_OPTIONAL, "extract entries that match specified key"); + cmd_AddParm(ts, "-long", CMD_FLAG, CMD_OPTIONAL, "print long info for each entry"); + cmd_AddParm(ts, "-numeric", CMD_FLAG, CMD_OPTIONAL, "addresses only"); code = cmd_Dispatch(argc, argv); return code; } -- 1.9.4