aboutsummaryrefslogtreecommitdiff
path: root/src/lib/krb5/krb/t_kerb.c
diff options
context:
space:
mode:
authorTheodore Tso <tytso@mit.edu>1995-05-05 04:56:00 +0000
committerTheodore Tso <tytso@mit.edu>1995-05-05 04:56:00 +0000
commit4f899d27fe46faddbb527ca4ab9c40bbc2d16f54 (patch)
treed7e29a3caf0ab7002d45cbd070353f264089a32e /src/lib/krb5/krb/t_kerb.c
parent42848b7219afc576f0550f5cbe9f6706d72ff6ac (diff)
downloadkrb5-4f899d27fe46faddbb527ca4ab9c40bbc2d16f54.zip
krb5-4f899d27fe46faddbb527ca4ab9c40bbc2d16f54.tar.gz
krb5-4f899d27fe46faddbb527ca4ab9c40bbc2d16f54.tar.bz2
conv_princ.c (krb5_425_conv_principal): Use new calling
convention of krb5_get_realm_domain, which is that it returns the realm *without* the leading dot. Also use the profile code to look up individual instance conversions using [realms]/<realm>/v4_instance_convert/<inst> This allows special case handling of mit.edu and lithium.lcs.mit.edu. t_kerb.c: New file for testing krb library functions. Currently only tests krb5_425_conv_principal. git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@5726 dc483132-0cff-0310-8789-dd5450dbe970
Diffstat (limited to 'src/lib/krb5/krb/t_kerb.c')
-rw-r--r--src/lib/krb5/krb/t_kerb.c85
1 files changed, 85 insertions, 0 deletions
diff --git a/src/lib/krb5/krb/t_kerb.c b/src/lib/krb5/krb/t_kerb.c
new file mode 100644
index 0000000..f2dcf8a
--- /dev/null
+++ b/src/lib/krb5/krb/t_kerb.c
@@ -0,0 +1,85 @@
+/*
+ * This driver routine is used to test many of the standard Kerberos library
+ * routines.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+
+#include "com_err.h"
+#include "krb5.h"
+
+
+void test_425_conv_principal(ctx, name, inst, realm)
+ krb5_context ctx;
+ char *name, *inst, *realm;
+{
+ krb5_error_code retval;
+ krb5_principal princ;
+
+ retval = krb5_425_conv_principal(ctx, name, inst, realm, &princ);
+ if (retval) {
+ com_err("krb5_425_conv_principal", retval, 0);
+ return;
+ }
+ retval = krb5_unparse_name(ctx, princ, &name);
+ printf("425_converted principal: '%s'\n", name);
+ free(name);
+ krb5_free_principal(ctx, princ);
+}
+
+void usage(progname)
+ char *progname;
+{
+ fprintf(stderr, "%s: Usage: %s [425_conv_principal <name> <inst> <realm]\n",
+ progname, progname);
+ exit(1);
+}
+
+int
+main(argc, argv)
+ int argc;
+ char **argv;
+{
+ krb5_context ctx;
+ krb5_error_code retval;
+ char *progname;
+ char *name, *inst, *realm;
+
+ retval = krb5_init_context(&ctx);
+ if (retval) {
+ fprintf(stderr, "krb5_init_context returned error %ld\n",
+ retval);
+ exit(1);
+ }
+ krb5_init_ets(ctx);
+ progname = argv[0];
+
+ /* Parse arguments. */
+ argc--; argv++;
+ while (argc) {
+ if (strcmp(*argv, "425_conv_principal") == 0) {
+ argc--; argv++;
+ if (!argc) usage(progname);
+ name = *argv;
+ argc--; argv++;
+ if (!argc) usage(progname);
+ inst = *argv;
+ argc--; argv++;
+ if (!argc) usage(progname);
+ realm = *argv;
+ test_425_conv_principal(ctx, name, inst, realm);
+ } else
+ usage(progname);
+ argc--; argv++;
+ }
+
+ krb5_free_context(ctx);
+
+ return 0;
+}