+Tue Sep 24 20:59:14 1996 Theodore Y. Ts'o <tytso@mit.edu>
+
+ * get_in_tkt.c (make_preauth_list): Correctly null-terminate the
+ preauth list generated by make_preauth_list.
+
+Thu Sep 19 12:29:59 1996 Theodore Y. Ts'o <tytso@mit.edu>
+
+ * unparse.c (krb5_unparse_name_ext): Make unparse correctly handle
+ a all cases where a principal contains a nulls, backspace,
+ newlines, or tabs.
+
+ * t_kerb.c (test_parse_principal): Add test for checking
+ krb5_parse_principal()
+
+ * parse.c (krb5_parse_name): Set all of the magic field values.
+
Wed Jul 24 17:09:39 1996 Theodore Y. Ts'o <tytso@mit.edu>
* preauth.c (find_pa_system): Change type of first argument to be
check-unix:: $(TEST_PROGS)
KRB5_CONFIG=$(srcdir)/t_krb5.conf ; export KRB5_CONFIG ;\
- $(RUN_SETUP) ./t_kerb 425_conv_principal rcmd e40-po ATHENA.MIT.EDU \
- 425_conv_principal rcmd mit ATHENA.MIT.EDU \
- 425_conv_principal rcmd lithium ATHENA.MIT.EDU \
- 425_conv_principal rcmd tweedledumb CYGNUS.COM \
- 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 \
+ $(RUN_SETUP) ./t_kerb \
+ parse_name tytso \
+ parse_name tytso@SHAZAAM \
+ parse_name tytso/root@VEGGIE.COM \
+ parse_name tytso/tuber/carrot@VEGGIE.COM \
+ parse_name tytso/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t \
+ parse_name tytso/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t@FOO \
+ parse_name tytso\\\\0/\\0@B\\n\\t\\\\GAG \
+ parse_name tytso/\\n/\\b\\t@B\\0hacky-test \
+ parse_name \\/slash/\\@atsign/octa\\/thorpe@\\/slash\\@at\\/sign \
+ 425_conv_principal rcmd e40-po ATHENA.MIT.EDU \
+ 425_conv_principal rcmd mit ATHENA.MIT.EDU \
+ 425_conv_principal rcmd lithium ATHENA.MIT.EDU \
+ 425_conv_principal rcmd tweedledumb CYGNUS.COM \
+ 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 \
> test.out
cmp test.out $(srcdir)/t_ref_kerb.out
$(RM) test.out
(*preauthp)->length = 0;
(*preauthp)->contents = 0;
}
+ *preauthp = NULL;
*ret_list = preauth_to_use;
return 0;
}
}
default_realm_size = strlen(default_realm);
}
- krb5_princ_realm(context, principal)->length = default_realm_size;
realmsize = default_realm_size;
}
/*
*/
for (i=0; i < components; i++)
krb5_princ_component(context, principal, i)->length = fcompsize[i];
- krb5_princ_realm(context, principal)->length = realmsize;
}
/*
* Now, we need to allocate the space for the strings themselves.....
krb5_xfree(principal);
return ENOMEM;
}
+ krb5_princ_set_realm_length(context, principal, realmsize);
krb5_princ_set_realm_data(context, principal, tmpdata);
for (i=0; i < components; i++) {
char *tmpdata =
return(ENOMEM);
}
krb5_princ_component(context, principal, i)->data = tmpdata;
+ krb5_princ_component(context, principal, i)->magic = KV5M_DATA;
}
/*
*/
krb5_princ_type(context, principal) = KRB5_NT_PRINCIPAL;
principal->magic = KV5M_PRINCIPAL;
+ principal->realm.magic = KV5M_DATA;
*nprincipal = principal;
return(0);
}
{
krb5_error_code retval;
krb5_principal princ;
+ char *out_name;
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);
+ retval = krb5_unparse_name(ctx, princ, &out_name);
+ if (retval) {
+ com_err("krb5_unparse_name", retval, 0);
+ return;
+ }
+ printf("425_converted principal(%s, %s, %s): '%s'\n",
+ name, inst, realm, out_name);
+ free(out_name);
krb5_free_principal(ctx, princ);
}
+void test_parse_name(ctx, name)
+ krb5_context ctx;
+ const char *name;
+{
+ krb5_error_code retval;
+ krb5_principal princ = 0, princ2 = 0;
+ char *outname = 0;
+
+ retval = krb5_parse_name(ctx, name, &princ);
+ if (retval) {
+ com_err("krb5_parse_name", retval, 0);
+ goto fail;
+ }
+ retval = krb5_copy_principal(ctx, princ, &princ2);
+ if (retval) {
+ com_err("krb5_copy_principal", retval, 0);
+ goto fail;
+ }
+ retval = krb5_unparse_name(ctx, princ2, &outname);
+ if (retval) {
+ com_err("krb5_unparse_name", retval, 0);
+ goto fail;
+ }
+ printf("parsed (and unparsed) principal(%s): ", name);
+ if (strcmp(name, outname) == 0)
+ printf("MATCH\n");
+ else
+ printf("'%s'\n", outname);
+fail:
+ if (outname)
+ free(outname);
+ if (princ)
+ krb5_free_principal(ctx, princ);
+ if (princ2)
+ krb5_free_principal(ctx, princ2);
+}
+
void usage(progname)
char *progname;
{
- fprintf(stderr, "%s: Usage: %s [425_conv_principal <name> <inst> <realm]\n",
+ fprintf(stderr, "%s: Usage: %s 425_conv_principal <name> <inst> <realm\n",
progname, progname);
+ fprintf(stderr, "\t%s parse_name <name>\n", progname);
exit(1);
}
if (!argc) usage(progname);
realm = *argv;
test_425_conv_principal(ctx, name, inst, realm);
- } else
+ } else if (strcmp(*argv, "parse_name") == 0) {
+ argc--; argv++;
+ if (!argc) usage(progname);
+ name = *argv;
+ test_parse_name(ctx, name);
+ }
+ else
usage(progname);
argc--; argv++;
}
-425_converted principal: 'host/e40-po.mit.edu@ATHENA.MIT.EDU'
-425_converted principal: 'host/mit.edu@ATHENA.MIT.EDU'
-425_converted principal: 'host/lithium.lcs.mit.edu@ATHENA.MIT.EDU'
-425_converted principal: 'host/tweedledumb.cygnus.com@CYGNUS.COM'
-425_converted principal: 'host/uunet.uu.net@UU.NET'
-425_converted principal: 'zephyr/zephyr@ATHENA.MIT.EDU'
-425_converted principal: 'kadmin/ATHENA.MIT.EDU@ATHENA.MIT.EDU'
+parsed (and unparsed) principal(tytso): 'tytso@ATHENA.MIT.EDU'
+parsed (and unparsed) principal(tytso@SHAZAAM): MATCH
+parsed (and unparsed) principal(tytso/root@VEGGIE.COM): MATCH
+parsed (and unparsed) principal(tytso/tuber/carrot@VEGGIE.COM): MATCH
+parsed (and unparsed) principal(tytso/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t): 'tytso/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t@ATHENA.MIT.EDU'
+parsed (and unparsed) principal(tytso/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t@FOO): MATCH
+parsed (and unparsed) principal(tytso\\0/\0@B\n\t\\GAG): MATCH
+parsed (and unparsed) principal(tytso/\n/\b\t@B\0hacky-test): MATCH
+parsed (and unparsed) principal(\/slash/\@atsign/octa\/thorpe@\/slash\@at\/sign): MATCH
+425_converted principal(rcmd, e40-po, ATHENA.MIT.EDU): 'host/e40-po.mit.edu@ATHENA.MIT.EDU'
+425_converted principal(rcmd, mit, ATHENA.MIT.EDU): 'host/mit.edu@ATHENA.MIT.EDU'
+425_converted principal(rcmd, lithium, ATHENA.MIT.EDU): 'host/lithium.lcs.mit.edu@ATHENA.MIT.EDU'
+425_converted principal(rcmd, tweedledumb, CYGNUS.COM): 'host/tweedledumb.cygnus.com@CYGNUS.COM'
+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'
switch (*cp) {
case COMPONENT_SEP:
case REALM_SEP:
- case '\0':
- *q++ = '\\';
- *q++ = *cp;
- break;
case '\\':
*q++ = '\\';
- *q++ = '\\';
+ *q++ = *cp;
break;
case '\t':
*q++ = '\\';
*q++ = '\\';
*q++ = 'b';
break;
+ case '\0':
+ *q++ = '\\';
+ *q++ = '0';
+ break;
default:
*q++ = *cp;
}
switch (*cp) {
case COMPONENT_SEP:
case REALM_SEP:
- case '\t':
case '\\':
*q++ = '\\';
*q++ = *cp;
break;
+ case '\t':
+ *q++ = '\\';
+ *q++ = 't';
+ break;
+ case '\n':
+ *q++ = '\\';
+ *q++ = 'n';
+ break;
+ case '\b':
+ *q++ = '\\';
+ *q++ = 'b';
+ break;
case '\0':
*q++ = '\\';
*q++ = '0';