|
|
27639a |
diff -up pptp-1.7.2/pptp.c.alias pptp-1.7.2/pptp.c
|
|
|
27639a |
--- pptp-1.7.2/pptp.c.alias 2011-12-06 22:24:06.617318769 +0000
|
|
|
27639a |
+++ pptp-1.7.2/pptp.c 2011-12-06 22:36:25.761692858 +0000
|
|
|
27639a |
@@ -463,7 +463,10 @@ int open_callmgr(struct in_addr inetaddr
|
|
|
27639a |
char **envp, int pty_fd, int gre_fd)
|
|
|
27639a |
{
|
|
|
27639a |
/* Try to open unix domain socket to call manager. */
|
|
|
27639a |
- struct sockaddr_un where;
|
|
|
27639a |
+ union {
|
|
|
27639a |
+ struct sockaddr a;
|
|
|
27639a |
+ struct sockaddr_un u;
|
|
|
27639a |
+ } where;
|
|
|
27639a |
const int NUM_TRIES = 3;
|
|
|
27639a |
int i, fd;
|
|
|
27639a |
pid_t pid;
|
|
|
27639a |
@@ -473,12 +476,12 @@ int open_callmgr(struct in_addr inetaddr
|
|
|
27639a |
fatal("Could not create unix domain socket: %s", strerror(errno));
|
|
|
27639a |
}
|
|
|
27639a |
/* Make address */
|
|
|
27639a |
- callmgr_name_unixsock(&where, inetaddr, localbind);
|
|
|
27639a |
+ callmgr_name_unixsock(&where.u, inetaddr, localbind);
|
|
|
27639a |
for (i = 0; i < NUM_TRIES; i++) {
|
|
|
27639a |
- if (connect(fd, (struct sockaddr *) &where, sizeof(where)) < 0) {
|
|
|
27639a |
+ if (connect(fd, &where.a, sizeof(where.u)) < 0) {
|
|
|
27639a |
/* couldn't connect. We'll have to launch this guy. */
|
|
|
27639a |
|
|
|
27639a |
- unlink (where.sun_path);
|
|
|
27639a |
+ unlink (where.u.sun_path);
|
|
|
27639a |
|
|
|
27639a |
/* fork and launch call manager process */
|
|
|
27639a |
switch (pid = fork()) {
|
|
|
27639a |
diff -up pptp-1.7.2/pptp_callmgr.c.alias pptp-1.7.2/pptp_callmgr.c
|
|
|
27639a |
--- pptp-1.7.2/pptp_callmgr.c.alias 2011-12-06 22:24:06.617318769 +0000
|
|
|
27639a |
+++ pptp-1.7.2/pptp_callmgr.c 2011-12-06 22:34:46.142647941 +0000
|
|
|
27639a |
@@ -196,14 +196,17 @@ int callmgr_main(int argc, char **argv,
|
|
|
27639a |
/* Step 5b: Handle new connection to UNIX socket */
|
|
|
27639a |
if (FD_ISSET(unix_sock, &read_set)) {
|
|
|
27639a |
/* New call! */
|
|
|
27639a |
- struct sockaddr_un from;
|
|
|
27639a |
- socklen_t len = sizeof(from);
|
|
|
27639a |
+ union {
|
|
|
27639a |
+ struct sockaddr a;
|
|
|
27639a |
+ struct sockaddr_un u;
|
|
|
27639a |
+ } from;
|
|
|
27639a |
+ socklen_t len = sizeof(from.u);
|
|
|
27639a |
PPTP_CALL * call;
|
|
|
27639a |
struct local_callinfo *lci;
|
|
|
27639a |
int s;
|
|
|
27639a |
/* Accept the socket */
|
|
|
27639a |
FD_CLR (unix_sock, &read_set);
|
|
|
27639a |
- if ((s = accept(unix_sock, (struct sockaddr *) &from, &len)) < 0) {
|
|
|
27639a |
+ if ((s = accept(unix_sock, &from.a, &len)) < 0) {
|
|
|
27639a |
warn("Socket not accepted: %s", strerror(errno));
|
|
|
27639a |
goto skip_accept;
|
|
|
27639a |
}
|
|
|
27639a |
@@ -313,11 +316,14 @@ cleanup:
|
|
|
27639a |
/*** open_inetsock ************************************************************/
|
|
|
27639a |
int open_inetsock(struct in_addr inetaddr)
|
|
|
27639a |
{
|
|
|
27639a |
- struct sockaddr_in dest, src;
|
|
|
27639a |
+ union {
|
|
|
27639a |
+ struct sockaddr a;
|
|
|
27639a |
+ struct sockaddr_in i;
|
|
|
27639a |
+ } dest, src;
|
|
|
27639a |
int s;
|
|
|
27639a |
- dest.sin_family = AF_INET;
|
|
|
27639a |
- dest.sin_port = htons(PPTP_PORT);
|
|
|
27639a |
- dest.sin_addr = inetaddr;
|
|
|
27639a |
+ dest.i.sin_family = AF_INET;
|
|
|
27639a |
+ dest.i.sin_port = htons(PPTP_PORT);
|
|
|
27639a |
+ dest.i.sin_addr = inetaddr;
|
|
|
27639a |
if ((s = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
|
|
|
27639a |
warn("socket: %s", strerror(errno));
|
|
|
27639a |
return s;
|
|
|
27639a |
@@ -332,14 +338,14 @@ int open_inetsock(struct in_addr inetadd
|
|
|
27639a |
#endif
|
|
|
27639a |
if (localbind.s_addr != INADDR_NONE) {
|
|
|
27639a |
bzero(&src, sizeof(src));
|
|
|
27639a |
- src.sin_family = AF_INET;
|
|
|
27639a |
- src.sin_addr = localbind;
|
|
|
27639a |
- if (bind(s, (struct sockaddr *) &src, sizeof(src)) != 0) {
|
|
|
27639a |
+ src.i.sin_family = AF_INET;
|
|
|
27639a |
+ src.i.sin_addr = localbind;
|
|
|
27639a |
+ if (bind(s, &src.a, sizeof(src.i)) != 0) {
|
|
|
27639a |
warn("bind: %s", strerror(errno));
|
|
|
27639a |
close(s); return -1;
|
|
|
27639a |
}
|
|
|
27639a |
}
|
|
|
27639a |
- if (connect(s, (struct sockaddr *) &dest, sizeof(dest)) < 0) {
|
|
|
27639a |
+ if (connect(s, &dest.a, sizeof(dest.i)) < 0) {
|
|
|
27639a |
warn("connect: %s", strerror(errno));
|
|
|
27639a |
close(s); return -1;
|
|
|
27639a |
}
|
|
|
27639a |
@@ -349,7 +355,10 @@ int open_inetsock(struct in_addr inetadd
|
|
|
27639a |
/*** open_unixsock ************************************************************/
|
|
|
27639a |
int open_unixsock(struct in_addr inetaddr)
|
|
|
27639a |
{
|
|
|
27639a |
- struct sockaddr_un where;
|
|
|
27639a |
+ union {
|
|
|
27639a |
+ struct sockaddr a;
|
|
|
27639a |
+ struct sockaddr_un u;
|
|
|
27639a |
+ } where;
|
|
|
27639a |
struct stat st;
|
|
|
27639a |
char *dir;
|
|
|
27639a |
int s;
|
|
|
27639a |
@@ -357,21 +366,21 @@ int open_unixsock(struct in_addr inetadd
|
|
|
27639a |
warn("socket: %s", strerror(errno));
|
|
|
27639a |
return s;
|
|
|
27639a |
}
|
|
|
27639a |
- callmgr_name_unixsock( &where, inetaddr, localbind);
|
|
|
27639a |
- if (stat(where.sun_path, &st) >= 0) {
|
|
|
27639a |
+ callmgr_name_unixsock( &where.u, inetaddr, localbind);
|
|
|
27639a |
+ if (stat(where.u.sun_path, &st) >= 0) {
|
|
|
27639a |
warn("Call manager for %s is already running.", inet_ntoa(inetaddr));
|
|
|
27639a |
close(s); return -1;
|
|
|
27639a |
}
|
|
|
27639a |
/* Make sure path is valid. */
|
|
|
27639a |
- dir = dirname(where.sun_path);
|
|
|
27639a |
+ dir = dirname(where.u.sun_path);
|
|
|
27639a |
if (!make_valid_path(dir, 0770))
|
|
|
27639a |
- fatal("Could not make path to %s: %s", where.sun_path, strerror(errno));
|
|
|
27639a |
+ fatal("Could not make path to %s: %s", where.u.sun_path, strerror(errno));
|
|
|
27639a |
free(dir);
|
|
|
27639a |
- if (bind(s, (struct sockaddr *) &where, sizeof(where)) < 0) {
|
|
|
27639a |
+ if (bind(s, &where.a, sizeof(where.u)) < 0) {
|
|
|
27639a |
warn("bind: %s", strerror(errno));
|
|
|
27639a |
close(s); return -1;
|
|
|
27639a |
}
|
|
|
27639a |
- chmod(where.sun_path, 0777);
|
|
|
27639a |
+ chmod(where.u.sun_path, 0777);
|
|
|
27639a |
listen(s, 127);
|
|
|
27639a |
return s;
|
|
|
27639a |
}
|
|
|
27639a |
diff -up pptp-1.7.2/pptp_gre.c.alias pptp-1.7.2/pptp_gre.c
|
|
|
27639a |
--- pptp-1.7.2/pptp_gre.c.alias 2011-12-06 22:24:06.627318773 +0000
|
|
|
27639a |
+++ pptp-1.7.2/pptp_gre.c 2011-12-06 22:24:06.629318775 +0000
|
|
|
27639a |
@@ -85,7 +85,10 @@ uint64_t time_now_usecs(void)
|
|
|
27639a |
/*** Open IP protocol socket **************************************************/
|
|
|
27639a |
int pptp_gre_bind(struct in_addr inetaddr)
|
|
|
27639a |
{
|
|
|
27639a |
- struct sockaddr_in src_addr, loc_addr;
|
|
|
27639a |
+ union {
|
|
|
27639a |
+ struct sockaddr a;
|
|
|
27639a |
+ struct sockaddr_in i;
|
|
|
27639a |
+ } loc_addr, src_addr;
|
|
|
27639a |
int s = socket(AF_INET, SOCK_RAW, PPTP_PROTO);
|
|
|
27639a |
if (s < 0) { warn("socket: %s", strerror(errno)); return -1; }
|
|
|
27639a |
#ifdef SO_MARK
|
|
|
27639a |
@@ -98,16 +101,16 @@ int pptp_gre_bind(struct in_addr inetadd
|
|
|
27639a |
#endif
|
|
|
27639a |
if (localbind.s_addr != INADDR_NONE) {
|
|
|
27639a |
bzero(&loc_addr, sizeof(loc_addr));
|
|
|
27639a |
- loc_addr.sin_family = AF_INET;
|
|
|
27639a |
- loc_addr.sin_addr = localbind;
|
|
|
27639a |
- if (bind(s, (struct sockaddr *) &loc_addr, sizeof(loc_addr)) != 0) {
|
|
|
27639a |
+ loc_addr.i.sin_family = AF_INET;
|
|
|
27639a |
+ loc_addr.i.sin_addr = localbind;
|
|
|
27639a |
+ if (bind(s, &loc_addr.a, sizeof(loc_addr.i)) != 0) {
|
|
|
27639a |
warn("bind: %s", strerror(errno)); close(s); return -1;
|
|
|
27639a |
}
|
|
|
27639a |
}
|
|
|
27639a |
- src_addr.sin_family = AF_INET;
|
|
|
27639a |
- src_addr.sin_addr = inetaddr;
|
|
|
27639a |
- src_addr.sin_port = 0;
|
|
|
27639a |
- if (connect(s, (struct sockaddr *) &src_addr, sizeof(src_addr)) < 0) {
|
|
|
27639a |
+ src_addr.i.sin_family = AF_INET;
|
|
|
27639a |
+ src_addr.i.sin_addr = inetaddr;
|
|
|
27639a |
+ src_addr.i.sin_port = 0;
|
|
|
27639a |
+ if (connect(s, &src_addr.a, sizeof(src_addr.i)) < 0) {
|
|
|
27639a |
warn("connect: %s", strerror(errno)); close(s); return -1;
|
|
|
27639a |
}
|
|
|
27639a |
my = test_redirections();
|