diff -urN pptp-1.7.1.orig/Makefile pptp-1.7.1/Makefile --- pptp-1.7.1.orig/Makefile 2006-02-13 06:07:42.000000000 +0300 +++ pptp-1.7.1/Makefile 2008-01-09 22:44:12.860111000 +0300 @@ -4,7 +4,7 @@ ################################################################# # CHANGE THIS LINE to point to the location of your pppd binary. -PPPD = /usr/sbin/pppd +PPPD = /usr/bin/pppd ################################################################# BINDIR=$(DESTDIR)/usr/sbin @@ -17,7 +17,11 @@ DEBUG = -g INCLUDE = CFLAGS = -Wall $(OPTIMIZE) $(DEBUG) $(INCLUDE) -LIBS = -lutil +# LIBS = -lutil +# Solaris 10 +LIBS = -lnsl -lsocket -lresolv +# Solaris Nevada build 14 or above +# LIBS = -lnsl -lsocket LDFLAGS = PPTP_BIN = pptp @@ -25,7 +29,7 @@ PPTP_OBJS = pptp.o pptp_gre.o ppp_fcs.o \ pptp_ctrl.o dirutil.o vector.o \ inststr.o util.o version.o \ - pptp_quirks.o orckit_quirks.o pqueue.o pptp_callmgr.o + pptp_quirks.o orckit_quirks.o pqueue.o pptp_callmgr.o pptp_compat.o PPTP_DEPS = pptp_callmgr.h pptp_gre.h ppp_fcs.h util.h \ pptp_quirks.h orckit_quirks.h config.h pqueue.h diff -urN pptp-1.7.1.orig/ppp_fcs.h pptp-1.7.1/ppp_fcs.h --- pptp-1.7.1.orig/ppp_fcs.h 2006-02-13 06:07:43.000000000 +0300 +++ pptp-1.7.1/ppp_fcs.h 2008-01-09 15:29:51.982000000 +0300 @@ -4,6 +4,8 @@ * $Id: ppp_fcs.h,v 1.1.1.1 2000/12/23 08:19:51 scott Exp $ */ +#include "pptp_compat.h" + #define PPPINITFCS16 0xffff /* Initial FCS value */ #define PPPGOODFCS16 0xf0b8 /* Good final FCS value */ Binary files pptp-1.7.1.orig/pptp and pptp-1.7.1/pptp differ diff -urN pptp-1.7.1.orig/pptp_compat.c pptp-1.7.1/pptp_compat.c --- pptp-1.7.1.orig/pptp_compat.c 1970-01-01 03:00:00.000000000 +0300 +++ pptp-1.7.1/pptp_compat.c 2008-01-09 22:51:48.389860000 +0300 @@ -0,0 +1,92 @@ +/* pptp_compat.c ... Compatibility functions + * + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include "pptp_compat.h" +#include +#include "util.h" + + +#if defined (__SVR4) && defined (__sun) /* Solaris */ +/* + * daemon implementation from uClibc + */ +int daemon(int nochdir, int noclose) +{ + int fd; + + switch (fork()) { + case -1: + return (-1); + case 0: + break; + default: + _exit(0); + } + + if (setsid() == -1) + return (-1); + + if (!nochdir) + chdir("/"); + + if (!noclose && (fd = open("/dev/null", O_RDWR, 0)) != -1) { + dup2(fd, STDIN_FILENO); + dup2(fd, STDOUT_FILENO); + dup2(fd, STDERR_FILENO); + if (fd > 2) + close (fd); + } + return (0); +} + +/* + * openpty implementation based on pts(7D) example + */ +int openpty(int *amaster, int *aslave, char *name, struct termios *termp, struct winsize * winp) { + int fdm,fds; + char * slavename; + + /* open master */ + if ( (fdm = open("/dev/ptmx", O_RDWR)) == -1 ) + return -1; + + /* grant access to the slave pseudo-terminal device */ + if ( grantpt(fdm) == -1 ) + return -1; + + /* unlock a pseudo-terminal master/slave pair */ + if ( unlockpt(fdm) == -1 ) + return -1; + + /* get name of the slave pseudo-terminal device */ + if ( (slavename = ptsname(fdm)) == NULL ) + return -1; + + if ( (fds = open(slavename, O_RDWR)) == -1 ) { + free(slavename); + return -1; + } + + ioctl(fds, I_PUSH, "ptem"); /* push ptem */ + ioctl(fds, I_PUSH, "ldterm"); /* push ldterm*/ + + if ( name != NULL ) + strcpy(name,slavename); + + *amaster = fdm; + *aslave = fds; + + free(slavename); + return 0; + +} +#endif /* Solaris */ diff -urN pptp-1.7.1.orig/pptp_compat.h pptp-1.7.1/pptp_compat.h --- pptp-1.7.1.orig/pptp_compat.h 1970-01-01 03:00:00.000000000 +0300 +++ pptp-1.7.1/pptp_compat.h 2008-01-09 19:34:26.608219000 +0300 @@ -0,0 +1,18 @@ +/* pptp_compat.h ... Compatibility functions + * + */ + +#if defined (__SVR4) && defined (__sun) /* Solaris */ +#include + +#define u_int8_t uint8_t +#define u_int16_t uint16_t +#define u_int32_t uint32_t + +#ifndef INADDR_NONE +#define INADDR_NONE 0xffffffffU +#endif + +int daemon(int nochdir, int noclose); +int openpty(int *amaster, int *aslave, char *name, struct termios *termp, struct winsize * winp); +#endif /* Solaris */ diff -urN pptp-1.7.1.orig/pptp_ctrl.h pptp-1.7.1/pptp_ctrl.h --- pptp-1.7.1.orig/pptp_ctrl.h 2006-02-13 06:07:43.000000000 +0300 +++ pptp-1.7.1/pptp_ctrl.h 2008-01-09 15:29:24.614969000 +0300 @@ -7,6 +7,7 @@ #ifndef INC_PPTP_CTRL_H #define INC_PPTP_CTRL_H #include +#include "pptp_compat.h" typedef struct PPTP_CONN PPTP_CONN; typedef struct PPTP_CALL PPTP_CALL; diff -urN pptp-1.7.1.orig/pptp_gre.h pptp-1.7.1/pptp_gre.h --- pptp-1.7.1.orig/pptp_gre.h 2006-02-13 06:07:43.000000000 +0300 +++ pptp-1.7.1/pptp_gre.h 2008-01-09 14:53:20.046840000 +0300 @@ -5,6 +5,8 @@ * $Id: pptp_gre.h,v 1.5 2004/06/09 00:13:32 quozl Exp $ */ +#include "pptp_compat.h" + int pptp_gre_bind(struct in_addr inetaddr); void pptp_gre_copy(u_int16_t call_id, u_int16_t peer_call_id, int pty_fd, int gre_fd); diff -urN pptp-1.7.1.orig/pptp_msg.h pptp-1.7.1/pptp_msg.h --- pptp-1.7.1.orig/pptp_msg.h 2006-02-13 06:07:43.000000000 +0300 +++ pptp-1.7.1/pptp_msg.h 2008-01-09 15:29:10.509468000 +0300 @@ -9,6 +9,7 @@ /* Grab definitions of int16, int32, etc. */ #include +#include "pptp_compat.h" /* define "portable" htons, etc. */ #define hton8(x) (x) #define ntoh8(x) (x) diff -urN pptp-1.7.1.orig/pptp.c pptp-1.7.1/pptp.c --- pptp-1.7.1.orig/pptp.c 2006-02-13 06:07:42.000000000 +0300 +++ pptp-1.7.1/pptp.c 2008-01-09 23:11:34.776541000 +0300 @@ -13,6 +13,7 @@ #include #elif defined(__APPLE__) #include +#elif defined (__SVR4) && defined (__sun) #else #include #endif @@ -52,6 +53,7 @@ #include "pptp_quirks.h" #include "pqueue.h" #include "pptp_options.h" +#include "pptp_compat.h" #ifndef PPPD_BINARY #define PPPD_BINARY "pppd" @@ -100,7 +102,11 @@ exit(1); } +#if defined (__SVR4) && defined (__sun) +struct in_addr localbind = { INADDR_ANY }; +#else struct in_addr localbind = { INADDR_NONE }; +#endif static int signaled = 0; /*** do nothing signal handler ************************************************/ @@ -353,8 +359,9 @@ file2fd("/dev/null", "wb", STDERR_FILENO); } - snprintf(buf, sizeof(buf), "pptp: GRE-to-PPP gateway on %s", - ttyname(tty_fd)); + char * tty_name = ttyname(tty_fd); + snprintf(buf, sizeof(buf), "pptp: GRE-to-PPP gateway on %s", + tty_name ? tty_name : "(null)"); #ifdef PR_SET_NAME rc = prctl(PR_SET_NAME, "pptpgw", 0, 0, 0); if (rc != 0) perror("prctl");