X-Git-Url: http://git.marmaro.de/?p=mmh;a=blobdiff_plain;f=uip%2Fmsgchk.c;h=9489ef0d716ccbc86dba511dcb6c8451f0d3bd05;hp=23ede03625ca2d3e469b5fdca0341f5e3f008e30;hb=8f4c5da8971926f7eccc912f7998c343aef3c33b;hpb=0d1c5f533f3a6cd1c7f038f59585378f53b666c2 diff --git a/uip/msgchk.c b/uip/msgchk.c index 23ede03..9489ef0 100644 --- a/uip/msgchk.c +++ b/uip/msgchk.c @@ -6,8 +6,8 @@ */ #include -#include -#include +#include +#include #include #ifdef POP @@ -42,6 +42,12 @@ # define KPOPminc(a) 0 #endif +#ifndef CYRUS_SASL +# define SASLminc(a) (a) +#else +# define SASLminc(a) 0 +#endif + static struct swit switches[] = { #define DATESW 0 { "date", 0 }, @@ -66,11 +72,15 @@ static struct swit switches[] = { #define VERSIONSW 10 { "version", 0 }, #define HELPSW 11 - { "help", 4 }, + { "help", 0 }, #define SNOOPSW 12 { "snoop", -5 }, #define KPOPSW 13 { "kpop", KPOPminc (-4) }, +#define SASLSW 14 + { "sasl", SASLminc(-4) }, +#define SASLMECHSW 15 + { "saslmech", SASLminc(-5) }, { NULL, 0 } }; @@ -101,7 +111,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, int); +static int remotemail (char *, char *, int, int, int, int, int, int, char *); #endif @@ -110,10 +120,10 @@ main (int argc, char **argv) { int datesw = 1, notifysw = NT_ALL; int rpop, status = 0; - int kpop = 0; + int kpop = 0, sasl = 0; int snoop = 0, vecp = 0; uid_t uid; - char *cp, *host = NULL, *user, buf[BUFSIZ]; + char *cp, *host = NULL, *user, buf[BUFSIZ], *saslmech = NULL; char **argp, **arguments, *vec[MAXVEC]; struct passwd *pw; @@ -214,6 +224,15 @@ main (int argc, char **argv) case SNOOPSW: snoop++; continue; + + case SASLSW: + sasl++; + continue; + + case SASLMECHSW: + if (!(saslmech = *argp++) || *saslmech == '-') + adios (NULL, "missing argument to %s", argp[-2]); + continue; } } if (vecp >= MAXVEC-1) @@ -259,11 +278,16 @@ main (int argc, char **argv) #ifdef POP if (host) { + if ( strcmp( POPSERVICE, "kpop" ) == 0 ) { + kpop = 1; + } if (vecp == 0) { - status = remotemail (host, user, rpop, kpop, notifysw, 1, snoop); + status = remotemail (host, user, rpop, kpop, notifysw, 1, snoop, + sasl, saslmech); } else { for (vecp = 0; vec[vecp]; vecp++) - status += remotemail (host, vec[vecp], rpop, kpop, notifysw, 0, snoop); + status += remotemail (host, vec[vecp], rpop, kpop, notifysw, 0, + snoop, sasl, saslmech); } } else { #endif /* POP */ @@ -384,20 +408,21 @@ checkmail (char *user, char *home, int datesw, int notifysw, int personal) extern char response[]; static int -remotemail (char *host, char *user, int rpop, int kpop, int notifysw, int personal, int snoop) +remotemail (char *host, char *user, int rpop, int kpop, int notifysw, int personal, int snoop, int sasl, char *saslmech) { int nmsgs, nbytes, status; char *pass = NULL; if (user == NULL) user = getusername (); - if (kpop || (rpop > 0)) + if (kpop || sasl || (rpop > 0)) pass = getusername (); else ruserpass (host, &user, &pass); /* open the POP connection */ - if (pop_init (host, user, pass, snoop, kpop ? 1 : rpop, kpop) == NOTOK + if (pop_init (host, user, pass, snoop, kpop ? 1 : rpop, kpop, + sasl, saslmech) == NOTOK || pop_stat (&nmsgs, &nbytes) == NOTOK /* check for messages */ || pop_quit () == NOTOK) { /* quit POP connection */ advise (NULL, "%s", response);