Date: Sun, 23 Jun 2013 12:53:53 GMT From: dpl@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r253376 - soc2013/dpl/head/contrib/bzip2 Message-ID: <201306231253.r5NCrroI013605@socsvn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: dpl Date: Sun Jun 23 12:53:53 2013 New Revision: 253376 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=253376 Log: Declare structs needed to pass fds only if needed. (Not compiliing and don't know why, investigating) Modified: soc2013/dpl/head/contrib/bzip2/bzip2.c Modified: soc2013/dpl/head/contrib/bzip2/bzip2.c ============================================================================== --- soc2013/dpl/head/contrib/bzip2/bzip2.c Sun Jun 23 10:51:26 2013 (r253375) +++ soc2013/dpl/head/contrib/bzip2/bzip2.c Sun Jun 23 12:53:53 2013 (r253376) @@ -91,7 +91,7 @@ # ifdef __FreeBSD__ # include <osreldate.h> # if __FreeBSD_version >= 900041 -# define CAPSICUM +# define CAPSICUM 1 # include <sys/capability.h> # include <sys/socket.h> # include <sys/wait.h> @@ -221,17 +221,28 @@ FILE *outputHandleJustInCase; Int32 workFactor; -#ifdef CAPSICUM +#if CAPSICUM int sv[2], len; +char buf[1]; +char cms[CMSG_SPACE(sizeof(int))]; +struct iovec iov; struct cmsghdr *cmsg; +struct msghdr msg; +buf[0] = 0; +iov.iov_base = buf; +iov.iov_len = 1; + +cmsg->cmsg_len = CMSG_LEN(sizeof (int)); cmsg->cmsg_level = SOL_SOCKET; cmsg->cmsg_type = SOL_RIGHTS; -struct msghdr msg; + msg.msg_name = NULL; -msg.msg_namelen = 0; -msg.msg_iov = NULL; -msg.msg_iovlen = 0; +msg.,msg_namelen = 0; +msg.msg_iov = &iov; +msg.msg_iovlen = 1; +/* msg.msg_control = (caddr_t)cms; */ +/* msg.msg_controllen = CMSG_LEN(sizeof(int)); */ #endif static void panic ( const Char* ) NORETURN; @@ -987,7 +998,7 @@ FILE* fp; IntNative fh; fh = open(name, O_WRONLY|O_CREAT|O_EXCL, S_IWUSR|S_IRUSR); -# ifdef CAPSICUM +# if CAPSICUM cap_rights_limit(fh, CAP_WRITE); # endif if (fh == -1) return NULL; @@ -1162,7 +1173,7 @@ FILE *inStr; FILE *outStr; Int32 n, i; -# ifdef CAPSICUM +# if CAPSICUM Int32 infd; pid_t forkpid; # endif @@ -1254,7 +1265,7 @@ } if ( srcMode != SM_I2O ){ -# ifdef CAPSICUM +# if CAPSICUM infd = open( inName, O_RDONLY ); cap_rights_limit(infd, CAP_READ); inStr = fdopen ( infd, "rb" ); @@ -1328,7 +1339,7 @@ fflush ( stderr ); } -# ifdef CAPSICUM +# if CAPSICUM /* Pass the limited file descriptors with a unix domain socket. */ switch( forkpid = rfork(RFPROC | RFCFDG) ) { case ( 0 ): @@ -1358,7 +1369,7 @@ deleteOutputOnInterrupt = False; -# ifdef CAPSICUM +# if CAPSICUM break; case ( -1 ): @@ -1367,7 +1378,7 @@ default: /* Send the two FDs */ - sendmsg(); + /* sendmsg(); */ wait(NULL); return; } @@ -1383,7 +1394,7 @@ FILE *inStr; FILE *outStr; Int32 n, i; -# ifdef CAPSICUM +# if CAPSICUM Int32 infd; pid_t forkpid; # endif @@ -1480,7 +1491,7 @@ } if ( srcMode != SM_I2O ){ -# ifdef CAPSICUM +# if CAPSICUM infd = open( inName, O_RDONLY ); cap_rights_limit(infd, CAP_READ); inStr = fdopen ( infd, "rb" ); @@ -2035,7 +2046,7 @@ # endif } -# ifdef CAPSICUM +# if CAPSICUM if ( socketpair(PF_LOCAL, SOCK_STREAM, 0, sv) == -1 ){ fprintf ( stderr, "%s: Can't create socket: %s.\n", progName, strerror(errno) );
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201306231253.r5NCrroI013605>