Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 24 Jul 2013 18:15:35 GMT
From:      dpl@FreeBSD.org
To:        svn-soc-all@FreeBSD.org
Subject:   socsvn commit: r255120 - soc2013/dpl/head/lib/libz
Message-ID:  <201307241815.r6OIFZ8O007997@socsvn.freebsd.org>

next in thread | raw e-mail | index | archive | help
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 <osreldate.h>
+#	if __FreeBSD_version >= 900041
+#		define CAPSICUM
+#		include <sys/capability.h>
+#		include <unistd.h>
+#		include <sys/types.h>
+#		include <sys/wait.h>
+#		include <sys/socket.h>
+#		include <sys/select.h>
+#	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 <osreldate.h>
-#  if __FreeBSD_version >= 900041
-#    define CAPSICUM
-#    include <sys/capability.h>
-#    include <unistd.h>
-#    include <sys/types.h>
-#    include <sys/wait.h>
-#  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 <osreldate.h>
-#    if __FreeBSD_version >= 900041
-#        define CAPSICUM
-#        include <sys/capability.h>
-#        include <unistd.h>
-#        include <sys/types.h>
-#        include <sys/wait.h>
-#    endif
-#endif
 
 /* provide prototypes for these when building zlib without LFS */
 #if !defined(_WIN32) && \



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201307241815.r6OIFZ8O007997>