Skip to content

Commit

Permalink
mail/xmail: Fix pty handling
Browse files Browse the repository at this point in the history
Modernize to work with openpty(). Else we get this:

	Error: xmail cannot open master/slave pipe connection

MFH:	2023Q3
  • Loading branch information
cschuber committed Jul 18, 2023
1 parent 1c0793d commit 5ba8ffe
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 10 deletions.
2 changes: 1 addition & 1 deletion mail/xmail/Makefile
Expand Up @@ -14,7 +14,7 @@ LICENSE_FILE= ${WRKSRC}/COPYRIGHT
USES= imake xorg
USE_XORG= ice sm x11 xaw xbitmaps xext xmu xpm xt

CFLAGS+= -Wno-incompatible-function-pointer-types
CFLAGS+= -Wno-incompatible-function-pointer-types -lutil

post-patch:
# Fix the build with -fno-common (for Clang 11 and GCC 10)
Expand Down
6 changes: 3 additions & 3 deletions mail/xmail/files/patch-Imakefile
@@ -1,5 +1,5 @@
--- Imakefile.orig Mon Jan 30 22:41:47 1995
+++ Imakefile Wed Oct 15 09:52:37 2003
--- Imakefile.orig 1995-01-30 13:41:47.000000000 -0800
+++ Imakefile 2023-07-18 07:06:05.053673000 -0700
@@ -1,63 +1,62 @@
-/* */#
-/* */# @(#)Imakefile - for xmail version 1 patchlevel 5
Expand Down Expand Up @@ -103,7 +103,7 @@

DEPLIBS = $(DEPXAWLIB) $(DEPXMULIB) $(DEPXTOOLLIB) $(DEPXLIB)
-LOCAL_LIBRARIES = $(LIBXPM) $(XAWLIB) $(XMULIB) $(XTOOLLIB) $(XLIB) $(COMPFACE) $(LPT)
+LOCAL_LIBRARIES = $(LIBXPM) $(XAWLIB) $(XMULIB) $(XTOOLLIB) $(XLIB) $(COMPFACE) $(LPT) -lcompat
+LOCAL_LIBRARIES = $(LIBXPM) $(XAWLIB) $(XMULIB) $(XTOOLLIB) $(XLIB) $(COMPFACE) $(LPT) -lcompat -lutil

SRCS = Mailwatch.c HelpText.c actions.c callMail.c callbacks.c \
confirm.c directory.c environs.c handler.c mail.c parser.c \
50 changes: 44 additions & 6 deletions mail/xmail/files/patch-callMail.c
@@ -1,6 +1,17 @@
--- callMail.c.orig Thu Jan 26 21:52:01 1995
+++ callMail.c Wed Feb 4 23:30:07 1998
@@ -38,11 +38,10 @@
--- callMail.c.orig 1995-01-26 21:52:01.000000000 -0800
+++ callMail.c 2023-07-18 07:01:24.570712000 -0700
@@ -34,15 +34,21 @@
#include <sys/stat.h>
#include <signal.h>

+#ifdef __FreeBSD__
+#include <sys/types.h>
+#include <sys/ioctl.h>
+#include <termios.h>
+#include <libutil.h>
+#endif
+
#if defined(AIXV3) || defined(_IBMR2)
#include <sys/select.h>
#endif

Expand All @@ -14,7 +25,7 @@
#include <fcntl.h>
#if defined(att)
#include <sys/stropts.h>
@@ -81,7 +80,7 @@
@@ -81,7 +87,7 @@
#ifdef hpux
#define PTYCHAR2 "fedcba9876543210"
#else /* !hpux */
Expand All @@ -23,7 +34,23 @@
#endif /* !hpux */
#endif /* !PTYCHAR2 */

@@ -207,8 +206,8 @@
@@ -91,6 +97,7 @@
char pseudo_tty[20];


+#ifndef __FreeBSD__
/*
** @(#) openMaster - searches for and opens a pty master. If it finds one,
** it returns the value of the file descriptor. If not,
@@ -197,6 +204,7 @@
#endif
return(-1); /* look for more master/slave pairs */
} /* openSlave */
+#endif /* __FreeBSD__ */


/*
@@ -207,30 +215,34 @@
callMail(argv)
char *argv[];
{
Expand All @@ -34,7 +61,18 @@
#else
struct sgttyb Sgtty;
#endif
@@ -223,14 +222,14 @@
int slave; /* file descriptor to slave pty */


+#ifdef __FreeBSD__
+ openpty(&mail_fd, &slave, NULL, NULL, NULL);
+#else
for (;;) { /* find a pair, or master fails */
mail_fd = openMaster();
if ((slave = openSlave(mail_fd)) != -1)
break;
}
+#endif
/*
** Set minimal requirements for slave connection (no echo, no NL->CR, keep TABS)
*/
Expand Down

0 comments on commit 5ba8ffe

Please sign in to comment.