From 7a5f79fb6c8b8d8be7b36b034a42c0f52779b50f Mon Sep 17 00:00:00 2001 From: Theodore Tso Date: Wed, 19 Feb 1997 19:23:14 +0000 Subject: [PATCH] Added new function krb5_set_principal_realm(), which is used to 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 | 9 +++++++ src/lib/krb5/krb/Makefile.in | 6 ++++- src/lib/krb5/krb/t_kerb.c | 42 +++++++++++++++++++++++++++++++++ src/lib/krb5/krb/t_ref_kerb.out | 1 + 4 files changed, 57 insertions(+), 1 deletion(-) diff --git a/src/lib/krb5/krb/ChangeLog b/src/lib/krb5/krb/ChangeLog index 9b96516e1..9d43b9c24 100644 --- a/src/lib/krb5/krb/ChangeLog +++ b/src/lib/krb5/krb/ChangeLog @@ -1,3 +1,12 @@ +Wed Feb 19 14:21:12 1997 Theodore Y. Ts'o + + * 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 * get_in_tkt.c (krb5_get_in_tkt): Initialize as_reply; if diff --git a/src/lib/krb5/krb/Makefile.in b/src/lib/krb5/krb/Makefile.in index f81d49555..c38d3d9b4 100644 --- a/src/lib/krb5/krb/Makefile.in +++ b/src/lib/krb5/krb/Makefile.in @@ -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 diff --git a/src/lib/krb5/krb/t_kerb.c b/src/lib/krb5/krb/t_kerb.c index 3a960b844..310d0d1d9 100644 --- a/src/lib/krb5/krb/t_kerb.c +++ b/src/lib/krb5/krb/t_kerb.c @@ -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 \n", progname); + fprintf(stderr, "\t%s set_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); diff --git a/src/lib/krb5/krb/t_ref_kerb.out b/src/lib/krb5/krb/t_ref_kerb.out index d3a79827b..942394453 100644 --- a/src/lib/krb5/krb/t_ref_kerb.out +++ b/src/lib/krb5/krb/t_ref_kerb.out @@ -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 -- 2.26.2