Removed all POP support
authormarkus schnalke <meillo@marmaro.de>
Tue, 4 Oct 2011 13:27:47 +0000 (15:27 +0200)
committermarkus schnalke <meillo@marmaro.de>
Tue, 4 Oct 2011 13:27:47 +0000 (15:27 +0200)
To retrieve mail from POP servers use external tools, e.g. fetchmail.

20 files changed:
INSTALL
acconfig.h
configure.in
docs/COMPLETION-BASH
docs/README.SASL
docs/TODO
etc/mts.conf.in
h/msh.h
h/mts.h
h/popsbr.h [deleted file]
man/Makefile.in
man/inc.man
man/mh-chart.man
man/mh-tailor.man
man/msgchk.man
sbr/mts.c
uip/Makefile.in
uip/inc.c
uip/msgchk.c
uip/popsbr.c [deleted file]

diff --git a/INSTALL b/INSTALL
index 3c48294..506288a 100644 (file)
--- a/INSTALL
+++ b/INSTALL
@@ -64,34 +64,19 @@ need an ANSI C compiler such as gcc.
    on the local machine via SMTP.
 
    If, instead, all your mail sending and receiving occurs on a 
-   remote POP/SMTP server, you will need to look at the values of the 
-   variables "localname", "pophost", and "servers":
+   remote SMTP server, you will need to look at the values of the 
+   variables "localname" and "servers":
 
     a) "localname" defines the hostname that nmh considers local.
-       If not set, then nmh queries your OS for this value.  You will
-       want to change this if you wish your e-mail to appear as if it
-       originated on the POP server.
+       If not set, then nmh queries your OS for this value.
 
-    b) "pophost" defines the server that runs the POP daemon, and to
-       which `inc' and `msgchk' will always query for new mail.
-
-    c) "servers" defines the server to which you send outgoing SMTP
+    b) "servers" defines the server to which you send outgoing SMTP
        traffic.
 
-   If you compile with POP support, but don't want to use it exclusively,
-   you can use the `-host' and `-user' options to `inc' and `msgchk'
-   rather than hardcoding pophost in `mts.conf'.
-
    Check the `mh-tailor' man page for a list of all the available options
    for this file ("masquerade" may be of particular interest).
 
-6) If you have enabled POP support, make sure that `pop3' (or more
-   precisely the value of the define POPSERVICE in config.h) is defined
-   in the /etc/services file (or its NIS/NIS+ equivalent) on the client
-   machine.  It should be something equivalent to "110/tcp".  This might
-   have already been done when the POP daemon was installed.
-
-7) Edit the file `mhn.defaults' (installed in the nmh `etc' directory).
+6) Edit the file `mhn.defaults' (installed in the nmh `etc' directory).
    This file contains the default profile entries for the nmh command
    `mhn' and is created by the script `mhn.defaults.sh'.  This script
    will search a generic path (essentially your $PATH) for programs to
@@ -112,7 +97,7 @@ need an ANSI C compiler such as gcc.
    "MH & xmh: Email for Users and Programmers", 3rd edition, by Jerry Peek,
    on the Internet at <http://www.ics.uci.edu/~mh/book/mh/confmhn.htm>.
 
-9) Add an optional global mh.profile, if desired.  This profile should be
+7) Add an optional global mh.profile, if desired.  This profile should be
    placed in the nmh `etc' directory with the name `mh.profile'.  This
    file will be used to construct the initial .mh_profile of a new nmh
    user, but will not be consulted after that.
@@ -196,12 +181,6 @@ Options for configure
 --enable-mhe    (DEFAULT)
      Add support for the Emacs front-end `mhe'.
 
---enable-pop
-     Enable client-side support for pop.
-
---enable-apop
-     Enable client-side support for apop (Authenticated POP).
-
 --with-editor=EDITOR  (DEFAULT is vi)
      specify the full path of the default editor to use.  If this
      option is not given, then the configuration process will search
@@ -210,16 +189,6 @@ Options for configure
      nmh command `prompter'.  If you specify `prompter', then you don't
      need to give the full pathname.
 
---with-hesiod=PREFIX
-     Specify the location of Hesiod.
-
---with-krb4=PREFIX
-     Specify the location of Kerberos V4 for KPOP support. After
-     running configure, you will need to change the POPSERVICE #define in
-     config.h if you want to use KPOP exclusively (rather than being able
-     to switch between KPOP and normal POP3).  See the comments inside
-     config.h for details.
-
 --with-locking=LOCKTYPE    (DEFAULT is dot)
      Specify the locking mechanism when attempting to "inc" or
      "msgchk" a local mail spool. Valid options are "dot",
index 3649bf3..efd9f38 100644 (file)
 #define BUILTIN_FTP 1
 
 /*
- * If you enable POP support, this is the the port name that nmh will use.  Make
- * sure this is defined in your /etc/services file (or its NIS/NIS+ equivalent).
- * If you are using KPOP, you will need to change this to "kpop" unless you want
- * to be able to use both POP3 _and_ Kerberized POP and plan to use inc and
- * msgchk's -kpop switch every time in the latter case.
- */
-#define POPSERVICE "pop3"
-
-/*
  * Define the default creation modes for folders and messages.
  */
 #define DEFAULT_FOLDER_MODE "700"
index 44f07b3..6fc7f1e 100644 (file)
@@ -67,14 +67,6 @@ if test x"$enable_mhe" != x"no" -a x"$enable_nmh_mhe" != x"no"; then
     [Define to compile in support for the Emacs front-end mh-e.])dnl
 fi
 
-dnl Do you want client-side support for pop?
-AC_ARG_ENABLE(pop,
-  AS_HELP_STRING([--enable-pop], [enable client-side support for plain POP3]))
-dnl The old redundant --enable-nmh-pop is deprecated and undocumented.
-if test x"$enable_nmh_pop" = x"yes"; then
-  enable_pop=yes
-fi
-
 dnl Do you want to disable use of locale functions
 AH_TEMPLATE([LOCALE],
 [Undefine if you don't want locale features.  By default this is defined.])
@@ -87,12 +79,12 @@ AC_DEFINE(LOCALE)
 )
 
 dnl Do you want client-side support for using SASL for authentication?
-dnl Note that this code will be enabled for both POP and SMTP
+dnl Note that this code will be enabled for SMTP
 AC_ARG_WITH(cyrus-sasl, AS_HELP_STRING([--with-cyrus-sasl],
   [Enable SASL support via the Cyrus SASL library]))
 if test x"$with_cyrus_sasl" != x -a x"$with_cyrus_sasl" != x"no"; then
   AC_DEFINE(CYRUS_SASL, 1,
-    [Define to use the Cyrus SASL library for authentication of POP and SMTP.])dnl
+    [Define to use the Cyrus SASL library for authentication of SMTP.])dnl
   if test x"$with_cyrus_sasl" != xyes; then
     AC_MSG_WARN([Arguments to --with-cyrus-sasl now ignored])
     AC_MSG_WARN([Please pass the appropriate arguments to CPPFLAGS/LDFLAGS])
