From owner-svn-soc-all@FreeBSD.ORG Wed Jul 24 18:15:35 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id 63217CE8 for ; Wed, 24 Jul 2013 18:15:35 +0000 (UTC) (envelope-from dpl@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 419422359 for ; Wed, 24 Jul 2013 18:15:35 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6OIFZpQ008018 for ; Wed, 24 Jul 2013 18:15:35 GMT (envelope-from dpl@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r6OIFZ8O007997 for svn-soc-all@FreeBSD.org; Wed, 24 Jul 2013 18:15:35 GMT (envelope-from dpl@FreeBSD.org) Date: Wed, 24 Jul 2013 18:15:35 GMT Message-Id: <201307241815.r6OIFZ8O007997@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to dpl@FreeBSD.org using -f From: dpl@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r255120 - soc2013/dpl/head/lib/libz MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 24 Jul 2013 18:15:35 -0000 Author: dpl Date: Wed Jul 24 18:15:34 2013 New Revision: 255120 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=255120 Log: We're heading towards a new design here. We will create a persistent process that will wait for commands passed from the parent, and execute the zlib functions from capability mode there. Added: soc2013/dpl/head/lib/libz/capsicum.c soc2013/dpl/head/lib/libz/capsicum.h Modified: soc2013/dpl/head/lib/libz/crc32.c soc2013/dpl/head/lib/libz/zconf.h soc2013/dpl/head/lib/libz/zutil.h Added: soc2013/dpl/head/lib/libz/capsicum.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2013/dpl/head/lib/libz/capsicum.c Wed Jul 24 18:15:34 2013 (r255120) @@ -0,0 +1,48 @@ +#include "capsicum.h" + +int childpid = 0; +int sv[2]; +int buf[1024]; + +void listenAndServe(); +void setChildSignals(); +void getCommand(); +void sendCommand(int, int *); +int startChild(); + + +int startChild() +{ + if ( socketpair(PF_LOCAL, SOCK_STREAM, 0, sv) < 0 ) + return -1; + + if( (childpid = fork()) == -1 ) { + return -1; + } else if (childpid == 0){ + close(STDIN_FILENO); + close(STDERR_FILENO); + listenAndServe(); + } + return 0; +} + +void setChildSignals() +{ + +} + +/* Wait for commands, and execute them */ +void listenAndServe() +{ + setChildSignals(); + while(true) + ; +} + +void sendCommand(int c, int *buf){ + +} + +void getCommand(){ + +} Added: soc2013/dpl/head/lib/libz/capsicum.h ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2013/dpl/head/lib/libz/capsicum.h Wed Jul 24 18:15:34 2013 (r255120) @@ -0,0 +1,15 @@ +/* + * With Capsicum, we get a compartmentalized, and securer lib. + */ +#if defined(__FreeBSD__) +# include +# if __FreeBSD_version >= 900041 +# define CAPSICUM +# include +# include +# include +# include +# include +# include +# endif +#endif Modified: soc2013/dpl/head/lib/libz/crc32.c ============================================================================== --- soc2013/dpl/head/lib/libz/crc32.c Wed Jul 24 17:55:08 2013 (r255119) +++ soc2013/dpl/head/lib/libz/crc32.c Wed Jul 24 18:15:34 2013 (r255120) @@ -37,8 +37,6 @@ # define BYFOUR #endif #ifdef BYFOUR - unsigned long crc32_ OF((unsigned long, - const unsigned char FAR *, uInt)); local unsigned long crc32_little OF((unsigned long, const unsigned char FAR *, unsigned)); local unsigned long crc32_big OF((unsigned long, @@ -208,27 +206,6 @@ const unsigned char FAR *buf; uInt len; { - long ret; - #ifdef CAPSICUM - int forkpid; - if ( (forkpid = fork()) == 0 ){ - cap_enter(); - #endif - ret = crc32_(crc, buf, len); - #ifdef CAPSICUM - return ret; - } else if ( forkpid != 0) { - wait(NULL); - } - #endif - return ret; -} - -unsigned long ZEXPORT crc32_(crc, buf, len) - unsigned long crc; - const unsigned char FAR *buf; - uInt len; -{ if (buf == Z_NULL) return 0UL; #ifdef DYNAMIC_CRC_TABLE Modified: soc2013/dpl/head/lib/libz/zconf.h ============================================================================== --- soc2013/dpl/head/lib/libz/zconf.h Wed Jul 24 17:55:08 2013 (r255119) +++ soc2013/dpl/head/lib/libz/zconf.h Wed Jul 24 18:15:34 2013 (r255120) @@ -480,24 +480,12 @@ /* * This is hard-configured for FreeBSD. */ +#include "capsicum.h" #define z_off_t off_t #ifndef _FILE_OFFSET_BITS #define _FILE_OFFSET_BITS 64 #endif -/* - * With Capsicum, we get a compartmentalized, and securer lib. - */ -#if defined(__FreeBSD__) -# include -# if __FreeBSD_version >= 900041 -# define CAPSICUM -# include -# include -# include -# include -# endif -#endif #ifndef z_off_t # define z_off_t long Modified: soc2013/dpl/head/lib/libz/zutil.h ============================================================================== --- soc2013/dpl/head/lib/libz/zutil.h Wed Jul 24 17:55:08 2013 (r255119) +++ soc2013/dpl/head/lib/libz/zutil.h Wed Jul 24 18:15:34 2013 (r255120) @@ -167,19 +167,6 @@ #pragma warn -8066 #endif -/* - * With Capsicum, we get a compartmentalized, and securer lib. - */ -#if defined(__FreeBSD__) -# include -# if __FreeBSD_version >= 900041 -# define CAPSICUM -# include -# include -# include -# include -# endif -#endif /* provide prototypes for these when building zlib without LFS */ #if !defined(_WIN32) && \