From 0d1c5f533f3a6cd1c7f038f59585378f53b666c2 Mon Sep 17 00:00:00 2001 From: Dan Harkless Date: Fri, 4 Feb 2000 01:32:12 +0000 Subject: [PATCH] * Applied wesley.craig@umich.edu's KPOP patches. According to him: The following patch fixes a problem with requesting a service key for a machine that has multiple 'A' records. It also makes "-kpop" a command line option, for users who would like to use both "kpop" and "pop". Did no testing of the new features, as I don't have access to a KPOP server. One tweak I made to the patch he sent to nmh-workers was to move the declaration of his new hp2 variable into the #ifdef KPOP section so you don't get an "unused variable" warning when compiling without KPOP. * Modified inc.man and msgchk.man to document Wesley's new -kpop. --- ChangeLog | 14 ++++++++++++++ h/popsbr.h | 2 +- man/inc.man | 5 +++++ man/msgchk.man | 5 +++++ uip/inc.c | 21 +++++++++++++++------ uip/msgchk.c | 29 +++++++++++++++++++---------- uip/popsbr.c | 23 +++++++++++++++-------- zotnet/mts/client.c | 7 ++++++- 8 files changed, 80 insertions(+), 26 deletions(-) diff --git a/ChangeLog b/ChangeLog index c493981..725c4b9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,17 @@ +Thu Feb 03 17:22:48 2000 Dan Harkless + + * Applied wesley.craig@umich.edu's KPOP patches. According to him: + + The following patch fixes a problem with requesting a + service key for a machine that has multiple 'A' records. It + also makes "-kpop" a command line option, for users who + would like to use both "kpop" and "pop". + + Did no testing of the new features, as I don't have access to a + KPOP server. + + * Modified inc.man and msgchk.man to document Wesley's new -kpop. + Fri Jan 28 17:39:24 2000 Dan Harkless * All %-escapes in mhn.defaults that actually expand to something diff --git a/h/popsbr.h b/h/popsbr.h index a9e0883..c53b291 100644 --- a/h/popsbr.h +++ b/h/popsbr.h @@ -22,7 +22,7 @@ int pop_set (int, int, int); int pop_exists (int (*)()); #endif -int pop_init (char *, char *, char *, int, int); +int pop_init (char *, char *, char *, int, int, int); int pop_fd (char *, int, char *, int); int pop_stat (int *, int *); int pop_retr (int, int (*)()); diff --git a/man/inc.man b/man/inc.man index b2e5c7b..dda206c 100644 --- a/man/inc.man +++ b/man/inc.man @@ -32,6 +32,7 @@ inc \%[\-user\ username] \%[\-pack\ file] \%[\-nopack] +\%[\-kpop] .br %nmhendpop% \%[\-version] @@ -145,6 +146,10 @@ maildrops. For debugging purposes, you may give the switch `\-snoop', which will allow you to watch the POP transaction take place between you and the POP server. + +If nmh has been compiled with KPOP #defined, but without POPSERVICE being set to +"kpop", the -kpop switch may be specified to cause the use of Kerberized POP +rather than standard POP3 during a given invocation of \fIinc\fR. %nmhendpop% .Fi ^$HOME/\&.mh\(ruprofile~^The user profile diff --git a/man/msgchk.man b/man/msgchk.man index e7624a0..973fb4b 100644 --- a/man/msgchk.man +++ b/man/msgchk.man @@ -20,6 +20,7 @@ msgchk %nmhbeginpop% \%[\-host\ hostname] \%[\-user\ username] +\%[\-kpop] .br %nmhendpop% \%[users\ ...] @@ -75,6 +76,10 @@ you. For debugging purposes, there is also a switch `\-snoop', which will allow you to watch the POP transaction take place between you and the POP server. + +If nmh has been compiled with KPOP #defined, but without POPSERVICE being set to +"kpop", the -kpop switch may be specified to cause the use of Kerberized POP +rather than standard POP3 during a given invocation of \fImsgchk\fR. %nmhendpop% .Fi ^$HOME/\&.mh\(ruprofile~^The user profile diff --git a/uip/inc.c b/uip/inc.c index 164ac98..fd7b55e 100644 --- a/uip/inc.c +++ b/uip/inc.c @@ -55,6 +55,12 @@ # define APOPminc(a) 0 #endif +#ifndef KPOP +# define KPOPminc(a) (a) +#else +# define KPOPminc(a) 0 +#endif + static struct swit switches[] = { #define AUDSW 0 { "audit audit-file", 0 }, @@ -102,6 +108,8 @@ static struct swit switches[] = { { "help", 4 }, #define SNOOPSW 22 { "snoop", -5 }, +#define KPOPSW 23 + { "kpop", KPOPminc (-4) }, { NULL, 0 } }; @@ -157,6 +165,7 @@ main (int argc, char **argv) int chgflag = 1, trnflag = 1; int noisy = 1, width = 0, locked = 0; int rpop, i, hghnum, msgnum; + int kpop = 0; char *cp, *maildir, *folder = NULL; char *format = NULL, *form = NULL; char *newmail, *host = NULL, *user = NULL; @@ -218,11 +227,7 @@ main (int argc, char **argv) snoop++; #endif /* POP */ -#ifdef KPOP - rpop = 1; -#else rpop = 0; -#endif while ((cp = *argp++)) { if (*cp == '-') { @@ -346,6 +351,10 @@ main (int argc, char **argv) rpop = 0; continue; + case KPOPSW: + kpop = 1; + continue; + case SNOOPSW: snoop++; continue; @@ -393,7 +402,7 @@ main (int argc, char **argv) if (inc_type == INC_POP) { if (user == NULL) user = getusername (); - if (rpop > 0) + if (kpop || ( rpop > 0)) pass = getusername (); else ruserpass (host, &user, &pass); @@ -401,7 +410,7 @@ main (int argc, char **argv) /* * initialize POP connection */ - if (pop_init (host, user, pass, snoop, rpop) == NOTOK) + if (pop_init (host, user, pass, snoop, kpop ? 1 : rpop, kpop) == NOTOK) adios (NULL, "%s", response); /* Check if there are any messages */ diff --git a/uip/msgchk.c b/uip/msgchk.c index a063049..23ede03 100644 --- a/uip/msgchk.c +++ b/uip/msgchk.c @@ -36,6 +36,12 @@ # define APOPminc(a) 0 #endif +#ifndef KPOP +# define KPOPminc(a) (a) +#else +# define KPOPminc(a) 0 +#endif + static struct swit switches[] = { #define DATESW 0 { "date", 0 }, @@ -63,6 +69,8 @@ static struct swit switches[] = { { "help", 4 }, #define SNOOPSW 12 { "snoop", -5 }, +#define KPOPSW 13 + { "kpop", KPOPminc (-4) }, { NULL, 0 } }; @@ -93,7 +101,7 @@ static int donote (char *, int); static int checkmail (char *, char *, int, int, int); #ifdef POP -static int remotemail (char *, char *, int, int, int, int); +static int remotemail (char *, char *, int, int, int, int, int); #endif @@ -102,6 +110,7 @@ main (int argc, char **argv) { int datesw = 1, notifysw = NT_ALL; int rpop, status = 0; + int kpop = 0; int snoop = 0, vecp = 0; uid_t uid; char *cp, *host = NULL, *user, buf[BUFSIZ]; @@ -133,11 +142,7 @@ main (int argc, char **argv) snoop++; #endif -#ifdef KPOP - rpop = 1; -#else rpop = 0; -#endif while ((cp = *argp++)) { if (*cp == '-') { @@ -202,6 +207,10 @@ main (int argc, char **argv) rpop = 0; continue; + case KPOPSW: + kpop = 1; + continue; + case SNOOPSW: snoop++; continue; @@ -251,10 +260,10 @@ main (int argc, char **argv) #ifdef POP if (host) { if (vecp == 0) { - status = remotemail (host, user, rpop, notifysw, 1, snoop); + status = remotemail (host, user, rpop, kpop, notifysw, 1, snoop); } else { for (vecp = 0; vec[vecp]; vecp++) - status += remotemail (host, vec[vecp], rpop, notifysw, 0, snoop); + status += remotemail (host, vec[vecp], rpop, kpop, notifysw, 0, snoop); } } else { #endif /* POP */ @@ -375,20 +384,20 @@ checkmail (char *user, char *home, int datesw, int notifysw, int personal) extern char response[]; static int -remotemail (char *host, char *user, int rpop, int notifysw, int personal, int snoop) +remotemail (char *host, char *user, int rpop, int kpop, int notifysw, int personal, int snoop) { int nmsgs, nbytes, status; char *pass = NULL; if (user == NULL) user = getusername (); - if (rpop > 0) + if (kpop || (rpop > 0)) pass = getusername (); else ruserpass (host, &user, &pass); /* open the POP connection */ - if (pop_init (host, user, pass, snoop, rpop) == NOTOK + if (pop_init (host, user, pass, snoop, kpop ? 1 : rpop, kpop) == NOTOK || pop_stat (&nmsgs, &nbytes) == NOTOK /* check for messages */ || pop_quit () == NOTOK) { /* quit POP connection */ advise (NULL, "%s", response); diff --git a/uip/popsbr.c b/uip/popsbr.c index eec025d..bfc39ea 100644 --- a/uip/popsbr.c +++ b/uip/popsbr.c @@ -118,7 +118,7 @@ pop_auth (char *user, char *pass) int -pop_init (char *host, char *user, char *pass, int snoop, int rpop) +pop_init (char *host, char *user, char *pass, int snoop, int rpop, int kpop) { int fd1, fd2; char buffer[BUFSIZ]; @@ -131,16 +131,23 @@ pop_init (char *host, char *user, char *pass, int snoop, int rpop) #endif #ifndef NNTP -# ifndef KPOP - if ((fd1 = client (host, "tcp", POPSERVICE, rpop, response, sizeof(response))) == NOTOK) -# else /* KPOP */ - snprintf (buffer, sizeof(buffer), "%s/%s", KPOP_PRINCIPAL, POPSERVICE); - if ((fd1 = client (host, "tcp", buffer, rpop, response, sizeof(response))) == NOTOK) -# endif +# ifdef KPOP + if ( kpop ) { + snprintf (buffer, sizeof(buffer), "%s/%s", KPOP_PRINCIPAL, "kpop"); + if ((fd1 = client (host, "tcp", buffer, 0, response, sizeof(response))) == NOTOK) { + return NOTOK; + } + } else { +# endif /* KPOP */ + if ((fd1 = client (host, "tcp", POPSERVICE, rpop, response, sizeof(response))) == NOTOK) + return NOTOK; +# ifdef KPOP + } +# endif /* KPOP */ #else /* NNTP */ if ((fd1 = client (host, "tcp", "nntp", rpop, response, sizeof(response))) == NOTOK) -#endif return NOTOK; +#endif if ((fd2 = dup (fd1)) == NOTOK) { char *s; diff --git a/zotnet/mts/client.c b/zotnet/mts/client.c index 924684c..0095959 100644 --- a/zotnet/mts/client.c +++ b/zotnet/mts/client.c @@ -208,6 +208,7 @@ rcaux (struct servent *sp, struct hostent *hp, int rproto, #ifdef KPOP int rem; + struct hostent *hp2; #endif /* KPOP */ for (ap = nets; ap < n1; ap++) @@ -256,7 +257,11 @@ rcaux (struct servent *sp, struct hostent *hp, int rproto, if (kservice) { /* "pop" */ char *instance; - if ((instance = strdup (hp->h_name)) == NULL) { + if (( hp2 = gethostbyaddr( hp->h_addr, hp->h_length, hp->h_addrtype )) + == NULL ) { + return NOTOK; + } + if ((instance = strdup (hp2->h_name)) == NULL) { close (sd); strncpy (response, "Out of memory.", len_response); return OOPS2; -- 1.7.10.4