Change output format.

git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@1083 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
Johan Danielsson
1996-12-04 10:10:25 +00:00
parent 843a46159f
commit 3b3aeb9fb3

View File

@@ -1,65 +1,78 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <sys/time.h>
#include <krb5.h>
char*
stime(time_t t)
{
static char s[128];
strcpy(s, ctime(&t)+ 4);
s[15] = 0;
return s;
}
int
main (int argc, char **argv)
{
krb5_error_code err;
krb5_context context;
krb5_ccache ccache;
krb5_principal principal;
krb5_cc_cursor cursor;
krb5_creds creds;
char *str;
krb5_error_code err;
krb5_context context;
krb5_ccache ccache;
krb5_principal principal;
krb5_cc_cursor cursor;
krb5_creds creds;
char *str;
err = krb5_init_context (&context);
if (err)
abort ();
err = krb5_init_context (&context);
if (err)
abort ();
err = krb5_cc_default (context, &ccache);
if (err)
abort ();
err = krb5_cc_default (context, &ccache);
if (err)
abort ();
err = krb5_cc_get_principal (context, ccache, &principal);
if (err)
abort ();
err = krb5_cc_get_principal (context, ccache, &principal);
if (err)
abort ();
err = krb5_unparse_name (context, principal, &str);
if (err)
abort ();
err = krb5_unparse_name (context, principal, &str);
if (err)
abort ();
printf ("Principal: %s\n", str);
free (str);
printf ("\tPrincipal: %s\n\n", str);
free (str);
err = krb5_cc_start_seq_get (context, ccache, &cursor);
if (err)
abort ();
err = krb5_cc_start_seq_get (context, ccache, &cursor);
if (err)
abort ();
while (krb5_cc_next_cred (context,
ccache,
&creds,
&cursor) == 0) {
err = krb5_unparse_name (context, creds.server, &str);
if (err)
abort ();
printf ("%s\t", str);
free (str);
printf ("%s\t", ctime(&creds.times.authtime));
printf ("%s\n", ctime(&creds.times.endtime));
}
err = krb5_cc_end_seq_get (context, ccache, &cursor);
if (err)
return err;
while (krb5_cc_next_cred (context,
ccache,
&creds,
&cursor) == 0) {
printf ("%s ", stime(creds.times.authtime));
printf ("%s ", stime(creds.times.endtime));
err = krb5_unparse_name (context, creds.server, &str);
if (err)
abort ();
printf ("%s\n", str);
free (str);
}
err = krb5_cc_end_seq_get (context, ccache, &cursor);
if (err)
return err;
err = krb5_cc_close (context, ccache);
if (err)
abort ();
err = krb5_cc_close (context, ccache);
if (err)
abort ();
krb5_free_principal (principal);
krb5_free_principal (principal);
krb5_free_context (context);
return 0;
krb5_free_context (context);
return 0;
}