masqmail

changeset 192:89f951be358f

REMOVED POP3 SUPPORT masqmail will not include a POP3 client anymore from 0.3.0 on maybe the POP3 code will be reworked into a standalone program some day if you rely on the POP3 client, use fetchmail or something similar instead
author meillo@marmaro.de
date Thu, 15 Jul 2010 14:24:40 +0200
parents f186650135c3
children bd9704417d49
files INSTALL Makefile.am Makefile.in TODO acconfig.h config.h.in configure configure.ac examples/example.get man/Makefile.am man/Makefile.in man/masqmail.8 man/masqmail.conf.5 man/masqmail.get.5 man/masqmail.route.5 src/Makefile.am src/Makefile.in src/accept.c src/conf.c src/get.c src/masqmail.c src/masqmail.h src/pop3_in.c src/pop3_in.h
diffstat 24 files changed, 25 insertions(+), 1801 deletions(-) [+]
line diff
     1.1 --- a/INSTALL	Thu Jul 15 11:48:33 2010 +0200
     1.2 +++ b/INSTALL	Thu Jul 15 14:24:40 2010 +0200
     1.3 @@ -78,9 +78,6 @@
     1.4  installed, this will be linked, otherwise it will be statically linked
     1.5  using the sources included in the package.
     1.6  
     1.7 ---enable-pop3
     1.8 -enables POP3 support (disabled by default)
     1.9 -
    1.10  --disable-resolver
    1.11  disables resolver support. Without the resolver functions, masqmail
    1.12  uses only gethostbyname() to resolve DNS names, and you cannot send
    1.13 @@ -96,9 +93,9 @@
    1.14  
    1.15  --with-libcryto
    1.16  instead of using the md5 and hmac functions within the package, link
    1.17 -dynamically with libcrypto. This applies only if you have POP3 or SMTP
    1.18 -AUTH enabled. Only makes sense if your resources are limited and you
    1.19 -have libcrypto installed. Untested.
    1.20 +dynamically with libcrypto. This applies only if you have SMTP AUTH
    1.21 +enabled. Only makes sense if your resources are limited and you have
    1.22 +libcrypto installed. Untested.
    1.23  
    1.24  --with-glib-static
    1.25  links with glib statically. This makes the binary larger by around 30K
    1.26 @@ -131,7 +128,6 @@
    1.27  	drwxr-xr-x 5 mail trusted   4096 May 10 12:34 /var/spool/masqmail
    1.28  	drwxr-xr-x 2 mail trusted   4096 May 10 12:34 /var/spool/masqmail/input
    1.29  	drwxr-xr-x 2 mail trusted   4096 May 10 12:34 /var/spool/masqmail/lock
    1.30 -	drwxr-xr-x 2 mail trusted   4096 May 10 12:34 /var/spool/masqmail/popuidl
    1.31  
    1.32  Important are the set-user-id bit for /usr/local/sbin/masqmail and
    1.33  the permissions of all files.
     2.1 --- a/Makefile.am	Thu Jul 15 11:48:33 2010 +0200
     2.2 +++ b/Makefile.am	Thu Jul 15 14:24:40 2010 +0200
     2.3 @@ -55,14 +55,12 @@
     2.4  	install -d -o @with_user@ -g @with_group@ $(DESTDIR)@with_spooldir@
     2.5  	install -d -o @with_user@ -g @with_group@ $(DESTDIR)@with_spooldir@/lock
     2.6  	install -d -o @with_user@ -g @with_group@ $(DESTDIR)@with_spooldir@/input
     2.7 -	install -d -o @with_user@ -g @with_group@ $(DESTDIR)@with_spooldir@/popuidl
     2.8  
     2.9  rm-spool_dir:
    2.10  	: # removal fails if the dirs are non-empty
    2.11  	: # this prevents losing spooled files
    2.12  	rmdir $(DESTDIR)@with_spooldir@/lock
    2.13  	rmdir $(DESTDIR)@with_spooldir@/input
    2.14 -	rmdir $(DESTDIR)@with_spooldir@/popuidl
    2.15  	rmdir $(DESTDIR)@with_spooldir@
    2.16  
    2.17  rmail:
     3.1 --- a/Makefile.in	Thu Jul 15 11:48:33 2010 +0200
     3.2 +++ b/Makefile.in	Thu Jul 15 14:24:40 2010 +0200
     3.3 @@ -738,14 +738,12 @@
     3.4  	install -d -o @with_user@ -g @with_group@ $(DESTDIR)@with_spooldir@
     3.5  	install -d -o @with_user@ -g @with_group@ $(DESTDIR)@with_spooldir@/lock
     3.6  	install -d -o @with_user@ -g @with_group@ $(DESTDIR)@with_spooldir@/input
     3.7 -	install -d -o @with_user@ -g @with_group@ $(DESTDIR)@with_spooldir@/popuidl
     3.8  
     3.9  rm-spool_dir:
    3.10  	: # removal fails if the dirs are non-empty
    3.11  	: # this prevents losing spooled files
    3.12  	rmdir $(DESTDIR)@with_spooldir@/lock
    3.13  	rmdir $(DESTDIR)@with_spooldir@/input
    3.14 -	rmdir $(DESTDIR)@with_spooldir@/popuidl
    3.15  	rmdir $(DESTDIR)@with_spooldir@
    3.16  
    3.17  rmail:
     4.1 --- a/TODO	Thu Jul 15 11:48:33 2010 +0200
     4.2 +++ b/TODO	Thu Jul 15 14:24:40 2010 +0200
     4.3 @@ -10,9 +10,6 @@
     4.4  - more configuration options
     4.5  - make conf more fool proof
     4.6  
     4.7 -pop:
     4.8 -- multidrop support
     4.9 -
    4.10  lookup:
    4.11  - optimize MX lookup
    4.12  
     5.1 --- a/acconfig.h	Thu Jul 15 11:48:33 2010 +0200
     5.2 +++ b/acconfig.h	Thu Jul 15 14:24:40 2010 +0200
     5.3 @@ -10,8 +10,6 @@
     5.4  
     5.5  #undef ENABLE_SMTP_SERVER
     5.6  
     5.7 -#undef ENABLE_POP3
     5.8 -
     5.9  #undef ENABLE_AUTH
    5.10  
    5.11  #undef ENABLE_MAILDIR
     6.1 --- a/config.h.in	Thu Jul 15 11:48:33 2010 +0200
     6.2 +++ b/config.h.in	Thu Jul 15 14:24:40 2010 +0200
     6.3 @@ -11,8 +11,6 @@
     6.4  
     6.5  #undef ENABLE_SMTP_SERVER
     6.6  
     6.7 -#undef ENABLE_POP3
     6.8 -
     6.9  #undef ENABLE_AUTH
    6.10  
    6.11  #undef ENABLE_MAILDIR
    6.12 @@ -51,9 +49,6 @@
    6.13  /* If Maildirs are enabled */
    6.14  #undef ENABLE_MAILDIR
    6.15  
    6.16 -/* If the POP3 support is enabled */
    6.17 -#undef ENABLE_POP3
    6.18 -
    6.19  /* If the resolver is to be used */
    6.20  #undef ENABLE_RESOLVER
    6.21  
     7.1 --- a/configure	Thu Jul 15 11:48:33 2010 +0200
     7.2 +++ b/configure	Thu Jul 15 14:24:40 2010 +0200
     7.3 @@ -706,7 +706,6 @@
     7.4  enable_debug
     7.5  with_glib_static
     7.6  enable_smtp_server
     7.7 -enable_pop3
     7.8  enable_auth
     7.9  enable_maildir
    7.10  with_libcrypto
    7.11 @@ -1350,7 +1349,6 @@
    7.12    --disable-resolver       disable resolver support
    7.13    --disable-debug          disable debugging
    7.14    --disable-smtp-server    disable smtp server support
    7.15 -  --disable-pop3           disable pop3 support
    7.16    --enable-auth            enable AUTH (RFC 2554) client support
    7.17    --enable-maildir            enable qmail style maildir support
    7.18    --enable-ident           enable ident (RFC 1413) support
    7.19 @@ -5182,21 +5180,6 @@
    7.20  
    7.21  fi
    7.22  
    7.23 -# Check whether --enable-pop3 was given.
    7.24 -if test "${enable_pop3+set}" = set; then :
    7.25 -  enableval=$enable_pop3; if test "x$enable_pop3" != 'xno'; then
    7.26 -		pop3_enabled='yes'
    7.27 -	fi
    7.28 -fi
    7.29 -
    7.30 -if test "x$pop3_enabled" = xyes; then
    7.31 -
    7.32 -$as_echo "#define ENABLE_POP3 1" >>confdefs.h
    7.33 -
    7.34 -#	MD5_LIBS='md5/libmd5c.a'
    7.35 -	need_md5='yes'
    7.36 -fi
    7.37 -
    7.38  # Check whether --enable-auth was given.
    7.39  if test "${enable_auth+set}" = set; then :
    7.40    enableval=$enable_auth; if test "x$enable_auth" != 'xno'; then
     8.1 --- a/configure.ac	Thu Jul 15 11:48:33 2010 +0200
     8.2 +++ b/configure.ac	Thu Jul 15 14:24:40 2010 +0200
     8.3 @@ -143,19 +143,6 @@
     8.4  	AC_DEFINE(ENABLE_SMTP_SERVER, 1, [If the SMTP server is enabled])
     8.5  fi
     8.6  
     8.7 -dnl pop support (default is use it)
     8.8 -AC_ARG_ENABLE(pop3,
     8.9 -	[  --disable-pop3           disable pop3 support],
    8.10 -	if test "x$enable_pop3" != 'xno'; then
    8.11 -		pop3_enabled='yes'
    8.12 -	fi,
    8.13 -	)
    8.14 -if test "x$pop3_enabled" = xyes; then
    8.15 -	AC_DEFINE(ENABLE_POP3, 1, [If the POP3 support is enabled])
    8.16 -#	MD5_LIBS='md5/libmd5c.a'
    8.17 -	need_md5='yes'
    8.18 -fi
    8.19 -
    8.20  dnl auth support (default is to not use it)
    8.21  AC_ARG_ENABLE(auth,
    8.22  	[  --enable-auth            enable AUTH (RFC 2554) client support],
     9.1 --- a/examples/example.get	Thu Jul 15 11:48:33 2010 +0200
     9.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     9.3 @@ -1,30 +0,0 @@
     9.4 -# example 'mail get' configuration
     9.5 -#
     9.6 -# the protocol, only 'pop3' or 'apop' are supported. apop is
     9.7 -# recommended if the server supports it (password encryption).
     9.8 -# Unfortunately most do not.
     9.9 -protocol=apop
    9.10 -
    9.11 -# the server:
    9.12 -server = pop.example.org
    9.13 -
    9.14 -# the account name:
    9.15 -user=okurth
    9.16 -
    9.17 -# and the password:
    9.18 -pass="keepInMind"
    9.19 -
    9.20 -# the (local) address, where the retrieved mail should be sent to:
    9.21 -address=okurth@localhost
    9.22 -
    9.23 -# should we keep the mail on server?
    9.24 -do_keep=false
    9.25 -
    9.26 -# if we do keep the mail, you should really set this to true,
    9.27 -# otherwise you will get it again next time you fetch mail.
    9.28 -# masqmail completely ignores any headers (which may mark a mail as read).
    9.29 -do_uidl=false
    9.30 -
    9.31 -# optionally, you can set the maximum size of a mail. Setting it to 0
    9.32 -# means get all, disregarding size.
    9.33 -max_size=50000
    10.1 --- a/man/Makefile.am	Thu Jul 15 11:48:33 2010 +0200
    10.2 +++ b/man/Makefile.am	Thu Jul 15 14:24:40 2010 +0200
    10.3 @@ -1,1 +1,1 @@
    10.4 -man_MANS=masqmail.8 mservdetect.1 masqmail.conf.5 masqmail.route.5 masqmail.get.5 masqmail.aliases.5 rmail.8
    10.5 +man_MANS=masqmail.8 mservdetect.1 masqmail.conf.5 masqmail.route.5 masqmail.aliases.5 rmail.8
    11.1 --- a/man/Makefile.in	Thu Jul 15 11:48:33 2010 +0200
    11.2 +++ b/man/Makefile.in	Thu Jul 15 14:24:40 2010 +0200
    11.3 @@ -176,7 +176,7 @@
    11.4  with_logdir = @with_logdir@
    11.5  with_spooldir = @with_spooldir@
    11.6  with_user = @with_user@
    11.7 -man_MANS = masqmail.8 mservdetect.1 masqmail.conf.5 masqmail.route.5 masqmail.get.5 masqmail.aliases.5 rmail.8
    11.8 +man_MANS = masqmail.8 mservdetect.1 masqmail.conf.5 masqmail.route.5 masqmail.aliases.5 rmail.8
    11.9  all: all-am
   11.10  
   11.11  .SUFFIXES:
    12.1 --- a/man/masqmail.8	Thu Jul 15 11:48:33 2010 +0200
    12.2 +++ b/man/masqmail.8	Thu Jul 15 14:24:40 2010 +0200
    12.3 @@ -14,10 +14,6 @@
    12.4  
    12.5  \fB/usr/sbin/masqmail \fR[\fB\-qo \fR[\fIname\fR]]
    12.6  
    12.7 -\fB/usr/sbin/masqmail \fR[\fB\-odq\fR] [\fB\-g \fR[\fIname\fR]]
    12.8 -
    12.9 -\fB/usr/sbin/masqmail \fR[\fB\-odq\fR] [\fB\-go \fR[\fIname\fR]]
   12.10 -
   12.11  \fB/usr/sbin/masqmail \fR[\fB\-t\fR] [\fB\-oi\fR] [\fB\-f \fIaddress\fR] [\fB\-\-\fR] \fIaddress...
   12.12  
   12.13  \fB/usr/sbin/mailq\fR
   12.14 @@ -29,8 +25,6 @@
   12.15  e.g. a home network or a single host at home.
   12.16  It has special support for connections to different ISPs.
   12.17  It replaces sendmail or other MTAs such as qmail or exim.
   12.18 -It can also act as a POP3 client (if this functionality has not been disabled at
   12.19 -build configuration time).
   12.20  
   12.21  
   12.22  .SH OPTIONS
   12.23 @@ -117,32 +111,6 @@
   12.24  Set the full sender name (in the From: header) to \fIstring\fR.
   12.25  
   12.26  .TP
   12.27 -\fB\-g [\fIname\fB]\fR
   12.28 -
   12.29 -Get mail (using pop3 or apop),
   12.30 -using the configurations given with get.\fIname\fR in the main configuration.
   12.31 -Without \fIname\fR, all get configurations will be used.
   12.32 -See also \fBmasqmail.get(5)\fR
   12.33 -
   12.34 -.TP
   12.35 -\fB\-go [\fIinterval\fB] [\fIname\fB]\fR
   12.36 -
   12.37 -Can be followed by a connection name.
   12.38 -Use this option in your script which starts as soon as a link to the internet
   12.39 -has been set up (usually ip-up).
   12.40 -When masqmail is called with this option, the specified get configuration(s)
   12.41 -is(are) read and mail will be retrieved from servers on the internet.
   12.42 -The \fIname\fR is defined in the configuration (see \fBonline_gets.\fIname\fR).
   12.43 -
   12.44 -If called with an interval option (recognized by a digit as the first characater),
   12.45 -masqmail starts as a daemon and tries to get mail in these intervals.
   12.46 -It checks for the online status first.
   12.47 -Example: `masqmail \-go 5m' will retrieve mail every five minutes.
   12.48 -
   12.49 -If called without \fIname\fR, the online status is determined with the configured method
   12.50 -(see \fBonline_detect\fR in \fBmasqmail.conf(5)\fR).
   12.51 -
   12.52 -.TP
   12.53  \fB\-i\fR
   12.54  
   12.55  Same as \fB\-oi\fR, see below.
   12.56 @@ -263,7 +231,7 @@
   12.57  files in \fI/etc/masqmail/\fR.
   12.58  
   12.59  \fI/var/spool/masqmail/\fR is the spool directory where masqmail stores
   12.60 -its spooled messages and the uniq pop ids.
   12.61 +its spooled messages.
   12.62  
   12.63  \fI/var/spool/mail/\fR is the directory where locally delivered mail will be put,
   12.64  if not configured differently in \fImasqmail.conf\fR.
   12.65 @@ -276,8 +244,6 @@
   12.66  
   12.67  RFC 821, 822, 1869, 1870, 2197, 2554 (SMTP)
   12.68  
   12.69 -RFC 1725, 1939 (POP3)
   12.70 -
   12.71  RFC 1321 (MD5)
   12.72  
   12.73  RFC 2195 (CRAM-MD5)
   12.74 @@ -299,4 +265,4 @@
   12.75  
   12.76  .SH SEE ALSO
   12.77  
   12.78 -\fBmasqmail.conf(5)\fR, \fBmasqmail.route(5)\fR, \fBmasqmail.get(5)\fR, \fBmasqmail.aliases(5)\fR
   12.79 +\fBmasqmail.conf(5)\fR, \fBmasqmail.route(5)\fR, \fBmasqmail.aliases(5)\fR
    13.1 --- a/man/masqmail.conf.5	Thu Jul 15 11:48:33 2010 +0200
    13.2 +++ b/man/masqmail.conf.5	Thu Jul 15 14:24:40 2010 +0200
    13.3 @@ -26,7 +26,7 @@
    13.4  The spaces in front of and after the equal sign `=' are optional.
    13.5  
    13.6  Most lists (exceptions: \fBlocal_hosts\fR, \fBlocal_nets\fR, \fBlisten_addresses\fR,
    13.7 - \fBonline_routes\fR, and \fBonline_gets\fR) accept files.
    13.8 +and \fBonline_routes\fR) accept files.
    13.9  These will be recognized by a leading slash `/'.
   13.10  The contents of these files will be included at the position of the file name,
   13.11  there can be items or other files before and after the file entry.
   13.12 @@ -184,7 +184,7 @@
   13.13  If this is set to true, a possibly existing Envelope-to: header in an incoming mail
   13.14  which is received via either pop3 or smtp will be saved as an X-Orig-Envelope-to: header.
   13.15  
   13.16 -This is useful if you retrieve mail from a pop3 server with either masqmail or fetchmail,
   13.17 +This is useful if you retrieve mail from a pop3 server with fetchmail,
   13.18  and the server supports Envelope-to: headers,
   13.19  and you want to make use of those with a mail filtering tool, e.g. procmail.
   13.20  It cannot be preserved because masqmail sets such a header by itself.
   13.21 @@ -411,20 +411,6 @@
   13.22  
   13.23  
   13.24  .TP
   13.25 -\fBget.\fIname\fR = \fIfile\fR
   13.26 -
   13.27 -Replace \fIname\fR with a name to identify a get configuration.
   13.28 -Set this to a filename for the get configuration.
   13.29 -These files will be used to retrieve mail when called with the \-g option.
   13.30 -
   13.31 -.TP
   13.32 -\fBonline_gets.\fIname\fR = \fIlist\fR
   13.33 -
   13.34 -Replace \fIname\fR with a name to identify an online configuration.
   13.35 -Set this to a filename (or a list of filenames) for the get configuration.
   13.36 -These files will be used to retrieve mail when called with the \-go option.
   13.37 -
   13.38 -.TP
   13.39  \fBident_trusted_nets = \fIlist\fR
   13.40  
   13.41  \fIlist\fR is a list of networks of the form a.b.c.d/e (e.g. 192.168.1.0/24),
   13.42 @@ -526,4 +512,4 @@
   13.43  
   13.44  .SH SEE ALSO
   13.45  
   13.46 -\fBmasqmail(8)\fR, \fBmasqmail.route(5)\fR, \fBmasqmail.get(5)\fR
   13.47 +\fBmasqmail(8)\fR, \fBmasqmail.route(5)\fR
    14.1 --- a/man/masqmail.get.5	Thu Jul 15 11:48:33 2010 +0200
    14.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    14.3 @@ -1,151 +0,0 @@
    14.4 -.TH masqmail.get 5 2010-07-06 masqmail-0.2.25 "File Formats"
    14.5 -
    14.6 -.SH NAME
    14.7 -masqmail.get \- masqmail get configuration file
    14.8 -
    14.9 -
   14.10 -.SH DESCRIPTION
   14.11 - 
   14.12 -This man page describes the options available for the masqmail get configuration.
   14.13 -
   14.14 -
   14.15 -.SH OPTIONS
   14.16 -
   14.17 -.TP
   14.18 -\fBprotocol\fR = \fIstring\fR
   14.19 -
   14.20 -The protocol with which you retrieve your mail.
   14.21 -Currently only `pop3' and `apop' are supported.
   14.22 -There is no default.
   14.23 -
   14.24 -.TP
   14.25 -\fBserver\fR = \fIstring\fR
   14.26 -
   14.27 -The server you get your mail from.
   14.28 -
   14.29 -.TP
   14.30 -\fBport\fR = \fInumber\fR
   14.31 -
   14.32 -The port number of \fBserver\fP to connect to.
   14.33 -
   14.34 -Default: 110.
   14.35 -
   14.36 -.TP
   14.37 -\fBresolve_list\fR = \fIlist\fR
   14.38 -
   14.39 -Specify the method how the domain of the server is resolved.
   14.40 -Possible values are dns_mx, dns_a, byname.
   14.41 -For `dns_mx', the domain is assumed to be an MX pointer to a list of host names,
   14.42 -these will be tried each in order
   14.43 -(lowest preference value first, equal preference values in random order).
   14.44 -For `dns_a', the domain is assumed to be an A pointer.
   14.45 -For `byname', the library function \fBgethostbyname(3)\fR will be used.
   14.46 -
   14.47 -The default is "dns_a;byname".
   14.48 -It does not make much sense here to use `dns_mx'.
   14.49 -
   14.50 -.TP
   14.51 -\fBuser\fR = \fIstring\fR
   14.52 -
   14.53 -Your login name.
   14.54 -
   14.55 -.TP
   14.56 -\fBpass\fR = \fIstring\fR
   14.57 -
   14.58 -Your password.
   14.59 -
   14.60 -.TP
   14.61 -\fBaddress\fR = \fIaddress\fR
   14.62 -
   14.63 -The address where the retrieved mail should be sent to.
   14.64 -It can be any address, but you probably want to set this to a local address on your LAN.
   14.65 -
   14.66 -.TP
   14.67 -\fBreturn_path\fR = \fIaddress\fR
   14.68 -
   14.69 -If set, masqmail sets the return path to this address.
   14.70 -Bounces generated during further delivery will be sent to this address.
   14.71 -If unset, masqmail looks for the Return-Path: header in the mail,
   14.72 -if this does not exist it uses the From: address and if this fails, postmaster will be used.
   14.73 -
   14.74 -It is in most cases not useful to set this to the same address as the `address'
   14.75 -option as this may generate multiple bounces.
   14.76 -postmaster is recommended.
   14.77 -
   14.78 -.TP
   14.79 -\fBdo_keep\fR = \fIboolean\fR
   14.80 -
   14.81 -If you want to keep your mail on the server after you retrieved it, set this to true.
   14.82 -It is recommended that you also set do_uidl,
   14.83 -otherwise you will get the mail again each time you connect to the server.
   14.84 -Masqmail does not check any headers before it retrieves mail, which may mark it as already fetched.
   14.85 -Note that this behaviour is different to that of fetchmail.
   14.86 -The default is false.
   14.87 -
   14.88 -.TP
   14.89 -\fBdo_uidl\fR = \fIboolean\fR
   14.90 -
   14.91 -If set, masqmail keeps a list of unique IDs of mails already fetched,
   14.92 -so that they will not be retrieved again.
   14.93 -Default is false.
   14.94 -
   14.95 -.TP
   14.96 -\fBdo_uidl_dele\fR = \fIboolean\fR
   14.97 -
   14.98 -If set, and \fBdo_uidl\fR is also set, MasqMail sends a delete (DELE) command
   14.99 -to the server for each message uid in the uid listing at the beginning of the session.
  14.100 -This prevents mail to be left on the server if masqmail gets interrupted during
  14.101 -a session before it can send the QUIT command to the server.
  14.102 -Default is false.
  14.103 -
  14.104 -.TP
  14.105 -\fBmax_size\fR = \fInumeric\fR
  14.106 -
  14.107 -If set to a value > 0, only messages smaller than this in bytes will be retrieved.
  14.108 -The default is 0.
  14.109 -
  14.110 -.TP
  14.111 -\fBmax_count\fR = \fInumeric\fR
  14.112 -
  14.113 -If set to a value > 0, only \fBmax_count\fR messages will be retrieved.
  14.114 -The default is 0.
  14.115 -
  14.116 -.TP
  14.117 -\fBmax_size_delete\fR = \fIboolean\fR
  14.118 -
  14.119 -If \fBmax_size\fP > 0 and \fBdo_uidl_dele\fP is set,
  14.120 -delete messages that are larger than \fImax_size\fP on the server
  14.121 -WITHOUT retrieving them.
  14.122 -Be careful with this option.
  14.123 -
  14.124 -Default: false
  14.125 -
  14.126 -.TP
  14.127 -\fBwrapper\fR = \fIcommand\fR
  14.128 -
  14.129 -If set, instead of opening a connection to a remote server,
  14.130 -\fIcommand\fR will be called and all traffic will be piped to its stdin and from its stdout.
  14.131 -Purpose is to tunnel ip traffic, e.g. for ssl.
  14.132 -
  14.133 -Example for ssl tunneling:
  14.134 -
  14.135 -wrapper="/usr/bin/openssl s_client \-quiet \-connect pop.gmx.net:995 2>/dev/null"
  14.136 -
  14.137 -
  14.138 -.SH AUTHOR
  14.139 -
  14.140 -Masqmail was written by Oliver Kurth.
  14.141 -It is now maintained by Markus Schnalke <meillo@marmaro.de>.
  14.142 -
  14.143 -You will find the newest version of masqmail at \fBhttp://marmaro.de/prog/masqmail/\fR.
  14.144 -There is also a mailing list, you will find information about it at masqmail's main site.
  14.145 -
  14.146 -
  14.147 -.SH BUGS
  14.148 -
  14.149 -Please report bugs to the mailing list.
  14.150 -
  14.151 -
  14.152 -.SH SEE ALSO
  14.153 -
  14.154 -\fBmasqmail(8)\fR, \fBmasqmail.route(5)\fR, \fBmasqmail.conf(5)\fR
    15.1 --- a/man/masqmail.route.5	Thu Jul 15 11:48:33 2010 +0200
    15.2 +++ b/man/masqmail.route.5	Thu Jul 15 14:24:40 2010 +0200
    15.3 @@ -317,4 +317,4 @@
    15.4  
    15.5  .SH SEE ALSO
    15.6  
    15.7 -\fBmasqmail(8)\fR, \fBmasqmail.conf(5)\fR, \fBmasqmail.get(5)\fR
    15.8 +\fBmasqmail(8)\fR, \fBmasqmail.conf(5)\fR
    16.1 --- a/src/Makefile.am	Thu Jul 15 11:48:33 2010 +0200
    16.2 +++ b/src/Makefile.am	Thu Jul 15 14:24:40 2010 +0200
    16.3 @@ -22,7 +22,6 @@
    16.4  	dotlock.c\
    16.5  	expand.c\
    16.6  	fail_msg.c\
    16.7 -	get.c\
    16.8  	header.c\
    16.9  	interface.c\
   16.10  	local.c\
   16.11 @@ -36,8 +35,6 @@
   16.12  	peopen.c\
   16.13  	peopen.h\
   16.14  	permissions.c\
   16.15 -	pop3_in.c\
   16.16 -	pop3_in.h\
   16.17  	readsock.c\
   16.18  	rewrite.c\
   16.19  	route.c\
    17.1 --- a/src/Makefile.in	Thu Jul 15 11:48:33 2010 +0200
    17.2 +++ b/src/Makefile.in	Thu Jul 15 14:24:40 2010 +0200
    17.3 @@ -50,15 +50,14 @@
    17.4  am_masqmail_OBJECTS = accept.$(OBJEXT) address.$(OBJEXT) \
    17.5  	alias.$(OBJEXT) child.$(OBJEXT) connect.$(OBJEXT) \
    17.6  	conf.$(OBJEXT) deliver.$(OBJEXT) dotlock.$(OBJEXT) \
    17.7 -	expand.$(OBJEXT) fail_msg.$(OBJEXT) get.$(OBJEXT) \
    17.8 -	header.$(OBJEXT) interface.$(OBJEXT) local.$(OBJEXT) \
    17.9 -	log.$(OBJEXT) listen.$(OBJEXT) lookup.$(OBJEXT) \
   17.10 -	masqmail.$(OBJEXT) message.$(OBJEXT) online.$(OBJEXT) \
   17.11 -	parse.$(OBJEXT) peopen.$(OBJEXT) permissions.$(OBJEXT) \
   17.12 -	pop3_in.$(OBJEXT) readsock.$(OBJEXT) rewrite.$(OBJEXT) \
   17.13 -	route.$(OBJEXT) queue.$(OBJEXT) smtp_in.$(OBJEXT) \
   17.14 -	smtp_out.$(OBJEXT) spool.$(OBJEXT) tables.$(OBJEXT) \
   17.15 -	timeival.$(OBJEXT)
   17.16 +	expand.$(OBJEXT) fail_msg.$(OBJEXT) header.$(OBJEXT) \
   17.17 +	interface.$(OBJEXT) local.$(OBJEXT) log.$(OBJEXT) \
   17.18 +	listen.$(OBJEXT) lookup.$(OBJEXT) masqmail.$(OBJEXT) \
   17.19 +	message.$(OBJEXT) online.$(OBJEXT) parse.$(OBJEXT) \
   17.20 +	peopen.$(OBJEXT) permissions.$(OBJEXT) readsock.$(OBJEXT) \
   17.21 +	rewrite.$(OBJEXT) route.$(OBJEXT) queue.$(OBJEXT) \
   17.22 +	smtp_in.$(OBJEXT) smtp_out.$(OBJEXT) spool.$(OBJEXT) \
   17.23 +	tables.$(OBJEXT) timeival.$(OBJEXT)
   17.24  masqmail_OBJECTS = $(am_masqmail_OBJECTS)
   17.25  masqmail_DEPENDENCIES =
   17.26  am_mservdetect_OBJECTS = mservdetect.$(OBJEXT) readsock.$(OBJEXT) \
   17.27 @@ -250,7 +249,6 @@
   17.28  	dotlock.c\
   17.29  	expand.c\
   17.30  	fail_msg.c\
   17.31 -	get.c\
   17.32  	header.c\
   17.33  	interface.c\
   17.34  	local.c\
   17.35 @@ -264,8 +262,6 @@
   17.36  	peopen.c\
   17.37  	peopen.h\
   17.38  	permissions.c\
   17.39 -	pop3_in.c\
   17.40 -	pop3_in.h\
   17.41  	readsock.c\
   17.42  	rewrite.c\
   17.43  	route.c\
   17.44 @@ -451,7 +447,6 @@
   17.45  @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dotlock.Po@am__quote@
   17.46  @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/expand.Po@am__quote@
   17.47  @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fail_msg.Po@am__quote@
   17.48 -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/get.Po@am__quote@
   17.49  @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/header.Po@am__quote@
   17.50  @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/interface.Po@am__quote@
   17.51  @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/listen.Po@am__quote@
   17.52 @@ -465,7 +460,6 @@
   17.53  @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/parse.Po@am__quote@
   17.54  @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/peopen.Po@am__quote@
   17.55  @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/permissions.Po@am__quote@
   17.56 -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pop3_in.Po@am__quote@
   17.57  @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/queue.Po@am__quote@
   17.58  @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/readsock.Po@am__quote@
   17.59  @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/readtest.Po@am__quote@
    18.1 --- a/src/accept.c	Thu Jul 15 11:48:33 2010 +0200
    18.2 +++ b/src/accept.c	Thu Jul 15 14:24:40 2010 +0200
    18.3 @@ -24,8 +24,6 @@
    18.4  	"bsmtp",
    18.5  	"smtp",
    18.6  	"esmtp",
    18.7 -	"pop3",
    18.8 -	"apop",
    18.9  	"(unknown)"  /* should not happen, but better than crashing. */
   18.10  };
   18.11  
    19.1 --- a/src/conf.c	Thu Jul 15 11:48:33 2010 +0200
    19.2 +++ b/src/conf.c	Thu Jul 15 14:24:40 2010 +0200
    19.3 @@ -548,22 +548,7 @@
    19.4  			conf.online_pipe = g_strdup(rval);
    19.5  		else if (strcmp(lval, "do_queue") == 0)
    19.6  			conf.do_queue = parse_boolean(rval);
    19.7 -		else if (strncmp(lval, "get.", 4) == 0) {
    19.8 -#ifdef ENABLE_POP3
    19.9 -			table_pair *pair = create_pair_string(&(lval[4]), rval);
   19.10 -			conf.get_names = g_list_append(conf.get_names, pair);
   19.11 -#else
   19.12 -			logwrite(LOG_WARNING, "get.<name> ignored: not compiled with pop support\n");
   19.13 -#endif
   19.14 -		} else if (strncmp(lval, "online_gets.", 12) == 0) {
   19.15 -#ifdef ENABLE_POP3
   19.16 -			GList *file_list = parse_list(rval, FALSE);
   19.17 -			table_pair *pair = create_pair(&(lval[12]), file_list);
   19.18 -			conf.online_gets = g_list_append(conf.online_gets, pair);
   19.19 -#else
   19.20 -			logwrite(LOG_WARNING, "online_gets.<name> ignored: not compiled with pop support\n");
   19.21 -#endif
   19.22 -		} else if (strcmp(lval, "errmsg_file") == 0)
   19.23 +		else if (strcmp(lval, "errmsg_file") == 0)
   19.24  			conf.errmsg_file = g_strdup(rval);
   19.25  		else if (strcmp(lval, "warnmsg_file") == 0)
   19.26  			conf.warnmsg_file = g_strdup(rval);
   19.27 @@ -896,100 +881,6 @@
   19.28  	g_list_free(list);
   19.29  }
   19.30  
   19.31 -#ifdef ENABLE_POP3
   19.32 -
   19.33 -get_conf*
   19.34 -read_get_conf(gchar * filename)
   19.35 -{
   19.36 -	FILE *in;
   19.37 -
   19.38 -	get_conf *gc = g_malloc(sizeof(get_conf));
   19.39 -	memset(gc, 0, sizeof(get_conf));
   19.40 -
   19.41 -	gc->server_port = 110;
   19.42 -
   19.43 -	if ((in = fopen(filename, "r")) == NULL) {
   19.44 -		logwrite(LOG_ALERT, "could not open get file %s: %s\n", filename, strerror(errno));
   19.45 -		g_free(gc);
   19.46 -		return NULL;
   19.47 -	}
   19.48 -
   19.49 -	gchar lval[256], rval[2048];
   19.50 -	while (read_statement(in, lval, 256, rval, 2048)) {
   19.51 -		if (strcmp(lval, "protocol") == 0)
   19.52 -			gc->protocol = g_strdup(rval);
   19.53 -		else if (strcmp(lval, "server") == 0)
   19.54 -			gc->server_name = g_strdup(rval);
   19.55 -		else if (strcmp(lval, "port") == 0)
   19.56 -			gc->server_port = atoi(rval);
   19.57 -		else if (strcmp(lval, "wrapper") == 0)
   19.58 -			gc->wrapper = g_strdup(rval);
   19.59 -		else if (strcmp(lval, "user") == 0)
   19.60 -			gc->login_user = g_strdup(rval);
   19.61 -		else if (strcmp(lval, "pass") == 0)
   19.62 -			gc->login_pass = g_strdup(rval);
   19.63 -		else if (strcmp(lval, "address") == 0)
   19.64 -			gc->address = create_address_qualified(rval, TRUE, conf.host_name);
   19.65 -		else if (strcmp(lval, "return_path") == 0)
   19.66 -			gc->return_path = create_address_qualified(rval, TRUE, conf.host_name);
   19.67 -		else if (strcmp(lval, "do_ssl") == 0)
   19.68 -			/* we ignore this. This option is used by sqilconf */
   19.69 -			;
   19.70 -		else if (strcmp(lval, "do_keep") == 0)
   19.71 -			gc->do_keep = parse_boolean(rval);
   19.72 -		else if (strcmp(lval, "do_uidl") == 0)
   19.73 -			gc->do_uidl = parse_boolean(rval);
   19.74 -		else if (strcmp(lval, "do_uidl_dele") == 0)
   19.75 -			gc->do_uidl_dele = parse_boolean(rval);
   19.76 -		else if (strcmp(lval, "max_size") == 0)
   19.77 -			gc->max_size = atoi(rval);
   19.78 -		else if (strcmp(lval, "max_size_delete") == 0)
   19.79 -			gc->max_size_delete = parse_boolean(rval);
   19.80 -		else if (strcmp(lval, "max_count") == 0)
   19.81 -			gc->max_count = atoi(rval);
   19.82 -		else if (strcmp(lval, "resolve_list") == 0)
   19.83 -			gc->resolve_list = parse_resolve_list(rval);
   19.84 -		else
   19.85 -			logwrite(LOG_WARNING, "var '%s' not (yet) known, ignored\n", lval);
   19.86 -	}
   19.87 -	fclose(in);
   19.88 -
   19.89 -	if (gc->resolve_list == NULL) {
   19.90 -#ifdef ENABLE_RESOLVER
   19.91 -		gc->resolve_list = g_list_append(NULL, resolve_dns_a);
   19.92 -#endif
   19.93 -		gc->resolve_list = g_list_append(NULL, resolve_byname);
   19.94 -	}
   19.95 -
   19.96 -	if (gc->protocol == NULL)
   19.97 -		gc->protocol = g_strdup("pop3");
   19.98 -	return gc;
   19.99 -}
  19.100 -
  19.101 -void
  19.102 -destroy_get_conf(get_conf * gc)
  19.103 -{
  19.104 -	if (gc->protocol)
  19.105 -		g_free(gc->protocol);
  19.106 -	if (gc->server_name)
  19.107 -		g_free(gc->server_name);
  19.108 -	if (gc->login_user)
  19.109 -		g_free(gc->login_user);
  19.110 -	if (gc->login_pass)
  19.111 -		g_free(gc->login_pass);
  19.112 -	if (gc->wrapper)
  19.113 -		g_free(gc->wrapper);
  19.114 -	if (gc->address)
  19.115 -		destroy_address(gc->address);
  19.116 -	if (gc->return_path)
  19.117 -		destroy_address(gc->return_path);
  19.118 -	if (gc->resolve_list)
  19.119 -		g_list_free(gc->resolve_list);
  19.120 -	g_free(gc);
  19.121 -}
  19.122 -
  19.123 -#endif
  19.124 -
  19.125  connect_route*
  19.126  create_local_route()
  19.127  {
    20.1 --- a/src/get.c	Thu Jul 15 11:48:33 2010 +0200
    20.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    20.3 @@ -1,372 +0,0 @@
    20.4 -/*  MasqMail
    20.5 -    Copyright (C) 2000-2002 Oliver Kurth
    20.6 -
    20.7 -    This program is free software; you can redistribute it and/or modify
    20.8 -    it under the terms of the GNU General Public License as published by
    20.9 -    the Free Software Foundation; either version 2 of the License, or
   20.10 -    (at your option) any later version.
   20.11 -
   20.12 -    This program is distributed in the hope that it will be useful,
   20.13 -    but WITHOUT ANY WARRANTY; without even the implied warranty of
   20.14 -    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   20.15 -    GNU General Public License for more details.
   20.16 -
   20.17 -    You should have received a copy of the GNU General Public License
   20.18 -    along with this program; if not, write to the Free Software
   20.19 -    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
   20.20 -*/
   20.21 -
   20.22 -#include <sys/wait.h>
   20.23 -#include <sys/file.h>
   20.24 -#include <sys/types.h>
   20.25 -
   20.26 -#include "masqmail.h"
   20.27 -#include "pop3_in.h"
   20.28 -
   20.29 -#ifdef ENABLE_POP3
   20.30 -
   20.31 -static int volatile sighup_seen = 0;
   20.32 -
   20.33 -static void
   20.34 -sighup_handler(int sig)
   20.35 -{
   20.36 -	sighup_seen = 1;
   20.37 -	signal(SIGHUP, sighup_handler);
   20.38 -}
   20.39 -
   20.40 -static void
   20.41 -sigchld_handler(int sig)
   20.42 -{
   20.43 -	pid_t pid;
   20.44 -	int status;
   20.45 -
   20.46 -	pid = waitpid(0, &status, 0);
   20.47 -	if (pid > 0) {
   20.48 -		if (WEXITSTATUS(status) != EXIT_SUCCESS)
   20.49 -			logwrite(LOG_WARNING, "process %d exited with %d\n", pid, WEXITSTATUS(status));
   20.50 -		if (WIFSIGNALED(status))
   20.51 -			logwrite(LOG_WARNING, "process with pid %d got signal: %d\n", pid, WTERMSIG(status));
   20.52 -	}
   20.53 -	signal(SIGCHLD, sigchld_handler);
   20.54 -}
   20.55 -
   20.56 -static int
   20.57 -get_lock(get_conf * gc)
   20.58 -{
   20.59 -#ifdef USE_DOTLOCK
   20.60 -	gboolean ok = FALSE;
   20.61 -	gchar *hitch_name;
   20.62 -	gchar *lock_name;
   20.63 -
   20.64 -	/* the name of the lock is constructed from the user
   20.65 -	   and the server name, to prevent more than one connection at the same time
   20.66 -	   to the same server and the same user. This way concurrent connections
   20.67 -	   are possible to different servers or different users */
   20.68 -	hitch_name = g_strdup_printf("%s/masqmail-get-%s@%s-%d.lock",
   20.69 -	                             conf.lock_dir, gc->login_user, gc->server_name, getpid());
   20.70 -	lock_name = g_strdup_printf("%s/masqmail-get-%s@%s.lock",
   20.71 -	                            conf.lock_dir, gc->login_user, gc->server_name);
   20.72 -
   20.73 -	ok = dot_lock(lock_name, hitch_name);
   20.74 -	if (!ok)
   20.75 -		logwrite(LOG_WARNING, "getting mail for %s@%s is locked\n", gc->login_user, gc->server_name);
   20.76 -
   20.77 -	g_free(lock_name);
   20.78 -	g_free(hitch_name);
   20.79 -
   20.80 -	return ok;
   20.81 -#else
   20.82 -	gchar *lock_name;
   20.83 -	int fd;
   20.84 -
   20.85 -	lock_name = g_strdup_printf("%s/masqmail-get-%s@%s.lock", conf.lock_dir, gc->login_user, gc->server_name);
   20.86 -
   20.87 -	if ((fd = open(lock_name, O_WRONLY | O_NDELAY | O_APPEND | O_CREAT, 0600)) >= 0) {
   20.88 -		if (flock(fd, LOCK_EX | LOCK_NB) != 0) {
   20.89 -			close(fd);
   20.90 -			logwrite(LOG_WARNING, "getting mail for %s@%s is locked\n", gc->login_user, gc->server_name);
   20.91 -			fd = -1;
   20.92 -		}
   20.93 -	} else
   20.94 -		logwrite(LOG_WARNING, "could not open lock %s: %s\n", lock_name, strerror(errno));
   20.95 -
   20.96 -	g_free(lock_name);
   20.97 -
   20.98 -	return fd;
   20.99 -#endif
  20.100 -}
  20.101 -
  20.102 -#ifdef USE_DOTLOCK
  20.103 -static gboolean
  20.104 -get_unlock(get_conf * gc)
  20.105 -{
  20.106 -	gchar *lock_name lock_name = g_strdup_printf("%s/masqmail-get-%s@%s.lock",
  20.107 -	                                             conf.lock_dir, gc->login_user, gc->server_name);
  20.108 -
  20.109 -	dot_unlock(lock_name);
  20.110 -	g_free(lock_name);
  20.111 -
  20.112 -	return TRUE;
  20.113 -}
  20.114 -#else
  20.115 -static void
  20.116 -get_unlock(get_conf * gc, int fd)
  20.117 -{
  20.118 -	gchar *lock_name = g_strdup_printf("%s/masqmail-get-%s@%s.lock",
  20.119 -	                                   conf.lock_dir, gc->login_user, gc->server_name);
  20.120 -
  20.121 -	flock(fd, LOCK_UN);
  20.122 -	close(fd);
  20.123 -
  20.124 -	unlink(lock_name);
  20.125 -	g_free(lock_name);
  20.126 -}
  20.127 -#endif
  20.128 -
  20.129 -gboolean
  20.130 -get_from_file(gchar * fname)
  20.131 -{
  20.132 -	guint flags = 0;
  20.133 -	get_conf *gc = read_get_conf(fname);
  20.134 -	gboolean ok = TRUE;
  20.135 -	int lock;
  20.136 -
  20.137 -	if (gc) {
  20.138 -		if (!gc->do_keep)
  20.139 -			flags |= POP3_FLAG_DELETE;
  20.140 -		if (gc->do_uidl)
  20.141 -			flags |= POP3_FLAG_UIDL;
  20.142 -		if (gc->do_uidl_dele)
  20.143 -			flags |= POP3_FLAG_UIDL_DELE;
  20.144 -
  20.145 -		if (!(gc->server_name)) {
  20.146 -			logwrite(LOG_ALERT, "no server name given in %s\n", fname);
  20.147 -			return FALSE;
  20.148 -		}
  20.149 -		if (!(gc->address)) {
  20.150 -			logwrite(LOG_ALERT, "no address given in %s\n", fname);
  20.151 -			return FALSE;
  20.152 -		}
  20.153 -		if (!(gc->login_user)) {
  20.154 -			logwrite(LOG_ALERT, "no user name given in %s\n", fname);
  20.155 -			return FALSE;
  20.156 -		}
  20.157 -		if (!(gc->login_pass)) {
  20.158 -			logwrite(LOG_ALERT, "no password given in %s\n", fname);
  20.159 -			return FALSE;
  20.160 -		}
  20.161 -
  20.162 -		DEBUG(3) debugf("flags = %d\n", flags);
  20.163 -
  20.164 -		if ((strcmp(gc->protocol, "pop3") == 0) || (strcmp(gc->protocol, "apop") == 0)) {
  20.165 -			pop3_base *popb = NULL;
  20.166 -
  20.167 -			if (strcmp(gc->protocol, "apop") == 0) {
  20.168 -				flags |= POP3_FLAG_APOP;
  20.169 -				DEBUG(3) debugf("attempting to get mail for user %s at host %s for %s@%s with apop\n",
  20.170 -				                gc->login_user, gc->server_name, gc->address->local_part, gc->address->domain);
  20.171 -			} else {
  20.172 -				DEBUG(3) debugf("attempting to get mail for user %s at host %s for %s@%s with pop3\n",
  20.173 -				                gc->login_user, gc->server_name, gc->address->local_part, gc->address->domain);
  20.174 -			}
  20.175 -#ifdef USE_DOTLOCK
  20.176 -			if ((lock = get_lock(gc))) {
  20.177 -#else
  20.178 -			if ((lock = get_lock(gc)) >= 0) {
  20.179 -#endif
  20.180 -				if (gc->wrapper) {
  20.181 -					popb = pop3_in_open_child(gc->wrapper, flags);
  20.182 -					/* quick hack */
  20.183 -					popb->remote_host = gc->server_name;
  20.184 -				} else {
  20.185 -					popb = pop3_in_open(gc->server_name, gc->server_port, gc->resolve_list, flags);
  20.186 -				}
  20.187 -				if (popb) {
  20.188 -					ok = pop3_get(popb, gc->login_user, gc->login_pass, gc->address, gc->return_path,
  20.189 -					              gc->max_count, gc->max_size, gc->max_size_delete);
  20.190 -					pop3_in_close(popb);
  20.191 -				} else {
  20.192 -					ok = FALSE;
  20.193 -					logwrite(LOG_ALERT, "failed to connect to host %s\n", gc->server_name);
  20.194 -				}
  20.195 -#ifdef USE_DOTLOCK
  20.196 -				get_unlock(gc);
  20.197 -#else
  20.198 -				get_unlock(gc, lock);
  20.199 -#endif
  20.200 -			}
  20.201 -		} else {
  20.202 -			logwrite(LOG_ALERT, "get protocol %s unknown\n", gc->protocol);
  20.203 -			ok = FALSE;
  20.204 -		}
  20.205 -
  20.206 -		destroy_get_conf(gc);
  20.207 -	}
  20.208 -	return ok;
  20.209 -}
  20.210 -
  20.211 -gboolean
  20.212 -get_from_name(gchar * name)
  20.213 -{
  20.214 -	gchar *fname = (gchar *) table_find(conf.get_names, name);
  20.215 -	if (fname)
  20.216 -		return get_from_file(fname);
  20.217 -	return FALSE;
  20.218 -}
  20.219 -
  20.220 -gboolean
  20.221 -get_all()
  20.222 -{
  20.223 -	GList *get_table = conf.get_names;
  20.224 -	GList *get_node;
  20.225 -	void (*old_signal) (int);
  20.226 -
  20.227 -	old_signal = signal(SIGCHLD, SIG_DFL);
  20.228 -
  20.229 -	foreach(get_table, get_node) {
  20.230 -		table_pair *pair = (table_pair *) (get_node->data);
  20.231 -		gchar *fname = (gchar *) pair->value;
  20.232 -		pid_t pid;
  20.233 -
  20.234 -		pid = fork();
  20.235 -		if (pid == 0) {
  20.236 -			signal(SIGCHLD, old_signal);
  20.237 -			exit(get_from_file(fname) ? EXIT_SUCCESS : EXIT_FAILURE);
  20.238 -		} else if (pid > 0) {
  20.239 -			int status;
  20.240 -			waitpid(pid, &status, 0);
  20.241 -			if (WEXITSTATUS(status) != EXIT_SUCCESS)
  20.242 -				logwrite(LOG_WARNING, "child returned %d\n", WEXITSTATUS(status));
  20.243 -			if (WIFSIGNALED(status))
  20.244 -				logwrite(LOG_WARNING, "child got signal: %d\n", WTERMSIG(status));
  20.245 -		} else
  20.246 -			logwrite(LOG_WARNING, "forking child failed: %s\n", strerror(errno));
  20.247 -	}
  20.248 -
  20.249 -	signal(SIGCHLD, old_signal);
  20.250 -
  20.251 -	return TRUE;
  20.252 -}
  20.253 -
  20.254 -void
  20.255 -get_online()
  20.256 -{
  20.257 -	GList *gf_list = NULL;
  20.258 -	gchar *connect_name = detect_online();
  20.259 -
  20.260 -	if (connect_name != NULL) {
  20.261 -		void (*old_signal) (int);
  20.262 -
  20.263 -		old_signal = signal(SIGCHLD, SIG_DFL);
  20.264 -
  20.265 -		logwrite(LOG_NOTICE, "detected online configuration %s\n", connect_name);
  20.266 -		/* we are online! */
  20.267 -		gf_list = (GList *) table_find(conf.online_gets, connect_name);
  20.268 -		if (gf_list != NULL) {
  20.269 -			GList *node;
  20.270 -			foreach(gf_list, node) {
  20.271 -				gchar *fname = (gchar *) (node->data);
  20.272 -				pid_t pid;
  20.273 -
  20.274 -				if (fname[0] != '/')
  20.275 -					fname = (gchar *) table_find(conf.get_names, fname);
  20.276 -
  20.277 -				if (fname != NULL) {
  20.278 -					pid = fork();
  20.279 -					if (pid == 0) {
  20.280 -						signal(SIGCHLD, old_signal);
  20.281 -						exit(get_from_file(fname) ? EXIT_SUCCESS : EXIT_FAILURE);
  20.282 -					} else if (pid > 0) {
  20.283 -						int status;
  20.284 -						waitpid(pid, &status, 0);
  20.285 -						if (WEXITSTATUS(status) != EXIT_SUCCESS)
  20.286 -							logwrite(LOG_WARNING, "child returned %d\n", WEXITSTATUS(status));
  20.287 -						if (WIFSIGNALED(status))
  20.288 -							logwrite(LOG_WARNING, "child got signal: %d\n", WTERMSIG(status));
  20.289 -					} else
  20.290 -						logwrite(LOG_WARNING, "forking child failed: %s\n", strerror(errno));
  20.291 -				}
  20.292 -			}
  20.293 -		}
  20.294 -		signal(SIGCHLD, old_signal);
  20.295 -	}
  20.296 -}
  20.297 -
  20.298 -void
  20.299 -get_daemon(gint gival, char *argv[])
  20.300 -{
  20.301 -	struct timeval tm;
  20.302 -	time_t time_before, time_now;
  20.303 -	int sel_ret;
  20.304 -
  20.305 -	/* setup handler for HUP signal: */
  20.306 -	signal(SIGHUP, sighup_handler);
  20.307 -
  20.308 -	/* we can give up root privileges */
  20.309 -	if (!conf.run_as_user) {
  20.310 -		if (setegid(conf.mail_gid) != 0) {
  20.311 -			logwrite(LOG_ALERT, "could not change gid to %d: %s\n", conf.mail_gid, strerror(errno));
  20.312 -			exit(EXIT_FAILURE);
  20.313 -		}
  20.314 -		if (seteuid(conf.mail_uid) != 0) {
  20.315 -			logwrite(LOG_ALERT, "could not change uid to %d: %s\n", conf.mail_uid, strerror(errno));
  20.316 -			exit(EXIT_FAILURE);
  20.317 -		}
  20.318 -	}
  20.319 -
  20.320 -	/*  sel_ret = 0; */
  20.321 -	time(&time_before);
  20.322 -	time_before -= gival;
  20.323 -	sel_ret = -1;
  20.324 -
  20.325 -	while (1) {
  20.326 -		/* see listen_port() in listen.c */
  20.327 -		if (gival > 0) {
  20.328 -			time(&time_now);
  20.329 -			if (sel_ret == 0) {	/* we are either just starting or did a queue run */
  20.330 -				tm.tv_sec = gival;
  20.331 -				tm.tv_usec = 0;
  20.332 -				time_before = time_now;
  20.333 -			} else {
  20.334 -				tm.tv_sec = gival - (time_now - time_before);
  20.335 -				tm.tv_usec = 0;
  20.336 -
  20.337 -				/* race condition, very unlikely (but possible): */
  20.338 -				if (tm.tv_sec < 0)
  20.339 -					tm.tv_sec = 0;
  20.340 -			}
  20.341 -		}
  20.342 -
  20.343 -		if ((sel_ret = select(0, NULL, NULL, NULL, &tm)) < 0) {
  20.344 -			if (errno != EINTR) {
  20.345 -				logwrite(LOG_ALERT, "select: (terminating): %s\n", strerror(errno));
  20.346 -				exit(EXIT_FAILURE);
  20.347 -			} else {
  20.348 -				if (sighup_seen) {
  20.349 -					logwrite(LOG_NOTICE, "HUP signal received. Restarting daemon\n");
  20.350 -
  20.351 -					if (argv == NULL)
  20.352 -						exit(EXIT_SUCCESS);
  20.353 -
  20.354 -					execv(argv[0], &(argv[0]));
  20.355 -					logwrite(LOG_ALERT, "restarting failed: %s\n", strerror(errno));
  20.356 -					exit(EXIT_FAILURE);
  20.357 -
  20.358 -				}
  20.359 -			}
  20.360 -		} else {
  20.361 -			/* If select returns 0, the interval time has elapsed. We start a new get process */
  20.362 -			int pid;
  20.363 -			signal(SIGCHLD, sigchld_handler);
  20.364 -			if ((pid = fork()) == 0) {
  20.365 -				get_online();
  20.366 -
  20.367 -				_exit(EXIT_SUCCESS);
  20.368 -			} else if (pid < 0) {
  20.369 -				logwrite(LOG_ALERT, "could not fork for get run");
  20.370 -			}
  20.371 -		}
  20.372 -	}
  20.373 -}
  20.374 -
  20.375 -#endif
    21.1 --- a/src/masqmail.c	Thu Jul 15 11:48:33 2010 +0200
    21.2 +++ b/src/masqmail.c	Thu Jul 15 14:24:40 2010 +0200
    21.3 @@ -34,15 +34,13 @@
    21.4  
    21.5  #include "masqmail.h"
    21.6  
    21.7 -/* mutually exclusive modes. Note that there is neither a 'get' mode
    21.8 -   nor a 'queue daemon' mode. These, as well as the distinction beween
    21.9 -   the two (non exclusive) daemon (queue and listen) modes are handled
   21.10 -   by flags.*/
   21.11 +/* mutually exclusive modes. Note that there is no 'queue daemon' mode.
   21.12 +   It, as well as the distinction beween the two (non exclusive) daemon
   21.13 +   (queue and listen) modes, is handled by flags.*/
   21.14  typedef enum _mta_mode {
   21.15  	MODE_ACCEPT = 0,  /* accept message on stdin */
   21.16  	MODE_DAEMON,  /* run as daemon */
   21.17  	MODE_RUNQUEUE,  /* single queue run, online or offline */
   21.18 -	MODE_GET_DAEMON,  /* run as get (retrieve) daemon */
   21.19  	MODE_SMTP,  /* accept SMTP on stdin */
   21.20  	MODE_LIST,  /* list queue */
   21.21  	MODE_MCMD,  /* do queue manipulation */
   21.22 @@ -179,49 +177,6 @@
   21.23  	listen_port(do_listen ? conf.listen_addresses : NULL, queue_interval, argv);
   21.24  }
   21.25  
   21.26 -#ifdef ENABLE_POP3
   21.27 -static void
   21.28 -mode_get_daemon(gint get_interval, char *argv[])
   21.29 -{
   21.30 -	guint pid;
   21.31 -
   21.32 -	/* daemon */
   21.33 -	if (!conf.run_as_user) {
   21.34 -		if ((conf.orig_uid != 0) && (conf.orig_uid != conf.mail_uid)) {
   21.35 -			fprintf(stderr, "must be root or %s for daemon.\n", DEF_MAIL_USER);
   21.36 -			exit(EXIT_FAILURE);
   21.37 -		}
   21.38 -	}
   21.39 -
   21.40 -	/* reparent to init only if init is not already the parent */
   21.41 -	if (getppid() != 1) {
   21.42 -		if ((pid = fork()) > 0) {
   21.43 -			exit(EXIT_SUCCESS);
   21.44 -		} else if (pid < 0) {
   21.45 -			logwrite(LOG_ALERT, "could not fork!");
   21.46 -			exit(EXIT_FAILURE);
   21.47 -		}
   21.48 -	}
   21.49 -
   21.50 -	signal(SIGTERM, sigterm_handler);
   21.51 -	write_pidfile(PIDFILEDIR "/masqmail-get.pid");
   21.52 -
   21.53 -	conf.do_verbose = FALSE;
   21.54 -
   21.55 -	/* closing and reopening the log ensures that it is open afterwards
   21.56 -	   because it is possible that the log is assigned to fd 1 and gets
   21.57 -	   thus closes by fclose(stdout). Similar for the debugfile.
   21.58 -	*/
   21.59 -	logclose();
   21.60 -	fclose(stdin);
   21.61 -	fclose(stdout);
   21.62 -	fclose(stderr);
   21.63 -	logopen();
   21.64 -
   21.65 -	get_daemon(get_interval, argv);
   21.66 -}
   21.67 -#endif
   21.68 -
   21.69  #ifdef ENABLE_SMTP_SERVER
   21.70  static void
   21.71  mode_smtp()
   21.72 @@ -336,8 +291,6 @@
   21.73  	/* cmd line flags */
   21.74  	gchar *conf_file = CONF_FILE;
   21.75  	gint arg = 1;
   21.76 -	gboolean do_get = FALSE;
   21.77 -	gboolean do_get_online = FALSE;
   21.78  
   21.79  	gboolean do_listen = FALSE;
   21.80  	gboolean do_runq = FALSE;
   21.81 @@ -351,7 +304,6 @@
   21.82  	mta_mode mta_mode = MODE_ACCEPT;
   21.83  
   21.84  	gint queue_interval = 0;
   21.85 -	gint get_interval = 0;
   21.86  	gboolean opt_t = FALSE;
   21.87  	gboolean opt_i = FALSE;
   21.88  	gboolean opt_odb = FALSE;
   21.89 @@ -362,7 +314,6 @@
   21.90  
   21.91  	gint exit_code = EXIT_SUCCESS;
   21.92  	gchar *route_name = NULL;
   21.93 -	gchar *get_name = NULL;
   21.94  	gchar *progname;
   21.95  	gchar *f_address = NULL;
   21.96  	gchar *full_sender_name = NULL;
   21.97 @@ -464,30 +415,6 @@
   21.98  					}
   21.99  				}
  21.100  				break;
  21.101 -			case 'g':
  21.102 -				do_get = TRUE;
  21.103 -				if (!mta_mode)
  21.104 -					mta_mode = MODE_NONE;  /* to prevent default MODE_ACCEPT */
  21.105 -				if (argv[arg][pos] == 'o') {
  21.106 -					pos++;
  21.107 -					do_get_online = TRUE;
  21.108 -					/* can be NULL, then we use online detection method */
  21.109 -					route_name = get_optarg(argv, argc, &arg, &pos);
  21.110 -
  21.111 -					if (route_name != NULL) {
  21.112 -						if (isdigit(route_name[0])) {
  21.113 -							get_interval = time_interval(route_name, &pos);
  21.114 -							route_name = get_optarg(argv, argc, &arg, &pos);
  21.115 -							mta_mode = MODE_GET_DAEMON;
  21.116 -							do_get = FALSE;
  21.117 -						}
  21.118 -					}
  21.119 -				} else {
  21.120 -					if ((optarg = get_optarg(argv, argc, &arg, &pos))) {
  21.121 -						get_name = get_optarg(argv, argc, &arg, &pos);
  21.122 -					}
  21.123 -				}
  21.124 -				break;
  21.125  			case 'i':
  21.126  				if (argv[arg][pos] == 0) {
  21.127  					opt_i = TRUE;
  21.128 @@ -574,7 +501,6 @@
  21.129  	if (mta_mode == MODE_VERSION) {
  21.130  		gchar *with_resolver = "";
  21.131  		gchar *with_smtp_server = "";
  21.132 -		gchar *with_pop3 = "";
  21.133  		gchar *with_auth = "";
  21.134  		gchar *with_maildir = "";
  21.135  		gchar *with_ident = "";
  21.136 @@ -585,9 +511,6 @@
  21.137  #ifdef ENABLE_SMTP_SERVER
  21.138  		with_smtp_server = " +smtp-server";
  21.139  #endif
  21.140 -#ifdef ENABLE_POP3
  21.141 -		with_pop3 = " +pop3";
  21.142 -#endif
  21.143  #ifdef ENABLE_AUTH
  21.144  		with_auth = " +auth";
  21.145  #endif
  21.146 @@ -598,8 +521,8 @@
  21.147  		with_ident = " +ident";
  21.148  #endif
  21.149  
  21.150 -		printf("%s %s%s%s%s%s%s%s\n", PACKAGE, VERSION, with_resolver, with_smtp_server,
  21.151 -		       with_pop3, with_auth, with_maildir, with_ident);
  21.152 +		printf("%s %s%s%s%s%s%s\n", PACKAGE, VERSION, with_resolver, with_smtp_server,
  21.153 +		       with_auth, with_maildir, with_ident);
  21.154  
  21.155  		exit(EXIT_SUCCESS);
  21.156  	}
  21.157 @@ -699,30 +622,6 @@
  21.158  		}
  21.159  	}
  21.160  
  21.161 -	if (do_get) {
  21.162 -#ifdef ENABLE_POP3
  21.163 -		if ((mta_mode == MODE_NONE) || (mta_mode == MODE_RUNQUEUE)) {
  21.164 -			set_identity(conf.orig_uid, "getting mail");
  21.165 -			if (do_get_online) {
  21.166 -				if (route_name != NULL) {
  21.167 -					conf.online_detect = g_strdup("argument");
  21.168 -					set_online_name(route_name);
  21.169 -				}
  21.170 -				get_online();
  21.171 -			} else {
  21.172 -				if (get_name)
  21.173 -					get_from_name(get_name);
  21.174 -				else
  21.175 -					get_all();
  21.176 -			}
  21.177 -		} else {
  21.178 -			logwrite(LOG_ALERT, "get (-g) only allowed alone or together with queue run (-q)\n");
  21.179 -		}
  21.180 -#else
  21.181 -		fprintf(stderr, "get (pop) support not compiled in\n");
  21.182 -#endif
  21.183 -	}
  21.184 -
  21.185  	switch (mta_mode) {
  21.186  	case MODE_DAEMON:
  21.187  		mode_daemon(do_listen, queue_interval, argv);
  21.188 @@ -745,15 +644,6 @@
  21.189  			}
  21.190  		}
  21.191  		break;
  21.192 -	case MODE_GET_DAEMON:
  21.193 -#ifdef ENABLE_POP3
  21.194 -		if (route_name != NULL) {
  21.195 -			conf.online_detect = g_strdup("argument");
  21.196 -			set_online_name(route_name);
  21.197 -		}
  21.198 -		mode_get_daemon(get_interval, argv);
  21.199 -#endif
  21.200 -		break;
  21.201  
  21.202  	case MODE_SMTP:
  21.203  #ifdef ENABLE_SMTP_SERVER
    22.1 --- a/src/masqmail.h	Thu Jul 15 11:48:33 2010 +0200
    22.2 +++ b/src/masqmail.h	Thu Jul 15 14:24:40 2010 +0200
    22.3 @@ -125,26 +125,6 @@
    22.4  	gboolean pipe_fromhack;
    22.5  } connect_route;
    22.6  
    22.7 -typedef struct _get_conf {
    22.8 -	gchar *protocol;
    22.9 -	gchar *server_name;
   22.10 -	guint server_port;
   22.11 -	gchar *wrapper;
   22.12 -	gchar *login_user;
   22.13 -	gchar *login_pass;
   22.14 -	address *address;
   22.15 -	address *return_path;
   22.16 -	gboolean do_keep;
   22.17 -	gboolean do_uidl;
   22.18 -	gboolean do_uidl_dele;
   22.19 -	gint max_size;
   22.20 -	gboolean max_size_delete;
   22.21 -	gint max_count;
   22.22 -
   22.23 -	GList *resolve_list;
   22.24 -
   22.25 -} get_conf;
   22.26 -
   22.27  typedef struct _masqmail_conf {
   22.28  	gint mail_uid;
   22.29  	gint mail_gid;
   22.30 @@ -207,9 +187,6 @@
   22.31  	gchar *online_file;
   22.32  	gchar *online_pipe;
   22.33  
   22.34 -	GList *get_names;
   22.35 -	GList *online_gets;  /* list of pairs which point to lists */
   22.36 -
   22.37  	gchar *errmsg_file;
   22.38  	gchar *warnmsg_file;
   22.39  	GList *warn_intervals;
   22.40 @@ -231,8 +208,6 @@
   22.41  	PROT_BSMTP,
   22.42  	PROT_SMTP,
   22.43  	PROT_ESMTP,
   22.44 -	PROT_POP3,
   22.45 -	PROT_APOP,
   22.46  	PROT_NUM
   22.47  } prot_id;
   22.48  
   22.49 @@ -386,8 +361,6 @@
   22.50  GList *read_route_list(GList * rf_list, gboolean is_local_net);
   22.51  void destroy_route(connect_route * r);
   22.52  void destroy_route_list(GList * list);
   22.53 -get_conf *read_get_conf(gchar * filename);
   22.54 -void destroy_get_conf(get_conf * gc);
   22.55  connect_route *create_local_route();
   22.56  
   22.57  /* expand.c */
   22.58 @@ -473,13 +446,6 @@
   22.59  gboolean fail_msg(message * msg, gchar * template, GList * failed_rcpts, gchar * err_fmt, va_list args);
   22.60  gboolean warn_msg(message * msg, gchar * template, GList * failed_rcpts, gchar * err_fmt, va_list args);
   22.61  
   22.62 -/* get.c */
   22.63 -gboolean get_from_file(gchar * fname);
   22.64 -gboolean get_from_name(gchar * name);
   22.65 -gboolean get_all(void);
   22.66 -void get_online(void);
   22.67 -void get_daemon(gint gival, char *argv[]);
   22.68 -
   22.69  /* interface.c */
   22.70  gboolean init_sockaddr(struct sockaddr_in *name, interface * iface);
   22.71  int make_server_socket(interface * iface);
    23.1 --- a/src/pop3_in.c	Thu Jul 15 11:48:33 2010 +0200
    23.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    23.3 @@ -1,783 +0,0 @@
    23.4 -/* pop3_in.c, Copyright (C) 2000 by Oliver Kurth,
    23.5 - *
    23.6 - * This program is free software; you can redistribute it and/or modify
    23.7 - * it under the terms of the GNU General Public License as published by
    23.8 - * the Free Software Foundation; either version 2 of the License, or
    23.9 - * (at your option) any later version.
   23.10 - *
   23.11 - * This program is distributed in the hope that it will be useful,
   23.12 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
   23.13 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   23.14 - * GNU General Public License for more details.
   23.15 - *
   23.16 - * You should have received a copy of the GNU General Public License
   23.17 - * along with this program; if not, write to the Free Software
   23.18 - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
   23.19 - */
   23.20 -
   23.21 -/* see RFC 1725 */
   23.22 -
   23.23 -#include <sys/wait.h>
   23.24 -#include <sys/stat.h>
   23.25 -
   23.26 -#include "masqmail.h"
   23.27 -#include "pop3_in.h"
   23.28 -#include "readsock.h"
   23.29 -
   23.30 -#ifdef USE_LIB_CRYPTO
   23.31 -#include <openssl/md5.h>
   23.32 -#else
   23.33 -#include "md5/global.h"
   23.34 -#include "md5/md5.h"
   23.35 -#endif
   23.36 -
   23.37 -#ifdef ENABLE_POP3
   23.38 -
   23.39 -/* experimental feature */
   23.40 -#define DO_WRITE_UIDL_EARLY 1
   23.41 -
   23.42 -static gchar*
   23.43 -MD5String(char *string)
   23.44 -{
   23.45 -	MD5_CTX context;
   23.46 -	unsigned char digest[16];
   23.47 -	char str_digest[33];
   23.48 -	int i;
   23.49 -
   23.50 -#ifdef USE_LIB_CRYPTO
   23.51 -	MD5(string, strlen(string), digest);
   23.52 -#else
   23.53 -	MD5Init(&context);
   23.54 -	MD5Update(&context, string, strlen(string));
   23.55 -	MD5Final(digest, &context);
   23.56 -#endif
   23.57 -	for (i = 0; i < 16; i++)
   23.58 -		sprintf(str_digest + 2 * i, "%02x", digest[i]);
   23.59 -
   23.60 -	return g_strdup(str_digest);
   23.61 -}
   23.62 -
   23.63 -static pop3_base*
   23.64 -create_pop3base(gint sock, guint flags)
   23.65 -{
   23.66 -	gint dup_sock;
   23.67 -
   23.68 -	pop3_base *popb = (pop3_base *) g_malloc(sizeof(pop3_base));
   23.69 -	if (popb) {
   23.70 -		memset(popb, 0, sizeof(pop3_base));
   23.71 -
   23.72 -		popb->error = pop3_ok;
   23.73 -
   23.74 -		popb->buffer = (gchar *) g_malloc(POP3_BUF_LEN);
   23.75 -
   23.76 -		dup_sock = dup(sock);
   23.77 -		popb->out = fdopen(sock, "w");
   23.78 -		popb->in = fdopen(dup_sock, "r");
   23.79 -
   23.80 -		popb->flags = flags;
   23.81 -	}
   23.82 -	return popb;
   23.83 -}
   23.84 -
   23.85 -static void
   23.86 -pop3_printf(FILE * out, gchar * fmt, ...)
   23.87 -{
   23.88 -	va_list args;
   23.89 -	va_start(args, fmt);
   23.90 -
   23.91 -	DEBUG(4) {
   23.92 -		gchar buf[256];
   23.93 -		va_list args_copy;
   23.94 -
   23.95 -		va_copy(args_copy, args);
   23.96 -		vsnprintf(buf, 255, fmt, args_copy);
   23.97 -		va_end(args_copy);
   23.98 -
   23.99 -		debugf(">>>%s", buf);
  23.100 -	}
  23.101 -
  23.102 -	vfprintf(out, fmt, args);
  23.103 -	fflush(out);
  23.104 -
  23.105 -	va_end(args);
  23.106 -}
  23.107 -
  23.108 -static gboolean
  23.109 -find_uid(pop3_base * popb, gchar * str)
  23.110 -{
  23.111 -	GList *node, *node_next;
  23.112 -
  23.113 -	for (node = popb->list_uid_old; node; node = node_next) {
  23.114 -		gchar *uid = (gchar *) (node->data);
  23.115 -		node_next = node->next;
  23.116 -		if (strcmp(uid, str) == 0) {
  23.117 -#if 1
  23.118 -			popb->list_uid_old = g_list_remove_link(popb->list_uid_old, node);
  23.119 -			g_list_free_1(node);
  23.120 -			g_free(uid);
  23.121 -#endif
  23.122 -			return TRUE;
  23.123 -		}
  23.124 -	}
  23.125 -	return FALSE;
  23.126 -}
  23.127 -
  23.128 -static gboolean
  23.129 -write_uidl(pop3_base * popb, gchar * user)
  23.130 -{
  23.131 -	gboolean ok = FALSE;
  23.132 -	GList *node;
  23.133 -	gchar *filename = g_strdup_printf("%s/popuidl/%s@%s", conf.spool_dir, user, popb->remote_host);
  23.134 -	gchar *tmpname = g_strdup_printf("%s.tmp", filename);
  23.135 -	FILE *fptr = fopen(tmpname, "wt");
  23.136 -
  23.137 -	if (fptr) {
  23.138 -		foreach(popb->drop_list, node) {
  23.139 -			msg_info *info = (msg_info *) (node->data);
  23.140 -			if (info->is_fetched || info->is_in_uidl)
  23.141 -				fprintf(fptr, "%s\n", info->uid);
  23.142 -		}
  23.143 -		fclose(fptr);
  23.144 -		ok = (rename(tmpname, filename) != -1);
  23.145 -	}
  23.146 -
  23.147 -	g_free(tmpname);
  23.148 -	g_free(filename);
  23.149 -	return ok;
  23.150 -}
  23.151 -
  23.152 -static gboolean
  23.153 -read_uidl_fname(pop3_base * popb, gchar * filename)
  23.154 -{
  23.155 -	gboolean ok = FALSE;
  23.156 -	FILE *fptr = fopen(filename, "rt");
  23.157 -	gchar buf[256];
  23.158 -
  23.159 -	if (fptr) {
  23.160 -		popb->list_uid_old = NULL;
  23.161 -		while (fgets(buf, 255, fptr)) {
  23.162 -			if (buf[strlen(buf) - 1] == '\n') {
  23.163 -				g_strchomp(buf);
  23.164 -				popb->list_uid_old = g_list_append(popb->list_uid_old, g_strdup(buf));
  23.165 -			} else {
  23.166 -				logwrite(LOG_ALERT, "broken uid: %s\n", buf);
  23.167 -				break;
  23.168 -			}
  23.169 -		}
  23.170 -		fclose(fptr);
  23.171 -		ok = TRUE;
  23.172 -	} else
  23.173 -		logwrite(LOG_ALERT, "opening of %s failed: %s", filename, strerror(errno));
  23.174 -	return ok;
  23.175 -}
  23.176 -
  23.177 -static gboolean
  23.178 -read_uidl(pop3_base * popb, gchar * user)
  23.179 -{
  23.180 -	gboolean ok = FALSE;
  23.181 -	struct stat statbuf;
  23.182 -	gchar *filename = g_strdup_printf("%s/popuidl/%s@%s", conf.spool_dir, user, popb->remote_host);
  23.183 -
  23.184 -	if (stat(filename, &statbuf) == 0) {
  23.185 -		ok = read_uidl_fname(popb, filename);
  23.186 -		if (ok) {
  23.187 -			GList *drop_node;
  23.188 -			foreach(popb->drop_list, drop_node) {
  23.189 -				msg_info *info = (msg_info *) (drop_node->data);
  23.190 -				if (find_uid(popb, info->uid)) {
  23.191 -					DEBUG(5) debugf("msg with uid '%s' already known\n", info->uid);
  23.192 -					info->is_in_uidl = TRUE;
  23.193 -					popb->uidl_known_cnt++;
  23.194 -				} else
  23.195 -					DEBUG(5) debugf("msg with uid '%s' not known\n", info->uid);
  23.196 -			}
  23.197 -		}
  23.198 -	} else {
  23.199 -		logwrite(LOG_DEBUG, "no uidl file '%s' found\n", filename);
  23.200 -		ok = TRUE;
  23.201 -	}
  23.202 -
  23.203 -	g_free(filename);
  23.204 -	return ok;  /* return code is irrelevant, do not check... */
  23.205 -}
  23.206 -
  23.207 -static gboolean
  23.208 -read_response(pop3_base * popb, int timeout)
  23.209 -{
  23.210 -	gint len;
  23.211 -
  23.212 -	len = read_sockline(popb->in, popb->buffer, POP3_BUF_LEN, timeout, READSOCKL_CHUG);
  23.213 -
  23.214 -	if (len == -3) {
  23.215 -		popb->error = pop3_timeout;
  23.216 -		return FALSE;
  23.217 -	} else if (len == -2) {
  23.218 -		popb->error = pop3_syntax;
  23.219 -		return FALSE;
  23.220 -	} else if (len == -1) {
  23.221 -		popb->error = pop3_eof;
  23.222 -		return FALSE;
  23.223 -	}
  23.224 -
  23.225 -	return TRUE;
  23.226 -}
  23.227 -
  23.228 -static gboolean
  23.229 -check_response(pop3_base * popb)
  23.230 -{
  23.231 -	char c = popb->buffer[0];
  23.232 -
  23.233 -	if (c == '+') {
  23.234 -		popb->error = pop3_ok;
  23.235 -		return TRUE;
  23.236 -	} else if (c == '-')
  23.237 -		popb->error = pop3_fail;
  23.238 -	else
  23.239 -		popb->error = pop3_syntax;
  23.240 -	return FALSE;
  23.241 -}
  23.242 -
  23.243 -static gboolean
  23.244 -strtoi(gchar * p, gchar ** pend, gint * val)
  23.245 -{
  23.246 -	gchar buf[12];
  23.247 -	gint i = 0;
  23.248 -
  23.249 -	while (*p && isspace(*p))
  23.250 -		p++;
  23.251 -	if (*p) {
  23.252 -		while ((i < 11) && isdigit(*p))
  23.253 -			buf[i++] = *(p++);
  23.254 -		buf[i] = 0;
  23.255 -		*val = atoi(buf);
  23.256 -		*pend = p;
  23.257 -		return TRUE;
  23.258 -	}
  23.259 -	return FALSE;
  23.260 -}
  23.261 -
  23.262 -static gboolean
  23.263 -check_response_int_int(pop3_base * popb, gint * arg0, gint * arg1)
  23.264 -{
  23.265 -	if (check_response(popb)) {
  23.266 -		gchar *p = &(popb->buffer[3]);
  23.267 -		gchar *pe;
  23.268 -
  23.269 -		if (strtoi(p, &pe, arg0)) {
  23.270 -			DEBUG(5) debugf("arg0 = %d\n", *arg0);
  23.271 -			p = pe;
  23.272 -			if (strtoi(p, &pe, arg1))
  23.273 -				DEBUG(5) debugf("arg1 = %d\n", *arg1);
  23.274 -			return TRUE;
  23.275 -			/* FIXME: Paolo's code has the return stmt
  23.276 -			   inside the if block right above it. What
  23.277 -			   is correct? */
  23.278 -		}
  23.279 -		popb->error = pop3_syntax;
  23.280 -	}
  23.281 -	return FALSE;
  23.282 -}
  23.283 -
  23.284 -static gboolean
  23.285 -get_drop_listing(pop3_base * popb)
  23.286 -{
  23.287 -	gchar buf[64];
  23.288 -
  23.289 -	DEBUG(5) debugf("get_drop_listing() entered\n");
  23.290 -
  23.291 -	while (1) {
  23.292 -		gint len = read_sockline(popb->in, buf, 64, POP3_CMD_TIMEOUT, READSOCKL_CHUG);
  23.293 -		if (len > 0) {
  23.294 -			if (buf[0] == '.')
  23.295 -				return TRUE;
  23.296 -			else {
  23.297 -				gint number, msg_size;
  23.298 -				gchar *p = buf, *pe;
  23.299 -				if (strtoi(p, &pe, &number)) {
  23.300 -					p = pe;
  23.301 -					if (strtoi(p, &pe, &msg_size)) {
  23.302 -						msg_info *info = g_malloc(sizeof(msg_info));
  23.303 -						info->number = number;
  23.304 -						info->size = msg_size;
  23.305 -
  23.306 -						DEBUG(5) debugf ("get_drop_listing(), number = %d, msg_size = %d\n", number, msg_size);
  23.307 -
  23.308 -						info->uid = NULL;
  23.309 -						info->is_fetched = FALSE;
  23.310 -						info->is_in_uidl = FALSE;
  23.311 -						popb->drop_list = g_list_append(popb->drop_list, info);
  23.312 -					} else {
  23.313 -						popb->error = pop3_syntax;
  23.314 -						break;
  23.315 -					}
  23.316 -				} else {
  23.317 -					popb->error = pop3_syntax;
  23.318 -					break;
  23.319 -				}
  23.320 -			}
  23.321 -		} else {
  23.322 -			popb->error = (len == -1) ? pop3_eof : pop3_timeout;
  23.323 -			return FALSE;
  23.324 -		}
  23.325 -	}
  23.326 -	return FALSE;
  23.327 -}
  23.328 -
  23.329 -static gboolean
  23.330 -get_uid_listing(pop3_base * popb)
  23.331 -{
  23.332 -	gchar buf[64];
  23.333 -
  23.334 -	while (1) {
  23.335 -		gint len = read_sockline(popb->in, buf, 64, POP3_CMD_TIMEOUT, READSOCKL_CHUG);
  23.336 -		if (len > 0) {
  23.337 -			if (buf[0] == '.')
  23.338 -				return TRUE;
  23.339 -			else {
  23.340 -				gint number;
  23.341 -				gchar *p = buf, *pe;
  23.342 -				if (strtoi(p, &pe, &number)) {
  23.343 -					msg_info *info = NULL;
  23.344 -					GList *drop_node;
  23.345 -
  23.346 -					p = pe;
  23.347 -					while (*p && isspace(*p))
  23.348 -						p++;
  23.349 -
  23.350 -					foreach(popb->drop_list, drop_node) {
  23.351 -						msg_info *curr_info = (msg_info *) (drop_node->data);
  23.352 -						if (curr_info->number == number) {
  23.353 -							info = curr_info;
  23.354 -							break;
  23.355 -						}
  23.356 -					}
  23.357 -					if (info) {
  23.358 -						info->uid = g_strdup(p);
  23.359 -						g_strchomp(info->uid);
  23.360 -					}
  23.361 -
  23.362 -				} else {
  23.363 -					popb->error = pop3_syntax;
  23.364 -					break;
  23.365 -				}
  23.366 -			}
  23.367 -		}
  23.368 -	}
  23.369 -	return FALSE;
  23.370 -}
  23.371 -
  23.372 -static gboolean
  23.373 -check_init_response(pop3_base * popb)
  23.374 -{
  23.375 -	if (check_response(popb)) {
  23.376 -		gchar buf[256];
  23.377 -		gchar *p = popb->buffer;
  23.378 -		gint i = 0;
  23.379 -		if (*p) {
  23.380 -			while (*p && (*p != '<'))
  23.381 -				p++;
  23.382 -			while (*p && (*p != '>') && (i < 254))
  23.383 -				buf[i++] = *(p++);
  23.384 -			buf[i++] = '>';
  23.385 -			buf[i] = '\0';
  23.386 -
  23.387 -			popb->timestamp = g_strdup(buf);
  23.388 -
  23.389 -			return TRUE;
  23.390 -		}
  23.391 -	}
  23.392 -	return FALSE;
  23.393 -}
  23.394 -
  23.395 -void
  23.396 -pop3_in_close(pop3_base * popb)
  23.397 -{
  23.398 -	GList *node;
  23.399 -
  23.400 -	fclose(popb->in);
  23.401 -	fclose(popb->out);
  23.402 -
  23.403 -	close(popb->sock);
  23.404 -
  23.405 -	foreach(popb->list_uid_old, node) {
  23.406 -		gchar *uid = (gchar *) (node->data);
  23.407 -		g_free(uid);
  23.408 -	}
  23.409 -	g_list_free(popb->list_uid_old);
  23.410 -
  23.411 -	foreach(popb->drop_list, node) {
  23.412 -		msg_info *info = (msg_info *) (node->data);
  23.413 -		if (info->uid)
  23.414 -			g_free(info->uid);
  23.415 -		g_free(info);
  23.416 -	}
  23.417 -	g_list_free(popb->drop_list);
  23.418 -
  23.419 -	if (popb->buffer)
  23.420 -		g_free(popb->buffer);
  23.421 -	if (popb->timestamp)
  23.422 -		g_free(popb->timestamp);
  23.423 -}
  23.424 -
  23.425 -pop3_base*
  23.426 -pop3_in_open(gchar * host, gint port, GList * resolve_list, guint flags)
  23.427 -{
  23.428 -	pop3_base *popb;
  23.429 -	gint sock;
  23.430 -	mxip_addr *addr;
  23.431 -
  23.432 -	DEBUG(5) debugf("pop3_in_open entered, host = %s\n", host);
  23.433 -
  23.434 -	if ((addr = connect_resolvelist(&sock, host, port, resolve_list))) {
  23.435 -		/* create structure to hold status data: */
  23.436 -		popb = create_pop3base(sock, flags);
  23.437 -		popb->remote_host = addr->name;
  23.438 -
  23.439 -		DEBUG(5) {
  23.440 -			struct sockaddr_in name;
  23.441 -			int len;
  23.442 -			getsockname(sock, (struct sockaddr *) (&name), &len);
  23.443 -			debugf("socket: name.sin_addr = %s\n", inet_ntoa(name.sin_addr));
  23.444 -		}
  23.445 -		return popb;
  23.446 -	}
  23.447 -	return NULL;
  23.448 -}
  23.449 -
  23.450 -pop3_base*
  23.451 -pop3_in_open_child(gchar * cmd, guint flags)
  23.452 -{
  23.453 -	pop3_base *popb;
  23.454 -	gint sock;
  23.455 -
  23.456 -	DEBUG(5) debugf("pop3_in_open_child entered, cmd = %s\n", cmd);
  23.457 -	sock = child(cmd);
  23.458 -	if (sock > 0) {
  23.459 -		popb = create_pop3base(sock, flags);
  23.460 -		popb->remote_host = NULL;
  23.461 -		return popb;
  23.462 -	}
  23.463 -	logwrite(LOG_ALERT, "child failed (sock = %d): %s\n", sock, strerror(errno));
  23.464 -
  23.465 -	return NULL;
  23.466 -}
  23.467 -
  23.468 -gboolean
  23.469 -pop3_in_init(pop3_base * popb)
  23.470 -{
  23.471 -	gboolean ok;
  23.472 -
  23.473 -	if ((ok = read_response(popb, POP3_INITIAL_TIMEOUT))) {
  23.474 -		ok = check_init_response(popb);
  23.475 -	}
  23.476 -	if (!ok)
  23.477 -		/* pop3_in_log_failure(popb, NULL); */
  23.478 -		logwrite(LOG_ALERT, "pop3 failed\n");
  23.479 -	return ok;
  23.480 -}
  23.481 -
  23.482 -gboolean
  23.483 -pop3_in_login(pop3_base * popb, gchar * user, gchar * pass)
  23.484 -{
  23.485 -	if (popb->flags & POP3_FLAG_APOP) {
  23.486 -
  23.487 -		gchar *string = g_strdup_printf("%s%s", popb->timestamp, pass);
  23.488 -		gchar *digest = MD5String(string);
  23.489 -		pop3_printf(popb->out, "APOP %s %s\r\n", user, digest);
  23.490 -		g_free(string);
  23.491 -		g_free(digest);
  23.492 -		if (read_response(popb, POP3_CMD_TIMEOUT)) {
  23.493 -			if (check_response(popb))
  23.494 -				return TRUE;
  23.495 -			else
  23.496 -				popb->error = pop3_login_failure;
  23.497 -		}
  23.498 -
  23.499 -	} else {
  23.500 -
  23.501 -		pop3_printf(popb->out, "USER %s\r\n", user);
  23.502 -		if (read_response(popb, POP3_CMD_TIMEOUT)) {
  23.503 -			if (check_response(popb)) {
  23.504 -				pop3_printf(popb->out, "PASS %s\r\n", pass);
  23.505 -				if (read_response(popb, POP3_CMD_TIMEOUT)) {
  23.506 -					if (check_response(popb))
  23.507 -						return TRUE;
  23.508 -					else
  23.509 -						popb->error = pop3_login_failure;
  23.510 -				}
  23.511 -			} else {
  23.512 -				popb->error = pop3_login_failure;
  23.513 -			}
  23.514 -		}
  23.515 -	}
  23.516 -	return FALSE;
  23.517 -}
  23.518 -
  23.519 -gboolean
  23.520 -pop3_in_stat(pop3_base * popb)
  23.521 -{
  23.522 -	pop3_printf(popb->out, "STAT\r\n");
  23.523 -	if (read_response(popb, POP3_CMD_TIMEOUT)) {
  23.524 -		gint msg_cnt, mbox_size;
  23.525 -		if (check_response_int_int(popb, &msg_cnt, &mbox_size)) {
  23.526 -			popb->msg_cnt = msg_cnt;
  23.527 -			popb->mbox_size = mbox_size;
  23.528 -
  23.529 -			return TRUE;
  23.530 -		}
  23.531 -	}
  23.532 -	return FALSE;
  23.533 -}
  23.534 -
  23.535 -gboolean
  23.536 -pop3_in_list(pop3_base * popb)
  23.537 -{
  23.538 -	pop3_printf(popb->out, "LIST\r\n");
  23.539 -	if (read_response(popb, POP3_CMD_TIMEOUT)) {
  23.540 -		if (get_drop_listing(popb)) {
  23.541 -			return TRUE;
  23.542 -		}
  23.543 -	}
  23.544 -	return FALSE;
  23.545 -}
  23.546 -
  23.547 -gboolean
  23.548 -pop3_in_dele(pop3_base * popb, gint number)
  23.549 -{
  23.550 -	pop3_printf(popb->out, "DELE %d\r\n", number);
  23.551 -	if (read_response(popb, POP3_CMD_TIMEOUT)) {
  23.552 -		return TRUE;
  23.553 -	}
  23.554 -	return FALSE;
  23.555 -}
  23.556 -
  23.557 -message*
  23.558 -pop3_in_retr(pop3_base * popb, gint number, address * rcpt)
  23.559 -{
  23.560 -	accept_error err;
  23.561 -
  23.562 -	pop3_printf(popb->out, "RETR %d\r\n", number);
  23.563 -	if (read_response(popb, POP3_CMD_TIMEOUT)) {
  23.564 -		message *msg = create_message();
  23.565 -		msg->received_host = popb->remote_host;
  23.566 -		msg->received_prot = (popb->flags & POP3_FLAG_APOP) ? PROT_APOP : PROT_POP3;
  23.567 -		msg->transfer_id = (popb->next_id)++;
  23.568 -		msg->rcpt_list = g_list_append(NULL, copy_address(rcpt));
  23.569 -
  23.570 -		if ((err = accept_message(popb->in, msg, ACC_MAIL_FROM_HEAD
  23.571 -		                          | (conf.do_save_envelope_to ? ACC_SAVE_ENVELOPE_TO : 0)))
  23.572 -		    == AERR_OK)
  23.573 -			return msg;
  23.574 -
  23.575 -		destroy_message(msg);
  23.576 -	}
  23.577 -	return NULL;
  23.578 -}
  23.579 -
  23.580 -gboolean
  23.581 -pop3_in_uidl(pop3_base * popb)
  23.582 -{
  23.583 -	pop3_printf(popb->out, "UIDL\r\n");
  23.584 -	if (read_response(popb, POP3_CMD_TIMEOUT)) {
  23.585 -		if (get_uid_listing(popb)) {
  23.586 -			return TRUE;
  23.587 -		}
  23.588 -	}
  23.589 -	return FALSE;
  23.590 -}
  23.591 -
  23.592 -gboolean
  23.593 -pop3_in_quit(pop3_base * popb)
  23.594 -{
  23.595 -	pop3_printf(popb->out, "QUIT\r\n");
  23.596 -	DEBUG(4) debugf("QUIT\n");
  23.597 -	signal(SIGALRM, SIG_DFL);
  23.598 -	return TRUE;
  23.599 -}
  23.600 -
  23.601 -/* Send a DELE command for each message in (the old) uid listing.
  23.602 -   This is to prevent mail from to be kept on server, if a previous
  23.603 -   transaction was interupted. */
  23.604 -gboolean
  23.605 -pop3_in_uidl_dele(pop3_base * popb)
  23.606 -{
  23.607 -	GList *drop_node;
  23.608 -
  23.609 -	foreach(popb->drop_list, drop_node) {
  23.610 -		msg_info *info = (msg_info *) (drop_node->data);
  23.611 -		/* if(find_uid(popb, info->uid)){ */
  23.612 -		if (info->is_in_uidl) {
  23.613 -			if (!pop3_in_dele(popb, info->number))
  23.614 -				return FALSE;
  23.615 -			/* TODO: it probably makes sense to also delete this uid from the listing */
  23.616 -		}
  23.617 -	}
  23.618 -	return TRUE;
  23.619 -}
  23.620 -
  23.621 -gboolean
  23.622 -pop3_get(pop3_base * popb, gchar * user, gchar * pass, address * rcpt, address * return_path,
  23.623 -         gint max_count, gint max_size, gboolean max_size_delete)
  23.624 -{
  23.625 -	gboolean ok = FALSE;
  23.626 -	gint num_children = 0;
  23.627 -
  23.628 -	DEBUG(5) debugf("rcpt = %s@%s\n", rcpt->local_part, rcpt->domain);
  23.629 -
  23.630 -	signal(SIGCHLD, SIG_DFL);
  23.631 -
  23.632 -	if (pop3_in_init(popb)) {
  23.633 -		if (pop3_in_login(popb, user, pass)) {
  23.634 -			if (pop3_in_stat(popb)) {
  23.635 -				if (popb->msg_cnt > 0) {
  23.636 -
  23.637 -					logwrite(LOG_NOTICE | LOG_VERBOSE, "%d message(s) for user %s at %s\n",
  23.638 -					         popb->msg_cnt, user, popb->remote_host);
  23.639 -
  23.640 -					if (pop3_in_list(popb)) {
  23.641 -						gboolean do_get = !(popb->flags & POP3_FLAG_UIDL);
  23.642 -						if (!do_get)
  23.643 -							do_get = pop3_in_uidl(popb);
  23.644 -						if (do_get) {
  23.645 -							gint count = 0;
  23.646 -							GList *drop_node;
  23.647 -
  23.648 -							if (popb->flags & POP3_FLAG_UIDL) {
  23.649 -								read_uidl(popb, user);
  23.650 -								logwrite(LOG_VERBOSE | LOG_NOTICE, "%d message(s) already in uidl.\n", popb->uidl_known_cnt);
  23.651 -							}
  23.652 -							if ((popb->flags & POP3_FLAG_UIDL) && (popb->flags & POP3_FLAG_UIDL_DELE))
  23.653 -								pop3_in_uidl_dele(popb);
  23.654 -
  23.655 -							foreach(popb->drop_list, drop_node) {
  23.656 -
  23.657 -								msg_info *info = (msg_info *) (drop_node->data);
  23.658 -								gboolean do_get_this = !(popb->flags & POP3_FLAG_UIDL);
  23.659 -								/* if(!do_get_this) do_get_this = !find_uid(popb, info->uid); */
  23.660 -								if (!do_get_this)
  23.661 -									do_get_this = !(info->is_in_uidl);
  23.662 -								if (do_get_this) {
  23.663 -
  23.664 -									if ((info->size < max_size) || (max_size == 0)) {
  23.665 -										message *msg;
  23.666 -
  23.667 -										logwrite(LOG_VERBOSE | LOG_NOTICE, "receiving message %d\n", info->number);
  23.668 -										msg = pop3_in_retr(popb, info->number, rcpt);
  23.669 -
  23.670 -										if (msg) {
  23.671 -											if (return_path)
  23.672 -												msg->return_path = copy_address(return_path);
  23.673 -											if (spool_write(msg, TRUE)) {
  23.674 -												pid_t pid;
  23.675 -												logwrite(LOG_NOTICE, "%s <= %s host=%s with %s\n", msg->uid,
  23.676 -												         addr_string(msg->return_path), popb->remote_host,
  23.677 -												         (popb->flags & POP3_FLAG_APOP) ? prot_names [PROT_APOP] : prot_names [PROT_POP3]);
  23.678 -												info->is_fetched = TRUE;
  23.679 -												count++;
  23.680 -#if DO_WRITE_UIDL_EARLY
  23.681 -												if (popb->flags & POP3_FLAG_UIDL)
  23.682 -													write_uidl(popb, user);
  23.683 -#endif
  23.684 -												if (!conf.do_queue) {
  23.685 -
  23.686 -													/* wait for child processes. If there are too many, we wait blocking, before we fork another one */
  23.687 -													while (num_children > 0) {
  23.688 -														int status, options = WNOHANG;
  23.689 -														pid_t pid;
  23.690 -
  23.691 -														if (num_children >= POP3_MAX_CHILDREN) {
  23.692 -															logwrite(LOG_NOTICE, "too many children - waiting\n");
  23.693 -															options = 0;
  23.694 -														}
  23.695 -														if ((pid = waitpid(0, &status, options)) > 0) {
  23.696 -															num_children--;
  23.697 -															if (WEXITSTATUS(status) != EXIT_SUCCESS)
  23.698 -																logwrite(LOG_WARNING, "delivery process with pid %d returned %d\n", pid, WEXITSTATUS (status));
  23.699 -															if (WIFSIGNALED(status))
  23.700 -																logwrite(LOG_WARNING, "delivery process with pid %d got signal: %d\n", pid, WTERMSIG (status));
  23.701 -														} else if (pid < 0) {
  23.702 -															logwrite(LOG_WARNING, "wait got error: %s\n", strerror(errno));
  23.703 -														}
  23.704 -													}
  23.705 -
  23.706 -													if ((pid = fork()) == 0) {
  23.707 -														deliver(msg);
  23.708 -														_exit(EXIT_SUCCESS);
  23.709 -													} else if (pid < 0) {
  23.710 -														logwrite(LOG_ALERT | LOG_VERBOSE, "could not fork for delivery, id = %s: %s\n", msg->uid, strerror(errno));
  23.711 -													} else
  23.712 -														num_children++;
  23.713 -												} else {
  23.714 -													DEBUG(1) debugf("queuing forced by configuration or option.\n");
  23.715 -												}
  23.716 -												if (popb->flags & POP3_FLAG_DELETE)
  23.717 -													pop3_in_dele(popb, info->number);
  23.718 -
  23.719 -												destroy_message(msg);
  23.720 -											}	/* if(spool_write(msg, TRUE)) */
  23.721 -										} else {
  23.722 -											logwrite(LOG_ALERT, "retrieving of message %d failed: %d\n", info->number, popb->error);
  23.723 -										}
  23.724 -									} else {
  23.725 -										/* info->size > max_size */
  23.726 -										logwrite(LOG_NOTICE | LOG_VERBOSE, "size of message #%d (%d) > max_size (%d)\n", info->number, info->size, max_size);
  23.727 -										if (max_size_delete)
  23.728 -											if (popb->flags & POP3_FLAG_DELETE)
  23.729 -												pop3_in_dele(popb, info->number);
  23.730 -									}
  23.731 -								} /* if(do_get_this) ... */
  23.732 -								else {
  23.733 -									if (popb->flags & POP3_FLAG_UIDL) {
  23.734 -										info->is_fetched = TRUE;  /* obsolete? */
  23.735 -										logwrite(LOG_VERBOSE, "message %d already known\n", info->number);
  23.736 -										DEBUG(1) debugf("message %d (uid = %s) not fetched\n", info->number, info->uid);
  23.737 -#if 0
  23.738 -#if DO_WRITE_UIDL_EARLY
  23.739 -										write_uidl(popb, user);  /* obsolete? */
  23.740 -#endif
  23.741 -#endif
  23.742 -									}
  23.743 -								}
  23.744 -								if ((max_count != 0) && (count >= max_count))
  23.745 -									break;
  23.746 -							}	/* foreach() */
  23.747 -#if DO_WRITE_UIDL_EARLY
  23.748 -#else
  23.749 -							if (popb->flags & POP3_FLAG_UIDL)
  23.750 -								write_uidl(popb, user);
  23.751 -#endif
  23.752 -						}  /* if(pop3_in_uidl(popb) ... */
  23.753 -					}  /* if(pop3_in_list(popb)) */
  23.754 -				}  /* if(popb->msg_cnt > 0) */
  23.755 -				else {
  23.756 -					logwrite(LOG_NOTICE | LOG_VERBOSE, "no messages for user %s at %s\n", user, popb->remote_host);
  23.757 -				}
  23.758 -				ok = TRUE;
  23.759 -			}
  23.760 -			pop3_in_quit(popb);
  23.761 -		} else {
  23.762 -			logwrite(LOG_ALERT | LOG_VERBOSE, "pop3 login failed for user %s, host = %s\n", user, popb->remote_host);
  23.763 -		}
  23.764 -	}
  23.765 -	if (!ok) {
  23.766 -		logwrite(LOG_ALERT | LOG_VERBOSE, "pop3 failed, error = %d\n", popb->error);
  23.767 -	}
  23.768 -
  23.769 -	while (num_children > 0) {
  23.770 -		int status;
  23.771 -		pid_t pid;
  23.772 -		if ((pid = wait(&status)) > 0) {
  23.773 -			num_children--;
  23.774 -			if (WEXITSTATUS(status) != EXIT_SUCCESS)
  23.775 -				logwrite(LOG_WARNING, "delivery process with pid %d returned %d\n", pid, WEXITSTATUS(status));
  23.776 -			if (WIFSIGNALED(status))
  23.777 -				logwrite(LOG_WARNING, "delivery process with pid %d got signal: %d\n", pid, WTERMSIG(status));
  23.778 -		} else {
  23.779 -			logwrite(LOG_WARNING, "wait got error: %s\n", strerror(errno));
  23.780 -		}
  23.781 -	}
  23.782 -
  23.783 -	return ok;
  23.784 -}
  23.785 -
  23.786 -#endif
    24.1 --- a/src/pop3_in.h	Thu Jul 15 11:48:33 2010 +0200
    24.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    24.3 @@ -1,80 +0,0 @@
    24.4 -/* pop3_in.h, Copyright 2000 (C) Oliver Kurth,
    24.5 - *
    24.6 - * This program is free software; you can redistribute it and/or modify
    24.7 - * it under the terms of the GNU General Public License as published by
    24.8 - * the Free Software Foundation; either version 2 of the License, or
    24.9 - * (at your option) any later version.
   24.10 - *
   24.11 - * This program is distributed in the hope that it will be useful,
   24.12 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
   24.13 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   24.14 - * GNU General Public License for more details.
   24.15 - *
   24.16 - * You should have received a copy of the GNU General Public License
   24.17 - * along with this program; if not, write to the Free Software
   24.18 - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
   24.19 - */
   24.20 -
   24.21 -#ifdef ENABLE_POP3
   24.22 -
   24.23 -#define POP3_BUF_LEN 1024
   24.24 -
   24.25 -#define POP3_INITIAL_TIMEOUT 5*60
   24.26 -#define POP3_CMD_TIMEOUT 5*60
   24.27 -#define POP3_DATA_TIMEOUT 5*60
   24.28 -#define POP3_FINAL_TIMEOUT 10*60
   24.29 -
   24.30 -#define POP3_FLAG_DELETE 0x01
   24.31 -#define POP3_FLAG_UIDL 0x02
   24.32 -#define POP3_FLAG_UIDL_DELE 0x04
   24.33 -#define POP3_FLAG_APOP 0x08
   24.34 -
   24.35 -#define POP3_MAX_CHILDREN 2
   24.36 -
   24.37 -typedef enum _pop3_error {
   24.38 -	pop3_ok = 0,
   24.39 -	pop3_fail,
   24.40 -	pop3_eof,
   24.41 -	pop3_timeout,
   24.42 -	pop3_login_failure,
   24.43 -	pop3_syntax
   24.44 -} pop3_error;
   24.45 -
   24.46 -typedef struct pop3_base {
   24.47 -	FILE *in;
   24.48 -	FILE *out;
   24.49 -	gint sock;
   24.50 -	gint dup_sock;
   24.51 -
   24.52 -	gchar *remote_host;
   24.53 -	gchar *buffer;
   24.54 -
   24.55 -	gint next_id;
   24.56 -	gint msg_cnt;
   24.57 -	gint uidl_known_cnt;
   24.58 -	gint mbox_size;
   24.59 -
   24.60 -	GList *list_uid_old;
   24.61 -	GList *drop_list;
   24.62 -
   24.63 -	gchar *timestamp;
   24.64 -
   24.65 -	guint flags;
   24.66 -
   24.67 -	pop3_error error;
   24.68 -} pop3_base;
   24.69 -
   24.70 -typedef struct _msg_info {
   24.71 -	gint number;
   24.72 -	gint size;
   24.73 -	gchar *uid;
   24.74 -	gboolean is_fetched;
   24.75 -	gboolean is_in_uidl;
   24.76 -} msg_info;
   24.77 -
   24.78 -pop3_base *pop3_in_open(gchar * host, gint port, GList * resolve_list, guint flags);
   24.79 -pop3_base *pop3_in_open_child(gchar * cmd, guint flags);
   24.80 -void pop3_in_close(pop3_base * popb);
   24.81 -gboolean pop3_get(pop3_base * popb, gchar * user, gchar * pass, address * rcpt, address * return_path, gint max_count, gint max_size, gboolean max_size_delete);
   24.82 -
   24.83 -#endif