socsvn commit: r257242 - in soc2013/dpl/head/lib/libzcap: . test zlibworker
dpl at FreeBSD.org
dpl at FreeBSD.org
Thu Sep 12 19:56:36 UTC 2013
Author: dpl
Date: Thu Sep 12 19:56:36 2013
New Revision: 257242
URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=257242
Log:
Changed the open() arguments.
Modified:
soc2013/dpl/head/lib/libzcap/capsicum.c
soc2013/dpl/head/lib/libzcap/commands.c
soc2013/dpl/head/lib/libzcap/gzlib.c
soc2013/dpl/head/lib/libzcap/test/testlib.sh
soc2013/dpl/head/lib/libzcap/zlibworker/commands.c
Modified: soc2013/dpl/head/lib/libzcap/capsicum.c
==============================================================================
--- soc2013/dpl/head/lib/libzcap/capsicum.c Thu Sep 12 18:08:25 2013 (r257241)
+++ soc2013/dpl/head/lib/libzcap/capsicum.c Thu Sep 12 19:56:36 2013 (r257242)
@@ -111,6 +111,8 @@
{
struct sandbox *sandbox;
+ if (DEBUG_ZCAP)
+ printf("DEBUG: findSandbox(%p)\n", ptr);
if (ptr == NULL)
return (SLIST_FIRST(&sandboxes));
@@ -119,7 +121,7 @@
return (sandbox);
/* Not found */
- return (NULL);
+ errx(1, "findSandbox: Couldn't find sandbox");
}
struct sandbox *
@@ -176,7 +178,7 @@
newsandbox->socket = sv[1];
if (DEBUG_ZCAP) {
printf("DEBUG: We have started a new sandbox.\n");
- printf("\tpd: %d, socket: %d\n", newsandbox->pd, newsandbox->socket);
+ printf("\tdata: %p pd: %d, socket: %d\n", data, newsandbox->pd, newsandbox->socket);
}
}
return (newsandbox);
@@ -202,8 +204,14 @@
box = findSandbox(ptr);
+ if (DEBUG_ZCAP)
+ printf("DEBUG: zcaplib: Entered sendCommand(%p, %p): box: %p\n", nvl, ptr, box);
+ if (DEBUG_ZCAP)
+ printf("DEBUG: zcaplib: About to send command\n");
if( nvlist_send(box->socket, nvl) != 0 )
err(1, "zcaplib: nvlist_send Error");
+ if (DEBUG_ZCAP)
+ printf("DEBUG: zcaplib: Awaiting command\n");
if ((new = nvlist_recv(box->socket)) == NULL)
err(1, "nvlist_recv(): nvlist_t is NULL");
return (new);
Modified: soc2013/dpl/head/lib/libzcap/commands.c
==============================================================================
--- soc2013/dpl/head/lib/libzcap/commands.c Thu Sep 12 18:08:25 2013 (r257241)
+++ soc2013/dpl/head/lib/libzcap/commands.c Thu Sep 12 19:56:36 2013 (r257242)
@@ -784,6 +784,9 @@
gzFile file;
const void *ptr;
+ if ((file = malloc(gzfilesize)) == NULL)
+ err(1, "malloc");
+
initNvl();
startSandbox(file);
@@ -794,8 +797,7 @@
result = sendCommand(nvl, file);
- if ((file = malloc(gzfilesize)) == NULL)
- err(1, "malloc");
+ ptr = nvlist_get_binary(result, "result", gzfilesize);
memcpy(file, ptr, gzfilesize);
destroy();
return(file);
Modified: soc2013/dpl/head/lib/libzcap/gzlib.c
==============================================================================
--- soc2013/dpl/head/lib/libzcap/gzlib.c Thu Sep 12 18:08:25 2013 (r257241)
+++ soc2013/dpl/head/lib/libzcap/gzlib.c Thu Sep 12 19:56:36 2013 (r257242)
@@ -8,22 +8,13 @@
#include <sys/capability.h>
#include <err.h>
+#include <sys/stat.h>
#include "gzguts.h"
#include "zutil.h"
#include "commands.h"
#include "zconf.h"
-#if defined(_WIN32) && !defined(__BORLANDC__)
-# define LSEEK _lseeki64
-#else
-#if defined(_LARGEFILE64_SOURCE) && _LFS64_LARGEFILE-0
-# define LSEEK lseek64
-#else
-# define LSEEK lseek
-#endif
-#endif
-
/* -- see zlib.h -- */
gzFile ZEXPORT gzopen(path, mode)
const char *path;
@@ -31,12 +22,13 @@
{
int oflag = 0;
int fd;
- char *loopmode;
+ const char *loopmode;
cap_rights_t rights;
+ mode_t mode2;
- strncpy(loopmode, mode, strlen(mode)+1);
+ loopmode = mode;
while(*loopmode) {
- switch (*mode){
+ switch (*loopmode){
#ifndef NO_GZCOMPRESS
case('w'):
oflag |= O_WRONLY|O_CREAT|O_TRUNC;
@@ -68,9 +60,11 @@
++loopmode;
}
- if ((fd = open(path, oflag)) < 0)
+ mode2 = S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH;
+ if ((fd = open(path, oflag, mode2)) < 0)
err(1, "zcaplib: Couldn't create gzip file");
+ //limitgzip(fd, mode);
cap_rights_init(&rights, CAP_READ, CAP_SEEK, CAP_WRITE, CAP_FSTAT, CAP_FCNTL);
if (cap_rights_limit(fd, &rights) < 0)
err(1, "zcaplib: Couldn't limit fd: %d", fd);
@@ -104,7 +98,6 @@
gzFile file;
unsigned size;
{
- fprintf(stderr, "Inside gzbuffer, calling zcapcmd_gzbuffer()");
return zcapcmd_gzbuffer(file, size);
}
@@ -198,23 +191,3 @@
{
zcapcmd_simplecommand(file, ZCAPCMD_GZCLEARERR);
}
-
-
-#ifndef INT_MAX
-/* portably return maximum value for an int (when limits.h presumed not
- available) -- we need to do this to cover cases where 2's complement not
- used, since C standard permits 1's complement and sign-bit representations,
- otherwise we could just use ((unsigned)-1) >> 1 */
-unsigned ZLIB_INTERNAL gz_intmax()
-{
- unsigned p, q;
-
- p = 1;
- do {
- q = p;
- p <<= 1;
- p++;
- } while (p > q);
- return q >> 1;
-}
-#endif
Modified: soc2013/dpl/head/lib/libzcap/test/testlib.sh
==============================================================================
--- soc2013/dpl/head/lib/libzcap/test/testlib.sh Thu Sep 12 18:08:25 2013 (r257241)
+++ soc2013/dpl/head/lib/libzcap/test/testlib.sh Thu Sep 12 19:56:36 2013 (r257242)
@@ -1,11 +1,12 @@
#!/bin/sh
-cd /usr/home/athos/gsoc/head/lib/libzcap/
-sudo make clean all install
-cd /usr/home/athos/gsoc/head/lib/libzcap/test
+cd ..
+make clean all
+sudo make install
+
+echo; echo
+cd test
cc -o zcaplibtest -g -Wall -fno-color-diagnostics -lnv -lzcap zcaplibtest.c
echo; echo
-echo 'Done compiling library and tester.'
-echo
-sudo ktrace -i ./zcaplibtest
+ktrace -i ./zcaplibtest
Modified: soc2013/dpl/head/lib/libzcap/zlibworker/commands.c
==============================================================================
--- soc2013/dpl/head/lib/libzcap/zlibworker/commands.c Thu Sep 12 18:08:25 2013 (r257241)
+++ soc2013/dpl/head/lib/libzcap/zlibworker/commands.c Thu Sep 12 19:56:36 2013 (r257242)
@@ -79,7 +79,7 @@
z_streamp zstrmtemp;
/* We save the z_stream into memory. */
if ((stream = malloc(zstreamsize)) == NULL)
- err(1, "deflateInit: Can't allocate memory");
+ err(1, "inflateInit: Can't allocate memory");
zstrmtemp = (z_streamp)nvlist_get_binary(args, "strm", &zstreamsize);
memcpy(stream, zstrmtemp , zstreamsize);
@@ -109,7 +109,7 @@
z_streamp zstrmtemp;
/* We save the z_stream into memory. */
if ((stream = malloc(zstreamsize)) == NULL)
- err(1, "deflateInit: Can't allocate memory");
+ err(1, "inflateEnd: Can't allocate memory");
zstrmtemp = (z_streamp)nvlist_get_binary(args, "strm", &zstreamsize);
memcpy(stream, zstrmtemp , zstreamsize);
@@ -262,11 +262,14 @@
zcapcmd_gzbuffer(nvlist_t *args, nvlist_t *result)
{
int ret = -1;
+ gzFile file;
+ unsigned size;
- ret = gzbuffer(
- (gzFile)nvlist_get_binary(args, "file", &gzsize),
- nvlist_get_number(args, "size")
- );
+ fprintf(stderr, "zlibworker: zcapcmd_gzbuffer(): Starts\n");
+ file = (gzFile)nvlist_get_binary(args, "file", &gzsize);
+ size = nvlist_get_number(args, "size");
+
+ ret = gzbuffer(file, size);
nvlist_add_number(result, "result", ret);
}
More information about the svn-soc-all
mailing list