From 0f6b6bf411d16e063b9d37352d03887bf3055c26 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Fri, 13 Sep 1996 16:39:22 +0000 Subject: [PATCH] Add RPOP support. svn path=/trunk/; revision=94 --- fetchmail.c | 5 ++- fetchmail.h | 1 + fetchmail.man | 33 ++++++++++-------- pop3.c | 94 +++++++++++++++++++++++++-------------------------- rcfile_l.l | 1 + rcfile_y.y | 3 +- 6 files changed, 73 insertions(+), 64 deletions(-) diff --git a/fetchmail.c b/fetchmail.c index d3645db1..64321b8a 100644 --- a/fetchmail.c +++ b/fetchmail.c @@ -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); diff --git a/fetchmail.h b/fetchmail.h index fa78c726..43d34868 100644 --- a/fetchmail.h +++ b/fetchmail.h @@ -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]; diff --git a/fetchmail.man b/fetchmail.man index e11c94d4..53b27e61 100644 --- a/fetchmail.man +++ b/fetchmail.man @@ -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 . diff --git a/pop3.c b/pop3.c index f8bad81f..379d3873 100644 --- 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; diff --git a/rcfile_l.l b/rcfile_l.l index 1998f3b2..508c1d51 100644 --- a/rcfile_l.l +++ b/rcfile_l.l @@ -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; } diff --git a/rcfile_y.y b/rcfile_y.y index cc040dee..284d7352 100644 --- a/rcfile_y.y +++ b/rcfile_y.y @@ -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_AUTO PROTO_POP2 PROTO_POP3 PROTO_IMAP PROTO_APOP PROTO_RPOP %token 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);} -- 2.43.2