CFLAGS = $(CCOPTS) $(DEFS) $(LOCALINCLUDE)
+RUN_SETUP = @KRB5_RUN_ENV@
PROG_LIBPATH=-L$(TOPLIBD) $(KRB4_LIBPATH)
PROG_RPATH=$(KRB5_LIBDIR)
-all:: krb5kdc
+all:: krb5kdc rtest
DEFINES = -DBACKWARD_COMPAT $(KRB4DEF)
replay.o \
kerberos_v4.o
+RT_OBJS= rtest.o \
+ kdc_util.o \
+ policy.o \
+ extern.o
+
depend:: kdc5_err.c
logger.c: $(SRCTOP)/lib/kadm5/logger.c
krb5kdc: $(OBJS) $(KADMSRV_DEPLIBS) $(KRB4COMPAT_DEPLIBS)
$(CC_LINK) -o krb5kdc $(OBJS) $(KADMSRV_LIBS) $(KRB4COMPAT_LIBS)
+rtest: $(RT_OBJS) $(KADM_COMM_DEPLIBS) $(KRB5_BASE_DEPLIBS)
+ $(CC_LINK) -o rtest $(RT_OBJS) $(KADM_COMM_LIBS) $(KRB5_BASE_LIBS)
+
+check-unix:: rtest
+ KRB5_CONFIG=$(SRCTOP)/config-files/krb5.conf ; export KRB5_CONFIG ;\
+ $(RUN_SETUP) $(srcdir)/rtscript > test.out
+ cmp test.out $(srcdir)/rtest.good
+ $(RM) test.out
+
install::
$(INSTALL_PROGRAM) krb5kdc ${DESTDIR}$(SERVER_BINDIR)/krb5kdc
$(INSTALL_DATA) $(srcdir)/krb5kdc.M ${DESTDIR}$(SERVER_MANDIR)/krb5kdc.8
clean::
- $(RM) kdc5_err.h kdc5_err.c krb5kdc logger.c
+ $(RM) kdc5_err.h kdc5_err.c krb5kdc logger.c rtest.o rtest
{
char *realm;
char *trans;
- char *otrans;
+ char *otrans, *otrans_ptr;
/* The following are for stepping through the transited field */
realm[krb5_princ_realm(kdc_context, tgs)->length] = '\0';
if (!(otrans = (char *) malloc(tgt_trans->length+1))) {
+ free(realm);
return(ENOMEM);
}
memcpy(otrans, tgt_trans->data, tgt_trans->length);
otrans[tgt_trans->length] = '\0';
-
- if (!(trans = (char *) malloc(strlen(realm) + strlen(otrans) + 1))) {
+ /* Keep track of start so we can free */
+ otrans_ptr = otrans;
+
+ /* +1 for null,
+ +1 for extra comma which may be added between
+ +1 for potential space when leading slash in realm */
+ if (!(trans = (char *) malloc(strlen(realm) + strlen(otrans) + 3))) {
+ free(realm);
+ free(otrans_ptr);
return(ENOMEM);
}
if (new_trans->data) free(new_trans->data);
new_trans->data = trans;
+ new_trans->length = 0;
+
+ trans[0] = '\0';
/* For the purpose of appending, the realm preceding the first */
/* realm in the transited field is considered the null realm */
new_trans->length = strlen(trans) + 1;
}
+ free(realm);
+ free(otrans_ptr);
return(0);
}
#include "k5-int.h"
#include <stdio.h>
#include "kdc_util.h"
+#include "extern.h"
+
+krb5_principal
+make_princ(ctx, str, prog)
+ krb5_context ctx;
+ const char *str;
+ const char *prog;
+{
+ krb5_principal ret;
+ char *dat;
+
+ if(!(ret = (krb5_principal) malloc(sizeof(krb5_principal_data)))) {
+ com_err(prog, ENOMEM, "while allocating principal data");
+ exit(3);
+ }
+ memset(ret, 0, sizeof(krb5_principal_data));
+
+ /* We do not include the null... */
+ if(!(dat = (char *) malloc(strlen(str)))) {
+ com_err(prog, ENOMEM, "while allocating principal realm data");
+ exit(3);
+ }
+ memcpy(dat, str, strlen(str));
+ krb5_princ_set_realm_data(ctx, ret, dat);
+ krb5_princ_set_realm_length(ctx, ret, strlen(str));
+
+ return ret;
+}
void
main(argc,argv)
{
krb5_data otrans;
krb5_data ntrans;
-
- krb5_data *tgnames[10];
- krb5_principal tgs = tgnames;
- krb5_data tgsrlm;
-
- krb5_data *cnames[10];
- krb5_principal cl = cnames;
- krb5_data crlm;
-
- krb5_data *snames[10];
- krb5_principal sv = snames;
- krb5_data srlm;
+ krb5_principal tgs, cl, sv;
+ krb5_error_code kret;
+ kdc_realm_t kdc_realm;
if (argc < 4) {
fprintf(stderr, "not enough args\n");
exit(1);
}
+
+
+ /* Get a context */
+ kret = krb5_init_context(&kdc_realm.realm_context);
+ if (kret) {
+ com_err(argv[0], kret, "while getting krb5 context");
+ exit(2);
+ }
+ /* Needed so kdc_context will work */
+ kdc_active_realm = &kdc_realm;
+
ntrans.length = 0;
- otrans.length = strlen(argv[1]) + 1;
+ ntrans.data = 0;
+
+ otrans.length = strlen(argv[1]);
otrans.data = (char *) malloc(otrans.length);
- strcpy(otrans.data,argv[1]);
-
- tgsrlm.length = strlen(argv[2]) + 1;
- tgsrlm.data = (char *) malloc(tgsrlm.length);
- strcpy(tgsrlm.data,argv[2]);
- tgs[0] = &tgsrlm;
-
- crlm.length = strlen(argv[3]) + 1;
- crlm.data = (char *) malloc(crlm.length);
- strcpy(crlm.data,argv[3]);
- cl[0] = &crlm;
-
- srlm.length = strlen(argv[4]) + 1;
- srlm.data = (char *) malloc(srlm.length);
- strcpy(srlm.data,argv[4]);
- sv[0] = &srlm;
+ memcpy(otrans.data,argv[1], otrans.length);
+
+ tgs = make_princ(kdc_context, argv[2], argv[0]);
+ cl = make_princ(kdc_context, argv[3], argv[0]);
+ sv = make_princ(kdc_context, argv[4], argv[0]);
add_to_transited(&otrans,&ntrans,tgs,cl,sv);
printf("%s\n",ntrans.data);
+ /* Free up all memory so we can profile for leaks */
+ free(otrans.data);
+ free(ntrans.data);
+
+ krb5_free_principal(kdc_realm.realm_context, tgs);
+ krb5_free_principal(kdc_realm.realm_context, cl);
+ krb5_free_principal(kdc_realm.realm_context, sv);
+ krb5_free_context(kdc_realm.realm_context);
+
+ exit(0);
}
-krb5_encrypt_block master_encblock;
+void krb5_klog_syslog() {}