[192] in Kerberos-V5-bugs
changes to klist.c: improve output slightly.
daemon@ATHENA.MIT.EDU (Bill Sommerfeld)
Tue Aug 27 19:30:26 1991
Date: Tue, 27 Aug 91 19:22:21 EDT
From: sommerfeld@apollo.com (Bill Sommerfeld)
To: krb5-bugs@ATHENA.MIT.EDU
Cc: Joe Pato <pato@apollo.com>
The following patch to klist.c (relative to the beta-1 release)
improves the output formatting a bit.
a) Expired tickets (relative to the local clock) are reported as
EXPIRED, in large unfriendly letters.
b) Timestamp printing is collected into one procedure (better
modularity)
c) if the client name is the same as the default name, it's not
printed.
*** klist.c/MIT-beta1 Thu Jun 6 10:00:41 1991
--- klist.c/dce Tue Aug 27 18:51:06 1991
***************
*** 41,46 ****
--- 41,48 ----
extern char *optarg;
int show_flags = 0;
char *progname;
+ char *defname;
+ time_t now;
void
show_credential PROTOTYPE((krb5_creds *));
***************
*** 63,68 ****
--- 65,72 ----
krb5_init_ets();
+ time(&now);
+
if (strrchr(argv[0], '/'))
progname = strrchr(argv[0], '/')+1;
else
***************
*** 123,135 ****
com_err(progname, code, "while retrieving principal name");
exit(1);
}
! if (code = krb5_unparse_name(princ, &name)) {
com_err(progname, code, "while unparsing principal name");
exit(1);
}
printf("Ticket cache: %s\nDefault principal: %s\n",
! krb5_cc_get_name(cache), name);
! free(name);
if (code = krb5_cc_start_seq_get(cache, &cur)) {
com_err(progname, code, "while starting to retrieve tickets");
exit(1);
--- 127,138 ----
com_err(progname, code, "while retrieving principal name");
exit(1);
}
! if (code = krb5_unparse_name(princ, &defname)) {
com_err(progname, code, "while unparsing principal name");
exit(1);
}
printf("Ticket cache: %s\nDefault principal: %s\n",
! krb5_cc_get_name(cache), defname);
if (code = krb5_cc_start_seq_get(cache, &cur)) {
com_err(progname, code, "while starting to retrieve tickets");
exit(1);
***************
*** 197,202 ****
--- 200,220 ----
putchar(')');
}
+ void printtime(tv)
+ time_t tv;
+ {
+ struct tm *stime;
+ stime = localtime((time_t *)&tv);
+
+ printf("%02d/%02d/%02d:%02d:%02d:%02d",
+ stime->tm_year,
+ stime->tm_mon + 1,
+ stime->tm_mday,
+ stime->tm_hour,
+ stime->tm_min,
+ stime->tm_sec);
+ }
+
void
show_credential(cred)
register krb5_creds *cred;
***************
*** 203,209 ****
{
krb5_error_code retval;
char *name, *sname;
- struct tm *stime;
retval = krb5_unparse_name(cred->client, &name);
if (retval) {
--- 221,226 ----
***************
*** 216,250 ****
free(name);
return;
}
printf("C: %s\tS: %s\n\t", name, sname);
if (!cred->times.starttime)
cred->times.starttime = cred->times.authtime;
! stime = localtime((time_t *)&cred->times.starttime);
! printf("valid %02d/%02d/%02d:%02d:%02d:%02d to ",
! stime->tm_year,
! stime->tm_mon + 1,
! stime->tm_mday,
! stime->tm_hour,
! stime->tm_min,
! stime->tm_sec);
! stime = localtime((time_t *)&cred->times.endtime);
! printf("%02d/%02d/%02d:%02d:%02d:%02d",
! stime->tm_year,
! stime->tm_mon + 1,
! stime->tm_mday,
! stime->tm_hour,
! stime->tm_min,
! stime->tm_sec);
if (cred->times.renew_till) {
! stime = localtime((time_t *)&cred->times.renew_till);
! printf("\n\trenew until %02d/%02d/%02d:%02d:%02d:%02d",
! stime->tm_year,
! stime->tm_mon + 1,
! stime->tm_mday,
! stime->tm_hour,
! stime->tm_min,
! stime->tm_sec);
}
if (show_flags) {
fputs("\n\t",stdout);
--- 233,257 ----
free(name);
return;
}
+ if (strcmp(name, defname) == 0) {
+ printf("S: %s\n\t", sname);
+ } else {
printf("C: %s\tS: %s\n\t", name, sname);
+ }
if (!cred->times.starttime)
cred->times.starttime = cred->times.authtime;
!
! if (cred->times.endtime < now) {
! printf("EXPIRED; was ");
! }
! printf("valid ");
! printtime(cred->times.starttime);
! printf(" to ");
! printtime(cred->times.endtime);
if (cred->times.renew_till) {
! printf("\n\trenew until ");
! printtime(cred->times.renew_till);
}
if (show_flags) {
fputs("\n\t",stdout);