]> Pileus Git - ~andy/fetchmail/commitdiff
Add RPOP support.
authorEric S. Raymond <esr@thyrsus.com>
Fri, 13 Sep 1996 16:39:22 +0000 (16:39 -0000)
committerEric S. Raymond <esr@thyrsus.com>
Fri, 13 Sep 1996 16:39:22 +0000 (16:39 -0000)
svn path=/trunk/; revision=94

fetchmail.c
fetchmail.h
fetchmail.man
pop3.c
rcfile_l.l
rcfile_y.y

index d3645db194eb9629ac7ac5992adc228a61481bff..64321b8a8940634e7d51b608424c3f51378097c4 100644 (file)
@@ -373,7 +373,10 @@ struct hostrec *queryctl;
     char *cp;
 
     printf("  Username = '%s'\n", queryctl->remotename);
-    printf("  Password = '%s'\n", queryctl->password);
+    if (queryctl->password)
+       printf("  Password = '%s'\n", queryctl->password);
+    if (queryctl->rpopid)
+       printf("  RPOP id = '%s'\n", queryctl->rpopid);
     printf("  Protocol is %s", showproto(queryctl->protocol));
     if (queryctl->port)
        printf(" (using port %d)", queryctl->port);
index fa78c72682658fd0d44503a692869c923d4feb6d..43d348687fdfd3511bbee8bfb4e24f92c0c9c02e 100644 (file)
@@ -54,6 +54,7 @@ struct hostrec
   char localname [USERNAMELEN];
   char remotename [USERNAMELEN];
   char password [PASSWORDLEN];
+  char rpopid [PASSWORDLEN];
   char userfolder [FOLDERLEN];
   char remotefolder [FOLDERLEN];
   char smtphost[HOSTLEN];
index e11c94d4d98c0e6173abbcee588cee76c64624a5..53b27e61968fd94464fbcb97822b80c7e2e821af 100644 (file)
@@ -12,6 +12,8 @@ popclient \- retrieve mail from a mailserver using POP or IMAP
 is a mail retrieval client which supports 
 POP2 (as specified in RFC 937), POP3 (RFC 1725), IMAP2bis (as
 implemented by the 4.4BSD imapd program), and IMAP4 (RFC1730).
+It can use (but does not require) the RPOP and LAST facilities
+removed from later POP3 versions.
 .PP
 The,
 .I popclient
@@ -138,15 +140,12 @@ Post Office Protocol 2
 Post Office Protocol 3
 .IP APOP
 Use POP3 with MD5 authentication.
-.IP RPOP
-Use POP3 with trusted-host-based authentication (like rlogin/rsh). 
-.I popclient
-must be installed as a setuid root program to use RPOP.
 .RE
 .TP
 .B \-P, --port
-The  option permits you to specify a TCP/IP port to connect on.
-This will seldom be necessary as all the supported protocols have
+The  option permits you to specify a TCP/IP port to connect on.  You
+will need to specify this in order to use RPOP authentication.  Otherwise
+this option will seldom be necessary as all the supported protocols have
 well-established default port numbers.
 .TP
 .B \-r folder, --remote folder
@@ -248,6 +247,15 @@ password are usually assigned by the server administrator when you apply for
 a mailbox on the server.  Contact your server administrator if you don't know 
 the correct user-id and password for your mailbox account.
 .PP
+POP3 versions up to the RFC1225 version supported an alternate
+authentication mechanism called RPOP intended to remove the security
+risk inherent in sending unencrypted account passwords across the net
+(in RFC1460 this facility was replaced with APOP).  If your .poprc
+file specifies an RPOP id and a connection port in the privileged
+range (1..1024),
+.I popclient will
+ship the id with an RPOP command rather than sending a password.
+.PP
 .SH OUTPUT OPTIONS
 The default behavior of 
 .I popmail
@@ -386,6 +394,7 @@ Legal keywords are:
     protocol (or proto)
     username (or user)
     password (or pass)
+    rpopid
     remotefolder (or remote)
     localfolder (or local)
     mda