@@ -130,18 +122,6 @@ fi
 AC_DEFINE_UNQUOTED(BACKUP_PREFIX, "$backup_prefix",
     [The prefix that is prepended to the name of message files when they are "removed" by rmm. This should typically be `,' or `#'.])dnl
 
-dnl After we know if we're including apop and kpop support, do pop stuff
-if test x"$enable_pop" = x"yes"; then
-  AC_DEFINE(POP, 1,
-    [Define this to compile client-side support for pop into inc and msgchk.])dnl
-  POPLIB=popsbr.o
-  POPSED='/^%nmhbeginpop%/d;/^%nmhendpop%/d'
-else
-  POPSED='/^%nmhbeginpop%/,/^%nmhendpop%/d'
-fi
-AC_SUBST(POPLIB)dnl
-AC_SUBST(POPSED)dnl
-
 dnl What method of locking to use?
 AC_ARG_WITH(locking,
   AS_HELP_STRING([--with-locking=@<:@dot|fcntl|flock|lockf@:>@],
@@ -971,17 +951,6 @@ eval "nmhsysconf=${sysconfdir}"; eval "nmhsysconf=${nmhsysconf}"
 eval "nmhlib=${libdir}";         eval "nmhlib=${nmhlib}"
 eval "nmhman=${mandir}";         eval "nmhman=${nmhman}"
 
-pop_kinds=no
-if test x"$enable_pop" = x"yes"; then
-  pop_kinds="yes ("
-
-  if test x"$enable_apop" = x"yes"; then
-    pop_kinds="${pop_kinds}APOP "
-  fi
-
-  pop_kinds="${pop_kinds}POP3)"
-fi
-
 echo "
 nmh configuration
 -----------------
@@ -1003,7 +972,6 @@ default smtp servers       : ${smtpservers}
 default editor             : ${editorpath}
 default pager              : ${pagerpath}
 email address masquerading : ${masquerade}
-pop is enabled             : ${pop_kinds}
 SASL support               : ${sasl_support}
 TLS support                : ${tls_support}"
 echo ""
index b5bdfbc..e77e152 100644 (file)
@@ -65,8 +65,7 @@ _nmh()
             ;;
         inc )
             options=(-audit -noaudit -changecur -nochangecur -form -format
-                    -file -silent -nosilent -truncate -notruncate -width -host
-                    -user -pack -nopack -apop -noapop -kpop -sasl -saslmech -snoop
+                    -file -silent -nosilent -truncate -notruncate -width
                     -version -help)
             ;;
         mark )
index 24a85ab..c06568b 100644 (file)
@@ -6,10 +6,10 @@ SASL is short for the Simple Authentication and Security Layer.  Is is
 a framework for adding authentication and encryption to network protocols.
 It is described in IETF RFC 2222.
 
-This release of nmh supports SASL for POP and SMTP.  The SASL support
-is implemented using the Cyrus-SASL library.  This library can be found
-at ftp://ftp.andrew.cmu.edu/pub/cyrus-mail.  Obviously, SASL support only
-works if you use --enable-pop and the SMTP mail transport.
+This release of nmh supports SASL for SMTP.  The SASL support is
+implemented using the Cyrus-SASL library.  This library can be found at
+ftp://ftp.andrew.cmu.edu/pub/cyrus-mail.  Obviously, SASL support only
+works if you use the SMTP mail transport.
 
 This release of NMH only supports "Version 2" of the Cyrus SASL library.
 It should work with any newer Cyrus SASL release, but it was tested with
@@ -19,18 +19,17 @@ could manifest when negotiating encrypting depending on the encryption
 type you used, so a newer version of Cyrus-SASL is recommended.
 
 Currently, security layers ("encryption" in SASL-speak) are supported
-for both POP and SMTP.  This means that if your POP or SMTP server
-_and_ the selected SASL mechanism supports it, client-server
-communications will be encrypted.  In theory this should work with
-any SASL mechanism that supports security layers; it has only been
-tested with the GSSAPI mechanism.
+for SMTP.  This means that if your SMTP server _and_ the selected SASL
+mechanism supports it, client-server communications will be encrypted.
+In theory this should work with any SASL mechanism that supports security
+layers; it has only been tested with the GSSAPI mechanism.
 
 If you are curious as to whether or not your communications are actually
-encrypted or not, you can use the -snoop flag to the POP or SMTP utilities.
+encrypted or not, you can use the -snoop flag to the SMTP utilities.
 Communication that is encrypted is preceeded by an (encrypted) or
 (decrypted), depending on the direction of communication.
 
 If you would like to use the GSSAPI SASL mechanism (Kerberos V), you
-should read very carefully the documentation that comes with
-Cyrus-SASL, specifically the GSSAPI documentation.  Getting the GSSAPI
-plugin to work correctly with SASL can be "interesting" to say the least.
+should read very carefully the documentation that comes with Cyrus-SASL,
+specifically the GSSAPI documentation.  Getting the GSSAPI plugin to
+work correctly with SASL can be "interesting" to say the least.
index 97d4ef6..a9de6dd 100644 (file)
--- a/docs/TODO
+++ b/docs/TODO
@@ -52,13 +52,6 @@ ENVIRONMENT/PROFILE
 * Maybe add profile entry "Pager" to change the default pager?
 * Should nmh check for EDITOR or PAGER environment variable?
 
-POP
----
-* Clean up uip/spop.c (I dont' think it's needed any longer).
-* Need to decide if want to support APOP, RPOP, MPOP.  APOP
-  and RPOP still work, but need autoconf support added.  Does
-  anyone still use this stuff?
-
 OPTIONS
 -------
 * change switches to accept two dashes (--help)
index c3c946d..24d73f5 100644 (file)
@@ -31,8 +31,5 @@ mmdfldir: %mailspool%
 # are kept.  If this is empty, the user's login name is used.
 mmdflfil:
 
-# Hardcoded POP server name (prevents inc'ing from local mail spool).
-#pophost: localhost
-
 # List of smtp servers to try if using smtp support
 servers: %smtpservers%
diff --git a/h/msh.h b/h/msh.h
index 201c7ec..585e50a 100644 (file)
--- a/h/msh.h
+++ b/h/msh.h
@@ -24,14 +24,6 @@ struct Cmd {
 
 #define CUR (1 << (FFATTRSLOT + NUMATTRS - 1))
 
-#ifdef BPOP
-# define VIRTUAL SELECT_EMPTY
-
-# define is_virtual(mp,msgnum)    ((mp)->msgstats[msgnum] & VIRTUAL)
-# define unset_virtual(mp,msgnum) ((mp)->msgstats[msgnum] &= ~VIRTUAL)
-# define set_virtual(mp,msgnum)   ((mp)->msgstats[msgnum] |= VIRTUAL)
-#endif
-
 struct Msg {
     struct drop m_drop;
     char *m_scanl;
diff --git a/h/mts.h b/h/mts.h
index 2d2aa95..6ec3a0b 100644 (file)
--- a/h/mts.h
+++ b/h/mts.h
@@ -54,11 +54,10 @@ extern char *sendmail;
 #endif
 
 /*
- * SMTP/POP stuff
+ * SMTP stuff
  */
 extern char *clientname;
 extern char *servers;
-extern char *pophost;
 
 /*
  * Global MailDelivery File
diff --git a/h/popsbr.h b/h/popsbr.h
deleted file mode 100644 (file)
index fc06f0b..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-
-/*
- * popsbr.h -- header for POP client subroutines
- */
-
-int pop_init (char *, char *, char *, char *, char *, int, int, char *);
-int pop_fd (char *, int, char *, int);
-int pop_stat (int *, int *);
-int pop_retr (int, int (*)(char *));
-int pop_dele (int);
-int pop_noop (void);
-int pop_rset (void);
-int pop_top (int, int, int (*)(char *));
-int pop_quit (void);
-int pop_done (void);
-int pop_set (int, int, int);
-int pop_list (int, int *, int *, int *);
index c94ab00..5e99542 100644 (file)
@@ -33,9 +33,6 @@ INSTALL_DATA = @INSTALL_DATA@
 SED = sed
 SEDMAN = $(SED) -f man.sed $< > $@
 
-# sed line for editing pop information in man pages
-POPSED = @POPSED@
-
 .SUFFIXES:
 .SUFFIXES: .man .$(manext1) .$(manext5) .$(manext8)
 
@@ -109,7 +106,6 @@ man.sed: Makefile
        echo 's,%manext1%,$(manext1),g' >> $@
        echo 's,%manext5%,$(manext5),g' >> $@
        echo 's,%manext8%,$(manext8),g' >> $@
-       echo '$(POPSED)' >> $@
        echo '/%components%/r $(top_srcdir)/etc/components' >> $@
        echo ' s,%components%,,g' >> $@
        echo '/%distcomps%/r $(top_srcdir)/etc/distcomps' >> $@
index 540b378..b581ec2 100644 (file)
@@ -23,21 +23,6 @@ inc \- incorporate new mail
 .RB [ \-truncate " | " \-notruncate ]
 .RB [ \-width
 .IR columns ]
-%nmhbeginpop%
-.RB [ \-host
-.IR hostname ]
-.RB [ \-user
-.IR username ]
-.RB [ \-pack
-.IR file ]
-.RB [ \-nopack ]
-.RB [ \-proxy
-.IR command ]
-.RB [ \-sasl ]
-.RB [ \-saslmech
-.IR mechanism ]
-.RB [ \-snoop ]
-%nmhendpop%
 .RB [ \-version ]
 .RB [ \-help ]
 .ad
@@ -172,113 +157,6 @@ switch directs
 to be quiet and not ask any questions at all.  This is useful for putting
 .B inc
 in the background and going on to other things.
-%nmhbeginpop%
-.PP
-.SS "Using POP"
-.B inc
-will normally check local mail drops for mail, as covered above.  But
-if the option
-.RI \*(lq pophost \*(rq
-is set in
-.RI \*(lq mts.conf \*(rq,
-or if the
-.B \-host
-.I hostname
-switch is given, or if the
-.B $MAILHOST
-environment variable is set, then
-.B inc
-will query this POP service host for mail to incorporate.  If
-.B $MAILHOST
-is set and
-.B \-host
-is specified as well, the commandline switch will override
-the environment variable.
-.PP
-The default is for
-.B inc
-to assume that your account name on
-the POP server is the same as your current username.  To specify
-a different username, use the
-.B \-user
-.I username
-switch.
-.PP
-When using POP, you will normally need to type the password for
-your account on the POP server, in order to retrieve your messages.
-It is possible to automate this process by creating a
-.RI \*(lq .netrc \*(rq
-file containing your login account information for this POP server.
-For each POP server, this file should have a line of the following
-form.  Replace the words
-.IR mypopserver ,
-.IR mylogin ,
-and
-.I mypassword
-with your own account information.
-.PP
-.RS 5
-.B machine
-.I mypopserver
-.B login
-.I mylogin
-.B password
-.I mypassword
-.RE
-.PP
-This
-.RI \*(lq .netrc \*(rq
-file should be owned and readable only by you.
-.PP
-If passed the
-.B \-proxy
-.I command
-switch,
-.B inc
-will use the specified command to establish the connection to the POP
-server. The string
-.IR %h
-in the command will be substituted by the hostname to connect to.
-.PP
-If
-.B inc
-uses POP, then the
-.B \-pack
-.I file
-switch is considered. If given, then
-.B inc
-simply uses the POP to
-.B packf
-the user's maildrop from the POP service host to the named file.  This switch
-is provided for those users who prefer to use
-.B msh
-to read their maildrops.
-.PP
-For debugging purposes, you may give the switch
-.BR \-snoop ,
-which will allow you to watch the POP transaction take place
-between you and the POP server.
-.PP
-If
-.B nmh
-has been compiled with SASL support, the
-.B \-sasl
-switch will enable
-the use of SASL authentication.  Depending on the SASL mechanism used, this
-may require an additional password prompt from the user (but the
-.RI \*(lq .netrc \*(rq
-file can be used to store this password).  The
-.B \-saslmech
-switch can be used to select a particular SASL mechanism.
-.PP
-If SASL authentication is successful,
-.B inc
-will attempt to negotiate a security layer for session encryption.
-Encrypted traffic is labelled with `(encrypted)' and `(decrypted)'
-when viewing the POP transaction with the
-.B \-snoop
-switch.
-%nmhendpop%
 
 .SH FILES
 .fc ^ ~
@@ -314,9 +192,6 @@ mhmail(1), scan(1), mh\-mail(5), post(8)
 .RB ` \-nosilent '
 .RB ` \-truncate "' if `" \-file " name' not given, `" \-notruncate "' otherwise"
 .RB ` \-width "' defaulted to the width of the terminal"
-%nmhbeginpop%
-.RB ` \-nopack '
-%nmhendpop%
 .fi
 
 .SH CONTEXT
index 793562f..c27b8d3 100644 (file)
@@ -242,19 +242,6 @@ is equivalent to
 .RB [ \-truncate " | " \-notruncate ]
 .RB [ \-width
 .IR columns ]
-%nmhbeginpop%
-.RB [ \-host
-.IR hostname ]
-.RB [ \-user
-.IR username ]
-.RB [ \-pack
-.IR file ]
-.RB [ \-nopack ]
-.RB [ \-sasl ]
-.RB [ \-saslmech
-.IR mechanism ]
-.RB [ \-snoop ]
-%nmhendpop%
 .RB [ \-version ]
 .RB [ \-help ]
 
@@ -434,16 +421,6 @@ is equivalent to
 all/mail/nomail ]
 .RB [ \-nonotify
 all/mail/nomail ]
-%nmhbeginpop%
-.RB [ \-host
-.IR hostname ]
-.RB [ \-user
-.IR username ]
-.RB [ \-sasl ]
-.RB [ \-saslmech
-.IR mechanism ]
-.RB [ \-snoop ]
-%nmhendpop%
 .RI [ users
 \&... ]
 .RB [ \-version ]
index 15704ee..4ad381d 100644 (file)
@@ -308,18 +308,6 @@ The pathname to the
 .B sendmail
 program.
 .RE
-.SS "Post Office Protocol"
-This option is only available if you have compiled
-.B nmh
-with POP support enabled (i.e., \*(lq--enable-pop\*(rq).
-.PP
-.BR pophost :
-.RS 5
-The name of the default POP service host.  If this is not set, then
-.B nmh
-looks in the standard maildrop areas for waiting mail, otherwise
-the named POP service host is consulted.
-.RE
 \"  .SS "BBoards Delivery"
 \"  This option is only available if you compiled \fInmh\fP with
 \"  \*(lqbbdelivery:\ on\*(rq.
@@ -329,34 +317,6 @@ the named POP service host is consulted.
 \"  The local BBoards domain (a UCI hack).
 \"  .RE
 
-\"  .SS "BBoards & The POP"
-\"  These options are only available if you compiled \fInmh\fP with
-\"  \*(lqbboards:\ pop\*(rq and \*(lqpop:\ on\*(rq.
-
-\"  .PP
-\"  .BR popbbhost :
-\"  .RS 5
-\"  The POP service host which also acts as a BBoard server.  This variable
-\"  should be set on the POP BBoards client host.
-\"  .RE
-\"  .PP
-\"  .BR popbbuser :
-\"  .RS 5
-\"  The guest account on the POP/BB service host.  This should be a different
-\"  login ID than either the POP user or the BBoards user.  (The user-id
-\"  \*(lqftp\*(rq is highly recommended.)  This variable should be set on
-\"  both the POP BBoards client and service hosts.
-\"  .RE
-\"  .PP
-\"  .BR popbblist :
-\"  %etcdir%/hosts.popbb
-\"  .RS 5
-\"  A file containing of lists of hosts that are allowed to use the POP
-\"  facility to access BBoards using the guest account.  If this file is not
-\"  present, then no check is made.  This variable should be set on the POP
-\"  BBoards service host.
-\"  .RE
-
 .SS "File Locking"
 A few words on locking:
 .B nmh
index 55d4a18..fd2b0f5 100644 (file)
@@ -13,16 +13,6 @@ msgchk \- check for messages
 all/mail/nomail ]
 .RB [ \-nonotify
 all/mail/nomail ]
-%nmhbeginpop%
-.RB [ \-host
-.IR hostname ]
-.RB [ \-user
-.IR username ]
-.RB [ \-sasl ]
-.RB [ \-saslmech
-.IR mechanism ]
-.RB [ \-snoop ]
-%nmhendpop%
 .RI [ users
 \&... ]
 .RB [ \-version ]
@@ -77,80 +67,6 @@ switch directs
 .B msgchk
 to print out the last date mail was read, if this can
 be determined.
-%nmhbeginpop%
-.SS "Using POP"
-.B msgchk
-will normally check all the local mail drops, but if
-the option \*(lqpophost:\*(rq is set in the mts configuration file
-\*(lqmts.conf\*(rq, or if the
-.B \-host
-.I hostname
-switch is given,
-.B msgchk
-will query this POP service host as to the status of
-mail waiting.
-.PP
-The default is for
-.B msgchk
-to assume that your account name
-on the POP server is the same as your current username.  To specify
-a different username, use the `\-user\ username' switch.
-.PP
-When using POP, you will normally need to type the password for
-your account on the POP server, in order to retrieve your messages.
-It is possible to automate this process by creating a
-.RI \*(lq \&.netrc \*(rq
-file containing your login account information for this POP server.
-For each POP server, this file should have a line of the following
-form.  Replace the words
-.IR mypopserver ,
-.IR mylogin ,
-and
-.I mypassword
-with
-your own account information.
-.PP
-.RS 5
-machine
-.I mypopserver
-login
-.I mylogin
-password
-.I mypassword
-.RE
-.PP
-This
-.RI \*(lq \&.netrc \*(rq
-file should be owned and readable only by you.
-.PP
-For debugging purposes, there is also a switch
-.BR \-snoop ,
-which will
-allow you to watch the POP transaction take place between you and the
-POP server.
-.PP
-If
-.B nmh
-has been compiled with SASL support, the
-.B \-sasl
-switch will enable
-the use of SASL authentication.  Depending on the SASL mechanism used, this
-may require an additional password prompt from the user (but the
-.RI \*(lq \&.netrc \*(rq
-file can be used to store this password).  The
-.B \-saslmech
-switch can be used to select a particular SASL mechanism.
-.PP
-If SASL authentication is successful,
-.B inc
-will attempt to negotiate
-a security layer for session encryption.  Encrypted traffic is labelled
-with `(encrypted)' and `(decrypted)' when viewing the POP transaction
-with the
-.B \-snoop
-switch.
-%nmhendpop%
 
 .SH FILES
 .fc ^ ~
index 0e01318..93c9fa9 100644 (file)
--- a/sbr/mts.c
+++ b/sbr/mts.c
@@ -81,11 +81,10 @@ char *sendmail = SENDMAILPATH;
 #endif
 
 /*
- * SMTP/POP stuff
+ * SMTP stuff
  */
 char *clientname = NULL;
 char *servers    = "localhost \01localnet";
-char *pophost    = "";
 
 /*
  * Global MailDelivery file
@@ -130,7 +129,6 @@ static struct bind binds[] = {
 
     { "clientname",  &clientname },
     { "servers", &servers },
-    { "pophost", &pophost },
 
     { "maildelivery", &maildelivery },
     { "everyone", &everyone },
index ba22ac9..691bfe6 100644 (file)
@@ -31,7 +31,6 @@ LINTFLAGS = @LINTFLAGS@
 
 TERMLIB = @TERMLIB@
 LEXLIB  = @LEXLIB@
-POPLIB  = @POPLIB@
 
 COMPILE = $(CC) -c $(DEFS) $(INCLUDES) $(CFLAGS)
 LINK    = $(CC) $(LDFLAGS) -o $@
@@ -75,7 +74,7 @@ SRCS = ali.c aliasbr.c anno.c annosbr.c ap.c burst.c comp.c             \
        mhbuildsbr.c mhcachesbr.c mhfree.c mhl.c mhlist.c mhlistsbr.c     \
        mhlsbr.c mhmail.c mhmisc.c mhn.c mhoutsbr.c mhparam.c mhparse.c   \
        mhpath.c mhshow.c mhshowsbr.c mhstore.c mhstoresbr.c mhtest.c     \
-       msgchk.c msh.c mshcmds.c new.c packf.c pick.c picksbr.c popsbr.c \
+       msgchk.c msh.c mshcmds.c new.c packf.c pick.c picksbr.c \
        prompter.c rcvdist.c rcvpack.c rcvstore.c rcvtty.c        \
        refile.c repl.c replsbr.c rmf.c rmm.c scan.c scansbr.c send.c     \
        sendsbr.c show.c slocal.c sortm.c spost.c termsbr.c viamail.c     \
@@ -130,8 +129,8 @@ folder: folder.o $(LOCALLIBS)
 forw: forw.o whatnowproc.o whatnowsbr.o sendsbr.o annosbr.o distsbr.o $(LOCALLIBS)
        $(LINK) forw.o whatnowproc.o whatnowsbr.o sendsbr.o annosbr.o distsbr.o $(LINKLIBS)
 
-inc: inc.o scansbr.o dropsbr.o termsbr.o $(POPLIB) $(LOCALLIBS)
-       $(LINK) inc.o scansbr.o dropsbr.o termsbr.o $(POPLIB) $(LINKLIBS) $(TERMLIB)
+inc: inc.o scansbr.o dropsbr.o termsbr.o $(LOCALLIBS)
+       $(LINK) inc.o scansbr.o dropsbr.o termsbr.o $(LINKLIBS) $(TERMLIB)
 
 install-mh: install-mh.o $(LOCALLIBS)
        $(LINK) install-mh.o $(LINKLIBS)
@@ -169,8 +168,8 @@ mhstore: mhstore.o mhparse.o mhcachesbr.o mhshowsbr.o mhlistsbr.o mhstoresbr.o m
 mhtest: mhtest.o mhparse.o mhcachesbr.o mhoutsbr.o mhmisc.o mhfree.o ftpsbr.o termsbr.o md5.o $(LOCALLIBS)
        $(LINK) mhtest.o mhparse.o mhcachesbr.o mhoutsbr.o mhmisc.o mhfree.o ftpsbr.o termsbr.o md5.o $(LINKLIBS) $(TERMLIB)
 
-msgchk: msgchk.o $(POPLIB) $(LOCALLIBS)
-       $(LINK) msgchk.o $(POPLIB) $(LINKLIBS)
+msgchk: msgchk.o $(LOCALLIBS)
+       $(LINK) msgchk.o $(LINKLIBS)
 
 msh: msh.o mshcmds.o vmhsbr.o picksbr.o scansbr.o dropsbr.o mhlsbr.o termsbr.o $(LOCALLIBS)
        $(LINK) msh.o mshcmds.o vmhsbr.o picksbr.o scansbr.o dropsbr.o mhlsbr.o termsbr.o $(LINKLIBS) $(TERMLIB)
index 8f99b7b..7c91c25 100644 (file)
--- a/uip/inc.c
+++ b/uip/inc.c
 #include <h/utils.h>
 #include <fcntl.h>
 
-#ifdef POP
-# include <h/dropsbr.h>
-# include <h/popsbr.h>
-#endif
-
 #include <h/fmt_scan.h>
 #include <h/scansbr.h>
 #include <h/signals.h>
 #include <errno.h>
 #include <signal.h>
 
-#ifndef        POP
-# define POPminc(a) (a)
-#else
-# define POPminc(a)  0
-#endif
-
-#ifndef CYRUS_SASL
-# define SASLminc(a) (a)
-#else
-# define SASLminc(a)  0
-#endif
-
 static struct swit switches[] = {
 #define        AUDSW                      0
     { "audit audit-file", 0 },
@@ -70,16 +53,6 @@ static struct swit switches[] = {
     { "form formatfile", 0 },
 #define        FMTSW                      6
     { "format string", 5 },
-#define        HOSTSW                     7
-    { "host hostname", POPminc (-4) },
-#define        USERSW                     8
-    { "user username", POPminc (-4) },
-#define        PACKSW                     9
-    { "pack file", POPminc (-4) },
-#define        NPACKSW                   10
-    { "nopack", POPminc (-6) },
-#define PORTSW                   11
-    { "port name/number", POPminc (-4) },
 #define        SILSW                     12
     { "silent", 0 },
 #define        NSILSW                    13
@@ -94,46 +67,12 @@ static struct swit switches[] = {
     { "version", 0 },
 #define        HELPSW                    18
     { "help", 0 },
-#define SNOOPSW                   19
-    { "snoop", -5 },
-#define SASLSW                    20
-    { "sasl", SASLminc(-4) },
-#define SASLMECHSW                21
-    { "saslmech", SASLminc(-8) },
-#define PROXYSW                   22
-    { "proxy command", POPminc(-5) },
-    { NULL, 0 }
 };
 
-/*
- * flags for the mail source
- */
-#define INC_FILE  0
-#define INC_POP   1
-
-static int inc_type;
-static int snoop = 0;
-
-#ifdef POP
-extern char response[];
-
-static char *packfile = NULL;
-static int size;
-static long pos;
-static long start;
-static long stop;
-
-static int mbx_style = MMDF_FORMAT;
-static int pd = NOTOK;
-static FILE *pf = NULL;
-#endif /* POP */
-
 /* This is an attempt to simplify things by putting all the
  * privilege ops into macros.
  * *GROUPPRIVS() is related to handling the setgid MAIL property,
  * and only applies if MAILGROUP is defined.
- * *USERPRIVS() is related to handling the setuid root property,
- * and only applies if POP is defined [why does POP => setuid root?]
  * Basically, SAVEGROUPPRIVS() is called right at the top of main()
  * to initialise things, and then DROPGROUPPRIVS() and GETGROUPPRIVS()
  * do the obvious thing. TRYDROPGROUPPRIVS() has to be safe to call
@@ -155,15 +94,10 @@ static FILE *pf = NULL;
  */
 #ifdef MAILGROUP
 static int return_gid;
-#ifndef POP
 /* easy case; we're not setuid root, so can drop group privs
  * immediately.
  */
 #define TRYDROPGROUPPRIVS() DROPGROUPPRIVS()
-#else /* POP ie we are setuid root */
-#define TRYDROPGROUPPRIVS() \
-if (geteuid() != 0) DROPGROUPPRIVS()
-#endif
 #define DROPGROUPPRIVS() setgid(getgid())
 #define GETGROUPPRIVS() setgid(return_gid)
 #define SAVEGROUPPRIVS() return_gid = getegid()
@@ -186,11 +120,6 @@ static FILE *in;
 char *map_name(char *);
 
 static void inc_done(int) NORETURN;
-#ifdef POP
-static int pop_action(char *);
-static int pop_pack(char *);
-static int map_count(void);
-#endif
 
 
 int
@@ -199,12 +128,10 @@ main (int argc, char **argv)
     int chgflag = 1, trnflag = 1;
     int noisy = 1, width = 0;
     int hghnum = 0, msgnum = 0;
-    int sasl = 0;
     int incerr = 0; /* <0 if inc hits an error which means it should not truncate mailspool */
     char *cp, *maildir = NULL, *folder = NULL;
     char *format = NULL, *form = NULL;
-    char *host = NULL, *port = NULL, *user = NULL, *proxy = NULL;
-    char *audfile = NULL, *from = NULL, *saslmech = NULL;
+    char *audfile = NULL, *from = NULL;
     char buf[BUFSIZ], **argp, *nfs, **arguments;
     struct msgs *mp = NULL;
     struct stat st, s1;
@@ -212,12 +139,6 @@ main (int argc, char **argv)
     char b[MAXPATHLEN + 1];
     char *maildir_copy = NULL; /* copy of mail directory because the static gets overwritten */
 
-#ifdef POP
-    int nmsgs, nbytes;
-    char *pass = NULL;
-    char *MAILHOST_env_variable;
-#endif
-
 #ifdef MHE
     FILE *mhe = NULL;
 #endif
@@ -242,27 +163,6 @@ main (int argc, char **argv)
     arguments = getarguments (invo_name, argc, argv, 1);
     argp = arguments;
 
-#ifdef POP
-    /*
-     * Scheme is:
-     *        use MAILHOST environment variable if present,
-     *  else try Hesiod.
-     *  If that fails, use the default (if any)
-     *  provided by mts.conf in mts_init()
-     */
-    if ((MAILHOST_env_variable = getenv("MAILHOST")) != NULL)
-       pophost = MAILHOST_env_variable;
-    /*
-     * If there is a valid "pophost" entry in mts.conf,
-     * then use it as the default host.
-     */
-    if (pophost && *pophost)
-       host = pophost;
-
-    if ((cp = getenv ("MHPOPDEBUG")) && *cp)
-       snoop++;
-#endif /* POP */
-
     while ((cp = *argp++)) {
        if (*cp == '-') {
            switch (smatch (++cp, switches)) {
@@ -346,53 +246,6 @@ main (int argc, char **argv)
                    adios (NULL, "missing argument to %s", argp[-2]);
                width = atoi (cp);
                continue;
-
-           case HOSTSW:
-               if (!(host = *argp++) || *host == '-')
-                   adios (NULL, "missing argument to %s", argp[-2]);
-               continue;
-
-           case PORTSW:
-               if (!(host = *argp++) || *port == '-')
-                   adios (NULL, "missing argument to %s", argp[-2]);
-               continue;
-
-           case USERSW:
-               if (!(user = *argp++) || *user == '-')
-                   adios (NULL, "missing argument to %s", argp[-2]);
-               continue;
-
-           case PACKSW:
-#ifndef        POP
-               if (!(cp = *argp++) || *cp == '-')
-                   adios (NULL, "missing argument to %s", argp[-2]);
-#else /* POP */
-               if (!(packfile = *argp++) || *packfile == '-')
-                   adios (NULL, "missing argument to %s", argp[-2]);
-#endif /* POP */
-               continue;
-           case NPACKSW:
-#ifdef POP
-               packfile = NULL;
-#endif /* POP */
-               continue;
-
-           case SNOOPSW:
-               snoop++;
-               continue;
-       
-           case SASLSW:
-               sasl++;
-               continue;
-       
-           case SASLMECHSW:
-               if (!(saslmech = *argp++) || *saslmech == '-')
-                   adios (NULL, "missing argument to %s", argp[-2]);
-               continue;
-           case PROXYSW:
-               if (!(proxy = *argp++) || *proxy == '-')
-                   adios (NULL, "missing argument to %s", argp[-2]);
-               continue;
            }
        }
        if (*cp == '+' || *cp == '@') {
@@ -408,86 +261,29 @@ main (int argc, char **argv)
     /* NOTE: above this point you should use TRYDROPGROUPPRIVS(),
      * not DROPGROUPPRIVS().
      */
-#ifdef POP
-    if (host && !*host)
-       host = NULL;
-#endif /* POP */
-
     /* guarantee dropping group priveleges; we might not have done so earlier */
     DROPGROUPPRIVS();
 
     /*
-     * Where are we getting the new mail?
-     */
-    if (from)
-       inc_type = INC_FILE;
-#ifdef POP
-    else if (host)
-       inc_type = INC_POP;
-#endif
-    else
-       inc_type = INC_FILE;
-
-#ifdef POP
-    /*
-     * Are we getting the mail from
-     * a POP server?
-     */
-    if (inc_type == INC_POP) {
-       if (user == NULL)
-           user = getusername ();
-       if (sasl)
-           pass = getusername ();
-       else
-           ruserpass (host, &user, &pass);
-
-       /*
-        * initialize POP connection
-        */
-       if (pop_init (host, port, user, pass, proxy, snoop, sasl,
-                     saslmech) == NOTOK)
-           adios (NULL, "%s", response);
-
-       /* Check if there are any messages */
-       if (pop_stat (&nmsgs, &nbytes) == NOTOK)
-           adios (NULL, "%s", response);
-
-       if (nmsgs == 0) {
-           pop_quit();
-           adios (NULL, "no mail to incorporate");
-       }
-    }
-#endif /* POP */
-
-    /*
      * We will get the mail from a file
      * (typically the standard maildrop)
      */
-
-    if (inc_type == INC_FILE) {
-       if (from)
-           newmail = from;
-       else if ((newmail = getenv ("MAILDROP")) && *newmail)
-           newmail = m_mailpath (newmail);
-       else if ((newmail = context_find ("maildrop")) && *newmail)
-           newmail = m_mailpath (newmail);
-       else {
-           newmail = concat (MAILDIR, "/", MAILFIL, NULL);
-       }
-       if (stat (newmail, &s1) == NOTOK || s1.st_size == 0)
-           adios (NULL, "no mail to incorporate");
-
-       if ((cp = strdup(newmail)) == (char *)0)
-           adios (NULL, "error allocating memory to copy newmail");
-
-       newmail = cp;
+    if (from)
+       newmail = from;
+    else if ((newmail = getenv ("MAILDROP")) && *newmail)
+       newmail = m_mailpath (newmail);
+    else if ((newmail = context_find ("maildrop")) && *newmail)
+       newmail = m_mailpath (newmail);
+    else {
+       newmail = concat (MAILDIR, "/", MAILFIL, NULL);
     }
+    if (stat (newmail, &s1) == NOTOK || s1.st_size == 0)
+       adios (NULL, "no mail to incorporate");
+
+    if ((cp = strdup(newmail)) == (char *)0)
+       adios (NULL, "error allocating memory to copy newmail");
 
-#ifdef POP
-    /* skip the folder setup */
-    if ((inc_type == INC_POP) && packfile)
-       goto go_to_it;
-#endif /* POP */
+    newmail = cp;
 
     if (!context_find ("path"))
        free (path ("./", TFOLDER));
@@ -515,31 +311,25 @@ main (int argc, char **argv)
     if (!(mp = folder_read (folder)))
        adios (NULL, "unable to read folder %s", folder);
 
-#ifdef POP
-go_to_it:
-#endif /* POP */
-
-    if (inc_type == INC_FILE) {
-       if (access (newmail, W_OK) != NOTOK) {
-           locked++;
-           if (trnflag) {
-               SIGNAL (SIGHUP, SIG_IGN);
-               SIGNAL (SIGINT, SIG_IGN);
-               SIGNAL (SIGQUIT, SIG_IGN);
-               SIGNAL (SIGTERM, SIG_IGN);
-           }
+    if (access (newmail, W_OK) != NOTOK) {
+        locked++;
+        if (trnflag) {
+       SIGNAL (SIGHUP, SIG_IGN);
+       SIGNAL (SIGINT, SIG_IGN);
+       SIGNAL (SIGQUIT, SIG_IGN);
+       SIGNAL (SIGTERM, SIG_IGN);
+    }
 
-            GETGROUPPRIVS();       /* Reset gid to lock mail file */
-            in = lkfopen (newmail, "r");
-            DROPGROUPPRIVS();
-            if (in == NULL)
-               adios (NULL, "unable to lock and fopen %s", newmail);
-           fstat (fileno(in), &s1);
-       } else {
-           trnflag = 0;
-           if ((in = fopen (newmail, "r")) == NULL)
-               adios (newmail, "unable to read");
-       }
+    GETGROUPPRIVS();       /* Reset gid to lock mail file */
+    in = lkfopen (newmail, "r");
+    DROPGROUPPRIVS();
+    if (in == NULL)
+       adios (NULL, "unable to lock and fopen %s", newmail);
+        fstat (fileno(in), &s1);
+    } else {
+        trnflag = 0;
+        if ((in = fopen (newmail, "r")) == NULL)
+       adios (newmail, "unable to read");
     }
 
     /* This shouldn't be necessary but it can't hurt. */
@@ -554,15 +344,8 @@ go_to_it:
        else if (i == NOTOK)
            chmod (audfile, m_gmprot ());
 
-#ifdef POP
-       fprintf (aud, from ? "<<inc>> %s -ms %s\n"
-                : host ? "<<inc>> %s -host %s -user %s\n"
-                : "<<inc>> %s\n",
-                dtimenow (0), from ? from : host, user);
-#else /* POP */
        fprintf (aud, from ? "<<inc>> %s  -ms %s\n" : "<<inc>> %s\n",
                 dtimenow (0), from);
-#endif /* POP */
     }
 
 #ifdef MHE
@@ -587,227 +370,76 @@ go_to_it:
        fflush (stdout);
     }
 
-#ifdef POP
-    /*
-     * Get the mail from a POP server
-     */
-    if (inc_type == INC_POP) {
-       int i;
-       if (packfile) {
-           packfile = path (packfile, TFILE);
-           if (stat (packfile, &st) == NOTOK) {
-               if (errno != ENOENT)
-                   adios (packfile, "error on file");
-               cp = concat ("Create file \"", packfile, "\"? ", NULL);
-               if (noisy && !getanswer (cp))
-                   done (1);
-               free (cp);
-           }
-           msgnum = map_count ();
-           if ((pd = mbx_open (packfile, mbx_style, getuid(), getgid(), m_gmprot()))
-               == NOTOK)
-               adios (packfile, "unable to open");
-           if ((pf = fdopen (pd, "w+")) == NULL)
-               adios (NULL, "unable to fdopen %s", packfile);
-       } else {
-           hghnum = msgnum = mp->hghmsg;
-           /*
-            * Check if we have enough message space for all the new
-            * messages.  If not, then realloc the folder and add enough
-            * space for all new messages plus 10 additional slots.
-            */
-           if (mp->hghmsg + nmsgs >= mp->hghoff
-               && !(mp = folder_realloc (mp, mp->lowoff, mp->hghmsg + nmsgs + 10)))
-               adios (NULL, "unable to allocate folder storage");
-       }
-
-       for (i = 1; i <= nmsgs; i++) {
-           msgnum++;
-           if (packfile) {
-               fseek (pf, 0L, SEEK_CUR);
-               pos = ftell (pf);
-               size = 0;
-               fwrite (mmdlm1, 1, strlen (mmdlm1), pf);
-               start = ftell (pf);
-
-               if (pop_retr (i, pop_pack) == NOTOK)
-                   adios (NULL, "%s", response);
-
-               fseek (pf, 0L, SEEK_CUR);
-               stop = ftell (pf);
-               if (fflush (pf))
-                   adios (packfile, "write error on");
-               fseek (pf, start, SEEK_SET);
-           } else {
-               cp = getcpy (m_name (msgnum));
-               if ((pf = fopen (cp, "w+")) == NULL)
-                   adios (cp, "unable to write");
-               chmod (cp, m_gmprot ());
-               start = stop = 0L;
-
-               if (pop_retr (i, pop_action) == NOTOK)
-                   adios (NULL, "%s", response);
-
-               if (fflush (pf))
-                   adios (cp, "write error on");
-               fseek (pf, 0L, SEEK_SET);
-           }
-           switch (incerr = scan (pf, msgnum, 0, nfs, width,
-                             packfile ? 0 : msgnum == mp->hghmsg + 1 && chgflag,
-                             1, NULL, stop - start, noisy)) {
-           case SCNEOF: 
-               printf ("%*d  empty\n", DMAXFOLDER, msgnum);
-               break;
-
-           case SCNFAT:
-               trnflag = 0;
-               noisy++;
-               /* advise (cp, "unable to read"); already advised */
-               /* fall thru */
-
-           case SCNERR:
-           case SCNNUM: 
-               break;
-
-           case SCNMSG: 
-           case SCNENC:
-           default: 
-               if (aud)
-                   fputs (scanl, aud);
-# ifdef MHE
-               if (mhe)
-                   fputs (scanl, mhe);
-# endif /* MHE */
-               if (noisy)
-                   fflush (stdout);
-               if (!packfile) {
-                   clear_msg_flags (mp, msgnum);
-                   set_exists (mp, msgnum);
-                   set_unseen (mp, msgnum);
-                   mp->msgflags |= SEQMOD;
-               }
-               break;
-           }
-           if (packfile) {
-               fseek (pf, stop, SEEK_SET);
-               fwrite (mmdlm2, 1, strlen (mmdlm2), pf);
-               if (fflush (pf) || ferror (pf)) {
-                   int e = errno;
-                   pop_quit ();
-                   errno = e;
-                   adios (packfile, "write error on");
-               }
-               map_write (packfile, pd, 0, 0L, start, stop, pos, size, noisy);
-           } else {
-               if (ferror(pf) || fclose (pf)) {
-                   int e = errno;
-                   unlink (cp);
-                   pop_quit ();
-                   errno = e;
-                   adios (cp, "write error on");
-               }
-               free (cp);
-           }
-
-           if (trnflag && pop_dele (i) == NOTOK)
-               adios (NULL, "%s", response);
-       }
-
-       if (pop_quit () == NOTOK)
-           adios (NULL, "%s", response);
-       if (packfile) {
-           mbx_close (packfile, pd);
-           pd = NOTOK;
-       }
-    }
-#endif /* POP */
-
     /*
      * Get the mail from file (usually mail spool)
      */
-    if (inc_type == INC_FILE) {
-       m_unknown (in);         /* the MAGIC invocation... */
-       hghnum = msgnum = mp->hghmsg;
-       for (;;) {
-           /*
-            * Check if we need to allocate more space for message status.
-            * If so, then add space for an additional 100 messages.
-            */
-           if (msgnum >= mp->hghoff
-               && !(mp = folder_realloc (mp, mp->lowoff, mp->hghoff + 100))) {
-               advise (NULL, "unable to allocate folder storage");
-               incerr = NOTOK;
-               break;
-           }
-
-#if 0
-           /* copy file from spool to tmp file */
-           tmpfilenam = m_scratch ("", invo_name);
-           if ((fd = creat (tmpfilenam, m_gmprot ())) == NOTOK)
-               adios (tmpfilenam, "unable to create");
-           chmod (tmpfilenam, m_gmprot ());
-           if (!(in2 = fdopen (fd, "r+")))
-               adios (tmpfilenam, "unable to access");
-           cpymsg (in, in2);
-
-           /* link message into folder */
-           newmsg = folder_addmsg(mp, tmpfilenam);
-#endif
-           /* create scanline for new message */
-           switch (incerr = scan (in, msgnum + 1, msgnum + 1, nfs, width,
-                             msgnum == hghnum && chgflag, 1, NULL, 0L, noisy)) {
-           case SCNFAT:
-           case SCNEOF: 
-               break;
-
-           case SCNERR:
-               if (aud)
-                   fputs ("inc aborted!\n", aud);
-               advise (NULL, "aborted!");      /* doesn't clean up locks! */
-               break;
-
-           case SCNNUM: 
-               advise (NULL, "BUG in %s, number out of range", invo_name);
-               break;
-
-           default: 
-               advise (NULL, "BUG in %s, scan() botch (%d)", invo_name, incerr);
-               break;
-
-           case SCNMSG:
-           case SCNENC:
-               /*
-                *  Run the external program hook on the message.
-                */
-
-               (void)snprintf(b, sizeof (b), "%s/%d", maildir_copy, msgnum + 1);
-               (void)ext_hook("add-hook", b, (char *)0);
-
-               if (aud)
-                   fputs (scanl, aud);
+    m_unknown (in);            /* the MAGIC invocation... */
+    hghnum = msgnum = mp->hghmsg;
+    for (;;) {
+        /*
+         * Check if we need to allocate more space for message status.
+         * If so, then add space for an additional 100 messages.
+         */
+        if (msgnum >= mp->hghoff
+           && !(mp = folder_realloc (mp, mp->lowoff, mp->hghoff + 100))) {
+           advise (NULL, "unable to allocate folder storage");
+           incerr = NOTOK;
+           break;
+        }
+
+        /* create scanline for new message */
+        switch (incerr = scan (in, msgnum + 1, msgnum + 1, nfs, width,
+                     msgnum == hghnum && chgflag, 1, NULL, 0L, noisy)) {
+        case SCNFAT:
+        case SCNEOF: 
+       break;
+
+        case SCNERR:
+       if (aud)
+           fputs ("inc aborted!\n", aud);
+       advise (NULL, "aborted!");      /* doesn't clean up locks! */
+       break;
+
+        case SCNNUM: 
+       advise (NULL, "BUG in %s, number out of range", invo_name);
+       break;
+
+        default: 
+       advise (NULL, "BUG in %s, scan() botch (%d)", invo_name, incerr);
+       break;
+
+        case SCNMSG:
+        case SCNENC:
+       /*
+        *  Run the external program hook on the message.
+        */
+
+       (void)snprintf(b, sizeof (b), "%s/%d", maildir_copy, msgnum + 1);
+       (void)ext_hook("add-hook", b, (char *)0);
+
+       if (aud)
+           fputs (scanl, aud);
 #ifdef MHE
-               if (mhe)
-                   fputs (scanl, mhe);
+       if (mhe)
+           fputs (scanl, mhe);
 #endif /* MHE */
-               if (noisy)
-                   fflush (stdout);
-
-               msgnum++;
-               mp->hghmsg++;
-               mp->nummsg++;
-               if (mp->lowmsg == 0) mp->lowmsg = 1;
-
-               clear_msg_flags (mp, msgnum);
-               set_exists (mp, msgnum);
-               set_unseen (mp, msgnum);
-               mp->msgflags |= SEQMOD;
-               continue;
-           }
-           /* If we get here there was some sort of error from scan(),
-            * so stop processing anything more from the spool.
-            */
-           break;
-       }
+       if (noisy)
+           fflush (stdout);
+           msgnum++;
+           mp->hghmsg++;
+           mp->nummsg++;
+           if (mp->lowmsg == 0)
+               mp->lowmsg = 1;
+           clear_msg_flags (mp, msgnum);
+           set_exists (mp, msgnum);
+           set_unseen (mp, msgnum);
+           mp->msgflags |= SEQMOD;
+           continue;
+        }
+        /* If we get here there was some sort of error from scan(),
+         * so stop processing anything more from the spool.
+         */
+        break;
     }
 
     if (incerr < 0) {          /* error */
@@ -832,30 +464,23 @@ go_to_it:
     if (noisy)
        fflush (stdout);
 
-#ifdef POP
-    if ((inc_type == INC_POP) && packfile)
-       done (0);
-#endif /* POP */
-
     /*
      * truncate file we are incorporating from
      */
-    if (inc_type == INC_FILE) {
-       if (trnflag) {
-           if (stat (newmail, &st) != NOTOK && s1.st_mtime != st.st_mtime)
-               advise (NULL, "new messages have arrived!\007");
-           else {
-               int newfd;
-               if ((newfd = creat (newmail, 0600)) != NOTOK)
-                   close (newfd);
-               else
-                   admonish (newmail, "error zero'ing");
-               unlink(map_name(newmail));
-           }
-       } else {
-           if (noisy)
-               printf ("%s not zero'd\n", newmail);
-       }
+    if (trnflag) {
+        if (stat (newmail, &st) != NOTOK && s1.st_mtime != st.st_mtime)
+           advise (NULL, "new messages have arrived!\007");
+        else {
+           int newfd;
+           if ((newfd = creat (newmail, 0600)) != NOTOK)
+               close (newfd);
+           else
+               admonish (newmail, "error zero'ing");
+           unlink(map_name(newmail));
+        }
+    } else {
+        if (noisy)
+           printf ("%s not zero'd\n", newmail);
     }
 
     if (msgnum == hghnum) {
@@ -874,14 +499,12 @@ go_to_it:
     /*
      * unlock the mail spool
      */
-    if (inc_type == INC_FILE) {
-       if (locked) {
-           GETGROUPPRIVS();        /* Be sure we can unlock mail file */
-           (void) lkfclose (in, newmail); in = NULL;
-           DROPGROUPPRIVS();       /* And then return us to normal privileges */
-       } else {
-           fclose (in); in = NULL;
-       }
+    if (locked) {
+        GETGROUPPRIVS();        /* Be sure we can unlock mail file */
+        (void) lkfclose (in, newmail); in = NULL;
+        DROPGROUPPRIVS();       /* And then return us to normal privileges */
+    } else {
+        fclose (in); in = NULL;
     }
 
     seq_setunseen (mp, 0);     /* set the Unseen-Sequence */
@@ -891,47 +514,9 @@ go_to_it:
     return 1;
 }
 
-
-#if 0
-
-/*
- * Copy message message from spool into
- * temporary file.  Massage the "From " line
- * while copying.
- */
-
-cpymsg (FILE *in, FILE *out)
-{
-    int state;
-    char *tmpbuf, name[NAMESZ];
-
-    for (;;) {
-       state = m_getfld (state, name, tmpbuf, rlwidth, in);
-       switch (state) {
-       case FLD:
-       case FLDPLUS:
-           break;
-       case BODY:
-           break;
-       case LENERR:
-       case FMTERR:
-           break;
-       case FILEEOF:
-           break;
-       default:
-       }
-    }
-}
-#endif /* if 0 */
-
-
 static void
 inc_done (int status)
 {
-#ifdef POP
-    if (packfile && pd != NOTOK)
-       mbx_close (packfile, pd);
-#endif /* POP */
     if (locked)
     {
         GETGROUPPRIVS();
@@ -940,49 +525,3 @@ inc_done (int status)
     }
     exit (status);
 }
-
-#ifdef POP
-static int
-pop_action (char *s)
-{
-    fprintf (pf, "%s\n", s);
-    stop += strlen (s) + 1;
-    return 0;  /* Is return value used?  This was missing before 1999-07-15. */
-}
-
-static int
-pop_pack (char *s)
-{
-    int j;
-    char buffer[BUFSIZ];
-
-    snprintf (buffer, sizeof(buffer), "%s\n", s);
-    for (j = 0; (j = stringdex (mmdlm1, buffer)) >= 0; buffer[j]++)
-       continue;
-    for (j = 0; (j = stringdex (mmdlm2, buffer)) >= 0; buffer[j]++)
-       continue;
-    fputs (buffer, pf);
-    size += strlen (buffer) + 1;
-    return 0;  /* Is return value used?  This was missing before 1999-07-15. */
-}
-
-static int
-map_count (void)
-{
-    int md;
-    char *cp;
-    struct drop d;
-    struct stat st;
-
-    if (stat (packfile, &st) == NOTOK)
-       return 0;
-    if ((md = open (cp = map_name (packfile), O_RDONLY)) == NOTOK
-           || map_chk (cp, md, &d, (long) st.st_size, 1)) {
-       if (md != NOTOK)
-           close (md);
-       return 0;
-    }
-    close (md);
-    return (d.d_id);
-}
-#endif /* POP */
index 9b56649..7ee5df5 100644 (file)
 #include <h/tws.h>
 #include <pwd.h>
 
-#ifdef POP
-# include <h/popsbr.h>
-#endif
-
-#ifndef        POP
-# define POPminc(a) (a)
-#else
-# define POPminc(a)  0
-#endif
-
-#ifndef CYRUS_SASL
-# define SASLminc(a) (a)
-#else
-# define SASLminc(a)  0
-#endif
-
 static struct swit switches[] = {
 #define        DATESW                   0
     { "date", 0 },
@@ -37,25 +21,10 @@ static struct swit switches[] = {
     { "notify type", 0 },
 #define        NNOTESW                  3
     { "nonotify type", 0 },
-#define        HOSTSW                   4
-    { "host hostname", POPminc (-4) },
-#define        USERSW                   5
-    { "user username", POPminc (-4) },
-#define PORTSW                  6
-    { "port name/number", POPminc(-4) },
 #define VERSIONSW                7
     { "version", 0 },
 #define        HELPSW                   8
     { "help", 0 },
-#define SNOOPSW                  9
-    { "snoop", -5 },
-#define SASLSW                  10
-    { "sasl", SASLminc(-4) },
-#define SASLMECHSW             11
-    { "saslmech", SASLminc(-5) },
-#define PROXYSW                12
-    { "proxy command", POPminc(-5) },
-    { NULL, 0 }
 };
 
 /*
@@ -84,29 +53,19 @@ static struct swit switches[] = {
 static int donote (char *, int);
 static int checkmail (char *, char *, int, int, int);
 
-#ifdef POP
-static int remotemail (char *, char *, char *, char *, int, int, int, int,
-                      char *);
-#endif
-
 
 int
 main (int argc, char **argv)
 {
     int datesw = 1, notifysw = NT_ALL;
-    int status = 0, sasl = 0;
-    int snoop = 0, vecp = 0;
+    int status = 0;
+    int vecp = 0;
     uid_t uid;
-    char *cp, *host = NULL, *port = NULL, *user, *proxy = NULL; 
-    char buf[BUFSIZ], *saslmech = NULL; 
+    char buf[BUFSIZ]; 
+    char *user, *cp;
     char **argp, **arguments, *vec[MAXVEC];
     struct passwd *pw;
 
-#ifdef HESIOD
-    struct hes_postoffice *po;
-    char *tmphost;
-#endif
-
 #ifdef LOCALE
     setlocale(LC_ALL, "");
 #endif
@@ -122,11 +81,6 @@ main (int argc, char **argv)
     arguments = getarguments (invo_name, argc, argv, 1);
     argp = arguments;
 
-#ifdef POP
-    if ((cp = getenv ("MHPOPDEBUG")) && *cp)
-       snoop++;
-#endif
-
     while ((cp = *argp++)) {
        if (*cp == '-') {
            switch (smatch (++cp, switches)) {
@@ -162,43 +116,6 @@ main (int argc, char **argv)
                        adios (NULL, "missing argument to %s", argp[-2]);
                    notifysw &= ~donote (cp, 0);
                    continue;
-
-               case HOSTSW: 
-                   if (!(host = *argp++) || *host == '-')
-                       adios (NULL, "missing argument to %s", argp[-2]);
-                   continue;
-
-               case PORTSW:
-                   if (!(port = *argp++) || *port == '-')
-                       adios (NULL, "missing argument to %s", argp[-2]);
-               continue;
-
-               case USERSW: 
-                   if (!(cp = *argp++) || *cp == '-')
-                       adios (NULL, "missing argument to %s", argp[-2]);
-                   if (vecp >= MAXVEC-1)
-                       adios (NULL, "you can only check %d users at a time", MAXVEC-1);
-                   else
-                       vec[vecp++] = cp;
-                   continue;
-
-               case SNOOPSW:
-                   snoop++;
-                   continue;
-
-               case SASLSW:
-                   sasl++;
-                   continue;
-               
-               case SASLMECHSW:
-                   if (!(saslmech = *argp++) || *saslmech == '-')
-                       adios (NULL, "missing argument to %s", argp[-2]);
-                   continue;
-
-               case PROXYSW:
-                   if (!(proxy = *argp++) || *proxy == '-')
-                       adios (NULL, "missing argument to %s", argp[-2]);
-                   continue;
            }
        }
        if (vecp >= MAXVEC-1)
@@ -207,38 +124,9 @@ main (int argc, char **argv)
            vec[vecp++] = cp;
     }
 
-#ifdef POP
-    /*
-     * If -host is not specified by user
-     */
-    if (!host || !*host) {
-       /*
-        * If "pophost" is specified in mts.conf,
-        * use it as default value.
-        */
-       if (pophost && *pophost)
-           host = pophost;
-    }
-    if (!host || !*host)
-       host = NULL;
-#endif /* POP */
-
     if (vecp != 0)
        vec[vecp] = NULL;
 
-#ifdef POP
-    if (host) {
-       if (vecp == 0) {
-           status = remotemail (host, port, user, proxy, notifysw, 1,
-                                snoop, sasl, saslmech);
-       } else {
-           for (vecp = 0; vec[vecp]; vecp++)
-               status += remotemail (host, port, vec[vecp], proxy, notifysw, 0,
-                                     snoop, sasl, saslmech);
-       }
-    } else {
-#endif /* POP */
-
     if (vecp == 0) {
        char *home;
 
@@ -258,9 +146,6 @@ main (int argc, char **argv)
                advise (NULL, "no such user as %s", vec[vecp]);
        }
     }
-#ifdef POP
-    }          /* host == NULL */
-#endif
 
     done (status);
     return 1;
@@ -349,54 +234,3 @@ checkmail (char *user, char *home, int datesw, int notifysw, int personal)
 
     return status;
 }
-
-
-#ifdef POP
-extern char response[];
-
-static int
-remotemail (char *host, char *port, char *user, char *proxy, int notifysw,
-           int personal, int snoop, int sasl, char *saslmech)
-{
-    int nmsgs, nbytes, status;
-    char *pass = NULL;
-
-    if (user == NULL)
-       user = getusername ();
-    if (sasl)
-       pass = getusername ();
-    else
-       ruserpass (host, &user, &pass);
-
-    /* open the POP connection */
-    if (pop_init (host, port, user, pass, proxy, snoop, sasl, saslmech) == NOTOK
-           || pop_stat (&nmsgs, &nbytes) == NOTOK      /* check for messages  */
-           || pop_quit () == NOTOK) {                  /* quit POP connection */
-       advise (NULL, "%s", response);
-       return 1;
-    }
-
-    if (nmsgs) {
-       if (notifysw & NT_MAIL) {
-           printf (personal ? "You have " : "%s has ", user);
-           printf ("%d message%s (%d bytes)",
-                   nmsgs, nmsgs != 1 ? "s" : "", nbytes);
-       }
-       else
-           notifysw = 0;
-
-       status = 0;
-    } else {
-       if (notifysw & NT_NMAI)
-           printf (personal ? "You don't %s%s" : "%s doesn't %s",
-                   personal ? "" : user, "have any mail waiting");
-       else
-           notifysw = 0;
-       status = 1;
-    }
-    if (notifysw)
-       printf (" on %s\n", host);
-
-    return status;
-}
-#endif /* POP */
diff --git a/uip/popsbr.c b/uip/popsbr.c
deleted file mode 100644 (file)
index 2d03efd..0000000
+++ /dev/null
@@ -1,962 +0,0 @@
-/*
- * popsbr.c -- POP client subroutines
- *
- * This code is Copyright (c) 2002, by the authors of nmh.  See the
- * COPYRIGHT file in the root directory of the nmh distribution for
- * complete copyright information.
- */
-
-#include <h/mh.h>
-#include <h/utils.h>
-
-#ifdef CYRUS_SASL
-# include <sasl/sasl.h>
-# include <sasl/saslutil.h>
-#endif /* CYRUS_SASL */
-
-#include <h/popsbr.h>
-#include <h/signals.h>
-#include <signal.h>
-#include <errno.h>
-
-#define        TRM     "."
-#define        TRMLEN  (sizeof TRM - 1)
-
-static int poprint = 0;
-static int pophack = 0;
-
-char response[BUFSIZ];
-
-static FILE *input;
-static FILE *output;
-
-#ifdef CYRUS_SASL
-static sasl_conn_t *conn;      /* SASL connection state */
-static int sasl_complete = 0;  /* Has sasl authentication succeeded? */
-static int maxoutbuf;          /* Maximum output buffer size */
-static sasl_ssf_t sasl_ssf = 0;        /* Security strength factor */
-static int sasl_get_user(void *, int, const char **, unsigned *);
-static int sasl_get_pass(sasl_conn_t *, void *, int, sasl_secret_t **);
-struct pass_context {
-    char *user;
-    char *host;
-};
-
-static sasl_callback_t callbacks[] = {
-    { SASL_CB_USER, sasl_get_user, NULL },
-#define POP_SASL_CB_N_USER 0
-    { SASL_CB_PASS, sasl_get_pass, NULL },
-#define POP_SASL_CB_N_PASS 1
-    { SASL_CB_LOG, NULL, NULL },
-    { SASL_CB_LIST_END, NULL, NULL },
-
-#define SASL_BUFFER_SIZE 262144
-};
-#else /* CYRUS_SASL */
-# define sasl_fgetc fgetc
-#endif /* CYRUS_SASL */
-
-/*
- * static prototypes
- */
-
-static int command(const char *, ...);
-static int multiline(void);
-
-#ifdef CYRUS_SASL
-static int pop_auth_sasl(char *, char *, char *);
-static int sasl_fgetc(FILE *);
-#endif /* CYRUS_SASL */
-
-static int traverse (int (*)(char *), const char *, ...);
-static int vcommand(const char *, va_list);
-static int sasl_getline (char *, int, FILE *);
-static int putline (char *, FILE *);
-
-
-#ifdef CYRUS_SASL
-/*
- * This function implements the AUTH command for various SASL mechanisms
- *
- * We do the whole SASL dialog here.  If this completes, then we've
- * authenticated successfully and have (possibly) negotiated a security
- * layer.
- */
-
-int
-pop_auth_sasl(char *user, char *host, char *mech)
-{
-    int result, status, sasl_capability = 0;
-    unsigned int buflen, outlen;
-    char server_mechs[256], *buf, outbuf[BUFSIZ];
-    const char *chosen_mech;
-    sasl_security_properties_t secprops;
-    struct pass_context p_context;
-    sasl_ssf_t *ssf;
-    int *moutbuf;
-
-    /*
-     * First off, we're going to send the CAPA command to see if we can
-     * even support the AUTH command, and if we do, then we'll get a
-     * list of mechanisms the server supports.  If we don't support
-     * the CAPA command, then it's unlikely that we will support
-     * SASL
-     */
-
-    if (command("CAPA") == NOTOK) {
-       snprintf(response, sizeof(response),
-                "The POP CAPA command failed; POP server does not "
-                "support SASL");
-       return NOTOK;
-    }
-
-    while ((status = multiline()) != DONE)
-       switch (status) {
-       case NOTOK:
-           return NOTOK;
-           break;
-       case DONE:      /* Shouldn't be possible, but just in case */
-           break;
-       case OK:
-           if (strncasecmp(response, "SASL ", 5) == 0) {
-               /*
-                * We've seen the SASL capability.  Grab the mech list
-                */
-               sasl_capability++;
-               strncpy(server_mechs, response + 5, sizeof(server_mechs));
-           }
-           break;
-       }
-
-    if (!sasl_capability) {
-       snprintf(response, sizeof(response), "POP server does not support "
-                "SASL");
-       return NOTOK;
-    }
-
-    /*
-     * If we received a preferred mechanism, see if the server supports it.
-     */
-
-    if (mech && stringdex(mech, server_mechs) == -1) {
-       snprintf(response, sizeof(response), "Requested SASL mech \"%s\" is "
-                "not in list of supported mechanisms:\n%s",
-                mech, server_mechs);
-       return NOTOK;
-    }
-
-    /*
-     * Start the SASL process.  First off, initialize the SASL library.
-     */
-
-    callbacks[POP_SASL_CB_N_USER].context = user;
-    p_context.user = user;
-    p_context.host = host;
-    callbacks[POP_SASL_CB_N_PASS].context = &p_context;
-
-    result = sasl_client_init(callbacks);
-
-    if (result != SASL_OK) {
-       snprintf(response, sizeof(response), "SASL library initialization "
-                "failed: %s", sasl_errstring(result, NULL, NULL));
-       return NOTOK;
-    }
-
-    result = sasl_client_new("pop", host, NULL, NULL, NULL, 0, &conn);
-
-    if (result != SASL_OK) {
-       snprintf(response, sizeof(response), "SASL client initialization "
-                "failed: %s", sasl_errstring(result, NULL, NULL));
-       return NOTOK;
-    }
-
-    /*
-     * Initialize the security properties
-     */
-
-    memset(&secprops, 0, sizeof(secprops));
-    secprops.maxbufsize = SASL_BUFFER_SIZE;
-    secprops.max_ssf = UINT_MAX;
-
-    result = sasl_setprop(conn, SASL_SEC_PROPS, &secprops);
-
-    if (result != SASL_OK) {
-       snprintf(response, sizeof(response), "SASL security property "
-                "initialization failed: %s", sasl_errdetail(conn));
-       return NOTOK;
-    }
-
-    /*
-     * Start the actual protocol.  Feed the mech list into the library
-     * and get out a possible initial challenge
-     */
-
-    result = sasl_client_start(conn,
-                              (const char *) (mech ? mech : server_mechs),
-                              NULL, (const char **) &buf,
-                              &buflen, &chosen_mech);
-
-    if (result != SASL_OK && result != SASL_CONTINUE) {
-       snprintf(response, sizeof(response), "SASL client start failed: %s",
-                sasl_errdetail(conn));
-       return NOTOK;
-    }
-
-    if (buflen) {
-       status = sasl_encode64(buf, buflen, outbuf, sizeof(outbuf), NULL);
-       if (status != SASL_OK) {
-           snprintf(response, sizeof(response), "SASL base64 encode "
-                    "failed: %s", sasl_errstring(status, NULL, NULL));
-           return NOTOK;
-       }
-
-       status = command("AUTH %s %s", chosen_mech, outbuf);
-    } else
-       status = command("AUTH %s", chosen_mech);
-
-    while (result == SASL_CONTINUE) {
-       if (status == NOTOK)
-           return NOTOK;
-       
-       /*
-        * If we get a "+OK" prefix to our response, then we should
-        * exit out of this exchange now (because authenticated should
-        * have succeeded)
-        */
-       
-       if (strncmp(response, "+OK", 3) == 0)
-           break;
-       
-       /*
-        * Otherwise, make sure the server challenge is correctly formatted
-        */
-       
-       if (strncmp(response, "+ ", 2) != 0) {
-           command("*");
-           snprintf(response, sizeof(response),
-                    "Malformed authentication message from server");
-           return NOTOK;
-       }
-
-       result = sasl_decode64(response + 2, strlen(response + 2),
-                              outbuf, sizeof(outbuf), &outlen);
-       
-       if (result != SASL_OK) {
-           command("*");
-           snprintf(response, sizeof(response), "SASL base64 decode "
-                    "failed: %s", sasl_errstring(result, NULL, NULL));
-           return NOTOK;
-       }
-
-       result = sasl_client_step(conn, outbuf, outlen, NULL,
-                                 (const char **) &buf, &buflen);
-
-       if (result != SASL_OK && result != SASL_CONTINUE) {
-           command("*");
-           snprintf(response, sizeof(response), "SASL client negotiaton "
-                    "failed: %s", sasl_errdetail(conn));
-           return NOTOK;
-       }
-
-       status = sasl_encode64(buf, buflen, outbuf, sizeof(outbuf), NULL);
-
-       if (status != SASL_OK) {
-           command("*");
-           snprintf(response, sizeof(response), "SASL base64 encode "
-                    "failed: %s", sasl_errstring(status, NULL, NULL));
-           return NOTOK;
-       }
-
-       status = command(outbuf);
-    }
-
-    /*
-     * If we didn't get a positive final response, then error out
-     * (that probably means we failed an authorization check).
-     */
-
-    if (status != OK)
-       return NOTOK;
-
-    /*
-     * We _should_ be okay now.  Get a few properties now that negotiation
-     * has completed.
-     */
-
-    result = sasl_getprop(conn, SASL_MAXOUTBUF, (const void **) &moutbuf);
-
-    if (result != SASL_OK) {
-       snprintf(response, sizeof(response), "Cannot retrieve SASL negotiated "
-                "output buffer size: %s", sasl_errdetail(conn));
-       return NOTOK;
-    }
-
-    maxoutbuf = *moutbuf;
-
-    result = sasl_getprop(conn, SASL_SSF, (const void **) &ssf);
-
-    sasl_ssf = *ssf;
-
-    if (result != SASL_OK) {
-       snprintf(response, sizeof(response), "Cannot retrieve SASL negotiated "
-                "security strength factor: %s", sasl_errdetail(conn));
-       return NOTOK;
-    }
-
-    /*
-     * Limit this to what we can deal with.  Shouldn't matter much because
-     * this is only outgoing data (which should be small)
-     */
-
-    if (maxoutbuf == 0 || maxoutbuf > BUFSIZ)
-       maxoutbuf = BUFSIZ;
-
-    sasl_complete = 1;
-
-    return status;
-}
-
-/*
- * Callback to return the userid sent down via the user parameter
- */
-
-static int
-sasl_get_user(void *context, int id, const char **result, unsigned *len)
-{
-    char *user = (char *) context;
-
-    if (! result || id != SASL_CB_USER)
-       return SASL_BADPARAM;
-
-    *result = user;
-    if (len)
-       *len = strlen(user);
-
-    return SASL_OK;
-}
-
-/*
- * Callback to return the password (we call ruserpass, which can get it
- * out of the .netrc
- */
-
-static int
-sasl_get_pass(sasl_conn_t *conn, void *context, int id, sasl_secret_t **psecret)
-{
-    struct pass_context *p_context = (struct pass_context *) context;
-    char *pass = NULL;
-    int len;
-
-    if (! psecret || id != SASL_CB_PASS)
-       return SASL_BADPARAM;
-
-    ruserpass(p_context->user, &(p_context->host), &pass);
-
-    len = strlen(pass);
-
-    *psecret = (sasl_secret_t *) mh_xmalloc(sizeof(sasl_secret_t) + len);
-
-    (*psecret)->len = len;
-    strcpy((char *) (*psecret)->data, pass);
-
-    return SASL_OK;
-}
-#endif /* CYRUS_SASL */
-
-
-/*
- * Split string containing proxy command into an array of arguments
- * suitable for passing to exec. Returned array must be freed. Shouldn't
- * be possible to call this with host set to NULL.
- */
-char **
-parse_proxy(char *proxy, char *host)
-{
-    char **pargv, **p;
-    int pargc = 2;
-    int hlen = strlen(host);
-    int plen = 1;
-    unsigned char *cur, *pro;
-    char *c;
-    
-    /* skip any initial space */
-    for (pro = (unsigned char *) proxy; isspace(*pro); pro++)
-        continue;
-    
-    /* calculate required size for argument array */
-    for (cur = pro; *cur; cur++) {
-        if (isspace(*cur) && cur[1] && !isspace(cur[1]))
-           plen++, pargc++;
-       else if (*cur == '%' && cur[1] == 'h') {
-           plen += hlen;
-            cur++;
-       } else if (!isspace(*cur))
-           plen++;
-    }
-
-   /* put together list of arguments */
-    p = pargv = mh_xmalloc(pargc * sizeof(char *));
-    c = *pargv = mh_xmalloc(plen * sizeof(char));
-    for (cur = pro; *cur; cur++) {
-        if (isspace(*cur) && cur[1] && !isspace(cur[1])) {
-           *c++ = '\0';
-           *++p = c;
-       } else if (*cur == '%' && cur[1] == 'h') {
-           strcpy (c, host);
-           c += hlen;
-           cur++;
-       } else if (!isspace(*cur))
-           *c++ = *cur;
-    }
-    *++p = NULL;
-    return pargv;
-}
-
-int
-pop_init (char *host, char *port, char *user, char *pass, char *proxy,
-         int snoop, int sasl, char *mech)
-{
-    int fd1, fd2;
-    char buffer[BUFSIZ];
-
-    if (proxy && *proxy) {
-       int pid;
-       int inpipe[2];    /* for reading from the server */
-       int outpipe[2];    /* for sending to the server */
-
-       /* first give up any root priviledges we may have for rpop */
-       setuid(getuid());
-
-       pipe(inpipe);
-       pipe(outpipe);
-
-       pid=fork();
-       if (pid==0) {
-          char **argv;
-          
-          /* in child */
-          close(0);  
-          close(1);
-          dup2(outpipe[0],0);  /* connect read end of connection */
-          dup2(inpipe[1], 1);  /* connect write end of connection */
-          if(inpipe[0]>1) close(inpipe[0]);
-          if(inpipe[1]>1) close(inpipe[1]);
-          if(outpipe[0]>1) close(outpipe[0]);
-          if(outpipe[1]>1) close(outpipe[1]);
-
-          /* run the proxy command */
-          argv=parse_proxy(proxy, host);
-          execvp(argv[0],argv);
-
-          perror(argv[0]);
-          close(0);
-          close(1);
-          free(*argv);
-          free(argv);
-          exit(10);
-       }
-
-       /* okay in the parent we do some stuff */
-       close(inpipe[1]);  /* child uses this */
-       close(outpipe[0]); /* child uses this */
-
-       /* we read on fd1 */
-       fd1=inpipe[0];
-       /* and write on fd2 */
-       fd2=outpipe[1];
-
-    } else {
-
-       if ((fd1 = client (host, port ? port : "pop3", response,
-                          sizeof(response), snoop)) == NOTOK) {
-           return NOTOK;
-       }
-
-       if ((fd2 = dup (fd1)) == NOTOK) {
-           char *s;
-
-           if ((s = strerror(errno)))
-               snprintf (response, sizeof(response),
-                   "unable to dup connection descriptor: %s", s);
-           else
-               snprintf (response, sizeof(response),
-                   "unable to dup connection descriptor: unknown error");
-           close (fd1);
-           return NOTOK;
-       }
-    }
-    if (pop_set (fd1, fd2, snoop) == NOTOK)
-       return NOTOK;
-
-    SIGNAL (SIGPIPE, SIG_IGN);
-
-    switch (sasl_getline (response, sizeof response, input)) {
-       case OK: 
-           if (poprint)
-               fprintf (stderr, "<--- %s\n", response);
-           if (*response == '+') {
-#  ifdef CYRUS_SASL
-               if (sasl) {
-                   if (pop_auth_sasl(user, host, mech) != NOTOK)
-                       return OK;
-               } else
-#  endif /* CYRUS_SASL */
-               if (command ("USER %s", user) != NOTOK
-                   && command ("%s %s", (pophack++, "PASS"),
-                                       pass) != NOTOK)
-               return OK;
-           }
-           strncpy (buffer, response, sizeof(buffer));
-           command ("QUIT");
-           strncpy (response, buffer, sizeof(response));
-                               /* and fall */
-
-       case NOTOK: 
-       case DONE: 
-           if (poprint)            
-               fprintf (stderr, "%s\n", response);
-           fclose (input);
-           fclose (output);
-           return NOTOK;
-    }
-
-    return NOTOK;      /* NOTREACHED */
-}
-
-int
-pop_set (int in, int out, int snoop)
-{
-
-    if ((input = fdopen (in, "r")) == NULL
-           || (output = fdopen (out, "w")) == NULL) {
-       strncpy (response, "fdopen failed on connection descriptor", sizeof(response));
-       if (input)
-           fclose (input);
-       else
-           close (in);
-       close (out);
-       return NOTOK;
-    }
-
-    poprint = snoop;
-
-    return OK;
-}
-
-
-int
-pop_fd (char *in, int inlen, char *out, int outlen)
-{
-    snprintf (in, inlen, "%d", fileno (input));
-    snprintf (out, outlen, "%d", fileno (output));
-    return OK;
-}
-
-
-/*
- * Find out number of messages available
- * and their total size.
- */
-
-int
-pop_stat (int *nmsgs, int *nbytes)
-{
-
-    if (command ("STAT") == NOTOK)
-       return NOTOK;
-
-    *nmsgs = *nbytes = 0;
-    sscanf (response, "+OK %d %d", nmsgs, nbytes);
-
-    return OK;
-}
-
-
-int
-pop_list (int msgno, int *nmsgs, int *msgs, int *bytes)
-{
-    int i;
-    int *ids = NULL;
-
-    if (msgno) {
-       if (command ("LIST %d", msgno) == NOTOK)
-           return NOTOK;
-       *msgs = *bytes = 0;
-       if (ids) {
-           *ids = 0;
-           sscanf (response, "+OK %d %d %d", msgs, bytes, ids);
-       }
-       else
-           sscanf (response, "+OK %d %d", msgs, bytes);
-       return OK;
-    }
-
-    if (command ("LIST") == NOTOK)
-       return NOTOK;
-
-    for (i = 0; i < *nmsgs; i++)
-       switch (multiline ()) {
-           case NOTOK: 
-               return NOTOK;
-           case DONE: 
-               *nmsgs = ++i;
-               return OK;
-           case OK: 
-               *msgs = *bytes = 0;
-               if (ids) {
-                   *ids = 0;
-                   sscanf (response, "%d %d %d",
-                           msgs++, bytes++, ids++);
-               }
-               else
-                   sscanf (response, "%d %d", msgs++, bytes++);
-               break;
-       }
-    for (;;)
-       switch (multiline ()) {
-           case NOTOK: 
-               return NOTOK;
-           case DONE: 
-               return OK;
-           case OK: 
-               break;
-       }
-}
-
-
-int
-pop_retr (int msgno, int (*action)(char *))
-{
-    return traverse (action, "RETR %d", msgno);
-}
-
-
-static int
-traverse (int (*action)(char *), const char *fmt, ...)
-{
-    int result;
-    va_list ap;
-    char buffer[sizeof(response)];
-
-    va_start(ap, fmt);
-    result = vcommand (fmt, ap);
-    va_end(ap);
-
-    if (result == NOTOK)
-       return NOTOK;
-    strncpy (buffer, response, sizeof(buffer));
-
-    for (;;)
-       switch (multiline ()) {
-           case NOTOK: 
-               return NOTOK;
-
-           case DONE: 
-               strncpy (response, buffer, sizeof(response));
-               return OK;
-
-           case OK: 
-               (*action) (response);
-               break;
-       }
-}
-
-
-int
-pop_dele (int msgno)
-{
-    return command ("DELE %d", msgno);
-}
-
-
-int
-pop_noop (void)
-{
-    return command ("NOOP");
-}
-
-
-int
-pop_rset (void)
-{
-    return command ("RSET");
-}
-
-
-int
-pop_top (int msgno, int lines, int (*action)(char *))
-{
-    return traverse (action, "TOP %d %d", msgno, lines);
-}
-
-
-int
-pop_quit (void)
-{
-    int i;
-
-    i = command ("QUIT");
-    pop_done ();
-
-    return i;
-}
-
-
-int
-pop_done (void)
-{
-#ifdef CYRUS_SASL
-    if (conn)
-       sasl_dispose(&conn);
-#endif /* CYRUS_SASL */
-    fclose (input);
-    fclose (output);
-
-    return OK;
-}
-
-
-int
-command(const char *fmt, ...)
-{
-    va_list ap;
-    int result;
-
-    va_start(ap, fmt);
-    result = vcommand(fmt, ap);
-    va_end(ap);
-
-    return result;
-}
-
-
-static int
-vcommand (const char *fmt, va_list ap)
-{
-    char *cp, buffer[BUFSIZ];
-
-    vsnprintf (buffer, sizeof(buffer), fmt, ap);
-    if (poprint) {
-#ifdef CYRUS_SASL
-       if (sasl_ssf)
-           fprintf(stderr, "(encrypted) ");
-#endif /* CYRUS_SASL */
-       if (pophack) {
-           if ((cp = strchr (buffer, ' ')))
-               *cp = 0;
-           fprintf (stderr, "---> %s ********\n", buffer);
-           if (cp)
-               *cp = ' ';
-           pophack = 0;
-       }
-       else
-           fprintf (stderr, "---> %s\n", buffer);
-    }
-
-    if (putline (buffer, output) == NOTOK)
-       return NOTOK;
-
-#ifdef CYRUS_SASL
-    if (poprint && sasl_ssf)
-       fprintf(stderr, "(decrypted) ");
-#endif /* CYRUS_SASL */
-
-    switch (sasl_getline (response, sizeof response, input)) {
-       case OK: 
-           if (poprint)
-               fprintf (stderr, "<--- %s\n", response);
-           return (*response == '+' ? OK : NOTOK);
-
-       case NOTOK: 
-       case DONE: 
-           if (poprint)            
-               fprintf (stderr, "%s\n", response);
-           return NOTOK;
-    }
-
-    return NOTOK;      /* NOTREACHED */
-}
-
-
-int
-multiline (void)
-{
-    char buffer[BUFSIZ + TRMLEN];
-
-    if (sasl_getline (buffer, sizeof buffer, input) != OK)
-       return NOTOK;
-#ifdef DEBUG
-    if (poprint) {
-#ifdef CYRUS_SASL
-       if (sasl_ssf)
-           fprintf(stderr, "(decrypted) ");
-#endif /* CYRUS_SASL */
-       fprintf (stderr, "<--- %s\n", response);
-    }
-#endif /* DEBUG */
-    if (strncmp (buffer, TRM, TRMLEN) == 0) {
-       if (buffer[TRMLEN] == 0)
-           return DONE;
-       else
-           strncpy (response, buffer + TRMLEN, sizeof(response));
-    }
-    else
-       strncpy (response, buffer, sizeof(response));
-
-    return OK;
-}
-
-/*
- * Note that these functions have been modified to deal with layer encryption
- * in the SASL case
- */
-
-static int
-sasl_getline (char *s, int n, FILE *iop)
-{
-    int c = -2;
-    char *p;
-
-    p = s;
-    while (--n > 0 && (c = sasl_fgetc (iop)) != EOF && c != -2) 
-       if ((*p++ = c) == '\n')
-           break;
-    if (c == -2)
-       return NOTOK;
-    if (ferror (iop) && c != EOF) {
-       strncpy (response, "error on connection", sizeof(response));
-       return NOTOK;
-    }
-    if (c == EOF && p == s) {
-       strncpy (response, "connection closed by foreign host", sizeof(response));
-       return DONE;
-    }
-    *p = 0;
-    if (*--p == '\n')
-       *p = 0;
-    if (*--p == '\r')
-       *p = 0;
-
-    return OK;
-}
-
-
-static int
-putline (char *s, FILE *iop)
-{
-#ifdef CYRUS_SASL
-    char outbuf[BUFSIZ], *buf;
-    int result;
-    unsigned int buflen;
-
-    if (!sasl_complete) {
-#endif /* CYRUS_SASL */
-       fprintf (iop, "%s\r\n", s);
-#ifdef CYRUS_SASL
-    } else {
-       /*
-        * Build an output buffer, encrypt it using sasl_encode, and
-        * squirt out the results.
-        */
-       strncpy(outbuf, s, sizeof(outbuf) - 3);
-       outbuf[sizeof(outbuf) - 3] = '\0';   /* Just in case */
-       strcat(outbuf, "\r\n");
-
-       result = sasl_encode(conn, outbuf, strlen(outbuf),
-                            (const char **) &buf, &buflen);
-
-       if (result != SASL_OK) {
-           snprintf(response, sizeof(response), "SASL encoding error: %s",
-                    sasl_errdetail(conn));
-           return NOTOK;
-       }
-
-       fwrite(buf, buflen, 1, iop);
-    }
-#endif /* CYRUS_SASL */
-
-    fflush (iop);
-    if (ferror (iop)) {
-       strncpy (response, "lost connection", sizeof(response));
-       return NOTOK;
-    }
-
-    return OK;
-}
-
-#ifdef CYRUS_SASL
-/*
- * Okay, our little fgetc replacement.  Hopefully this is a little more
- * efficient than the last one.
- */
-static int
-sasl_fgetc(FILE *f)
-{
-    static unsigned char *buffer = NULL, *ptr;
-    static int size = 0;
-    static int cnt = 0;
-    unsigned int retbufsize = 0;
-    int cc, result;
-    char *retbuf, tmpbuf[SASL_BUFFER_SIZE];
-
-    /*
-     * If we have some leftover data, return that
-     */
-
-    if (cnt) {
-       cnt--;
-       return (int) *ptr++;
-    }
-
-    /*
-     * Otherwise, fill our buffer until we have some data to return.
-     */
-
-    while (retbufsize == 0) {
-
-       cc = read(fileno(f), tmpbuf, sizeof(tmpbuf));
-
-       if (cc == 0)
-           return EOF;
-
-       if (cc < 0) {
-           snprintf(response, sizeof(response), "Error during read from "
-                    "network: %s", strerror(errno));
-           return -2;
-       }
-
-       /*
-        * We're not allowed to call sasl_decode until sasl_complete is
-        * true, so we do these gyrations ...
-        */
-       
-       if (!sasl_complete) {
-
-           retbuf = tmpbuf;
-           retbufsize = cc;
-
-       } else {
-
-           result = sasl_decode(conn, tmpbuf, cc,
-                                (const char **) &retbuf, &retbufsize);
-
-           if (result != SASL_OK) {
-               snprintf(response, sizeof(response), "Error during SASL "
-                        "decoding: %s", sasl_errdetail(conn));
-               return -2;
-           }
-       }
-    }
-
-    if (retbufsize > size) {
-       buffer = mh_xrealloc(buffer, retbufsize);
-       size = retbufsize;
-    }
-
-    memcpy(buffer, retbuf, retbufsize);
-    ptr = buffer + 1;
-    cnt = retbufsize - 1;
-
-    return (int) buffer[0];
-}
-#endif /* CYRUS_SASL */