Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/crypto/dist/heimdal Check the return value of krb5_init_cont...



details:   https://anonhg.NetBSD.org/src/rev/cb46561c6ae9
branches:  trunk
changeset: 500871:cb46561c6ae9
user:      nathanw <nathanw%NetBSD.org@localhost>
date:      Tue Dec 19 21:31:11 2000 +0000

description:
Check the return value of krb5_init_context(), and bail out if it failed.

Also, when failing, don't try to use the non-initialized context value
to determine the error text.

This avoids dumping core in the following programs when /etc/krb5.conf is
missing or broken: klist, kdestroy, kpasswd, kadmin, kadmind, ktutil, kdc.

XXX Better error reporting in this failure case would be nice.

diffstat:

 crypto/dist/heimdal/admin/ktutil.c    |  6 ++++--
 crypto/dist/heimdal/kadmin/kadmin.c   |  6 ++++--
 crypto/dist/heimdal/kadmin/kadmind.c  |  6 ++++--
 crypto/dist/heimdal/kdc/main.c        |  6 ++++--
 crypto/dist/heimdal/kpasswd/kpasswd.c |  4 ++--
 crypto/dist/heimdal/kuser/kdestroy.c  |  4 ++--
 crypto/dist/heimdal/kuser/klist.c     |  4 ++--
 7 files changed, 22 insertions(+), 14 deletions(-)

diffs (155 lines):

diff -r 3b03cfdb0e24 -r cb46561c6ae9 crypto/dist/heimdal/admin/ktutil.c
--- a/crypto/dist/heimdal/admin/ktutil.c        Tue Dec 19 21:18:32 2000 +0000
+++ b/crypto/dist/heimdal/admin/ktutil.c        Tue Dec 19 21:31:11 2000 +0000
@@ -33,7 +33,7 @@
 
 #include "ktutil_locl.h"
 
-RCSID("$Id: ktutil.c,v 1.1.1.2 2000/08/02 19:58:04 assar Exp $");
+RCSID("$Id: ktutil.c,v 1.2 2000/12/19 21:31:11 nathanw Exp $");
 
 static int help_flag;
 static int version_flag;
@@ -129,7 +129,9 @@
     int optind = 0;
     krb5_error_code ret;
     set_progname(argv[0]);
-    krb5_init_context(&context);
+    ret = krb5_init_context(&context);
+    if (ret)
+       errx(1, "krb5_init_context failed: %u", ret);
     if(getarg(args, num_args, argc, argv, &optind))
        usage(1);
     if(help_flag)
diff -r 3b03cfdb0e24 -r cb46561c6ae9 crypto/dist/heimdal/kadmin/kadmin.c
--- a/crypto/dist/heimdal/kadmin/kadmin.c       Tue Dec 19 21:18:32 2000 +0000
+++ b/crypto/dist/heimdal/kadmin/kadmin.c       Tue Dec 19 21:31:11 2000 +0000
@@ -34,7 +34,7 @@
 #include "kadmin_locl.h"
 #include <sl.h>
 
-RCSID("$Id: kadmin.c,v 1.1.1.2 2000/08/02 19:58:51 assar Exp $");
+RCSID("$Id: kadmin.c,v 1.2 2000/12/19 21:31:11 nathanw Exp $");
 
 static char *config_file;
 static char *keyfile;
@@ -205,7 +205,9 @@
 
     set_progname(argv[0]);
 
-    krb5_init_context(&context);
+    ret = krb5_init_context(&context);
+    if (ret)
+       errx(1, "krb5_init_context failed: %u", ret);
 
     while((e = getarg(args, num_args, argc, argv, &optind)))
        errx(1, "error at argument `%s'", argv[optind]);
diff -r 3b03cfdb0e24 -r cb46561c6ae9 crypto/dist/heimdal/kadmin/kadmind.c
--- a/crypto/dist/heimdal/kadmin/kadmind.c      Tue Dec 19 21:18:32 2000 +0000
+++ b/crypto/dist/heimdal/kadmin/kadmind.c      Tue Dec 19 21:31:11 2000 +0000
@@ -33,7 +33,7 @@
 
 #include "kadmin_locl.h"
 
-RCSID("$Id: kadmind.c,v 1.2 2000/08/06 06:48:50 thorpej Exp $");
+RCSID("$Id: kadmind.c,v 1.3 2000/12/19 21:31:11 nathanw Exp $");
 
 static char *config_file;
 static char *keyfile;
@@ -95,7 +95,9 @@
 
     set_progname(argv[0]);
 
