X-Git-Url: http://git.marmaro.de/?a=blobdiff_plain;f=uip%2Finc.c;h=07440b123f3cd5e56f668dc28abcbbd45ba5c0dd;hb=bfad64befb4d6696fdfb63b119666eec4bac6fb3;hp=3dd1872f806121843dad37dc8601447af7fe50e8;hpb=bc20acd6c385612fd19bc3ce40f56c32983748f1;p=mmh diff --git a/uip/inc.c b/uip/inc.c index 3dd1872..07440b1 100644 --- a/uip/inc.c +++ b/uip/inc.c @@ -30,11 +30,8 @@ #include #include -#ifdef POP -# include -# include -#endif - +#include +#include #include #include #include @@ -43,12 +40,6 @@ #include #include -#ifndef POP -# define POPminc(a) (a) -#else -# define POPminc(a) 0 -#endif - #ifndef CYRUS_SASL # define SASLminc(a) (a) #else @@ -71,15 +62,15 @@ static struct swit switches[] = { #define FMTSW 6 { "format string", 5 }, #define HOSTSW 7 - { "host hostname", POPminc (-4) }, + { "host hostname", 0 }, #define USERSW 8 - { "user username", POPminc (-4) }, + { "user username", 0 }, #define PACKSW 9 - { "pack file", POPminc (-4) }, + { "pack file", 0}, #define NPACKSW 10 - { "nopack", POPminc (-6) }, + { "nopack", 0 }, #define PORTSW 11 - { "port name/number", POPminc (-4) }, + { "port name/number", 0 }, #define SILSW 12 { "silent", 0 }, #define NSILSW 13 @@ -98,10 +89,12 @@ static struct swit switches[] = { { "snoop", -5 }, #define SASLSW 20 { "sasl", SASLminc(-4) }, -#define SASLMECHSW 21 +#define NOSASLSW 21 + { "nosasl", SASLminc(-6) }, +#define SASLMECHSW 22 { "saslmech", SASLminc(-8) }, -#define PROXYSW 22 - { "proxy command", POPminc(-5) }, +#define PROXYSW 23 + { "proxy command", 0 }, { NULL, 0 } }; @@ -119,7 +112,6 @@ static struct Maildir_entry { static int num_maildir_entries = 0; static int snoop = 0; -#ifdef POP extern char response[]; static int size; @@ -127,7 +119,6 @@ static long pos; static int mbx_style = MMDF_FORMAT; static int pd = NOTOK; -#endif /* POP */ static long start; static long stop; @@ -139,13 +130,9 @@ static FILE *pf = NULL; * privilege ops into macros. * *GROUPPRIVS() is related to handling the setgid MAIL property, * and only applies if MAILGROUP is defined. - * *USERPRIVS() is related to handling the setuid root property, - * and only applies if POP is defined [why does POP => setuid root?] * Basically, SAVEGROUPPRIVS() is called right at the top of main() * to initialise things, and then DROPGROUPPRIVS() and GETGROUPPRIVS() - * do the obvious thing. TRYDROPGROUPPRIVS() has to be safe to call - * before DROPUSERPRIVS() is called [this is needed because setgid() - * sets both effective and real uids if euid is root.] + * do the obvious thing. * * There's probably a better implementation if we're allowed to use * BSD-style setreuid() rather than using POSIX saved-ids. @@ -162,15 +149,7 @@ static FILE *pf = NULL; */ #ifdef MAILGROUP static int return_gid; -#ifndef POP -/* easy case; we're not setuid root, so can drop group privs - * immediately. - */ #define TRYDROPGROUPPRIVS() DROPGROUPPRIVS() -#else /* POP ie we are setuid root */ -#define TRYDROPGROUPPRIVS() \ -if (geteuid() != 0) DROPGROUPPRIVS() -#endif #define DROPGROUPPRIVS() setgid(getgid()) #define GETGROUPPRIVS() setgid(return_gid) #define SAVEGROUPPRIVS() return_gid = getegid() @@ -193,11 +172,9 @@ static FILE *in; char *map_name(char *); static void inc_done(int) NORETURN; -#ifdef POP static int pop_action(char *); static int pop_pack(char *); static int map_count(void); -#endif int maildir_srt(const void *va, const void *vb) @@ -227,18 +204,12 @@ main (int argc, char **argv) struct msgs *mp = NULL; struct stat st, s1; FILE *aud = NULL; - char b[MAXPATHLEN + 1]; + char b[PATH_MAX + 1]; char *maildir_copy = NULL; /* copy of mail directory because the static gets overwritten */ -#ifdef POP int nmsgs, nbytes; char *pass = NULL; char *MAILHOST_env_variable; -#endif - -#ifdef MHE - FILE *mhe = NULL; -#endif done=inc_done; @@ -260,7 +231,6 @@ main (int argc, char **argv) arguments = getarguments (invo_name, argc, argv, 1); argp = arguments; -#ifdef POP /* * Scheme is: * use MAILHOST environment variable if present, @@ -277,10 +247,6 @@ main (int argc, char **argv) if (pophost && *pophost) host = pophost; - if ((cp = getenv ("MHPOPDEBUG")) && *cp) - snoop++; -#endif /* POP */ - while ((cp = *argp++)) { if (*cp == '-') { switch (smatch (++cp, switches)) { @@ -293,10 +259,10 @@ main (int argc, char **argv) case HELPSW: snprintf (buf, sizeof(buf), "%s [+folder] [switches]", invo_name); print_help (buf, switches, 1); - done (1); + done (0); case VERSIONSW: print_version(invo_name); - done (1); + done (0); case AUDSW: if (!(cp = *argp++) || *cp == '-') @@ -371,7 +337,7 @@ main (int argc, char **argv) continue; case PORTSW: - if (!(host = *argp++) || *port == '-') + if (!(port = *argp++) || *port == '-') adios (NULL, "missing argument to %s", argp[-2]); continue; @@ -381,18 +347,11 @@ main (int argc, char **argv) continue; case PACKSW: -#ifndef POP - if (!(cp = *argp++) || *cp == '-') - adios (NULL, "missing argument to %s", argp[-2]); -#else /* POP */ if (!(packfile = *argp++) || *packfile == '-') adios (NULL, "missing argument to %s", argp[-2]); -#endif /* POP */ continue; case NPACKSW: -#ifdef POP packfile = NULL; -#endif /* POP */ continue; case SNOOPSW: @@ -402,6 +361,9 @@ main (int argc, char **argv) case SASLSW: sasl++; continue; + case NOSASLSW: + sasl = 0; + continue; case SASLMECHSW: if (!(saslmech = *argp++) || *saslmech == '-') @@ -426,10 +388,8 @@ main (int argc, char **argv) /* NOTE: above this point you should use TRYDROPGROUPPRIVS(), * not DROPGROUPPRIVS(). */ -#ifdef POP if (host && !*host) host = NULL; -#endif /* POP */ /* guarantee dropping group priveleges; we might not have done so earlier */ DROPGROUPPRIVS(); @@ -439,14 +399,11 @@ main (int argc, char **argv) */ if (from) inc_type = INC_FILE; -#ifdef POP else if (host) inc_type = INC_POP; -#endif else inc_type = INC_FILE; -#ifdef POP /* * Are we getting the mail from * a POP server? @@ -475,7 +432,6 @@ main (int argc, char **argv) adios (NULL, "no mail to incorporate"); } } -#endif /* POP */ /* * We will get the mail from a file @@ -550,11 +506,9 @@ main (int argc, char **argv) newmail = cp; } -#ifdef POP /* skip the folder setup */ if ((inc_type == INC_POP) && packfile) goto go_to_it; -#endif /* POP */ if (!context_find ("path")) free (path ("./", TFOLDER)); @@ -582,9 +536,7 @@ main (int argc, char **argv) if (!(mp = folder_read (folder))) adios (NULL, "unable to read folder %s", folder); -#ifdef POP go_to_it: -#endif /* POP */ if (inc_type == INC_FILE && Maildir == NULL) { if (access (newmail, W_OK) != NOTOK) { @@ -621,31 +573,12 @@ go_to_it: else if (i == NOTOK) chmod (audfile, m_gmprot ()); -#ifdef POP fprintf (aud, from ? "<> %s -ms %s\n" : host ? "<> %s -host %s -user %s\n" : "<> %s\n", dtimenow (0), from ? from : host, user); -#else /* POP */ - fprintf (aud, from ? "<> %s -ms %s\n" : "<> %s\n", - dtimenow (0), from); -#endif /* POP */ } -#ifdef MHE - if (context_find ("mhe")) { - int i; - cp = concat (maildir, "/++", NULL); - i = stat (cp, &st); - if ((mhe = fopen (cp, "a")) == NULL) - admonish (cp, "unable to append to"); - else - if (i == NOTOK) - chmod (cp, m_gmprot ()); - free (cp); - } -#endif /* MHE */ - /* Get new format string */ nfs = new_fs (form, format, FORMAT); @@ -654,7 +587,6 @@ go_to_it: fflush (stdout); } -#ifdef POP /* * Get the mail from a POP server */ @@ -741,10 +673,6 @@ go_to_it: default: if (aud) fputs (scanl, aud); -# ifdef MHE - if (mhe) - fputs (scanl, mhe); -# endif /* MHE */ if (noisy) fflush (stdout); if (!packfile) { @@ -787,7 +715,6 @@ go_to_it: pd = NOTOK; } } -#endif /* POP */ /* * Get the mail from file (usually mail spool) @@ -807,19 +734,6 @@ go_to_it: break; } -#if 0 - /* copy file from spool to tmp file */ - tmpfilenam = m_scratch ("", invo_name); - if ((fd = creat (tmpfilenam, m_gmprot ())) == NOTOK) - adios (tmpfilenam, "unable to create"); - chmod (tmpfilenam, m_gmprot ()); - if (!(in2 = fdopen (fd, "r+"))) - adios (tmpfilenam, "unable to access"); - cpymsg (in, in2); - - /* link message into folder */ - newmsg = folder_addmsg(mp, tmpfilenam); -#endif /* create scanline for new message */ switch (incerr = scan (in, msgnum + 1, msgnum + 1, nfs, width, msgnum == hghnum && chgflag, 1, NULL, 0L, noisy)) { @@ -852,10 +766,6 @@ go_to_it: if (aud) fputs (scanl, aud); -#ifdef MHE - if (mhe) - fputs (scanl, mhe); -#endif /* MHE */ if (noisy) fflush (stdout); @@ -951,10 +861,6 @@ go_to_it: if (aud) fputs (scanl, aud); -# ifdef MHE - if (mhe) - fputs (scanl, mhe); -# endif /* MHE */ if (noisy) fflush (stdout); if (!packfile) { @@ -995,18 +901,11 @@ go_to_it: if (aud) fclose (aud); -#ifdef MHE - if (mhe) - fclose (mhe); -#endif /* MHE */ - if (noisy) fflush (stdout); -#ifdef POP if ((inc_type == INC_POP) && packfile) done (0); -#endif /* POP */ /* * truncate file we are incorporating from @@ -1063,46 +962,11 @@ go_to_it: } -#if 0 - -/* - * Copy message message from spool into - * temporary file. Massage the "From " line - * while copying. - */ - -cpymsg (FILE *in, FILE *out) -{ - int state; - char *tmpbuf, name[NAMESZ]; - - for (;;) { - state = m_getfld (state, name, tmpbuf, rlwidth, in); - switch (state) { - case FLD: - case FLDPLUS: - break; - case BODY: - break; - case LENERR: - case FMTERR: - break; - case FILEEOF: - break; - default: - } - } -} -#endif /* if 0 */ - - static void inc_done (int status) { -#ifdef POP if (packfile && pd != NOTOK) mbx_close (packfile, pd); -#endif /* POP */ if (locked) { GETGROUPPRIVS(); @@ -1112,7 +976,6 @@ inc_done (int status) exit (status); } -#ifdef POP static int pop_action (char *s) { @@ -1156,4 +1019,3 @@ map_count (void) close (md); return (d.d_id); } -#endif /* POP */