@@ -508,11 +517,9 @@ connection.  If you don't know what a socket is, don't worry about it --
 just treat this as an 'unrecoverable error'.
 .IP 3
 The user authentication step failed.  This usually means that a bad 
-user-id or password was specified.
+user-id, password, or RPOP id was specified.
 .IP 4
-Some sort of protocol error was detected.  POP is not especially forgiving
-when it comes to unexpected responses, commands, etc -- the protocol invariably
-calls for terminating the connection under such error conditions.
+Some sort of fatal protocol error was detected.
 .IP 5
 There was a syntax error in the arguments to 
 .I popclient.
@@ -561,10 +568,8 @@ find a POP2 server to test the necessary code reorganization with.
 The --remotefolder option doesn't work with POP3, the protocol won't
 support it.
 .PP
-The UIDL support for RFC1725-compliant servers without LAST is not yet
-very well tested.
-.PP
-No RPOP support yet.
+The RPOP support, and the UIDL support for RFC1725-compliant servers
+without LAST, are not yet very well tested.
 .PP
 Send comments, bug reports, gripes, and the like to Eric S. Raymond
 <esr@thyrsus.com>.
diff --git a/pop3.c b/pop3.c
index f8bad81f90ecdd9c896eddac601ba0687fd71c3f..379d38732657c074b4da9ce62981372d355dc09d 100644 (file)
--- a/pop3.c
+++ b/pop3.c
@@ -86,69 +86,67 @@ int socket;
 struct hostrec *queryctl;
 char *greeting;
 {
-  char buf [POPBUFSIZE];
+    char buf [POPBUFSIZE];
 
 #if defined(HAVE_APOP_SUPPORT)
-  /* build MD5 digest from greeting timestamp + password */
-  if (queryctl->protocol == P_APOP) 
-    if (POP3_BuildDigest(greeting,queryctl) != 0) {
-      return(PS_AUTHFAIL);
-    }
-#endif
+    /* build MD5 digest from greeting timestamp + password */
+    if (queryctl->protocol == P_APOP) 
+       if (POP3_BuildDigest(greeting,queryctl) != 0) {
+           return(PS_AUTHFAIL);
+       }
+#endif  /* HAVE_APOP_SUPPORT */
 
-  switch (queryctl->protocol) {
+    switch (queryctl->protocol) {
     case P_POP3:
-      SockPrintf(socket,"USER %s\r\n",queryctl->remotename);
-      if (outlevel == O_VERBOSE)
-        fprintf(stderr,"> USER %s\n",queryctl->remotename);
-      if (pop3_ok(buf,socket) != 0)
-        goto badAuth;
-
-      SockPrintf(socket,"PASS %s\r\n",queryctl->password);
-      if (outlevel == O_VERBOSE)
-        fprintf(stderr,"> PASS password\n");
-      if (pop3_ok(buf,socket) != 0)
-        goto badAuth;
-    
-      break;
+       SockPrintf(socket,"USER %s\r\n",queryctl->remotename);
+       if (outlevel == O_VERBOSE)
+           fprintf(stderr,"> USER %s\n",queryctl->remotename);
+       if (pop3_ok(buf,socket) != 0)
+           goto badAuth;
+
+       if (queryctl->rpopid[0])
+       {
+           SockPrintf(socket, "RPOP %s\r\n", queryctl->rpopid);
+           if (outlevel == O_VERBOSE)
+               fprintf(stderr,"> RPOP %s %s\n",queryctl->rpopid);
+       }
+       else
+       {
+           SockPrintf(socket,"PASS %s\r\n",queryctl->password);
+           if (outlevel == O_VERBOSE)
+               fprintf(stderr,"> PASS password\n");
+       }
+       if (pop3_ok(buf,socket) != 0)
+           goto badAuth;
+       break;
 
 #if defined(HAVE_APOP_SUPPORT)
     case P_APOP:
-      SockPrintf(socket,"APOP %s %s\r\n", 
-                 queryctl->remotename, queryctl->digest);
-      if (outlevel == O_VERBOSE)
-        fprintf(stderr,"> APOP %s %s\n",queryctl->remotename, queryctl->digest);
-      if (pop3_ok(buf,socket) != 0) 
-        goto badAuth;
-      break;
+       SockPrintf(socket,"APOP %s %s\r\n", 
+                  queryctl->remotename, queryctl->digest);
+       if (outlevel == O_VERBOSE)
+           fprintf(stderr,"> APOP %s %s\n",queryctl->remotename, queryctl->digest);
+       if (pop3_ok(buf,socket) != 0) 
+           goto badAuth;
+       break;
 #endif  /* HAVE_APOP_SUPPORT */
 
-#if defined(HAVE_RPOP_SUPPORT)
-    case P_RPOP:
-      SockPrintf(socket, "RPOP %s\r\n", queryctl->remotename);
-      if (pop3_ok(buf,socket) != 0)
-         goto badAuth;
-      if (outlevel == O_VERBOSE)
-        fprintf(stderr,"> RPOP %s %s\n",queryctl->remotename);
-      break;
-#endif  /* HAVE_RPOP_SUPPORT */
-
     default:
-      fprintf(stderr,"Undefined protocol request in POP3_auth\n");
-  }
+       fprintf(stderr,"Undefined protocol request in POP3_auth\n");
+    }
 
-  /* we're approved */
-  return(0);
+    /* we're approved */
+    return(0);
 
-  /*NOTREACHED*/
+    /*NOTREACHED*/
 
 badAuth:
-  if (outlevel > O_SILENT && outlevel < O_VERBOSE)
-    fprintf(stderr,"%s\n",buf);
-  else
-    ; /* say nothing */
+    if (outlevel > O_SILENT && outlevel < O_VERBOSE)
+       fprintf(stderr,"%s\n",buf);
+    else
+       ; /* say nothing */
 
-  return(PS_ERROR);
+    return(PS_ERROR);
 }
 
 static int use_uidl;
