imapext-2007

changeset 3:2366b362676d

imap-2007f
author HIROSE Yuuji <yuuji@gentei.org>
date Thu, 30 Oct 2014 00:00:57 +0900
parents fc6002700ecd
children d741b3ecc917
files Makefile docs/RELNOTES src/c-client/auth_log.c src/c-client/auth_md5.c src/c-client/mail.c src/c-client/mail.h src/imapd/imapd.c src/ipopd/ipop3d.c src/osdep/unix/Makefile src/osdep/unix/env_unix.c src/osdep/unix/os_a52.c src/osdep/unix/os_a52.h src/osdep/unix/tcp_unix.c src/osdep/unix/unix.c
diffstat 14 files changed, 162 insertions(+), 254 deletions(-) [+]
line diff
     1.1 --- a/Makefile	Mon Sep 14 20:06:41 2009 +0900
     1.2 +++ b/Makefile	Thu Oct 30 00:00:57 2014 +0900
     1.3 @@ -37,6 +37,7 @@
     1.4  # The following ports are bundled:
     1.5  # a32	AIX 3.2 for RS/6000
     1.6  # a41	AIX 4.1 for RS/6000
     1.7 +# a52	Attempt at AIX 5.2
     1.8  # aix	AIX/370 (not RS/6000!!)
     1.9  # ami	AmigaDOS
    1.10  # am2	AmigaDOS with a 68020+
    1.11 @@ -252,9 +253,7 @@
    1.12  #	British.  As of 2005, the Julian calendar and the Gregorian calendar
    1.13  #	diverge by 15 days.
    1.14  
    1.15 -# EXTRACFLAGS=-DQMAIL -DRESTRICT_POP -DXADDR_DELIM="+" -DDOTQMAIL=".forward"
    1.16 -## EXTRACFLAGS=-DQMAIL -DRESTRICT_POP
    1.17 -EXTRACFLAGS=-DQMAIL -DRESTRICT_POP -DINET6
    1.18 +EXTRACFLAGS=
    1.19  
    1.20  
    1.21  # Extra linker flags (additional/alternative libraries, etc.)
    1.22 @@ -308,7 +307,7 @@
    1.23  
    1.24  # Note on SCO you may have to set LN to "ln".
    1.25  
    1.26 -a32 a41 aix bs3 bsi d-g d54 do4 drs epx ga4 gas gh9 ghp ghs go5 gsc gsg gso gul h11 hpp hpx lnp lyn mct mnt nec nto nxt nx3 osf os4 ptx qnx sc5 sco sgi sg6 shp sl4 sl5 slx snx soc sol sos uw2: an
    1.27 +a32 a41 a52 aix bs3 bsi d-g d54 do4 drs epx ga4 gas gh9 ghp ghs go5 gsc gsg gso gul h11 hpp hpx lnp lyn mct mnt nec nto nxt nx3 osf os4 ptx qnx sc5 sco sgi sg6 shp sl4 sl5 slx snx soc sol sos uw2: an
    1.28  	$(BUILD) BUILDTYPE=$@
    1.29  
    1.30  # If you use sv4, you may find that it works to move it to use the an process.
    1.31 @@ -730,7 +729,6 @@
    1.32  clean:
    1.33  	@echo Removing old processed sources and binaries...
    1.34  	$(SH) -c '$(RM) an ua OSTYPE SPECIALS c-client mtest imapd ipopd mailutil mlock dmail tmail || true'
    1.35 -	$(SH) -c '$(RM) ip6 || true'
    1.36  	$(CD) tools;$(MAKE) clean
    1.37  
    1.38  
     2.1 --- a/docs/RELNOTES	Mon Sep 14 20:06:41 2009 +0900
     2.2 +++ b/docs/RELNOTES	Thu Oct 30 00:00:57 2014 +0900
     2.3 @@ -11,6 +11,17 @@
     2.4   * ========================================================================
     2.5   */
     2.6  
     2.7 +Updated: 22 July 2011
     2.8 +
     2.9 +imap-2007f fixes a couple bugs.
    2.10 +Fix for RFC 4959 Initial Client Response auth failures noted first by
    2.11 +  MacOSX Lion Mail users.
    2.12 +Adjust tcp_open.c:tcp_socket_open to make it a little more useful by adding
    2.13 +  a write file descriptor test to the select in the case that the open
    2.14 +  timeout is set.
    2.15 +In osdep/unix/env_unix.c:create_path there was a printf that should have
    2.16 +  been an sprintf. Doesn't matter on modern systems.
    2.17 +
    2.18  Updated: 16 December 2008
    2.19  
    2.20  imap-2007e is a maintenance release, consisting primarily of bugfixes to
     3.1 --- a/src/c-client/auth_log.c	Mon Sep 14 20:06:41 2009 +0900
     3.2 +++ b/src/c-client/auth_log.c	Thu Oct 30 00:00:57 2014 +0900
     3.3 @@ -105,10 +105,6 @@
     3.4    char *ret = NIL;
     3.5    char *user,*pass,*authuser;
     3.6    if (user = (*responder) (PWD_USER,sizeof (PWD_USER),NIL)) {
     3.7 -#ifdef QMAIL
     3.8 -    extern char* conv_virtualdomain(char*);
     3.9 -    user = conv_virtualdomain(user);
    3.10 -#endif
    3.11      if (pass = (*responder) (PWD_PWD,sizeof (PWD_PWD),NIL)) {
    3.12  				/* delimit user from possible admin */
    3.13        if (authuser = strchr (user,'*')) *authuser++ = '\0';
     4.1 --- a/src/c-client/auth_md5.c	Mon Sep 14 20:06:41 2009 +0900
     4.2 +++ b/src/c-client/auth_md5.c	Thu Oct 30 00:00:57 2014 +0900
     4.3 @@ -75,11 +75,9 @@
     4.4  
     4.5  long auth_md5_valid (void)
     4.6  {
     4.7 -#ifndef QMAIL			/* qmail extension can always handle MD5 */
     4.8    struct stat sbuf;
     4.9  				/* server forbids MD5 if no MD5 enable file */
    4.10    if (stat (MD5ENABLE,&sbuf)) auth_md5.server = NIL;
    4.11 -#endif
    4.12    return T;			/* MD5 is otherwise valid */
    4.13  }
    4.14  
    4.15 @@ -188,7 +186,6 @@
    4.16  char *auth_md5_pwd (char *user)
    4.17  {
    4.18    struct stat sbuf;
    4.19 -#ifndef QMAIL
    4.20    int fd = open (MD5ENABLE,O_RDONLY,NIL);
    4.21    unsigned char *s,*t,*buf,*lusr,*lret;
    4.22    char *r;
    4.23 @@ -217,77 +214,6 @@
    4.24      fs_give ((void **) &buf);	/* flush the buffer */
    4.25      close (fd);			/* don't need file any longer */
    4.26    }
    4.27 -#else
    4.28 -# ifndef USERAPOPFILE
    4.29 -#  define USERAPOPFILE ".apop" 
    4.30 -# endif
    4.31 -# ifndef XADDR_DELIM
    4.32 -#  ifdef POSTFIX		/* Same if-condition is in maildir.c.. sorry */
    4.33 -#   define XADDR_DELIM "+"
    4.34 -#  else
    4.35 -#   define XADDR_DELIM "-"
    4.36 -#  endif
    4.37 -# endif
    4.38 -  extern char *myMailSuffix;
    4.39 -  char mycrypt[BUFSIZ+1];
    4.40 -  char *ret = NIL, *tmp=NIL;
    4.41 -  FILE *apopfile = NIL;
    4.42 -  struct passwd *pw = getpwnam(user);
    4.43 -  if (!pw) pw = getpwnam(lcase(tmp=cpystr(user)));
    4.44 -  if (!pw && strstr(user, XADDR_DELIM)) { /* Check qmail alias */
    4.45 -    char tmp[BUFSIZ];
    4.46 -    char *s = user;
    4.47 -    memset(tmp, 0, BUFSIZ);
    4.48 -    while (*s && s && !pw) {
    4.49 -      s = strstr(s, XADDR_DELIM);
    4.50 -      if (!s) break;
    4.51 -      strncpy(tmp, user, s-user);
    4.52 -      s++;
    4.53 -      pw = getpwnam(tmp);
    4.54 -    }
    4.55 -    if (pw) {
    4.56 -      myMailSuffix = lcase(cpystr(s-1));
    4.57 -      user[strlen(tmp)] = '\0'; /* zap suffix */
    4.58 -    }
    4.59 -  }
    4.60 -  if (pw) {
    4.61 -    snprintf(mycrypt, BUFSIZ, "%s/%s", pw->pw_dir, USERAPOPFILE);
    4.62 -    if (NIL != myMailSuffix) strcat(mycrypt, myMailSuffix);
    4.63 -    if (stat(mycrypt, &sbuf) < 0) {
    4.64 -      /* printf("Cannot stat [%s]\015\n", mycrypt); */
    4.65 -      return ret;
    4.66 -    }
    4.67 -    if (sbuf.st_mode & ~(S_IFREG | S_IREAD | S_IWRITE)) {
    4.68 -      /* printf("Your apoppassword file is readable by others. Do chmod 600 %s%c\n", mycrypt, 015); */
    4.69 -      return ret;
    4.70 -    }
    4.71 -#ifdef APOPOPEN
    4.72 -    if (stat(APOPOPEN, &sbuf) >= 0) {	/* if APPOPEN exists */
    4.73 -      /* read apop password via APOPOPEN program */
    4.74 -      int bytes = 3+strlen(APOPOPEN)+strlen(mycrypt);
    4.75 -      char *aproc = (char*) fs_get(bytes);
    4.76 -      snprintf(aproc, bytes, "%s %s%c", APOPOPEN, mycrypt, '\0');
    4.77 -      apopfile = popen(aproc, "r");
    4.78 -      memset(aproc, 0, bytes);
    4.79 -      fs_give((void**)&aproc);
    4.80 -    }
    4.81 -#endif /* APOPOPEN */
    4.82 -    if ((NIL!=apopfile) || (apopfile = fopen( mycrypt, "r" ))) {
    4.83 -      fgets(mycrypt, sizeof(mycrypt) - 1, apopfile);
    4.84 -      fclose(apopfile);
    4.85 -      if (mycrypt[0]) {
    4.86 -	char p = strlen(mycrypt);
    4.87 -	while (p > 0 && (mycrypt[p-1] == '\n' || mycrypt[p-1] == '\r')) {
    4.88 -	   mycrypt[--p] = '\0'; /* zap trailing newlines */
    4.89 -	}
    4.90 -      }
    4.91 -    } else {
    4.92 -      return ret;
    4.93 -    }
    4.94 -    ret = cpystr(mycrypt);
    4.95 -    memset(mycrypt, 0, sizeof(mycrypt));
    4.96 -  }
    4.97 -#endif				/* if QMAIL */
    4.98    return ret;			/* return password */
    4.99  }
   4.100  
   4.101 @@ -305,9 +231,6 @@
   4.102    int i,j;
   4.103    char *ret = NIL;
   4.104    char *s,*authuser,tmp[MAILTMPLEN];
   4.105 -#ifdef QMAIL
   4.106 -  char *userback = cpystr(user);
   4.107 -#endif
   4.108    unsigned char digest[MD5DIGLEN];
   4.109    MD5CONTEXT ctx;
   4.110    char *hex = "0123456789abcdef";
   4.111 @@ -337,15 +260,7 @@
   4.112      memset (tmp,0,MAILTMPLEN);	/* erase sensitive information */
   4.113    }
   4.114    if (!ret) sleep (3);		/* slow down possible cracker */
   4.115 -  else {
   4.116 -    extern void permitsmtp();
   4.117 -    /* permitsmtp();*/
   4.118 -  }
   4.119 -#ifdef QMAIL
   4.120 -  return (ret) ? userback : ret;
   4.121 -#else
   4.122    return ret;
   4.123 -#endif
   4.124  }
   4.125  
   4.126  /*
     5.1 --- a/src/c-client/mail.c	Mon Sep 14 20:06:41 2009 +0900
     5.2 +++ b/src/c-client/mail.c	Thu Oct 30 00:00:57 2014 +0900
     5.3 @@ -6081,9 +6081,6 @@
     5.4      if (auth->server && !compare_cstring (auth->name,mechanism))
     5.5        return (!(auth->flags & AU_DISABLE) &&
     5.6  	      ((auth->flags & AU_SECURE) ||
     5.7 -#ifdef QMAIL
     5.8 -	       getenv("INTRANET") ||
     5.9 -#endif
    5.10  	       !mail_parameters (NIL,GET_DISABLEPLAINTEXT,NIL))) ?
    5.11  	(*auth->server) (resp,argc,argv) : NIL;
    5.12    return NIL;			/* no authenticator found */
     6.1 --- a/src/c-client/mail.h	Mon Sep 14 20:06:41 2009 +0900
     6.2 +++ b/src/c-client/mail.h	Thu Oct 30 00:00:57 2014 +0900
     6.3 @@ -21,12 +21,12 @@
     6.4   *		Internet: MRC@Washington.EDU
     6.5   *
     6.6   * Date:	22 November 1989
     6.7 - * Last Edited:	16 December 2008
     6.8 + * Last Edited:	22 July 2011
     6.9   */
    6.10  
    6.11  /* The Version */
    6.12  
    6.13 -#define CCLIENTVERSION "2007e"
    6.14 +#define CCLIENTVERSION "2007f"
    6.15  
    6.16  /* Build parameters */
    6.17  
    6.18 @@ -858,7 +858,6 @@
    6.19    unsigned int spare7 : 1;	/* seventh spare bit */
    6.20    unsigned int spare8 : 1;	/* eighth spare bit */
    6.21    void *sparep;			/* spare pointer */
    6.22 -  void *maildirp;		/* for the Maildir driver */
    6.23    unsigned long user_flags;	/* user-assignable flags */
    6.24  } MESSAGECACHE;
    6.25  
     7.1 --- a/src/imapd/imapd.c	Mon Sep 14 20:06:41 2009 +0900
     7.2 +++ b/src/imapd/imapd.c	Thu Oct 30 00:00:57 2014 +0900
     7.3 @@ -21,7 +21,7 @@
     7.4   *		Internet: MRC@Washington.EDU
     7.5   *
     7.6   * Date:	5 November 1990
     7.7 - * Last Edited:	3 March 2008
     7.8 + * Last Edited:	22 July 2011
     7.9   */
    7.10  
    7.11  /* Parameter files */
    7.12 @@ -553,9 +553,6 @@
    7.13  
    7.14  				/* plaintext login with password */
    7.15  	else if (!strcmp (cmd,"LOGIN")) {
    7.16 -          #ifdef QMAIL
    7.17 -          extern char* conv_virtualdomain(char*);
    7.18 -          #endif
    7.19  	  if (user) fs_give ((void **) &user);
    7.20  	  if (pass) fs_give ((void **) &pass);
    7.21  				/* two arguments */
    7.22 @@ -576,11 +573,7 @@
    7.23  	  else {		/* delimit user from possible admin */
    7.24  	    if (s = strchr (user,'*')) *s++ ='\0';
    7.25  				/* see if username and password are OK */
    7.26 -#ifdef QMAIL
    7.27 -	    if (server_login (conv_virtualdomain(user),pass,s,argc,argv)) {
    7.28 -#else
    7.29  	    if (server_login (user,pass,s,argc,argv)) {
    7.30 -#endif
    7.31  	      state = SELECT;	/* make select */
    7.32  	      alerttime = 0;	/* force alert */
    7.33  	      response = logwin;/* return logged-in capabilities */
    7.34 @@ -2148,7 +2141,7 @@
    7.35  				/* must be at least one BASE64 char */
    7.36    else if (!base64mask[*ret]) return NIL;
    7.37    else {			/* quick and dirty */
    7.38 -    while (base64mask[*s++]);	/* scan until end of BASE64 */
    7.39 +    while (base64mask[*s]) s++;	/* scan until end of BASE64 */
    7.40      if (*s == '=') ++s;		/* allow up to two padding chars */
    7.41      if (*s == '=') ++s;
    7.42    }
     8.1 --- a/src/ipopd/ipop3d.c	Mon Sep 14 20:06:41 2009 +0900
     8.2 +++ b/src/ipopd/ipop3d.c	Thu Oct 30 00:00:57 2014 +0900
     8.3 @@ -96,9 +96,6 @@
     8.4  void trmint ();
     8.5  int pass_login (char *t,int argc,char *argv[]);
     8.6  char *apop_login (char *chal,char *user,char *md5,int argc,char *argv[]);
     8.7 -#ifdef QMAIL
     8.8 -char* conv_virtualdomain(char *account);
     8.9 -#endif
    8.10  char *responder (void *challenge,unsigned long clen,unsigned long *rlen);
    8.11  int mbxopen (char *mailbox);
    8.12  long blat (char *text,long lines,unsigned long size,STRING *st);
    8.13 @@ -131,11 +128,7 @@
    8.14      AUTHENTICATOR *auth = mail_lookup_auth (1);
    8.15      while (auth && compare_cstring (auth->name,"CRAM-MD5")) auth = auth->next;
    8.16  				/* build challenge -- less than 128 chars */
    8.17 -#ifndef QMAIL
    8.18 -    if (!(auth->flags & AU_DISABLE))
    8.19 -#else
    8.20      if (auth && auth->server && !(auth->flags & AU_DISABLE))
    8.21 -#endif
    8.22        sprintf (challenge,"<%lx.%lx@%.64s>",(unsigned long) getpid (),
    8.23  	       (unsigned long) time (0),tcp_serverhost ());
    8.24      else challenge[0] = '\0';	/* no MD5 authentication */
    8.25 @@ -265,17 +258,10 @@
    8.26  				/* get user name */
    8.27  	    if (!(t && *t && (s = strtok (t," ")) && (t = strtok(NIL,"\012"))))
    8.28  	      PSOUT ("-ERR Missing APOP argument\015\012");
    8.29 - #ifdef QMAIL
    8.30 -	    else if (!(user = apop_login (challenge,conv_virtualdomain(s),t,argc,argv))) {
    8.31 - #else /* !QMAIL */
    8.32 -	      else if (!(user = apop_login (challenge,s,t,argc,argv))) {
    8.33 - #endif /* QMAIL */
    8.34 -	      PSOUT ("-ERR Bad APOP (Maybe your password is expired)\015\012");
    8.35 -	      user = cpystr (s);
    8.36 -              syslog (LOG_INFO,"APOP login failure user=%.80s host=%.80s",
    8.37 -                    user,tcp_clienthost ());
    8.38 -	    } else if ((state = mbxopen ("INBOX")) == TRANSACTION)
    8.39 -	      syslog (LOG_INFO,"APOP user=%.80s host=%.80s nmsgs=%ld/%ld",
    8.40 +	    else if (!(user = apop_login (challenge,s,t,argc,argv)))
    8.41 +	      PSOUT ("-ERR Bad APOP\015\012");
    8.42 +	    else if ((state = mbxopen ("INBOX")) == TRANSACTION)
    8.43 +	      syslog (LOG_INFO,"APOP user=%.80s host=%.80s nmsgs=%lu/%lu",
    8.44  		      user,tcp_clienthost (),nmsgs,stream->nmsgs);
    8.45  	    else syslog (LOG_INFO,"APOP user=%.80s host=%.80s no mailbox",
    8.46  			 user,tcp_clienthost ());
    8.47 @@ -293,20 +279,8 @@
    8.48  	  }
    8.49  	  else PSOUT ("+OK STLS completed\015\012");
    8.50  	}
    8.51 -#ifndef RESTRICT_POP
    8.52  	else if (!mail_parameters (NIL,GET_DISABLEPLAINTEXT,NIL) &&
    8.53  		 !strcmp (s,"USER")) {
    8.54 -#else	/* !RESTRICT_POP */
    8.55 -	else if (!strcmp (s,"USER")) {
    8.56 -	  if (getenv("INTRANET") == NIL) {
    8.57 -	    PSOUT("-ERR Sorry, we don't allow POP3 from your network.  Use APOP instead.\015\012");
    8.58 -	    user = cpystr(t);
    8.59 -	    syslog (LOG_INFO,"Plain POP3 is restricted user=%.80s host=%.80s",
    8.60 -		    user,tcp_clienthost ());
    8.61 -	    memset(user, '\0', strlen(user));
    8.62 -	    break;
    8.63 -	  }
    8.64 -#endif
    8.65  	  if (host) fs_give ((void **) &host);
    8.66  	  if (user) fs_give ((void **) &user);
    8.67  	  if (pass) fs_give ((void **) &pass);
    8.68 @@ -320,11 +294,7 @@
    8.69  	      user = cpystr (s);/* copy user name */
    8.70  	    }
    8.71  				/* local user name */
    8.72 -#ifdef QMAIL
    8.73 -	    else user = conv_virtualdomain(cpystr (t));
    8.74 -#else
    8.75  	    else user = cpystr (t);
    8.76 -#endif
    8.77  	    PSOUT ("+OK User name accepted, password please\015\012");
    8.78  	  }
    8.79  	  else PSOUT ("-ERR Missing username argument\015\012");
     9.1 --- a/src/osdep/unix/Makefile	Mon Sep 14 20:06:41 2009 +0900
     9.2 +++ b/src/osdep/unix/Makefile	Thu Oct 30 00:00:57 2014 +0900
     9.3 @@ -27,7 +27,7 @@
     9.4  # Command line build parameters
     9.5  
     9.6  EXTRAAUTHENTICATORS=
     9.7 -EXTRADRIVERS=maildir mbox
     9.8 +EXTRADRIVERS=mbox
     9.9  PASSWDTYPE=std
    9.10  SSLTYPE=nopwd
    9.11  IP=4
    9.12 @@ -102,7 +102,6 @@
    9.13  NEWSSPOOL=$(SPOOLDIR)/news
    9.14  RSHPATH=/usr/ucb/rsh
    9.15  MD5PWD=/etc/cram-md5.pwd
    9.16 -MD5CFLAGS= -DAPOPOPEN=\"/usr/local/sbin/deapop\" -DUSERAPOPFILE=\".apop\" -DPOPBEFORESMTP -DPOP3RECORDER=\"/usr/local/etc/pop3-record\"
    9.17  # Tries one of the test alternatives below if not specified.
    9.18  LOCKPGM=
    9.19  # Test alternatives if LOCKPGM not specified
    9.20 @@ -145,21 +144,17 @@
    9.21  # However, mh needs to be before any sysinbox formats (such as mmdf or unix)
    9.22  # since otherwise INBOX won't work correctly when mh_allow_inbox is set.
    9.23  #
    9.24 -DEFAULTDRIVERS=maildir imap nntp pop3 mix mx mbx tenex mtx mh mmdf unix news phile
    9.25 +DEFAULTDRIVERS=imap nntp pop3 mix mx mbx tenex mtx mh mmdf unix news phile
    9.26  CHUNKSIZE=65536
    9.27  
    9.28  # Normally no need to change any of these
    9.29 -EXTRACFLAGS=-DQMAIL
    9.30 -# Next variable controls default maildir when user has no ~/.qmail
    9.31 -#MAILDIRCFLAGS=-DDEFAULTMAILDIR="maildir" -DQMAILCONTROL="/var/qmail/control"
    9.32 -MAILDIRCFLAGS=-DQMAILCONTROL="/var/qmail/control"
    9.33  
    9.34  ARCHIVE=c-client.a
    9.35  BINARIES=osdep.o mail.o misc.o newsrc.o smanager.o utf8.o utf8aux.o siglocal.o \
    9.36   dummy.o pseudo.o netmsg.o flstring.o fdstring.o \
    9.37   rfc822.o nntp.o smtp.o imap4r1.o pop3.o \
    9.38 - unix.o mbx.o mmdf.o tenex.o mtx.o news.o phile.o mh.o mx.o mix.o maildir.o
    9.39 -CFLAGS=-g $(EXTRACFLAGS)
    9.40 + unix.o mbx.o mmdf.o tenex.o mtx.o news.o phile.o mh.o mx.o mix.o
    9.41 +CFLAGS=-g
    9.42  
    9.43  CAT=cat
    9.44  MAKE=make
    9.45 @@ -204,6 +199,14 @@
    9.46  	 BASECFLAGS="-g -Dunix=1 -D_BSD -qro -qroconst" \
    9.47  	 BASELDFLAGS="-ls"
    9.48  
    9.49 +a52:	# Attempt at AIX 5.2
    9.50 +	$(BUILD) `$(CAT) SPECIALS` OS=$@ \
    9.51 +	 SIGTYPE=psx CHECKPW=a41 CRXTYPE=nfs \
    9.52 +	 SPOOLDIR=/var/spool \
    9.53 +	 RSHPATH=/usr/bin/rsh \
    9.54 +	 BASECFLAGS="-g -Dunix=1 -D_BSD -qro -qroconst" \
    9.55 +	 BASELDFLAGS="-ls"
    9.56 +
    9.57  aix:	# AIX/370
    9.58  	@echo You are building for AIX on an S/370 class machine
    9.59  	@echo If you want AIX on an RS/6000 you need to use a32 or a41 instead!
    9.60 @@ -897,7 +900,6 @@
    9.61  unix.o: mail.h misc.h osdep.h unix.h pseudo.h dummy.h
    9.62  utf8.o: mail.h misc.h osdep.h utf8.h tmap.c widths.c
    9.63  utf8aux.o: mail.h misc.h osdep.h utf8.h
    9.64 -maildir.o: mail.h misc.h osdep.h maildir.h dummy.h
    9.65  
    9.66  
    9.67  # OS-dependent
    9.68 @@ -966,7 +968,6 @@
    9.69  	@echo Once-only environment setup...
    9.70  	echo $(CC) > CCTYPE
    9.71  	echo $(BASECFLAGS) '$(EXTRACFLAGS)' -DCHUNKSIZE=$(CHUNKSIZE) > CFLAGS
    9.72 -	echo '$(MAILDIRCFLAGS)' >> CFLAGS
    9.73  	echo -DCREATEPROTO=$(CREATEPROTO) -DEMPTYPROTO=$(EMPTYPROTO) \
    9.74  	 -DMD5ENABLE=\"$(MD5PWD)\" -DMAILSPOOL=\"$(MAILSPOOL)\" \
    9.75  	 -DANONYMOUSHOME=\"$(MAILSPOOL)/anonymous\" \
    9.76 @@ -974,7 +975,6 @@
    9.77  	 -DRSHPATH=\"$(RSHPATH)\" -DLOCKPGM=\"$(LOCKPGM)\" \
    9.78  	 -DLOCKPGM1=\"$(LOCKPGM1)\" -DLOCKPGM2=\"$(LOCKPGM2)\" \
    9.79  	 -DLOCKPGM3=\"$(LOCKPGM3)\" > OSCFLAGS
    9.80 -	echo $(MD5CFLAGS) >> OSCFLAGS
    9.81  	echo $(BASELDFLAGS) $(EXTRALDFLAGS) > LDFLAGS
    9.82  	echo "$(ARRC) $(ARCHIVE) $(BINARIES);$(RANLIB) $(ARCHIVE)" > ARCHIVE
    9.83  	echo $(OS) > OSTYPE
    10.1 --- a/src/osdep/unix/env_unix.c	Mon Sep 14 20:06:41 2009 +0900
    10.2 +++ b/src/osdep/unix/env_unix.c	Thu Oct 30 00:00:57 2014 +0900
    10.3 @@ -21,7 +21,7 @@
    10.4   *		Internet: MRC@Washington.EDU
    10.5   *
    10.6   * Date:	1 August 1988
    10.7 - * Last Edited:	15 May 2008
    10.8 + * Last Edited:	23 February 2009
    10.9   */
   10.10  
   10.11  #include <grp.h>
   10.12 @@ -422,10 +422,6 @@
   10.13    case SET_DISABLEPLAINTEXT:
   10.14      disablePlaintext = (long) value;
   10.15    case GET_DISABLEPLAINTEXT:
   10.16 -#ifdef RESTRICT_POP
   10.17 -    if (getenv("INTRANET") == NIL) disablePlaintext = 1;
   10.18 -    else disablePlaintext = NIL;
   10.19 -#endif
   10.20      ret = (void *) disablePlaintext;
   10.21      break;
   10.22    case SET_CHROOTSERVER:
   10.23 @@ -669,7 +665,6 @@
   10.24    char *s;
   10.25    struct passwd *pw;
   10.26    struct passwd *ret = NIL;
   10.27 -#ifndef QMAIL	/* imapext md5 checker run previously. no need to do here */
   10.28    if (auth_md5.server) {	/* using CRAM-MD5 authentication? */
   10.29      if (s = auth_md5_pwd (user)) {
   10.30        if (!strcmp (s,pwd) || ((*pwd == ' ') && pwd[1] && !strcmp (s,pwd+1)))
   10.31 @@ -678,9 +673,7 @@
   10.32        fs_give ((void **) &s);
   10.33      }
   10.34    }
   10.35 -  else
   10.36 -#endif
   10.37 -  if (pw = pwuser (user)) {/* can get user? */
   10.38 +  else if (pw = pwuser (user)) {/* can get user? */
   10.39      s = cpystr (pw->pw_name);	/* copy returned name in case we need it */
   10.40      if (*pwd && !(ret = checkpw (pw,pwd,argc,argv)) &&
   10.41  	(*pwd == ' ') && pwd[1] && (ret = pwuser (s)))
   10.42 @@ -704,10 +697,6 @@
   10.43    struct passwd *pw = NIL;
   10.44    int level = LOG_NOTICE;
   10.45    char *err = "failed";
   10.46 -#ifdef QMAIL
   10.47 -  char usr[MAILTMPLEN], *apoppswd;
   10.48 -  strncpy(usr, user, MAILTMPLEN-1);
   10.49 -#endif
   10.50  				/* cretins still haven't given up */
   10.51    if ((strlen (user) >= NETMAXUSER) ||
   10.52        (authuser && (strlen (authuser) >= NETMAXUSER))) {
   10.53 @@ -717,16 +706,6 @@
   10.54    }
   10.55    else if (logtry-- <= 0) err = "excessive login failures";
   10.56    else if (disablePlaintext) err = "disabled";
   10.57 -#ifdef QMAIL
   10.58 -  else if ((logtry > 0) &&
   10.59 -            (apoppswd = auth_md5_pwd(usr))
   10.60 -           && !strcmp(apoppswd, pwd)
   10.61 -           && (pw = getpwnam(usr))) {
   10.62 -    memset(apoppswd, 0, strlen(apoppswd));
   10.63 -    fs_give((void**) &apoppswd);
   10.64 -    return pw_login(pw, usr, pw->pw_name, pw->pw_dir, argc, argv);
   10.65 -  }
   10.66 -#endif
   10.67    else if (!(authuser && *authuser)) pw = valpwd (user,pwd,argc,argv);
   10.68    else if (valpwd (authuser,pwd,argc,argv)) pw = pwuser (user);
   10.69    if (pw && pw_login (pw,authuser,pw->pw_name,NIL,argc,argv)) return T;
   10.70 @@ -749,34 +728,6 @@
   10.71    return pw_login (pwuser (user),authuser,user,NIL,argc,argv);
   10.72  }
   10.73  
   10.74 -void permitsmtp()	/* to update tcp permission */
   10.75 -{
   10.76 -#ifdef POPBEFORESMTP
   10.77 -  #include <sys/types.h>
   10.78 -  #include <sys/wait.h>
   10.79 -  #ifndef POP3RECORDER
   10.80 -  # define POP3RECORDER "/usr/local/etc/pop3-record"
   10.81 -  #endif
   10.82 -  int child;
   10.83 -  int wstat;
   10.84 -  char *permsmtp = POP3RECORDER;
   10.85 -
   10.86 -  switch(child = fork())
   10.87 -   {
   10.88 -    case -1:
   10.89 -	syslog (LOG_INFO,"Cannot exec %s", permsmtp);
   10.90 -	_exit(111);
   10.91 -	break;
   10.92 -    case 0:
   10.93 -	execl(permsmtp, permsmtp, 0);
   10.94 -	syslog (LOG_INFO,"Cannot exec %s", permsmtp);
   10.95 -	_exit(111); break;
   10.96 -   }
   10.97 -  waitpid(child, &wstat, 0);
   10.98 -#endif
   10.99 -}
  10.100 -
  10.101 -
  10.102  
  10.103  /* Log in as anonymous daemon
  10.104   * Accepts: argument count
  10.105 @@ -830,14 +781,8 @@
  10.106        else fatal ("Login failed after chroot");
  10.107      }
  10.108  				/* normal login */
  10.109 -#ifdef QMAIL
  10.110 -    else if (((pw->pw_uid == geteuid ()) || (permitsmtp(), loginpw (pw,argc,argv
  10.111 -))) &&
  10.112 -             (ret = env_init (user,home))) chdir (myhomedir ());
  10.113 -#else
  10.114      else if (((pw->pw_uid == geteuid ()) || loginpw (pw,argc,argv)) &&
  10.115 -             (ret = env_init (user,home))) chdir (myhomedir ());
  10.116 -#endif
  10.117 +	     (ret = env_init (user,home))) chdir (myhomedir ());
  10.118      fs_give ((void **) &home);	/* clean up */
  10.119      if (user) fs_give ((void **) &user);
  10.120    }
  10.121 @@ -1868,7 +1813,7 @@
  10.122    restrictBox = NIL;		/* can't restrict */
  10.123    if (blackBox) {		/* if black box */
  10.124  				/* toss out driver dependent names */
  10.125 -    printf (path,"%s/INBOX",mymailboxdir ());
  10.126 +    sprintf (path,"%s/INBOX",mymailboxdir ());
  10.127      blackBox = NIL;		/* well that's evil - evil is going on */
  10.128      ret = mail_create (stream,path);
  10.129      blackBox = T;		/* restore the box */
    11.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    11.2 +++ b/src/osdep/unix/os_a52.c	Thu Oct 30 00:00:57 2014 +0900
    11.3 @@ -0,0 +1,63 @@
    11.4 +/* ========================================================================
    11.5 + * Copyright 1988-2006 University of Washington
    11.6 + *
    11.7 + * Licensed under the Apache License, Version 2.0 (the "License");
    11.8 + * you may not use this file except in compliance with the License.
    11.9 + * You may obtain a copy of the License at
   11.10 + *
   11.11 + *     http://www.apache.org/licenses/LICENSE-2.0
   11.12 + *
   11.13 + * 
   11.14 + * ========================================================================
   11.15 + */
   11.16 +
   11.17 +/*
   11.18 + * Program:	Operating-system dependent routines -- AIX 4.1 on RS 6000
   11.19 + *
   11.20 + * Author:	Mark Crispin
   11.21 + *		Networks and Distributed Computing
   11.22 + *		Computing & Communications
   11.23 + *		University of Washington
   11.24 + *		Administration Building, AG-44
   11.25 + *		Seattle, WA  98195
   11.26 + *		Internet: MRC@CAC.Washington.EDU
   11.27 + *
   11.28 + * Date:	1 August 1988
   11.29 + * Last Edited:	30 August 2006
   11.30 + */
   11.31 + 
   11.32 +#include "tcp_unix.h"		/* must be before osdep includes tcp.h */
   11.33 +#include "mail.h"
   11.34 +#include "osdep.h"
   11.35 +#include <stdio.h>
   11.36 +#include <sys/time.h>
   11.37 +#include <sys/socket.h>
   11.38 +#include <sys/stat.h>
   11.39 +#include <netinet/in.h>
   11.40 +#include <arpa/inet.h>
   11.41 +#include <netdb.h>
   11.42 +#include <ctype.h>
   11.43 +#include <errno.h>
   11.44 +extern int errno;		/* just in case */
   11.45 +#include <pwd.h>
   11.46 +#include "misc.h"
   11.47 +#include <sys/select.h>
   11.48 +#include <stddef.h>		/* needed for authenticate() */
   11.49 +
   11.50 +int authenticate (char *UserName,char *Response,int *Reenter,char **Message);
   11.51 +
   11.52 +extern int sys_nerr;
   11.53 +extern char *sys_errlist[];
   11.54 +
   11.55 +
   11.56 +#include "fs_unix.c"
   11.57 +#include "ftl_unix.c"
   11.58 +#include "nl_unix.c"
   11.59 +#include "env_unix.c"
   11.60 +#include "tcp_unix.c"
   11.61 +#include "gr_waitp.c"
   11.62 +#include "tz_sv4.c"
   11.63 +#include "flocksim.c"
   11.64 +#undef setpgrp
   11.65 +#include "setpgrp.c"
   11.66 +#include "utime.c"
    12.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    12.2 +++ b/src/osdep/unix/os_a52.h	Thu Oct 30 00:00:57 2014 +0900
    12.3 @@ -0,0 +1,53 @@
    12.4 +/* ========================================================================
    12.5 + * Copyright 1988-2006 University of Washington
    12.6 + *
    12.7 + * Licensed under the Apache License, Version 2.0 (the "License");
    12.8 + * you may not use this file except in compliance with the License.
    12.9 + * You may obtain a copy of the License at
   12.10 + *
   12.11 + *     http://www.apache.org/licenses/LICENSE-2.0
   12.12 + *
   12.13 + * 
   12.14 + * ========================================================================
   12.15 + */
   12.16 +
   12.17 +/*
   12.18 + * Program:	Operating-system dependent routines -- AIX on RS6000
   12.19 + *
   12.20 + * Author:	Mark Crispin
   12.21 + *		Networks and Distributed Computing
   12.22 + *		Computing & Communications
   12.23 + *		University of Washington
   12.24 + *		Administration Building, AG-44
   12.25 + *		Seattle, WA  98195
   12.26 + *		Internet: MRC@CAC.Washington.EDU
   12.27 + *
   12.28 + * Date:	1 August 1988
   12.29 + * Last Edited:	30 August 2006
   12.30 + */
   12.31 +
   12.32 +#include <stdlib.h>
   12.33 +#include <unistd.h>
   12.34 +#include <string.h>
   12.35 +#include <sys/types.h>
   12.36 +#include <time.h>		/* for struct tm */
   12.37 +#include <dirent.h>
   12.38 +#include <fcntl.h>
   12.39 +#include <utime.h>
   12.40 +#include <syslog.h>
   12.41 +#include <sys/file.h>
   12.42 +#include <ustat.h>
   12.43 +
   12.44 +
   12.45 +#define setpgrp(a,b) Setpgrp(a,b)
   12.46 +int Setpgrp (int pid,int gid);
   12.47 +
   12.48 +#define utime portable_utime
   12.49 +int portable_utime (char *file,time_t timep[2]);
   12.50 +
   12.51 +#include "env_unix.h"
   12.52 +#include "fs.h"
   12.53 +#include "ftl.h"
   12.54 +#include "nl.h"
   12.55 +#include "tcp.h"
   12.56 +#include "flocksim.h"
    13.1 --- a/src/osdep/unix/tcp_unix.c	Mon Sep 14 20:06:41 2009 +0900
    13.2 +++ b/src/osdep/unix/tcp_unix.c	Thu Oct 30 00:00:57 2014 +0900
    13.3 @@ -239,7 +239,7 @@
    13.4    size_t len;
    13.5    time_t now;
    13.6    struct protoent *pt = getprotobyname ("tcp");
    13.7 -  fd_set fds,efds;
    13.8 +  fd_set rfds,wfds,efds;
    13.9    struct timeval tmo;
   13.10    struct sockaddr *sadr = ip_sockaddr (family,adr,adrlen,port,&len);
   13.11    blocknotify_t bn = (blocknotify_t) mail_parameters (NIL,GET_BLOCKNOTIFY,NIL);
   13.12 @@ -285,13 +285,15 @@
   13.13        now = time (0);		/* open timeout */
   13.14        ti = ttmo_open ? now + ttmo_open : 0;
   13.15        tmo.tv_usec = 0;
   13.16 -      FD_ZERO (&fds);		/* initialize selection vector */
   13.17 +      FD_ZERO (&rfds);		/* initialize selection vector */
   13.18 +      FD_ZERO (&wfds);		/* initialize selection vector */
   13.19        FD_ZERO (&efds);		/* handle errors too */
   13.20 -      FD_SET (sock,&fds);	/* block for error or readable */
   13.21 +      FD_SET (sock,&rfds);	/* block for error or readable or writable */
   13.22 +      FD_SET (sock,&wfds);
   13.23        FD_SET (sock,&efds);
   13.24        do {			/* block under timeout */
   13.25  	tmo.tv_sec = ti ? ti - now : 0;
   13.26 -	i = select (sock+1,&fds,NIL,&efds,ti ? &tmo : NIL);
   13.27 +	i = select (sock+1,&rfds,&wfds,&efds,ti ? &tmo : NIL);
   13.28  	now = time (0);		/* fake timeout if interrupt & time expired */
   13.29  	if ((i < 0) && (errno == EINTR) && ti && (ti <= now)) i = 0;
   13.30        } while ((i < 0) && (errno == EINTR));
   13.31 @@ -300,7 +302,7 @@
   13.32  	fcntl (sock,F_SETFL,flgs);
   13.33  	/* This used to be a zero-byte read(), but that crashes Solaris */
   13.34  				/* get socket status */
   13.35 -	while (((i = *ctr = read (sock,tmp,1)) < 0) && (errno == EINTR));
   13.36 +	if(FD_ISSET(sock, &rfds)) while (((i = *ctr = read (sock,tmp,1)) < 0) && (errno == EINTR));
   13.37        }	
   13.38        if (i <= 0) {		/* timeout or error? */
   13.39  	i = i ? errno : ETIMEDOUT;/* determine error code */
   13.40 @@ -818,20 +820,6 @@
   13.41    return stream->localhost;	/* return local host name */
   13.42  }
   13.43  
   13.44 -/* Get $TCPREMOTEHOST || $TCPREMOTEHOST
   13.45 - * If invoked via tcpserver or couriertcpd, consult $TCPREMOTEHOST
   13.46 - * or $TCPREMOTEIP
   13.47 - */
   13.48 -char* gettcpremoteip()
   13.49 -{
   13.50 -  if (getenv("TCPREMOTEHOST") && strcmp("0", getenv("TCPREMOTEHOST"))) {
   13.51 -    return getenv("TCPREMOTEHOST");
   13.52 -  } else if (getenv("TCPREMOTEIP")) {
   13.53 -    return getenv("TCPREMOTEIP");
   13.54 -  }
   13.55 -  return "NON-IPv4";
   13.56 -}
   13.57 -
   13.58  /* TCP/IP get client host address (server calls only)
   13.59   * Returns: client host address
   13.60   */
   13.61 @@ -862,15 +850,6 @@
   13.62    if (!myClientHost) {
   13.63      size_t sadrlen;
   13.64      struct sockaddr *sadr = ip_newsockaddr (&sadrlen);
   13.65 -#ifdef INET6
   13.66 -    if (getenv("TCPREMOTEIP")) {
   13.67 -      myClientHost =
   13.68 -         cpystr((getenv("TCPREMOTEHOST")
   13.69 - 		&& strcasecmp("UNKNOWN", getenv("TCPREMOTEHOST")))
   13.70 - 		? getenv("TCPREMOTEHOST")
   13.71 - 		: getenv("TCPREMOTEIP"));
   13.72 -    } else
   13.73 -#endif
   13.74      if (getpeername (0,sadr,(void *) &sadrlen)) {
   13.75        char *s,*t,*v,tmp[MAILTMPLEN];
   13.76        if ((s = getenv (t = "SSH_CLIENT")) ||
   13.77 @@ -934,8 +913,7 @@
   13.78      size_t sadrlen;
   13.79      struct sockaddr *sadr = ip_newsockaddr (&sadrlen);
   13.80  				/* get stdin's name */
   13.81 -    if (getsockname (0,sadr,(void *) &sadrlen) ||
   13.82 -        (myServerPort = ip_sockaddrtoport (sadr)) < 0)
   13.83 +    if (getsockname (0,sadr,(void *) &sadrlen))
   13.84        myServerHost = cpystr (mylocalhost ());
   13.85      else {			/* get stdin's name */
   13.86        myServerHost = tcp_name (sadr,NIL);
    14.1 --- a/src/osdep/unix/unix.c	Mon Sep 14 20:06:41 2009 +0900
    14.2 +++ b/src/osdep/unix/unix.c	Thu Oct 30 00:00:57 2014 +0900
    14.3 @@ -202,7 +202,6 @@
    14.4  
    14.5  				/* driver parameters */
    14.6  static long unix_fromwidget = T;
    14.7 -char *myMailSuffix =NIL;	/* home directory name */
    14.8  
    14.9  /* UNIX mail validate mailbox
   14.10   * Accepts: mailbox name
   14.11 @@ -2402,15 +2401,6 @@
   14.12    }
   14.13    f->filepos += size;		/* update file position */
   14.14  }
   14.15 -
   14.16 -/* Return my mail suffix(of qmail or Postfix)
   14.17 - * Returns: my mail address extensional suffix
   14.18 - */
   14.19 -
   14.20 -char *mymailsuffix ()
   14.21 -{
   14.22 -  return myMailSuffix ? myMailSuffix : "";
   14.23 -}
   14.24  
   14.25  /* MBOX mail routines */
   14.26  

UW-IMAP'd extensions by yuuji