[BACK]Return to patch-pty_c CVS log [TXT][DIR] Up to [local] / ports / net / xl2tpd / patches

File: [local] / ports / net / xl2tpd / patches / Attic / patch-pty_c (download)

Revision 1.1, Mon May 25 09:11:22 2009 UTC (15 years, 1 month ago) by yason
Branch: MAIN

Initial revision

--- pty.c.orig	Mon Mar  9 02:25:30 2009
+++ pty.c	Mon May 25 11:01:46 2009
@@ -25,6 +25,8 @@
 #include <errno.h>
 #include <stdio.h>
 #include <fcntl.h>
+#include <termios.h>
+#include <util.h>
 #include "l2tp.h"
 
 
@@ -47,77 +49,6 @@
 #define PTY01 "0123456789abcdefghijklmnopqrstuv"
 #endif
 
-#ifndef OPENBSD
-int getPtyMaster_pty (char *tty10, char *tty01)
-{
-    char *p10;
-    char *p01;
-    static char dev[] = PTY00;
-    int fd;
-
-    for (p10 = PTY10; *p10; p10++)
-    {
-        dev[8] = *p10;
-        for (p01 = PTY01; *p01; p01++)
-        {
-            dev[9] = *p01;
-            fd = open (dev, O_RDWR | O_NONBLOCK);
-            if (fd >= 0)
-            {
-                *tty10 = *p10;
-                *tty01 = *p01;
-                return fd;
-            }
-        }
-    }
-    l2tp_log (LOG_CRIT, "%s: No more free pseudo-tty's\n", __FUNCTION__);
-    return -1;
-}
-
-int getPtyMaster_ptmx(char *ttybuf, int ttybuflen)
-{
-    int fd;
-    char *tty;
-
-    fd = open("/dev/ptmx", O_RDWR);
-    if (fd == -1)
-    {
-	l2tp_log (LOG_WARNING, "%s: unable to open /dev/ptmx to allocate pty\n",
-		  __FUNCTION__);
-	return -EINVAL;
-    }
-
-    /* change the onwership */
-    if (grantpt(fd))
-    {
-	l2tp_log (LOG_WARNING, "%s: unable to grantpt() on pty\n",
-		  __FUNCTION__);
-	close(fd);
-	return -EINVAL;
-    }
-
-    if (unlockpt(fd))
-    {
-	l2tp_log (LOG_WARNING, "%s: unable to unlockpt() on pty\n",
-		  __FUNCTION__);
-	close(fd);
-	return -EINVAL;
-    }
-
-    tty = ptsname(fd);
-    if (tty == NULL)
-    {
-	l2tp_log (LOG_WARNING, "%s: unable to obtain name of slave tty\n",
-		  __FUNCTION__);
-	close(fd);
-	return -EINVAL;
-    }
-    ttybuf[0]='\0';
-    strncat(ttybuf, tty, ttybuflen);
-
-    return fd;
-}
-#ifdef OPENBSD
 int getPtyMaster_ptm(char *ttybuf, int ttybuflen)
 {
     int amaster, aslave;
@@ -138,36 +69,14 @@ int getPtyMaster_ptm(char *ttybuf, int ttybuflen)
 
     return amaster;
 }
-#endif /* OPENBSD */
 
 int getPtyMaster(char *ttybuf, int ttybuflen)
 {
     int fd;
-#ifndef OPENBSD
-    fd = getPtyMaster_ptmx(ttybuf, ttybuflen);
-    char a, b;
-
-    if(fd >= 0) {
-	return fd;
-    }
-
-    l2tp_log (LOG_WARNING, "%s: failed to use pts -- using legacy ptys\n", __FUNCTION__);
-    fd = getPtyMaster_pty(&a,&b);
-    
-    if(fd >= 0) {
-	snprintf(ttybuf, ttybuflen, "/dev/tty%c%c", a, b);
-	return fd;
-    }
-#endif
-#ifdef OPENBSD
-
     fd = getPtyMaster_ptm(ttybuf, ttybuflen);
     if(fd >= 0) {
         return fd;
     }
-#endif /* OPENBSD */
 
     return -EINVAL;
 }
-
-#endif