index 1998f3b252dddd0dc23ebd5da55dfb82ff46de10..508c1d510395667a74b2ae0ba6e34fbf365bc442 100644 (file)
@@ -29,6 +29,7 @@ server                { return KW_SERVER; }
 proto(col)?    { return KW_PROTOCOL; }
 user(name)?    { return KW_USERNAME; }
 pass(word)?    { return KW_PASSWORD; }
+rpopid         { return KW_RPOPID; }
 remote(folder)? { return KW_REMOTEFOLDER; }
 local(folder)? { return KW_LOCALFOLDER; }
 smtp(host)?    { return KW_SMTPHOST; }
index cc040deed635c1ad46145e4ee3c06de474b6661b..284d7352389ec1a004f331a7303f9df1e43f539c 100644 (file)
@@ -29,7 +29,7 @@ int yydebug;  /* in case we didn't generate with -- debug */
   char *sval;
 }
 
-%token KW_SERVER KW_PROTOCOL KW_USERNAME KW_PASSWORD
+%token KW_SERVER KW_PROTOCOL KW_USERNAME KW_PASSWORD KW_RPOPID
 %token KW_REMOTEFOLDER KW_LOCALFOLDER KW_SMTPHOST KW_MDA KW_EOL KW_DEFAULTS
 %token <proto> PROTO_AUTO PROTO_POP2 PROTO_POP3 PROTO_IMAP PROTO_APOP PROTO_RPOP
 %token <sval> PARAM_STRING
@@ -66,6 +66,7 @@ serv_option_clause:
                KW_PROTOCOL proto               {prc_setproto($2);}
        |       KW_USERNAME PARAM_STRING        {prc_remotename($2);}
        |       KW_PASSWORD PARAM_STRING        {prc_setpassword($2);}
+       |       KW_RPOPID PARAM_STRING          {prc_setrpopid($2);}
        |       KW_REMOTEFOLDER PARAM_STRING    {prc_setremote($2);}
        |       KW_LOCALFOLDER PARAM_STRING     {prc_setlocal($2);}
        |       KW_SMTPHOST PARAM_STRING        {prc_setsmtphost($2);}