Added new function krb5_set_principal_realm(), which is used to
authorTheodore Tso <tytso@mit.edu>
Wed, 19 Feb 1997 19:23:14 +0000 (19:23 +0000)
committerTheodore Tso <tytso@mit.edu>
Wed, 19 Feb 1997 19:23:14 +0000 (19:23 +0000)
mutate the realm of a principal.  This avoids a really heinous abstraction
boundary violation by the appl/bsd and appl/telnet code.

A test case for this function was added to t_kerb, and a test new test acse to
t_ref_kerb.out

git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@9916 dc483132-0cff-0310-8789-dd5450dbe970

src/lib/krb5/krb/ChangeLog
src/lib/krb5/krb/Makefile.in
src/lib/krb5/krb/t_kerb.c
src/lib/krb5/krb/t_ref_kerb.out

index 9b96516e16bf7981a3c4f309f34d62dc2cc9bde9..9d43b9c243d939b8aa01728429068fc6a0cf76b3 100644 (file)
@@ -1,3 +1,12 @@
+Wed Feb 19 14:21:12 1997  Theodore Y. Ts'o  <tytso@mit.edu>
+
+       * t_kerb.c (test_set_realm): New function used to test
+       krb5_set_principal_realm().  Called by using the new "set_realm"
+       command to t_kerb.
+
+       * set_realm.c (krb5_set_principal_realm): New function which sets
+               the realm of a principal.
+
 Thu Feb 13 14:17:00 1997  Richard Basch  <basch@lehman.com>
 
        * get_in_tkt.c (krb5_get_in_tkt): Initialize as_reply; if
index f81d495552dde0a12dde80bcce77048ff22204cd..c38d3d9b4fe6c1c6b4363b5c3a594d7c4f906944 100644 (file)
@@ -76,6 +76,7 @@ STLIBOBJS= \
        ser_key.o       \
        ser_princ.o     \
        serialize.o     \
+       set_realm.o     \
        srv_rcache.o    \
        str_conv.o      \
        tgtname.o       \
@@ -150,6 +151,7 @@ OBJS=       addr_comp.$(OBJEXT)     \
        ser_key.$(OBJEXT)       \
        ser_princ.$(OBJEXT)     \
        serialize.$(OBJEXT)     \
+       set_realm.$(OBJEXT)     \
        srv_rcache.$(OBJEXT)    \
        str_conv.$(OBJEXT)      \
        tgtname.$(OBJEXT)       \
@@ -225,6 +227,7 @@ SRCS=       $(srcdir)/addr_comp.c   \
        $(srcdir)/ser_key.c     \
        $(srcdir)/ser_princ.c   \
        $(srcdir)/serialize.c   \
+       $(srcdir)/set_realm.c   \
        $(srcdir)/srv_rcache.c  \
        $(srcdir)/str_conv.c    \
        $(srcdir)/tgtname.c     \
@@ -246,7 +249,7 @@ COMERRLIB=$(TOPLIBD)/libcom_err.a
 T_WALK_RTREE_OBJS= t_walk_rtree.o walk_rtree.o tgtname.o unparse.o \
        free_rtree.o bld_pr_ext.o 
 
-T_KERB_OBJS= t_kerb.o conv_princ.o unparse.o 
+T_KERB_OBJS= t_kerb.o conv_princ.o unparse.o set_realm.o
 
 T_SER_OBJS= t_ser.o ser_actx.o ser_adata.o ser_addr.o ser_auth.o ser_cksum.o \
        ser_ctx.o ser_eblk.o ser_key.o ser_princ.o serialize.o 
@@ -284,6 +287,7 @@ check-unix:: $(TEST_PROGS)
                425_conv_principal rcmd uunet UU.NET \
                425_conv_principal zephyr zephyr ATHENA.MIT.EDU \
                425_conv_principal kadmin ATHENA.MIT.EDU ATHENA.MIT.EDU \
+               set_realm marc@MIT.EDU CYGNUS.COM \
                > test.out
        cmp test.out $(srcdir)/t_ref_kerb.out
        $(RM) test.out
index 3a960b844ee0cb8df3d0117519a6e227f2f1aad4..310d0d1d9a87ce04c978b36436a34391a5cd0860 100644 (file)
@@ -76,12 +76,46 @@ fail:
                krb5_free_principal(ctx, princ2);
 }
 
+void test_set_realm(ctx, name, realm)
+       krb5_context ctx;
+       const char *name;
+       const char *realm;
+{
+       krb5_error_code retval;
+       krb5_principal  princ = 0;
+       char            *outname = 0;
+
+       retval = krb5_parse_name(ctx, name, &princ);
+       if (retval) {
+               com_err("krb5_parse_name", retval, 0);
+               goto fail;
+       }
+       retval = krb5_set_principal_realm(ctx, princ, realm);
+       if (retval) {
+               com_err("krb5_set_principal_realm", retval, 0);
+               goto fail;
+       }
+       retval = krb5_unparse_name(ctx, princ, &outname);
+       if (retval) {
+               com_err("krb5_unparse_name", retval, 0);
+               goto fail;
+       }
+       printf("old principal: %s, modified principal: %s\n", name,
+              outname);
+fail:
+       if (outname)
+               free(outname);
+       if (princ)
+               krb5_free_principal(ctx, princ);
+}
+
 void usage(progname)
        char    *progname;
 {
        fprintf(stderr, "%s: Usage: %s 425_conv_principal <name> <inst> <realm\n",
                progname, progname);
        fprintf(stderr, "\t%s parse_name <name>\n", progname);
+       fprintf(stderr, "\t%s set_realm <name> <realm>\n", progname);
        exit(1);
 }
 
@@ -123,6 +157,14 @@ main(argc, argv)
                  if (!argc) usage(progname);
                  name = *argv;
                  test_parse_name(ctx, name);
+         } else if (strcmp(*argv, "set_realm") == 0) {
+                 argc--; argv++;
+                 if (!argc) usage(progname);
+                 name = *argv;
+                 argc--; argv++;
+                 if (!argc) usage(progname);
+                 realm = *argv;
+                 test_set_realm(ctx, name, realm);
          }
          else
              usage(progname);
index d3a79827b297826262eedc9b436c34ea6c49c56b..9423944534ff08b22ed4d4c899234fc599896cc8 100644 (file)
@@ -14,3 +14,4 @@ parsed (and unparsed) principal(\/slash/\@atsign/octa\/thorpe@\/slash\@at\/sign)
 425_converted principal(rcmd, uunet, UU.NET): 'host/uunet.uu.net@UU.NET'
 425_converted principal(zephyr, zephyr, ATHENA.MIT.EDU): 'zephyr/zephyr@ATHENA.MIT.EDU'
 425_converted principal(kadmin, ATHENA.MIT.EDU, ATHENA.MIT.EDU): 'kadmin/ATHENA.MIT.EDU@ATHENA.MIT.EDU'
+old principal: marc@MIT.EDU, modified principal: marc@CYGNUS.COM