/* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */1/* kdc/rtest.c */2/*3* Copyright 1991 by the Massachusetts Institute of Technology.4* All Rights Reserved.5*6* Export of this software from the United States of America may7* require a specific license from the United States Government.8* It is the responsibility of any person or organization contemplating9* export to obtain such a license before exporting.10*11* WITHIN THAT CONSTRAINT, permission to use, copy, modify, and12* distribute this software and its documentation for any purpose and13* without fee is hereby granted, provided that the above copyright14* notice appear in all copies and that both that copyright notice and15* this permission notice appear in supporting documentation, and that16* the name of M.I.T. not be used in advertising or publicity pertaining17* to distribution of the software without specific, written prior18* permission. Furthermore if you modify this software you must label19* your software as modified software and not distribute it in such a20* fashion that it might be confused with the original M.I.T. software.21* M.I.T. makes no representations about the suitability of22* this software for any purpose. It is provided "as is" without express23* or implied warranty.24*/2526#include "k5-int.h"27#include <stdio.h>28#include "kdc_util.h"29#include "extern.h"3031void krb5_klog_syslog(void);3233static krb5_principal34make_princ(krb5_context ctx, const char *str, const char *prog)35{36krb5_principal ret;37char *dat;3839if(!(ret = (krb5_principal) malloc(sizeof(krb5_principal_data)))) {40com_err(prog, ENOMEM, "while allocating principal data");41exit(3);42}43memset(ret, 0, sizeof(krb5_principal_data));4445/* We do not include the null... */46if(!(dat = (char *) malloc(strlen(str)))) {47com_err(prog, ENOMEM, "while allocating principal realm data");48exit(3);49}50memcpy(dat, str, strlen(str));51krb5_princ_set_realm_data(ctx, ret, dat);52krb5_princ_set_realm_length(ctx, ret, strlen(str));5354return ret;55}5657int58main(int argc, char **argv)59{60krb5_data otrans;61krb5_data ntrans;62krb5_principal tgs, cl, sv;63krb5_error_code kret;64krb5_context ctx;6566if (argc < 4) {67fprintf(stderr, "not enough args\n");68exit(1);69}707172/* Get a context */73kret = krb5int_init_context_kdc(&ctx);74if (kret) {75com_err(argv[0], kret, "while getting krb5 context");76exit(2);77}7879ntrans.length = 0;80ntrans.data = 0;8182otrans.length = strlen(argv[1]);83if (otrans.length)84otrans.data = (char *) malloc(otrans.length);85else86otrans.data = 0;87memcpy(otrans.data,argv[1], otrans.length);8889tgs = make_princ(ctx, argv[2], argv[0]);90cl = make_princ(ctx, argv[3], argv[0]);91sv = make_princ(ctx, argv[4], argv[0]);9293add_to_transited(&otrans,&ntrans,tgs,cl,sv);9495printf("%s\n",ntrans.data);9697/* Free up all memory so we can profile for leaks */98if (otrans.data)99free(otrans.data);100free(ntrans.data);101102krb5_free_principal(ctx, tgs);103krb5_free_principal(ctx, cl);104krb5_free_principal(ctx, sv);105krb5_free_context(ctx);106107exit(0);108}109110void krb5_klog_syslog(void) {}111kdc_realm_t *112find_realm_data(struct server_handle *handle,113char *rname, krb5_ui_4 rsize)114{115return 0;116}117118119