-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This compiles without errors on macOS 10.14.6 using Bazel 0.29.1 and Xcode 11.0.
- Loading branch information
0 parents
commit 550e027
Showing
32 changed files
with
14,676 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# $Id: LICENSE.wPRN,v 1.2 2004/12/06 15:17:53 ksb Exp $ | ||
|
||
This package contains fragments of code released under Copyright from | ||
Purdue Research Foundation, West Lafayette, Indiana, 47907. | ||
|
||
The original Copyright allows for derived works, so long as we don't hold | ||
them responsible, misrepresent this code as solely our work, or distribute | ||
altered versions as the original. See that Copyright notice in the file | ||
"local/lib/mkcmd/util_time.mc". | ||
|
||
The modifications I've made to this software are pervasive, no file in the | ||
package remains unaltered, as far as I know. | ||
|
||
Permission is granted to anyone to use, modify and distribute the modified | ||
software for any purpose, so long as you don't violate the original Purdue | ||
terms, or hold the authors (nor Purdue University) responsible for any | ||
consequences of the use of these modifications. | ||
|
||
To be safe you might include (in your license file) the first paragraph of | ||
this notice. I feel Purdue deserves the credit, but I'm not a lawyer. | ||
|
||
-- | ||
ksb (Kevin S Braunsdorf), ksb plus crn At spam.NPCGuild.org minus spam. |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package(default_visibility = ["//visibility:public"]) | ||
|
||
cc_binary( | ||
name = "ptbw", | ||
srcs = [ | ||
"fdrights.h", | ||
"fdwrapper.c", | ||
"machine.c", | ||
"machine.h", | ||
"ptbw.c", | ||
"ptbw.h", | ||
], | ||
copts = [ | ||
"-DLINUX", | ||
"-DHOSTOS=160400", | ||
"-D_GNU_SOURCE", | ||
"-Wno-expansion-to-defined", | ||
"-Wno-incompatible-pointer-types", | ||
], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/*@Header@*/ | ||
/*@Version $Revision: 3.4 $@*/ | ||
/* $Id: fdrights.h,v 3.4 2010/02/26 21:30:39 ksb Exp $ | ||
*/ | ||
|
||
#if !defined(FDRIGHTS_H_) | ||
#define FDRIGHTS_H_ 0xcabfab | ||
|
||
#if !defined(RIGHTS_TAG_LINE) | ||
#define RIGHTS_TAG_LINE 64 | ||
#endif | ||
|
||
extern char acRightsRecvBuf[RIGHTS_TAG_LINE]; | ||
|
||
#if 0 == HAVE_PROTO | ||
|
||
extern int RightsSendFd(), RightsRecvFd(), RightsWrap(), RopenSplit(), ropen(); | ||
#else | ||
extern int RightsSendFd(int, int *, unsigned, char *); | ||
extern int RightsRecvFd(int, int *, unsigned, char *, size_t *); | ||
extern int RopenSplit(void (*)()); | ||
extern int RightsWrap(int , char *, void *, char *); | ||
extern int ropen(char *, int , int ); | ||
#endif | ||
#endif /* ! FDRIGHTS_H_ */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
/* $Id: fdrights.c,v 3.6 2009/10/16 15:41:17 ksb Exp $ | ||
* $Compile: ${cc-cc} ${cc_debug--O} -DTEST %f -o %F | ||
* $Compile: ${cc-cc} ${cc_debug--O} -DTEST %f -o %F -lsocket | ||
* $Test: date > /tmp/test && ./%F | ||
*/ | ||
#include <sys/types.h> | ||
#include <sys/param.h> | ||
#include <sys/socket.h> | ||
#include <unistd.h> | ||
#include <sys/uio.h> | ||
#include <errno.h> | ||
#include <string.h> | ||
#include <stdlib.h> | ||
|
||
#include "fdrights.h" | ||
|
||
#if !defined(USE_STRINGS) | ||
#define USE_STRINGS (defined(bsd)) | ||
#endif | ||
|
||
#include "machine.h" | ||
char acRightsRecvBuf[RIGHTS_TAG_LINE]; | ||
|
||
/* Receive an array of descriptors through a unix domain socket (bj) | ||
* return -1 on error, 0 on success | ||
*/ | ||
int | ||
RightsRecvFd(s, piFds, iFdCount, pcText, piTextLen) | ||
int s; | ||
int *piFds; | ||
unsigned iFdCount; | ||
char *pcText; | ||
size_t *piTextLen; | ||
{ | ||
int error; | ||
struct msghdr msg; | ||
struct iovec iov; | ||
#if HAVE_SCM_RIGHTS | ||
struct cmsghdr *pcmsg; | ||
int iLen; | ||
|
||
iLen = sizeof(struct cmsghdr) + sizeof(int)*iFdCount; | ||
if ((struct cmsghdr *)0 == (pcmsg = (struct cmsghdr *) malloc(iLen))) { | ||
errno = ENOMEM; | ||
return -1; | ||
} | ||
pcmsg->cmsg_len = iLen; | ||
pcmsg->cmsg_level = SOL_SOCKET; | ||
pcmsg->cmsg_type = SCM_RIGHTS; | ||
msg.msg_control = (caddr_t) pcmsg; | ||
msg.msg_controllen = pcmsg->cmsg_len; | ||
#else | ||
msg.msg_accrights = (caddr_t) piFds; | ||
msg.msg_accrightslen = sizeof(int) * iFdCount; | ||
#endif /* HAVE_SCM_RIGHTS */ | ||
|
||
/* no name (assume socket is connected */ | ||
msg.msg_name = (char *)0; | ||
msg.msg_namelen = 0; | ||
/* some sync data data and our file descriptors */ | ||
if ((char *)0 != pcText) { | ||
iov.iov_base = pcText; | ||
iov.iov_len = (size_t *)0 == piTextLen ? 0 : *piTextLen; | ||
} else { | ||
iov.iov_base = acRightsRecvBuf; | ||
iov.iov_len = sizeof(acRightsRecvBuf); | ||
} | ||
msg.msg_iov = &iov; | ||
msg.msg_iovlen = 1; | ||
|
||
error = recvmsg(s, &msg, 0); | ||
|
||
#if HAVE_SCM_RIGHTS | ||
{ | ||
int e = errno; | ||
#if USE_STRINGS | ||
bcopy(pcmsg+1, piFds, sizeof(int)*iFdCount); | ||
#else | ||
memcpy(piFds, pcmsg+1, sizeof(int)*iFdCount); | ||
#endif | ||
free((char *) pcmsg); | ||
errno = e; | ||
} | ||
#endif /* HAVE_SCM_RIGHTS */ | ||
|
||
return error; | ||
} | ||
|
||
/* We got back not a - (fail) or + (just use the open socket) from (ksb) | ||
* a call to divConnect, so we accept access rights and use them (@). | ||
* This is the client turbo for wrapw, and you must have it to allow | ||
* all the magics wrapw provides to a wrapper. | ||
*/ | ||
int | ||
RightsWrap(int fdWrapw, char *pcCookie, void *pvData, char *pcType) | ||
{ | ||
auto int iLen, fdPriv; | ||
|
||
iLen = sizeof(acRightsRecvBuf); | ||
if (-1 == RightsRecvFd(fdWrapw, &fdPriv, 1, acRightsRecvBuf, &iLen)) { | ||
return -1; | ||
} | ||
close(fdWrapw); | ||
return fdPriv; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/*@Header@*/ | ||
/* $Id: machine.c,v 1.9 2008/09/02 18:05:36 ksb Exp $ | ||
* implementation of very machine dependent code for ptbw (ksb) | ||
* Most of this is gross. | ||
*/ | ||
#include <sys/types.h> | ||
#include <sys/socket.h> | ||
#include <sys/un.h> | ||
#include <sys/ipc.h> | ||
#include <sys/msg.h> | ||
#include <string.h> | ||
#include <stdio.h> | ||
#include <ctype.h> | ||
#include <unistd.h> | ||
#include <stdlib.h> | ||
|
||
#include "machine.h" | ||
extern char *progname; | ||
|
||
/*@Explode unsetenv@*/ | ||
/* Some older systems have setenv but not unseten (or neither) (ksb) | ||
*/ | ||
#if !defined(unsetenv) | ||
#if (defined(SUN5) && HOSTOS < 21000) || defined(HPUX11) || defined(IBMR2) || defined(AIX) | ||
int | ||
unsetenv(const char *pc) | ||
{ | ||
return setenv(pc, (char *)0, 1); | ||
} | ||
#endif | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
/* $Id: machine.h,v 1.9 2008/09/02 18:05:36 ksb Exp $ | ||
* | ||
* we don't love autoconfig as much as we should (ksb) | ||
*/ | ||
|
||
/* efficient accept logic in kernel | ||
*/ | ||
#if !defined(HAVE_ACCEPT_FILTER) | ||
#define HAVE_ACCEPT_FILTER (defined(FREEBSD)) | ||
#endif | ||
|
||
/* find name of peer process with /proc/$PID/file symblic link | ||
*/ | ||
#if !defined(HAVE_PROCFS) | ||
#define HAVE_PROCFS (defined(FREEBSD) || defined(LINUX)) | ||
#endif | ||
|
||
/* have SCM_RIGHTS | ||
*/ | ||
#if !defined(HAVE_SCM_RIGHTS) | ||
#if SUN5 | ||
#define HAVE_SCM_RIGHTS 0 | ||
#else | ||
#define HAVE_SCM_RIGHTS (defined(SCM_RIGHTS) || defined(LINUX)) | ||
#endif | ||
#endif | ||
|
||
/* sys/pipe.h, strangely only found on some *BSD systems | ||
*/ | ||
#if !defined(HAVE_SYS_PIPE_H) | ||
#define HAVE_SYS_PIPE_H (defined(FREEBSD)) | ||
#endif | ||
|
||
/* We just this, but I hate the kludge | ||
*/ | ||
#if !defined(EMU_SOCKUN_LEN) | ||
#define EMU_SOCKUN_LEN(Mpc) (strlen(Mpc)+2) | ||
#endif | ||
|
||
/* If we have arc4random we are special, really most people don't | ||
*/ | ||
#if !defined(EMU_ARC4RANDOM) | ||
#define EMU_ARC4RANDOM !(defined(FREEBSD)||defined(OPENBSD)) | ||
#endif | ||
|
||
/* I like snprintf as much as the next guy, but this is hard to | ||
* justify. I need a better emulation for it. | ||
*/ | ||
#if !defined(HAVE_SNPRINTF) | ||
#define HAVE_SNPRINTF !(defined(HPUX9)||defined(HPUX8)||defined(HPUX7)) | ||
#endif | ||
|
||
/* we still want to try to work on old-school systems, a little | ||
*/ | ||
#if defined(FREEBSD) && HOSTOS < 40000 | ||
typedef int socklen_t; | ||
#define HAVE_SIGACTION 0 | ||
#endif | ||
|
||
#if !defined(HAVE_SIGACTION) | ||
#define HAVE_SIGACTION 1 | ||
#endif | ||
|
||
/* HPUX is missing 2 sysexits | ||
*/ | ||
#if !defined(EX_CONFIG) | ||
#define EX_CONFIG 78 /* Linux, BSD, Solaris have this */ | ||
#endif | ||
#if !defined(EX_NOTFOUND) | ||
#define EX_NOTFOUND 79 /* Solaris, and others have this */ | ||
#endif |
Oops, something went wrong.