From 714dd892def958d93d43da6d0f056b6fcf86db3d Mon Sep 17 00:00:00 2001 From: Tom Yu Date: Tue, 17 Oct 2000 03:17:55 +0000 Subject: [PATCH] * kadmin.c (strdur): Print negative durations somewhat (!) sanely. (kadmin_startup): Call krb5_klog_init() to avoid coredumping if kadm5_init() logs something via krb5_klog_syslog(). git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@12764 dc483132-0cff-0310-8789-dd5450dbe970 --- src/kadmin/cli/ChangeLog | 7 +++++++ src/kadmin/cli/kadmin.c | 19 ++++++++++++++++--- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/src/kadmin/cli/ChangeLog b/src/kadmin/cli/ChangeLog index d5d16ef8a..509a7a422 100644 --- a/src/kadmin/cli/ChangeLog +++ b/src/kadmin/cli/ChangeLog @@ -1,3 +1,10 @@ +2000-10-16 Tom Yu + + * kadmin.c (strdur): Print negative durations somewhat (!) + sanely. + (kadmin_startup): Call krb5_klog_init() to avoid coredumping if + kadm5_init() logs something via krb5_klog_syslog(). + 2000-10-03 Ezra Peisach * kadmin.c (kadmin_getpol): Change format strings from %d to %ld diff --git a/src/kadmin/cli/kadmin.c b/src/kadmin/cli/kadmin.c index c7a001d63..948a71188 100644 --- a/src/kadmin/cli/kadmin.c +++ b/src/kadmin/cli/kadmin.c @@ -104,8 +104,13 @@ char *strdur(duration) time_t duration; { static char out[50]; - int days, hours, minutes, seconds; - + int neg, days, hours, minutes, seconds; + + if (duration < 0) { + duration *= -1; + neg = 1; + } else + neg = 0; days = duration / (24 * 3600); duration %= 24 * 3600; hours = duration / 3600; @@ -113,7 +118,8 @@ char *strdur(duration) minutes = duration / 60; duration %= 60; seconds = duration; - sprintf(out, "%d %s %02d:%02d:%02d", days, days == 1 ? "day" : "days", + sprintf(out, "%s%d %s %02d:%02d:%02d", neg ? "-" : "", + days, days == 1 ? "day" : "days", hours, minutes, seconds); return out; } @@ -378,6 +384,12 @@ char *kadmin_startup(argc, argv) } } + retval = krb5_klog_init(context, "admin_server", whoami, 0); + if (retval) { + com_err(whoami, retval, "while setting up logging"); + exit(1); + } + /* * Initialize the kadm5 connection. If we were given a ccache, * use it. Otherwise, use/prompt for the password. @@ -456,6 +468,7 @@ int quit() } /* insert more random cleanup here */ + krb5_klog_close(context); krb5_free_context(context); return 0; } -- 2.26.2