Path: blob/main/ftp/gftp/files/patch-lib-pty.c
16151 views
--- lib/pty.c.orig 2007-03-13 02:56:43.000000000 +01001+++ lib/pty.c 2010-01-17 17:34:25.000000000 +01002@@ -59,6 +59,50 @@3return (new_fds);4}56+#elif HAVE_OPENPTY7+8+#ifdef HAVE_PTY_H9+#include <pty.h>10+#include <utmp.h> /* for login_tty */11+#elif HAVE_LIBUTIL_H12+#include <libutil.h>13+#else14+extern int openpty(int *amaster, int *aslave, char *name, struct termios *termp, struct winsize * winp);15+extern int login_tty(int fd);16+#endif17+18+char *19+gftp_get_pty_impl (void)20+{21+ return ("openpty");22+}23+24+25+static int26+_gftp_ptym_open (char *pts_name, size_t len, int *fds)27+{28+ int fdm;29+30+ if (openpty (&fdm, fds, pts_name, NULL, NULL) < 0)31+ return (GFTP_ERETRYABLE);32+33+ ioctl (*fds, TIOCSCTTY, NULL);34+35+ return (fdm);36+}37+38+39+static int40+_gftp_ptys_open (int fdm, int fds, char *pts_name)41+{42+ if (login_tty (fds) < 0) {43+ close(fds);44+ return (GFTP_EFATAL);45+ }46+47+ return (fds);48+}49+50#elif HAVE_GRANTPT5152#if !(defined(__FreeBSD__) || defined(__NetBSD__) || defined(__APPLE__))53@@ -131,49 +192,6 @@54return (new_fds);55}5657-#elif HAVE_OPENPTY58-59-#ifdef HAVE_PTY_H60-#include <pty.h>61-#include <utmp.h> /* for login_tty */62-#elif HAVE_LIBUTIL_H63-#include <libutil.h>64-#include <utmp.h> /* for login_tty */65-#else66-extern int openpty(int *amaster, int *aslave, char *name, struct termios *termp, struct winsize * winp);67-extern int login_tty(int fd);68-#endif69-70-char *71-gftp_get_pty_impl (void)72-{73- return ("openpty");74-}75-76-77-static int78-_gftp_ptym_open (char *pts_name, size_t len, int *fds)79-{80- int fdm;81-82- if (openpty (&fdm, fds, pts_name, NULL, NULL) < 0)83- return (GFTP_ERETRYABLE);84-85- ioctl (*fds, TIOCSCTTY, NULL);86-87- return (fdm);88-}89-90-91-static int92-_gftp_ptys_open (int fdm, int fds, char *pts_name)93-{94- if (login_tty (fds) < 0)95- return (GFTP_EFATAL);96-97- return (fds);98-}99-100#else101102/* Fall back to *BSD... */103104105