Christian Weisgerber <na...@mips.inka.de> writes: > Jérémie Courrèges-Anglas: > >> I have diffs for metamail, elm, and gopher. > > metamail is a candidate for the most terrible code in the ports > tree. It can't be saved. Considering that e-mail is a primary > attack surface, I think we should kill it. Unfortunately, there > are even ports that depend on it. Ugh.
Let's try to keep it alive a bit longer, ok? ;) > Does elm actually need a fix? It defines its own version of cuserid() > and doesn't link with -lcompat, does it? Yup, I was making a list of the tmux panes I had opened but forgot that elm didn't need any change. Here's the metamail diff. I provide a knob to use tc[gs]etattr if desired. I didn't use cfmakeraw() since it seems that this one hasn't made its way into POSIX. While here I replaced the gets() calls with fgets but if that's not desired I can remove those parts. OK? Index: Makefile =================================================================== RCS file: /cvs/ports/mail/metamail/Makefile,v retrieving revision 1.28 diff -u -p -r1.28 Makefile --- Makefile 11 Mar 2013 11:23:51 -0000 1.28 +++ Makefile 29 Nov 2013 22:41:12 -0000 @@ -4,7 +4,7 @@ COMMENT= MIME implementation DISTNAME= mm2.7 PKGNAME= metamail-2.7 -REVISION= 3 +REVISION= 4 CATEGORIES= mail MASTER_SITES= http://www.guppylake.com/~nsb/metamail/ @@ -17,7 +17,7 @@ WANTLIB= c termcap USE_X11 = Yes WRKSRC= ${WRKDIST}/src -MAKE_FLAGS= CC="${CC}" +MAKE_FLAGS= CC="${CC}" CFLAGS="-DHAVE_TCGETATTR ${CFLAGS}" NO_TEST= Yes post-configure: Index: patches/patch-src_Makefile =================================================================== RCS file: /cvs/ports/mail/metamail/patches/patch-src_Makefile,v retrieving revision 1.1 diff -u -p -r1.1 patch-src_Makefile --- patches/patch-src_Makefile 17 Mar 2012 10:57:23 -0000 1.1 +++ patches/patch-src_Makefile 29 Nov 2013 22:29:46 -0000 @@ -1,6 +1,6 @@ $OpenBSD: patch-src_Makefile,v 1.1 2012/03/17 10:57:23 sthen Exp $ ---- src/Makefile.orig Wed Jan 26 17:32:33 1994 -+++ src/Makefile Sat Mar 17 10:51:52 2012 +--- src/Makefile.orig Wed Jan 26 18:32:33 1994 ++++ src/Makefile Fri Nov 29 23:29:41 2013 @@ -38,7 +38,7 @@ FOOBAR-sun4=-Bstatic STATICFLAG=FOOBAR${HOST_ARCH} @@ -10,18 +10,6 @@ $OpenBSD: patch-src_Makefile,v 1.1 2012/ # The following is better if you want to make sure you run with SYSV defined # CFLAGS = -g -I. ${$(STATICFLAG)} -DSYSV # Also, for SGI Irix, compile in K&R mode -@@ -49,9 +49,9 @@ CFLAGS = -g -I. ${$(STATICFLAG)} - # LDLIBS variable. - # - # For Sun and BSD systems, the following should work... --LDLIBS = -+# LDLIBS = - # On BSD 4.4 systems, you will need the following --# LDLIBS = -lcompat -+LDLIBS = -s -lcompat - # On SGI machines, we need -lsun for getpw...(), and -lc_s saves some space. - # LDLIBS = -lsun -lc_s - # ISC SysVr3.2.2 has a shared C library and requires libinet.a to resolve @@ -72,10 +72,10 @@ CONFIGDIR = . # install -s -c $(LOCALBINDIR) $$file # Index: patches/patch-src_config_h =================================================================== RCS file: /cvs/ports/mail/metamail/patches/patch-src_config_h,v retrieving revision 1.1 diff -u -p -r1.1 patch-src_config_h --- patches/patch-src_config_h 17 Mar 2012 10:57:23 -0000 1.1 +++ patches/patch-src_config_h 29 Nov 2013 21:43:44 -0000 @@ -1,6 +1,6 @@ $OpenBSD: patch-src_config_h,v 1.1 2012/03/17 10:57:23 sthen Exp $ ---- src/config.h.orig Wed Nov 24 15:36:07 1993 -+++ src/config.h Sat Mar 17 10:51:52 2012 +--- src/config.h.orig Wed Nov 24 16:36:07 1993 ++++ src/config.h Fri Nov 29 19:40:35 2013 @@ -73,7 +73,7 @@ WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES. #ifdef SYSV #define RESET_PROGRAM "tput clear" @@ -29,7 +29,7 @@ $OpenBSD: patch-src_config_h,v 1.1 2012/ #define PATH_SEPARATOR ':' #ifndef STDPATH -#define STDPATH "/.mailcap:/usr/local/etc/mailcap:/usr/etc/mailcap:/etc/mailcap:/etc/mail/mailcap:/usr/public/lib/mailcap" -+#define STDPATH "/.mailcap:${SYSCONFDIR}/mailcap:/etc/mail/mailcap" ++#define STDPATH "/.mailcap:/etc/mailcap:/etc/mail/mailcap" #endif #endif #endif Index: patches/patch-src_metamail_metamail_c =================================================================== RCS file: /cvs/ports/mail/metamail/patches/patch-src_metamail_metamail_c,v retrieving revision 1.1 diff -u -p -r1.1 patch-src_metamail_metamail_c --- patches/patch-src_metamail_metamail_c 17 Mar 2012 10:57:23 -0000 1.1 +++ patches/patch-src_metamail_metamail_c 29 Nov 2013 21:55:58 -0000 @@ -1,6 +1,6 @@ $OpenBSD: patch-src_metamail_metamail_c,v 1.1 2012/03/17 10:57:23 sthen Exp $ ---- src/metamail/metamail.c.orig Thu Feb 17 01:57:19 1994 -+++ src/metamail/metamail.c Sat Mar 17 10:51:52 2012 +--- src/metamail/metamail.c.orig Thu Feb 17 02:57:19 1994 ++++ src/metamail/metamail.c Fri Nov 29 22:55:55 2013 @@ -20,6 +20,8 @@ WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES. ******************************************************* */ @@ -19,7 +19,25 @@ $OpenBSD: patch-src_metamail_metamail_c, #define WRITE_BINARY "w" #else /* BORLAND */ #ifdef MICROSOFT -@@ -100,13 +102,6 @@ extern char **environ, *gets(); +@@ -46,12 +48,14 @@ extern char *mktemp(char *); + #include <signal.h> + + #ifndef AMIGA +-#ifdef SYSV ++#if defined(HAVE_TCGETATTR) ++#include <termios.h> ++#elif defined(SYSV) + #include <termio.h> + #include <unistd.h> +-#else /* SYSV */ ++#else + #include <sgtty.h> +-#endif /* SYSV */ ++#endif + #endif /* AMIGA */ + #endif /* MICROSOFT */ + #endif /* BORLAND */ +@@ -100,13 +104,6 @@ extern char **environ, *gets(); #define CMDSIZE 1200 /* Maximum size of command to execute */ #define LINE_BUF_SIZE 2000 @@ -33,7 +51,7 @@ $OpenBSD: patch-src_metamail_metamail_c, char fileToDelete[MAX_FILE_NAME_SIZE]; char *FindParam(); -@@ -302,24 +297,6 @@ char **argv; +@@ -302,24 +299,6 @@ char **argv; int retcode; modpath(AUXPATH); @@ -58,7 +76,16 @@ $OpenBSD: patch-src_metamail_metamail_c, tmproot = getenv("METAMAIL_TMPDIR"); if (!tmproot) tmproot="/tmp"; mailheaders = getenv("MM_HEADERS"); -@@ -1202,9 +1179,9 @@ char *SquirrelFile; +@@ -579,7 +558,7 @@ int nestingdepth; + int overwriteans = -1; + do { + printf("File %s exists. Do you want to overwrite it (y/n) ?\n", Fname); +- s = gets(AnsBuf); ++ s = fgets(AnsBuf, sizeof(AnsBuf), stdin); + if (!s) { + overwriteans = 0; + } else { +@@ -1202,9 +1181,9 @@ char *SquirrelFile; fprintf(outfp, "Content-type: %s", ContentType); for (j=0; j<CParamsUsed; ++j) { fprintf(outfp, " ; "); @@ -70,7 +97,16 @@ $OpenBSD: patch-src_metamail_metamail_c, } fprintf(outfp, "\n\n"); TranslateInputToOutput(InputFP, outfp, EncodingCode, ContentType); -@@ -2022,7 +1999,7 @@ int ShowLeadingWhitespace; +@@ -1823,7 +1802,7 @@ char *ctype, *progname, *label; + } else { + printf("This message contains '%s'-format data.\nDo you want to view it using the '%s' command (y/n) [y] ? ", ctype, ShortCommand(progname)); + } +- s = gets(AnsBuf); ++ s = fgets(AnsBuf, sizeof(AnsBuf), stdin); + if (!s) return(0); /* EOF */ + while (s && *s && isspace((unsigned char) *s)) ++s; + if (*s == 'y' || *s == 'Y' || !*s || *s == '\n') return(1); +@@ -2022,7 +2001,7 @@ int ShowLeadingWhitespace; if (lc2strcmp(charset, PrevCharset)) { char *s2, *charsetinuse; @@ -79,7 +115,7 @@ $OpenBSD: patch-src_metamail_metamail_c, for (s2=PrevCharset; *s2; ++s2) { if (isupper((unsigned char) *s2)) *s2 = tolower((unsigned char) *s2); } -@@ -2032,7 +2009,7 @@ int ShowLeadingWhitespace; +@@ -2032,7 +2011,7 @@ int ShowLeadingWhitespace; } } if (ecode == ENCODING_NONE) { @@ -88,7 +124,44 @@ $OpenBSD: patch-src_metamail_metamail_c, } else { /* What follows is REALLY bogus, but all my encoding stuff is pipe-oriented right now... */ MkTmpFileName(TmpFile); -@@ -2489,14 +2466,14 @@ char *name; +@@ -2374,8 +2353,11 @@ char *Prefix; + } + + int HasSavedTtyState=0; ++ + #if !defined(AMIGA) && !defined(MSDOS) +-#ifdef SYSV ++#if defined(HAVE_TCGETATTR) ++static struct termios MyTtyStateIn, MyTtyStateOut; ++#elif defined(SYSV) + static struct termio MyTtyStateIn, MyTtyStateOut; + #else + static struct sgttyb MyTtyStateIn, MyTtyStateOut; +@@ -2385,7 +2367,10 @@ static struct sgttyb MyTtyStateIn, MyTtyStateOut; + SaveTtyState() { + /* Bogus -- would like a good portable way to reset the terminal state here */ + #if !defined(AMIGA) && !defined(MSDOS) +-#ifdef SYSV ++#if defined(HAVE_TCGETATTR) ++ tcgetattr(fileno(stdin), &MyTtyStateIn); ++ tcgetattr(fileno(stdout), &MyTtyStateOut); ++#elif defined(SYSV) + ioctl(fileno(stdin), TCGETA, &MyTtyStateIn); + ioctl(fileno(stdout), TCGETA, &MyTtyStateOut); + #else +@@ -2398,7 +2383,10 @@ SaveTtyState() { + + RestoreTtyState() { + #if !defined(AMIGA) && !defined(MSDOS) +-#ifdef SYSV ++#if defined(HAVE_TCGETATTR) ++ tcsetattr(fileno(stdin), TCSADRAIN, &MyTtyStateIn); ++ tcsetattr(fileno(stdout), TCSADRAIN, &MyTtyStateOut); ++#elif defined(SYSV) + if (HasSavedTtyState) { + ioctl(fileno(stdout), TCSETA, &MyTtyStateOut); + ioctl(fileno(stdin), TCSETA, &MyTtyStateIn); +@@ -2489,14 +2477,14 @@ char *name; { #ifdef AMIGA strcpy(name, "T:mmXXXXXX"); @@ -106,3 +179,21 @@ $OpenBSD: patch-src_metamail_metamail_c, name[0] = 0; else if (DoDebug) printf("temp name = \"%s\"\n", name); +@@ -2681,7 +2669,16 @@ PauseForUser() { + + StartRawStdin() { + #if !defined(AMIGA) && !defined(MSDOS) +-#ifdef SYSV ++#if defined(HAVE_TCGETATTR) ++ struct termios term; ++ ++ if (tcgetattr(0, &term) == -1) /* get current (i.e. cooked) termio */ ++ return -1; ++ term.c_lflag &= ~ICANON; /* clear ICANON giving raw mode */ ++ term.c_cc[VMIN] = 1; /* set MIN char count to 1 */ ++ term.c_cc[VTIME] = 0; /* set NO time limit */ ++ return tcsetattr(0, TCSADRAIN, &term); ++#elif defined(SYSV) + struct termio orterm, fterm; + ioctl(0, TCGETA, &orterm); /* get current (i.e. cooked) termio */ + fterm = orterm; /* get termio to modify */