The attached patch supports Unix98 ptys under Linux, but removes
support for the old-style ptys (someone less lazy than me can figure
out how to do the configuration support for both cases).
Also, I've removed all references to RTF_DEFAULT; from the include
files, that seems to be a IPV6 thing, and so shouldn't go into the
rtentry structure (that's my guess at least; the constant doesn't even
fit into the rt_flags field).
*** pppd/sys-linux.c.orig Thu May 13 19:36:29 1999
--- pppd/sys-linux.c Tue Jul 27 13:31:00 1999
***************
*** 18,23 ****
--- 18,35 ----
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
+ /* Needed to get UNIX98 ptys from stdlib.h */
+ #ifndef _XOPEN_SOURCE
+ #define _XOPEN_SOURCE
+ #endif
+ /* Defining _XOPEN_SOURCE #undef's these, so #define them */
+ #ifndef _BSD_SOURCE
+ #define _BSD_SOURCE
+ #endif
+ #ifndef _SVID_SOURCE
+ #define _SVID_SOURCE
+ #endif
+
#include <sys/ioctl.h>
#include <sys/types.h>
#include <sys/socket.h>
***************
*** 88,97 ****
#include <sys/locks.h>
#endif
- #ifndef RTF_DEFAULT /* Normally in <linux/route.h> from <net/route.h> */
- #define RTF_DEFAULT 0
- #endif
-
/* We can get an EIO error on an ioctl if the modem has hung up */
#define ok_error(num) ((num)==EIO)
--- 100,105 ----
***************
*** 114,120 ****
static int restore_term = 0; /* 1 => we've munged the terminal */
static struct termios inittermios; /* Initial TTY termios */
! static char loop_name[20];
static unsigned char inbuf[512]; /* buffer for chars read from loopback */
static int if_is_up; /* Interface has been marked up */
--- 122,128 ----
static int restore_term = 0; /* 1 => we've munged the terminal */
static struct termios inittermios; /* Initial TTY termios */
! static char loop_name[MAXPATHLEN];
static unsigned char inbuf[512]; /* buffer for chars read from loopback */
static int if_is_up; /* Interface has been marked up */
***************
*** 1259,1265 ****
((struct sockaddr_in *) &rt.rt_gateway)->sin_addr.s_addr = gateway;
! rt.rt_flags = RTF_UP | RTF_GATEWAY | RTF_DEFAULT;
if (ioctl(sock_fd, SIOCADDRT, &rt) < 0) {
if ( ! ok_error ( errno ))
error("default route ioctl(SIOCADDRT): %m(%d)", errno);
--- 1267,1273 ----
((struct sockaddr_in *) &rt.rt_gateway)->sin_addr.s_addr = gateway;
! rt.rt_flags = RTF_UP | RTF_GATEWAY;
if (ioctl(sock_fd, SIOCADDRT, &rt) < 0) {
if ( ! ok_error ( errno ))
error("default route ioctl(SIOCADDRT): %m(%d)", errno);
***************
*** 1292,1298 ****
((struct sockaddr_in *) &rt.rt_gateway)->sin_addr.s_addr = gateway;
! rt.rt_flags = RTF_UP | RTF_GATEWAY | RTF_DEFAULT;
if (ioctl(sock_fd, SIOCDELRT, &rt) < 0 && errno != ESRCH) {
if (still_ppp()) {
if ( ! ok_error ( errno ))
--- 1300,1306 ----
((struct sockaddr_in *) &rt.rt_gateway)->sin_addr.s_addr = gateway;
! rt.rt_flags = RTF_UP | RTF_GATEWAY;
if (ioctl(sock_fd, SIOCDELRT, &rt) < 0 && errno != ESRCH) {
if (still_ppp()) {
if ( ! ok_error ( errno ))
***************
*** 1569,1575 ****
int local_fd;
int mfd = -1;
int ret = 0;
! char slave[16];
/*
* We used to open the serial device and set it to the ppp line
--- 1577,1583 ----
int local_fd;
int mfd = -1;
int ret = 0;
! char slave[MAXPATHLEN];
/*
* We used to open the serial device and set it to the ppp line
***************
*** 2117,2123 ****
/*
* get_pty - get a pty master/slave pair and chown the slave side
! * to the uid given. Assumes slave_name points to >= 12 bytes of space.
*/
int
get_pty(master_fdp, slave_fdp, slave_name, uid)
--- 2125,2131 ----
/*
* get_pty - get a pty master/slave pair and chown the slave side
! * to the uid given. Assumes slave_name points to MAXPATHLEN bytes of space.
*/
int
get_pty(master_fdp, slave_fdp, slave_name, uid)
***************
*** 2126,2152 ****
char *slave_name;
int uid;
{
! int i, mfd, sfd;
! char pty_name[12];
struct termios tios;
! sfd = -1;
! for (i = 0; i < 64; ++i) {
! slprintf(pty_name, sizeof(pty_name), "/dev/pty%c%x",
! 'p' + i / 16, i % 16);
! mfd = open(pty_name, O_RDWR, 0);
! if (mfd >= 0) {
! pty_name[5] = 't';
! sfd = open(pty_name, O_RDWR | O_NOCTTY, 0);
! if (sfd >= 0)
! break;
! close(mfd);
! }
}
- if (sfd < 0)
- return 0;
! strlcpy(slave_name, pty_name, 12);
*master_fdp = mfd;
*slave_fdp = sfd;
fchown(sfd, uid, -1);
--- 2134,2171 ----
char *slave_name;
int uid;
{
! int mfd, sfd;
! char *pty_name;
! size_t pty_len;
struct termios tios;
! /* Get master fd */
! mfd = open("/dev/ptmx",O_RDWR,0);
! if (mfd < 0)
! return 0;
! if (grantpt(mfd) < 0 || unlockpt(mfd) < 0) {
! close(mfd);
! return 0;
! }
! /* Find name of slave device */
! pty_name = ptsname(mfd);
! if (pty_name == 0) {
! close(mfd);
! return 0;
! }
! pty_len = sizeof(pty_name);
! if (pty_len >= MAXPATHLEN) {
! close(mfd);
! return 0;
! }
! /* open slave device */
! sfd = open(pty_name, O_RDWR | O_NOCTTY, 0);
! if (sfd < 0) {
! close(mfd);
! return 0;
}
! strcpy(slave_name, pty_name);
*master_fdp = mfd;
*slave_fdp = sfd;
fchown(sfd, uid, -1);
--
J. Scott Berg [EMAIL PROTECTED]
3025 E. Amy Ln. (812) 339-8368
Bloomington, IN 47408-4220