summaryrefslogtreecommitdiffstats
path: root/crypto/heimdal/appl/popper
diff options
context:
space:
mode:
Diffstat (limited to 'crypto/heimdal/appl/popper')
-rw-r--r--crypto/heimdal/appl/popper/ChangeLog169
-rw-r--r--crypto/heimdal/appl/popper/Makefile.am29
-rw-r--r--crypto/heimdal/appl/popper/Makefile.in623
-rw-r--r--crypto/heimdal/appl/popper/README381
-rw-r--r--crypto/heimdal/appl/popper/README-FIRST11
-rw-r--r--crypto/heimdal/appl/popper/README-KRB43
-rw-r--r--crypto/heimdal/appl/popper/maildir.c216
-rw-r--r--crypto/heimdal/appl/popper/pop3.rfc1081898
-rw-r--r--crypto/heimdal/appl/popper/pop3e.rfc1082619
-rw-r--r--crypto/heimdal/appl/popper/pop_auth.c220
-rw-r--r--crypto/heimdal/appl/popper/pop_debug.c280
-rw-r--r--crypto/heimdal/appl/popper/pop_dele.c107
-rw-r--r--crypto/heimdal/appl/popper/pop_dropcopy.c173
-rw-r--r--crypto/heimdal/appl/popper/pop_dropinfo.c232
-rw-r--r--crypto/heimdal/appl/popper/pop_get_command.c118
-rw-r--r--crypto/heimdal/appl/popper/pop_init.c398
-rw-r--r--crypto/heimdal/appl/popper/pop_last.c18
-rw-r--r--crypto/heimdal/appl/popper/pop_list.c59
-rw-r--r--crypto/heimdal/appl/popper/pop_log.c36
-rw-r--r--crypto/heimdal/appl/popper/pop_msg.c57
-rw-r--r--crypto/heimdal/appl/popper/pop_parse.c55
-rw-r--r--crypto/heimdal/appl/popper/pop_pass.c220
-rw-r--r--crypto/heimdal/appl/popper/pop_quit.c21
-rw-r--r--crypto/heimdal/appl/popper/pop_rset.c33
-rw-r--r--crypto/heimdal/appl/popper/pop_send.c176
-rw-r--r--crypto/heimdal/appl/popper/pop_stat.c26
-rw-r--r--crypto/heimdal/appl/popper/pop_uidl.c88
-rw-r--r--crypto/heimdal/appl/popper/pop_updt.c199
-rw-r--r--crypto/heimdal/appl/popper/pop_user.c36
-rw-r--r--crypto/heimdal/appl/popper/pop_xover.c37
-rw-r--r--crypto/heimdal/appl/popper/popper.8179
-rw-r--r--crypto/heimdal/appl/popper/popper.README.release45
-rw-r--r--crypto/heimdal/appl/popper/popper.c117
-rw-r--r--crypto/heimdal/appl/popper/popper.h347
-rw-r--r--crypto/heimdal/appl/popper/version.h19
35 files changed, 6245 insertions, 0 deletions
diff --git a/crypto/heimdal/appl/popper/ChangeLog b/crypto/heimdal/appl/popper/ChangeLog
new file mode 100644
index 0000000..8c85793
--- /dev/null
+++ b/crypto/heimdal/appl/popper/ChangeLog
@@ -0,0 +1,169 @@
+2000-12-31 Assar Westerlund <assar@sics.se>
+
+ * pop_init.c (pop_init): handle krb5_init_context failure
+ consistently
+ * pop_debug.c (doit_v5): handle krb5_init_context failure
+ consistently
+
+2000-06-10 Assar Westerlund <assar@sics.se>
+
+ * pop_init.c (krb4_authenticate): do not exit on failure, just
+ return
+ (krb5_authenticate): log errors from krb5_recvauth
+
+2000-04-12 Assar Westerlund <assar@sics.se>
+
+ * *.c: replace all erroneous calls to pop_log with POP_FAILURE
+ with POP_PRIORITY. reported by Janne Johansson <jj@it.kth.se>'
+
+2000-01-27 Assar Westerlund <assar@sics.se>
+
+ * pop_debug.c (main): figure out port number
+
+1999-12-20 Assar Westerlund <assar@sics.se>
+
+ * pop_init.c (pop_init): use getnameinfo_verified
+
+ * pop_debug.c (get_socket): use getaddrinfo
+
+1999-12-03 Johan Danielsson <joda@pdc.kth.se>
+
+ * pop_init.c: optionally trace connected addresses to a file
+
+1999-11-02 Assar Westerlund <assar@sics.se>
+
+ * pop_debug.c (main): redo the v4/v5 selection for consistency.
+ -4 -> try only v4 -5 -> try only v5 none, -45 -> try v5, v4
+
+1999-10-16 Johan Danielsson <joda@pdc.kth.se>
+
+ * pop_init.c (krb5_authenticate): don't use the principal
+ associated with the socket for authentication, instead let
+ krb5_rd_req pick the correct one from the ticket; just check that
+ it actually was a pop-ticket
+
+1999-08-12 Johan Danielsson <joda@pdc.kth.se>
+
+ * pop_init.c (pop_init): don't freehostent if ch == NULL
+
+ * pop_dele.c: implement XDELE to delete a range of messages
+
+1999-08-05 Assar Westerlund <assar@sics.se>
+
+ * pop_init.c: v6-ify
+
+ * pop_debug.c: v6-ify
+
+1999-05-10 Assar Westerlund <assar@sics.se>
+
+ * pop_debug.c (doit_v5): call krb5_sendauth with ccache == NULL
+
+1999-04-11 Assar Westerlund <assar@sics.se>
+
+ * pop_debug.c (main): use print_version
+
+Thu Apr 8 15:07:11 1999 Johan Danielsson <joda@hella.pdc.kth.se>
+
+ * pop_pass.c: remove definition of KRB_VERIFY_USER (moved to
+ config.h)
+
+Thu Mar 18 12:55:42 1999 Johan Danielsson <joda@hella.pdc.kth.se>
+
+ * pop_pass.c: define KRB_VERIFY_SECURE if not defined
+
+ * Makefile.am: include Makefile.am.common
+
+Wed Mar 17 23:36:21 1999 Assar Westerlund <assar@sics.se>
+
+ * pop_pass.c (krb4_verify_password): use KRB_VERIFY_SECURE instead
+ of 1
+
+Tue Mar 16 22:28:52 1999 Assar Westerlund <assar@sics.se>
+
+ * pop_pass.c: krb_verify_user_multiple -> krb_verify_user
+
+Sat Mar 13 22:17:29 1999 Assar Westerlund <assar@sics.se>
+
+ * pop_parse.c (pop_parse): cast when calling is* to get rid of a
+ warning
+
+Mon Mar 8 11:50:06 1999 Johan Danielsson <joda@hella.pdc.kth.se>
+
+ * pop_init.c: use print_version
+
+Fri Mar 5 15:14:29 1999 Johan Danielsson <joda@hella.pdc.kth.se>
+
+ * pop_send.c: fix handling of messages w/o body
+
+Sun Nov 22 10:33:29 1998 Assar Westerlund <assar@sics.se>
+
+ * pop_pass.c (pop_pass): try to always log
+
+ * Makefile.in (WFLAGS): set
+
+Fri Jul 10 01:14:25 1998 Assar Westerlund <assar@sics.se>
+
+ * pop_init.c: s/net_read/pop_net_read/
+
+Tue Jun 2 17:33:54 1998 Johan Danielsson <joda@emma.pdc.kth.se>
+
+ * pop_send.c: add missing newlines
+
+Sun May 24 20:59:45 1998 Johan Danielsson <joda@emma.pdc.kth.se>
+
+ * maildir.c (make_path): fix reversed args
+
+Sat May 16 00:02:18 1998 Assar Westerlund <assar@sics.se>
+
+ * Makefile.am: link with DBLIB
+
+Sun Apr 26 11:47:58 1998 Assar Westerlund <assar@sics.se>
+
+ * pop_pass.c (pop_pass): check return value from changeuser
+
+ * pop_dropcopy.c (changeuser): check that `setuid' and `setgid'
+ succeeded.
+
+ * popper.h: changeuser now returns int
+
+Thu Apr 23 00:54:38 1998 Johan Danielsson <joda@emma.pdc.kth.se>
+
+ * Add support for maildir spoolfiles.
+
+ * popper.h (MsgInfoList): replace `del_flag' and `retr_flag' with
+ single `flags'
+
+ * pop_dropcopy.c: Fix mismatched parenthesis.
+
+Sat Apr 4 15:13:56 1998 Assar Westerlund <assar@sics.se>
+
+ * pop_dropcopy.c (pop_dropcopy): first do mkstemp and then fdopen.
+ Originally from <map@stacken.kth.se>
+
+ * popper.h: include <io.h>
+
+Sat Feb 7 10:07:39 1998 Assar Westerlund <assar@sics.se>
+
+ * pop_pass.c(krb4_verify_password: Don't use REALM_SZ + 1, just
+ REALM_SZ
+
+Mon Dec 29 16:37:26 1997 Assar Westerlund <assar@sics.se>
+
+ * pop_updt.c (pop_updt): lseek before ftruncating the file. From
+ <map@stacken.kth.se>
+
+Sat Nov 22 13:46:39 1997 Johan Danielsson <joda@emma.pdc.kth.se>
+
+ * pop_pass.c: Destroy tickets after verification.
+
+Sun Nov 9 09:11:14 1997 Assar Westerlund <assar@sics.se>
+
+ * pop_dropinfo.c: be careful with mails without msg-id, subject,
+ or from
+
+Wed Oct 29 02:09:24 1997 Assar Westerlund <assar@sics.se>
+
+ * pop_pass.c: conditionalize OTP-support
+
+ * pop_init.c: conditionalize OTP-support
+
diff --git a/crypto/heimdal/appl/popper/Makefile.am b/crypto/heimdal/appl/popper/Makefile.am
new file mode 100644
index 0000000..d52d0cf
--- /dev/null
+++ b/crypto/heimdal/appl/popper/Makefile.am
@@ -0,0 +1,29 @@
+# $Id: Makefile.am,v 1.13 2000/11/15 22:51:09 assar Exp $
+
+include $(top_srcdir)/Makefile.am.common
+
+INCLUDES += $(INCLUDE_krb4)
+
+noinst_PROGRAMS = pop_debug
+
+libexec_PROGRAMS = popper
+
+popper_SOURCES = \
+ pop_dele.c pop_dropcopy.c pop_dropinfo.c \
+ pop_get_command.c pop_init.c \
+ pop_last.c pop_list.c pop_log.c \
+ pop_msg.c pop_parse.c pop_pass.c pop_quit.c \
+ pop_rset.c pop_send.c pop_stat.c pop_updt.c \
+ pop_user.c pop_uidl.c pop_xover.c popper.c \
+ maildir.c popper.h version.h
+
+EXTRA_DIST = pop3.rfc1081 pop3e.rfc1082 \
+ popper.README.release README-FIRST README-KRB4
+
+LDADD = \
+ $(LIB_otp) \
+ $(LIB_krb5) \
+ $(LIB_krb4) \
+ $(LIB_des) \
+ $(LIB_roken) \
+ $(DBLIB)
diff --git a/crypto/heimdal/appl/popper/Makefile.in b/crypto/heimdal/appl/popper/Makefile.in
new file mode 100644
index 0000000..0185f12
--- /dev/null
+++ b/crypto/heimdal/appl/popper/Makefile.in
@@ -0,0 +1,623 @@
+# Makefile.in generated automatically by automake 1.4b from Makefile.am
+
+# Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000
+# 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.
+
+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
+
+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@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_FLAG =
+transform = @program_transform_name@
+
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+
+@SET_MAKE@
+host_alias = @host_alias@
+host_triplet = @host@
+AIX_EXTRA_KAFS = @AIX_EXTRA_KAFS@
+AMDEP = @AMDEP@
+AMTAR = @AMTAR@
+AS = @AS@
+AWK = @AWK@
+CANONICAL_HOST = @CANONICAL_HOST@
+CATMAN = @CATMAN@
+CATMANEXT = @CATMANEXT@
+CC = @CC@
+CPP = @CPP@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+DBLIB = @DBLIB@
+DEPDIR = @DEPDIR@
+DIR_des = @DIR_des@
+DIR_roken = @DIR_roken@
+DLLTOOL = @DLLTOOL@
+EXEEXT = @EXEEXT@
+EXTRA_LIB45 = @EXTRA_LIB45@
+GROFF = @GROFF@
+INCLUDES_roken = @INCLUDES_roken@
+INCLUDE_ = @INCLUDE_@
+LEX = @LEX@
+LIBOBJS = @LIBOBJS@
+LIBTOOL = @LIBTOOL@
+LIB_ = @LIB_@
+LIB_AUTH_SUBDIRS = @LIB_AUTH_SUBDIRS@
+LIB_des = @LIB_des@
+LIB_des_appl = @LIB_des_appl@
+LIB_kdb = @LIB_kdb@
+LIB_otp = @LIB_otp@
+LIB_roken = @LIB_roken@
+LIB_security = @LIB_security@
+LN_S = @LN_S@
+LTLIBOBJS = @LTLIBOBJS@
+MAKEINFO = @MAKEINFO@
+NEED_WRITEAUTH_FALSE = @NEED_WRITEAUTH_FALSE@
+NEED_WRITEAUTH_TRUE = @NEED_WRITEAUTH_TRUE@
+NROFF = @NROFF@
+OBJDUMP = @OBJDUMP@
+OBJEXT = @OBJEXT@
+PACKAGE = @PACKAGE@
+RANLIB = @RANLIB@
+STRIP = @STRIP@
+VERSION = @VERSION@
+VOID_RETSIGTYPE = @VOID_RETSIGTYPE@
+WFLAGS = @WFLAGS@
+WFLAGS_NOIMPLICITINT = @WFLAGS_NOIMPLICITINT@
+WFLAGS_NOUNUSED = @WFLAGS_NOUNUSED@
+YACC = @YACC@
+dpagaix_CFLAGS = @dpagaix_CFLAGS@
+dpagaix_LDADD = @dpagaix_LDADD@
+install_sh = @install_sh@
+
+# $Id: Makefile.am,v 1.13 2000/11/15 22:51:09 assar Exp $
+
+
+# $Id: Makefile.am.common,v 1.3 1999/04/01 14:58:43 joda Exp $
+
+
+# $Id: Makefile.am.common,v 1.26 2001/05/21 13:27:48 joda Exp $
+
+
+AUTOMAKE_OPTIONS = foreign no-dependencies
+
+SUFFIXES = .et .h .1 .3 .5 .8 .cat1 .cat3 .cat5 .cat8 .x
+
+INCLUDES = -I$(top_builddir)/include $(INCLUDES_roken) $(INCLUDE_krb4)
+
+AM_CFLAGS = $(WFLAGS)
+
+CP = cp
+
+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_pidfile = @LIB_pidfile@
+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@
+
+LIBS = @LIBS@
+
+HESIODLIB = @HESIODLIB@
+HESIODINCLUDE = @HESIODINCLUDE@
+INCLUDE_hesiod = @INCLUDE_hesiod@
+LIB_hesiod = @LIB_hesiod@
+
+INCLUDE_krb4 = @INCLUDE_krb4@
+LIB_krb4 = @LIB_krb4@
+
+INCLUDE_openldap = @INCLUDE_openldap@
+LIB_openldap = @LIB_openldap@
+
+INCLUDE_readline = @INCLUDE_readline@
+
+LEXLIB = @LEXLIB@
+
+NROFF_MAN = groff -mandoc -Tascii
+
+@KRB4_TRUE@LIB_kafs = @KRB4_TRUE@$(top_builddir)/lib/kafs/libkafs.la $(AIX_EXTRA_KAFS)
+
+@KRB5_TRUE@LIB_krb5 = @KRB5_TRUE@$(top_builddir)/lib/krb5/libkrb5.la \
+@KRB5_TRUE@ $(top_builddir)/lib/asn1/libasn1.la
+@KRB5_TRUE@LIB_gssapi = @KRB5_TRUE@$(top_builddir)/lib/gssapi/libgssapi.la
+
+@DCE_TRUE@LIB_kdfs = @DCE_TRUE@$(top_builddir)/lib/kdfs/libkdfs.la
+
+CHECK_LOCAL = $(PROGRAMS)
+
+noinst_PROGRAMS = pop_debug
+
+libexec_PROGRAMS = popper
+
+popper_SOURCES = \
+ pop_dele.c pop_dropcopy.c pop_dropinfo.c \
+ pop_get_command.c pop_init.c \
+ pop_last.c pop_list.c pop_log.c \
+ pop_msg.c pop_parse.c pop_pass.c pop_quit.c \
+ pop_rset.c pop_send.c pop_stat.c pop_updt.c \
+ pop_user.c pop_uidl.c pop_xover.c popper.c \
+ maildir.c popper.h version.h
+
+
+EXTRA_DIST = pop3.rfc1081 pop3e.rfc1082 \
+ popper.README.release README-FIRST README-KRB4
+
+
+LDADD = \
+ $(LIB_otp) \
+ $(LIB_krb5) \
+ $(LIB_krb4) \
+ $(LIB_des) \
+ $(LIB_roken) \
+ $(DBLIB)
+
+subdir = appl/popper
+mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
+CONFIG_HEADER = ../../include/config.h
+CONFIG_CLEAN_FILES =
+libexec_PROGRAMS = popper$(EXEEXT)
+noinst_PROGRAMS = pop_debug$(EXEEXT)
+PROGRAMS = $(libexec_PROGRAMS) $(noinst_PROGRAMS)
+
+
+DEFS = @DEFS@ -I. -I$(srcdir) -I../../include
+CPPFLAGS = @CPPFLAGS@
+LDFLAGS = @LDFLAGS@
+X_CFLAGS = @X_CFLAGS@
+X_LIBS = @X_LIBS@
+X_EXTRA_LIBS = @X_EXTRA_LIBS@
+X_PRE_LIBS = @X_PRE_LIBS@
+pop_debug_SOURCES = pop_debug.c
+pop_debug_OBJECTS = pop_debug.$(OBJEXT)
+pop_debug_LDADD = $(LDADD)
+@KRB5_FALSE@pop_debug_DEPENDENCIES =
+@KRB5_TRUE@pop_debug_DEPENDENCIES = $(top_builddir)/lib/krb5/libkrb5.la \
+@KRB5_TRUE@$(top_builddir)/lib/asn1/libasn1.la
+pop_debug_LDFLAGS =
+am_popper_OBJECTS = pop_dele.$(OBJEXT) pop_dropcopy.$(OBJEXT) \
+pop_dropinfo.$(OBJEXT) pop_get_command.$(OBJEXT) pop_init.$(OBJEXT) \
+pop_last.$(OBJEXT) pop_list.$(OBJEXT) pop_log.$(OBJEXT) \
+pop_msg.$(OBJEXT) pop_parse.$(OBJEXT) pop_pass.$(OBJEXT) \
+pop_quit.$(OBJEXT) pop_rset.$(OBJEXT) pop_send.$(OBJEXT) \
+pop_stat.$(OBJEXT) pop_updt.$(OBJEXT) pop_user.$(OBJEXT) \
+pop_uidl.$(OBJEXT) pop_xover.$(OBJEXT) popper.$(OBJEXT) \
+maildir.$(OBJEXT)
+popper_OBJECTS = $(am_popper_OBJECTS)
+popper_LDADD = $(LDADD)
+@KRB5_FALSE@popper_DEPENDENCIES =
+@KRB5_TRUE@popper_DEPENDENCIES = $(top_builddir)/lib/krb5/libkrb5.la \
+@KRB5_TRUE@$(top_builddir)/lib/asn1/libasn1.la
+popper_LDFLAGS =
+COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+CFLAGS = @CFLAGS@
+CCLD = $(CC)
+LINK = $(LIBTOOL) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
+DIST_SOURCES = pop_debug.c $(popper_SOURCES)
+depcomp =
+DIST_COMMON = README ChangeLog Makefile.am Makefile.in
+
+
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+
+GZIP_ENV = --best
+SOURCES = pop_debug.c $(popper_SOURCES)
+OBJECTS = pop_debug.$(OBJEXT) $(am_popper_OBJECTS)
+
+all: all-redirect
+.SUFFIXES:
+.SUFFIXES: .et .h .1 .3 .5 .8 .cat1 .cat3 .cat5 .cat8 .x .c .lo .o .obj
+$(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/popper/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 \
+ f="`echo $$p|sed -e 's/$(EXEEXT)$$//' -e '$(transform)' -e 's/$$/$(EXEEXT)/'`"; \
+ echo " $(LIBTOOL) --mode=install $(INSTALL_PROGRAM) $(INSTALL_STRIP_FLAG) $$p $(DESTDIR)$(libexecdir)/$$f"; \
+ $(LIBTOOL) --mode=install $(INSTALL_PROGRAM) $(INSTALL_STRIP_FLAG) $$p $(DESTDIR)$(libexecdir)/$$f; \
+ else :; fi; \
+ done
+
+uninstall-libexecPROGRAMS:
+ @$(NORMAL_UNINSTALL)
+ @list='$(libexec_PROGRAMS)'; for p in $$list; do \
+ f="`echo $$p|sed -e 's/$(EXEEXT)$$//' -e '$(transform)' -e 's/$$/$(EXEEXT)/'`"; \
+ echo " rm -f $(DESTDIR)$(libexecdir)/$$f"; \
+ rm -f $(DESTDIR)$(libexecdir)/$$f; \
+ done
+
+mostlyclean-noinstPROGRAMS:
+
+clean-noinstPROGRAMS:
+ -test -z "$(noinst_PROGRAMS)" || rm -f $(noinst_PROGRAMS)
+
+distclean-noinstPROGRAMS:
+
+maintainer-clean-noinstPROGRAMS:
+
+mostlyclean-compile:
+ -rm -f *.o core *.core
+ -rm -f *.$(OBJEXT)
+
+clean-compile:
+
+distclean-compile:
+ -rm -f *.tab.c
+
+maintainer-clean-compile:
+
+mostlyclean-libtool:
+ -rm -f *.lo
+
+clean-libtool:
+ -rm -rf .libs _libs
+
+distclean-libtool:
+
+maintainer-clean-libtool:
+
+pop_debug$(EXEEXT): $(pop_debug_OBJECTS) $(pop_debug_DEPENDENCIES)
+ @rm -f pop_debug$(EXEEXT)
+ $(LINK) $(pop_debug_LDFLAGS) $(pop_debug_OBJECTS) $(pop_debug_LDADD) $(LIBS)
+
+popper$(EXEEXT): $(popper_OBJECTS) $(popper_DEPENDENCIES)
+ @rm -f popper$(EXEEXT)
+ $(LINK) $(popper_LDFLAGS) $(popper_OBJECTS) $(popper_LDADD) $(LIBS)
+.c.o:
+ $(COMPILE) -c $<
+.c.obj:
+ $(COMPILE) -c `cygpath -w $<`
+.c.lo:
+ $(LTCOMPILE) -c -o $@ $<
+
+tags: TAGS
+
+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
+ list='$(SOURCES) $(HEADERS) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) ' { files[$$0] = 1; } \
+ END { for (i in files) print i; }'`; \
+ mkid -fID $$unique $(LISP)
+
+TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+ $(TAGS_FILES) $(LISP)
+ tags=; \
+ here=`pwd`; \
+ list='$(SOURCES) $(HEADERS) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) ' { files[$$0] = 1; } \
+ END { for (i in files) print i; }'`; \
+ test -z "$(ETAGS_ARGS)$$unique$(LISP)$$tags" \
+ || etags $(ETAGS_ARGS) $$tags $$unique $(LISP)
+
+GTAGS:
+ here=`CDPATH=: && cd $(top_builddir) && pwd` \
+ && cd $(top_srcdir) \
+ && gtags -i $$here
+
+mostlyclean-tags:
+
+clean-tags:
+
+distclean-tags:
+ -rm -f TAGS ID
+
+maintainer-clean-tags:
+
+distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir)
+
+distdir: $(DISTFILES)
+ @for file in $(DISTFILES); do \
+ d=$(srcdir); \
+ if test -d $$d/$$file; then \
+ cp -pR $$d/$$file $(distdir) \
+ || exit 1; \
+ else \
+ test -f $(distdir)/$$file \
+ || cp -p $$d/$$file $(distdir)/$$file \
+ || exit 1; \
+ 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
+ @$(NORMAL_INSTALL)
+ $(MAKE) $(AM_MAKEFLAGS) install-exec-hook
+install-exec: install-exec-am
+
+install-data-am: 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: uninstall-am
+all-am: Makefile $(PROGRAMS) all-local
+all-redirect: all-am
+install-strip:
+ $(MAKE) $(AM_MAKEFLAGS) INSTALL_STRIP_FLAG=-s install
+installdirs:
+ $(mkinstalldirs) $(DESTDIR)$(libexecdir)
+
+
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+ -rm -f Makefile $(CONFIG_CLEAN_FILES)
+ -rm -f config.cache config.log stamp-h stamp-h[0-9]*
+
+maintainer-clean-generic:
+ -rm -f Makefile.in
+mostlyclean-am: mostlyclean-libexecPROGRAMS mostlyclean-noinstPROGRAMS \
+ mostlyclean-compile mostlyclean-libtool \
+ mostlyclean-tags mostlyclean-generic
+
+mostlyclean: mostlyclean-am
+
+clean-am: clean-libexecPROGRAMS clean-noinstPROGRAMS clean-compile \
+ clean-libtool clean-tags clean-generic mostlyclean-am
+
+clean: clean-am
+
+distclean-am: distclean-libexecPROGRAMS distclean-noinstPROGRAMS \
+ distclean-compile distclean-libtool distclean-tags \
+ distclean-generic clean-am
+ -rm -f libtool
+
+distclean: distclean-am
+
+maintainer-clean-am: maintainer-clean-libexecPROGRAMS \
+ maintainer-clean-noinstPROGRAMS \
+ 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-noinstPROGRAMS distclean-noinstPROGRAMS \
+clean-noinstPROGRAMS maintainer-clean-noinstPROGRAMS \
+mostlyclean-compile distclean-compile clean-compile \
+maintainer-clean-compile mostlyclean-libtool distclean-libtool \
+clean-libtool maintainer-clean-libtool 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 install-strip 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 \
+ echo "*"; \
+ echo "* Failed to install $$x setuid root"; \
+ echo "*"; \
+ 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-cat-mans:
+ $(SHELL) $(top_srcdir)/cf/install-catman.sh "$(INSTALL_DATA)" "$(mkinstalldirs)" "$(srcdir)" "$(DESTDIR)$(mandir)" '$(CATMANEXT)' $(man_MANS) $(man1_MANS) $(man3_MANS) $(man5_MANS) $(man8_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
+
+# 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/popper/README b/crypto/heimdal/appl/popper/README
new file mode 100644
index 0000000..0735fdd
--- /dev/null
+++ b/crypto/heimdal/appl/popper/README
@@ -0,0 +1,381 @@
+@(#)@(#)README 2.6 2.6 4/2/91
+
+
+The Post Office Protocol Server: Installation Guide
+
+
+
+Introduction
+
+The Post Office Protocol server runs on a variety of Unix[1] computers
+to manage electronic mail for Macintosh and MS-DOS computers. The
+server was developed at the University of California at Berkeley and
+conforms fully to the specifications in RFC 1081[2] and RFC 1082[3].
+The Berkeley server also has extensions to send electronic mail on
+behalf of a client.
+
+This guide explains how to install the POP server on your Unix
+computer. It assumes that you are not only familiar with Unix but also
+capable of performing Unix system administration.
+
+
+How to Obtain the Server
+
+The POP server is available via anonymous ftp from ftp.CC.Berkeley.EDU
+(128.32.136.9, 128.32.206.12). It is in two files in the pub directory:
+a compressed tar file popper-version.tar.Z and a Macintosh StuffIt archive
+in BinHex format called MacPOP.sit.hqx.
+
+
+Contents of the Distribution
+
+The distribution contains the following:
+
++ All of the C source necessary to create the server program.
+
++ A visual representation of how the POP system works.
+
++ Reprints of RFC 1081 and RFC 1082.
+
++ A HyperCard stack POP client implementation using MacTCP.
+
++ A man page for the popper daemon.
+
++ This guide.
+
+
+Compatibility
+
+The Berkeley POP server has been successfully tested on the following
+Unix operating systems:
+
++ Berkeley Systems Distribution 4.3
+
++ Sun Microsystems Operating System versions 3.5 and 4.0
+
++ Ultrix version 2.3
+
+The following POP clients operate correctly with the Berkeley POP server:
+
++ The Berkeley HyperMail HyperCard stack for the Apple Macintosh
+ (distributed with the server).
+
++ The Stanford University Macintosh Internet Protocol MacMH program.
+
++ The Stanford University Personal Computer Internet Protocol MH
+ program.
+
++ The mh version 6.0 programs for Unix.
+
+
+Support
+
+The Berkeley POP server is not officially supported and is without any
+warranty, explicit or implied. However, we are interested in your
+experiences using the server. Bugs, comments and suggestions should be
+sent electronically to netinfo@garnet.Berkeley.EDU.
+
+
+Operational Characteristics
+
+The POP Transaction Cycle
+
+The Berkeley POP server is a single program (called popper) that is
+launched by inetd when it gets a service request on the POP TCP port.
+(The official port number specified in RFC 1081 for POP version 3 is
+port 110. However, some POP3 clients attempt to contact the server at
+port 109, the POP version 2 port. Unless you are running both POP2 and
+POP3 servers, you can simply define both ports for use by the POP3
+server. This is explained in the installation instructions later on.)
+The popper program initializes and verifies that the peer IP address is
+registered in the local domain, logging a warning message when a
+connection is made to a client whose IP address does not have a
+canonical name. For systems using BSD 4.3 bind, it also checks to see
+if a cannonical name lookup for the client returns the same peer IP
+address, logging a warning message if it does not. The the server
+enters the authorization state, during which the client must correctly
+identify itself by providing a valid Unix userid and password on the
+server's host machine. No other exchanges are allowed during this
+state (other than a request to quit.) If authentication fails, a
+warning message is logged and the session ends. Once the user is
+identified, popper changes its user and group ids to match that of the
+user and enters the transaction state. The server makes a temporary
+copy of the user's maildrop (ordinarily in /usr/spool/mail) which is
+used for all subsequent transactions. These include the bulk of POP
+commands to retrieve mail, delete mail, undelete mail, and so forth. A
+Berkeley extension also allows the user to submit a mail parcel to the
+server who mails it using the sendmail program (this extension is
+supported in the HyperMail client distributed with the server). When
+the client quits, the server enters the final update state during which
+the network connection is terminated and the user's maildrop is updated
+with the (possibly) modified temporary maildrop.
+
+
+Logging
+
+The POP server uses syslog to keep a record of its activities. On
+systems with BSD 4.3 syslogging, the server logs (by default) to the
+"local0" facility at priority "notice" for all messages except
+debugging which is logged at priority "debug". The default log file is
+/usr/spool/mqueue/POPlog. These can be changed, if desired. On
+systems with 4.2 syslogging all messages are logged to the local log
+file, usually /usr/spool/mqueue/syslog.
+
+Problems
+
+If the filesystem which holds the /usr/spool/mail fills up users will
+experience difficulties. The filesystem must have enough space to hold
+(approximately) two copies of the largest mail box. Popper (v1.81 and
+above) is designed to be robust in the face of this problem, but you may
+end up with a situation where some of the user's mail is in
+
+ /usr/spool/mail/.userid.pop
+
+and some of the mail is in
+
+ /usr/spool/mail/userid
+
+If this happens the System Administrator should clear enough disk space
+so that the filesystem has at least as much free disk as both mailboxes
+hold and probably a little more. Then the user should initiate a POP
+session, and do nothing but quit. If the POP session ends without an
+error the user can then use POP or another mail program to clean up his/her
+mailbox.
+
+Alternatively, the System Administrator can combine the two files (but
+popper will do this for you if there is enough disk space).
+
+
+Debugging
+
+The popper program will log debugging information when the -d parameter
+is specified after its invocation in the inetd.conf file. Care should
+be exercised in using this option since it generates considerable
+output in the syslog file. Alternatively, the "-t <file-name>" option
+will place debugging information into file "<file-name>" using fprintf
+instead of syslog. (To enable debugging, you must edit the Makefile
+to add -DDEBUG to the compiler options.)
+
+For SunOS version 3.5, the popper program is launched by inetd from
+/etc/servers. This file does not allow you to specify command line
+arguments. Therefore, if you want to enable debugging, you can specify
+a shell script in /etc/servers to be launched instead of popper and in
+this script call popper with the desired arguments.
+
+
+Installation
+
+1. Examine this file for the latest information, warnings, etc.
+
+2. Check the Makefile for conformity with your system.
+
+3. Issue the make command in the directory containing the popper
+ source.
+
+4. Issue the make install command in the directory containing the
+ popper source to copy the program to /usr/etc.
+
+5. Enable syslogging:
+
+ + For systems with 4.3 syslogging:
+
+ Add the following line to the /etc/syslog.conf file:
+
+ local0.notice;local0.debug /usr/spool/mqueue/POPlog
+
+ Create the empty file /usr/spool/mqueue/POPlog.
+
+ Kill and restart the syslogd daemon.
+
+ + For systems with 4.2 syslogging:
+
+ Be sure that you are logging messages of priority 7 and higher.
+ For example:
+
+ 7/usr/spool/mqueue/syslog
+ 9/dev/null
+
+6. Update /etc/services:
+
+ Add the following line to the /etc/services file:
+
+ pop 110/tcp
+
+ Note: This is the official port number for version 3 of the
+ Post Office Protocol as defined in RFC 1081. However, some
+ POP3 clients use port 109, the port number for the previous
+ version (2) of POP. Therefore you may also want to add the
+ following line to the /etc/services file:
+
+ pop2 109/tcp
+
+ For Sun systems running yp, also do the following:
+
+ + Change to the /var/yp directory.
+
+ + Issue the make services command.
+
+7. Update the inetd daemon configuration. Include the second line ONLY if you
+ are running the server at both ports.
+
+ + On BSD 4.3 and SunOS 4.0 systems, add the following line to the
+ /etc/inetd.conf file:
+
+ pop stream tcp nowait root /usr/etc/popper popper
+ pop2 stream tcp nowait root /usr/etc/popper popper
+
+ + On Ultrix systems, add the following line to the
+ /etc/inetd.conf file:
+
+ pop stream tcp nowait /usr/etc/popper popper
+ pop2 stream tcp nowait /usr/etc/popper popper
+
+ + On SunOS 3.5 systems, add the following line to the
+ /etc/servers file:
+
+ pop tcp /usr/etc/popper
+ pop2 tcp /usr/etc/popper
+
+ Kill and restart the inetd daemon.
+
+You can confirm that the POP server is running on Unix by telneting to
+port 110 (or 109 if you set it up that way). For example:
+
+%telnet myhost 110
+Trying...
+Connected to myhost.berkeley.edu.
+Escape character is '^]'.
++OK UCB Pop server (version 1.6) at myhost starting.
+quit
+Connection closed by foreign host.
+
+
+Release Notes
+
+1.83 Make sure that everything we do as root is non-destructive.
+
+1.82 Make the /usr/spool/mail/.userid.pop file owned by the user rather
+ than owned by root.
+
+1.81 There were two versions of 1.7 floating around, 1.7b4 and 1.7b5.
+ The difference is that 1.7b5 attempted to save disk space on
+ /usr/spool/mail by deleting the users permanent maildrop after
+ making the temporary copy. Unfortunately, if compiled with
+ -DDEBUG, this version could easily wipe out a users' mail file.
+ This is now fixed.
+
+ This version also fixes a security hole for systems that have
+ /usr/spool/mail writeable by all users.
+
+ With this version we go to all new SCCS IDs for all files. This
+ is unfortunate, and we hope it is not too much of a problem.
+
+ Thanks to Steve Dorner of UIUC for pointing out the major problem.
+
+1.7 Extensive re-write of the maildrop processing code contributed by
+ Viktor Dukhovni <viktor@math.princeton.edu> that greatly reduces the
+ possibility that the maildrop can be corrupted as the result of
+ simultaneous access by two or more processes.
+
+ Added "pop_dropcopy" module to create a temporary maildrop from
+ the existing, standard maildrop as root before the setuid and
+ setgid for the user is done. This allows the temporary maildrop
+ to be created in a mail spool area that is not world read-writable.
+
+ This version does *not* send the sendmail "From " delimiter line
+ in response to a TOP or RETR command.
+
+ Encased all debugging code in #ifdef DEBUG constructs. This code can
+ be included by specifying the DEGUG compiler flag. Note: You still
+ need to use the -d or -t option to obtain debugging output.
+
+1.6 Corrects a bug that causes the server to crash on SunOS
+ 4.0 systems.
+
+ Uses varargs and vsprintf (if available) in pop_log and
+ pop_msg. This is enabled by the "HAVE_VSPRINTF"
+ compiler flag.
+
+ For systems with BSD 4.3 bind, performs a cannonical
+ name lookup and searches the returned address(es) for
+ the client's address, logging a warning message if it
+ is not located. This is enabled by the "BIND43"
+ comiler flag.
+
+ Removed all the includes from popper.h and distributed
+ them throughout the porgrams files, as needed.
+
+ Reformatted the source to convert tabs to spaces and
+ shorten lines for display on 80-column terminals.
+
+1.5 Creates the temporary maildrop with mode "600" and
+ immediately unlinks it.
+
+ Uses client's IP address in lieu of a canonical name if
+ the latter cannot be obtained.
+
+ Added "-t <file-name>" option. The presence of this
+ option causes debugging output to be placed in the file
+ "file-name" using fprintf instead of the system log
+ file using syslog.
+
+ Corrected maildrop parsing problem.
+
+1.4 Copies user's mail into a temporary maildrop on which
+ all subsequent activity is performed.
+
+ Added "pop_log" function and replaced "syslog" calls
+ throughout the code with it.
+
+1.3 Corrected updating of Status: header line.
+
+ Added strncasecmp for systems that do not have one.
+ Used strncasecmp in all appropriate places. This is
+ enabled by the STRNCASECMP compiler flag.
+
+1.2 Support for version 4.2 syslogging added. This is
+ enabled by the SYSLOG42 compiler flag.
+
+1.1 Several bugs fixed.
+
+1.0 Original version.
+
+
+Limitations
+
++ The POP server copies the user's entire maildrop to /tmp and
+ then operates on that copy. If the maildrop is particularly
+ large, or inadequate space is available in /tmp, then the
+ server will refuse to continue and terminate the connection.
+
++ Simultaneous modification of a single maildrop can result in
+ confusing results. For example, manipulating messages in a
+ maildrop using the Unix /usr/ucb/mail command while a copy of
+ it is being processed by the POP server can cause the changes
+ made by one program to be lost when the other terminates. This
+ problem is being worked on and will be fixed in a later
+ release.
+
+
+Credits
+
+The POP server was written by Edward Moy and Austin Shelton with
+contributions from Robert Campbell (U.C. Berkeley) and Viktor Dukhovni
+(Princeton University). Edward Moy wrote the HyperMail stack and drew
+the POP operation diagram. This installation guide was written by
+Austin Shelton.
+
+
+Footnotes
+
+[1] Copyright (c) 1990 Regents of the University of California.
+ All rights reserved. The Berkeley software License Agreement
+ specifies the terms and conditions for redistribution. Unix is
+ a registered trademark of AT&T corporation. HyperCard and
+ Macintosh are registered trademarks of Apple Corporation.
+
+[2] M. Rose, Post Office Protocol - Version 3. RFC 1081, NIC,
+ November 1988.
+
+[3] M. Rose, Post Office Protocol - Version 3 Extended Service
+ Offerings. RFC 1082, NIC, November 1988.
diff --git a/crypto/heimdal/appl/popper/README-FIRST b/crypto/heimdal/appl/popper/README-FIRST
new file mode 100644
index 0000000..3d78fb6
--- /dev/null
+++ b/crypto/heimdal/appl/popper/README-FIRST
@@ -0,0 +1,11 @@
+This kerberized popper was based on popper-1.831beta
+which was later announced as "offical" and not beta.
+
+This program is able to talk both the pop3 and the kpop3 protocol.
+
+Please note that the server principal is pop.hostname and not
+rcmd.hostname. I.e an additional entry is needed in your mailhub's
+/etc/srvtab. Use ksrvutil to add the extra prinicpal.
+
+The server is usually started from inetd and there is already an entry
+for that in inetd.conf.changes.
diff --git a/crypto/heimdal/appl/popper/README-KRB4 b/crypto/heimdal/appl/popper/README-KRB4
new file mode 100644
index 0000000..f029cf9
--- /dev/null
+++ b/crypto/heimdal/appl/popper/README-KRB4
@@ -0,0 +1,3 @@
+Define KERBEROS if you want support for Kerberos V4 style
+authentification, then you will be able to start a kerberise pop with
+the `-k' flag.
diff --git a/crypto/heimdal/appl/popper/maildir.c b/crypto/heimdal/appl/popper/maildir.c
new file mode 100644
index 0000000..4c9a441
--- /dev/null
+++ b/crypto/heimdal/appl/popper/maildir.c
@@ -0,0 +1,216 @@
+/*
+ * Copyright (c) 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.
+ */
+
+#include <popper.h>
+#include <dirent.h>
+RCSID("$Id: maildir.c,v 1.5 1999/12/02 16:58:33 joda Exp $");
+
+static void
+make_path(POP *p, MsgInfoList *mp, int new, char *buf, size_t len)
+{
+ snprintf(buf, len, "%s/%s%s%s", p->drop_name,
+ new ? "new" : "cur", mp ? "/" : "", mp ? mp->name : "");
+}
+
+static int
+scan_file(POP *p, MsgInfoList *mp)
+{
+ char path[MAXDROPLEN];
+ FILE *f;
+ char buf[1024];
+ int eoh = 0;
+
+ make_path(p, mp, mp->flags & NEW_FLAG, path, sizeof(path));
+ f = fopen(path, "r");
+
+ if(f == NULL) {
+#ifdef DEBUG
+ if(p->debug)
+ pop_log(p, POP_DEBUG,
+ "Failed to open message file `%s': %s",
+ path, strerror(errno));
+#endif
+ return pop_msg (p, POP_FAILURE,
+ "Failed to open message file `%s'", path);
+ }
+ while(fgets(buf, sizeof(buf), f)) {
+ if(buf[strlen(buf) - 1] == '\n')
+ mp->lines++;
+ mp->length += strlen(buf);
+ if(eoh)
+ continue;
+ if(strcmp(buf, "\n") == 0)
+ eoh = 1;
+ parse_header(mp, buf);
+ }
+ fclose(f);
+ return add_missing_headers(p, mp);
+}
+
+static int
+scan_dir(POP *p, int new)
+{
+ char tmp[MAXDROPLEN];
+ DIR *dir;
+ struct dirent *dent;
+ MsgInfoList *mp = p->mlp;
+ int n_mp = p->msg_count;
+ int e;
+
+ make_path(p, NULL, new, tmp, sizeof(tmp));
+ mkdir(tmp, 0700);
+ dir = opendir(tmp);
+ while((dent = readdir(dir)) != NULL) {
+ if(strcmp(dent->d_name, ".") == 0 || strcmp(dent->d_name, "..") == 0)
+ continue;
+ mp = realloc(mp, (n_mp + 1) * sizeof(*mp));
+ if(mp == NULL) {
+ p->msg_count = 0;
+ return pop_msg (p, POP_FAILURE,
+ "Can't build message list for '%s': Out of memory",
+ p->user);
+ }
+ memset(mp + n_mp, 0, sizeof(*mp));
+ mp[n_mp].name = strdup(dent->d_name);
+ if(mp[n_mp].name == NULL) {
+ p->msg_count = 0;
+ return pop_msg (p, POP_FAILURE,
+ "Can't build message list for '%s': Out of memory",
+ p->user);
+ }
+ mp[n_mp].number = n_mp + 1;
+ mp[n_mp].flags = 0;
+ if(new)
+ mp[n_mp].flags |= NEW_FLAG;
+ e = scan_file(p, &mp[n_mp]);
+ if(e != POP_SUCCESS)
+ return e;
+ p->drop_size += mp[n_mp].length;
+ n_mp++;
+ }
+ closedir(dir);
+ p->mlp = mp;
+ p->msg_count = n_mp;
+ return POP_SUCCESS;
+}
+
+int
+pop_maildir_info(POP *p)
+{
+ int e;
+
+ p->temp_drop[0] = '\0';
+ p->mlp = NULL;
+ p->msg_count = 0;
+
+ e = scan_dir(p, 0);
+ if(e != POP_SUCCESS) return e;
+
+ e = scan_dir(p, 1);
+ if(e != POP_SUCCESS) return e;
+ return POP_SUCCESS;
+}
+
+int
+pop_maildir_update(POP *p)
+{
+ int i;
+ char tmp1[MAXDROPLEN], tmp2[MAXDROPLEN];
+ for(i = 0; i < p->msg_count; i++) {
+ make_path(p, &p->mlp[i], p->mlp[i].flags & NEW_FLAG,
+ tmp1, sizeof(tmp1));
+ if(p->mlp[i].flags & DEL_FLAG) {
+#ifdef DEBUG
+ if(p->debug)
+ pop_log(p, POP_DEBUG, "Removing `%s'", tmp1);
+#endif
+ if(unlink(tmp1) < 0) {
+#ifdef DEBUG
+ if(p->debug)
+ pop_log(p, POP_DEBUG, "Failed to remove `%s': %s",
+ tmp1, strerror(errno));
+#endif
+ /* return failure? */
+ }
+ } else if((p->mlp[i].flags & NEW_FLAG) &&
+ (p->mlp[i].flags & RETR_FLAG)) {
+ make_path(p, &p->mlp[i], 0, tmp2, sizeof(tmp2));
+#ifdef DEBUG
+ if(p->debug)
+ pop_log(p, POP_DEBUG, "Linking `%s' to `%s'", tmp1, tmp2);
+#endif
+ if(link(tmp1, tmp2) == 0) {
+#ifdef DEBUG
+ if(p->debug)
+ pop_log(p, POP_DEBUG, "Removing `%s'", tmp1);
+#endif
+ if(unlink(tmp1) < 0) {
+#ifdef DEBUG
+ if(p->debug)
+ pop_log(p, POP_DEBUG, "Failed to remove `%s'", tmp1);
+#endif
+ /* return failure? */
+ }
+ } else {
+ if(errno == EXDEV) {
+#ifdef DEBUG
+ if(p->debug)
+ pop_log(p, POP_DEBUG, "Trying to rename `%s' to `%s'",
+ tmp1, tmp2);
+#endif
+ if(rename(tmp1, tmp2) < 0) {
+#ifdef DEBUG
+ if(p->debug)
+ pop_log(p, POP_DEBUG, "Failed to rename `%s' to `%s'",
+ tmp1, tmp2);
+#endif
+ }
+ }
+ }
+ }
+ }
+ return(pop_quit(p));
+}
+
+int
+pop_maildir_open(POP *p, MsgInfoList *mp)
+{
+ char tmp[MAXDROPLEN];
+ make_path(p, mp, mp->flags & NEW_FLAG, tmp, sizeof(tmp));
+ if(p->drop)
+ fclose(p->drop);
+ p->drop = fopen(tmp, "r");
+ if(p->drop == NULL)
+ return pop_msg(p, POP_FAILURE, "Failed to open message file");
+ return POP_SUCCESS;
+}
diff --git a/crypto/heimdal/appl/popper/pop3.rfc1081 b/crypto/heimdal/appl/popper/pop3.rfc1081
new file mode 100644
index 0000000..08ea6dd
--- /dev/null
+++ b/crypto/heimdal/appl/popper/pop3.rfc1081
@@ -0,0 +1,898 @@
+
+
+
+
+
+
+Network Working Group M. Rose
+Request for Comments: 1081 TWG
+ November 1988
+
+ Post Office Protocol - Version 3
+
+
+Status of this Memo
+
+ This memo suggests a simple method for workstations to dynamically
+ access mail from a mailbox server. This RFC specifies a proposed
+ protocol for the Internet community, and requests discussion and
+ suggestions for improvements. Distribution of this memo is
+ unlimited.
+
+ This memo is based on RFC 918 (since revised as RFC 937). Although
+ similar in form to the original Post Office Protocol (POP) proposed
+ for the Internet community, the protocol discussed in this memo is
+ similar in spirit to the ideas investigated by the MZnet project at
+ the University of California, Irvine.
+
+ Further, substantial work was done on examining POP in a PC-based
+ environment. This work, which resulted in additional functionality
+ in this protocol, was performed by the ACIS Networking Systems Group
+ at Stanford University. The author gratefully acknowledges their
+ interest.
+
+Introduction
+
+ On certain types of smaller nodes in the Internet it is often
+ impractical to maintain a message transport system (MTS). For
+ example, a workstation may not have sufficient resources (cycles,
+ disk space) in order to permit a SMTP server and associated local
+ mail delivery system to be kept resident and continuously running.
+ Similarly, it may be expensive (or impossible) to keep a personal
+ computer interconnected to an IP-style network for long amounts of
+ time (the node is lacking the resource known as "connectivity").
+
+ Despite this, it is often very useful to be able to manage mail on
+ these smaller nodes, and they often support a user agent (UA) to aid
+ the tasks of mail handling. To solve this problem, a node which can
+ support an MTS entity offers a maildrop service to these less endowed
+ nodes. The Post Office Protocol - Version 3 (POP3) is intended to
+ permit a workstation to dynamically access a maildrop on a server
+ host in a useful fashion. Usually, this means that the POP3 is used
+ to allow a workstation to retrieve mail that the server is holding
+ for it.
+
+
+
+
+Rose [Page 1]
+
+RFC 1081 POP3 November 1988
+
+
+ For the remainder of this memo, the term "client host" refers to a
+ host making use of the POP3 service, while the term "server host"
+ refers to a host which offers the POP3 service.
+
+A Short Digression
+
+ This memo does not specify how a client host enters mail into the
+ transport system, although a method consistent with the philosophy of
+ this memo is presented here:
+
+ When the user agent on a client host wishes to enter a message
+ into the transport system, it establishes an SMTP connection to
+ its relay host (this relay host could be, but need not be, the
+ POP3 server host for the client host).
+
+ If this method is followed, then the client host appears to the MTS
+ as a user agent, and should NOT be regarded as a "trusted" MTS entity
+ in any sense whatsoever. This concept, along with the role of the
+ POP3 as a part of a split-UA model is discussed later in this memo.
+
+ Initially, the server host starts the POP3 service by listening on
+ TCP port 110. When a client host wishes to make use of the service,
+ it establishes a TCP connection with the server host. When the
+ connection is established, the POP3 server sends a greeting. The
+ client and POP3 server then exchange commands and responses
+ (respectively) until the connection is closed or aborted.
+
+ Commands in the POP3 consist of a keyword possibly followed by an
+ argument. All commands are terminated by a CRLF pair.
+
+ Responses in the POP3 consist of a success indicator and a keyword
+ possibly followed by additional information. All responses are
+ terminated by a CRLF pair. There are currently two success
+ indicators: positive ("+OK") and negative ("-ERR").
+
+ Responses to certain commands are multi-line. In these cases, which
+ are clearly indicated below, after sending the first line of the
+ response and a CRLF, any additional lines are sent, each terminated
+ by a CRLF pair. When all lines of the response have been sent, a
+ final line is sent, consisting of a termination octet (decimal code
+ 046, ".") and a CRLF pair. If any line of the multi-line response
+ begins with the termination octet, the line is "byte-stuffed" by
+ pre-pending the termination octet to that line of the response.
+ Hence a multi-line response is terminated with the five octets
+ "CRLF.CRLF". When examining a multi-line response, the client checks
+ to see if the line begins with the termination octet. If so and if
+ octets other than CRLF follow, the the first octet of the line (the
+ termination octet) is stripped away. If so and if CRLF immediately
+
+
+
+Rose [Page 2]
+
+RFC 1081 POP3 November 1988
+
+
+ follows the termination character, then the response from the POP
+ server is ended and the line containing ".CRLF" is not considered
+ part of the multi-line response.
+
+ A POP3 session progresses through a number of states during its
+ lifetime. Once the TCP connection has been opened and the POP3
+ server has sent the greeting, the session enters the AUTHORIZATION
+ state. In this state, the client must identify itself to the POP3
+ server. Once the client has successfully done this, the server
+ acquires resources associated with the client's maildrop, and the
+ session enters the TRANSACTION state. In this state, the client
+ requests actions on the part of the POP3 server. When the client has
+ finished its transactions, the session enters the UPDATE state. In
+ this state, the POP3 server releases any resources acquired during
+ the TRANSACTION state and says goodbye. The TCP connection is then
+ closed.
+
+The AUTHORIZATION State
+
+ Once the TCP connection has been opened by a POP3 client, the POP3
+ server issues a one line greeting. This can be any string terminated
+ by CRLF. An example might be:
+
+ S. +OK dewey POP3 server ready (Comments to: PostMaster@UDEL.EDU)
+
+ Note that this greeting is a POP3 reply. The POP3 server should
+ always give a positive response as the greeting.
+
+ The POP3 session is now in the AUTHORIZATION state. The client must
+ now issue the USER command. If the POP3 server responds with a
+ positive success indicator ("+OK"), then the client may issue either
+ the PASS command to complete the authorization, or the QUIT command
+ to terminate the POP3 session. If the POP3 server responds with a
+ negative success indicator ("-ERR") to the USER command, then the
+ client may either issue a new USER command or may issue the QUIT
+ command.
+
+ When the client issues the PASS command, the POP3 server uses the
+ argument pair from the USER and PASS commands to determine if the
+ client should be given access to the appropriate maildrop. If so,
+ the POP3 server then acquires an exclusive-access lock on the
+ maildrop. If the lock is successfully acquired, the POP3 server
+ parses the maildrop into individual messages (read note below),
+ determines the last message (if any) present in the maildrop that was
+ referenced by the RETR command, and responds with a positive success
+ indicator. The POP3 session now enters the TRANSACTION state. If
+ the lock can not be acquired or the client should is denied access to
+ the appropriate maildrop or the maildrop can't be parsed for some
+
+
+
+Rose [Page 3]
+
+RFC 1081 POP3 November 1988
+
+
+ reason, the POP3 server responds with a negative success indicator.
+ (If a lock was acquired but the POP3 server intends to respond with a
+ negative success indicator, the POP3 server must release the lock
+ prior to rejecting the command.) At this point, the client may
+ either issue a new USER command and start again, or the client may
+ issue the QUIT command.
+
+ NOTE: Minimal implementations of the POP3 need only be
+ able to break a maildrop into its component messages;
+ they need NOT be able to parse individual messages.
+ More advanced implementations may wish to have this
+ capability, for reasons discussed later.
+
+ After the POP3 server has parsed the maildrop into individual
+ messages, it assigns a message-id to each message, and notes the size
+ of the message in octets. The first message in the maildrop is
+ assigned a message-id of "1", the second is assigned "2", and so on,
+ so that the n'th message in a maildrop is assigned a message-id of
+ "n". In POP3 commands and responses, all message-id's and message
+ sizes are expressed in base-10 (i.e., decimal).
+
+ It sets the "highest number accessed" to be that of the last message
+ referenced by the RETR command.
+
+ Here are summaries for the three POP3 commands discussed thus far:
+
+ USER name
+ Arguments: a server specific user-id (required)
+ Restrictions: may only be given in the AUTHORIZATION
+ state after the POP3 greeting or after an
+ unsuccessful USER or PASS command
+ Possible Responses:
+ +OK name is welcome here
+ -ERR never heard of name
+ Examples:
+ C: USER mrose
+ S: +OK mrose is a real hoopy frood
+ ...
+ C: USER frated
+ S: -ERR sorry, frated doesn't get his mail here
+
+ PASS string
+ Arguments: a server/user-id specific password (required)
+ Restrictions: may only be given in the AUTHORIZATION
+ state after a successful USER command
+ Possible Responses:
+ +OK maildrop locked and ready
+ -ERR invalid password
+
+
+
+Rose [Page 4]
+
+RFC 1081 POP3 November 1988
+
+
+ -ERR unable to lock maildrop
+ Examples:
+ C: USER mrose
+ S: +OK mrose is a real hoopy frood
+ C: PASS secret
+ S: +OK mrose's maildrop has 2 messages
+ (320 octets)
+ ...
+ C: USER mrose
+ S: +OK mrose is a real hoopy frood
+ C: PASS secret
+ S: -ERR unable to lock mrose's maildrop, file
+ already locked
+
+ QUIT
+ Arguments: none
+ Restrictions: none
+ Possible Responses:
+ +OK
+ Examples:
+ C: QUIT
+ S: +OK dewey POP3 server signing off
+
+
+The TRANSACTION State
+
+ Once the client has successfully identified itself to the POP3 server
+ and the POP3 server has locked and burst the appropriate maildrop,
+ the POP3 session is now in the TRANSACTION state. The client may now
+ issue any of the following POP3 commands repeatedly. After each
+ command, the POP3 server issues a response. Eventually, the client
+ issues the QUIT command and the POP3 session enters the UPDATE state.
+
+ Here are the POP3 commands valid in the TRANSACTION state:
+
+ STAT
+ Arguments: none
+ Restrictions: may only be given in the TRANSACTION state.
+ Discussion:
+
+ The POP3 server issues a positive response with a line
+ containing information for the maildrop. This line is
+ called a "drop listing" for that maildrop.
+
+ In order to simplify parsing, all POP3 servers are
+ required to use a certain format for drop listings.
+ The first octets present must indicate the number of
+ messages in the maildrop. Following this is the size
+
+
+
+Rose [Page 5]
+
+RFC 1081 POP3 November 1988
+
+
+ of the maildrop in octets. This memo makes no
+ requirement on what follows the maildrop size.
+ Minimal implementations should just end that line of
+ the response with a CRLF pair. More advanced
+ implementations may include other information.
+
+ NOTE: This memo STRONGLY discourages
+ implementations from supplying additional
+ information in the drop listing. Other,
+ optional, facilities are discussed later on
+ which permit the client to parse the messages
+ in the maildrop.
+
+ Note that messages marked as deleted are not counted in
+ either total.
+
+ Possible Responses:
+ +OK nn mm
+ Examples:
+ C: STAT
+ S: +OK 2 320
+
+ LIST [msg]
+ Arguments: a message-id (optionally) If a message-id is
+ given, it may NOT refer to a message marked as
+ deleted.
+ Restrictions: may only be given in the TRANSACTION state.
+ Discussion:
+
+ If an argument was given and the POP3 server issues a
+ positive response with a line containing information
+ for that message. This line is called a "scan listing"
+ for that message.
+
+ If no argument was given and the POP3 server issues a
+ positive response, then the response given is
+ multi-line. After the initial +OK, for each message
+ in the maildrop, the POP3 server responds with a line
+ containing information for that message. This line
+ is called a "scan listing" for that message.
+
+ In order to simplify parsing, all POP3 servers are
+ required to use a certain format for scan listings.
+ The first octets present must be the message-id of
+ the message. Following the message-id is the size of
+ the message in octets. This memo makes no requirement
+ on what follows the message size in the scan listing.
+ Minimal implementations should just end that line of
+
+
+
+Rose [Page 6]
+
+RFC 1081 POP3 November 1988
+
+
+ the response with a CRLF pair. More advanced
+ implementations may include other information, as
+ parsed from the message.
+
+ NOTE: This memo STRONGLY discourages
+ implementations from supplying additional
+ information in the scan listing. Other, optional,
+ facilities are discussed later on which permit
+ the client to parse the messages in the maildrop.
+
+ Note that messages marked as deleted are not listed.
+
+ Possible Responses:
+ +OK scan listing follows
+ -ERR no such message
+ Examples:
+ C: LIST
+ S: +OK 2 messages (320 octets)
+ S: 1 120
+ S: 2 200
+ S: .
+ ...
+ C: LIST 2
+ S: +OK 2 200
+ ...
+ C: LIST 3
+ S: -ERR no such message, only 2 messages in
+ maildrop
+
+ RETR msg
+ Arguments: a message-id (required) This message-id may
+ NOT refer to a message marked as deleted.
+ Restrictions: may only be given in the TRANSACTION state.
+ Discussion:
+
+ If the POP3 server issues a positive response, then the
+ response given is multi-line. After the initial +OK,
+ the POP3 server sends the message corresponding to the
+ given message-id, being careful to byte-stuff the
+ termination character (as with all multi-line
+ responses).
+
+ If the number associated with this message is higher
+ than the "highest number accessed" in the maildrop, the
+ POP3 server updates the "highest number accessed" to
+ the number associated with this message.
+
+
+
+
+
+Rose [Page 7]
+
+RFC 1081 POP3 November 1988
+
+
+ Possible Responses:
+ +OK message follows
+ -ERR no such message
+ Examples:
+ C: RETR 1
+ S: +OK 120 octets
+ S: <the POP3 server sends the entire message here>
+ S: .
+
+ DELE msg
+ Arguments: a message-id (required) This message-id
+ may NOT refer to a message marked as deleted.
+ Restrictions: may only be given in the TRANSACTION state.
+ Discussion:
+
+ The POP3 server marks the message as deleted. Any
+ future reference to the message-id associated with the
+ message in a POP3 command generates an error. The POP3
+ server does not actually delete the message until the
+ POP3 session enters the UPDATE state.
+
+ If the number associated with this message is higher
+ than the "highest number accessed" in the maildrop,
+ the POP3 server updates the "highest number accessed"
+ to the number associated with this message.
+
+ Possible Responses:
+ +OK message deleted
+ -ERR no such message
+ Examples:
+ C: DELE 1
+ S: +OK message 1 deleted
+ ...
+ C: DELE 2
+ S: -ERR message 2 already deleted
+
+ NOOP
+ Arguments: none
+ Restrictions: may only be given in the TRANSACTION state.
+ Discussion:
+
+ The POP3 server does nothing, it merely replies with a
+ positive response.
+
+ Possible Responses:
+ +OK
+
+
+
+
+
+Rose [Page 8]
+
+RFC 1081 POP3 November 1988
+
+
+ Examples:
+ C: NOOP
+ S: +OK
+
+ LAST
+ Arguments: none
+ Restrictions: may only be issued in the TRANSACTION state.
+ Discussion:
+
+ The POP3 server issues a positive response with a line
+ containing the highest message number which accessed.
+ Zero is returned in case no message in the maildrop has
+ been accessed during previous transactions. A client
+ may thereafter infer that messages, if any, numbered
+ greater than the response to the LAST command are
+ messages not yet accessed by the client.
+
+ Possible Response:
+ +OK nn
+
+ Examples:
+ C: STAT
+ S: +OK 4 320
+ C: LAST
+ S: +OK 1
+ C: RETR 3
+ S: +OK 120 octets
+ S: <the POP3 server sends the entire message
+ here>
+ S: .
+ C: LAST
+ S: +OK 3
+ C: DELE 2
+ S: +OK message 2 deleted
+ C: LAST
+ S: +OK 3
+ C: RSET
+ S: +OK
+ C: LAST
+ S: +OK 1
+
+ RSET
+ Arguments: none
+ Restrictions: may only be given in the TRANSACTION
+ state.
+ Discussion:
+
+ If any messages have been marked as deleted by the POP3
+
+
+
+Rose [Page 9]
+
+RFC 1081 POP3 November 1988
+
+
+ server, they are unmarked. The POP3 server then
+ replies with a positive response. In addition, the
+ "highest number accessed" is also reset to the value
+ determined at the beginning of the POP3 session.
+
+ Possible Responses:
+ +OK
+ Examples:
+ C: RSET
+ S: +OK maildrop has 2 messages (320 octets)
+
+
+
+The UPDATE State
+
+ When the client issues the QUIT command from the TRANSACTION state,
+ the POP3 session enters the UPDATE state. (Note that if the client
+ issues the QUIT command from the AUTHORIZATION state, the POP3
+ session terminates but does NOT enter the UPDATE state.)
+
+ QUIT
+ Arguments: none
+ Restrictions: none
+ Discussion:
+
+ The POP3 server removes all messages marked as deleted
+ from the maildrop. It then releases the
+ exclusive-access lock on the maildrop and replies as
+ to the success of
+ these operations. The TCP connection is then closed.
+
+ Possible Responses:
+ +OK
+ Examples:
+ C: QUIT
+ S: +OK dewey POP3 server signing off (maildrop
+ empty)
+ ...
+ C: QUIT
+ S: +OK dewey POP3 server signing off (2 messages
+ left)
+ ...
+
+
+Optional POP3 Commands
+
+ The POP3 commands discussed above must be supported by all minimal
+ implementations of POP3 servers.
+
+
+
+Rose [Page 10]
+
+RFC 1081 POP3 November 1988
+
+
+ The optional POP3 commands described below permit a POP3 client
+ greater freedom in message handling, while preserving a simple POP3
+ server implementation.
+
+ NOTE: This memo STRONGLY encourages implementations to
+ support these commands in lieu of developing augmented
+ drop and scan listings. In short, the philosophy of
+ this memo is to put intelligence in the part of the
+ POP3 client and not the POP3 server.
+
+ TOP msg n
+ Arguments: a message-id (required) and a number. This
+ message-id may NOT refer to a message marked as
+ deleted.
+ Restrictions: may only be given in the TRANSACTION state.
+ Discussion:
+
+ If the POP3 server issues a positive response, then
+ the response given is multi-line. After the initial
+ +OK, the POP3 server sends the headers of the message,
+ the blank line separating the headers from the body,
+ and then the number of lines indicated message's body,
+ being careful to byte-stuff the termination character
+ (as with all multi-line responses).
+
+ Note that if the number of lines requested by the POP3
+ client is greater than than the number of lines in the
+ body, then the POP3 server sends the entire message.
+
+ Possible Responses:
+ +OK top of message follows
+ -ERR no such message
+ Examples:
+ C: TOP 10
+ S: +OK
+ S: <the POP3 server sends the headers of the
+ message, a blank line, and the first 10 lines
+ of the body of the message>
+ S: .
+ ...
+ C: TOP 100
+ S: -ERR no such message
+
+ RPOP user
+ Arguments: a client specific user-id (required)
+ Restrictions: may only be given in the AUTHORIZATION
+ state after a successful USER command; in addition,
+ may only be given if the client used a reserved
+
+
+
+Rose [Page 11]
+
+RFC 1081 POP3 November 1988
+
+
+ (privileged) TCP port to connect to the server.
+ Discussion:
+
+ The RPOP command may be used instead of the PASS
+ command to authenticate access to the maildrop. In
+ order for this command to be successful, the POP3
+ client must use a reserved TCP port (port < 1024) to
+ connect tothe server. The POP3 server uses the
+ argument pair from the USER and RPOP commands to
+ determine if the client should be given access to
+ the appropriate maildrop. Unlike the PASS command
+ however, the POP3 server considers if the remote user
+ specified by the RPOP command who resides on the POP3
+ client host is allowed to access the maildrop for the
+ user specified by the USER command (e.g., on Berkeley
+ UNIX, the .rhosts mechanism is used). With the
+ exception of this differing in authentication, this
+ command is identical to the PASS command.
+
+ Note that the use of this feature has allowed much wider
+ penetration into numerous hosts on local networks (and
+ sometimes remote networks) by those who gain illegal
+ access to computers by guessing passwords or otherwise
+ breaking into the system.
+
+ Possible Responses:
+ +OK maildrop locked and ready
+ -ERR permission denied
+ Examples:
+ C: USER mrose
+ S: +OK mrose is a real hoopy frood
+ C: RPOP mrose
+ S: +OK mrose's maildrop has 2 messages (320
+ octets)
+
+ Minimal POP3 Commands:
+ USER name valid in the AUTHORIZATION state
+ PASS string
+ QUIT
+
+ STAT valid in the TRANSACTION state
+ LIST [msg]
+ RETR msg
+ DELE msg
+ NOOP
+ LAST
+ RSET
+
+
+
+
+Rose [Page 12]
+
+RFC 1081 POP3 November 1988
+
+
+ QUIT valid in the UPDATE state
+
+ Optional POP3 Commands:
+ RPOP user valid in the AUTHORIZATION state
+
+ TOP msg n valid in the TRANSACTION state
+
+ POP3 Replies:
+ +OK
+ -ERR
+
+ Note that with the exception of the STAT command, the reply given
+ by the POP3 server to any command is significant only to "+OK"
+ and "-ERR". Any text occurring after this reply may be ignored
+ by the client.
+
+Example POP3 Session
+
+ S: <wait for connection on TCP port 110>
+ ...
+ C: <open connection>
+ S: +OK dewey POP3 server ready (Comments to: PostMaster@UDEL.EDU)
+ C: USER mrose
+ S: +OK mrose is a real hoopy frood
+ C: PASS secret
+ S: +OK mrose's maildrop has 2 messages (320 octets)
+ C: STAT
+ S: +OK 2 320
+ C: LIST
+ S: +OK 2 messages (320 octets)
+ S: 1 120
+ S: 2 200
+ S: .
+ C: RETR 1
+ S: +OK 120 octets
+ S: <the POP3 server sends message 1>
+ S: .
+ C: DELE 1
+ S: +OK message 1 deleted
+ C: RETR 2
+ S: +OK 200 octets
+ S: <the POP3 server sends message 2>
+ S: .
+ C: DELE 2
+ S: +OK message 2 deleted
+ C: QUIT
+
+
+
+
+
+Rose [Page 13]
+
+RFC 1081 POP3 November 1988
+
+
+ S: +OK dewey POP3 server signing off (maildrop empty)
+ C: <close connection>
+ S: <wait for next connection>
+
+Message Format
+
+ All messages transmitted during a POP3 session are assumed to conform
+ to the standard for the format of Internet text messages [RFC822].
+
+ It is important to note that the byte count for a message on the
+ server host may differ from the octet count assigned to that message
+ due to local conventions for designating end-of-line. Usually,
+ during the AUTHORIZATION state of the POP3 session, the POP3 client
+ can calculate the size of each message in octets when it parses the
+ maildrop into messages. For example, if the POP3 server host
+ internally represents end-of-line as a single character, then the
+ POP3 server simply counts each occurrence of this character in a
+ message as two octets. Note that lines in the message which start
+ with the termination octet need not be counted twice, since the POP3
+ client will remove all byte-stuffed termination characters when it
+ receives a multi-line response.
+
+The POP and the Split-UA model
+
+ The underlying paradigm in which the POP3 functions is that of a
+ split-UA model. The POP3 client host, being a remote PC based
+ workstation, acts solely as a client to the message transport system.
+ It does not provide delivery/authentication services to others.
+ Hence, it is acting as a UA, on behalf of the person using the
+ workstation. Furthermore, the workstation uses SMTP to enter mail
+ into the MTS.
+
+ In this sense, we have two UA functions which interface to the
+ message transport system: Posting (SMTP) and Retrieval (POP3). The
+ entity which supports this type of environment is called a split-UA
+ (since the user agent is split between two hosts which must
+ interoperate to provide these functions).
+
+ ASIDE: Others might term this a remote-UA instead.
+ There are arguments supporting the use of both terms.
+
+ This memo has explicitly referenced TCP as the underlying transport
+ agent for the POP3. This need not be the case. In the MZnet split-
+ UA, for example, personal micro-computer systems are used which do
+ not have IP-style networking capability. To connect to the POP3
+ server host, a PC establishes a terminal connection using some simple
+ protocol (PhoneNet). A program on the PC drives the connection,
+ first establishing a login session as a normal user. The login shell
+
+
+
+Rose [Page 14]
+
+RFC 1081 POP3 November 1988
+
+
+ for this pseudo-user is a program which drives the other half of the
+ terminal protocol and communicates with one of two servers. Although
+ MZnet can support several PCs, a single pseudo-user login is present
+ on the server host. The user-id and password for this pseudo-user
+ login is known to all members of MZnet. Hence, the first action of
+ the login shell, after starting the terminal protocol, is to demand a
+ USER/PASS authorization pair from the PC. This second level of
+ authorization is used to ascertain who is interacting with the MTS.
+ Although the server host is deemed to support a "trusted" MTS entity,
+ PCs in MZnet are not. Naturally, the USER/PASS authorization pair
+ for a PC is known only to the owner of the PC (in theory, at least).
+
+ After successfully verifying the identity of the client, a modified
+ SMTP server is started, and the PC posts mail with the server host.
+ After the QUIT command is given to the SMTP server and it terminates,
+ a modified POP3 server is started, and the PC retrieves mail from the
+ server host. After the QUIT command is given to the POP3 server and
+ it terminates, the login shell for the pseudo-user terminates the
+ terminal protocol and logs the job out. The PC then closes the
+ terminal connection to the server host.
+
+ The SMTP server used by MZnet is modified in the sense that it knows
+ that it's talking to a user agent and not a "trusted" entity in the
+ message transport system. Hence, it does performs the validation
+ activities normally performed by an entity in the MTS when it accepts
+ a message from a UA.
+
+ The POP3 server used by MZnet is modified in the sense that it does
+ not require a USER/PASS combination before entering the TRANSACTION
+ state. The reason for this (of course) is that the PC has already
+ identified itself during the second-level authorization step
+ described above.
+
+ NOTE: Truth in advertising laws require that the author
+ of this memo state that MZnet has not actually been
+ fully implemented. The concepts presented and proven
+ by the project led to the notion of the MZnet
+ split-slot model. This notion has inspired the
+ split-UA concept described in this memo, led to the
+ author's interest in the POP, and heavily influenced
+ the the description of the POP3 herein.
+
+ In fact, some UAs present in the Internet already support the notion
+ of posting directly to an SMTP server and retrieving mail directly
+ from a POP server, even if the POP server and client resided on the
+ same host!
+
+ ASIDE: this discussion raises an issue which this memo
+
+
+
+Rose [Page 15]
+
+RFC 1081 POP3 November 1988
+
+
+ purposedly avoids: how does SMTP know that it's talking
+ to a "trusted" MTS entity?
+
+References
+
+ [MZnet] Stefferud, E., J. Sweet, and T. Domae, "MZnet: Mail
+ Service for Personal Micro-Computer Systems",
+ Proceedings, IFIP 6.5 International Conference on
+ Computer Message Systems, Nottingham, U.K., May 1984.
+
+ [RFC821] Postel, J., "Simple Mail Transfer Protocol",
+ USC/Information Sciences Institute, August 1982.
+
+ [RFC822] Crocker, D., "Standard for the Format of ARPA-Internet
+ Text Messages", University of Delaware, August 1982.
+
+ [RFC937] Butler, M., J. Postel, D. Chase, J. Goldberger, and J.
+ Reynolds, "Post Office Protocol - Version 2", RFC 937,
+ USC/Information Sciences Institute, February 1985.
+
+ [RFC1010] Reynolds, J., and J. Postel, "Assigned Numbers", RFC
+ 1010, USC/Information Sciences Institute, May 1987.
+
+Author's Address:
+
+
+ Marshall Rose
+ The Wollongong Group
+ 1129 San Antonio Rd.
+ Palo Alto, California 94303
+
+ Phone: (415) 962-7100
+
+ Email: MRose@TWG.COM
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Rose [Page 16]
diff --git a/crypto/heimdal/appl/popper/pop3e.rfc1082 b/crypto/heimdal/appl/popper/pop3e.rfc1082
new file mode 100644
index 0000000..ac49448
--- /dev/null
+++ b/crypto/heimdal/appl/popper/pop3e.rfc1082
@@ -0,0 +1,619 @@
+
+
+
+
+
+
+Network Working Group M. Rose
+Request for Comments: 1082 TWG
+ November 1988
+
+
+
+ Post Office Protocol - Version 3
+ Extended Service Offerings
+
+Status of This Memo
+
+ This memo suggests a simple method for workstations to dynamically
+ access mail from a discussion group server, as an extension to an
+ earlier memo which dealt with dynamically accessing mail from a
+ mailbox server using the Post Office Protocol - Version 3 (POP3).
+ This RFC specifies a proposed protocol for the Internet community,
+ and requests discussion and suggestions for improvements. All of the
+ extensions described in this memo to the POP3 are OPTIONAL.
+ Distribution of this memo is unlimited.
+
+Introduction and Motivation
+
+ It is assumed that the reader is familiar with RFC 1081 that
+ discusses the Post Office Protocol - Version 3 (POP3) [RFC1081].
+ This memo describes extensions to the POP3 which enhance the service
+ it offers to clients. This additional service permits a client host
+ to access discussion group mail, which is often kept in a separate
+ spool area, using the general POP3 facilities.
+
+ The next section describes the evolution of discussion groups and the
+ technologies currently used to implement them. To summarize:
+
+ o An exploder is used to map from a single address to
+ a list of addresses which subscribe to the list, and redirects
+ any subsequent error reports associated with the delivery of
+ each message. This has two primary advantages:
+ - Subscribers need know only a single address
+ - Responsible parties get the error reports and not
+ the subscribers
+
+
+
+
+
+
+
+
+
+
+
+
+Rose [Page 1]
+
+RFC 1082 POP3 Extended Service November 1988
+
+
+ o Typically, each subscription address is not a person's private
+ maildrop, but a system-wide maildrop, which can be accessed
+ by more than one user. This has several advantages:
+ - Only a single copy of each message need traverse the
+ net for a given site (which may contain several local
+ hosts). This conserves bandwidth and cycles.
+ - Only a single copy of each message need reside on each
+ subscribing host. This conserves disk space.
+ - The private maildrop for each user is not cluttered
+ with discussion group mail.
+
+ Despite this optimization of resources, further economy can be
+ achieved at sites with more than one host. Typically, sites with
+ more than one host either:
+
+ 1. Replicate discussion group mail on each host. This
+ results in literally gigabytes of disk space committed to
+ unnecessarily store redundant information.
+
+ 2. Keep discussion group mail on one host and give all users a
+ login on that host (in addition to any other logins they may
+ have). This is usually a gross inconvenience for users who
+ work on other hosts, or a burden to users who are forced to
+ work on that host.
+
+ As discussed in [RFC1081], the problem of giving workstations dynamic
+ access to mail from a mailbox server has been explored in great
+ detail (originally there was [RFC918], this prompted the author to
+ write [RFC1081], independently of this [RFC918] was upgraded to
+ [RFC937]). A natural solution to the problem outlined above is to
+ keep discussion group mail on a mailbox server at each site and
+ permit different hosts at that site to employ the POP3 to access
+ discussion group mail. If implemented properly, this avoids the
+ problems of both strategies outlined above.
+
+ ASIDE: It might be noted that a good distributed filesystem
+ could also solve this problem. Sadly, "good"
+ distributed filesystems, which do not suffer
+ unacceptable response time for interactive use, are
+ few and far between these days!
+
+ Given this motivation, now let's consider discussion groups, both in
+ general and from the point of view of a user agent. Following this,
+ extensions to the POP3 defined in [RFC1081] are presented. Finally,
+ some additional policy details are discussed along with some initial
+ experiences.
+
+
+
+
+
+Rose [Page 2]
+
+RFC 1082 POP3 Extended Service November 1988
+
+
+What's in a Discussion Group
+
+ Since mailers and user agents first crawled out of the primordial
+ ARPAnet, the value of discussion groups have been appreciated,
+ (though their implementation has not always been well-understood).
+
+ Described simply, a discussion group is composed of a number of
+ subscribers with a common interest. These subscribers post mail to a
+ single address, known as a distribution address. From this
+ distribution address, a copy of the message is sent to each
+ subscriber. Each group has a moderator, which is the person that
+ administrates the group. The moderator can usually be reached at a
+ special address, known as a request address. Usually, the
+ responsibilities of the moderator are quite simple, since the mail
+ system handles the distribution to subscribers automatically. In
+ some cases, the interest group, instead of being distributed directly
+ to its subscribers, is put into a digest format by the moderator and
+ then sent to the subscribers. Although this requires more work on
+ the part of the moderator, such groups tend to be better organized.
+
+ Unfortunately, there are a few problems with the scheme outlined
+ above. First, if two users on the same host subscribe to the same
+ interest group, two copies of the message get delivered. This is
+ wasteful of both processor and disk resources.
+
+ Second, some of these groups carry a lot of traffic. Although
+ subscription to an group does indicate interest on the part of a
+ subscriber, it is usually not interesting to get 50 messages or so
+ delivered to the user's private maildrop each day, interspersed with
+ personal mail, that is likely to be of a much more important and
+ timely nature.
+
+ Third, if a subscriber on the distribution list for a group becomes
+ "bad" somehow, the originator of the message and not the moderator of
+ the group is notified. It is not uncommon for a large list to have
+ 10 or so bogus addresses present. This results in the originator
+ being flooded with "error messages" from mailers across the Internet
+ stating that a given address on the list was bad. Needless to say,
+ the originator usually could not care less if the bogus addresses got
+ a copy of the message or not. The originator is merely interested in
+ posting a message to the group at large. Furthermore, the moderator
+ of the group does care if there are bogus addresses on the list, but
+ ironically does not receive notification.
+
+ There are various approaches which can be used to solve some or all
+ of these problems. Usually these involve placing an exploder agent
+ at the distribution source of the discussion group, which expands the
+ name of the group into the list of subscription addresses for the
+
+
+
+Rose [Page 3]
+
+RFC 1082 POP3 Extended Service November 1988
+
+
+ group. In the process, the exploder will also change the address
+ that receives error notifications to be the request address or other
+ responsible party.
+
+ A complementary approach, used in order to cut down on resource
+ utilization of all kinds, replaces all the subscribers at a single
+ host (or group of hosts under a single administration) with a single
+ address at that host. This address maps to a file on the host,
+ usually in a spool area, which all users can access. (Advanced
+ implementations can also implement private discussion groups this
+ way, in which a single copy of each message is kept, but is
+ accessible to only a select number of users on the host.)
+
+ The two approaches can be combined to avoid all of the problems
+ described above.
+
+ Finally, a third approach can be taken, which can be used to aid user
+ agents processing mail for the discussion group: In order to speed
+ querying of the maildrop which contains the local host's copy of the
+ discussion group, two other items are usually associated with the
+ discussion group, on a local basis. These are the maxima and the
+ last-date. Each time a message is received for the group on the
+ local host, the maxima is increased by at least one. Furthermore,
+ when a new maxima is generated, the current date is determined. This
+ is called the last date. As the message is entered into the local
+ maildrop, it is given the current maxima and last-date. This permits
+ the user agent to quickly determine if new messages are present in
+ the maildrop.
+
+ NOTE: The maxima may be characterized as a monotonically
+ increasing quanity. Although sucessive values of the
+ maxima need not be consecutive, any maxima assigned
+ is always greater than any previously assigned value.
+
+Definition of Terms
+
+ To formalize these notions somewhat, consider the following 7
+ parameters which describe a given discussion group from the
+ perspective of the user agent (the syntax given is from [RFC822]):
+
+
+
+
+
+
+
+
+
+
+
+
+Rose [Page 4]
+
+RFC 1082 POP3 Extended Service November 1988
+
+
+ NAME Meaning: the name of the discussion group
+ Syntax: TOKEN (ALPHA *[ ALPHA / DIGIT / "-" ])
+ (case-insensitive recognition)
+ Example: unix-wizards
+
+ ALIASES Meaning: alternates names for the group, which
+ are locally meaningful; these are
+ typically used to shorten user typein
+ Syntax: TOKEN (case-insensitive recognition)
+ Example: uwiz
+
+ ADDRESS Meaning: the primary source of the group
+ Syntax: 822 address
+ Example: Unix-Wizards@BRL.MIL
+
+ REQUEST Meaning: the primary moderator of the group
+ Syntax: 822 address
+ Example: Unix-Wizards-Request@BRL.MIL
+
+ FLAGS Meaning: locally meaningful flags associated
+ with the discussion group; this memo
+ leaves interpretation of this
+ parameter to each POP3 implementation
+ Syntax: octal number
+ Example: 01
+
+ MAXIMA Meaning: the magic cookie associated with the
+ last message locally received for the
+ group; it is the property of the magic
+ cookie that it's value NEVER
+ decreases, and increases by at least
+ one each time a message is locally
+ received
+ Syntax: decimal number
+ Example: 1004
+
+ LASTDATE Meaning: the date that the last message was
+ locally received
+ Syntax: 822 date
+ Example: Thu, 19 Dec 85 10:26:48 -0800
+
+ Note that the last two values are locally determined for the maildrop
+ associated with the discussion group and with each message in that
+ maildrop. Note however that the last message in the maildrop have a
+ different MAXIMA and LASTDATE than the discussion group. This often
+ occurs when the maildrop has been archived.
+
+
+
+
+
+Rose [Page 5]
+
+RFC 1082 POP3 Extended Service November 1988
+
+
+ Finally, some local systems provide mechanisms for automatically
+ archiving discussion group mail. In some cases, a two-level archive
+ scheme is used: current mail is kept in the standard maildrop,
+ recent mail is kept in an archive maildrop, and older mail is kept
+ off-line. With this scheme, in addition to having a "standard"
+ maildrop for each discussion group, an "archive" maildrop may also be
+ available. This permits a user agent to examine the most recent
+ archive using the same mechanisms as those used on the current mail.
+
+The XTND Command
+
+ The following commands are valid only in the TRANSACTION state of the
+ POP3. This implies that the POP3 server has already opened the
+ user's maildrop (which may be empty). This maildrop is called the
+ "default maildrop". The phrase "closes the current maildrop" has two
+ meanings, depending on whether the current maildrop is the default
+ maildrop or is a maildrop associated with a discussion group.
+
+ In the former context, when the current maildrop is closed any
+ messages marked as deleted are removed from the maildrop currently in
+ use. The exclusive-access lock on the maildrop is then released
+ along with any implementation-specific resources (e.g., file-
+ descriptors).
+
+ In the latter context, a maildrop associated with a discussion group
+ is considered to be read-only to the POP3 client. In this case, the
+ phrase "closes the current maildrop" merely means that any
+ implementation-specific resources are released. (Hence, the POP3
+ command DELE is a no-op.)
+
+ All the new facilities are introduced via a single POP3 command,
+ XTND. All positive reponses to the XTND command are multi-line.
+
+ The most common multi-line response to the commands contains a
+ "discussion group listing" which presents the name of the discussion
+ group along with it's maxima. In order to simplify parsing all POP3
+ servers are required to use a certain format for discussion group
+ listings:
+
+ NAME SP MAXIMA
+
+ This memo makes no requirement on what follows the maxima in the
+ listing. Minimal implementations should just end that line of the
+ response with a CRLF pair. More advanced implementations may include
+ other information, as parsed from the message.
+
+ NOTE: This memo STRONGLY discourages implementations from
+ supplying additional information in the listing.
+
+
+
+Rose [Page 6]
+
+RFC 1082 POP3 Extended Service November 1988
+
+
+ XTND BBOARDS [name]
+ Arguments: the name of a discussion group (optionally)
+ Restrictions: may only be given in the TRANSACTION state.
+ Discussion:
+
+ If an argument was given, the POP3 server closes the current
+ maildrop. The POP3 server then validates the argument as the name of
+ a discussion group. If this is successful, it opens the maildrop
+ associated with the group, and returns a multi-line response
+ containing the discussion group listing. If the discussion group
+ named is not valid, or the associated archive maildrop is not
+ readable by the user, then an error response is returned.
+
+ If no argument was given, the POP3 server issues a multi-line
+ response. After the initial +OK, for each discussion group known,
+ the POP3 server responds with a line containing the listing for that
+ discussion group. Note that only world-readable discussion groups
+ are included in the multi-line response.
+
+ In order to aid user agents, this memo requires an extension to the
+ scan listing when an "XTND BBOARDS" command has been given.
+ Normally, a scan listing, as generated by the LIST, takes the form:
+
+ MSGNO SIZE
+
+ where MSGNO is the number of the message being listed and SIZE is the
+ size of the message in octets. When reading a maildrop accessed via
+ "XTND BBOARDS", the scan listing takes the form
+
+ MSGNO SIZE MAXIMA
+
+ where MAXIMA is the maxima that was assigned to the message when it
+ was placed in the BBoard.
+
+ Possible Responses:
+ +OK XTND
+ -ERR no such bboard
+ Examples:
+ C: XTND BBOARDS
+ S: +OK XTND
+ S: system 10
+ S: mh-users 100
+ S: .
+ C: XTND BBOARDS system
+ S: + OK XTND
+ S: system 10
+ S: .
+
+
+
+
+Rose [Page 7]
+
+RFC 1082 POP3 Extended Service November 1988
+
+
+ XTND ARCHIVE name
+ Arguments: the name of a discussion group (required)
+ Restrictions: may only be given in the TRANSACTION state.
+ Discussion:
+
+ The POP3 server closes the current maildrop. The POP3 server then
+ validates the argument as the name of a discussion group. If this is
+ successful, it opens the archive maildrop associated with the group,
+ and returns a multi-line response containing the discussion group
+ listing. If the discussion group named is not valid, or the
+ associated archive maildrop is not readable by the user, then an
+ error response is returned.
+
+ In addition, the scan listing generated by the LIST command is
+ augmented (as described above).
+
+ Possible Responses:
+ +OK XTND
+ -ERR no such bboard Examples:
+ C: XTND ARCHIVE system
+ S: + OK XTND
+ S: system 3
+ S: .
+
+ XTND X-BBOARDS name
+ Arguments: the name of a discussion group (required)
+ Restrictions: may only be given in the TRANSACTION state.
+ Discussion:
+
+ The POP3 server validates the argument as the name of a
+ discussion group. If this is unsuccessful, then an error
+ response is returned. Otherwise a multi-line response is
+ returned. The first 14 lines of this response (after the
+ initial +OK) are defined in this memo. Minimal implementations
+ need not include other information (and may omit certain
+ information, outputing a bare CRLF pair). More advanced
+ implementations may include other information.
+
+ Line Information (refer to "Definition of Terms")
+ ---- -----------
+ 1 NAME
+ 2 ALIASES, separated by SP
+ 3 system-specific: maildrop
+ 4 system-specific: archive maildrop
+ 5 system-specific: information
+ 6 system-specific: maildrop map
+ 7 system-specific: encrypted password
+ 8 system-specific: local leaders, separated by SP
+
+
+
+Rose [Page 8]
+
+RFC 1082 POP3 Extended Service November 1988
+
+
+ 9 ADDRESS
+ 10 REQUEST
+ 11 system-specific: incoming feed
+ 12 system-specific: outgoing feeds
+ 13 FLAGS SP MAXIMA
+ 14 LASTDATE
+
+ Most of this information is entirely too specific to the UCI Version
+ of the Rand MH Message Handling System [MRose85]. Nevertheless,
+ lines 1, 2, 9, 10, 13, and 14 are of general interest, regardless of
+ the implementation.
+
+ Possible Responses:
+ +OK XTND
+ -ERR no such bboard
+ Examples:
+ C: XTND X-BBOARDS system
+ S: + OK XTND
+ S: system
+ S: local general
+ S: /usr/bboards/system.mbox
+ S: /usr/bboards/archive/system.mbox
+ S: /usr/bboards/.system.cnt
+ S: /usr/bboards/.system.map
+ S: *
+ S: mother
+ S: system@nrtc.northrop.com
+ S: system-request@nrtc.northrop.com
+ S:
+ S: dist-system@nrtc-gremlin.northrop.com
+ S: 01 10
+ S: Thu, 19 Dec 85 00:08:49 -0800
+ S: .
+
+Policy Notes
+
+ Depending on the particular entity administrating the POP3 service
+ host, two additional policies might be implemented:
+
+ 1. Private Discussion Groups
+
+ In the general case, discussion groups are world-readable, any user,
+ once logged in (via a terminal, terminal server, or POP3, etc.), is
+ able to read the maildrop for each discussion group known to the POP3
+ service host. Nevertheless, it is desirable, usually for privacy
+ reasons, to implement private discussion groups as well.
+
+ Support of this is consistent with the extensions outlined in this
+
+
+
+Rose [Page 9]
+
+RFC 1082 POP3 Extended Service November 1988
+
+
+ memo. Once the AUTHORIZATION state has successfully concluded, the
+ POP3 server grants the user access to exactly those discussion groups
+ the POP3 service host permits the authenticated user to access. As a
+ "security" feature, discussion groups associated with unreadable
+ maildrops should not be listed in a positive response to the XTND
+ BBOARDS command.
+
+ 2. Anonymous POP3 Users
+
+ In order to minimize the authentication problem, a policy permitting
+ "anonymous" access to the world-readable maildrops for discussion
+ groups on the POP3 server may be implemented.
+
+ Support of this is consistent with the extensions outlined in this
+ memo. The POP3 server can be modified to accept a USER command for a
+ well-known pseudonym (i.e., "anonymous") which is valid with any PASS
+ command. As a "security" feature, it is advisable to limit this kind
+ of access to only hosts at the local site, or to hosts named in an
+ access list.
+
+Experiences and Conclusions
+
+ All of the facilities described in this memo and in [RFC1081] have
+ been implemented in MH #6.1. Initial experiences have been, on the
+ whole, very positive.
+
+ After the first implementation, some performance tuning was required.
+ This consisted primarily of caching the datastructures which describe
+ discussion groups in the POP3 server. A second optimization
+ pertained to the client: the program most commonly used to read
+ BBoards in MH was modified to retrieve messages only when needed.
+ Two schemes are used:
+
+ o If only the headers (and the first few lines of the body) of
+ the message are required (e.g., for a scan listing), then only
+ these are retrieved. The resulting output is then cached, on
+ a per-message basis.
+
+ o If the entire message is required, then it is retrieved intact,
+ and cached locally.
+
+ With these optimizations, response time is quite adequate when the
+ POP3 server and client are connected via a high-speed local area
+ network. In fact, the author uses this mechanism to access certain
+ private discussion groups over the Internet. In this case, response
+ is still good. When a 9.6Kbps modem is inserted in the path,
+ response went from good to almost tolerable (fortunately the author
+ only reads a few discussion groups in this fashion).
+
+
+
+Rose [Page 10]
+
+RFC 1082 POP3 Extended Service November 1988
+
+
+ To conclude: the POP3 is a good thing, not only for personal mail but
+ for discussion group mail as well.
+
+
+References
+
+ [RFC1081] Rose, M., "Post Office Protocol - Verison 3 (POP3)", RFC
+ 1081, TWG, November 1988.
+
+ [MRose85] Rose, M., and J. Romine, "The Rand MH Message Handling
+ System: User's Manual", University of California, Irvine,
+ November 1985.
+
+ [RFC822] Crocker, D., "Standard for the Format of ARPA-Internet
+ Text Messages", RFC 822, University of Delaware, August
+ 1982.
+
+ [RFC918] Reynolds, J., "Post Office Protocol", RFC 918,
+ USC/Information Sciences Institute, October 1984.
+
+ [RFC937] Butler, M., J. Postel, D. Chase, J. Goldberger, and J.
+ Reynolds, "Post Office Protocol - Version 2", RFC 937,
+ USC/Information Sciences Institute, February 1985.
+
+Author's Address:
+
+
+ Marshall Rose
+ The Wollongong Group
+ 1129 San Antonio Rd.
+ Palo Alto, California 94303
+
+ Phone: (415) 962-7100
+
+ Email: MRose@TWG.COM
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Rose [Page 11]
+
diff --git a/crypto/heimdal/appl/popper/pop_auth.c b/crypto/heimdal/appl/popper/pop_auth.c
new file mode 100644
index 0000000..525beaa
--- /dev/null
+++ b/crypto/heimdal/appl/popper/pop_auth.c
@@ -0,0 +1,220 @@
+/*
+ * Copyright (c) 1995, 1996, 1997 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. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the Kungliga Tekniska
+ * Högskolan and its contributors.
+ *
+ * 4. 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 <popper.h>
+#include <base64.h>
+RCSID("$Id: pop_auth.c,v 1.2 2000/04/12 15:37:45 assar Exp $");
+
+#ifdef KRB4
+
+enum {
+ NO_PROT = 1,
+ INT_PROT = 2,
+ PRIV_PROT = 4
+};
+
+static int
+auth_krb4(POP *p)
+{
+ int ret;
+ des_cblock key;
+ u_int32_t nonce, nonce_reply;
+ u_int32_t max_client_packet;
+ int protocols = NO_PROT | INT_PROT | PRIV_PROT;
+ char data[8];
+ int len;
+ char *s;
+ char instance[INST_SZ];
+ KTEXT_ST authent;
+ des_key_schedule schedule;
+ struct passwd *pw;
+
+ /* S -> C: 32 bit nonce in MSB base64 */
+
+ des_new_random_key(&key);
+ nonce = (key[0] | (key[1] << 8) | (key[2] << 16) | (key[3] << 24)
+ | key[4] | (key[5] << 8) | (key[6] << 16) | (key[7] << 24));
+ krb_put_int(nonce, data, 4, 8);
+ len = base64_encode(data, 4, &s);
+
+ pop_msg(p, POP_CONTINUE, "%s", s);
+ free(s);
+
+ /* C -> S: ticket and authenticator */
+
+ ret = sch_readline(p->input, &s);
+ if (ret <= 0 || strcmp (s, "*") == 0)
+ return pop_msg(p, POP_FAILURE,
+ "authentication aborted by client");
+ len = strlen(s);
+ if (len > sizeof(authent.dat)) {
+ return pop_msg(p, POP_FAILURE, "data packet too long");
+ }
+
+ authent.length = base64_decode(s, authent.dat);
+
+ k_getsockinst (0, instance, sizeof(instance));
+ ret = krb_rd_req(&authent, "pop", instance,
+ p->in_addr.sin_addr.s_addr,
+ &p->kdata, NULL);
+ if (ret != 0) {
+ return pop_msg(p, POP_FAILURE, "rd_req: %s",
+ krb_get_err_text(ret));
+ }
+ if (p->kdata.checksum != nonce) {
+ return pop_msg(p, POP_FAILURE, "data stream modified");
+ }
+
+ /* S -> C: nonce + 1 | bit | max segment */
+
+ krb_put_int(nonce + 1, data, 4, 7);
+ data[4] = protocols;
+ krb_put_int(1024, data + 5, 3, 3); /* XXX */
+ des_key_sched(&p->kdata.session, schedule);
+ des_pcbc_encrypt((des_cblock*)data,
+ (des_cblock*)data, 8,
+ schedule,
+ &p->kdata.session,
+ DES_ENCRYPT);
+ len = base64_encode(data, 8, &s);
+ pop_msg(p, POP_CONTINUE, "%s", s);
+
+ free(s);
+
+ /* C -> S: nonce | bit | max segment | username */
+
+ ret = sch_readline(p->input, &s);
+ if (ret <= 0 || strcmp (s, "*") == 0)
+ return pop_msg(p, POP_FAILURE,
+ "authentication aborted");
+ len = strlen(s);
+ if (len > sizeof(authent.dat)) {
+ return pop_msg(p, POP_FAILURE, "data packet too long");
+ }
+
+ authent.length = base64_decode(s, authent.dat);
+
+ if (authent.length % 8 != 0) {
+ return pop_msg(p, POP_FAILURE, "reply is not a multiple of 8 bytes");
+ }
+
+ des_key_sched(&p->kdata.session, schedule);
+ des_pcbc_encrypt((des_cblock*)authent.dat,
+ (des_cblock*)authent.dat,
+ authent.length,
+ schedule,
+ &p->kdata.session,
+ DES_DECRYPT);
+
+ krb_get_int(authent.dat, &nonce_reply, 4, 0);
+ if (nonce_reply != nonce) {
+ return pop_msg(p, POP_FAILURE, "data stream modified");
+ }
+ protocols &= authent.dat[4];
+ krb_get_int(authent.dat + 5, &max_client_packet, 3, 0);
+ if(authent.dat[authent.length - 1] != '\0') {
+ return pop_msg(p, POP_FAILURE, "bad format of username");
+ }
+ strncpy (p->user, authent.dat + 8, sizeof(p->user));
+ pw = k_getpwnam(p->user);
+ if (pw == NULL) {
+ return (pop_msg(p,POP_FAILURE,
+ "Password supplied for \"%s\" is incorrect.",
+ p->user));
+ }
+
+ if (kuserok(&p->kdata, p->user)) {
+ pop_log(p, POP_PRIORITY,
+ "%s: (%s.%s@%s) tried to retrieve mail for %s.",
+ p->client, p->kdata.pname, p->kdata.pinst,
+ p->kdata.prealm, p->user);
+ return(pop_msg(p,POP_FAILURE,
+ "Popping not authorized"));
+ }
+ pop_log(p, POP_INFO, "%s: %s.%s@%s -> %s",
+ p->ipaddr,
+ p->kdata.pname, p->kdata.pinst, p->kdata.prealm,
+ p->user);
+ ret = pop_login(p, pw);
+ if (protocols & PRIV_PROT)
+ ;
+ else if (protocols & INT_PROT)
+ ;
+ else
+ ;
+
+ return ret;
+}
+#endif /* KRB4 */
+
+#ifdef KRB5
+static int
+auth_gssapi(POP *p)
+{
+
+}
+#endif /* KRB5 */
+
+/*
+ * auth: RFC1734
+ */
+
+static struct {
+ const char *name;
+ int (*func)(POP *);
+} methods[] = {
+#ifdef KRB4
+ {"KERBEROS_V4", auth_krb4},
+#endif
+#ifdef KRB5
+ {"GSSAPI", auth_gssapi},
+#endif
+ {NULL, NULL}
+};
+
+int
+pop_auth (POP *p)
+{
+ int i;
+
+ for (i = 0; methods[i].name != NULL; ++i)
+ if (strcasecmp(p->pop_parm[1], methods[i].name) == 0)
+ return (*methods[i].func)(p);
+ return pop_msg(p, POP_FAILURE,
+ "Authentication method %s unknown", p->pop_parm[1]);
+}
diff --git a/crypto/heimdal/appl/popper/pop_debug.c b/crypto/heimdal/appl/popper/pop_debug.c
new file mode 100644
index 0000000..e400278
--- /dev/null
+++ b/crypto/heimdal/appl/popper/pop_debug.c
@@ -0,0 +1,280 @@
+/*
+ * Copyright (c) 1995 - 2000 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.
+ */
+
+/* Tiny program to help debug popper */
+
+#include "popper.h"
+RCSID("$Id: pop_debug.c,v 1.21 2001/02/20 01:44:47 assar Exp $");
+
+static void
+loop(int s)
+{
+ char cmd[1024];
+ char buf[1024];
+ fd_set fds;
+ while(1){
+ FD_ZERO(&fds);
+ FD_SET(0, &fds);
+ FD_SET(s, &fds);
+ if(select(s+1, &fds, 0, 0, 0) < 0)
+ err(1, "select");
+ if(FD_ISSET(0, &fds)){
+ fgets(cmd, sizeof(cmd), stdin);
+ cmd[strlen(cmd) - 1] = '\0';
+ strlcat (cmd, "\r\n", sizeof(cmd));
+ write(s, cmd, strlen(cmd));
+ }
+ if(FD_ISSET(s, &fds)){
+ int n = read(s, buf, sizeof(buf));
+ if(n == 0)
+ exit(0);
+ fwrite(buf, n, 1, stdout);
+ }
+ }
+}
+
+static int
+get_socket (const char *hostname, int port)
+{
+ int ret;
+ struct addrinfo *ai, *a;
+ struct addrinfo hints;
+ char portstr[NI_MAXSERV];
+
+ memset (&hints, 0, sizeof(hints));
+ hints.ai_socktype = SOCK_STREAM;
+ snprintf (portstr, sizeof(portstr), "%d", ntohs(port));
+ ret = getaddrinfo (hostname, portstr, &hints, &ai);
+ if (ret)
+ errx (1, "getaddrinfo %s: %s", hostname, gai_strerror (ret));
+
+ for (a = ai; a != NULL; a = a->ai_next) {
+ int s;
+
+ 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) {
+ close (s);
+ continue;
+ }
+ freeaddrinfo (ai);
+ return s;
+ }
+ err (1, "failed to connect to %s", hostname);
+}
+
+#ifdef KRB4
+static int
+doit_v4 (char *host, int port)
+{
+ KTEXT_ST ticket;
+ MSG_DAT msg_data;
+ CREDENTIALS cred;
+ des_key_schedule sched;
+ int ret;
+ int s = get_socket (host, port);
+
+ ret = krb_sendauth(0,
+ s,
+ &ticket,
+ "pop",
+ 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;
+ }
+ loop(s);
+ return 0;
+}
+#endif
+
+#ifdef KRB5
+static int
+doit_v5 (char *host, int port)
+{
+ krb5_error_code ret;
+ krb5_context context;
+ krb5_auth_context auth_context = NULL;
+ krb5_principal server;
+ int s = get_socket (host, port);
+
+ ret = krb5_init_context (&context);
+ if (ret)
+ errx (1, "krb5_init_context failed: %d", ret);
+
+ 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);
+ if (ret) {
+ warnx ("krb5_sendauth: %s",
+ krb5_get_err_text (context, ret));
+ return 1;
+ }
+ loop (s);
+ return 0;
+}
+#endif
+
+
+#ifdef KRB4
+static int use_v4 = -1;
+#endif
+static int use_v5 = -1;
+static char *port_str;
+static int do_version;
+static int do_help;
+
+struct getargs args[] = {
+#ifdef KRB4
+ { "krb4", '4', arg_flag, &use_v4, "Use Kerberos V4",
+ NULL },
+#endif
+ { "krb5", '5', arg_flag, &use_v5, "Use Kerberos V5",
+ NULL },
+ { "port", 'p', arg_string, &port_str, "Use this port",
+ "number-or-service" },
+ { "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,
+ "hostname");
+ exit (ret);
+}
+
+int
+main(int argc, char **argv)
+{
+ int port = 0;
+ int ret = 1;
+ int optind = 0;
+
+ setprogname(argv[0]);
+
+ if (getarg (args, sizeof(args) / sizeof(args[0]), argc, argv,
+ &optind))
+ usage (1);
+
+ argc -= optind;
+ argv += optind;
+
+ if (do_help)
+ usage (0);
+
+ if (do_version) {
+ print_version (NULL);
+ return 0;
+ }
+
+ if (argc < 1)
+ 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 (NULL, "kpop", "tcp", 1109);
+#elif defined(KRB4)
+ port = k_getportbyname ("kpop", "tcp", 1109);
+#else
+#error must define KRB4 or KRB5
+#endif
+ }
+
+#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
+
+#ifdef KRB5
+ if (ret && use_v5) {
+ ret = doit_v5 (argv[0], port);
+ }
+#endif
+#ifdef KRB4
+ if (ret && use_v4) {
+ ret = doit_v4 (argv[0], port);
+ }
+#endif
+ return ret;
+}
diff --git a/crypto/heimdal/appl/popper/pop_dele.c b/crypto/heimdal/appl/popper/pop_dele.c
new file mode 100644
index 0000000..f1c2952
--- /dev/null
+++ b/crypto/heimdal/appl/popper/pop_dele.c
@@ -0,0 +1,107 @@
+/*
+ * Copyright (c) 1989 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#include <popper.h>
+RCSID("$Id: pop_dele.c,v 1.10 1999/08/12 11:35:26 joda Exp $");
+
+/*
+ * dele: Delete a message from the POP maildrop
+ */
+int
+pop_dele (POP *p)
+{
+ MsgInfoList * mp; /* Pointer to message info list */
+ int msg_num;
+
+ /* Convert the message number parameter to an integer */
+ msg_num = atoi(p->pop_parm[1]);
+
+ /* Is requested message out of range? */
+ if ((msg_num < 1) || (msg_num > p->msg_count))
+ return (pop_msg (p,POP_FAILURE,"Message %d does not exist.",msg_num));
+
+ /* Get a pointer to the message in the message list */
+ mp = &(p->mlp[msg_num-1]);
+
+ /* Is the message already flagged for deletion? */
+ if (mp->flags & DEL_FLAG)
+ return (pop_msg (p,POP_FAILURE,"Message %d has already been deleted.",
+ msg_num));
+
+ /* Flag the message for deletion */
+ mp->flags |= DEL_FLAG;
+
+#ifdef DEBUG
+ if(p->debug)
+ pop_log(p, POP_DEBUG,
+ "Deleting message %u at offset %ld of length %ld\n",
+ mp->number, mp->offset, mp->length);
+#endif /* DEBUG */
+
+ /* Update the messages_deleted and bytes_deleted counters */
+ p->msgs_deleted++;
+ p->bytes_deleted += mp->length;
+
+ /* Update the last-message-accessed number if it is lower than
+ the deleted message */
+ if (p->last_msg < msg_num) p->last_msg = msg_num;
+
+ return (pop_msg (p,POP_SUCCESS,"Message %d has been deleted.",msg_num));
+}
+
+#ifdef XDELE
+/* delete a range of messages */
+int
+pop_xdele(POP *p)
+{
+ MsgInfoList * mp; /* Pointer to message info list */
+
+ int msg_min, msg_max;
+ int i;
+
+
+ msg_min = atoi(p->pop_parm[1]);
+ if(p->parm_count == 1)
+ msg_max = msg_min;
+ else
+ msg_max = atoi(p->pop_parm[2]);
+
+ if (msg_min < 1)
+ return (pop_msg (p,POP_FAILURE,"Message %d does not exist.",msg_min));
+ if(msg_max > p->msg_count)
+ return (pop_msg (p,POP_FAILURE,"Message %d does not exist.",msg_max));
+ for(i = msg_min; i <= msg_max; i++) {
+
+ /* Get a pointer to the message in the message list */
+ mp = &(p->mlp[i - 1]);
+
+ /* Is the message already flagged for deletion? */
+ if (mp->flags & DEL_FLAG)
+ continue; /* no point in returning error */
+ /* Flag the message for deletion */
+ mp->flags |= DEL_FLAG;
+
+#ifdef DEBUG
+ if(p->debug)
+ pop_log(p, POP_DEBUG,
+ "Deleting message %u at offset %ld of length %ld\n",
+ mp->number, mp->offset, mp->length);
+#endif /* DEBUG */
+
+ /* Update the messages_deleted and bytes_deleted counters */
+ p->msgs_deleted++;
+ p->bytes_deleted += mp->length;
+ }
+
+ /* Update the last-message-accessed number if it is lower than
+ the deleted message */
+ if (p->last_msg < msg_max) p->last_msg = msg_max;
+
+ return (pop_msg (p,POP_SUCCESS,"Messages %d-%d has been deleted.",
+ msg_min, msg_max));
+
+}
+#endif /* XDELE */
diff --git a/crypto/heimdal/appl/popper/pop_dropcopy.c b/crypto/heimdal/appl/popper/pop_dropcopy.c
new file mode 100644
index 0000000..f33cfb0
--- /dev/null
+++ b/crypto/heimdal/appl/popper/pop_dropcopy.c
@@ -0,0 +1,173 @@
+/*
+ * Copyright (c) 1989 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#include <popper.h>
+RCSID("$Id: pop_dropcopy.c,v 1.25 1999/09/16 20:38:49 assar Exp $");
+
+/*
+ * Run as the user in `pwd'
+ */
+
+int
+changeuser(POP *p, struct passwd *pwd)
+{
+ if(setgid(pwd->pw_gid) < 0) {
+ pop_log (p, POP_PRIORITY,
+ "Unable to change to gid %u: %s",
+ (unsigned)pwd->pw_gid,
+ strerror(errno));
+ return pop_msg (p, POP_FAILURE,
+ "Unable to change gid");
+ }
+ if(setuid(pwd->pw_uid) < 0) {
+ pop_log (p, POP_PRIORITY,
+ "Unable to change to uid %u: %s",
+ (unsigned)pwd->pw_uid,
+ strerror(errno));
+ return pop_msg (p, POP_FAILURE,
+ "Unable to change uid");
+ }
+#ifdef DEBUG
+ if(p->debug)
+ pop_log(p, POP_DEBUG,"uid = %u, gid = %u",
+ (unsigned)getuid(),
+ (unsigned)getgid());
+#endif /* DEBUG */
+ return POP_SUCCESS;
+}
+
+/*
+ * dropcopy: Make a temporary copy of the user's mail drop and
+ * save a stream pointer for it.
+ */
+
+int
+pop_dropcopy(POP *p, struct passwd *pwp)
+{
+ int mfd; /* File descriptor for
+ the user's maildrop */
+ int dfd; /* File descriptor for
+ the SERVER maildrop */
+ FILE *tf; /* The temp file */
+ char template[POP_TMPSIZE]; /* Temp name holder */
+ char buffer[BUFSIZ]; /* Read buffer */
+ long offset; /* Old/New boundary */
+ int nchar; /* Bytes written/read */
+ int tf_fd; /* fd for temp file */
+ int ret;
+
+ /* Create a temporary maildrop into which to copy the updated maildrop */
+ snprintf(p->temp_drop, sizeof(p->temp_drop), POP_DROP,p->user);
+
+#ifdef DEBUG
+ if(p->debug)
+ pop_log(p,POP_DEBUG,"Creating temporary maildrop '%s'",
+ p->temp_drop);
+#endif /* DEBUG */
+
+ /* Here we work to make sure the user doesn't cause us to remove or
+ * write over existing files by limiting how much work we do while
+ * running as root.
+ */
+
+ strlcpy(template, POP_TMPDROP, sizeof(template));
+ if ((tf_fd = mkstemp(template)) < 0 ||
+ (tf = fdopen(tf_fd, "w+")) == NULL) {
+ pop_log(p,POP_PRIORITY,
+ "Unable to create temporary temporary maildrop '%s': %s",template,
+ strerror(errno));
+ return pop_msg(p,POP_FAILURE,
+ "System error, can't create temporary file.");
+ }
+
+ /* Now give this file to the user */
+ chown(template, pwp->pw_uid, pwp->pw_gid);
+ chmod(template, 0600);
+
+ /* Now link this file to the temporary maildrop. If this fails it
+ * is probably because the temporary maildrop already exists. If so,
+ * this is ok. We can just go on our way, because by the time we try
+ * to write into the file we will be running as the user.
+ */
+ link(template,p->temp_drop);
+ fclose(tf);
+ unlink(template);
+
+ ret = changeuser(p, pwp);
+ if (ret != POP_SUCCESS)
+ return ret;
+
+ /* Open for append, this solves the crash recovery problem */
+ if ((dfd = open(p->temp_drop,O_RDWR|O_APPEND|O_CREAT,0600)) == -1){
+ pop_log(p,POP_PRIORITY,
+ "Unable to open temporary maildrop '%s': %s",p->temp_drop,
+ strerror(errno));
+ return pop_msg(p,POP_FAILURE,
+ "System error, can't open temporary file, do you own it?");
+ }
+
+ /* Lock the temporary maildrop */
+ if ( flock (dfd, (LOCK_EX | LOCK_NB)) == -1 )
+ switch(errno) {
+ case EWOULDBLOCK:
+ return pop_msg(p,POP_FAILURE,
+ "Maildrop lock busy! Is another session active?");
+ /* NOTREACHED */
+ default:
+ return pop_msg(p,POP_FAILURE,"flock: '%s': %s", p->temp_drop,
+ strerror(errno));
+ /* NOTREACHED */
+ }
+
+ /* May have grown or shrunk between open and lock! */
+ offset = lseek(dfd,0, SEEK_END);
+
+ /* Open the user's maildrop, If this fails, no harm in assuming empty */
+ if ((mfd = open(p->drop_name,O_RDWR)) > 0) {
+
+ /* Lock the maildrop */
+ if (flock (mfd, LOCK_EX) == -1) {
+ close(mfd) ;
+ return pop_msg(p,POP_FAILURE, "flock: '%s': %s", p->temp_drop,
+ strerror(errno));
+ }
+
+ /* Copy the actual mail drop into the temporary mail drop */
+ while ( (nchar=read(mfd,buffer,BUFSIZ)) > 0 )
+ if ( nchar != write(dfd,buffer,nchar) ) {
+ nchar = -1 ;
+ break ;
+ }
+
+ if ( nchar != 0 ) {
+ /* Error adding new mail. Truncate to original size,
+ and leave the maildrop as is. The user will not
+ see the new mail until the error goes away.
+ Should let them process the current backlog, in case
+ the error is a quota problem requiring deletions! */
+ ftruncate(dfd,(int)offset) ;
+ } else {
+ /* Mail transferred! Zero the mail drop NOW, that we
+ do not have to do gymnastics to figure out what's new
+ and what is old later */
+ ftruncate(mfd,0) ;
+ }
+
+ /* Close the actual mail drop */
+ close (mfd);
+ }
+
+ /* Acquire a stream pointer for the temporary maildrop */
+ if ( (p->drop = fdopen(dfd,"a+")) == NULL ) {
+ close(dfd) ;
+ return pop_msg(p,POP_FAILURE,"Cannot assign stream for %s",
+ p->temp_drop);
+ }
+
+ rewind (p->drop);
+
+ return(POP_SUCCESS);
+}
diff --git a/crypto/heimdal/appl/popper/pop_dropinfo.c b/crypto/heimdal/appl/popper/pop_dropinfo.c
new file mode 100644
index 0000000..71922d2
--- /dev/null
+++ b/crypto/heimdal/appl/popper/pop_dropinfo.c
@@ -0,0 +1,232 @@
+/*
+ * Copyright (c) 1989 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#include <popper.h>
+RCSID("$Id: pop_dropinfo.c,v 1.24 1999/09/16 20:38:49 assar Exp $");
+
+#if defined(UIDL) || defined(XOVER)
+
+/*
+ * Copy the string found after after : into a malloced buffer. Stop
+ * copying at end of string or end of line. End of line delimiter is
+ * not part of the resulting copy.
+ */
+static
+char *
+find_value_after_colon(char *p)
+{
+ char *t, *tmp;
+
+ for (; *p != 0 && *p != ':'; p++) /* Find : */
+ ;
+
+ if (*p == 0)
+ goto error;
+
+ p++; /* Skip over : */
+
+ for(; *p == ' ' || *p == '\t'; p++) /* Remove white space */
+ ;
+
+ for (t = p; *t != 0 && *t != '\n' && *t != '\r'; t++) /* Find end of str */
+ ;
+
+ tmp = t = malloc(t - p + 1);
+ if (tmp == 0)
+ goto error;
+
+ for (; *p != 0 && *p != '\n' && *p != '\r'; p++, t++) /* Copy characters */
+ *t = *p;
+ *t = 0; /* Terminate string */
+ return tmp;
+
+error:
+ return "ErrorUIDL";
+}
+#endif
+
+void
+parse_header(MsgInfoList *mp, char *buffer)
+{
+#if defined(UIDL) || defined(XOVER)
+ if (strncasecmp("Message-Id:",buffer, 11) == 0) {
+ if (mp->msg_id == NULL)
+ mp->msg_id = find_value_after_colon(buffer);
+ }
+#ifdef UIDL
+ else if (strncasecmp(buffer, "X-UIDL:", 7) == 0) {
+ /* Courtesy to Qualcomm, there really is no such
+ thing as X-UIDL */
+ mp->msg_id = find_value_after_colon(buffer);
+ }
+#endif
+#endif
+#ifdef XOVER
+ else if (strncasecmp("Subject:", buffer, 8) == 0) {
+ if(mp->subject == NULL){
+ char *p;
+ mp->subject = find_value_after_colon(buffer);
+ for(p = mp->subject; *p; p++)
+ if(*p == '\t') *p = ' ';
+ }
+ }
+ else if (strncasecmp("From:", buffer, 5) == 0) {
+ if(mp->from == NULL){
+ char *p;
+ mp->from = find_value_after_colon(buffer);
+ for(p = mp->from; *p; p++)
+ if(*p == '\t') *p = ' ';
+ }
+ }
+ else if (strncasecmp("Date:", buffer, 5) == 0) {
+ if(mp->date == NULL){
+ char *p;
+ mp->date = find_value_after_colon(buffer);
+ for(p = mp->date; *p; p++)
+ if(*p == '\t') *p = ' ';
+ }
+ }
+#endif
+}
+
+int
+add_missing_headers(POP *p, MsgInfoList *mp)
+{
+#if defined(UIDL) || defined(XOVER)
+ if (mp->msg_id == NULL) {
+ asprintf(&mp->msg_id, "no-message-id-%d", mp->number);
+ if(mp->msg_id == NULL) {
+ fclose (p->drop);
+ p->msg_count = 0;
+ return pop_msg (p,POP_FAILURE,
+ "Can't build message list for '%s': Out of memory",
+ p->user);
+ }
+ }
+#endif
+#ifdef XOVER
+ if (mp->subject == NULL)
+ mp->subject = "<none>";
+ if (mp->from == NULL)
+ mp->from = "<unknown>";
+ if (mp->date == NULL)
+ mp->date = "<unknown>";
+#endif
+ return POP_SUCCESS;
+}
+
+/*
+ * dropinfo: Extract information about the POP maildrop and store
+ * it for use by the other POP routines.
+ */
+
+int
+pop_dropinfo(POP *p)
+{
+ char buffer[BUFSIZ]; /* Read buffer */
+ MsgInfoList * mp; /* Pointer to message
+ info list */
+ int msg_num; /* Current message
+ counter */
+ int nchar; /* Bytes written/read */
+ int blank_line = 1; /* previous line was blank */
+ int in_header = 0; /* if we are in a header block */
+
+ /* Initialize maildrop status variables in the POP parameter block */
+ p->msg_count = 0;
+ p->msgs_deleted = 0;
+ p->last_msg = 0;
+ p->bytes_deleted = 0;
+ p->drop_size = 0;
+
+ /* Allocate memory for message information structures */
+ p->msg_count = ALLOC_MSGS;
+ p->mlp = (MsgInfoList *)calloc((unsigned)p->msg_count,sizeof(MsgInfoList));
+ if (p->mlp == NULL){
+ fclose (p->drop);
+ p->msg_count = 0;
+ return pop_msg (p,POP_FAILURE,
+ "Can't build message list for '%s': Out of memory", p->user);
+ }
+
+ rewind (p->drop);
+
+ /* Scan the file, loading the message information list with
+ information about each message */
+
+ for (msg_num = p->drop_size = 0, mp = p->mlp - 1;
+ fgets(buffer,MAXMSGLINELEN,p->drop);) {
+
+ nchar = strlen(buffer);
+
+ if (blank_line && strncmp(buffer,"From ",5) == 0) {
+ in_header = 1;
+ if (++msg_num > p->msg_count) {
+ p->mlp=(MsgInfoList *) realloc(p->mlp,
+ (p->msg_count+=ALLOC_MSGS)*sizeof(MsgInfoList));
+ if (p->mlp == NULL){
+ fclose (p->drop);
+ p->msg_count = 0;
+ return pop_msg (p,POP_FAILURE,
+ "Can't build message list for '%s': Out of memory",
+ p->user);
+ }
+ mp = p->mlp + msg_num - 2;
+ }
+ ++mp;
+ mp->number = msg_num;
+ mp->length = 0;
+ mp->lines = 0;
+ mp->offset = ftell(p->drop) - nchar;
+ mp->flags = 0;
+#if defined(UIDL) || defined(XOVER)
+ mp->msg_id = 0;
+#endif
+#ifdef XOVER
+ mp->subject = 0;
+ mp->from = 0;
+ mp->date = 0;
+#endif
+#ifdef DEBUG
+ if(p->debug)
+ pop_log(p, POP_DEBUG,
+ "Msg %d at offset %ld being added to list",
+ mp->number, mp->offset);
+#endif /* DEBUG */
+ } else if(in_header)
+ parse_header(mp, buffer);
+ blank_line = (strncmp(buffer, "\n", nchar) == 0);
+ if(blank_line) {
+ int e;
+ in_header = 0;
+ e = add_missing_headers(p, mp);
+ if(e != POP_SUCCESS)
+ return e;
+ }
+ mp->length += nchar;
+ p->drop_size += nchar;
+ mp->lines++;
+ }
+ p->msg_count = msg_num;
+
+#ifdef DEBUG
+ if(p->debug && msg_num > 0) {
+ int i;
+ for (i = 0, mp = p->mlp; i < p->msg_count; i++, mp++)
+#ifdef UIDL
+ pop_log(p,POP_DEBUG,
+ "Msg %d at offset %ld is %ld octets long and has %u lines and id %s.",
+ mp->number,mp->offset,mp->length,mp->lines, mp->msg_id);
+#else
+ pop_log(p,POP_DEBUG,
+ "Msg %d at offset %d is %d octets long and has %u lines.",
+ mp->number,mp->offset,mp->length,mp->lines);
+#endif
+ }
+#endif /* DEBUG */
+
+ return(POP_SUCCESS);
+}
diff --git a/crypto/heimdal/appl/popper/pop_get_command.c b/crypto/heimdal/appl/popper/pop_get_command.c
new file mode 100644
index 0000000..e43c1d9
--- /dev/null
+++ b/crypto/heimdal/appl/popper/pop_get_command.c
@@ -0,0 +1,118 @@
+/*
+ * Copyright (c) 1989 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#include <popper.h>
+RCSID("$Id: pop_get_command.c,v 1.15 1999/09/16 20:38:49 assar Exp $");
+
+/*
+ * get_command: Extract the command from an input line form a POP client
+ */
+
+static state_table states[] = {
+ {auth1, "user", 1, 1, pop_user, {auth1, auth2}},
+ {auth2, "pass", 1, 99, pop_pass, {auth1, trans}},
+#ifdef RPOP
+ {auth2, "rpop", 1, 1, pop_rpop, {auth1, trans}},
+#endif /* RPOP */
+ {auth1, "quit", 0, 0, pop_quit, {halt, halt}},
+ {auth2, "quit", 0, 0, pop_quit, {halt, halt}},
+ {trans, "stat", 0, 0, pop_stat, {trans, trans}},
+ {trans, "list", 0, 1, pop_list, {trans, trans}},
+ {trans, "retr", 1, 1, pop_send, {trans, trans}},
+ {trans, "dele", 1, 1, pop_dele, {trans, trans}},
+ {trans, "noop", 0, 0, NULL, {trans, trans}},
+ {trans, "rset", 0, 0, pop_rset, {trans, trans}},
+ {trans, "top", 2, 2, pop_send, {trans, trans}},
+ {trans, "last", 0, 0, pop_last, {trans, trans}},
+ {trans, "quit", 0, 0, pop_updt, {halt, halt}},
+ {trans, "help", 0, 0, pop_help, {trans, trans}},
+#ifdef UIDL
+ {trans, "uidl", 0, 1, pop_uidl, {trans, trans}},
+#endif
+#ifdef XOVER
+ {trans, "xover", 0, 0, pop_xover, {trans, trans}},
+#endif
+#ifdef XDELE
+ {trans, "xdele", 1, 2, pop_xdele, {trans, trans}},
+#endif
+ {(state) 0, NULL, 0, 0, NULL, {halt, halt}},
+};
+
+state_table *
+pop_get_command(POP *p, char *mp)
+{
+ state_table * s;
+ char buf[MAXMSGLINELEN];
+
+ /* Save a copy of the original client line */
+#ifdef DEBUG
+ if(p->debug) strlcpy (buf, mp, sizeof(buf));
+#endif /* DEBUG */
+
+ /* Parse the message into the parameter array */
+ if ((p->parm_count = pop_parse(p,mp)) < 0) return(NULL);
+
+ /* Do not log cleartext passwords */
+#ifdef DEBUG
+ if(p->debug){
+ if(strcmp(p->pop_command,"pass") == 0)
+ pop_log(p,POP_DEBUG,"Received: \"%s xxxxxxxxx\"",p->pop_command);
+ else {
+ /* Remove trailing <LF> */
+ buf[strlen(buf)-2] = '\0';
+ pop_log(p,POP_DEBUG,"Received: \"%s\"",buf);
+ }
+ }
+#endif /* DEBUG */
+
+ /* Search for the POP command in the command/state table */
+ for (s = states; s->command; s++) {
+
+ /* Is this a valid command for the current operating state? */
+ if (strcmp(s->command,p->pop_command) == 0
+ && s->ValidCurrentState == p->CurrentState) {
+
+ /* Were too few parameters passed to the command? */
+ if (p->parm_count < s->min_parms) {
+ pop_msg(p,POP_FAILURE,
+ "Too few arguments for the %s command.",
+ p->pop_command);
+ return NULL;
+ }
+
+ /* Were too many parameters passed to the command? */
+ if (p->parm_count > s->max_parms) {
+ pop_msg(p,POP_FAILURE,
+ "Too many arguments for the %s command.",
+ p->pop_command);
+ return NULL;
+ }
+
+ /* Return a pointer to the entry for this command in
+ the command/state table */
+ return (s);
+ }
+ }
+ /* The client command was not located in the command/state table */
+ pop_msg(p,POP_FAILURE,
+ "Unknown command: \"%s\".",p->pop_command);
+ return NULL;
+}
+
+int
+pop_help (POP *p)
+{
+ state_table *s;
+
+ pop_msg(p, POP_SUCCESS, "help");
+
+ for (s = states; s->command; s++) {
+ fprintf (p->output, "%s\r\n", s->command);
+ }
+ fprintf (p->output, ".\r\n");
+ fflush (p->output);
+ return POP_SUCCESS;
+}
diff --git a/crypto/heimdal/appl/popper/pop_init.c b/crypto/heimdal/appl/popper/pop_init.c
new file mode 100644
index 0000000..7487ce6
--- /dev/null
+++ b/crypto/heimdal/appl/popper/pop_init.c
@@ -0,0 +1,398 @@
+/*
+ * Copyright (c) 1989 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#include <popper.h>
+RCSID("$Id: pop_init.c,v 1.58 2001/02/20 01:44:47 assar Exp $");
+
+
+#if defined(KRB4) || defined(KRB5)
+
+static int
+pop_net_read(POP *p, int fd, void *buf, size_t len)
+{
+#ifdef KRB5
+ return krb5_net_read(p->context, &fd, buf, len);
+#elif defined(KRB4)
+ return krb_net_read(fd, buf, len);
+#endif
+}
+#endif
+
+static char *addr_log;
+
+static void
+pop_write_addr(POP *p, struct sockaddr *addr)
+{
+ char ts[32];
+ char as[128];
+ time_t t;
+ FILE *f;
+ if(addr_log == NULL)
+ return;
+ t = time(NULL);
+ strftime(ts, sizeof(ts), "%Y%m%d%H%M%S", localtime(&t));
+ if(inet_ntop (addr->sa_family, socket_get_address(addr),
+ as, sizeof(as)) == NULL) {
+ pop_log(p, POP_PRIORITY, "failed to print address");
+ return;
+ }
+
+ f = fopen(addr_log, "a");
+ if(f == NULL) {
+ pop_log(p, POP_PRIORITY, "failed to open address log (%s)", addr_log);
+ return;
+ }
+ fprintf(f, "%s %s\n", as, ts);
+ fclose(f);
+}
+
+#ifdef KRB4
+static int
+krb4_authenticate (POP *p, int s, u_char *buf, struct sockaddr *addr)
+{
+ Key_schedule schedule;
+ KTEXT_ST ticket;
+ char instance[INST_SZ];
+ char version[9];
+ int auth;
+
+ if (memcmp (buf, KRB_SENDAUTH_VERS, 4) != 0)
+ return -1;
+ if (pop_net_read (p, s, buf + 4,
+ KRB_SENDAUTH_VLEN - 4) != KRB_SENDAUTH_VLEN - 4)
+ return -1;
+ if (memcmp (buf, KRB_SENDAUTH_VERS, KRB_SENDAUTH_VLEN) != 0)
+ return -1;
+
+ k_getsockinst (0, instance, sizeof(instance));
+ auth = krb_recvauth(KOPT_IGNORE_PROTOCOL,
+ s,
+ &ticket,
+ "pop",
+ instance,
+ (struct sockaddr_in *)addr,
+ (struct sockaddr_in *) NULL,
+ &p->kdata,
+ "",
+ schedule,
+ version);
+
+ if (auth != KSUCCESS) {
+ pop_msg(p, POP_FAILURE, "Kerberos authentication failure: %s",
+ krb_get_err_text(auth));
+ pop_log(p, POP_PRIORITY, "%s: (%s.%s@%s) %s", p->client,
+ p->kdata.pname, p->kdata.pinst, p->kdata.prealm,
+ krb_get_err_text(auth));
+ return -1;
+ }
+
+#ifdef DEBUG
+ pop_log(p, POP_DEBUG, "%s.%s@%s (%s): ok", p->kdata.pname,
+ p->kdata.pinst, p->kdata.prealm, p->ipaddr);
+#endif /* DEBUG */
+ return 0;
+}
+#endif /* KRB4 */
+
+#ifdef KRB5
+static int
+krb5_authenticate (POP *p, int s, u_char *buf, struct sockaddr *addr)
+{
+ krb5_error_code ret;
+ krb5_auth_context auth_context = NULL;
+ u_int32_t len;
+ krb5_ticket *ticket;
+ char *server;
+
+ if (memcmp (buf, "\x00\x00\x00\x13", 4) != 0)
+ return -1;
+ len = (buf[0] << 24) | (buf[1] << 16) | (buf[2] << 8) | (buf[3]);
+
+ if (krb5_net_read(p->context, &s, buf, len) != len)
+ return -1;
+ if (len != sizeof(KRB5_SENDAUTH_VERSION)
+ || memcmp (buf, KRB5_SENDAUTH_VERSION, len) != 0)
+ return -1;
+
+ ret = krb5_recvauth (p->context,
+ &auth_context,
+ &s,
+ "KPOPV1.0",
+ NULL, /* let rd_req figure out what server to use */
+ KRB5_RECVAUTH_IGNORE_VERSION,
+ NULL,
+ &ticket);
+ if (ret) {
+ pop_log(p, POP_PRIORITY, "krb5_recvauth: %s",
+ krb5_get_err_text(p->context, ret));
+ return -1;
+ }
+
+
+ ret = krb5_unparse_name(p->context, ticket->server, &server);
+ if(ret) {
+ pop_log(p, POP_PRIORITY, "krb5_unparse_name: %s",
+ krb5_get_err_text(p->context, ret));
+ ret = -1;
+ goto out;
+ }
+ /* does this make sense? */
+ if(strncmp(server, "pop/", 4) != 0) {
+ pop_log(p, POP_PRIORITY,
+ "Got ticket for service `%s'", server);
+ ret = -1;
+ goto out;
+ } else if(p->debug)
+ pop_log(p, POP_DEBUG,
+ "Accepted ticket for service `%s'", server);
+ free(server);
+ out:
+ krb5_auth_con_free (p->context, auth_context);
+ krb5_copy_principal (p->context, ticket->client, &p->principal);
+ krb5_free_ticket (p->context, ticket);
+
+ return ret;
+}
+#endif
+
+static int
+krb_authenticate(POP *p, struct sockaddr *addr)
+{
+#if defined(KRB4) || defined(KRB5)
+ u_char buf[BUFSIZ];
+
+ if (pop_net_read (p, 0, buf, 4) != 4) {
+ pop_msg(p, POP_FAILURE, "Reading four bytes: %s",
+ strerror(errno));
+ exit (1);
+ }
+#ifdef KRB4
+ if (krb4_authenticate (p, 0, buf, addr) == 0){
+ pop_write_addr(p, addr);
+ p->version = 4;
+ return POP_SUCCESS;
+ }
+#endif
+#ifdef KRB5
+ if (krb5_authenticate (p, 0, buf, addr) == 0){
+ pop_write_addr(p, addr);
+ p->version = 5;
+ return POP_SUCCESS;
+ }
+#endif
+ exit (1);
+
+#endif /* defined(KRB4) || defined(KRB5) */
+
+ return(POP_SUCCESS);
+}
+
+static int
+plain_authenticate (POP *p, struct sockaddr *addr)
+{
+ return(POP_SUCCESS);
+}
+
+static int kerberos_flag;
+static char *auth_str;
+static int debug_flag;
+static int interactive_flag;
+static char *port_str;
+static char *trace_file;
+static int timeout;
+static int help_flag;
+static int version_flag;
+
+static struct getargs args[] = {
+#if defined(KRB4) || defined(KRB5)
+ { "kerberos", 'k', arg_flag, &kerberos_flag, "use kerberos" },
+#endif
+ { "auth-mode", 'a', arg_string, &auth_str, "required authentication" },
+ { "debug", 'd', arg_flag, &debug_flag },
+ { "interactive", 'i', arg_flag, &interactive_flag, "create new socket" },
+ { "port", 'p', arg_string, &port_str, "port to listen to", "port" },
+ { "trace-file", 't', arg_string, &trace_file, "trace all command to file", "file" },
+ { "timeout", 'T', arg_integer, &timeout, "timeout", "seconds" },
+ { "address-log", 0, arg_string, &addr_log, "enable address log", "file" },
+ { "help", 'h', arg_flag, &help_flag },
+ { "version", 'v', arg_flag, &version_flag }
+};
+
+static int num_args = sizeof(args) / sizeof(args[0]);
+
+/*
+ * init: Start a Post Office Protocol session
+ */
+
+static int
+pop_getportbyname(POP *p, const char *service,
+ const char *proto, short def)
+{
+#ifdef KRB5
+ return krb5_getportbyname(p->context, service, proto, def);
+#elif defined(KRB4)
+ return k_getportbyname(service, proto, htons(def));
+#else
+ return htons(default);
+#endif
+}
+
+int
+pop_init(POP *p,int argcount,char **argmessage)
+{
+ struct sockaddr_storage cs_ss;
+ struct sockaddr *cs = (struct sockaddr *)&cs_ss;
+ socklen_t len;
+ char * trace_file_name = "/tmp/popper-trace";
+ int portnum = 0;
+ int optind = 0;
+ int error;
+
+ /* Initialize the POP parameter block */
+ memset (p, 0, sizeof(POP));
+
+ setprogname(argmessage[0]);
+
+ /* Save my name in a global variable */
+ p->myname = (char*)getprogname();
+
+ /* Get the name of our host */
+ gethostname(p->myhost,MaxHostNameLen);
+
+#ifdef KRB5
+ {
+ krb5_error_code ret;
+
+ ret = krb5_init_context (&p->context);
+ if (ret)
+ errx (1, "krb5_init_context failed: %d", ret);
+
+ krb5_openlog(p->context, p->myname, &p->logf);
+ krb5_set_warn_dest(p->context, p->logf);
+ }
+#else
+ /* Open the log file */
+ roken_openlog(p->myname,POP_LOGOPTS,POP_FACILITY);
+#endif
+
+ p->auth_level = AUTH_NONE;
+
+ if(getarg(args, num_args, argcount, argmessage, &optind)){
+ arg_printusage(args, num_args, NULL, "");
+ exit(1);
+ }
+ if(help_flag){
+ arg_printusage(args, num_args, NULL, "");
+ exit(0);
+ }
+ if(version_flag){
+ print_version(NULL);
+ exit(0);
+ }
+
+ argcount -= optind;
+ argmessage += optind;
+
+ if (argcount != 0) {
+ arg_printusage(args, num_args, NULL, "");
+ exit(1);
+ }
+
+ if(auth_str){
+ if (strcmp (auth_str, "none") == 0)
+ p->auth_level = AUTH_NONE;
+ else if(strcmp(auth_str, "otp") == 0)
+ p->auth_level = AUTH_OTP;
+ else
+ warnx ("bad value for -a: %s", optarg);
+ }
+ /* Debugging requested */
+ p->debug = debug_flag;
+
+ if(port_str)
+ portnum = htons(atoi(port_str));
+ if(trace_file){
+ p->debug++;
+ if ((p->trace = fopen(trace_file, "a+")) == NULL) {
+ pop_log(p, POP_PRIORITY,
+ "Unable to open trace file \"%s\", err = %d",
+ optarg,errno);
+ exit (1);
+ }
+ trace_file_name = trace_file;
+ }
+
+#if defined(KRB4) || defined(KRB5)
+ p->kerberosp = kerberos_flag;
+#endif
+
+ if(timeout)
+ pop_timeout = timeout;
+
+ /* Fake inetd */
+ if (interactive_flag) {
+ if (portnum == 0)
+ portnum = p->kerberosp ?
+ pop_getportbyname(p, "kpop", "tcp", 1109) :
+ pop_getportbyname(p, "pop", "tcp", 110);
+ mini_inetd (portnum);
+ }
+
+ /* Get the address and socket of the client to whom I am speaking */
+ len = sizeof(cs_ss);
+ if (getpeername(STDIN_FILENO, cs, &len) < 0) {
+ pop_log(p,POP_PRIORITY,
+ "Unable to obtain socket and address of client, err = %d",errno);
+ exit (1);
+ }
+
+ /* Save the dotted decimal form of the client's IP address
+ in the POP parameter block */
+ inet_ntop (cs->sa_family, socket_get_address (cs),
+ p->ipaddr, sizeof(p->ipaddr));
+
+ /* Save the client's port */
+ p->ipport = ntohs(socket_get_port (cs));
+
+ /* Get the canonical name of the host to whom I am speaking */
+ error = getnameinfo_verified (cs, len, p->client, sizeof(p->client),
+ NULL, 0, 0);
+ if (error) {
+ pop_log (p, POP_PRIORITY,
+ "getnameinfo: %s", gai_strerror (error));
+ strlcpy (p->client, p->ipaddr, sizeof(p->client));
+ }
+
+ /* Create input file stream for TCP/IP communication */
+ if ((p->input = fdopen(STDIN_FILENO,"r")) == NULL){
+ pop_log(p,POP_PRIORITY,
+ "Unable to open communication stream for input, err = %d",errno);
+ exit (1);
+ }
+
+ /* Create output file stream for TCP/IP communication */
+ if ((p->output = fdopen(STDOUT_FILENO,"w")) == NULL){
+ pop_log(p,POP_PRIORITY,
+ "Unable to open communication stream for output, err = %d",errno);
+ exit (1);
+ }
+
+ pop_log(p,POP_PRIORITY,
+ "(v%s) Servicing request from \"%s\" at %s\n",
+ VERSION,p->client,p->ipaddr);
+
+#ifdef DEBUG
+ if (p->trace)
+ pop_log(p,POP_PRIORITY,
+ "Tracing session and debugging information in file \"%s\"",
+ trace_file_name);
+ else if (p->debug)
+ pop_log(p,POP_PRIORITY,"Debugging turned on");
+#endif /* DEBUG */
+
+
+ return((p->kerberosp ? krb_authenticate : plain_authenticate)(p, cs));
+}
diff --git a/crypto/heimdal/appl/popper/pop_last.c b/crypto/heimdal/appl/popper/pop_last.c
new file mode 100644
index 0000000..36fdd0d
--- /dev/null
+++ b/crypto/heimdal/appl/popper/pop_last.c
@@ -0,0 +1,18 @@
+/*
+ * Copyright (c) 1989 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#include <popper.h>
+RCSID("$Id: pop_last.c,v 1.6 1996/10/28 16:25:28 assar Exp $");
+
+/*
+ * last: Display the last message touched in a POP session
+ */
+
+int
+pop_last (POP *p)
+{
+ return (pop_msg(p,POP_SUCCESS,"%u is the last message seen.",p->last_msg));
+}
diff --git a/crypto/heimdal/appl/popper/pop_list.c b/crypto/heimdal/appl/popper/pop_list.c
new file mode 100644
index 0000000..aa7666a
--- /dev/null
+++ b/crypto/heimdal/appl/popper/pop_list.c
@@ -0,0 +1,59 @@
+/*
+ * Copyright (c) 1989 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#include <popper.h>
+RCSID("$Id: pop_list.c,v 1.10 1998/04/23 17:37:47 joda Exp $");
+
+/*
+ * list: List the contents of a POP maildrop
+ */
+
+int
+pop_list (POP *p)
+{
+ MsgInfoList * mp; /* Pointer to message info list */
+ int i;
+ int msg_num;
+
+ /* Was a message number provided? */
+ if (p->parm_count > 0) {
+ msg_num = atoi(p->pop_parm[1]);
+
+ /* Is requested message out of range? */
+ if ((msg_num < 1) || (msg_num > p->msg_count))
+ return (pop_msg (p,POP_FAILURE,
+ "Message %d does not exist.",msg_num));
+
+ /* Get a pointer to the message in the message list */
+ mp = &p->mlp[msg_num-1];
+
+ /* Is the message already flagged for deletion? */
+ if (mp->flags & DEL_FLAG)
+ return (pop_msg (p,POP_FAILURE,
+ "Message %d has been deleted.",msg_num));
+
+ /* Display message information */
+ return (pop_msg(p,POP_SUCCESS,"%d %ld",msg_num,mp->length));
+ }
+
+ /* Display the entire list of messages */
+ pop_msg(p,POP_SUCCESS,
+ "%d messages (%ld octets)",
+ p->msg_count-p->msgs_deleted,
+ p->drop_size-p->bytes_deleted);
+
+ /* Loop through the message information list. Skip deleted messages */
+ for (i = p->msg_count, mp = p->mlp; i > 0; i--, mp++) {
+ if (!(mp->flags & DEL_FLAG))
+ fprintf(p->output,"%u %lu\r\n",mp->number,mp->length);
+ }
+
+ /* "." signals the end of a multi-line transmission */
+ fprintf(p->output,".\r\n");
+ fflush(p->output);
+
+ return(POP_SUCCESS);
+}
diff --git a/crypto/heimdal/appl/popper/pop_log.c b/crypto/heimdal/appl/popper/pop_log.c
new file mode 100644
index 0000000..deb9841
--- /dev/null
+++ b/crypto/heimdal/appl/popper/pop_log.c
@@ -0,0 +1,36 @@
+/*
+ * Copyright (c) 1989 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#include <popper.h>
+RCSID("$Id: pop_log.c,v 1.13 1997/10/14 21:59:07 joda Exp $");
+
+/*
+ * log: Make a log entry
+ */
+
+int
+pop_log(POP *p, int stat, char *format, ...)
+{
+ char msgbuf[MAXLINELEN];
+ va_list ap;
+
+ va_start(ap, format);
+ vsnprintf(msgbuf, sizeof(msgbuf), format, ap);
+
+ if (p->debug && p->trace) {
+ fprintf(p->trace,"%s\n",msgbuf);
+ fflush(p->trace);
+ } else {
+#ifdef KRB5
+ krb5_log(p->context, p->logf, stat, "%s", msgbuf);
+#else
+ syslog (stat,"%s",msgbuf);
+#endif
+ }
+ va_end(ap);
+
+ return(stat);
+}
diff --git a/crypto/heimdal/appl/popper/pop_msg.c b/crypto/heimdal/appl/popper/pop_msg.c
new file mode 100644
index 0000000..12887a4
--- /dev/null
+++ b/crypto/heimdal/appl/popper/pop_msg.c
@@ -0,0 +1,57 @@
+/*
+ * Copyright (c) 1989 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#include <popper.h>
+RCSID("$Id: pop_msg.c,v 1.16 1999/09/16 20:38:50 assar Exp $");
+
+/*
+ * msg: Send a formatted line to the POP client
+ */
+
+int
+pop_msg(POP *p, int stat, char *format, ...)
+{
+ char *mp;
+ char message[MAXLINELEN];
+ va_list ap;
+
+ va_start(ap, format);
+
+ /* Point to the message buffer */
+ mp = message;
+
+ /* Format the POP status code at the beginning of the message */
+ snprintf (mp, sizeof(message), "%s ",
+ (stat == POP_SUCCESS) ? POP_OK : POP_ERR);
+
+ /* Point past the POP status indicator in the message message */
+ mp += strlen(mp);
+
+ /* Append the message (formatted, if necessary) */
+ if (format)
+ vsnprintf (mp, sizeof(message) - strlen(message),
+ format, ap);
+
+ /* Log the message if debugging is turned on */
+#ifdef DEBUG
+ if (p->debug && stat == POP_SUCCESS)
+ pop_log(p,POP_DEBUG,"%s",message);
+#endif /* DEBUG */
+
+ /* Log the message if a failure occurred */
+ if (stat != POP_SUCCESS)
+ pop_log(p,POP_PRIORITY,"%s",message);
+
+ /* Append the <CR><LF> */
+ strlcat(message, "\r\n", sizeof(message));
+
+ /* Send the message to the client */
+ fputs(message, p->output);
+ fflush(p->output);
+
+ va_end(ap);
+ return(stat);
+}
diff --git a/crypto/heimdal/appl/popper/pop_parse.c b/crypto/heimdal/appl/popper/pop_parse.c
new file mode 100644
index 0000000..37aef36
--- /dev/null
+++ b/crypto/heimdal/appl/popper/pop_parse.c
@@ -0,0 +1,55 @@
+/*
+ * Copyright (c) 1989 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#include <popper.h>
+RCSID("$Id: pop_parse.c,v 1.9 1999/03/13 21:17:27 assar Exp $");
+
+/*
+ * parse: Parse a raw input line from a POP client
+ * into null-delimited tokens
+ */
+
+int
+pop_parse(POP *p, char *buf)
+{
+ char * mp;
+ int i;
+
+ /* Loop through the POP command array */
+ for (mp = buf, i = 0; ; i++) {
+
+ /* Skip leading spaces and tabs in the message */
+ while (isspace((unsigned char)*mp))mp++;
+
+ /* Are we at the end of the message? */
+ if (*mp == 0) break;
+
+ /* Have we already obtained the maximum allowable parameters? */
+ if (i >= MAXPARMCOUNT) {
+ pop_msg(p,POP_FAILURE,"Too many arguments supplied.");
+ return(-1);
+ }
+
+ /* Point to the start of the token */
+ p->pop_parm[i] = mp;
+
+ /* Search for the first space character (end of the token) */
+ while (!isspace((unsigned char)*mp) && *mp) mp++;
+
+ /* Delimit the token with a null */
+ if (*mp) *mp++ = 0;
+ }
+
+ /* Were any parameters passed at all? */
+ if (i == 0) return (-1);
+
+ /* Convert the first token (POP command) to lower case */
+ strlwr(p->pop_command);
+
+ /* Return the number of tokens extracted minus the command itself */
+ return (i-1);
+
+}
diff --git a/crypto/heimdal/appl/popper/pop_pass.c b/crypto/heimdal/appl/popper/pop_pass.c
new file mode 100644
index 0000000..cebd780
--- /dev/null
+++ b/crypto/heimdal/appl/popper/pop_pass.c
@@ -0,0 +1,220 @@
+/*
+ * Copyright (c) 1989 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#include <popper.h>
+RCSID("$Id: pop_pass.c,v 1.41 2000/04/12 15:37:46 assar Exp $");
+
+#ifdef KRB4
+static int
+krb4_verify_password (POP *p)
+{
+ int status;
+ char lrealm[REALM_SZ];
+ char tkt[MaxPathLen];
+
+ status = krb_get_lrealm(lrealm,1);
+ if (status == KFAILURE) {
+ pop_log(p, POP_PRIORITY, "%s: (%s.%s@%s) %s", p->client,
+ p->kdata.pname, p->kdata.pinst, p->kdata.prealm,
+ krb_get_err_text(status));
+ return 1;
+ }
+ snprintf(tkt, sizeof(tkt), "%s_popper.%u", TKT_ROOT, (unsigned)getpid());
+ krb_set_tkt_string (tkt);
+
+ status = krb_verify_user(p->user, "", lrealm,
+ p->pop_parm[1], KRB_VERIFY_SECURE, "pop");
+ dest_tkt(); /* no point in keeping the tickets */
+ return status;
+}
+#endif /* KRB4 */
+
+#ifdef KRB5
+static int
+krb5_verify_password (POP *p)
+{
+ krb5_preauthtype pre_auth_types[] = {KRB5_PADATA_ENC_TIMESTAMP};
+ krb5_get_init_creds_opt get_options;
+ krb5_verify_init_creds_opt verify_options;
+ krb5_error_code ret;
+ krb5_principal client, server;
+ krb5_creds creds;
+
+ krb5_get_init_creds_opt_init (&get_options);
+
+ krb5_get_init_creds_opt_set_preauth_list (&get_options,
+ pre_auth_types,
+ 1);
+
+ krb5_verify_init_creds_opt_init (&verify_options);
+
+ ret = krb5_parse_name (p->context, p->user, &client);
+ if (ret) {
+ pop_log(p, POP_PRIORITY, "krb5_parse_name: %s",
+ krb5_get_err_text (p->context, ret));
+ return 1;
+ }
+
+ ret = krb5_get_init_creds_password (p->context,
+ &creds,
+ client,
+ p->pop_parm[1],
+ NULL,
+ NULL,
+ 0,
+ NULL,
+ &get_options);
+ if (ret) {
+ pop_log(p, POP_PRIORITY,
+ "krb5_get_init_creds_password: %s",
+ krb5_get_err_text (p->context, ret));
+ return 1;
+ }
+
+ ret = krb5_sname_to_principal (p->context,
+ p->myhost,
+ "pop",
+ KRB5_NT_SRV_HST,
+ &server);
+ if (ret) {
+ pop_log(p, POP_PRIORITY,
+ "krb5_get_init_creds_password: %s",
+ krb5_get_err_text (p->context, ret));
+ return 1;
+ }
+
+ ret = krb5_verify_init_creds (p->context,
+ &creds,
+ server,
+ NULL,
+ NULL,
+ &verify_options);
+ krb5_free_principal (p->context, client);
+ krb5_free_principal (p->context, server);
+ krb5_free_creds_contents (p->context, &creds);
+ return ret;
+}
+#endif
+/*
+ * pass: Obtain the user password from a POP client
+ */
+
+int
+pop_pass (POP *p)
+{
+ struct passwd *pw;
+ int i;
+ struct stat st;
+
+ /* Make one string of all these parameters */
+
+ for (i = 1; i < p->parm_count; ++i)
+ p->pop_parm[i][strlen(p->pop_parm[i])] = ' ';
+
+ /* Look for the user in the password file */
+ if ((pw = k_getpwnam(p->user)) == NULL)
+ return (pop_msg(p,POP_FAILURE,
+ "Password supplied for \"%s\" is incorrect.",
+ p->user));
+
+ if (p->kerberosp) {
+#ifdef KRB4
+ if (p->version == 4) {
+ if(kuserok (&p->kdata, p->user)) {
+ pop_log(p, POP_PRIORITY,
+ "%s: (%s.%s@%s) tried to retrieve mail for %s.",
+ p->client, p->kdata.pname, p->kdata.pinst,
+ p->kdata.prealm, p->user);
+ return(pop_msg(p,POP_FAILURE,
+ "Popping not authorized"));
+ }
+ pop_log(p, POP_INFO, "%s: %s.%s@%s -> %s",
+ p->ipaddr,
+ p->kdata.pname, p->kdata.pinst, p->kdata.prealm,
+ p->user);
+ } else
+#endif /* KRB4 */
+#ifdef KRB5
+ if (p->version == 5) {
+ char *name;
+
+ if (!krb5_kuserok (p->context, p->principal, p->user)) {
+ pop_log (p, POP_PRIORITY,
+ "krb5 permission denied");
+ return pop_msg(p, POP_FAILURE,
+ "Popping not authorized");
+ }
+ if(krb5_unparse_name (p->context, p->principal, &name) == 0) {
+ pop_log(p, POP_INFO, "%s: %s -> %s",
+ p->ipaddr, name, p->user);
+ free (name);
+ }
+ } else {
+ pop_log (p, POP_PRIORITY, "kerberos authentication failed");
+ return pop_msg (p, POP_FAILURE,
+ "kerberos authentication failed");
+ }
+#endif
+ { }
+ } else {
+ /* We don't accept connections from users with null passwords */
+ if (pw->pw_passwd == NULL)
+ return (pop_msg(p,
+ POP_FAILURE,
+ "Password supplied for \"%s\" is incorrect.",
+ p->user));
+
+#ifdef OTP
+ if (otp_verify_user (&p->otp_ctx, p->pop_parm[1]) == 0)
+ /* pass OK */;
+ else
+#endif
+ /* Compare the supplied password with the password file entry */
+ if (p->auth_level != AUTH_NONE)
+ return pop_msg(p, POP_FAILURE,
+ "Password supplied for \"%s\" is incorrect.",
+ p->user);
+ else if (!strcmp(crypt(p->pop_parm[1], pw->pw_passwd), pw->pw_passwd))
+ /* pass OK */;
+ else {
+ int ret = -1;
+#ifdef KRB4
+ ret = krb4_verify_password (p);
+#endif
+#ifdef KRB5
+ if(ret)
+ ret = krb5_verify_password (p);
+#endif
+ if(ret)
+ return pop_msg(p, POP_FAILURE,
+ "Password incorrect");
+ }
+ }
+ pop_log(p, POP_INFO, "login from %s as %s",
+ p->ipaddr, p->user);
+
+ /* Build the name of the user's maildrop */
+ snprintf(p->drop_name, sizeof(p->drop_name), "%s/%s", POP_MAILDIR, p->user);
+
+ if(stat(p->drop_name, &st) < 0 || !S_ISDIR(st.st_mode)){
+ /* Make a temporary copy of the user's maildrop */
+ /* and set the group and user id */
+ if (pop_dropcopy(p, pw) != POP_SUCCESS) return (POP_FAILURE);
+
+ /* Get information about the maildrop */
+ if (pop_dropinfo(p) != POP_SUCCESS) return(POP_FAILURE);
+ } else {
+ if(changeuser(p, pw) != POP_SUCCESS) return POP_FAILURE;
+ if(pop_maildir_info(p) != POP_SUCCESS) return POP_FAILURE;
+ }
+ /* Initialize the last-message-accessed number */
+ p->last_msg = 0;
+
+ /* Authorization completed successfully */
+ return (pop_msg (p, POP_SUCCESS,
+ "%s has %d message(s) (%ld octets).",
+ p->user, p->msg_count, p->drop_size));
+}
diff --git a/crypto/heimdal/appl/popper/pop_quit.c b/crypto/heimdal/appl/popper/pop_quit.c
new file mode 100644
index 0000000..429b181
--- /dev/null
+++ b/crypto/heimdal/appl/popper/pop_quit.c
@@ -0,0 +1,21 @@
+/*
+ * Copyright (c) 1989 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#include <popper.h>
+RCSID("$Id: pop_quit.c,v 1.7 1996/11/19 22:48:30 assar Exp $");
+
+/*
+ * quit: Terminate a POP session
+ */
+
+int
+pop_quit (POP *p)
+{
+ /* Release the message information list */
+ if (p->mlp) free (p->mlp);
+
+ return(POP_SUCCESS);
+}
diff --git a/crypto/heimdal/appl/popper/pop_rset.c b/crypto/heimdal/appl/popper/pop_rset.c
new file mode 100644
index 0000000..6888ebf
--- /dev/null
+++ b/crypto/heimdal/appl/popper/pop_rset.c
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 1989 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#include <popper.h>
+RCSID("$Id: pop_rset.c,v 1.9 1998/04/23 17:38:08 joda Exp $");
+
+/*
+ * rset: Unflag all messages flagged for deletion in a POP maildrop
+ */
+
+int
+pop_rset (POP *p)
+{
+ MsgInfoList * mp; /* Pointer to the message info list */
+ int i;
+
+ /* Unmark all the messages */
+ for (i = p->msg_count, mp = p->mlp; i > 0; i--, mp++)
+ mp->flags &= ~DEL_FLAG;
+
+ /* Reset the messages-deleted and bytes-deleted counters */
+ p->msgs_deleted = 0;
+ p->bytes_deleted = 0;
+
+ /* Reset the last-message-access flag */
+ p->last_msg = 0;
+
+ return (pop_msg(p,POP_SUCCESS,"Maildrop has %u messages (%ld octets)",
+ p->msg_count, p->drop_size));
+}
diff --git a/crypto/heimdal/appl/popper/pop_send.c b/crypto/heimdal/appl/popper/pop_send.c
new file mode 100644
index 0000000..166b990
--- /dev/null
+++ b/crypto/heimdal/appl/popper/pop_send.c
@@ -0,0 +1,176 @@
+/*
+ * Copyright (c) 1989 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#include <popper.h>
+RCSID("$Id: pop_send.c,v 1.25 1999/03/05 14:14:28 joda Exp $");
+
+/*
+ * sendline: Send a line of a multi-line response to a client.
+ */
+static int
+pop_sendline(POP *p, char *buffer)
+{
+ char * bp;
+
+ /* Byte stuff lines that begin with the termination octet */
+ if (*buffer == POP_TERMINATE)
+ fputc(POP_TERMINATE,p->output);
+
+ /* Look for a <NL> in the buffer */
+ if ((bp = strchr(buffer, '\n')))
+ *bp = 0;
+
+ /* Send the line to the client */
+ fputs(buffer,p->output);
+
+#ifdef DEBUG
+ if(p->debug)
+ pop_log(p,POP_DEBUG,"Sending line \"%s\"",buffer);
+#endif /* DEBUG */
+
+ /* Put a <CR><NL> if a newline was removed from the buffer */
+ if (bp)
+ fputs ("\r\n",p->output);
+ return bp != NULL;
+}
+
+/*
+ * send: Send the header and a specified number of lines
+ * from a mail message to a POP client.
+ */
+
+int
+pop_send(POP *p)
+{
+ MsgInfoList * mp; /* Pointer to message info list */
+ int msg_num;
+ int msg_lines;
+ char buffer[MAXMSGLINELEN];
+#ifdef RETURN_PATH_HANDLING
+ char * return_path_adr;
+ char * return_path_end;
+ int return_path_sent;
+ int return_path_linlen;
+#endif
+ int sent_nl = 0;
+
+ /* Convert the first parameter into an integer */
+ msg_num = atoi(p->pop_parm[1]);
+
+ /* Is requested message out of range? */
+ if ((msg_num < 1) || (msg_num > p->msg_count))
+ return (pop_msg (p,POP_FAILURE,"Message %d does not exist.",msg_num));
+
+ /* Get a pointer to the message in the message list */
+ mp = &p->mlp[msg_num-1];
+
+ /* Is the message flagged for deletion? */
+ if (mp->flags & DEL_FLAG)
+ return (pop_msg (p,POP_FAILURE,
+ "Message %d has been deleted.",msg_num));
+
+ /* If this is a TOP command, get the number of lines to send */
+ if (strcmp(p->pop_command, "top") == 0) {
+ /* Convert the second parameter into an integer */
+ msg_lines = atoi(p->pop_parm[2]);
+ }
+ else {
+ /* Assume that a RETR (retrieve) command was issued */
+ msg_lines = -1;
+ /* Flag the message as retreived */
+ mp->flags |= RETR_FLAG;
+ }
+
+ /* Display the number of bytes in the message */
+ pop_msg(p, POP_SUCCESS, "%ld octets", mp->length);
+
+ if(IS_MAILDIR(p)) {
+ int e = pop_maildir_open(p, mp);
+ if(e != POP_SUCCESS)
+ return e;
+ }
+
+ /* Position to the start of the message */
+ fseek(p->drop, mp->offset, 0);
+
+ return_path_sent = 0;
+
+ if(!IS_MAILDIR(p)) {
+ /* Skip the first line (the sendmail "From" line) */
+ fgets (buffer,MAXMSGLINELEN,p->drop);
+
+#ifdef RETURN_PATH_HANDLING
+ if (strncmp(buffer,"From ",5) == 0) {
+ return_path_linlen = strlen(buffer);
+ for (return_path_adr = buffer+5;
+ (*return_path_adr == ' ' || *return_path_adr == '\t') &&
+ return_path_adr < buffer + return_path_linlen;
+ return_path_adr++)
+ ;
+ if (return_path_adr < buffer + return_path_linlen) {
+ if ((return_path_end = strchr(return_path_adr, ' ')) != NULL)
+ *return_path_end = '\0';
+ if (strlen(return_path_adr) != 0 && *return_path_adr != '\n') {
+ static char tmpbuf[MAXMSGLINELEN + 20];
+ if (snprintf (tmpbuf,
+ sizeof(tmpbuf),
+ "Return-Path: %s\n",
+ return_path_adr) < MAXMSGLINELEN) {
+ pop_sendline (p,tmpbuf);
+ if (hangup)
+ return pop_msg (p, POP_FAILURE,
+ "SIGHUP or SIGPIPE flagged");
+ return_path_sent++;
+ }
+ }
+ }
+ }
+#endif
+ }
+
+ /* Send the header of the message followed by a blank line */
+ while (fgets(buffer,MAXMSGLINELEN,p->drop)) {
+#ifdef RETURN_PATH_HANDLING
+ /* Don't send existing Return-Path-header if already sent own */
+ if (!return_path_sent || strncasecmp(buffer, "Return-Path:", 12) != 0)
+#endif
+ sent_nl = pop_sendline (p,buffer);
+ /* A single newline (blank line) signals the
+ end of the header. sendline() converts this to a NULL,
+ so that's what we look for. */
+ if (*buffer == 0) break;
+ if (hangup)
+ return (pop_msg (p,POP_FAILURE,"SIGHUP or SIGPIPE flagged"));
+ }
+ /* Send the message body */
+ {
+ int blank_line = 1;
+ while (fgets(buffer, MAXMSGLINELEN-1, p->drop)) {
+ /* Look for the start of the next message */
+ if (!IS_MAILDIR(p) && blank_line && strncmp(buffer,"From ",5) == 0)
+ break;
+ blank_line = (strncmp(buffer, "\n", 1) == 0);
+ /* Decrement the lines sent (for a TOP command) */
+ if (msg_lines >= 0 && msg_lines-- == 0) break;
+ sent_nl = pop_sendline(p,buffer);
+ if (hangup)
+ return (pop_msg (p,POP_FAILURE,"SIGHUP or SIGPIPE flagged"));
+ }
+ /* add missing newline at end */
+ if(!sent_nl)
+ fputs("\r\n", p->output);
+ /* some pop-clients want a blank line at the end of the
+ message, we always add one here, but what the heck -- in
+ outer (white) space, no one can hear you scream */
+ if(IS_MAILDIR(p))
+ fputs("\r\n", p->output);
+ }
+ /* "." signals the end of a multi-line transmission */
+ fputs(".\r\n",p->output);
+ fflush(p->output);
+
+ return(POP_SUCCESS);
+}
diff --git a/crypto/heimdal/appl/popper/pop_stat.c b/crypto/heimdal/appl/popper/pop_stat.c
new file mode 100644
index 0000000..9ab2800
--- /dev/null
+++ b/crypto/heimdal/appl/popper/pop_stat.c
@@ -0,0 +1,26 @@
+/*
+ * Copyright (c) 1989 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#include <popper.h>
+RCSID("$Id: pop_stat.c,v 1.7 1997/05/11 11:04:35 assar Exp $");
+
+/*
+ * stat: Display the status of a POP maildrop to its client
+ */
+
+int
+pop_stat (POP *p)
+{
+#ifdef DEBUG
+ if (p->debug) pop_log(p,POP_DEBUG,"%d message(s) (%ld octets).",
+ p->msg_count-p->msgs_deleted,
+ p->drop_size-p->bytes_deleted);
+#endif /* DEBUG */
+ return (pop_msg (p,POP_SUCCESS,
+ "%d %ld",
+ p->msg_count-p->msgs_deleted,
+ p->drop_size-p->bytes_deleted));
+}
diff --git a/crypto/heimdal/appl/popper/pop_uidl.c b/crypto/heimdal/appl/popper/pop_uidl.c
new file mode 100644
index 0000000..42dc12d
--- /dev/null
+++ b/crypto/heimdal/appl/popper/pop_uidl.c
@@ -0,0 +1,88 @@
+/*
+ * Copyright (c) 1995, 1996, 1997 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 <popper.h>
+RCSID("$Id: pop_uidl.c,v 1.9 1999/12/02 16:58:33 joda Exp $");
+
+#ifdef UIDL
+/*
+ * uidl: Uidl the contents of a POP maildrop
+ */
+
+int
+pop_uidl (POP *p)
+{
+ MsgInfoList * mp; /* Pointer to message info list */
+ int i;
+ int msg_num;
+
+ /* Was a message number provided? */
+ if (p->parm_count > 0) {
+ msg_num = atoi(p->pop_parm[1]);
+
+ /* Is requested message out of range? */
+ if ((msg_num < 1) || (msg_num > p->msg_count))
+ return (pop_msg (p,POP_FAILURE,
+ "Message %d does not exist.",msg_num));
+
+ /* Get a pointer to the message in the message list */
+ mp = &p->mlp[msg_num-1];
+
+ /* Is the message already flagged for deletion? */
+ if (mp->flags & DEL_FLAG)
+ return (pop_msg (p,POP_FAILURE,
+ "Message %d has been deleted.",msg_num));
+
+ /* Display message information */
+ return (pop_msg(p,POP_SUCCESS,"%u %s",msg_num,mp->msg_id));
+ }
+
+ /* Display the entire list of messages */
+ pop_msg(p,POP_SUCCESS,
+ "%d messages (%ld octets)",
+ p->msg_count-p->msgs_deleted,
+ p->drop_size-p->bytes_deleted);
+
+ /* Loop through the message information list. Skip deleted messages */
+ for (i = p->msg_count, mp = p->mlp; i > 0; i--, mp++) {
+ if (!(mp->flags & DEL_FLAG))
+ fprintf(p->output,"%u %s\r\n",mp->number,mp->msg_id);
+ }
+
+ /* "." signals the end of a multi-line transmission */
+ fprintf(p->output,".\r\n");
+ fflush(p->output);
+
+ return(POP_SUCCESS);
+}
+#endif /* UIDL */
diff --git a/crypto/heimdal/appl/popper/pop_updt.c b/crypto/heimdal/appl/popper/pop_updt.c
new file mode 100644
index 0000000..0130132
--- /dev/null
+++ b/crypto/heimdal/appl/popper/pop_updt.c
@@ -0,0 +1,199 @@
+/*
+ * Copyright (c) 1989 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#include <popper.h>
+RCSID("$Id: pop_updt.c,v 1.19 1998/04/23 18:36:51 joda Exp $");
+
+static char standard_error[] =
+ "Error error updating primary drop. Mailbox unchanged";
+
+/*
+ * updt: Apply changes to a user's POP maildrop
+ */
+
+int
+pop_updt (POP *p)
+{
+ FILE * md; /* Stream pointer for
+ the user's maildrop */
+ int mfd; /* File descriptor for
+ above */
+ char buffer[BUFSIZ]; /* Read buffer */
+
+ MsgInfoList * mp; /* Pointer to message
+ info list */
+ int msg_num; /* Current message
+ counter */
+ int status_written; /* Status header field
+ written */
+ int nchar; /* Bytes read/written */
+
+ long offset; /* New mail offset */
+
+ int blank_line;
+
+#ifdef DEBUG
+ if (p->debug) {
+ pop_log(p,POP_DEBUG,"Performing maildrop update...");
+ pop_log(p,POP_DEBUG,"Checking to see if all messages were deleted");
+ }
+#endif /* DEBUG */
+
+ if(IS_MAILDIR(p))
+ return pop_maildir_update(p);
+
+ if (p->msgs_deleted == p->msg_count) {
+ /* Truncate before close, to avoid race condition, DO NOT UNLINK!
+ Another process may have opened, and not yet tried to lock */
+ ftruncate ((int)fileno(p->drop),0);
+ fclose(p->drop) ;
+ return (POP_SUCCESS);
+ }
+
+#ifdef DEBUG
+ if (p->debug)
+ pop_log(p,POP_DEBUG,"Opening mail drop \"%s\"",p->drop_name);
+#endif /* DEBUG */
+
+ /* Open the user's real maildrop */
+ if ((mfd = open(p->drop_name,O_RDWR|O_CREAT,0600)) == -1 ||
+ (md = fdopen(mfd,"r+")) == NULL) {
+ return pop_msg(p,POP_FAILURE,standard_error);
+ }
+
+ /* Lock the user's real mail drop */
+ if ( flock(mfd, LOCK_EX) == -1 ) {
+ fclose(md) ;
+ return pop_msg(p,POP_FAILURE, "flock: '%s': %s", p->temp_drop,
+ strerror(errno));
+ }
+
+ /* Go to the right places */
+ offset = lseek((int)fileno(p->drop),0,SEEK_END) ;
+
+ /* Append any messages that may have arrived during the session
+ to the temporary maildrop */
+ while ((nchar=read(mfd,buffer,BUFSIZ)) > 0)
+ if ( nchar != write((int)fileno(p->drop),buffer,nchar) ) {
+ nchar = -1;
+ break ;
+ }
+ if ( nchar != 0 ) {
+ fclose(md) ;
+ ftruncate((int)fileno(p->drop),(int)offset) ;
+ fclose(p->drop) ;
+ return pop_msg(p,POP_FAILURE,standard_error);
+ }
+
+ rewind(md);
+ lseek(mfd,0,SEEK_SET);
+ ftruncate(mfd,0) ;
+
+ /* Synch stdio and the kernel for the POP drop */
+ rewind(p->drop);
+ lseek((int)fileno(p->drop),0,SEEK_SET);
+
+ /* Transfer messages not flagged for deletion from the temporary
+ maildrop to the new maildrop */
+#ifdef DEBUG
+ if (p->debug)
+ pop_log(p,POP_DEBUG,"Creating new maildrop \"%s\" from \"%s\"",
+ p->drop_name,p->temp_drop);
+#endif /* DEBUG */
+
+ for (msg_num = 0; msg_num < p->msg_count; ++msg_num) {
+
+ int doing_body;
+
+ /* Get a pointer to the message information list */
+ mp = &p->mlp[msg_num];
+
+ if (mp->flags & DEL_FLAG) {
+#ifdef DEBUG
+ if(p->debug)
+ pop_log(p,POP_DEBUG,
+ "Message %d flagged for deletion.",mp->number);
+#endif /* DEBUG */
+ continue;
+ }
+
+ fseek(p->drop,mp->offset,0);
+
+#ifdef DEBUG
+ if(p->debug)
+ pop_log(p,POP_DEBUG,"Copying message %d.",mp->number);
+#endif /* DEBUG */
+ blank_line = 1;
+ for(status_written = doing_body = 0 ;
+ fgets(buffer,MAXMSGLINELEN,p->drop);) {
+
+ if (doing_body == 0) { /* Header */
+
+ /* Update the message status */
+ if (strncasecmp(buffer,"Status:",7) == 0) {
+ if (mp->flags & RETR_FLAG)
+ fputs("Status: RO\n",md);
+ else
+ fputs(buffer, md);
+ status_written++;
+ continue;
+ }
+ /* A blank line signals the end of the header. */
+ if (*buffer == '\n') {
+ doing_body = 1;
+ if (status_written == 0) {
+ if (mp->flags & RETR_FLAG)
+ fputs("Status: RO\n\n",md);
+ else
+ fputs("Status: U\n\n",md);
+ }
+ else fputs ("\n", md);
+ continue;
+ }
+ /* Save another header line */
+ fputs (buffer, md);
+ }
+ else { /* Body */
+ if (blank_line && strncmp(buffer,"From ",5) == 0) break;
+ fputs (buffer, md);
+ blank_line = (*buffer == '\n');
+ }
+ }
+ }
+
+ /* flush and check for errors now! The new mail will writen
+ without stdio, since we need not separate messages */
+
+ fflush(md) ;
+ if (ferror(md)) {
+ ftruncate(mfd,0) ;
+ fclose(md) ;
+ fclose(p->drop) ;
+ return pop_msg(p,POP_FAILURE,standard_error);
+ }
+
+ /* Go to start of new mail if any */
+ lseek((int)fileno(p->drop),offset,SEEK_SET);
+
+ while((nchar=read((int)fileno(p->drop),buffer,BUFSIZ)) > 0)
+ if ( nchar != write(mfd,buffer,nchar) ) {
+ nchar = -1;
+ break ;
+ }
+ if ( nchar != 0 ) {
+ ftruncate(mfd,0) ;
+ fclose(md) ;
+ fclose(p->drop) ;
+ return pop_msg(p,POP_FAILURE,standard_error);
+ }
+
+ /* Close the maildrop and empty temporary maildrop */
+ fclose(md);
+ ftruncate((int)fileno(p->drop),0);
+ fclose(p->drop);
+
+ return(pop_quit(p));
+}
diff --git a/crypto/heimdal/appl/popper/pop_user.c b/crypto/heimdal/appl/popper/pop_user.c
new file mode 100644
index 0000000..be771e6
--- /dev/null
+++ b/crypto/heimdal/appl/popper/pop_user.c
@@ -0,0 +1,36 @@
+/*
+ * Copyright (c) 1989 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#include <popper.h>
+RCSID("$Id: pop_user.c,v 1.15 1999/09/16 20:38:50 assar Exp $");
+
+/*
+ * user: Prompt for the user name at the start of a POP session
+ */
+
+int
+pop_user (POP *p)
+{
+ char ss[256];
+
+ strlcpy(p->user, p->pop_parm[1], sizeof(p->user));
+
+#ifdef OTP
+ if (otp_challenge (&p->otp_ctx, p->user, ss, sizeof(ss)) == 0) {
+ return pop_msg(p, POP_SUCCESS, "Password %s required for %s.",
+ ss, p->user);
+ } else
+#endif
+ if (p->auth_level != AUTH_NONE) {
+ char *s = NULL;
+#ifdef OTP
+ s = otp_error(&p->otp_ctx);
+#endif
+ return pop_msg(p, POP_FAILURE, "Permission denied%s%s",
+ s ? ":" : "", s ? s : "");
+ } else
+ return pop_msg(p, POP_SUCCESS, "Password required for %s.", p->user);
+}
diff --git a/crypto/heimdal/appl/popper/pop_xover.c b/crypto/heimdal/appl/popper/pop_xover.c
new file mode 100644
index 0000000..94936f9
--- /dev/null
+++ b/crypto/heimdal/appl/popper/pop_xover.c
@@ -0,0 +1,37 @@
+#include <popper.h>
+RCSID("$Id: pop_xover.c,v 1.4 1998/04/23 17:39:31 joda Exp $");
+
+int
+pop_xover (POP *p)
+{
+#ifdef XOVER
+ MsgInfoList * mp; /* Pointer to message info list */
+ int i;
+
+ pop_msg(p,POP_SUCCESS,
+ "%d messages (%ld octets)",
+ p->msg_count-p->msgs_deleted,
+ p->drop_size-p->bytes_deleted);
+
+ /* Loop through the message information list. Skip deleted messages */
+ for (i = p->msg_count, mp = p->mlp; i > 0; i--, mp++) {
+ if (!(mp->flags & DEL_FLAG))
+ fprintf(p->output,"%u\t%s\t%s\t%s\t%s\t%lu\t%u\r\n",
+ mp->number,
+ mp->subject,
+ mp->from,
+ mp->date,
+ mp->msg_id,
+ mp->length,
+ mp->lines);
+ }
+
+ /* "." signals the end of a multi-line transmission */
+ fprintf(p->output,".\r\n");
+ fflush(p->output);
+
+ return(POP_SUCCESS);
+#else
+ return pop_msg(p, POP_FAILURE, "Command not implemented.");
+#endif
+}
diff --git a/crypto/heimdal/appl/popper/popper.8 b/crypto/heimdal/appl/popper/popper.8
new file mode 100644
index 0000000..30dc5b9
--- /dev/null
+++ b/crypto/heimdal/appl/popper/popper.8
@@ -0,0 +1,179 @@
+.\" Copyright (c) 1980 Regents of the University of California.
+.\" All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms are permitted
+.\" provided that this notice is preserved and that due credit is given
+.\" to the University of California at Berkeley. The name of the University
+.\" may not be used to endorse or promote products derived from this
+.\" software without specific prior written permission. This software
+.\" is provided ``as is'' without express or implied warranty.
+.\"
+.\" @(#)@(#)popper.8 2.3 2.3 (CCS) 4/2/91 Copyright (c) 1990 Regents of the University of California.\nAll rights reserved.\n
+.\"
+.TH popper 8 "August 1990"
+.UC 6
+.ad
+.SH NAME
+popper \- pop 3 server
+.SH SYNOPSIS
+.B /usr/etc/popper
+[ -d ]
+[ -a ]
+[ -k ]
+[ -t trace-file]
+[ -i ]
+[ -p portnum]
+.SH DESCRIPTION
+.I Popper
+is an implementation of the Post Office Protocol server that runs on a
+variety of Unix computers to manage electronic mail for Macintosh
+and MS-DOS computers. The server was developed at the University of
+California at Berkeley and conforms fully to the specifications in RFC
+1081 and RFC 1082. The Berkeley server also has extensions to
+send electronic mail on behalf of a client.
+.PP
+The
+.B \-d
+flag sets the socket to debugging and turns on debugging. All debugging
+information is saved using syslog(8).
+.PP
+The
+.B \-t trace\-file
+flag turns on debugging and saves the trace information in
+.I trace\-file
+using fprintf(s).
+.PP
+The
+.B \-k
+flag tells popper to talk the kerberised POP protocol (KPOP).
+.PP
+The
+.B \-a
+flag tells popper not to accept any cleartext passwords, but only OTPs.
+.PP
+The
+.B \-i
+flag tells popper it has not been started by inetd and should create
+its own socket and listen on it. This is useful for debugging.
+.PP
+The
+.B \-p portnum
+flag tells popper on which port it should listen for connections when
+creating a socket.
+.SH HOW TO OBTAIN THE SERVER
+.PP
+The POP server is available via anonymous ftp from ftp.CC.Berkeley.EDU
+(128.32.136.9, 128.32.206.12). It is in two files in the pub directory:
+a compressed
+tar file popper.tar.Z and a Macintosh StuffIt archive in BinHex format
+called MacPOP.sit.hqx.
+.SH THE POP TRANSACTION CYCLE
+.PP
+The Berkeley POP server is a single program (called popper) that is
+launched by inetd when it gets a service request on the POP TCP port.
+(The official port number specified in RFC 1081 for POP version 3 is
+port 110. However, some POP3 clients attempt to contact the server at
+port 109, the POP version 2 port. Unless you are running both POP2 and
+POP3 servers, you can simply define both ports for use by the POP3
+server. This is explained in the installation instructions later on.)
+The popper program initializes and verifies that the peer IP address is
+registered in the local domain, logging a warning message when a
+connection is made to a client whose IP address does not have a
+canonical name. For systems using BSD 4.3 bind, it also checks to see
+if a cannonical name lookup for the client returns the same peer IP
+address, logging a warning message if it does not. The the server
+enters the authorization state, during which the client must correctly
+identify itself by providing a valid Unix userid and password on the
+server's host machine. No other exchanges are allowed during this
+state (other than a request to quit.) If authentication fails, a
+warning message is logged and the session ends. Once the user is
+identified, popper changes its user and group ids to match that of the
+user and enters the transaction state. The server makes a temporary
+copy of the user's maildrop (ordinarily in /usr/spool/mail) which is
+used for all subsequent transactions. These include the bulk of POP
+commands to retrieve mail, delete mail, undelete mail, and so forth. A
+Berkeley extension also allows the user to submit a mail parcel to the
+server who mails it using the sendmail program (this extension is
+supported in the HyperMail client distributed with the server). When
+the client quits, the server enters the final update state during which
+the network connection is terminated and the user's maildrop is updated
+with the (possibly) modified temporary maildrop.
+.SH LOGGING
+.PP
+The POP server uses syslog to keep a record of its activities. On
+systems with BSD 4.3 syslogging, the server logs (by default) to the
+"local0" facility at priority "notice" for all messages except
+debugging which is logged at priority "debug". The default log file is
+/usr/spool/mqueue/POPlog. These can be changed, if desired. On
+systems with 4.2 syslogging all messages are logged to the local log
+file, usually /usr/spool/mqueue/syslog.
+.SH DEBUGGING
+.PP
+The popper program will log debugging information when the -d parameter
+is specified after its invocation in the inetd.conf file. Care should
+be exercised in using this option since it generates considerable
+output in the syslog file. Alternatively, the "-t <file-name>" option
+will place debugging information into file "<file-name>" using fprintf
+instead of syslog.
+.PP
+For SunOS version 3.5, the popper program is launched by inetd from
+/etc/servers. This file does not allow you to specify command line
+arguments. Therefore, if you want to enable debugging, you can specify
+a shell script in /etc/servers to be launched instead of popper and in
+this script call popper with the desired arguments.
+.PP
+You can confirm that the POP server is running on Unix by telneting to
+port 110 (or 109 if you set it up that way). For example:
+.PP
+.nf
+%telnet myhost 110
+Trying...
+Connected to myhost.berkeley.edu.
+Escape character is '^]'.
++OK UCB Pop server (version 1.6) at myhost starting.
+quit
+Connection closed by foreign host.
+.fi
+.SH VERSION 1.7 RELEASE NOTES
+Extensive re-write of the maildrop processing code contributed by
+Viktor Dukhovni <viktor@math.princeton.edu> that greatly reduces the
+possibility that the maildrop can be corrupted as the result of
+simultaneous access by two or more processes.
+.PP
+Added "pop_dropcopy" module to create a temporary maildrop from
+the existing, standard maildrop as root before the setuid and
+setgid for the user is done. This allows the temporary maildrop
+to be created in a mail spool area that is not world read-writable.
+.PP
+This version does *not* send the sendmail "From " delimiter line
+in response to a TOP or RETR command.
+.PP
+Encased all debugging code in #ifdef DEBUG constructs. This code can
+be included by specifying the DEGUG compiler flag. Note: You still
+need to use the -d or -t option to obtain debugging output.
+.SH LIMITATIONS
+The POP server copies the user's entire maildrop to /tmp and
+then operates on that copy. If the maildrop is particularly
+large, or inadequate space is available in /tmp, then the
+server will refuse to continue and terminate the connection.
+.PP
+Simultaneous modification of a single maildrop can result in
+confusing results. For example, manipulating messages in a
+maildrop using the Unix /usr/ucb/mail command while a copy of
+it is being processed by the POP server can cause the changes
+made by one program to be lost when the other terminates. This
+problem is being worked on and will be fixed in a later
+release.
+.SH FILES
+.nf
+/usr/spool/mail mail files
+/etc/inetd.conf pop program invocation
+/etc/syslog.conf logging specifications
+.fi
+.SH "SEE ALSO"
+inetd(8),
+RFC1081,
+RFC1082
+.SH AUTHORS
+Bob Campbell, Edward Moy, Austin Shelton, Marshall T Rose, and cast of
+thousands at Rand, UDel, UCI, and elsewhere
diff --git a/crypto/heimdal/appl/popper/popper.README.release b/crypto/heimdal/appl/popper/popper.README.release
new file mode 100644
index 0000000..c0b313e
--- /dev/null
+++ b/crypto/heimdal/appl/popper/popper.README.release
@@ -0,0 +1,45 @@
+Release Notes:
+
+popper-1.831beta is no longer beta 30 July 91
+ Removed popper-1.7.tar.Z
+
+popper-1.831beta.tar.Z 03 April 91
+ Changed mkstemp to mktemp for Ultrix. Sigh.
+
+popper-1.83beta.tar.Z 02 April 91
+
+ This version makes certain that while running as root we do nothing
+ at all destructive.
+
+popper-1.82beta.tar.Z 27 March 91
+
+ This version fixes problems on Encore MultiMax and some Sun releases
+ which wouldn't allow a user to ftruncate() a file from an open
+ file descripter unless the user owns the file. Now the user
+ owns the /usr/spool/mail/.userid.pop file. Thanks to Ben Levy
+ of FTP Software and Henry Holtzman of Apple.
+
+popper-1.81beta.tar.Z 20 March 91
+
+ This version of popper is supposed to fix three problems reported
+ with various versions of popper (all called 1.7 or 1.7something).
+
+ 1) Dropped network connections meant lost mail files. Some 1.7
+ versions also risked corrupting mail files.
+
+ 2) Some versions of 1.7 created temporary drop files with world
+ read and write permissions.
+
+ 3) Some versions of 1.7 were not careful about opening the temporary
+ drop file.
+
+popper-1.7.tar.Z 09 September 90 (updated 20 March 91)
+
+ This version will exhibit the first problem listed above if it is
+ compiled with -DDEBUG and run without the "-d" (debug) flag.
+
+ If it is compiled without -DDEBUG it will exhibit only the second
+ and third bug listed above.
+
+Cliff Frost poptest@nettlesome.berkeley.edu
+UC Berkeley
diff --git a/crypto/heimdal/appl/popper/popper.c b/crypto/heimdal/appl/popper/popper.c
new file mode 100644
index 0000000..28d6ab9
--- /dev/null
+++ b/crypto/heimdal/appl/popper/popper.c
@@ -0,0 +1,117 @@
+/*
+ * Copyright (c) 1989 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#include <popper.h>
+RCSID("$Id: popper.c,v 1.15 1997/05/11 11:04:37 assar Exp $");
+
+int hangup = FALSE ;
+
+static RETSIGTYPE
+catchSIGHUP(int sig)
+{
+ hangup = TRUE ;
+
+ /* This should not be a problem on BSD systems */
+ signal(SIGHUP, catchSIGHUP);
+ signal(SIGPIPE, catchSIGHUP);
+ SIGRETURN(0);
+}
+
+int pop_timeout = POP_TIMEOUT;
+
+jmp_buf env;
+
+static RETSIGTYPE
+ring(int sig)
+{
+ longjmp(env,1);
+}
+
+/*
+ * fgets, but with a timeout
+ */
+static char *
+tgets(char *str, int size, FILE *fp, int timeout)
+{
+ signal(SIGALRM, ring);
+ alarm(timeout);
+ if (setjmp(env))
+ str = NULL;
+ else
+ str = fgets(str,size,fp);
+ alarm(0);
+ signal(SIGALRM,SIG_DFL);
+ return(str);
+}
+
+/*
+ * popper: Handle a Post Office Protocol version 3 session
+ */
+int
+main (int argc, char **argv)
+{
+ POP p;
+ state_table * s;
+ char message[MAXLINELEN];
+
+ signal(SIGHUP, catchSIGHUP);
+ signal(SIGPIPE, catchSIGHUP);
+
+ /* Start things rolling */
+ pop_init(&p,argc,argv);
+
+ /* Tell the user that we are listenting */
+ pop_msg(&p,POP_SUCCESS,
+ "UCB based pop server (version %s at %s) starting.",VERSION,p.myhost);
+
+ /* State loop. The POP server is always in a particular state in
+ which a specific suite of commands can be executed. The following
+ loop reads a line from the client, gets the command, and processes
+ it in the current context (if allowed) or rejects it. This continues
+ until the client quits or an error occurs. */
+
+ for (p.CurrentState=auth1;p.CurrentState!=halt&&p.CurrentState!=error;) {
+ if (hangup) {
+ pop_msg(&p, POP_FAILURE, "POP hangup: %s", p.myhost);
+ if (p.CurrentState > auth2 && !pop_updt(&p))
+ pop_msg(&p, POP_FAILURE,
+ "POP mailbox update failed: %s", p.myhost);
+ p.CurrentState = error;
+ } else if (tgets(message, MAXLINELEN, p.input, pop_timeout) == NULL) {
+ pop_msg(&p, POP_FAILURE, "POP timeout: %s", p.myhost);
+ if (p.CurrentState > auth2 && !pop_updt(&p))
+ pop_msg(&p,POP_FAILURE,
+ "POP mailbox update failed: %s", p.myhost);
+ p.CurrentState = error;
+ }
+ else {
+ /* Search for the command in the command/state table */
+ if ((s = pop_get_command(&p,message)) == NULL) continue;
+
+ /* Call the function associated with this command in
+ the current state */
+ if (s->function) p.CurrentState = s->result[(*s->function)(&p)];
+
+ /* Otherwise assume NOOP and send an OK message to the client */
+ else {
+ p.CurrentState = s->success_state;
+ pop_msg(&p,POP_SUCCESS,NULL);
+ }
+ }
+ }
+
+ /* Say goodbye to the client */
+ pop_msg(&p,POP_SUCCESS,"Pop server at %s signing off.",p.myhost);
+
+ /* Log the end of activity */
+ pop_log(&p,POP_PRIORITY,
+ "(v%s) Ending request from \"%s\" at %s\n",VERSION,p.client,p.ipaddr);
+
+ /* Stop logging */
+ closelog();
+
+ return(0);
+}
diff --git a/crypto/heimdal/appl/popper/popper.h b/crypto/heimdal/appl/popper/popper.h
new file mode 100644
index 0000000..22707da
--- /dev/null
+++ b/crypto/heimdal/appl/popper/popper.h
@@ -0,0 +1,347 @@
+/*
+ * Copyright (c) 1989 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ * static char copyright[] = "Copyright (c) 1990 Regents of the University of California.\nAll rights reserved.\n";
+ * static char SccsId[] = "@(#)@(#)popper.h 2.2 2.2 4/2/91";
+ *
+ */
+
+/* $Id: popper.h,v 1.49 1999/08/12 11:37:55 joda Exp $ */
+
+/*
+ * Header file for the POP programs
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#define UIDL
+#define XOVER
+#define XDELE
+#define DEBUG
+#define RETURN_PATH_HANDLING
+#endif
+
+/* Common include files */
+
+#include <stdio.h>
+#include <stdarg.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+#include <signal.h>
+#include <setjmp.h>
+#include <ctype.h>
+#ifdef HAVE_FCNTL_H
+#include <fcntl.h>
+#endif
+#ifdef HAVE_PWD_H
+#include <pwd.h>
+#endif
+#ifdef HAVE_SYS_TYPES_H
+#include <sys/types.h>
+#endif
+#ifdef HAVE_IO_H
+#include <io.h>
+#endif
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+#ifdef HAVE_SYS_STAT_H
+#include <sys/stat.h>
+#endif
+#ifdef HAVE_SYS_FILE_H
+#include <sys/file.h>
+#endif
+#ifdef TIME_WITH_SYS_TIME
+#include <sys/time.h>
+#include <time.h>
+#elif defined(HAVE_SYS_TIME_H)
+#include <sys/time.h>
+#else
+#include <time.h>
+#endif
+#ifdef HAVE_SYS_RESOURCE_H
+#include <sys/resource.h>
+#endif
+#ifdef HAVE_SYS_WAIT_H
+#include <sys/wait.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_NETDB_H
+#include <netdb.h>
+#endif
+#ifdef HAVE_ARPA_INET_H
+#include <arpa/inet.h>
+#endif
+#ifdef HAVE_SYSLOG_H
+#include <syslog.h>
+#endif
+#ifdef HAVE_SYS_SELECT_H
+#include <sys/select.h>
+#endif
+#ifdef HAVE_SYS_PARAM_H
+#include <sys/param.h>
+#endif
+#include "version.h"
+
+#ifdef SOCKS
+#include <socks.h>
+#endif
+
+#include <err.h>
+#include <roken.h>
+#include <getarg.h>
+
+#ifdef KRB4
+#include <krb.h>
+#include <prot.h>
+#endif
+#ifdef KRB5
+#include <krb5.h>
+#endif
+
+#define MAXUSERNAMELEN 65
+#define MAXDROPLEN 64
+#define MAXLINELEN 1024
+#define MAXMSGLINELEN 1024
+#define MAXCMDLEN 4
+#define MAXPARMCOUNT 10
+#define MAXPARMLEN 10
+#define ALLOC_MSGS 20
+#define MAIL_COMMAND "/usr/lib/sendmail"
+
+#define POP_FACILITY LOG_LOCAL0
+#define POP_PRIORITY LOG_NOTICE
+#define POP_DEBUG LOG_DEBUG
+#define POP_INFO LOG_INFO
+#define POP_LOGOPTS 0
+
+#ifdef HAVE_PATHS_H
+#include <paths.h>
+#endif
+#ifdef HAVE_MAILLOCK_H
+#include <maillock.h>
+#endif
+
+#ifdef OTP
+#include <otp.h>
+#endif
+
+#if defined(KRB4_MAILDIR)
+#define POP_MAILDIR KRB4_MAILDIR
+#elif defined(_PATH_MAILDIR)
+#define POP_MAILDIR _PATH_MAILDIR
+#elif defined(MAILDIR)
+#define POP_MAILDIR MAILDIR
+#else
+#define POP_MAILDIR "/usr/spool/mail"
+#endif
+
+#define POP_DROP POP_MAILDIR "/.%s.pop"
+ /* POP_TMPSIZE needs to be big enough to hold the string
+ * defined by POP_TMPDROP. POP_DROP and POP_TMPDROP
+ * must be in the same filesystem.
+ */
+#define POP_TMPDROP POP_MAILDIR "/tmpXXXXXX"
+#define POP_TMPSIZE 256
+#define POP_TMPXMIT "/tmp/xmitXXXXXX"
+#define POP_OK "+OK"
+#define POP_ERR "-ERR"
+#define POP_SUCCESS 1
+#define POP_FAILURE 0
+#define POP_TERMINATE '.'
+#define POP_TIMEOUT 120 /* timeout connection after this many secs */
+
+extern int pop_timeout;
+
+extern int hangup;
+
+#define AUTH_NONE 0
+#define AUTH_OTP 1
+
+#define pop_command pop_parm[0] /* POP command is first token */
+#define pop_subcommand pop_parm[1] /* POP XTND subcommand is the
+ second token */
+
+typedef enum { /* POP processing states */
+ auth1, /* Authorization: waiting for
+ USER command */
+ auth2, /* Authorization: waiting for
+ PASS command */
+ trans, /* Transaction */
+ update, /* Update: session ended,
+ process maildrop changes */
+ halt, /* (Halt): stop processing
+ and exit */
+ error /* (Error): something really
+ bad happened */
+} state;
+
+
+#define DEL_FLAG 1
+#define RETR_FLAG 2
+#define NEW_FLAG 4
+
+typedef struct { /* Message information */
+ int number; /* Message number relative to
+ the beginning of list */
+ long length; /* Length of message in
+ bytes */
+ int lines; /* Number of (null-terminated) lines in the message */
+ long offset; /* Offset from beginning of
+ file */
+ unsigned flags;
+
+#if defined(UIDL) || defined(XOVER)
+ char *msg_id; /* The POP UIDL uniqueifier */
+#endif
+#ifdef XOVER
+ char *subject;
+ char *from;
+ char *date;
+#endif
+ char *name;
+} MsgInfoList;
+
+#define IS_MAILDIR(P) ((P)->temp_drop[0] == '\0')
+
+typedef struct { /* POP parameter block */
+ int debug; /* Debugging requested */
+ char * myname; /* The name of this POP
+ daemon program */
+ char myhost[MaxHostNameLen]; /* The name of our host
+ computer */
+ char client[MaxHostNameLen]; /* Canonical name of client
+ computer */
+ char ipaddr[MaxHostNameLen]; /* Dotted-notation format of
+ client IP address */
+ unsigned short ipport; /* Client port for privileged
+ operations */
+ char user[MAXUSERNAMELEN]; /* Name of the POP user */
+ state CurrentState; /* The current POP operational state */
+ MsgInfoList * mlp; /* Message information list */
+ int msg_count; /* Number of messages in
+ the maildrop */
+ int msgs_deleted; /* Number of messages flagged
+ for deletion */
+ int last_msg; /* Last message touched by
+ the user */
+ long bytes_deleted; /* Number of maildrop bytes
+ flagged for deletion */
+ char drop_name[MAXDROPLEN]; /* The name of the user's
+ maildrop */
+ char temp_drop[MAXDROPLEN]; /* The name of the user's
+ temporary maildrop */
+ long drop_size; /* Size of the maildrop in
+ bytes */
+ FILE * drop; /* (Temporary) mail drop */
+ FILE * input; /* Input TCP/IP communication
+ stream */
+ FILE * output; /* Output TCP/IP communication stream */
+ FILE * trace; /* Debugging trace file */
+ char * pop_parm[MAXPARMCOUNT]; /* Parse POP parameter list */
+ int parm_count; /* Number of parameters in
+ parsed list */
+ int kerberosp; /* Using KPOP? */
+#ifdef KRB4
+ AUTH_DAT kdata;
+#endif
+#ifdef KRB5
+ krb5_context context;
+ krb5_principal principal; /* principal auth as */
+ krb5_log_facility* logf;
+#endif
+ int version; /* 4 or 5? */
+ int auth_level; /* Dont allow cleartext */
+#ifdef OTP
+ OtpContext otp_ctx; /* OTP context */
+#endif
+} POP;
+
+typedef struct { /* State information for
+ each POP command */
+ state ValidCurrentState; /* The operating state of
+ the command */
+ char * command; /* The POP command */
+ int min_parms; /* Minimum number of parms
+ for the command */
+ int max_parms; /* Maximum number of parms
+ for the command */
+ int (*function) (); /* The function that process
+ the command */
+ state result[2]; /* The resulting state after
+ command processing */
+#define success_state result[0] /* State when a command
+ succeeds */
+} state_table;
+
+typedef struct { /* Table of extensions */
+ char * subcommand; /* The POP XTND subcommand */
+ int min_parms; /* Minimum number of parms for
+ the subcommand */
+ int max_parms; /* Maximum number of parms for
+ the subcommand */
+ int (*function) (); /* The function that processes
+ the subcommand */
+} xtnd_table;
+
+int pop_dele(POP *p);
+int pop_dropcopy(POP *p, struct passwd *pwp);
+int pop_dropinfo(POP *p);
+int pop_init(POP *p,int argcount,char **argmessage);
+int pop_last(POP *p);
+int pop_list(POP *p);
+int pop_parse(POP *p, char *buf);
+int pop_pass(POP *p);
+int pop_quit(POP *p);
+int pop_rset(POP *p);
+int pop_send(POP *p);
+int pop_stat(POP *p);
+int pop_updt(POP *p);
+int pop_user(POP *p);
+#ifdef UIDL
+int pop_uidl(POP *p);
+#endif
+#ifdef XOVER
+int pop_xover(POP *p);
+#endif
+#ifdef XDELE
+int pop_xdele(POP *p);
+#endif
+int pop_help(POP *p);
+state_table *pop_get_command(POP *p, char *mp);
+void pop_lower(char *buf);
+
+int pop_log(POP *p, int stat, char *format, ...)
+#ifdef __GNUC__
+__attribute__ ((format (printf, 3, 4)))
+#endif
+;
+
+int pop_msg(POP *p, int stat, char *format, ...)
+#ifdef __GNUC__
+__attribute__ ((format (printf, 3, 4)))
+#endif
+;
+
+int pop_maildir_info (POP*);
+int pop_maildir_open (POP*, MsgInfoList*);
+int pop_maildir_update (POP*);
+
+int changeuser(POP*, struct passwd*);
+void parse_header(MsgInfoList*, char*);
+int add_missing_headers(POP*, MsgInfoList*);
diff --git a/crypto/heimdal/appl/popper/version.h b/crypto/heimdal/appl/popper/version.h
new file mode 100644
index 0000000..1b5d135
--- /dev/null
+++ b/crypto/heimdal/appl/popper/version.h
@@ -0,0 +1,19 @@
+/*
+ * Copyright (c) 1989 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ * static char copyright[] = "Copyright (c) 1990 Regents of the University of California.\nAll rights reserved.\n";
+ * static char SccsId[] = "@(#)@(#)version.h 2.6 2.6 4/3/91";
+ *
+ */
+
+/* $Id: version.h,v 1.5 1997/08/08 22:50:13 assar Exp $ */
+
+/*
+ * Current version of this POP implementation
+ */
+
+#if 0
+#define VERSION krb4_version
+#endif
OpenPOWER on IntegriCloud