* t_ser.c - Test serialization.
*/
#include "k5-int.h"
+#include "com_err.h"
#include "auth_con.h"
+#include <ctype.h>
+
static const char stuff[]="You can't take a pointer to a function and convert \
it to a pointer to char; ANSI doesn't say it'll work, and in fact on the HPPA \
you can lose some bits of the function pointer, and get a pointer that you \
krb5_pointer nctx;
krb5_octet *outrep, *ibuf, *outrep2;
size_t outlen, ilen, outlen2;
- int i, j;
/* Initialize context and initialize all Kerberos serializers */
- krb5_init_context(&ser_ctx);
+ if ((kret = krb5_init_context(&ser_ctx))) {
+ printf("Couldn't initialize krb5 library: %s\n",
+ error_message(kret));
+ exit(1);
+ }
krb5_ser_context_init(ser_ctx);
krb5_ser_db_context_init(ser_ctx);
krb5_ser_auth_context_init(ser_ctx);
&ilen);
if (!kret) {
if (ilen)
- printf("%s: %d bytes left over after internalize\n", ilen);
+ printf("%s: %d bytes left over after internalize\n",
+ msg, ilen);
/* Now attempt to re-externalize it */
kret = krb5_externalize_data(ser_ctx, nctx, &outrep2, &outlen2);
if (!kret) {
sprintf(ccname, "STDIO:temp_cc_%d", getpid());
sprintf(princname, "xxx%d/i%d@this.is.a.test",
getpid(), getpid());
- if (kret = krb5_cc_resolve(kcontext, ccname, &ccache))
+ if ((kret = krb5_cc_resolve(kcontext, ccname, &ccache)))
kret = krb5_cc_register(kcontext, &krb5_scc_ops, 1);
if (!kret &&
!(kret = krb5_cc_resolve(kcontext, ccname, &ccache)) &&
(krb5_pointer) keytab, KV5M_KEYTAB)) &&
!(kret = krb5_kt_close(kcontext, keytab))) {
sprintf(ccname, "WRFILE:temp_kt_%d", getpid());
- if (kret = krb5_kt_resolve(kcontext, ccname, &keytab))
+ if ((kret = krb5_kt_resolve(kcontext, ccname, &keytab)))
kret = krb5_kt_register(kcontext, &krb5_ktf_writable_ops);
if (!kret &&
!(kret = krb5_kt_resolve(kcontext, ccname, &keytab)) &&
int verbose;
int option;
extern char *optarg;
+ char ch_err;
kret = 0;
verbose = 0;
do_xtest = 1;
break;
default:
- kret = EINVAL;
+ fprintf(stderr,
+ "%s: usage is %s [-acekprsxvACEKPRSX]\n",
+ argv[0], argv[0]);
+ exit(1);
break;
}
}
- if (!kret) {
- if (!(kret = krb5_init_context(&kcontext))) {
- if (!kret && do_xtest)
- kret = ser_kcontext_test(kcontext, verbose);
- if (!kret && do_atest)
- kret = ser_acontext_test(kcontext, verbose);
- if (!kret && do_ctest)
- kret = ser_ccache_test(kcontext, verbose);
- if (!kret && do_ktest)
- kret = ser_keytab_test(kcontext, verbose);
- if (!kret && do_rtest)
- kret = ser_rcache_test(kcontext, verbose);
- if (!kret && do_etest)
- kret = ser_eblock_test(kcontext, verbose);
- if (!kret && do_ptest)
- kret = ser_princ_test(kcontext, verbose);
- if (!kret && do_stest)
- kret = ser_cksum_test(kcontext, verbose);
- krb5_free_context(kcontext);
- }
+ if ((kret = krb5_init_context(&kcontext))) {
+ com_err(argv[0], kret, "while initializing krb5");
+ exit(1);
}
- else
- printf("%s: usage is %s [-acekprsxvACEKPRSX]\n", argv[0], argv[0]);
- if(kret && verbose) {
- com_err(argv[0], kret, "-- test failed ---");
+
+ if (do_xtest) {
+ ch_err = 'x';
+ kret = ser_kcontext_test(kcontext, verbose);
+ if (kret)
+ goto fail;
+ }
+ if (do_atest) {
+ ch_err = 'a';
+ kret = ser_acontext_test(kcontext, verbose);
+ if (kret)
+ goto fail;
+ }
+ if (do_ctest) {
+ ch_err = 'c';
+ kret = ser_ccache_test(kcontext, verbose);
+ if (kret)
+ goto fail;
+ }
+ if (do_ktest) {
+ ch_err = 'k';
+ kret = ser_keytab_test(kcontext, verbose);
+ if (kret)
+ goto fail;
+ }
+ if (do_rtest) {
+ ch_err = 'r';
+ kret = ser_rcache_test(kcontext, verbose);
+ if (kret)
+ goto fail;
+ }
+ if (do_etest) {
+ ch_err = 'e';
+ kret = ser_eblock_test(kcontext, verbose);
+ if (kret)
+ goto fail;
+ }
+ if (do_ptest) {
+ ch_err = 'p';
+ kret = ser_princ_test(kcontext, verbose);
+ if (kret)
+ goto fail;
+ }
+ if (do_stest) {
+ ch_err = 's';
+ kret = ser_cksum_test(kcontext, verbose);
+ if (kret)
+ goto fail;
}
- return((kret) ? 1 : 0);
+ krb5_free_context(kcontext);
+
+ exit(0);
+fail:
+ com_err(argv[0], kret, "--- test %cfailed", ch_err);
+ exit(1);
}