-    krb5_init_context(&context);
+    ret = krb5_init_context(&context);
+    if (ret)
+       errx(1, "krb5_init_context failed: %u", ret);
 
     ret = krb5_openlog(context, "kadmind", &logf);
     ret = krb5_set_warn_dest(context, logf);
diff -r 3b03cfdb0e24 -r cb46561c6ae9 crypto/dist/heimdal/kdc/main.c
--- a/crypto/dist/heimdal/kdc/main.c    Tue Dec 19 21:18:32 2000 +0000
+++ b/crypto/dist/heimdal/kdc/main.c    Tue Dec 19 21:31:11 2000 +0000
@@ -35,7 +35,7 @@
 
 #include <util.h>
 
-RCSID("$Id: main.c,v 1.2 2000/08/06 18:42:19 thorpej Exp $");
+RCSID("$Id: main.c,v 1.3 2000/12/19 21:31:11 nathanw Exp $");
 
 sig_atomic_t exit_flag = 0;
 krb5_context context;
@@ -52,7 +52,9 @@
     krb5_error_code ret;
     set_progname(argv[0]);
     
-    krb5_init_context(&context);
+    ret = krb5_init_context(&context);
+    if (ret)
+       errx(1, "krb5_init_context failed: %u", ret);
 
     configure(argc, argv);
 
diff -r 3b03cfdb0e24 -r cb46561c6ae9 crypto/dist/heimdal/kpasswd/kpasswd.c
--- a/crypto/dist/heimdal/kpasswd/kpasswd.c     Tue Dec 19 21:18:32 2000 +0000
+++ b/crypto/dist/heimdal/kpasswd/kpasswd.c     Tue Dec 19 21:31:11 2000 +0000
@@ -32,7 +32,7 @@
  */
 
 #include "kpasswd_locl.h"
-RCSID("$Id: kpasswd.c,v 1.1.1.2 2000/08/02 19:58:57 assar Exp $");
+RCSID("$Id: kpasswd.c,v 1.2 2000/12/19 21:31:11 nathanw Exp $");
 
 static int version_flag;
 static int help_flag;
@@ -87,7 +87,7 @@
 
     ret = krb5_init_context (&context);
     if (ret)
-       errx (1, "krb5_init_context: %s", krb5_get_err_text(context, ret));
+       errx(1, "krb5_init_context failed: %u", ret);
   
     if(argv[0]) {
        ret = krb5_parse_name (context, argv[0], &principal);
diff -r 3b03cfdb0e24 -r cb46561c6ae9 crypto/dist/heimdal/kuser/kdestroy.c
--- a/crypto/dist/heimdal/kuser/kdestroy.c      Tue Dec 19 21:18:32 2000 +0000
+++ b/crypto/dist/heimdal/kuser/kdestroy.c      Tue Dec 19 21:31:11 2000 +0000
@@ -32,7 +32,7 @@
  */
 
 #include "kuser_locl.h"
-RCSID("$Id: kdestroy.c,v 1.1.1.2 2000/08/02 19:58:58 assar Exp $");
+RCSID("$Id: kdestroy.c,v 1.2 2000/12/19 21:31:11 nathanw Exp $");
 
 static const char *cache;
 static int help_flag;
@@ -89,7 +89,7 @@
 
     ret = krb5_init_context (&context);
     if (ret)
-       errx (1, "krb5_init_context: %s", krb5_get_err_text(context, ret));
+       errx(1, "krb5_init_context failed: %u", ret);
   
     if(cache == NULL)
        cache = krb5_cc_default_name(context);
diff -r 3b03cfdb0e24 -r cb46561c6ae9 crypto/dist/heimdal/kuser/klist.c
--- a/crypto/dist/heimdal/kuser/klist.c Tue Dec 19 21:18:32 2000 +0000
+++ b/crypto/dist/heimdal/kuser/klist.c Tue Dec 19 21:31:11 2000 +0000
@@ -34,7 +34,7 @@
 #include "kuser_locl.h"
 #include "rtbl.h"
 
-RCSID("$Id: klist.c,v 1.1.1.2 2000/08/02 19:58:59 assar Exp $");
+RCSID("$Id: klist.c,v 1.2 2000/12/19 21:31:12 nathanw Exp $");
 
 static char*
 printable_time(time_t t)
@@ -526,7 +526,7 @@
 
     ret = krb5_init_context (&context);
     if (ret)
-       krb5_err(context, 1, ret, "krb5_init_context");
+       errx(1, "krb5_init_context failed: %u", ret);
 
     if(cred_cache) {
        ret = krb5_cc_resolve(context, cred_cache, &ccache);



Home | Main Index | Thread Index | Old Index