diff options
author | markm <markm@FreeBSD.org> | 2000-01-09 20:58:00 +0000 |
---|---|---|
committer | markm <markm@FreeBSD.org> | 2000-01-09 20:58:00 +0000 |
commit | 4ecbd6db44d79348bc815f31096e53104f50838b (patch) | |
tree | 36fa73706fa0587a390c45a3fbf17c9523cb0e35 /crypto/heimdal/appl/push | |
download | FreeBSD-src-4ecbd6db44d79348bc815f31096e53104f50838b.zip FreeBSD-src-4ecbd6db44d79348bc815f31096e53104f50838b.tar.gz |
Import KTH Heimdal, which will be the core of our Kerberos5.
Userland to follow.
Diffstat (limited to 'crypto/heimdal/appl/push')
-rw-r--r-- | crypto/heimdal/appl/push/ChangeLog | 150 | ||||
-rw-r--r-- | crypto/heimdal/appl/push/Makefile.am | 27 | ||||
-rw-r--r-- | crypto/heimdal/appl/push/Makefile.in | 713 | ||||
-rw-r--r-- | crypto/heimdal/appl/push/pfrom.in | 6 | ||||
-rw-r--r-- | crypto/heimdal/appl/push/push.8 | 138 | ||||
-rw-r--r-- | crypto/heimdal/appl/push/push.c | 790 | ||||
-rw-r--r-- | crypto/heimdal/appl/push/push_locl.h | 98 |
7 files changed, 1922 insertions, 0 deletions
diff --git a/crypto/heimdal/appl/push/ChangeLog b/crypto/heimdal/appl/push/ChangeLog new file mode 100644 index 0000000..f013090 --- /dev/null +++ b/crypto/heimdal/appl/push/ChangeLog @@ -0,0 +1,150 @@ +1999-12-28 Assar Westerlund <assar@sics.se> + + * push.c (main): call k_getportbyname with port number in + network-byte-order + +1999-12-14 Assar Westerlund <assar@sics.se> + + * push.c (do_connect): remove bogus local block variable + +1999-12-05 Assar Westerlund <assar@sics.se> + + * push.c (do_connect): use `getaddrinfo' + * push.c: add --count (print number of messages and bytes at + beginning) + +1999-11-13 Assar Westerlund <assar@sics.se> + + * push.c: make `-v' a arg_counter + +1999-11-02 Assar Westerlund <assar@sics.se> + + * push.c (main): redo the v4/v5 selection for consistency. -4 -> + try only v4 -5 -> try only v5 none, -45 -> try v5, v4 + +1999-08-19 Assar Westerlund <assar@sics.se> + + * push.c (doit): remember to step over the error message when we + discover that XDELE is not supported + +1999-08-12 Johan Danielsson <joda@pdc.kth.se> + + * push.c: use XDELE + +1999-08-05 Assar Westerlund <assar@sics.se> + + * push.c (do_connect): v6-ify + +1999-06-15 Assar Westerlund <assar@sics.se> + + * push.c: get_default_username and the resulting const propagation + +1999-05-21 Assar Westerlund <assar@sics.se> + + * push.c (parse_pobox): try $USERNAME + +1999-05-11 Assar Westerlund <assar@sics.se> + + * push.c (do_v5): remove unused and non-working code + +1999-05-10 Assar Westerlund <assar@sics.se> + + * push.c (do_v5): call krb5_sendauth with ccache == NULL + +Wed Apr 7 23:40:00 1999 Assar Westerlund <assar@sics.se> + + * Makefile.in: fix names of hesiod variables + +Wed Mar 24 04:37:04 1999 Assar Westerlund <assar@sics.se> + + * Makefile.am (pfrom): fix typo + + * push.c (get_pobox): try to handle old and new hesiod APIs + +Mon Mar 22 22:19:40 1999 Assar Westerlund <assar@sics.se> + + * Makefile.am: hesoid -> hesiod + +Sun Mar 21 18:02:10 1999 Johan Danielsson <joda@hella.pdc.kth.se> + + * Makefile.am: bindir -> libexecdir + +Sat Mar 20 00:12:26 1999 Assar Westerlund <assar@sics.se> + + * Makefile.am: LDADD: add missing backslash + +Thu Mar 18 15:28:35 1999 Johan Danielsson <joda@hella.pdc.kth.se> + + * Makefile.am: clean pfrom + + * Makefile.am: include Makefile.am.common + +Mon Mar 15 18:26:16 1999 Johan Danielsson <joda@blubb.pdc.kth.se> + + * push.c: strncasecmp headers + +Mon Feb 15 22:22:09 1999 Assar Westerlund <assar@sics.se> + + * Makefile.in (pfrom): use libexecdir + + * Makefile.am: build and install pfrom + + * push.c (do_connect): init `s' + (pop_state): spell-check enums + +Tue Nov 24 23:20:54 1998 Assar Westerlund <assar@sics.se> + + * Makefile.in: build and install pfrom + + * pfrom.in: bindir -> libexecdir + +Sun Nov 22 15:33:52 1998 Johan Danielsson <joda@hella.pdc.kth.se> + + * push.c: eliminate some warnings + +Sun Nov 22 10:34:54 1998 Assar Westerlund <assar@sics.se> + + * Makefile.in (WFLAGS): set + +Thu Nov 19 01:17:33 1998 Assar Westerlund <assar@sics.se> + + * push_locl.h: add <hesiod.h> + + * Makefile.am, Makefile.in: link and include hesiod + + * push.c (get_pobox): new function. add hesiod support. + +1998-11-07 Assar Westerlund <assar@sics.se> + + * push.8: updated + + * push.c: --from implementation from <lha@stacken.kth.se> + +Fri Jul 10 01:14:45 1998 Assar Westerlund <assar@sics.se> + + * push.c (net_{read,write}): remove + +Wed Jun 24 14:41:41 1998 Johan Danielsson <joda@blubb.pdc.kth.se> + + * push.c: allow `po:user@host' mailbox syntax + +Tue Jun 2 17:35:06 1998 Johan Danielsson <joda@emma.pdc.kth.se> + + * push.c: quote '^From ' properly + +Mon May 25 05:22:47 1998 Assar Westerlund <assar@sics.se> + + * Makefile.in (clean): PROGS -> PROGRAMS + +Sun Apr 26 11:42:13 1998 Assar Westerlund <assar@sics.se> + + * push.c (main): better default for v4 and v5 + + * push.c (main): init context correctly + + * push.c: should work with krb4 + + * push_locl.h: krb4 compat + + * Makefile.in: new file + diff --git a/crypto/heimdal/appl/push/Makefile.am b/crypto/heimdal/appl/push/Makefile.am new file mode 100644 index 0000000..07ecd0a --- /dev/null +++ b/crypto/heimdal/appl/push/Makefile.am @@ -0,0 +1,27 @@ +# $Id: Makefile.am,v 1.15 1999/04/09 18:29:48 assar Exp $ + +include $(top_srcdir)/Makefile.am.common + +INCLUDES += $(INCLUDE_krb4) $(INCLUDE_hesiod) + +bin_SCRIPTS = pfrom + +libexec_PROGRAMS = push + +push_SOURCES = push.c push_locl.h + +pfrom: pfrom.in + sed -e "s!%libexecdir%!$(libexecdir)!" $(srcdir)/pfrom.in > $@ + chmod +x $@ + +man_MANS = push.8 + +CLEANFILES = pfrom + +EXTRA_DIST = pfrom.in $(man_MANS) + +LDADD = $(LIB_krb5) \ + $(LIB_krb4) \ + $(top_builddir)/lib/des/libdes.la \ + $(LIB_roken) \ + $(LIB_hesiod) diff --git a/crypto/heimdal/appl/push/Makefile.in b/crypto/heimdal/appl/push/Makefile.in new file mode 100644 index 0000000..6e9fef1 --- /dev/null +++ b/crypto/heimdal/appl/push/Makefile.in @@ -0,0 +1,713 @@ +# Makefile.in generated automatically by automake 1.4 from Makefile.am + +# Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +# $Id: Makefile.am,v 1.15 1999/04/09 18:29:48 assar Exp $ + + +# $Id: Makefile.am.common,v 1.3 1999/04/01 14:58:43 joda Exp $ + + +# $Id: Makefile.am.common,v 1.13 1999/11/01 03:19:58 assar Exp $ + + +SHELL = @SHELL@ + +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ +VPATH = @srcdir@ +prefix = @prefix@ +exec_prefix = @exec_prefix@ + +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 + +DESTDIR = + +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ + +top_builddir = ../.. + +ACLOCAL = @ACLOCAL@ +AUTOCONF = @AUTOCONF@ +AUTOMAKE = @AUTOMAKE@ +AUTOHEADER = @AUTOHEADER@ + +INSTALL = @INSTALL@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ $(AM_INSTALL_PROGRAM_FLAGS) +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +transform = @program_transform_name@ + +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +host_alias = @host_alias@ +host_triplet = @host@ +AFS_EXTRA_LD = @AFS_EXTRA_LD@ +AIX_EXTRA_KAFS = @AIX_EXTRA_KAFS@ +AWK = @AWK@ +CANONICAL_HOST = @CANONICAL_HOST@ +CATMAN = @CATMAN@ +CATMANEXT = @CATMANEXT@ +CC = @CC@ +DBLIB = @DBLIB@ +EXEEXT = @EXEEXT@ +EXTRA_LIB45 = @EXTRA_LIB45@ +GROFF = @GROFF@ +INCLUDE_ = @INCLUDE_@ +LD = @LD@ +LEX = @LEX@ +LIBOBJS = @LIBOBJS@ +LIBTOOL = @LIBTOOL@ +LIB_ = @LIB_@ +LIB_AUTH_SUBDIRS = @LIB_AUTH_SUBDIRS@ +LIB_kdb = @LIB_kdb@ +LIB_otp = @LIB_otp@ +LIB_roken = @LIB_roken@ +LIB_security = @LIB_security@ +LN_S = @LN_S@ +LTLIBOBJS = @LTLIBOBJS@ +MAKEINFO = @MAKEINFO@ +MAKE_X_PROGS_BIN_PROGS = @MAKE_X_PROGS_BIN_PROGS@ +MAKE_X_PROGS_BIN_SCRPTS = @MAKE_X_PROGS_BIN_SCRPTS@ +MAKE_X_PROGS_LIBEXEC_PROGS = @MAKE_X_PROGS_LIBEXEC_PROGS@ +NEED_WRITEAUTH_FALSE = @NEED_WRITEAUTH_FALSE@ +NEED_WRITEAUTH_TRUE = @NEED_WRITEAUTH_TRUE@ +NM = @NM@ +NROFF = @NROFF@ +OBJEXT = @OBJEXT@ +PACKAGE = @PACKAGE@ +RANLIB = @RANLIB@ +VERSION = @VERSION@ +VOID_RETSIGTYPE = @VOID_RETSIGTYPE@ +WFLAGS = @WFLAGS@ +WFLAGS_NOIMPLICITINT = @WFLAGS_NOIMPLICITINT@ +WFLAGS_NOUNUSED = @WFLAGS_NOUNUSED@ +YACC = @YACC@ + +AUTOMAKE_OPTIONS = foreign no-dependencies + +SUFFIXES = .et .h .1 .3 .5 .8 .cat1 .cat3 .cat5 .cat8 .x + +INCLUDES = -I$(top_builddir)/include $(INCLUDE_krb4) $(INCLUDE_hesiod) + +AM_CFLAGS = $(WFLAGS) + +COMPILE_ET = $(top_builddir)/lib/com_err/compile_et + +buildinclude = $(top_builddir)/include + +LIB_XauReadAuth = @LIB_XauReadAuth@ +LIB_crypt = @LIB_crypt@ +LIB_dbm_firstkey = @LIB_dbm_firstkey@ +LIB_dbopen = @LIB_dbopen@ +LIB_dlopen = @LIB_dlopen@ +LIB_dn_expand = @LIB_dn_expand@ +LIB_el_init = @LIB_el_init@ +LIB_getattr = @LIB_getattr@ +LIB_gethostbyname = @LIB_gethostbyname@ +LIB_getpwent_r = @LIB_getpwent_r@ +LIB_getpwnam_r = @LIB_getpwnam_r@ +LIB_getsockopt = @LIB_getsockopt@ +LIB_logout = @LIB_logout@ +LIB_logwtmp = @LIB_logwtmp@ +LIB_odm_initialize = @LIB_odm_initialize@ +LIB_readline = @LIB_readline@ +LIB_res_search = @LIB_res_search@ +LIB_setpcred = @LIB_setpcred@ +LIB_setsockopt = @LIB_setsockopt@ +LIB_socket = @LIB_socket@ +LIB_syslog = @LIB_syslog@ +LIB_tgetent = @LIB_tgetent@ + +HESIODLIB = @HESIODLIB@ +HESIODINCLUDE = @HESIODINCLUDE@ +INCLUDE_hesiod = @INCLUDE_hesiod@ +LIB_hesiod = @LIB_hesiod@ + +INCLUDE_krb4 = @INCLUDE_krb4@ +LIB_krb4 = @LIB_krb4@ + +INCLUDE_readline = @INCLUDE_readline@ + +LEXLIB = @LEXLIB@ + +cat1dir = $(mandir)/cat1 +cat3dir = $(mandir)/cat3 +cat5dir = $(mandir)/cat5 +cat8dir = $(mandir)/cat8 + +MANRX = \(.*\)\.\([0-9]\) +CATSUFFIX = @CATSUFFIX@ + +NROFF_MAN = groff -mandoc -Tascii + +@KRB4_TRUE@LIB_kafs = $(top_builddir)/lib/kafs/libkafs.la $(AIX_EXTRA_KAFS) + +@KRB5_TRUE@LIB_krb5 = $(top_builddir)/lib/krb5/libkrb5.la $(top_builddir)/lib/asn1/libasn1.la +@KRB5_TRUE@LIB_gssapi = $(top_builddir)/lib/gssapi/libgssapi.la + +CHECK_LOCAL = $(PROGRAMS) + +bin_SCRIPTS = pfrom + +libexec_PROGRAMS = push + +push_SOURCES = push.c push_locl.h + +man_MANS = push.8 + +CLEANFILES = pfrom + +EXTRA_DIST = pfrom.in $(man_MANS) + +LDADD = $(LIB_krb5) $(LIB_krb4) $(top_builddir)/lib/des/libdes.la $(LIB_roken) $(LIB_hesiod) + +mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs +CONFIG_HEADER = ../../include/config.h +CONFIG_CLEAN_FILES = +libexec_PROGRAMS = push$(EXEEXT) +PROGRAMS = $(libexec_PROGRAMS) + + +DEFS = @DEFS@ -I. -I$(srcdir) -I../../include +CPPFLAGS = @CPPFLAGS@ +LDFLAGS = @LDFLAGS@ +LIBS = @LIBS@ +X_CFLAGS = @X_CFLAGS@ +X_LIBS = @X_LIBS@ +X_EXTRA_LIBS = @X_EXTRA_LIBS@ +X_PRE_LIBS = @X_PRE_LIBS@ +push_OBJECTS = push.$(OBJEXT) +push_LDADD = $(LDADD) +@KRB5_TRUE@push_DEPENDENCIES = $(top_builddir)/lib/krb5/libkrb5.la \ +@KRB5_TRUE@$(top_builddir)/lib/asn1/libasn1.la \ +@KRB5_TRUE@$(top_builddir)/lib/des/libdes.la +@KRB5_FALSE@push_DEPENDENCIES = $(top_builddir)/lib/des/libdes.la +push_LDFLAGS = +SCRIPTS = $(bin_SCRIPTS) + +CFLAGS = @CFLAGS@ +COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +CCLD = $(CC) +LINK = $(LIBTOOL) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(LDFLAGS) -o $@ +man8dir = $(mandir)/man8 +MANS = $(man_MANS) +DIST_COMMON = ChangeLog Makefile.am Makefile.in + + +DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST) + +TAR = tar +GZIP_ENV = --best +SOURCES = $(push_SOURCES) +OBJECTS = $(push_OBJECTS) + +all: all-redirect +.SUFFIXES: +.SUFFIXES: .1 .3 .5 .8 .S .c .cat1 .cat3 .cat5 .cat8 .et .h .lo .o .obj .s .x +$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4) $(top_srcdir)/Makefile.am.common $(top_srcdir)/cf/Makefile.am.common + cd $(top_srcdir) && $(AUTOMAKE) --foreign appl/push/Makefile + +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + cd $(top_builddir) \ + && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status + + +mostlyclean-libexecPROGRAMS: + +clean-libexecPROGRAMS: + -test -z "$(libexec_PROGRAMS)" || rm -f $(libexec_PROGRAMS) + +distclean-libexecPROGRAMS: + +maintainer-clean-libexecPROGRAMS: + +install-libexecPROGRAMS: $(libexec_PROGRAMS) + @$(NORMAL_INSTALL) + $(mkinstalldirs) $(DESTDIR)$(libexecdir) + @list='$(libexec_PROGRAMS)'; for p in $$list; do \ + if test -f $$p; then \ + echo " $(LIBTOOL) --mode=install $(INSTALL_PROGRAM) $$p $(DESTDIR)$(libexecdir)/`echo $$p|sed 's/$(EXEEXT)$$//'|sed '$(transform)'|sed 's/$$/$(EXEEXT)/'`"; \ + $(LIBTOOL) --mode=install $(INSTALL_PROGRAM) $$p $(DESTDIR)$(libexecdir)/`echo $$p|sed 's/$(EXEEXT)$$//'|sed '$(transform)'|sed 's/$$/$(EXEEXT)/'`; \ + else :; fi; \ + done + +uninstall-libexecPROGRAMS: + @$(NORMAL_UNINSTALL) + list='$(libexec_PROGRAMS)'; for p in $$list; do \ + rm -f $(DESTDIR)$(libexecdir)/`echo $$p|sed 's/$(EXEEXT)$$//'|sed '$(transform)'|sed 's/$$/$(EXEEXT)/'`; \ + done + +.c.o: + $(COMPILE) -c $< + +# FIXME: We should only use cygpath when building on Windows, +# and only if it is available. +.c.obj: + $(COMPILE) -c `cygpath -w $<` + +.s.o: + $(COMPILE) -c $< + +.S.o: + $(COMPILE) -c $< + +mostlyclean-compile: + -rm -f *.o core *.core + -rm -f *.$(OBJEXT) + +clean-compile: + +distclean-compile: + -rm -f *.tab.c + +maintainer-clean-compile: + +.c.lo: + $(LIBTOOL) --mode=compile $(COMPILE) -c $< + +.s.lo: + $(LIBTOOL) --mode=compile $(COMPILE) -c $< + +.S.lo: + $(LIBTOOL) --mode=compile $(COMPILE) -c $< + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs + +distclean-libtool: + +maintainer-clean-libtool: + +push$(EXEEXT): $(push_OBJECTS) $(push_DEPENDENCIES) + @rm -f push$(EXEEXT) + $(LINK) $(push_LDFLAGS) $(push_OBJECTS) $(push_LDADD) $(LIBS) + +install-binSCRIPTS: $(bin_SCRIPTS) + @$(NORMAL_INSTALL) + $(mkinstalldirs) $(DESTDIR)$(bindir) + @list='$(bin_SCRIPTS)'; for p in $$list; do \ + if test -f $$p; then \ + echo " $(INSTALL_SCRIPT) $$p $(DESTDIR)$(bindir)/`echo $$p|sed '$(transform)'`"; \ + $(INSTALL_SCRIPT) $$p $(DESTDIR)$(bindir)/`echo $$p|sed '$(transform)'`; \ + else if test -f $(srcdir)/$$p; then \ + echo " $(INSTALL_SCRIPT) $(srcdir)/$$p $(DESTDIR)$(bindir)/`echo $$p|sed '$(transform)'`"; \ + $(INSTALL_SCRIPT) $(srcdir)/$$p $(DESTDIR)$(bindir)/`echo $$p|sed '$(transform)'`; \ + else :; fi; fi; \ + done + +uninstall-binSCRIPTS: + @$(NORMAL_UNINSTALL) + list='$(bin_SCRIPTS)'; for p in $$list; do \ + rm -f $(DESTDIR)$(bindir)/`echo $$p|sed '$(transform)'`; \ + done + +install-man8: + $(mkinstalldirs) $(DESTDIR)$(man8dir) + @list='$(man8_MANS)'; \ + l2='$(man_MANS)'; for i in $$l2; do \ + case "$$i" in \ + *.8*) list="$$list $$i" ;; \ + esac; \ + done; \ + for i in $$list; do \ + if test -f $(srcdir)/$$i; then file=$(srcdir)/$$i; \ + else file=$$i; fi; \ + ext=`echo $$i | sed -e 's/^.*\\.//'`; \ + inst=`echo $$i | sed -e 's/\\.[0-9a-z]*$$//'`; \ + inst=`echo $$inst | sed '$(transform)'`.$$ext; \ + echo " $(INSTALL_DATA) $$file $(DESTDIR)$(man8dir)/$$inst"; \ + $(INSTALL_DATA) $$file $(DESTDIR)$(man8dir)/$$inst; \ + done + +uninstall-man8: + @list='$(man8_MANS)'; \ + l2='$(man_MANS)'; for i in $$l2; do \ + case "$$i" in \ + *.8*) list="$$list $$i" ;; \ + esac; \ + done; \ + for i in $$list; do \ + ext=`echo $$i | sed -e 's/^.*\\.//'`; \ + inst=`echo $$i | sed -e 's/\\.[0-9a-z]*$$//'`; \ + inst=`echo $$inst | sed '$(transform)'`.$$ext; \ + echo " rm -f $(DESTDIR)$(man8dir)/$$inst"; \ + rm -f $(DESTDIR)$(man8dir)/$$inst; \ + done +install-man: $(MANS) + @$(NORMAL_INSTALL) + $(MAKE) $(AM_MAKEFLAGS) install-man8 +uninstall-man: + @$(NORMAL_UNINSTALL) + $(MAKE) $(AM_MAKEFLAGS) uninstall-man8 + +tags: TAGS + +ID: $(HEADERS) $(SOURCES) $(LISP) + list='$(SOURCES) $(HEADERS)'; \ + unique=`for i in $$list; do echo $$i; done | \ + awk ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + here=`pwd` && cd $(srcdir) \ + && mkid -f$$here/ID $$unique $(LISP) + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS)'; \ + unique=`for i in $$list; do echo $$i; done | \ + awk ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + test -z "$(ETAGS_ARGS)$$unique$(LISP)$$tags" \ + || (cd $(srcdir) && etags $(ETAGS_ARGS) $$tags $$unique $(LISP) -o $$here/TAGS) + +mostlyclean-tags: + +clean-tags: + +distclean-tags: + -rm -f TAGS ID + +maintainer-clean-tags: + +distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir) + +subdir = appl/push + +distdir: $(DISTFILES) + @for file in $(DISTFILES); do \ + d=$(srcdir); \ + if test -d $$d/$$file; then \ + cp -pr $$/$$file $(distdir)/$$file; \ + else \ + test -f $(distdir)/$$file \ + || ln $$d/$$file $(distdir)/$$file 2> /dev/null \ + || cp -p $$d/$$file $(distdir)/$$file || :; \ + fi; \ + done + $(MAKE) $(AM_MAKEFLAGS) top_distdir="$(top_distdir)" distdir="$(distdir)" dist-hook +info-am: +info: info-am +dvi-am: +dvi: dvi-am +check-am: all-am + $(MAKE) $(AM_MAKEFLAGS) check-local +check: check-am +installcheck-am: +installcheck: installcheck-am +install-exec-am: install-libexecPROGRAMS install-binSCRIPTS + @$(NORMAL_INSTALL) + $(MAKE) $(AM_MAKEFLAGS) install-exec-hook +install-exec: install-exec-am + +install-data-am: install-man install-data-local +install-data: install-data-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am +install: install-am +uninstall-am: uninstall-libexecPROGRAMS uninstall-binSCRIPTS \ + uninstall-man +uninstall: uninstall-am +all-am: Makefile $(PROGRAMS) $(SCRIPTS) $(MANS) all-local +all-redirect: all-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) AM_INSTALL_PROGRAM_FLAGS=-s install +installdirs: + $(mkinstalldirs) $(DESTDIR)$(libexecdir) $(DESTDIR)$(bindir) \ + $(DESTDIR)$(mandir)/man8 + + +mostlyclean-generic: + +clean-generic: + -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) + +distclean-generic: + -rm -f Makefile $(CONFIG_CLEAN_FILES) + -rm -f config.cache config.log stamp-h stamp-h[0-9]* + +maintainer-clean-generic: +mostlyclean-am: mostlyclean-libexecPROGRAMS mostlyclean-compile \ + mostlyclean-libtool mostlyclean-tags \ + mostlyclean-generic + +mostlyclean: mostlyclean-am + +clean-am: clean-libexecPROGRAMS clean-compile clean-libtool clean-tags \ + clean-generic mostlyclean-am + +clean: clean-am + +distclean-am: distclean-libexecPROGRAMS distclean-compile \ + distclean-libtool distclean-tags distclean-generic \ + clean-am + -rm -f libtool + +distclean: distclean-am + +maintainer-clean-am: maintainer-clean-libexecPROGRAMS \ + maintainer-clean-compile maintainer-clean-libtool \ + maintainer-clean-tags maintainer-clean-generic \ + distclean-am + @echo "This command is intended for maintainers to use;" + @echo "it deletes files that may require special tools to rebuild." + +maintainer-clean: maintainer-clean-am + +.PHONY: mostlyclean-libexecPROGRAMS distclean-libexecPROGRAMS \ +clean-libexecPROGRAMS maintainer-clean-libexecPROGRAMS \ +uninstall-libexecPROGRAMS install-libexecPROGRAMS mostlyclean-compile \ +distclean-compile clean-compile maintainer-clean-compile \ +mostlyclean-libtool distclean-libtool clean-libtool \ +maintainer-clean-libtool uninstall-binSCRIPTS install-binSCRIPTS \ +install-man8 uninstall-man8 install-man uninstall-man tags \ +mostlyclean-tags distclean-tags clean-tags maintainer-clean-tags \ +distdir info-am info dvi-am dvi check-local check check-am \ +installcheck-am installcheck install-exec-am install-exec \ +install-data-local install-data-am install-data install-am install \ +uninstall-am uninstall all-local all-redirect all-am all installdirs \ +mostlyclean-generic distclean-generic clean-generic \ +maintainer-clean-generic clean mostlyclean distclean maintainer-clean + + +install-suid-programs: + @foo='$(bin_SUIDS)'; \ + for file in $$foo; do \ + x=$(DESTDIR)$(bindir)/$$file; \ + if chown 0:0 $$x && chmod u+s $$x; then :; else \ + chmod 0 $$x; fi; done + +install-exec-hook: install-suid-programs + +install-build-headers:: $(include_HEADERS) $(build_HEADERZ) + @foo='$(include_HEADERS) $(build_HEADERZ)'; \ + for f in $$foo; do \ + f=`basename $$f`; \ + if test -f "$(srcdir)/$$f"; then file="$(srcdir)/$$f"; \ + else file="$$f"; fi; \ + if cmp -s $$file $(buildinclude)/$$f 2> /dev/null ; then \ + : ; else \ + echo " cp $$file $(buildinclude)/$$f"; \ + cp $$file $(buildinclude)/$$f; \ + fi ; \ + done + +all-local: install-build-headers +#NROFF_MAN = nroff -man +.1.cat1: + $(NROFF_MAN) $< > $@ +.3.cat3: + $(NROFF_MAN) $< > $@ +.5.cat5: + $(NROFF_MAN) $< > $@ +.8.cat8: + $(NROFF_MAN) $< > $@ + +dist-cat1-mans: + @foo='$(man1_MANS)'; \ + bar='$(man_MANS)'; \ + for i in $$bar; do \ + case $$i in \ + *.1) foo="$$foo $$i";; \ + esac; done ;\ + for i in $$foo; do \ + x=`echo $$i | sed 's/\.[^.]*$$/.cat1/'`; \ + echo "$(NROFF_MAN) $(srcdir)/$$i > $(distdir)/$$x"; \ + $(NROFF_MAN) $(srcdir)/$$i > $(distdir)/$$x; \ + done + +dist-cat3-mans: + @foo='$(man3_MANS)'; \ + bar='$(man_MANS)'; \ + for i in $$bar; do \ + case $$i in \ + *.3) foo="$$foo $$i";; \ + esac; done ;\ + for i in $$foo; do \ + x=`echo $$i | sed 's/\.[^.]*$$/.cat3/'`; \ + echo "$(NROFF_MAN) $(srcdir)/$$i > $(distdir)/$$x"; \ + $(NROFF_MAN) $(srcdir)/$$i > $(distdir)/$$x; \ + done + +dist-cat5-mans: + @foo='$(man5_MANS)'; \ + bar='$(man_MANS)'; \ + for i in $$bar; do \ + case $$i in \ + *.5) foo="$$foo $$i";; \ + esac; done ;\ + for i in $$foo; do \ + x=`echo $$i | sed 's/\.[^.]*$$/.cat5/'`; \ + echo "$(NROFF_MAN) $(srcdir)/$$i > $(distdir)/$$x"; \ + $(NROFF_MAN) $(srcdir)/$$i > $(distdir)/$$x; \ + done + +dist-cat8-mans: + @foo='$(man8_MANS)'; \ + bar='$(man_MANS)'; \ + for i in $$bar; do \ + case $$i in \ + *.8) foo="$$foo $$i";; \ + esac; done ;\ + for i in $$foo; do \ + x=`echo $$i | sed 's/\.[^.]*$$/.cat8/'`; \ + echo "$(NROFF_MAN) $(srcdir)/$$i > $(distdir)/$$x"; \ + $(NROFF_MAN) $(srcdir)/$$i > $(distdir)/$$x; \ + done + +dist-hook: dist-cat1-mans dist-cat3-mans dist-cat5-mans dist-cat8-mans + +install-cat1-mans: + @ext=1;\ + foo='$(man1_MANS)'; \ + bar='$(man_MANS)'; \ + for i in $$bar; do \ + case $$i in \ + *.1) foo="$$foo $$i";; \ + esac; done; \ + if test "$$foo"; then \ + $(mkinstalldirs) $(DESTDIR)$(cat1dir); \ + for x in $$foo; do \ + f=`echo $$x | sed 's/\.[^.]*$$/.cat1/'`; \ + if test -f "$(srcdir)/$$f"; then \ + b=`echo $$x | sed 's!$(MANRX)!\1!'`; \ + echo "$(INSTALL_DATA) $(srcdir)/$$f $(DESTDIR)$(cat1dir)/$$b.$(CATSUFFIX)";\ + $(INSTALL_DATA) $(srcdir)/$$g $(DESTDIR)$(cat1dir)/$$b.$(CATSUFFIX);\ + fi; \ + done ;\ + fi + +install-cat3-mans: + @ext=3;\ + foo='$(man3_MANS)'; \ + bar='$(man_MANS)'; \ + for i in $$bar; do \ + case $$i in \ + *.3) foo="$$foo $$i";; \ + esac; done; \ + if test "$$foo"; then \ + $(mkinstalldirs) $(DESTDIR)$(cat3dir); \ + for x in $$foo; do \ + f=`echo $$x | sed 's/\.[^.]*$$/.cat3/'`; \ + if test -f "$(srcdir)/$$f"; then \ + b=`echo $$x | sed 's!$(MANRX)!\1!'`; \ + echo "$(INSTALL_DATA) $(srcdir)/$$f $(DESTDIR)$(cat3dir)/$$b.$(CATSUFFIX)";\ + $(INSTALL_DATA) $(srcdir)/$$g $(DESTDIR)$(cat3dir)/$$b.$(CATSUFFIX);\ + fi; \ + done ;\ + fi + +install-cat5-mans: + @ext=5;\ + foo='$(man5_MANS)'; \ + bar='$(man_MANS)'; \ + for i in $$bar; do \ + case $$i in \ + *.5) foo="$$foo $$i";; \ + esac; done; \ + if test "$$foo"; then \ + $(mkinstalldirs) $(DESTDIR)$(cat5dir); \ + for x in $$foo; do \ + f=`echo $$x | sed 's/\.[^.]*$$/.cat5/'`; \ + if test -f "$(srcdir)/$$f"; then \ + b=`echo $$x | sed 's!$(MANRX)!\1!'`; \ + echo "$(INSTALL_DATA) $(srcdir)/$$f $(DESTDIR)$(cat5dir)/$$b.$(CATSUFFIX)";\ + $(INSTALL_DATA) $(srcdir)/$$g $(DESTDIR)$(cat5dir)/$$b.$(CATSUFFIX);\ + fi; \ + done ;\ + fi + +install-cat8-mans: + @ext=8;\ + foo='$(man8_MANS)'; \ + bar='$(man_MANS)'; \ + for i in $$bar; do \ + case $$i in \ + *.8) foo="$$foo $$i";; \ + esac; done; \ + if test "$$foo"; then \ + $(mkinstalldirs) $(DESTDIR)$(cat8dir); \ + for x in $$foo; do \ + f=`echo $$x | sed 's/\.[^.]*$$/.cat8/'`; \ + if test -f "$(srcdir)/$$f"; then \ + b=`echo $$x | sed 's!$(MANRX)!\1!'`; \ + echo "$(INSTALL_DATA) $(srcdir)/$$f $(DESTDIR)$(cat8dir)/$$b.$(CATSUFFIX)";\ + $(INSTALL_DATA) $(srcdir)/$$g $(DESTDIR)$(cat8dir)/$$b.$(CATSUFFIX);\ + fi; \ + done ;\ + fi + +install-cat-mans: install-cat1-mans install-cat3-mans install-cat5-mans install-cat8-mans + +install-data-local: install-cat-mans + +.et.h: + $(COMPILE_ET) $< +.et.c: + $(COMPILE_ET) $< + +.x.c: + @cmp -s $< $@ 2> /dev/null || cp $< $@ + +check-local:: + @foo='$(CHECK_LOCAL)'; \ + if test "$$foo"; then \ + failed=0; all=0; \ + for i in $$foo; do \ + all=`expr $$all + 1`; \ + if ./$$i --version > /dev/null 2>&1; then \ + echo "PASS: $$i"; \ + else \ + echo "FAIL: $$i"; \ + failed=`expr $$failed + 1`; \ + fi; \ + done; \ + if test "$$failed" -eq 0; then \ + banner="All $$all tests passed"; \ + else \ + banner="$$failed of $$all tests failed"; \ + fi; \ + dashes=`echo "$$banner" | sed s/./=/g`; \ + echo "$$dashes"; \ + echo "$$banner"; \ + echo "$$dashes"; \ + test "$$failed" -eq 0; \ + fi + +pfrom: pfrom.in + sed -e "s!%libexecdir%!$(libexecdir)!" $(srcdir)/pfrom.in > $@ + chmod +x $@ + +# 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/crypto/heimdal/appl/push/pfrom.in b/crypto/heimdal/appl/push/pfrom.in new file mode 100644 index 0000000..6adf4f0 --- /dev/null +++ b/crypto/heimdal/appl/push/pfrom.in @@ -0,0 +1,6 @@ +#!/bin/sh +# $Id: pfrom.in,v 1.2 1998/11/24 13:25:47 assar Exp $ +libexecdir=%libexecdir% +PATH=$libexecdir:$PATH +export PATH +push --from $* diff --git a/crypto/heimdal/appl/push/push.8 b/crypto/heimdal/appl/push/push.8 new file mode 100644 index 0000000..d8f4401 --- /dev/null +++ b/crypto/heimdal/appl/push/push.8 @@ -0,0 +1,138 @@ +.\" $Id: push.8,v 1.4 1999/12/05 13:00:56 assar Exp $ +.\" +.Dd May 31, 1998 +.Dt PUSH 8 +.Os HEIMDAL +.Sh NAME +.Nm push +.Nd +fetch mail via POP +.Sh SYNOPSIS +.Nm +.Op Fl 4 | Fl -krb4 +.Op Fl 5 | Fl -krb5 +.Op Fl v | Fl -verbose +.Op Fl f | Fl -fork +.Op Fl l | -leave +.Op Fl -from +.Op Fl c | -count +.Op Fl -header +.Oo Fl p Ar port-spec \*(Ba Xo +.Fl -port= Ns Ar port-spec Oc +.Xc +.Ar po-box +.Pa filename +.Sh DESCRIPTION +.Nm +retrieves mail from the post office box +.Ar po-box , +and stores the mail in mbox format in +.Pa filename . +The +.Ar po-box +can have any of the following formats: +.Bl -hang -compact -offset indent +.It Ql hostname:username +.It Ql po:hostname:username +.It Ql username@hostname +.It Ql po:username@hostname +.It Ql hostname +.It Ql po:username +.El + +If no username is specified, +.Nm +assumes that it's the same as on the local machine; +.Ar hostname +defaults to the value of the +.Ev MAILHOST +environment variable. + +Supported options: +.Bl -tag -width Ds +.It Xo +.Fl 4 Ns , +.Fl -krb4 +.Xc +use Kerberos 4 (if compiled with support for Kerberos 4) +.It Xo +.Fl 5 Ns , +.Fl -krb5 +.Xc +use Kerberos 5 (if compiled with support for Kerberos 5) +.It Xo +.Fl f Ns , +.Fl -fork +.Xc +fork before starting to delete messages +.It Xo +.Fl l Ns , +.Fl -leave +.Xc +don't delete fetched mail +.It Xo +.Fl -from +.Xc +behave like from. +.It Xo +.Fl c Ns , +.Fl -count +.Xc +first print how many messages and bytes there are. +.It Xo +.Fl -header +.Xc +which header from should print. +.It Xo +.Fl p Ar port-spec Ns , +.Fl -port= Ns Ar port-spec +.Xc +use this port instead of the default +.Ql kpop +or +.Ql 1109 . +.El + +The default is to first try Kerberos 5 authentication and then, if +that fails, Kerberos 4. +.Sh ENVIRONMENT + +.Bl -tag -width Ds +.It Ev MAILHOST +points to the post office, if no other hostname is specified. +.El +.\".Sh FILES +.Sh EXAMPLES +.Bd -literal -offset indent +$ push cornfield:roosta ~/.gnus-crash-box +.Ed + +tries to fetch mail for the user +.Ar roosta +from the post office at +.Dq cornfield , +and stores the mail in +.Pa ~/.gnus-crash-box +(you are using Gnus, aren't you?) +.Bd -literal -offset indent +$ push --from -5 havregryn +.Ed + +tries to fetch +.Nm From: +lines for current user at post office +.Dq havregryn +using Kerberos 5. +.\".Sh DIAGNOSTICS +.Sh SEE ALSO +.Xr movemail 8 , +.Xr popper 8 , +.Xr from 1 +.\".Sh STANDARDS +.Sh HISTORY +.Nm +was written while waiting for +.Nm movemail +to finish getting the mail. +.\".Sh AUTHORS +.\".Sh BUGS diff --git a/crypto/heimdal/appl/push/push.c b/crypto/heimdal/appl/push/push.c new file mode 100644 index 0000000..1689a83 --- /dev/null +++ b/crypto/heimdal/appl/push/push.c @@ -0,0 +1,790 @@ +/* + * Copyright (c) 1997-1999 Kungliga Tekniska Högskolan + * (Royal Institute of Technology, Stockholm, Sweden). + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * 3. Neither the name of the Institute nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include "push_locl.h" +RCSID("$Id: push.c,v 1.38 1999/12/28 03:46:06 assar Exp $"); + +#ifdef KRB4 +static int use_v4 = -1; +#endif + +#ifdef KRB5 +static int use_v5 = -1; +static krb5_context context; +#endif + +static char *port_str; +static int verbose_level; +static int do_fork; +static int do_leave; +static int do_version; +static int do_help; +static int do_from; +static int do_count; +static char *header_str; + +struct getargs args[] = { +#ifdef KRB4 + { "krb4", '4', arg_flag, &use_v4, "Use Kerberos V4", + NULL }, +#endif +#ifdef KRB5 + { "krb5", '5', arg_flag, &use_v5, "Use Kerberos V5", + NULL }, +#endif + { "verbose",'v', arg_counter, &verbose_level, "Verbose", + NULL }, + { "fork", 'f', arg_flag, &do_fork, "Fork deleting proc", + NULL }, + { "leave", 'l', arg_flag, &do_leave, "Leave mail on server", + NULL }, + { "port", 'p', arg_string, &port_str, "Use this port", + "number-or-service" }, + { "from", 0, arg_flag, &do_from, "Behave like from", + NULL }, + { "header", 0, arg_string, &header_str, "Header string to print", NULL }, + { "count", 'c', arg_flag, &do_count, "Print number of messages", NULL}, + { "version", 0, arg_flag, &do_version, "Print version", + NULL }, + { "help", 0, arg_flag, &do_help, NULL, + NULL } + +}; + +static void +usage (int ret) +{ + arg_printusage (args, + sizeof(args) / sizeof(args[0]), + NULL, + "[[{po:username[@hostname] | hostname[:username]}] ...]" + "filename"); + exit (ret); +} + +static int +do_connect (const char *hostname, int port, int nodelay) +{ + struct addrinfo *ai, *a; + struct addrinfo hints; + int error; + int s; + char portstr[NI_MAXSERV]; + + memset (&hints, 0, sizeof(hints)); + hints.ai_socktype = SOCK_STREAM; + hints.ai_protocol = IPPROTO_TCP; + + snprintf (portstr, sizeof(portstr), "%u", ntohs(port)); + + error = getaddrinfo (hostname, portstr, &hints, &ai); + if (error) + errx (1, "getaddrinfo(%s): %s", hostname, gai_strerror(error)); + + for (a = ai; a != NULL; a = a->ai_next) { + s = socket (a->ai_family, a->ai_socktype, a->ai_protocol); + if (s < 0) + continue; + if (connect (s, a->ai_addr, a->ai_addrlen) < 0) { + warn ("connect(%s)", hostname); + close (s); + continue; + } + break; + } + freeaddrinfo (ai); + if (a == NULL) { + warnx ("failed to contact %s", hostname); + return -1; + } + + if(setsockopt(s, IPPROTO_TCP, TCP_NODELAY, + (void *)&nodelay, sizeof(nodelay)) < 0) + err (1, "setsockopt TCP_NODELAY"); + return s; +} + +typedef enum { INIT = 0, GREET, USER, PASS, STAT, RETR, TOP, + DELE, XDELE, QUIT} pop_state; + +#define PUSH_BUFSIZ 65536 + +#define STEP 16 + +struct write_state { + struct iovec *iovecs; + size_t niovecs, maxiovecs, allociovecs; + int fd; +}; + +static void +write_state_init (struct write_state *w, int fd) +{ +#ifdef UIO_MAXIOV + w->maxiovecs = UIO_MAXIOV; +#else + w->maxiovecs = 16; +#endif + w->allociovecs = min(STEP, w->maxiovecs); + w->niovecs = 0; + w->iovecs = malloc(w->allociovecs * sizeof(*w->iovecs)); + if (w->iovecs == NULL) + err (1, "malloc"); + w->fd = fd; +} + +static void +write_state_add (struct write_state *w, void *v, size_t len) +{ + if(w->niovecs == w->allociovecs) { + if(w->niovecs == w->maxiovecs) { + if(writev (w->fd, w->iovecs, w->niovecs) < 0) + err(1, "writev"); + w->niovecs = 0; + } else { + w->allociovecs = min(w->allociovecs + STEP, w->maxiovecs); + w->iovecs = realloc (w->iovecs, + w->allociovecs * sizeof(*w->iovecs)); + if (w->iovecs == NULL) + errx (1, "realloc"); + } + } + w->iovecs[w->niovecs].iov_base = v; + w->iovecs[w->niovecs].iov_len = len; + ++w->niovecs; +} + +static void +write_state_flush (struct write_state *w) +{ + if (w->niovecs) { + if (writev (w->fd, w->iovecs, w->niovecs) < 0) + err (1, "writev"); + w->niovecs = 0; + } +} + +static void +write_state_destroy (struct write_state *w) +{ + free (w->iovecs); +} + +static int +doit(int s, + const char *host, + const char *user, + const char *outfilename, + const char *header_str, + int leavep, + int verbose, + int forkp) +{ + int ret; + char out_buf[PUSH_BUFSIZ]; + size_t out_len = 0; + char in_buf[PUSH_BUFSIZ + 1]; /* sentinel */ + size_t in_len = 0; + char *in_ptr = in_buf; + pop_state state = INIT; + unsigned count, bytes; + unsigned asked_for = 0, retrieved = 0, asked_deleted = 0, deleted = 0; + unsigned sent_xdele = 0; + int out_fd; + char from_line[128]; + size_t from_line_length; + time_t now; + struct write_state write_state; + + if (do_from) { + out_fd = -1; + if (verbose) + fprintf (stderr, "%s@%s\n", user, host); + } else { + out_fd = open(outfilename, O_WRONLY | O_APPEND | O_CREAT, 0666); + if (out_fd < 0) + err (1, "open %s", outfilename); + if (verbose) + fprintf (stderr, "%s@%s -> %s\n", user, host, outfilename); + } + + now = time(NULL); + from_line_length = snprintf (from_line, sizeof(from_line), + "From %s %s", "push", ctime(&now)); + + out_len = snprintf (out_buf, sizeof(out_buf), + "USER %s\r\nPASS hej\r\nSTAT\r\n", + user); + if (net_write (s, out_buf, out_len) != out_len) + err (1, "write"); + if (verbose > 1) + write (STDERR_FILENO, out_buf, out_len); + + if (!do_from) + write_state_init (&write_state, out_fd); + + while(state != QUIT) { + fd_set readset, writeset; + + FD_ZERO(&readset); + FD_ZERO(&writeset); + FD_SET(s,&readset); + if (((state == STAT || state == RETR || state == TOP) + && asked_for < count) + || (state == XDELE && !sent_xdele) + || (state == DELE && asked_deleted < count)) + FD_SET(s,&writeset); + ret = select (s + 1, &readset, &writeset, NULL, NULL); + if (ret < 0) { + if (errno == EAGAIN) + continue; + else + err (1, "select"); + } + + if (FD_ISSET(s, &readset)) { + char *beg, *p; + size_t rem; + int blank_line = 0; + + ret = read (s, in_ptr, sizeof(in_buf) - in_len - 1); + if (ret < 0) + err (1, "read"); + else if (ret == 0) + errx (1, "EOF during read"); + + in_len += ret; + in_ptr += ret; + *in_ptr = '\0'; + + beg = in_buf; + rem = in_len; + while(rem > 1 + && (p = strstr(beg, "\r\n")) != NULL) { + if (state == TOP) { + char *copy = beg; + + if (strncasecmp(copy, + header_str, + min(p - copy + 1, strlen(header_str))) == 0) { + fprintf (stdout, "%.*s\n", (int)(p - copy), copy); + } + if (beg[0] == '.' && beg[1] == '\r' && beg[2] == '\n') { + state = STAT; + if (++retrieved == count) { + state = QUIT; + net_write (s, "QUIT\r\n", 6); + if (verbose > 1) + net_write (STDERR_FILENO, "QUIT\r\n", 6); + } + } + rem -= p - beg + 2; + beg = p + 2; + } else if (state == RETR) { + char *copy = beg; + if (beg[0] == '.') { + if (beg[1] == '\r' && beg[2] == '\n') { + if(!blank_line) + write_state_add(&write_state, "\n", 1); + state = STAT; + rem -= p - beg + 2; + beg = p + 2; + if (++retrieved == count) { + write_state_flush (&write_state); + if (fsync (out_fd) < 0) + err (1, "fsync"); + close(out_fd); + if (leavep) { + state = QUIT; + net_write (s, "QUIT\r\n", 6); + if (verbose > 1) + net_write (STDERR_FILENO, "QUIT\r\n", 6); + } else { + if (forkp) { + pid_t pid; + + pid = fork(); + if (pid < 0) + warn ("fork"); + else if(pid != 0) { + if(verbose) + fprintf (stderr, + "(exiting)"); + return 0; + } + } + + state = XDELE; + if (verbose) + fprintf (stderr, "deleting... "); + } + } + continue; + } else + ++copy; + } + *p = '\n'; + if(blank_line && + strncmp(copy, "From ", min(p - copy + 1, 5)) == 0) + write_state_add(&write_state, ">", 1); + write_state_add(&write_state, copy, p - copy + 1); + blank_line = (*copy == '\n'); + rem -= p - beg + 2; + beg = p + 2; + } else if (rem >= 3 && strncmp (beg, "+OK", 3) == 0) { + if (state == STAT) { + if (!do_from) + write_state_add(&write_state, + from_line, from_line_length); + blank_line = 0; + if (do_from) + state = TOP; + else + state = RETR; + } else if (state == XDELE) { + state = QUIT; + net_write (s, "QUIT\r\n", 6); + if (verbose > 1) + net_write (STDERR_FILENO, "QUIT\r\n", 6); + break; + } else if (state == DELE) { + if (++deleted == count) { + state = QUIT; + net_write (s, "QUIT\r\n", 6); + if (verbose > 1) + net_write (STDERR_FILENO, "QUIT\r\n", 6); + break; + } + } else if (++state == STAT) { + if(sscanf (beg + 4, "%u %u", &count, &bytes) != 2) + errx(1, "Bad STAT-line: %.*s", (int)(p - beg), beg); + if (verbose) { + fprintf (stderr, "%u message(s) (%u bytes). " + "fetching... ", + count, bytes); + if (do_from) + fprintf (stderr, "\n"); + } else if (do_count) { + fprintf (stderr, "%u message(s) (%u bytes).\n", + count, bytes); + } + if (count == 0) { + state = QUIT; + net_write (s, "QUIT\r\n", 6); + if (verbose > 1) + net_write (STDERR_FILENO, "QUIT\r\n", 6); + break; + } + } + + rem -= p - beg + 2; + beg = p + 2; + } else { + if(state == XDELE) { + state = DELE; + rem -= p - beg + 2; + beg = p + 2; + } else + errx (1, "Bad response: %.*s", (int)(p - beg), beg); + } + } + if (!do_from) + write_state_flush (&write_state); + + memmove (in_buf, beg, rem); + in_len = rem; + in_ptr = in_buf + rem; + } + if (FD_ISSET(s, &writeset)) { + if ((state == STAT && !do_from) || state == RETR) + out_len = snprintf (out_buf, sizeof(out_buf), + "RETR %u\r\n", ++asked_for); + else if ((state == STAT && do_from) || state == TOP) + out_len = snprintf (out_buf, sizeof(out_buf), + "TOP %u 0\r\n", ++asked_for); + else if(state == XDELE) { + out_len = snprintf(out_buf, sizeof(out_buf), + "XDELE %u %u\r\n", 1, count); + sent_xdele++; + } + else if(state == DELE) + out_len = snprintf (out_buf, sizeof(out_buf), + "DELE %u\r\n", ++asked_deleted); + if (net_write (s, out_buf, out_len) != out_len) + err (1, "write"); + if (verbose > 1) + write (STDERR_FILENO, out_buf, out_len); + } + } + if (verbose) + fprintf (stderr, "Done\n"); + if (!do_from) + write_state_destroy (&write_state); + return 0; +} + +#ifdef KRB5 +static int +do_v5 (const char *host, + int port, + const char *user, + const char *filename, + const char *header_str, + int leavep, + int verbose, + int forkp) +{ + krb5_error_code ret; + krb5_auth_context auth_context = NULL; + krb5_principal server; + int s; + + s = do_connect (host, port, 1); + if (s < 0) + return 1; + + ret = krb5_sname_to_principal (context, + host, + "pop", + KRB5_NT_SRV_HST, + &server); + if (ret) { + warnx ("krb5_sname_to_principal: %s", + krb5_get_err_text (context, ret)); + return 1; + } + + ret = krb5_sendauth (context, + &auth_context, + &s, + "KPOPV1.0", + NULL, + server, + 0, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL); + krb5_free_principal (context, server); + if (ret) { + warnx ("krb5_sendauth: %s", + krb5_get_err_text (context, ret)); + return 1; + } + return doit (s, host, user, filename, header_str, leavep, verbose, forkp); +} +#endif + +#ifdef KRB4 +static int +do_v4 (const char *host, + int port, + const char *user, + const char *filename, + const char *header_str, + int leavep, + int verbose, + int forkp) +{ + KTEXT_ST ticket; + MSG_DAT msg_data; + CREDENTIALS cred; + des_key_schedule sched; + int s; + int ret; + + s = do_connect (host, port, 1); + if (s < 0) + return 1; + ret = krb_sendauth(0, + s, + &ticket, + "pop", + (char *)host, + krb_realmofhost(host), + getpid(), + &msg_data, + &cred, + sched, + NULL, + NULL, + "KPOPV0.1"); + if(ret) { + warnx("krb_sendauth: %s", krb_get_err_text(ret)); + return 1; + } + return doit (s, host, user, filename, header_str, leavep, verbose, forkp); +} +#endif /* KRB4 */ + +#ifdef HESIOD + +#ifdef HESIOD_INTERFACES + +static char * +hesiod_get_pobox (const char **user) +{ + void *context; + struct hesiod_postoffice *hpo; + char *ret = NULL; + + if(hesiod_init (&context) != 0) + err (1, "hesiod_init"); + + hpo = hesiod_getmailhost (context, *user); + if (hpo == NULL) { + warn ("hesiod_getmailhost %s", *user); + } else { + if (strcasecmp(hpo->hesiod_po_type, "pop") != 0) + errx (1, "Unsupported po type %s", hpo->hesiod_po_type); + + ret = strdup(hpo->hesiod_po_host); + if(ret == NULL) + errx (1, "strdup: out of memory"); + *user = strdup(hpo->hesiod_po_name); + if (*user == NULL) + errx (1, "strdup: out of memory"); + hesiod_free_postoffice (context, hpo); + } + hesiod_end (context); + return ret; +} + +#else /* !HESIOD_INTERFACES */ + +static char * +hesiod_get_pobox (const char **user) +{ + char *ret = NULL; + struct hes_postoffice *hpo; + + hpo = hes_getmailhost (*user); + if (hpo == NULL) { + warn ("hes_getmailhost %s", *user); + } else { + if (strcasecmp(hpo->po_type, "pop") != 0) + errx (1, "Unsupported po type %s", hpo->po_type); + + ret = strdup(hpo->po_host); + if(ret == NULL) + errx (1, "strdup: out of memory"); + *user = strdup(hpo->po_name); + if (*user == NULL) + errx (1, "strdup: out of memory"); + } + return ret; +} + +#endif /* HESIOD_INTERFACES */ + +#endif /* HESIOD */ + +static char * +get_pobox (const char **user) +{ + char *ret = NULL; + +#ifdef HESIOD + ret = hesiod_get_pobox (user); +#endif + + if (ret == NULL) + ret = getenv("MAILHOST"); + if (ret == NULL) + errx (1, "MAILHOST not set"); + return ret; +} + +static void +parse_pobox (char *a0, const char **host, const char **user) +{ + const char *h, *u; + char *p; + int po = 0; + + if (a0 == NULL) { + + *user = getenv ("USERNAME"); + if (*user == NULL) { + struct passwd *pwd = getpwuid (getuid ()); + + if (pwd == NULL) + errx (1, "Who are you?"); + *user = strdup (pwd->pw_name); + if (*user == NULL) + errx (1, "strdup: out of memory"); + } + *host = get_pobox (user); + return; + } + + /* if the specification starts with po:, remember this information */ + if(strncmp(a0, "po:", 3) == 0) { + a0 += 3; + po++; + } + /* if there is an `@', the hostname is after it, otherwise at the + beginning of the string */ + p = strchr(a0, '@'); + if(p != NULL) { + *p++ = '\0'; + h = p; + } else { + h = a0; + } + /* if there is a `:', the username comes before it, otherwise at + the beginning of the string */ + p = strchr(a0, ':'); + if(p != NULL) { + *p++ = '\0'; + u = p; + } else { + u = a0; + } + if(h == u) { + /* some inconsistent compatibility with various mailers */ + if(po) { + h = get_pobox (&u); + } else { + u = get_default_username (); + if (u == NULL) + errx (1, "Who are you?"); + } + } + *host = h; + *user = u; +} + +int +main(int argc, char **argv) +{ + int port = 0; + int optind = 0; + int ret = 1; + const char *host, *user, *filename = NULL; + char *pobox = NULL; + + set_progname (argv[0]); + +#ifdef KRB5 + krb5_init_context (&context); +#endif + + if (getarg (args, sizeof(args) / sizeof(args[0]), argc, argv, + &optind)) + usage (1); + + argc -= optind; + argv += optind; + +#if defined(KRB4) && defined(KRB5) + if(use_v4 == -1 && use_v5 == 1) + use_v4 = 0; + if(use_v5 == -1 && use_v4 == 1) + use_v5 = 0; +#endif + + if (do_help) + usage (0); + + if (do_version) { + print_version(NULL); + return 0; + } + + if (do_from && header_str == NULL) + header_str = "From:"; + else if (header_str != NULL) + do_from = 1; + + if (do_from) { + if (argc == 0) + pobox = NULL; + else if (argc == 1) + pobox = argv[0]; + else + usage (1); + } else { + if (argc == 1) { + filename = argv[0]; + pobox = NULL; + } else if (argc == 2) { + filename = argv[1]; + pobox = argv[0]; + } else + usage (1); + } + + if (port_str) { + struct servent *s = roken_getservbyname (port_str, "tcp"); + + if (s) + port = s->s_port; + else { + char *ptr; + + port = strtol (port_str, &ptr, 10); + if (port == 0 && ptr == port_str) + errx (1, "Bad port `%s'", port_str); + port = htons(port); + } + } + if (port == 0) { +#ifdef KRB5 + port = krb5_getportbyname (context, "kpop", "tcp", 1109); +#elif defined(KRB4) + port = k_getportbyname ("kpop", "tcp", htons(1109)); +#else +#error must define KRB4 or KRB5 +#endif + } + + parse_pobox (pobox, &host, &user); + +#ifdef KRB5 + if (ret && use_v5) { + ret = do_v5 (host, port, user, filename, header_str, + do_leave, verbose_level, do_fork); + } +#endif + +#ifdef KRB4 + if (ret && use_v4) { + ret = do_v4 (host, port, user, filename, header_str, + do_leave, verbose_level, do_fork); + } +#endif /* KRB4 */ + return ret; +} diff --git a/crypto/heimdal/appl/push/push_locl.h b/crypto/heimdal/appl/push/push_locl.h new file mode 100644 index 0000000..1e5ca78 --- /dev/null +++ b/crypto/heimdal/appl/push/push_locl.h @@ -0,0 +1,98 @@ +/* + * Copyright (c) 1997, 1998 Kungliga Tekniska Högskolan + * (Royal Institute of Technology, Stockholm, Sweden). + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * 3. Neither the name of the Institute nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +/* $Id: push_locl.h,v 1.6 1999/12/02 16:58:33 joda Exp $ */ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#ifdef HAVE_FCNTL_H +#include <fcntl.h> +#endif +#ifdef HAVE_ERRNO_H +#include <errno.h> +#endif +#include <ctype.h> +#include <limits.h> +#include <time.h> +#ifdef HAVE_SYS_TYPES_H +#include <sys/types.h> +#endif +#ifdef HAVE_SYS_SELECT_H +#include <sys/select.h> +#endif +#ifdef HAVE_UNISTD_H +#include <unistd.h> +#endif +#ifdef HAVE_SYS_UIO_H +#include <sys/uio.h> +#endif +#ifdef HAVE_SYS_SOCKET_H +#include <sys/socket.h> +#endif +#ifdef HAVE_NETINET_IN_H +#include <netinet/in.h> +#endif +#ifdef HAVE_NETINET_IN6_H +#include <netinet/in6.h> +#endif +#ifdef HAVE_NETINET6_IN6_H +#include <netinet6/in6.h> +#endif +#ifdef HAVE_NETINET_TCP_H +#include <netinet/tcp.h> +#endif +#ifdef HAVE_NETDB_H +#include <netdb.h> +#endif +#ifdef HAVE_PWD_H +#include <pwd.h> +#endif +#ifdef HESIOD +#include <hesiod.h> +#endif + +#include <roken.h> +#include <err.h> +#include <getarg.h> +#ifdef KRB5 +#include <krb5.h> +#endif + +#ifdef KRB4 +#include <krb.h> +#endif |