From 6e3511d151acac36382774f98a22d779646f767e Mon Sep 17 00:00:00 2001 From: Johan Danielsson Date: Tue, 22 Oct 1996 22:25:20 +0000 Subject: [PATCH] Reorganized file tree. git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@877 ec53bebd-3082-4978-b11e-865c3cabbd6b --- Makefile.am | 4 + Makefile.in | 287 ++++++++++++++++++++---- acconfig.h | 19 ++ aclocal.m4 | 30 +++ cache.c | 566 ------------------------------------------------ cache.h | 93 -------- config_file.h | 55 ----- config_file.y | 281 ------------------------ configure.in | 30 ++- constants.c | 4 - context.c | 94 -------- data.c | 51 ----- get_addrs.c | 43 ---- get_cred.c | 82 ------- get_in_tkt.c | 271 ----------------------- get_in_tkt_pw.c | 43 ---- get_port.c | 17 -- kinit.c | 58 ----- klist.c | 65 ------ krb5.conf | 3 + krb5.h | 422 ------------------------------------ krb5_error.h | 58 ----- krb5_locl.h | 66 ------ krbhst.c | 28 --- misc.c | 27 --- mkinstalldirs | 40 ++++ principal.c | 359 ------------------------------ principal.h | 6 - principal_p.c | 24 -- send_to_kdc.c | 104 --------- stamp-h.in | 1 + str2key.c | 141 ------------ 32 files changed, 366 insertions(+), 3006 deletions(-) create mode 100644 Makefile.am create mode 100644 acconfig.h delete mode 100644 cache.c delete mode 100644 cache.h delete mode 100644 config_file.h delete mode 100644 config_file.y delete mode 100644 constants.c delete mode 100644 context.c delete mode 100644 data.c delete mode 100644 get_addrs.c delete mode 100644 get_cred.c delete mode 100644 get_in_tkt.c delete mode 100644 get_in_tkt_pw.c delete mode 100644 get_port.c delete mode 100644 kinit.c delete mode 100644 klist.c delete mode 100644 krb5.h delete mode 100644 krb5_error.h delete mode 100644 krb5_locl.h delete mode 100644 krbhst.c delete mode 100644 misc.c create mode 100755 mkinstalldirs delete mode 100644 principal.c delete mode 100644 principal.h delete mode 100644 principal_p.c delete mode 100644 send_to_kdc.c create mode 100644 stamp-h.in delete mode 100644 str2key.c diff --git a/Makefile.am b/Makefile.am new file mode 100644 index 000000000..52d7b26b8 --- /dev/null +++ b/Makefile.am @@ -0,0 +1,4 @@ +# $Id$ + +AUTOMAKE_OPTIONS = foreign no-dependencies +SUBDIRS = lib include kuser diff --git a/Makefile.in b/Makefile.in index 5123be2cc..5f3492ae3 100644 --- a/Makefile.in +++ b/Makefile.in @@ -1,63 +1,260 @@ +# Makefile.in generated automatically by automake 1.0 from Makefile.am + +# Copyright (C) 1994, 1995, 1996 Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy, distribute and modify it. + # $Id$ + SHELL = /bin/sh srcdir = @srcdir@ -VPATH = @srcdir@ +top_srcdir = @top_srcdir@ +VPATH = @srcdir@ +prefix = @prefix@ +exec_prefix = @exec_prefix@ -CC = @CC@ -DEFS = @DEFS@ -I$(srcdir) -Iasn1 -I. -I/usr/athena/include -YACC = @YACC@ +bindir = @bindir@ +sbindir = @sbindir@ +libexecdir = @libexecdir@ +datadir = @datadir@ +sysconfdir = @sysconfdir@ +sharedstatedir = @sharedstatedir@ +localstatedir = @localstatedir@ +libdir = @libdir@ +infodir = @infodir@ +mandir = @mandir@ +includedir = @includedir@ +oldincludedir = /usr/include -.SUFFIXES: .pro +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ -CFLAGS = -g +top_builddir = . -LIBS = -L/usr/athena/lib -ldes +INSTALL = @INSTALL@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +transform = @program_transform_name@ -SOURCES = cache.c principal.c principal_p.c data.c context.c misc.c \ - krbhst.c get_port.c send_to_kdc.c str2key.c \ - get_in_tkt.c get_in_tkt_pw.c constants.c get_addrs.c \ - get_cred.c - -OBJECTS = $(SOURCES:%.c=%.o) config_file.o - -all: kinit klist - -.c.o: - $(CC) $(CFLAGS) $(DEFS) -c $< -o $@ - -.c.pro: - gcc $(CFLAGS) $(DEFS) -S -o /dev/null -aux-info $*.X $< - awk -V f=$< -f $(srcdir)/format.awk $*.X > $@ - rm $*.X +AUTOMAKE_OPTIONS = foreign no-dependencies +SUBDIRS = lib include kuser +ACLOCAL = aclocal.m4 +ACCONFIG = acconfig.h +CONFIG_HEADER_IN = config.h.in +mkinstalldirs = $(top_srcdir)/mkinstalldirs +CONFIG_HEADER = ./config.h +DIST_COMMON = Makefile.am Makefile.in acconfig.h aclocal.m4 config.h.in \ +configure configure.in install-sh mkinstalldirs stamp-h.in -kinit: kinit.o libkrb5.a - $(CC) -o kinit kinit.o libkrb5.a -Lasn1 -lasn1 $(LIBS) +PACKAGE = @PACKAGE@ +VERSION = @VERSION@ -klist: klist.o libkrb5.a - $(CC) -o klist klist.o libkrb5.a $(LIBS) +DISTFILES = $(DIST_COMMON) $(SOURCES) $(BUILT_SOURCES) $(HEADERS) \ + $(TEXINFOS) $(INFOS) $(MANS) $(EXTRA_DIST) $(DATA) +DEP_DISTFILES = $(DIST_COMMON) $(SOURCES) $(BUILT_SOURCES) $(HEADERS) \ + $(TEXINFOS) $(INFO_DEPS) $(MANS) $(EXTRA_DIST) $(DATA) -tt: test.o libkrb5.a - $(CC) -o tt test.o libkrb5.a - -test.o: krb5.h - -libkrb5.a: $(OBJECTS) - ar cr libkrb5.a $(OBJECTS) - ranlib libkrb5.a - -config_file.o: config_file.c - -config_file.c: config_file.y - $(YACC) -p __k5cf_ $< - mv -f y.tab.c config_file.c - -clean: - rm -f *.o *~ libkrb5.a tt core \#* config_file.c +TAR = tar +default: all +$(srcdir)/Makefile.in: Makefile.am configure.in + cd $(srcdir) && automake Makefile -$(OBJECTS): krb5_locl.h krb5.h +# For an explanation of the following Makefile rules, see node +# `Automatic Remaking' in GNU Autoconf documentation. +Makefile: Makefile.in config.status + CONFIG_FILES=$@ CONFIG_HEADERS= ./config.status +config.status: configure + ./config.status --recheck +$(srcdir)/configure: configure.in $(ACLOCAL) $(CONFIGURE_DEPENDENCIES) + cd $(srcdir) && autoconf +$(CONFIG_HEADER): stamp-h +stamp-h: $(CONFIG_HEADER_IN) config.status + CONFIG_FILES= CONFIG_HEADERS=$(CONFIG_HEADER) ./config.status + @echo timestamp > stamp-h +$(srcdir)/$(CONFIG_HEADER_IN): stamp-h.in +$(srcdir)/stamp-h.in: configure.in $(ACLOCAL) $(ACCONFIG) $(CONFIG_TOP) $(CONFIG_BOT) + cd $(srcdir) && autoheader + echo timestamp > $(srcdir)/stamp-h.in + +# This directory's subdirectories are mostly independent; you can cd +# into them and run `make' without going through this Makefile. +# To change the values of `make' variables: instead of editing Makefiles, +# (1) if the variable is set in `config.status', edit `config.status' +# (which will cause the Makefiles to be regenerated when you run `make'); +# (2) otherwise, pass the desired values on the `make' command line. + +@SET_MAKE@ + +all-recursive install-data-recursive install-exec-recursive \ +installdirs-recursive install-recursive uninstall-recursive \ +check-recursive installcheck-recursive info-recursive dvi-recursive \ +mostlyclean-recursive clean-recursive distclean-recursive \ +maintainer-clean-recursive: + for subdir in $(SUBDIRS); do \ + target=`echo $@ | sed s/-recursive//`; \ + echo making $$target in $$subdir; \ + (cd $$subdir && $(MAKE) $$target) \ + || case "$(MFLAGS)" in *k*) fail=yes;; *) exit 1;; esac; \ + done && test -z "$$fail" + +tags: TAGS + +tags-recursive: + list="$(SUBDIRS)"; for subdir in $$list; do \ + (cd $$subdir && $(MAKE) tags); \ + done + +TAGS: tags-recursive $(HEADERS) $(SOURCES) $(CONFIG_HEADER) \ + $(TAGS_DEPENDENCIES) + tags=; \ + here=`pwd`; \ + for subdir in $(SUBDIRS); do \ + test -f $$subdir/TAGS && { \ + tags="$$tags -i $$here/$$subdir/TAGS"; \ + } \ + done; \ + test -z "$(ETAGS_ARGS)$(CONFIG_HEADER)$(SOURCES)$(HEADERS)$$tags" \ + || etags $(ETAGS_ARGS) $$tags $(CONFIG_HEADER) $(SOURCES) $(HEADERS) + +mostlyclean-tags: + +clean-tags: + +distclean-tags: + rm -f TAGS ID + +maintainer-clean-tags: + +distdir = $(PACKAGE)-$(VERSION) +# This target untars the dist file and tries a VPATH configuration. Then +# it guarantees that the distribution is self-contained by making another +# tarfile. +distcheck: dist + rm -rf $(distdir) + $(TAR) zxf $(distdir).tar.gz + mkdir $(distdir)/=build + mkdir $(distdir)/=inst + dc_install_base=`cd $(distdir)/=inst && pwd`; \ + cd $(distdir)/=build \ + && ../configure --srcdir=.. --prefix=$$dc_install_base \ + && $(MAKE) \ + && $(MAKE) check \ + && $(MAKE) install \ + && $(MAKE) installcheck \ + && $(MAKE) dist + rm -rf $(distdir) + @echo "========================"; \ + echo "$(distdir).tar.gz is ready for distribution"; \ + echo "========================" +dist: distdir + chmod -R a+r $(distdir) + $(TAR) chozf $(distdir).tar.gz $(distdir) + rm -rf $(distdir) +distdir: $(DEP_DISTFILES) + rm -rf $(distdir) + mkdir $(distdir) + chmod 777 $(distdir) + distdir=`cd $(distdir) && pwd` \ + && cd $(srcdir) \ + && automake --include-deps --output-dir=$$distdir --strictness=foreign + @for file in `cd $(srcdir) && echo $(DISTFILES)`; do \ + test -f $(distdir)/$$file \ + || ln $(srcdir)/$$file $(distdir)/$$file 2> /dev/null \ + || cp -p $(srcdir)/$$file $(distdir)/$$file; \ + done + for subdir in $(SUBDIRS); do \ + test -d $(distdir)/$$subdir \ + || mkdir $(distdir)/$$subdir \ + || exit 1; \ + chmod 777 $(distdir)/$$subdir; \ + (cd $$subdir && $(MAKE) distdir=../$(distdir)/$$subdir distdir) \ + || exit 1; \ + done +info: info-recursive + +dvi: dvi-recursive + +check: check-recursive + +installcheck: installcheck-recursive + +all-recursive-hack: $(CONFIG_HEADER) + $(MAKE) all-recursive + +all-am: Makefile config.h + +install-exec: install-exec-recursive + +install-data: install-data-recursive + +install: install-recursive + @: + +uninstall: uninstall-recursive + +all: all-recursive-hack all-am + +install-strip: + $(MAKE) INSTALL_PROGRAM='$(INSTALL_PROGRAM) -s' install +installdirs: installdirs-recursive + + +mostlyclean-generic: + test -z "$(MOSTLYCLEANFILES)" || rm -f $(MOSTLYCLEANFILES) + +clean-generic: + test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) + +distclean-generic: + rm -f Makefile $(DISTCLEANFILES) + rm -f config.cache config.log $(CONFIG_HEADER) stamp-h + +maintainer-clean-generic: + test -z "$(MAINTAINERCLEANFILES)" || rm -f $(MAINTAINERCLEANFILES) + test -z "$(BUILT_SOURCES)" || rm -f $(BUILT_SOURCES) +mostlyclean-am: mostlyclean-tags mostlyclean-generic + +clean-am: clean-tags clean-generic mostlyclean-am + +distclean-am: distclean-tags distclean-generic clean-am + +maintainer-clean-am: maintainer-clean-tags maintainer-clean-generic \ + distclean-am + +mostlyclean: mostlyclean-am mostlyclean-recursive + +clean: clean-am clean-recursive + +distclean: distclean-am distclean-recursive + rm -f config.status + +maintainer-clean: maintainer-clean-am maintainer-clean-recursive + @echo "This command is intended for maintainers to use;" + @echo "it deletes files that may require special tools to rebuild." + rm -f config.status + +.PHONY: default install-data-recursive uninstall-data-recursive \ +install-exec-recursive uninstall-exec-recursive installdirs-recursive \ +uninstalldirs-recursive all-recursive check-recursive \ +installcheck-recursive info-recursive dvi-recursive \ +mostlyclean-recursive distclean-recursive clean-recursive \ +maintainer-clean-recursive tags tags-recursive mostlyclean-tags \ +distclean-tags clean-tags maintainer-clean-tags distdir info dvi check \ +installcheck all-recursive-hack all-am install-exec install-data \ +install uninstall all installdirs mostlyclean-generic distclean-generic \ +clean-generic maintainer-clean-generic clean mostlyclean distclean \ +maintainer-clean + +.SUFFIXES: + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/acconfig.h b/acconfig.h new file mode 100644 index 000000000..9ba0ae643 --- /dev/null +++ b/acconfig.h @@ -0,0 +1,19 @@ +@BOTTOM@ + +#undef HAVE_INT8_T +#undef HAVE_INT16_T +#undef HAVE_INT32_T +#undef HAVE_INT64_T +#undef HAVE_U_INT8_T +#undef HAVE_U_INT16_T +#undef HAVE_U_INT32_T +#undef HAVE_U_INT64_T + +#ifdef VOID_RETSIGTYPE +#define SIGRETURN(x) return +#else +#define SIGRETURN(x) return (RETSIGTYPE)(x) +#endif + +#define RCSID(msg) \ +static /**/const char *const rcsid[] = { (char *)rcsid, "\100(#)" msg } diff --git a/aclocal.m4 b/aclocal.m4 index 4837dd501..fbdb29171 100644 --- a/aclocal.m4 +++ b/aclocal.m4 @@ -300,3 +300,33 @@ AC_MSG_RESULT($ac_have_pragma_weak) fi ]) ]) + +AC_DEFUN(AC_GROK_TYPE, [ +AC_CACHE_VAL(ac_cv_type_$1, +AC_TRY_COMPILE([ +#include "confdefs.h" +#ifdef HAVE_SYS_TYPES_H +#include +#endif +#ifdef HAVE_SYS_BITYPES_H +#include +#endif +], +$i x; +, +eval ac_cv_type_$1=yes, +eval ac_cv_type_$1=no))]) + + +AC_DEFUN(AC_GROK_TYPES, [ +for i in $1; do + AC_MSG_CHECKING(for $i) + AC_GROK_TYPE($i) + eval ac_res=\$ac_cv_type_$i + if test "$ac_res" = yes; then + type=HAVE_`echo $i | tr '[a-z]' '[A-Z]'` + AC_DEFINE_UNQUOTED($type) + fi + AC_MSG_RESULT($ac_res) +done +]) \ No newline at end of file diff --git a/cache.c b/cache.c deleted file mode 100644 index 7e22452e9..000000000 --- a/cache.c +++ /dev/null @@ -1,566 +0,0 @@ -#include "krb5_locl.h" - -/* XXX shouldn't be here */ - -void krb5_free_ccache(krb5_context context, - krb5_ccache val) -{ - free(((krb5_fcache*)(val->data.data))->filename); - krb5_data_free (&val->data); - free(val); -} - - -krb5_error_code -krb5_cc_resolve(krb5_context context, - const char *residual, - krb5_ccache *id) -{ - krb5_ccache p; - krb5_fcache *f; - - if(strncmp(residual, "FILE:", 5)){ - return -1; - } - - p = ALLOC(1, krb5_ccache_data); - - if(!p) - return ENOMEM; - - f = ALLOC(1, krb5_fcache); - - if(!f){ - free(p); - return ENOMEM; - } - f->filename = strdup(residual + 5); - if(!f->filename){ - free(f); - free(p); - return ENOMEM; - } - - p->data.data = f; - p->data.length = sizeof(*f); - p->type = 1; - - *id = p; - - return 0; -} - -#if 0 -krb5_error_code -krb5_cc_gen_new(krb5_context context, - krb5_cc_ops *ops, - krb5_ccache *id) -{ -} - -krb5_error_code -krb5_cc_register(krb5_context context, - krb5_cc_ops *ops, - krb5_boolean override) -{ -} -#endif - -char* -krb5_cc_get_name(krb5_context context, - krb5_ccache id) -{ - return ((krb5_fcache*)(id->data.data))->filename; -} - -char* -krb5_cc_default_name(krb5_context context) -{ - static char name[1024]; - char *p; - p = getenv("KRB5CCNAME"); - if(p) - strcpy(name, p); - else - sprintf(name, "FILE:/tmp/krb5cc_%d", getuid()); - return name; -} - - - - -krb5_error_code -krb5_cc_default(krb5_context context, - krb5_ccache *id) -{ - return krb5_cc_resolve(context, - krb5_cc_default_name(context), - id); -} - -static krb5_error_code -store_int32(int fd, - int32_t value) -{ - int ret; - - value = htonl(value); - ret = write(fd, &value, sizeof(value)); - if (ret != sizeof(value)) - return (ret<0)?errno:-1; - return 0; -} - -static krb5_error_code -ret_int32(int fd, - int32_t *value) -{ - int32_t v; - int ret; - ret = read(fd, &v, sizeof(v)); - if(ret != sizeof(v)) - return (ret<0)?errno:-1; /* XXX */ - - *value = ntohl(v); - return 0; -} - -static krb5_error_code -store_int16(int fd, - int16_t value) -{ - int ret; - - value = htons(value); - ret = write(fd, &value, sizeof(value)); - if (ret != sizeof(value)) - return (ret<0)?errno:-1; - return 0; -} - -static krb5_error_code -ret_int16(int fd, - int16_t *value) -{ - int16_t v; - int ret; - ret = read(fd, &v, sizeof(v)); - if(ret != sizeof(v)) - return (ret<0)?errno:-1; /* XXX */ - - *value = ntohs(v); - return 0; -} - -static krb5_error_code -store_int8(int fd, - int8_t value) -{ - int ret; - - ret = write(fd, &value, sizeof(value)); - if (ret != sizeof(value)) - return (ret<0)?errno:-1; - return 0; -} - -static krb5_error_code -ret_int8(int fd, - int8_t *value) -{ - int ret; - - ret = read (fd, value, sizeof(*value)); - if (ret != sizeof(*value)) - return (ret<0)?errno:-1; - return 0; -} - -static krb5_error_code -store_data(int fd, - krb5_data data) -{ - int ret; - ret = store_int32(fd, data.length); - if(ret < 0) - return ret; - return write(fd, data.data, data.length); -} - -static krb5_error_code -ret_data(int fd, - krb5_data *data) -{ - int ret; - int size; - ret = ret_int32(fd, &size); - data->length = size; - data->data = malloc(size); - ret = read(fd, data->data, size); - if(ret != size) - return (ret < 0)? errno : -1; /* XXX */ - return 0; -} - -static krb5_error_code -store_principal(int fd, - krb5_principal p) -{ - int i; - store_int32(fd, p->type); - store_int32(fd, p->ncomp); - store_data(fd, p->realm); - for(i = 0; i < p->ncomp; i++) - store_data(fd, p->comp[i]); - return 0; -} - -static krb5_error_code -ret_principal(int fd, - krb5_principal *princ) -{ - int i; - krb5_principal p; - - p = ALLOC(1, krb5_principal_data); - - if(ret_int32(fd, &p->type)) - return -1; - ret_int32(fd, &p->ncomp); - ret_data(fd, &p->realm); - p->comp = ALLOC(p->ncomp, krb5_data); - for(i = 0; i < p->ncomp; i++) - ret_data(fd, &p->comp[i]); - *princ = p; - return 0; -} - -static krb5_error_code -store_keyblock(int fd, krb5_keyblock p) -{ - store_int32(fd, p.keytype); - store_data(fd, p.contents); - return 0; -} - -static krb5_error_code -ret_keyblock(int fd, krb5_keyblock *p) -{ - ret_int32(fd, (int32_t*)&p->keytype); - ret_data(fd, &p->contents); - return 0; -} - -static krb5_error_code -store_times(int fd, krb5_times times) -{ - store_int32(fd, times.authtime); - store_int32(fd, times.starttime); - store_int32(fd, times.endtime); - store_int32(fd, times.renew_till); - return 0; -} - -static krb5_error_code -ret_times(int fd, krb5_times *times) -{ - ret_int32(fd, ×->authtime); - ret_int32(fd, ×->starttime); - ret_int32(fd, ×->endtime); - ret_int32(fd, ×->renew_till); - return 0; -} - -static krb5_error_code -store_address(int fd, krb5_address p) -{ - store_int32(fd, p.type); - store_data(fd, p.address); - return 0; -} - -static krb5_error_code -ret_address(int fd, krb5_address *adr) -{ - ret_int32(fd, (int32_t*)&adr->type); - ret_data(fd, &adr->address); - return 0; -} - -static krb5_error_code -store_addrs(int fd, krb5_addresses p) -{ - int i; - store_int32(fd, p.number); - for(i = 0; inumber); - adr->addrs = ALLOC(adr->number, krb5_address); - for(i = 0; i < adr->number; i++) - ret_address(fd, &adr->addrs[i]); - return 0; -} - -static krb5_error_code -store_ticket(int fd, krb5_ticket p) -{ - store_data(fd, p.enc_part); - return 0; -} - -static krb5_error_code -ret_ticket(int fd, krb5_ticket *tkt) -{ - ret_data(fd, &tkt->enc_part); - return 0; -} - -static krb5_error_code -store_authdata(int fd, krb5_data p) -{ - store_data(fd, p); - return 0; -} - -static krb5_error_code -ret_authdata(int fd, krb5_data *auth) -{ - ret_data(fd, auth); - return 0; -} - -krb5_error_code -erase_file(const char *filename) -{ - int fd; - off_t pos; - char *p; - - fd = open(filename, O_RDWR); - if(fd < 0) - if(errno == ENOENT) - return 0; - else - return errno; - pos = lseek(fd, 0, SEEK_END); - lseek(fd, 0, SEEK_SET); - p = (char*) malloc(pos); - memset(p, 0, pos); - write(fd, p, pos); - free(p); - close(fd); - unlink(filename); - return 0; -} - -krb5_error_code -krb5_cc_initialize(krb5_context context, - krb5_ccache id, - krb5_principal primary_principal) -{ - int ret; - int fd; - - char *f; - - f = krb5_cc_get_name(context, id); - - if((ret = erase_file(f))) - return ret; - - fd = open(f, O_RDWR | O_CREAT | O_EXCL, 0600); - if(fd == -1) - return errno; - store_int16(fd, 0x503); - store_principal(fd, primary_principal); - close(fd); - - return 0; -} - - -krb5_error_code -krb5_cc_destroy(krb5_context context, - krb5_ccache id) -{ - char *f; - int ret; - f = krb5_cc_get_name(context, id); - - ret = erase_file(f); - - krb5_free_ccache(context, id); - return ret; -} - -krb5_error_code -krb5_cc_close(krb5_context context, - krb5_ccache id) -{ - krb5_data_free (&id->data); - free(id); - return 0; -} - -krb5_error_code -krb5_cc_store_cred(krb5_context context, - krb5_ccache id, - krb5_creds *creds) -{ - int fd; - krb5_fcache *f; - - f = (krb5_fcache *)id->data.data; - - fd = open(f->filename, O_WRONLY | O_APPEND); - if(fd < 0) - return errno; - store_principal(fd, creds->client); - store_principal(fd, creds->server); - store_keyblock(fd, creds->session); - store_times(fd, creds->times); - store_int8(fd, 0); /* s/key */ - store_int32(fd, 0); /* flags */ - store_addrs(fd, creds->addresses); - store_authdata(fd, creds->authdata); - store_ticket(fd, creds->ticket); - store_ticket(fd, creds->second_ticket); - close(fd); - return 0; /* XXX */ -} - -static krb5_error_code -krb5_cc_read_cred (int fd, - krb5_creds *creds) -{ - int8_t dummy8; - int32_t dummy32; - - return ret_principal (fd, &creds->client) || - ret_principal (fd, &creds->server) || - ret_keyblock (fd, &creds->session) || - ret_times (fd, &creds->times) || - ret_int8 (fd, &dummy8) || - ret_int32 (fd, &dummy32) || - ret_addrs (fd, &creds->addresses) || - ret_authdata (fd, &creds->authdata) || - ret_ticket (fd, &creds->ticket) || - ret_ticket (fd, &creds->second_ticket); -} - -krb5_error_code -krb5_cc_retrieve_cred(krb5_context context, - krb5_ccache id, - krb5_flags whichfields, - krb5_creds *mcreds, - krb5_creds *creds) -{ - return 0; /* XXX */ -} - -krb5_error_code -krb5_cc_get_principal(krb5_context context, - krb5_ccache id, - krb5_principal *principal) -{ - int fd; - int16_t tag; - - fd = open(krb5_cc_get_name(context, id), O_RDONLY); - if(fd < 0) - return errno; - ret_int16(fd, &tag); - ret_principal(fd, principal); - close(fd); - return 0; -} - -krb5_error_code -krb5_cc_start_seq_get (krb5_context context, - krb5_ccache id, - krb5_cc_cursor *cursor) -{ - int16_t tag; - krb5_principal principal; - - if (id->type != 1) - abort (); - cursor->fd = open (krb5_cc_get_name (context, id), O_RDONLY); - if (cursor->fd < 0) - return errno; - ret_int16 (cursor->fd, &tag); - ret_principal (cursor->fd, &principal); - krb5_free_principal (principal); - return 0; -} - -krb5_error_code -krb5_cc_next_cred (krb5_context context, - krb5_ccache id, - krb5_creds *creds, - krb5_cc_cursor *cursor) -{ - if (id->type != 1) - abort (); - return krb5_cc_read_cred (cursor->fd, creds); -} - -krb5_error_code -krb5_cc_end_seq_get (krb5_context context, - krb5_ccache id, - krb5_cc_cursor *cursor) -{ - if (id->type != 1) - abort (); - return close (cursor->fd); -} - -krb5_error_code -krb5_cc_get_first(krb5_context context, - krb5_ccache id, - krb5_cc_cursor *cursor) -{ - return 0; /* XXX */ -} - -krb5_error_code -krb5_cc_get_next(krb5_context context, - krb5_ccache id, - krb5_creds *creds, - krb5_cc_cursor *cursor) -{ - return 0; /* XXX */ -} - -krb5_error_code -krb5_cc_end_get(krb5_context context, - krb5_ccache id, - krb5_cc_cursor *cursor) -{ - return 0; /* XXX */ -} - -krb5_error_code -krb5_cc_remove_cred(krb5_context context, - krb5_ccache id, - krb5_flags which, - krb5_creds *cred) -{ - return 0; /* XXX */ -} - -krb5_error_code -krb5_cc_set_flags(krb5_context context, - krb5_ccache id, - krb5_flags flags) -{ - return 0; /* XXX */ -} - diff --git a/cache.h b/cache.h deleted file mode 100644 index 7e798ce41..000000000 --- a/cache.h +++ /dev/null @@ -1,93 +0,0 @@ -#ifndef __CACHE_H__ -#define __CACHE_H__ - -krb5_error_code -krb5_cc_resolve (krb5_context context, - char *residual, - krb5_ccache *id); - -char * -krb5_cc_get_name (krb5_context context, - krb5_ccache id); - -char * -krb5_cc_default_name (krb5_context context); - -krb5_error_code -krb5_cc_default (krb5_context context, - krb5_ccache *id); - -krb5_error_code -krb5_cc_initialize (krb5_context context, - krb5_ccache id, - krb5_principal primary_principal); - -krb5_error_code -krb5_cc_destroy (krb5_context context, - krb5_ccache id); - -krb5_error_code -krb5_cc_close (krb5_context context, - krb5_ccache id); - -krb5_error_code -krb5_cc_store_cred (krb5_context context, - krb5_ccache id, - krb5_creds *creds); - -krb5_error_code -krb5_cc_retrieve_cred (krb5_context context, - krb5_ccache id, - krb5_flags whichfields, - krb5_creds *mcreds, - krb5_creds *creds); - -krb5_error_code -krb5_cc_get_principal (krb5_context context, - krb5_ccache id, - krb5_principal *principal); - -krb5_error_code -krb5_cc_get_first (krb5_context context, - krb5_ccache id, - krb5_cc_cursor *cursor); - -krb5_error_code -krb5_cc_get_next (krb5_context context, - krb5_ccache id, - krb5_creds *creds, - krb5_cc_cursor *cursor); - -krb5_error_code -krb5_cc_end_get (krb5_context context, - krb5_ccache id, - krb5_cc_cursor *cursor); - -krb5_error_code -krb5_cc_remove_cred (krb5_context context, - krb5_ccache id, - krb5_flags which, - krb5_creds *cred); - -krb5_error_code -krb5_cc_set_flags (krb5_context context, - krb5_ccache id, - krb5_flags flags); - -krb5_error_code -krb5_cc_start_seq_get (krb5_context context, - krb5_ccache id, - krb5_cc_cursor *cursor); - -krb5_error_code -krb5_cc_next_cred (krb5_context context, - krb5_ccache id, - krb5_creds *creds, - krb5_cc_cursor *cursor); - -krb5_error_code -krb5_cc_end_seq_get (krb5_context context, - krb5_ccache id, - krb5_cc_cursor *cursor); - -#endif /* __CACHE_H__ */ diff --git a/config_file.h b/config_file.h deleted file mode 100644 index 11eba6244..000000000 --- a/config_file.h +++ /dev/null @@ -1,55 +0,0 @@ -#ifndef __CONF_H__ -#define __CONF_H__ - -enum { - krb5_config_value_string, - krb5_config_value_list -}; - -struct krb5_config_relation; - -typedef struct krb5_config_value{ - int type; - union { - char *string; - struct krb5_config_relation *relations; - }data; -}krb5_config_value; - -typedef struct krb5_config_relation{ - char *tag; - struct krb5_config_value value; - struct krb5_config_relation *next; -}krb5_config_relation; - -typedef struct krb5_config_section{ - char *name; - struct krb5_config_relation *relations; - struct krb5_config_section *next; -}krb5_config_section; - -typedef struct k5_cfile{ - char *filename; - struct krb5_config_section *sections; -}k5_cfile; - - - -/* -static char *gettoken(FILE *F); -static void -free_config_file(k5_cfile *cf); -static krb5_error_code -new_config_file(k5_cfile **cf, const char *filename); -static void -free_config_section(krb5_config_section *sec); -static krb5_error_code -new_config_section(krb5_config_section **sec, const char *name); -static void -free_config_relation(krb5_config_relation *rel); -static void -free_config_value(krb5_config_value val); -static krb5_error_code -parse_config_file(k5_cfile **cf, const char *filename); -*/ -#endif /* __CONF_H__ */ diff --git a/config_file.y b/config_file.y deleted file mode 100644 index d135169dd..000000000 --- a/config_file.y +++ /dev/null @@ -1,281 +0,0 @@ -%{ - -#include -#include -#include -#include - -#include "krb5_locl.h" -#include "config_file.h" - -static char section[128]; -static FILE *F; - -static k5_cfile *cf; - -static krb5_config_section *csec; - -static krb5_config_relation **crel; -static krb5_config_relation **rels[16]; -static int relp; - -static void yyerror (char *); -static int yylex (void); - -%} - -%union { - int i; - char *s; -} - -%token STRING - -%% - -file : section_list - ; - -section_list : /* empty */ - | section rel_list section_list - { -#ifdef DEBUG - printf("section_list\n"); -#endif - } - ; - -section - : '[' STRING ']' - { - krb5_config_section *p; - p = ALLOC(1, krb5_config_section); - p->next = NULL; - p->name = $2; - p->relations = NULL; - if(cf->sections) - p->next = cf->sections; - cf->sections = p; - csec = p; - crel = &p->relations; -#ifdef DEBUG - printf("section\n"); -#endif - strcpy(section, $2); - } - ; - -rel_list - : relation rel_sub - ; - -rel_sub : /* empty */ - | relation rel_sub - ; - -relation - : tag '=' value - { -#ifdef DEBUG - printf("relation\n"); -#endif - } - ; - -tag : STRING - { - krb5_config_relation *p; - if(!crel){ - fprintf(stderr, "error\n"); - return -17; - } - p = ALLOC(1, krb5_config_relation); - p->tag = $1; - if(*crel){ - p->next = NULL; - (*crel)->value.data.relations = p; - rels[relp++] = crel; - crel = &p; - }else{ - p->next = *crel; - *crel = p; - } -#ifdef DEBUG - printf("tag\n"); -#endif - } - ; - -value : STRING - { - (*crel)->value.type = krb5_config_value_string; - (*crel)->value.data.string = $1; - crel = &(*crel)->next; -#ifdef DEBUG - printf("value/string\n"); -#endif - } - | '{' rel_list '}' - { - crel = rels[--relp]; - (*crel)->value.type = krb5_config_value_list; - crel = &(*crel)->next; -#ifdef DEBUG - printf("value/list\n"); -#endif - } - ; - -%% - -static int yylex(void) -{ - int c; - static char save; - static char yytext[1024]; - char *p = yytext; - int type = 0; - while(1){ - if(save){ - c = save; - save = 0; - }else - c = getc(F); - if(c == EOF) - break; - if(isspace(c)) - if(type) - break; /* end of token */ - else - continue; /* eat ws */ - if(strchr("[]={}", c)){ - if(type) - save = c; - else{ - return c; - } - break; - } - *p++ = c; - type = STRING; - continue; - } - *p = 0; - yylval.s = strdup(yytext); - return type; -} - -void yyerror(char *s) -{ - printf("yyerror: %s\n", s); -} - - -/*----------------------------------------*/ - -static void -free_config_file(k5_cfile *cf) -{ - if(!cf) - return; - FREE(cf->filename); - free(cf); -} - -static void free_config_relation(krb5_config_relation *rel); - -static void -free_config_value(krb5_config_value val) -{ - if(val.type == krb5_config_value_string) - FREE(val.data.string); - else if(val.type == krb5_config_value_list) - free_config_relation(val.data.relations); - else - fprintf(stderr, "free_config_value: krb5_config_value " - "with bad type passed (%d)\n", val.type); -} - -static void -free_config_relation(krb5_config_relation *rel) -{ - if(!rel) - return; - free_config_value(rel->value); - free_config_relation(rel->next); - FREE(rel); -} - -static void -free_config_section(krb5_config_section *sec) -{ - if(!sec) - return; - FREE(sec->name); - free_config_relation(sec->relations); - free_config_section(sec->next); - FREE(sec); -} - - -void -krb5_free_config_file(k5_cfile *cf) -{ - free_config_file(cf); -} - -krb5_error_code -krb5_get_config_tag(k5_cfile *cf, const char *tag, char **value) -{ - char *str; - char *p; - krb5_config_section *s; - krb5_config_relation *r; - - str = strdup(tag); - p = strtok(str, " \t"); - if(!p) - return ENOENT; - for(s = cf->sections; s; s = s->next){ - if(!strcmp(s->name, p)){ - p = strtok(NULL, " \t"); - for(r = s->relations; r;){ - if(!strcmp(r->tag, p)){ - if(r->value.type == krb5_config_value_string){ - *value = strdup(r->value.data.string); - free(str); - return 0; - }else{ - p = strtok(NULL, " \t"); - r = r->value.data.relations; - continue; - } - } - r = r->next; - } - } - } - return ENOENT; -} - -krb5_error_code -krb5_parse_config_file(k5_cfile **cfile, const char *filename) -{ - krb5_error_code ret; - if(!filename) - filename = krb5_config_file; - F = fopen(filename, "r"); - if(F == NULL) - return errno; - cf = ALLOC(1, k5_cfile); - if(!cf) - return ENOMEM; - ret = yyparse(); - - fclose(F); - if(ret) - krb5_free_config_file(cf); - else - *cfile = cf; - return ret; -} diff --git a/configure.in b/configure.in index ef3fb7d77..ad4911044 100644 --- a/configure.in +++ b/configure.in @@ -1,8 +1,13 @@ dnl Process this file with autoconf to produce a configure script. AC_REVISION($Revision$) -AC_INIT(send_to_kdc.c) +AC_INIT(lib/krb5/send_to_kdc.c) AC_CONFIG_HEADER(config.h) +PACKAGE=heimdal +VERSION=0.0 +AC_SUBST(PACKAGE) +AC_SUBST(VERSION) + dnl Checks for programs. AC_PROG_CC AC_PROG_INSTALL @@ -10,13 +15,16 @@ dnl AC_KRB_PROG_YACC AC_PROG_YACC AC_PROG_LEX AC_PROG_RANLIB +AC_PROG_MAKE_SET +AC_LN_S +AC_ARG_PROGRAM dnl Checks for libraries. dnl Checks for header files. AC_HEADER_STDC AC_CHECK_HEADERS(fcntl.h limits.h sys/ioctl.h sys/time.h unistd.h) -AC_CHECK_HEADERS(sys/bitypes.h) +AC_CHECK_HEADERS(sys/bitypes.h sys/filio.h sys/types.h) dnl Checks for typedefs, structures, and compiler characteristics. AC_C_CONST @@ -28,4 +36,20 @@ AC_STRUCT_TM dnl Checks for library functions. AC_CHECK_FUNCS(gethostname mktime select socket strdup strstr) -AC_OUTPUT(Makefile asn1/Makefile) +AC_TYPE_SIGNAL +if test "$ac_cv_type_signal" = "void" ; then + AC_DEFINE(VOID_RETSIGTYPE, 1) +fi +AC_SUBST(VOID_RETSIGTYPE) + + +AC_GROK_TYPES(int8_t int16_t int32_t int64_t) +AC_GROK_TYPES(u_int8_t u_int16_t u_int32_t u_int64_t) + +AC_OUTPUT(Makefile \ + include/Makefile \ + lib/Makefile \ + lib/asn1/Makefile \ + lib/des/Makefile \ + lib/krb5/Makefile \ + kuser/Makefile) diff --git a/constants.c b/constants.c deleted file mode 100644 index 94e5664c1..000000000 --- a/constants.c +++ /dev/null @@ -1,4 +0,0 @@ - - -const char krb5_config_file[] = "/etc/krb5.conf"; -const char krb5_defkeyname[] = "/etc/v5srvtab"; diff --git a/context.c b/context.c deleted file mode 100644 index cc5c5dedf..000000000 --- a/context.c +++ /dev/null @@ -1,94 +0,0 @@ -#include "krb5_locl.h" - -/* XXX */ - -#ifdef sun -#define memmove(a,b,c) bcopy(b,a,c) -#endif - -krb5_error_code -krb5_init_context(krb5_context *context) -{ - krb5_context p; - p = ALLOC(1, krb5_context_data); - if(!p) - return ENOMEM; - memset(p, 0, sizeof(krb5_context_data)); - krb5_parse_config_file(&p->cf, NULL); - krb5_get_lrealm(&p->default_realm); - *context = p; - return 0; -} - -void krb5_os_free_context(krb5_context context) -{ - -} - -void krb5_free_context(krb5_context context) -{ - free(context->default_realm); - free(context); -} - - -static krb5_boolean -valid_etype(krb5_enctype e) -{ - return e == ETYPE_DES_CBC_CRC; -} - -static krb5_error_code -default_etypes(krb5_enctype **etype) -{ - krb5_enctype *p; - p = ALLOC(1, krb5_enctype); - if(!p) - return ENOMEM; - p[0] = ETYPE_DES_CBC_CRC; - *etype = p; - return 0; -} - -krb5_error_code -krb5_set_default_in_tkt_etypes(krb5_context context, - const krb5_enctype *etypes) -{ - int i; - krb5_enctype *p = NULL; - if(etypes){ - i = 0; - while(etypes[i]) - if(!valid_etype(etypes[i++])) - return KRB5_PROG_ETYPE_NOSUPP; - p = ALLOC(i, krb5_enctype); - if(!p) - return ENOMEM; - memmove(p, etypes, i * sizeof(krb5_enctype)); - } - if(context->etypes) free(context->etypes); - context->etypes = p; - return 0; -} - - - -krb5_error_code -krb5_get_default_in_tkt_etypes(krb5_context context, - krb5_enctype **etypes) -{ - krb5_enctype *p; - int i; - if(context->etypes){ - for(i = 0; context->etypes[i]; i++); - p = ALLOC(i, krb5_enctype); - if(!p) - return ENOMEM; - memmove(p, context->etypes, i * sizeof(krb5_enctype)); - }else - if(default_etypes(&p)) - return ENOMEM; - *etypes = p; - return 0; -} - diff --git a/data.c b/data.c deleted file mode 100644 index 37c1e3bab..000000000 --- a/data.c +++ /dev/null @@ -1,51 +0,0 @@ -#include "krb5_locl.h" - -/* XXX */ - -#ifdef sun -#define memmove(a,b,c) bcopy(b,a,c) -#endif - -void -krb5_data_free(krb5_data *p) -{ - if(p->length && p->data) - free(p->data); - p->length = 0; -} - -krb5_error_code -krb5_data_alloc(krb5_data *p, int len) -{ - krb5_data_free(p); - p->data = (krb5_pointer)malloc(len); - if(!p->data) - return ENOMEM; - p->length = len; - return 0; -} - -krb5_error_code -krb5_data_realloc(krb5_data *p, int len) -{ - void *tmp; - tmp = realloc(p->data, len); - if(!tmp) - return ENOMEM; - p->data = tmp; - p->length = len; - return 0; -} - -krb5_error_code -krb5_data_copy(krb5_data *p, void *data, size_t len) -{ - krb5_data_free(p); - p->data = (krb5_pointer)malloc(len); - if(!p->data) - return ENOMEM; - memmove(p->data, data, len); - p->length = len; - return 0; -} - diff --git a/get_addrs.c b/get_addrs.c deleted file mode 100644 index 48fc93810..000000000 --- a/get_addrs.c +++ /dev/null @@ -1,43 +0,0 @@ -#include "krb5_locl.h" - - -/* - * Try to get all addresses, but return the one corresponding to - * `hostname' if we fail. - */ - -krb5_error_code -krb5_get_all_client_addrs (krb5_addresses *res) -{ - krb5_error_code err; - char hostname[MAXHOSTNAMELEN]; - struct hostent *hostent; - - if (gethostname (hostname, sizeof(hostname))) - return errno; - hostent = gethostbyname (hostname); - if (hostent == NULL) - return errno; - res->number = 1; - res->addrs = malloc (sizeof(*res->addrs)); - res->addrs[0].type = hostent->h_addrtype; - res->addrs[0].address.data = NULL; - res->addrs[0].address.length = 0; - err = krb5_data_alloc (&res->addrs[0].address, hostent->h_length); - if (err) - return err; - memcpy (res->addrs[0].address.data, - hostent->h_addr, - hostent->h_length); - return 0; -} - -/* - * Same as above, but with the fall-back to INADDR_ANY. - */ - -krb5_error_code -krb5_get_all_server_addrs () -{ - return 0; -} diff --git a/get_cred.c b/get_cred.c deleted file mode 100644 index 408321562..000000000 --- a/get_cred.c +++ /dev/null @@ -1,82 +0,0 @@ -#include -#include - -/* - * - */ - -krb5_error_code -krb5_get_credentials (krb5_context context, - krb5_flags options, - krb5_ccache ccache, - krb5_creds *in_creds, - krb5_creds *out_creds) -{ - return 17; -} -#if 0 - - krb5_error_code err; - Tgs_Req a; - krb5_kdc_rep rep; - krb5_data req, resp; - char buf[BUFSIZ]; - int i; - Buffer buffer; - - /* - * XXX - Check if cred found in ccache - */ - - /* - * Prepare Tgs_Req. - */ - - err = krb5_get_default_in_tkt_etypes (context, &a.etypes); - if (err) - return err; - a.num_etypes = 1; - - err = krb5_get_all_client_addrs (&a.addrs); - if (err) - return err; - - a.pvno = 5; - a.msg_type = KRB_TGS_REQ; - memset (&a.kdc_options, 0, sizeof(a.kdc_options)); - /* a.kdc_options */ - a.realm.length = 0; - krb5_data_copy (&a.realm, in_creds->server->realm.data, - in_creds->server->realm.length); - krb5_copy_principal (context, in_creds->server, &a.sname); - a.till = in_creds->times.endtime; - a.nonce = 17; - a.cname = NULL; - - /* - * Encode - */ - - req.length = der_put_as_req (buf + sizeof (buf) - 1, &a); - req.data = buf + sizeof(buf) - req.length; - - for (i = 0; i < a.addrs.number; ++i) - krb5_data_free (&a.addrs.addrs[i].address); - free (a.addrs.addrs); - - /* - * Send and receive - */ - - err = krb5_sendto_kdc (context, &req, &a.realm, &resp); - if (err) { - return err; - } - buf_init (&buffer, resp.data, resp.length); - if (der_get_tgs_rep (&buffer, &rep) == -1) { - return ASN1_PARSE_ERROR; - } - - -} -#endif diff --git a/get_in_tkt.c b/get_in_tkt.c deleted file mode 100644 index 2faa45e60..000000000 --- a/get_in_tkt.c +++ /dev/null @@ -1,271 +0,0 @@ -#include "krb5_locl.h" -#include - -static krb5_error_code -krb5_get_salt (krb5_principal princ, - krb5_data realm, - krb5_data *salt) -{ - size_t len; - int i; - krb5_error_code err; - char *p; - - len = realm.length; - for (i = 0; i < princ->ncomp; ++i) - len += princ->comp[i].length; - err = krb5_data_alloc (salt, len); - if (err) - return err; - p = salt->data; - strncpy (p, realm.data, realm.length); - p += realm.length; - for (i = 0; i < princ->ncomp; ++i) { - strncpy (p, princ->comp[i].data, princ->comp[i].length); - p += princ->comp[i].length; - } - return 0; -} - -static krb5_error_code -decrypt_tkt (krb5_context context, - const krb5_keyblock *key, - krb5_const_pointer decrypt_arg, - krb5_kdc_rep *dec_rep) -{ - des_key_schedule sched; - char *buf; - int i; - int len = dec_rep->part1.enc_part.cipher.length; - - des_set_key (key->contents.data, sched); - buf = malloc (len); - if (buf == NULL) - return ENOMEM; - des_cbc_encrypt ((des_cblock *)dec_rep->part1.enc_part.cipher.data, - (des_cblock *)buf, - len, - sched, - key->contents.data, - DES_DECRYPT); - /* XXX: Check CRC */ - - i = decode_EncTGSRepPart((unsigned char*)buf + 12, len - 12, &dec_rep->part2); - free (buf); - if (i < 0) - return ASN1_PARSE_ERROR; - return 0; -} - -/* - * - */ - -krb5_error_code -krb5_principal2principalname (PrincipalName *p, - krb5_principal from) -{ - int i; - - p->name_type = from->type; - p->name_string.len = from->ncomp; - p->name_string.val = malloc(from->ncomp * sizeof(*p->name_string.val)); - for (i = 0; i < from->ncomp; ++i) { - int len = from->comp[i].length; - p->name_string.val[i] = malloc(len + 1); - strncpy (p->name_string.val[i], from->comp[i].data, len); - p->name_string.val[i][len] = '\0'; - } - return 0; -} - -krb5_error_code -principalname2krb5_principal (krb5_principal p, - PrincipalName from, - krb5_data realm) -{ - int i; - - p = malloc (sizeof(*p)); - p->type = from.name_type; - p->ncomp = from.name_string.len; - p->comp = malloc (p->ncomp * sizeof(*p->comp)); - for (i = 0; i < p->ncomp; ++i) { - int len = strlen(from.name_string.val[i]) + 1; - p->comp[i].length = len; - p->comp[i].data = strdup(from.name_string.val[i]); - } - p->realm = realm; - return 0; -} - -/* - * - */ - -krb5_error_code -krb5_get_in_tkt(krb5_context context, - krb5_flags options, - krb5_address *const *addrs, - const krb5_enctype *etypes, - const krb5_preauthtype *ptypes, - krb5_key_proc key_proc, - krb5_const_pointer keyseed, - krb5_decrypt_proc decrypt_proc, - krb5_const_pointer decryptarg, - krb5_creds *creds, - krb5_ccache ccache, - krb5_kdc_rep **ret_as_reply) -{ - krb5_error_code err; - AS_REQ a; - krb5_kdc_rep rep; - krb5_data req, resp; - char buf[BUFSIZ]; - krb5_data salt; - krb5_keyblock *key; - - a.pvno = 5; - a.msg_type = krb_as_req; - memset (&a.req_body.kdc_options, 0, sizeof(a.req_body.kdc_options)); -/* a.kdc_options */ - a.req_body.cname = malloc(sizeof(*a.req_body.cname)); - a.req_body.sname = malloc(sizeof(*a.req_body.sname)); - krb5_principal2principalname (a.req_body.cname, creds->client); - krb5_principal2principalname (a.req_body.sname, creds->server); - a.req_body.realm = malloc(creds->client->realm.length + 1); - strncpy (a.req_body.realm, creds->client->realm.data, - creds->client->realm.length); - a.req_body.realm[creds->client->realm.length] = '\0'; - - a.req_body.till = creds->times.endtime; - a.req_body.nonce = 17; - if (etypes) - abort (); - else { - err = krb5_get_default_in_tkt_etypes (context, - (krb5_enctype**)&a.req_body.etype.val); - if (err) - return err; - a.req_body.etype.len = 1; - } - if (addrs){ - } else { - a.req_body.addresses = malloc(sizeof(*a.req_body.addresses)); - - err = krb5_get_all_client_addrs ((krb5_addresses*)a.req_body.addresses); - if (err) - return err; - } - a.req_body.enc_authorization_data = NULL; - a.req_body.additional_tickets = NULL; - a.padata = NULL; - - req.length = encode_AS_REQ ((unsigned char*)buf + sizeof(buf) - 1, - sizeof(buf), - &a); - if (req.length < 0) - return ASN1_PARSE_ERROR; - req.data = buf + sizeof(buf) - req.length; - if (addrs == NULL) { - int i; - - for (i = 0; i < a.req_body.addresses->len; ++i) - krb5_data_free (&a.req_body.addresses->val[i].address); - free (a.req_body.addresses->val); - } - - err = krb5_sendto_kdc (context, &req, &creds->client->realm, &resp); - if (err) { - return err; - } - if(decode_AS_REP(resp.data, resp.length, &rep.part1) < 0) - return ASN1_PARSE_ERROR; - - free (rep.part1.crealm); - /* krb5_principal_free (rep.part1.cname);*/ - creds->ticket.kvno = rep.part1.ticket.tkt_vno; - creds->ticket.etype = rep.part1.enc_part.etype; - creds->ticket.enc_part.length = 0; - creds->ticket.enc_part.data = NULL; - krb5_data_copy (&creds->ticket.enc_part, - rep.part1.ticket.enc_part.cipher.data, - rep.part1.ticket.enc_part.cipher.length); - krb5_data_free (&rep.part1.ticket.enc_part.cipher); - - principalname2krb5_principal (creds->ticket.sprinc, - rep.part1.ticket.sname, - creds->client->realm); - /* krb5_free_principal (rep.part1.ticket.sprinc);*/ - - salt.length = 0; - salt.data = NULL; - err = krb5_get_salt (creds->client, creds->client->realm, &salt); - if (err) - return err; - err = (*key_proc)(context, rep.part1.enc_part.etype, &salt, - keyseed, &key); - krb5_data_free (&salt); - if (err) - return err; - - if (decrypt_proc == NULL) - decrypt_proc = decrypt_tkt; - - err = (*decrypt_proc)(context, key, decryptarg, &rep); - if (err) - return err; - memset (key->contents.data, 0, key->contents.length); - krb5_data_free (&key->contents); - free (key); - if (rep.part2.key_expiration) - free (rep.part2.key_expiration); - if (rep.part2.starttime) { - creds->times.starttime = *rep.part2.starttime; - free (rep.part2.starttime); - } else - creds->times.starttime = rep.part2.authtime; - if (rep.part2.renew_till) { - creds->times.renew_till = *rep.part2.renew_till; - free (rep.part2.renew_till); - } else - creds->times.renew_till = rep.part2.endtime; - creds->times.authtime = rep.part2.authtime; - creds->times.endtime = rep.part2.endtime; -#if 0 /* What? */ - if (rep.part2.req.values) - free (rep.part2.req.values); -#endif -#if 0 - if (rep.part2.caddr.addrs) { - int i; - - for (i = 0; i < rep.part2.caddr.number; ++i) { - krb5_data_free (&rep.part2.caddr.addrs[i].address); - } - free (rep.part2.caddr.addrs); - } - krb5_principal_free (rep.part2.sname); - krb5_data_free (&rep.part2.srealm); -#endif - - if (err) - return err; - - creds->session.contents.length = 0; - creds->session.contents.data = NULL; - creds->session.keytype = rep.part2.key.keytype; - err = krb5_data_copy (&creds->session.contents, - rep.part2.key.keyvalue.data, - rep.part2.key.keyvalue.length); - memset (rep.part2.key.keyvalue.data, 0, - rep.part2.key.keyvalue.length); - krb5_data_free (&rep.part2.key.keyvalue); - creds->authdata.length = 0; - creds->authdata.data = NULL; - - if (err) - return err; - - return krb5_cc_store_cred (context, ccache, creds); -} diff --git a/get_in_tkt_pw.c b/get_in_tkt_pw.c deleted file mode 100644 index 908583543..000000000 --- a/get_in_tkt_pw.c +++ /dev/null @@ -1,43 +0,0 @@ -#include "krb5_locl.h" - -static krb5_error_code -key_proc (krb5_context context, - krb5_keytype type, - krb5_data *salt, - krb5_const_pointer keyseed, - krb5_keyblock **key) -{ - krb5_error_code err; - char *password = (char *)keyseed; - char buf[BUFSIZ]; - - *key = malloc (sizeof (**key)); - if (*key == NULL) - return ENOMEM; - (*key)->keytype = type; - (*key)->contents.length = 0; - (*key)->contents.data = NULL; - if (password == NULL) { - des_read_pw_string (buf, sizeof(buf), "Password: ", 0); - password = buf; - } - err = krb5_string_to_key (password, salt, *key); - memset (buf, 0, sizeof(buf)); - return err; -} - -krb5_error_code -krb5_get_in_tkt_with_password (krb5_context context, - krb5_flags options, - krb5_address *const *addrs, - const krb5_enctype *etypes, - const krb5_preauthtype *pre_auth_types, - const char *password, - krb5_ccache ccache, - krb5_creds *creds, - krb5_kdc_rep **ret_as_reply) -{ - return krb5_get_in_tkt (context, options, addrs, etypes, - pre_auth_types, key_proc, password, - NULL, NULL, creds, ccache, ret_as_reply); -} diff --git a/get_port.c b/get_port.c deleted file mode 100644 index 767201672..000000000 --- a/get_port.c +++ /dev/null @@ -1,17 +0,0 @@ -#include - -int -krb5_getportbyname (const char *service, - const char *proto, - int default_port) -{ - struct servent *sp; - - if ((sp = getservbyname (service, proto)) == NULL) { - fprintf (stderr, "%s/%s unknown service, " - "using default port %d\n", service, proto, - ntohs(default_port)); - return default_port; - } else - return sp->s_port; -} diff --git a/kinit.c b/kinit.c deleted file mode 100644 index 3b321367b..000000000 --- a/kinit.c +++ /dev/null @@ -1,58 +0,0 @@ -#include -#include - -int -main (int argc, char **argv) -{ - krb5_error_code err; - krb5_context context; - krb5_ccache ccache; - krb5_principal principal; - krb5_principal server; - krb5_creds cred; - - err = krb5_init_context (&context); - if (err) - abort (); - - err = krb5_cc_default (context, &ccache); - if (err) - abort (); - - err = krb5_parse_name (context, argv[1], &principal); - if (err) - abort (); - - err = krb5_cc_initialize (context, ccache, principal); - if (err) - abort (); - - cred.client = principal; - cred.times.endtime = time (NULL) + 4711; - - err = krb5_build_principal (context, - &cred.server, - principal->realm.length, - principal->realm.data, - "krbtgt", - principal->realm.data, - NULL); - if (err) - abort (); - cred.server->type = KRB5_NT_SRV_INST; - - err = krb5_get_in_tkt_with_password (context, - 0, - NULL, - NULL, - NULL, - NULL, - ccache, - &cred, - NULL); - if (err) - abort (); - - krb5_free_context (context); - return 0; -} diff --git a/klist.c b/klist.c deleted file mode 100644 index 34dbbe1f1..000000000 --- a/klist.c +++ /dev/null @@ -1,65 +0,0 @@ -#include -#include -#include - - -int -main (int argc, char **argv) -{ - krb5_error_code err; - krb5_context context; - krb5_ccache ccache; - krb5_principal principal; - krb5_cc_cursor cursor; - krb5_creds creds; - char *str; - - err = krb5_init_context (&context); - if (err) - abort (); - - err = krb5_cc_default (context, &ccache); - if (err) - abort (); - - err = krb5_cc_get_principal (context, ccache, &principal); - if (err) - abort (); - - err = krb5_unparse_name (context, principal, &str); - if (err) - abort (); - - printf ("Principal: %s\n", str); - free (str); - - err = krb5_cc_start_seq_get (context, ccache, &cursor); - if (err) - abort (); - - while (krb5_cc_next_cred (context, - ccache, - &creds, - &cursor) == 0) { - err = krb5_unparse_name (context, creds.server, &str); - if (err) - abort (); - printf ("%s\t", str); - free (str); - printf ("%s\t", ctime(&creds.times.authtime)); - printf ("%s\n", ctime(&creds.times.endtime)); - } - err = krb5_cc_end_seq_get (context, ccache, &cursor); - if (err) - return err; - - err = krb5_cc_close (context, ccache); - if (err) - abort (); - - - krb5_free_principal (principal); - - krb5_free_context (context); - return 0; -} diff --git a/krb5.conf b/krb5.conf index 174c3c7ba..d0880a9c4 100644 --- a/krb5.conf +++ b/krb5.conf @@ -10,6 +10,9 @@ default_domain = x-dce.pdc.kth.se } + FOO.SE = { + kdc = emma.pdc.kth.se:88 + } ATHENA.MIT.EDU = { kdc = KERBEROS-2.MIT.EDU:88 kdc = KERBEROS.MIT.EDU diff --git a/krb5.h b/krb5.h deleted file mode 100644 index facffa2f6..000000000 --- a/krb5.h +++ /dev/null @@ -1,422 +0,0 @@ -#ifndef __KRB5_H__ -#define __KRB5_H__ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include -#include -#include - -#ifdef HAVE_SYS_BITYPES_H -#include -#endif - -#include "config_file.h" - -/* simple constants */ - -#ifndef TRUE -#define TRUE 1 -#define FALSE 0 -#endif - -#if 1 -/* types */ -typedef int int32_t; -typedef short int16_t; -typedef char int8_t; - -typedef unsigned int u_int32_t; -typedef unsigned short u_int16_t; -typedef unsigned char u_int8_t; -#endif - -typedef int krb5_boolean; - -typedef int32_t krb5_error_code; - - - -typedef void *krb5_pointer; -typedef const void *krb5_const_pointer; - -typedef struct krb5_data{ - size_t length; - krb5_pointer data; -} krb5_data; - - -typedef enum krb5_cksumtype { - CKSUMTYPE_NONE = 0, - CKSUMTYPE_CRC32 = 1, - CKSUMTYPE_RSA_MD4 = 2, - CKSUMTYPE_RSA_MD4_DES = 3, - CKSUMTYPE_DES_MAC = 4, - CKSUMTYPE_DES_MAC_K = 5, - CKSUMTYPE_RSA_MD4_DES_K = 6, - CKSUMTYPE_RSA_MD5_DES = 7 -} krb5_cksumtype; - - - -typedef enum krb5_enctype { - ETYPE_NONE = 0, - ETYPE_DES_CBC_CRC = 1, - ETYPE_DES_CBC_MD4 = 2, - ETYPE_DES_CBC_MD5 = 3 -} krb5_enctype; - -typedef enum krb5_preauthtype { - KRB5_PADATA_NONE = 0, - KRB5_PADATA_AP_REQ, - KRB5_PADATA_TGS_REQ = 1, - KRB5_PADATA_PW_SALT = 3, - KRB5_PADATA_ENC_TIMESTAMP = 2, - KRB5_PADATA_ENC_SECURID -} krb5_preauthtype; - - -typedef enum krb5_address_type { - KRB5_ADDRESS_INET = 2 -} krb5_address_type; - -typedef struct krb5_address{ - krb5_address_type type; - krb5_data address; -} krb5_address; - -typedef struct krb5_addresses { - int number; - krb5_address *addrs; -} krb5_addresses; - -typedef enum krb5_keytype { KEYTYPE_DES } krb5_keytype; - -typedef struct krb5_keyblock{ - krb5_keytype keytype; - krb5_data contents; -} krb5_keyblock; - -typedef struct krb5_context_data{ - krb5_enctype *etypes; - char *default_realm; - k5_cfile *cf; -} krb5_context_data; - -typedef krb5_context_data *krb5_context; - - -typedef time_t krb5_time; - -typedef struct krb5_times{ - krb5_time authtime; - krb5_time starttime; - krb5_time endtime; - krb5_time renew_till; -} krb5_times; - - -enum{ - KRB5_NT_UNKNOWNN = 0, - KRB5_NT_PRINCIPAL = 1, - KRB5_NT_SRV_INST = 2, - KRB5_NT_SRV_HST = 3, - KRB5_NT_SRV_XHST = 4, - KRB5_NT_UID = 5 -}; - -typedef struct krb5_principal_data{ - int type; - krb5_data realm; - krb5_data *comp; - int ncomp; -}krb5_principal_data; - -typedef krb5_principal_data *krb5_principal; -typedef const krb5_principal_data *krb5_const_principal; - -typedef krb5_data krb5_realm; - -typedef struct krb5_ticket{ - int kvno; - krb5_principal sprinc; - krb5_data enc_part; - krb5_data enc_part2; - krb5_enctype etype; -}krb5_ticket; - -#define KRB5_PARSE_MALFORMED 17 -#define KRB5_PROG_ETYPE_NOSUPP 4711 - -typedef struct krb5_creds { - krb5_principal client; - krb5_principal server; - krb5_keyblock session; - krb5_times times; - krb5_ticket ticket; - - krb5_ticket second_ticket; /* ? */ - krb5_data authdata; /* ? */ - krb5_addresses addresses; - -} krb5_creds; - - -typedef struct krb5_authenticator_data{ - int vno; - krb5_principal cname; - int cusec; - krb5_time ctime; - int *seq_number; -} krb5_authenticator_data; - -typedef krb5_authenticator_data *krb5_authenticator; - -typedef struct krb5_rcache{ - int dummy; -}krb5_rcache; - -typedef struct krb5_ccache_data{ - int type; - krb5_data data; -}krb5_ccache_data; - -typedef struct krb5_ccache_data *krb5_ccache; - -typedef struct krb5_fcache{ - char *filename; -}krb5_fcache; - -typedef struct krb5_cc_cursor{ - int fd; -}krb5_cc_cursor; - -typedef struct krb5_keytab{ - int dummy; -}krb5_keytab; - - -typedef struct krb5_auth_context{ - int32_t flags; - krb5_cksumtype cksumtype; - - krb5_address local_address; - krb5_address remote_address; - krb5_keyblock key; - krb5_keyblock local_subkey; - krb5_keyblock remote_subkey; - - int32_t local_seqnumber; - int32_t remote_seqnumber; - - krb5_authenticator authenticator; - - krb5_pointer i_vector; - - krb5_rcache rcache; - -}krb5_auth_context; - - -typedef u_int32_t krb5_flags; - -#include - -typedef struct { - KDC_REP part1; - EncTGSRepPart part2; -} krb5_kdc_rep; - -krb5_error_code -krb5_init_context(krb5_context *context); - - -krb5_error_code -krb5_get_cred_from_kdc(krb5_context, - krb5_ccache ccache, - krb5_creds *in_cred, - krb5_creds **out_cred, - krb5_creds **tgts); - - -krb5_error_code -krb5_get_credentials(krb5_context context, - krb5_flags options, - krb5_ccache ccache, - krb5_creds *in_creds, - krb5_creds *out_creds); - -typedef krb5_error_code (*krb5_key_proc)(krb5_context context, - krb5_keytype type, - krb5_data *salt, - krb5_const_pointer keyseed, - krb5_keyblock **key); -typedef krb5_error_code (*krb5_decrypt_proc)(krb5_context context, - const krb5_keyblock *key, - krb5_const_pointer decrypt_arg, - krb5_kdc_rep *dec_rep); - -krb5_error_code -krb5_get_in_tkt(krb5_context context, - krb5_flags options, - krb5_address *const *addrs, - const krb5_enctype *etypes, - const krb5_preauthtype *ptypes, - krb5_key_proc key_proc, - krb5_const_pointer keyseed, - krb5_decrypt_proc decrypt_proc, - krb5_const_pointer decryptarg, - krb5_creds *creds, - krb5_ccache ccache, - krb5_kdc_rep **ret_as_reply); - -krb5_error_code -krb5_get_in_tkt_with_password (krb5_context context, - krb5_flags options, - krb5_address *const *addrs, - const krb5_enctype *etypes, - const krb5_preauthtype *pre_auth_types, - const char *password, - krb5_ccache ccache, - krb5_creds *creds, - krb5_kdc_rep **ret_as_reply); - -krb5_error_code -krb5_mk_req(krb5_context context, - krb5_auth_context **auth_context, - const krb5_flags ap_req_options, - char *service, - char *hostname, - krb5_data *in_data, - krb5_ccache ccache, - krb5_data *outbuf); - -krb5_error_code -krb5_generate_subkey(krb5_context context, - const krb5_keyblock *key, - krb5_keyblock **subkey); - - -krb5_error_code -krb5_rd_req(krb5_context context, - krb5_auth_context **auth_context, - const krb5_data *inbuf, - krb5_const_principal server, - krb5_keytab keytab, - krb5_flags *ap_req_options, - krb5_ticket **ticket); - - -krb5_error_code -krb5_parse_name(krb5_context context, - const char *name, - krb5_principal *principal); - -void -krb5_free_principal(krb5_principal principal); - -krb5_error_code -krb5_unparse_name(krb5_context context, - krb5_principal principal, - char **name); - -krb5_error_code -krb5_unparse_name_ext(krb5_context context, - krb5_const_principal principal, - char **name, - size_t *size); - -krb5_data* -krb5_princ_realm(krb5_context context, - krb5_principal principal); - -void -krb5_princ_set_realm(krb5_context context, - krb5_principal principal, - krb5_data *realm); - -krb5_error_code -krb5_build_principal(krb5_context context, - krb5_principal *principal, - int rlen, - const char *realm, - ...); - -krb5_error_code -krb5_build_principal_va(krb5_context context, - krb5_principal *principal, - int rlen, - const char *realm, - va_list ap); - -krb5_error_code -krb5_build_principal_ext(krb5_context context, - krb5_principal *principal, - int rlen, - const char *realm, - ...); - -krb5_error_code -krb5_copy_principal(krb5_context context, - krb5_const_principal inprinc, - krb5_principal *outprinc); - -krb5_boolean -krb5_principal_compare(krb5_context context, - krb5_const_principal princ1, - krb5_const_principal princ2); - -krb5_boolean -krb5_realm_compare(krb5_context context, - krb5_const_principal princ1, - krb5_const_principal princ2); - -krb5_error_code -krb5_425_conv_principal(krb5_context context, - const char *name, - const char *instance, - const char *realm, - krb5_principal *princ); - -krb5_error_code -krb5_get_krbhst (krb5_context context, - const krb5_data *realm, - char ***hostlist); - -krb5_error_code -krb5_free_krbhst (krb5_context context, - char *const *hostlist); - - -/* variables */ - -extern const char krb5_config_file[]; -extern const char krb5_defkeyname[]; - -void krb5_free_context(krb5_context context); - - -krb5_error_code -krb5_get_all_client_addrs (krb5_addresses *res); - -krb5_error_code -krb5_set_default_in_tkt_etypes(krb5_context context, - const krb5_enctype *etypes); -krb5_error_code -krb5_get_default_in_tkt_etypes(krb5_context context, - krb5_enctype **etypes); - - -krb5_error_code -krb5_string_to_key (char *str, - krb5_data *salt, - krb5_keyblock *key); - - -#include "cache.h" - - -#endif /* __KRB5_H__ */ - diff --git a/krb5_error.h b/krb5_error.h deleted file mode 100644 index a013f0615..000000000 --- a/krb5_error.h +++ /dev/null @@ -1,58 +0,0 @@ -#ifndef __KRB5_ERROR_H__ -#define __KRB5_ERROR_H__ - -#define KDC_ERR_NONE 0 -#define KDC_ERR_NAME_EXP 1 -#define KDC_ERR_SERVICE_EXP 2 -#define KDC_ERR_BAD_PVNO 3 -#define KDC_ERR_C_OLD_MAST_KVNO 4 -#define KDC_ERR_S_OLD_MAST_KVNO 5 -#define KDC_ERR_C_PRINCIPAL_UNKNOWN 6 -#define KDC_ERR_S_PRINCIPAL_UNKNOWN 7 -#define KDC_ERR_PRINCIPAL_NOT_UNIQUE 8 -#define KDC_ERR_NULL_KEY 9 -#define KDC_ERR_CANNOT_POSTDATE 10 -#define KDC_ERR_NEVER_VALID 11 -#define KDC_ERR_POLICY 12 -#define KDC_ERR_BADOPTION 13 -#define KDC_ERR_ETYPE_NOSUPP 14 -#define KDC_ERR_SUMTYPE_NOSUPP 15 -#define KDC_ERR_PADATA_TYPE_NOSUPP 16 -#define KDC_ERR_TRTYPE_NOSUPP 17 -#define KDC_ERR_CLIENT_REVOKED 18 -#define KDC_ERR_SERVICE_REVOKED 19 -#define KDC_ERR_TGT_REVOKED 20 -#define KDC_ERR_CLIENT_NOTYET 21 -#define KDC_ERR_SERVICE_NOTYET 22 -#define KDC_ERR_KEY_EXPIRED 23 -#define KDC_ERR_PREAUTH_FAILED 24 -#define KDC_ERR_PREAUTH_REQUIRED 25 -#define KRB_AP_ERR_BAD_INTEGRITY 31 -#define KRB_AP_ERR_TKT_EXPIRED 32 -#define KRB_AP_ERR_TKT_NYV 33 -#define KRB_AP_ERR_REPEAT 34 -#define KRB_AP_ERR_NOT_US 35 -#define KRB_AP_ERR_BADMATCH 36 -#define KRB_AP_ERR_SKEW 37 -#define KRB_AP_ERR_BADADDR 38 -#define KRB_AP_ERR_BADVERSION 39 -#define KRB_AP_ERR_MSG_TYPE 40 -#define KRB_AP_ERR_MODIFIED 41 -#define KRB_AP_ERR_BADORDER 42 -#define KRB_AP_ERR_BADKEYVER 44 -#define KRB_AP_ERR_NOKEY 45 -#define KRB_AP_ERR_MUT_FAIL 46 -#define KRB_AP_ERR_BADDIRECTION 47 -#define KRB_AP_ERR_METHOD 48 -#define KRB_AP_ERR_BADSEQ 49 -#define KRB_AP_ERR_INAPP_CKSUM 50 -#define KRB_ERR_GENERIC 60 -#define KRB_ERR_FIELD_TOOLONG 61 - -#define KRB5_KDC_UNREACH 155 - -/* Just some random number */ - -#define ASN1_PARSE_ERROR 274 - -#endif /* __KRB5_ERROR_H__ */ diff --git a/krb5_locl.h b/krb5_locl.h deleted file mode 100644 index 5172d5aa1..000000000 --- a/krb5_locl.h +++ /dev/null @@ -1,66 +0,0 @@ -#ifndef __KRB5_LOCL_H__ -#define __KRB5_LOCL_H__ - -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -extern int ioctl(int, int, ...); - - -#include -#include -#include -#include -#include -#include -#ifdef HAVE_SYS_FILIO_H -#include -#endif -#include - -#include "krb5.h" - -void krb5_data_free(krb5_data *); -krb5_error_code krb5_data_alloc(krb5_data *, int); -krb5_error_code krb5_data_realloc(krb5_data *, int); -krb5_error_code krb5_data_copy(krb5_data *, void *, size_t); - - -krb5_error_code krb5_principal_alloc(krb5_principal*); -void krb5_principal_free(krb5_principal); - -krb5_error_code krb5_get_lrealm(char ** realm); - -krb5_error_code -krb5_parse_config_file(k5_cfile **cfile, const char *filename); - -krb5_error_code -krb5_get_config_tag(k5_cfile *cf, const char *tag, char **value); - -int -krb5_getportbyname (const char *service, - const char *proto, - int default_port); - -krb5_error_code -krb5_sendto_kdc (krb5_context context, - const krb5_data *send, - const krb5_data *realm, - krb5_data *receive); - - - -#define ALLOC(N, X) ((X*)malloc((N) * sizeof(X))) -#define FREE(X) do{if(X)free(X);}while(0) - -#define RCSID(X) static char *rcsid[] = { (char*)rcsid, X } - -#endif /* __KRB5_LOCL_H__ */ diff --git a/krbhst.c b/krbhst.c deleted file mode 100644 index 4c2aaf67a..000000000 --- a/krbhst.c +++ /dev/null @@ -1,28 +0,0 @@ -#include "krb5_locl.h" - -krb5_error_code -krb5_get_krbhst (krb5_context context, - const krb5_data *realm, - char ***hostlist) -{ - krb5_error_code err; - char buf[BUFSIZ]; - char *val; - - sprintf (buf, "realms %.*s kdc", (int)realm->length, (char*)realm->data); - err = krb5_get_config_tag (context->cf, buf, &val); - if (err) - return err; - *hostlist = malloc (2 * sizeof (char *)); - (*hostlist)[0] = val; - (*hostlist)[1] = NULL; - return 0; -} - -krb5_error_code -krb5_free_krbhst (krb5_context context, - char *const *hostlist) -{ - free ((void*)hostlist); - return 0; /* XXX */ -} diff --git a/misc.c b/misc.c deleted file mode 100644 index 37e8e153a..000000000 --- a/misc.c +++ /dev/null @@ -1,27 +0,0 @@ -#include "krb5_locl.h" - - -krb5_error_code -krb5_get_lrealm(char **realm) -{ - FILE *F; - char s[128]; - char *p, *q; - F = fopen("/etc/krb5.conf", "r"); - while(fgets(s, 128, F)){ - if((p = strstr(s, "default_realm"))){ - p = strchr(p, '='); - p++; - while(isspace(*p)) p++; - q = p; - while(isalnum(*p) || strchr("_.-", *p)) p++; - *p=0; - *realm = strdup(q); - fclose(F); - return 0; - } - } - fclose(F); - *realm = 0; - return 0; -} diff --git a/mkinstalldirs b/mkinstalldirs new file mode 100755 index 000000000..d0fd194fd --- /dev/null +++ b/mkinstalldirs @@ -0,0 +1,40 @@ +#! /bin/sh +# mkinstalldirs --- make directory hierarchy +# Author: Noah Friedman +# Created: 1993-05-16 +# Public domain + +# $Id$ + +errstatus=0 + +for file +do + set fnord `echo ":$file" | sed -ne 's/^:\//#/;s/^://;s/\// /g;s/^#/\//;p'` + shift + + pathcomp= + for d + do + pathcomp="$pathcomp$d" + case "$pathcomp" in + -* ) pathcomp=./$pathcomp ;; + esac + + if test ! -d "$pathcomp"; then + echo "mkdir $pathcomp" 1>&2 + + mkdir "$pathcomp" || lasterr=$? + + if test ! -d "$pathcomp"; then + errstatus=$lasterr + fi + fi + + pathcomp="$pathcomp/" + done +done + +exit $errstatus + +# mkinstalldirs ends here diff --git a/principal.c b/principal.c deleted file mode 100644 index ae3a6b9b8..000000000 --- a/principal.c +++ /dev/null @@ -1,359 +0,0 @@ -#include "krb5_locl.h" - -RCSID("$Id$"); - -/* XXX */ - -#ifdef sun -#define memmove(a,b,c) bcopy(b,a,c) -#endif - -/* Public principal handling functions */ - -void -krb5_free_principal(krb5_principal p) -{ - krb5_principal_free(p); -} - -krb5_error_code -krb5_parse_name(krb5_context context, - const char *name, - krb5_principal *principal) -{ - - krb5_data *comp; - int ncomp; - krb5_data realm; - - char *p; - char *q; - char *s; - char *start; - - int n; - char c; - int got_realm = 0; - - /* count number of component */ - ncomp = 1; - for(p = (char*)name; *p; p++){ - if(*p=='\\'){ - if(!p[1]) - return KRB5_PARSE_MALFORMED; - p++; - } else if(*p == '/') - ncomp++; - } - comp = ALLOC(ncomp, krb5_data); - - n = 0; - start = q = p = s = strdup(name); - while(*p){ - c = *p++; - if(c == '\\'){ - c = *p++; - if(c == 'n') - c = '\n'; - else if(c == 't') - c = '\t'; - else if(c == 'b') - c = '\b'; - else if(c == '0') - c = '\0'; - }else if(c == '/' || c == '@'){ - if(got_realm){ - while(n>0) - free(comp[--n].data); - free(comp); - free(s); - return KRB5_PARSE_MALFORMED; - }else{ - comp[n].length = q - start; - comp[n].data = (krb5_pointer)malloc(comp[n].length); - memmove(comp[n].data, start, comp[n].length); - n++; - } - if(c == '@') - got_realm = 1; - start = q; - continue; - } - if(got_realm && (c == ':' || c == '/' || c == '\0')){ - while(n>0) - free(comp[--n].data); - free(comp); - free(s); - return KRB5_PARSE_MALFORMED; - } - *q++ = c; - } - if(got_realm){ - realm.length = q - start; - realm.data = (krb5_pointer)malloc(realm.length); - memmove(realm.data, start, realm.length); - }else{ - comp[n].length = q - start; - comp[n].data = (krb5_pointer)malloc(comp[n].length); - memmove(comp[n].data, start, comp[n].length); - n++; - } - *principal = ALLOC(1, krb5_principal_data); - (*principal)->type = KRB5_NT_PRINCIPAL; - (*principal)->realm = realm; - (*principal)->comp = comp; - (*principal)->ncomp = n; - free(s); - return 0; -} - -static void quote_string(char *s, int len, char **out) -{ - char *q; - char *p = *out; - int c=0; - for(q = s; q < s + len; q++){ - if(*q == '\n') - c = 'n'; - else if(*q == '\t') - c = 't'; - else if(*q == '\b') - c = 'b'; - else if(*q == '\0') - c = '0'; - else if(*q == '/') - c='/'; - else if(*q == '@') - c = '@'; - if(c){ - *p++ = '\\'; - *p++ = c; - c = 0; - }else - *p++ = *q; - } - *out = p; -} - - -krb5_error_code -krb5_unparse_name(krb5_context context, - krb5_principal principal, - char **name) -{ - int size = 0; - char *p; - char *s; - int i; - for(i = 0; i < principal->ncomp; i++) - size += 2*principal->comp[i].length + 1; - size += 2*principal->realm.length + 1; - s = ALLOC(size, char); - p = s; - for(i = 0; i < principal->ncomp; i++){ - if(i) *p++ = '/'; - quote_string(principal->comp[i].data, principal->comp[i].length, &p); - } - *p++ = '@'; - quote_string(principal->realm.data, principal->realm.length, &p); - *p = 0; - *name = strdup(s); - free(s); - return 0; -} - - -krb5_error_code -krb5_unparse_name_ext(krb5_context context, - krb5_const_principal principal, - char **name, - size_t *size) -{ - fprintf(stderr, "krb5_unparse_name_ext: not implemented\n"); - abort(); -} - - -krb5_data* -krb5_princ_realm(krb5_context context, - krb5_principal principal) -{ - return &principal->realm; -} - - -void -krb5_princ_set_realm(krb5_context context, - krb5_principal principal, - krb5_data *realm) -{ - principal->realm = *realm; -} - - -krb5_error_code -krb5_build_principal(krb5_context context, - krb5_principal *principal, - int rlen, - const char *realm, - ...) -{ - krb5_error_code ret; - va_list ap; - va_start(ap, realm); - ret = krb5_build_principal_va(context, principal, rlen, realm, ap); - va_end(ap); - return ret; -} - -krb5_error_code -krb5_principal_set_component(krb5_principal p, int n, void *data, size_t len) -{ - krb5_data *tmp; - if(p->ncomp <= n){ - int s = n + 10; - if(p->comp) - tmp = (krb5_data*)realloc(p->comp, s * sizeof(krb5_data)); - else - tmp = ALLOC(s, krb5_data); - if(!tmp) - return ENOMEM; - p->comp = tmp; - p->ncomp = s; - } - p->comp[n].length = 0; - p->comp[n].data = NULL; - krb5_data_copy(&p->comp[n], data, len); - return 0; -} - - -krb5_error_code -krb5_build_principal_va(krb5_context context, - krb5_principal *principal, - int rlen, - const char *realm, - va_list ap) -{ - krb5_principal p; - int n; - char *s; - - if(krb5_principal_alloc(&p)) - return ENOMEM; - p->type = KRB5_NT_PRINCIPAL; - - if(krb5_data_copy(&p->realm, (void*)realm, rlen)){ - free(p); - return ENOMEM; - } - - n = 0; - while(1){ - s = va_arg(ap, char*); - if(s == NULL) - break; - krb5_principal_set_component(p, n, s, strlen(s)); - n++; - } - p->ncomp = n; - *principal = p; - return 0; -} - - -krb5_error_code -krb5_build_principal_ext(krb5_context context, - krb5_principal *principal, - int rlen, - const char *realm, - ...) -{ - fprintf(stderr, "krb5_build_principal_ext: not implemented\n"); - abort(); -} - - -krb5_error_code -krb5_copy_principal(krb5_context context, - krb5_const_principal inprinc, - krb5_principal *outprinc) -{ - krb5_principal p; - int i; - if(krb5_principal_alloc(&p)) - return ENOMEM; - p->type = inprinc->type; - if(krb5_data_copy(&p->realm, inprinc->realm.data, inprinc->realm.length)){ - krb5_free_principal(p); - return ENOMEM; - } - p->comp = ALLOC(inprinc->ncomp, krb5_data); - if(!p->comp){ - krb5_free_principal(p); - return ENOMEM; - } - - for(i=0; incomp; i++){ - p->comp[i].length = 0; - if(krb5_data_copy(&p->comp[i], inprinc->comp[i].data, - inprinc->comp[i].length)){ - krb5_free_principal(p); - return ENOMEM; - } - p->ncomp = i+1; - } - *outprinc = p; - return 0; -} - - -krb5_boolean -krb5_principal_compare(krb5_context context, - krb5_const_principal princ1, - krb5_const_principal princ2) -{ - int i; - if(!krb5_realm_compare(context, princ1, princ2)) - return FALSE; - if(princ1->ncomp != princ2->ncomp) - return FALSE; - for(i=0; incomp; i++){ - if(princ1->comp[i].length != princ2->comp[i].length) - return FALSE; - if(memcmp(princ1->comp[i].data, princ2->comp[i].data, - princ1->comp[i].length)) - return FALSE; - } - return TRUE; -} - - -krb5_boolean -krb5_realm_compare(krb5_context context, - krb5_const_principal princ1, - krb5_const_principal princ2) -{ - if(princ1->realm.length != princ2->realm.length) - return FALSE; - if(memcmp(princ1->realm.data, princ2->realm.data, princ1->realm.length)) - return FALSE; - return TRUE; -} - - -krb5_error_code -krb5_425_conv_principal(krb5_context context, - const char *name, - const char *instance, - const char *realm, - krb5_principal *princ) -{ - if(!strcmp(name, "rcmd")) - name = "host"; - return krb5_build_principal(context, princ, - strlen(realm), realm, name, instance, 0); -} - - - diff --git a/principal.h b/principal.h deleted file mode 100644 index e2e4a4f71..000000000 --- a/principal.h +++ /dev/null @@ -1,6 +0,0 @@ -#ifndef __PRINCIPAL_H__ -#define __PRINCIPAL_H__ - -#include "krb5.h" - -#endif /* __PRINCIPAL_H__ */ diff --git a/principal_p.c b/principal_p.c deleted file mode 100644 index 91362aefe..000000000 --- a/principal_p.c +++ /dev/null @@ -1,24 +0,0 @@ -#include "krb5_locl.h" - -krb5_error_code -krb5_principal_alloc(krb5_principal *p) -{ - krb5_principal tmp; - tmp = ALLOC(1, krb5_principal_data); - if(!tmp) - return ENOMEM; - memset(tmp, 0, sizeof(krb5_principal_data)); - *p = tmp; - return 0; -} - -void -krb5_principal_free(krb5_principal principal) -{ - int i; - for(i = 0; i < principal->ncomp; i++) - krb5_data_free(&principal->comp[i]); - free(principal->comp); - krb5_data_free(&principal->realm); - free(principal); -} diff --git a/send_to_kdc.c b/send_to_kdc.c deleted file mode 100644 index 1b7c0b813..000000000 --- a/send_to_kdc.c +++ /dev/null @@ -1,104 +0,0 @@ -#include "krb5_locl.h" -#include "krb5_error.h" - -static int -send_and_recv (int fd, - struct sockaddr_in *addr, - const krb5_data *send, - krb5_data *recv) -{ - struct fd_set fdset; - struct timeval timeout; - int ret; - int nbytes; - - if (sendto (fd, send->data, send->length, 0, - (struct sockaddr *)addr, sizeof(*addr)) < 0) - return -1; - FD_ZERO(&fdset); - FD_SET(fd, &fdset); - timeout.tv_sec = 3; - timeout.tv_usec = 0; - ret = select (fd + 1, &fdset, NULL, NULL, &timeout); - if (ret <= 0) - return -1; - else { - int len; - - if (ioctl (fd, FIONREAD, &nbytes) < 0) - return -1; - - recv->data = malloc (nbytes); - ret = recvfrom (fd, recv->data, nbytes, 0, NULL, &len); - if (ret < 0) { - free (recv->data); - return -1; - } - recv->data = realloc (recv->data, ret); - recv->length = ret; - return 0; - } -} - -krb5_error_code -krb5_sendto_kdc (krb5_context context, - const krb5_data *send, - const krb5_data *realm, - krb5_data *receive) -{ - krb5_error_code err; - char **hostlist, **hp, *p; - struct hostent *hostent; - int fd; - int port; - int i; - - port = krb5_getportbyname ("kerberos", "udp", htons(88)); - fd = socket (AF_INET, SOCK_DGRAM, 0); - if (fd < 0) { - krb5_free_krbhst (context, hostlist); - return errno; - } - - err = krb5_get_krbhst (context, realm, &hostlist); - if (err) { - close (fd); - return err; - } - - for (i = 0; i < 3; ++i) - for (hp = hostlist; (p = *hp); ++hp) { - char *addr; - char *colon; - - colon = strchr (p, ':'); - if (colon) - *colon = '\0'; - hostent = gethostbyname (p); - if (colon) - *colon++ = ':'; - while ((addr = *hostent->h_addr_list++)) { - struct sockaddr_in a; - - memset (&a, 0, sizeof(a)); - a.sin_family = AF_INET; - if (colon) { - int tmp; - - sscanf (colon, "%d", &tmp); - a.sin_port = htons(tmp); - } else - a.sin_port = port; - a.sin_addr = *((struct in_addr *)addr); - - if (send_and_recv (fd, &a, send, receive) == 0) { - close (fd); - krb5_free_krbhst (context, hostlist); - return 0; - } - } - } - close (fd); - krb5_free_krbhst (context, hostlist); - return KRB5_KDC_UNREACH; -} diff --git a/stamp-h.in b/stamp-h.in new file mode 100644 index 000000000..9788f7023 --- /dev/null +++ b/stamp-h.in @@ -0,0 +1 @@ +timestamp diff --git a/str2key.c b/str2key.c deleted file mode 100644 index b8a38b122..000000000 --- a/str2key.c +++ /dev/null @@ -1,141 +0,0 @@ -#include - -/* - * Reverse 8 bytes - */ - -static void -reverse (unsigned char *s) -{ - static unsigned char tbl[] = { - 0x0, - 0x8, - 0x4, - 0xC, - 0x2, - 0xA, - 0x6, - 0xE, - 0x1, - 0x9, - 0x5, - 0xD, - 0x3, - 0xB, - 0x7, - 0xF - }; - - char tmp; - -#define REVONE(str, i, j) \ -do { tmp = str[i]; str[i] = str[j]; str[j] = tmp;} while(0) - - REVONE(s,0,7); - REVONE(s,1,6); - REVONE(s,2,5); - REVONE(s,3,4); -#undef REVONE - -#define REVTWO(q) \ -q = (tbl[q & 0x0F] << 4) | (tbl[q >> 4]) - - REVTWO(s[0]); - REVTWO(s[1]); - REVTWO(s[2]); - REVTWO(s[3]); - REVTWO(s[4]); - REVTWO(s[5]); - REVTWO(s[6]); - REVTWO(s[7]); - -#undef REVTWO -} - -/* - * A = A xor B. A & B is 8 bytes. - */ - -static void -xor (unsigned char *a, unsigned char *b) -{ - a[0] ^= b[0]; - a[1] ^= b[1]; - a[2] ^= b[2]; - a[3] ^= b[3]; - a[4] ^= b[4]; - a[5] ^= b[5]; - a[6] ^= b[6]; - a[7] ^= b[7]; -} - -/* - * Init a from b - */ - -static void -init (unsigned char *a, unsigned char *b) -{ - a[0] = b[0] << 1; - a[1] = b[1] << 1; - a[2] = b[2] << 1; - a[3] = b[3] << 1; - a[4] = b[4] << 1; - a[5] = b[5] << 1; - a[6] = b[6] << 1; - a[7] = b[7] << 1; -} - -krb5_error_code -krb5_string_to_key (char *str, - krb5_data *salt, - krb5_keyblock *key) -{ - int odd, i; - size_t len; - char *s, *p; - des_cblock tempkey; - des_key_schedule sched; - krb5_error_code err; - - len = strlen(str) + salt->length; -#if 1 - len = (len + 7) / 8 * 8; -#endif - p = s = malloc (len); - if (p == NULL) - return ENOMEM; - err = krb5_data_alloc (&key->contents, sizeof(des_cblock)); - if (err) { - free (p); - return err; - } - memset (s, 0, len); - strncpy (p, str, strlen(str)); - p += strlen(str); - strncpy (p, salt->data, salt->length); - odd = 1; - memset (tempkey, 0, sizeof(tempkey)); - for (i = 0; i < len; i += 8) { - unsigned char tmp[8]; - - init (tmp, (unsigned char*)&s[i]); - - if (odd == 0) { - odd = 1; - reverse (tmp); - init (tmp, tmp); - } else - odd = 0; - xor (tempkey, tmp); - } - des_set_odd_parity (&tempkey); - des_set_key (&tempkey, sched); - des_cbc_cksum ((des_cblock *)s, &tempkey, len, sched, &tempkey); - free (s); - des_set_odd_parity (&tempkey); - if (des_is_weak_key (&tempkey)) - xor ((unsigned char *)&tempkey, (unsigned char*)"0x000x000x000x000x000x000x000xF0"); - memcpy (key->contents.data, &tempkey, sizeof(tempkey)); - return 0; -}