From owner-svn-soc-all@FreeBSD.ORG Tue Jun 25 06:34:44 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]) by hub.freebsd.org (Postfix) with ESMTP id 0D1492A9 for ; Tue, 25 Jun 2013 06:34:44 +0000 (UTC) (envelope-from dpl@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) by mx1.freebsd.org (Postfix) with ESMTP id D9F79166F for ; Tue, 25 Jun 2013 06:34:43 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r5P6YhNv082977 for ; Tue, 25 Jun 2013 06:34:43 GMT (envelope-from dpl@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r5P6YhSB082971 for svn-soc-all@FreeBSD.org; Tue, 25 Jun 2013 06:34:43 GMT (envelope-from dpl@FreeBSD.org) Date: Tue, 25 Jun 2013 06:34:43 GMT Message-Id: <201306250634.r5P6YhSB082971@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: r253479 - soc2013/dpl/head/contrib/bzip2 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: Tue, 25 Jun 2013 06:34:44 -0000 Author: dpl Date: Tue Jun 25 06:34:43 2013 New Revision: 253479 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=253479 Log: Added error checking. Getting weird fd from socket. Modified: soc2013/dpl/head/contrib/bzip2/bzip2.c Modified: soc2013/dpl/head/contrib/bzip2/bzip2.c ============================================================================== --- soc2013/dpl/head/contrib/bzip2/bzip2.c Tue Jun 25 05:05:10 2013 (r253478) +++ soc2013/dpl/head/contrib/bzip2/bzip2.c Tue Jun 25 06:34:43 2013 (r253479) @@ -1365,23 +1365,40 @@ pad ( inName ); fflush ( stderr ); } + printf("About to fork!\n"); # if CAPSICUM /* Pass the limited file descriptors with a unix domain socket. */ - switch( forkpid = rfork(RFPROC | RFCFDG) ) { + switch( forkpid = fork() ) { case ( 0 ): - if (fd == recvfd(sv[1]) <= 0){ - fprintf ( stderr, "%s: Couldn't enter capability mode: %s.\n", + printf("Child\n"); + if(fclose(inStr) < 0){ + fprintf ( stderr, "%s: Couldn't close inStr: %s.\n", progName, strerror(errno) ); - exit(1); + setExit(1); + exit(exitValue); + } + if(fclose(outStr) < 0){ + fprintf ( stderr, "%s: Couldn't close outStr: %s.\n", + progName, strerror(errno) ); + setExit(1); + exit(exitValue); + } + printf("closed fds\n"); + if (fd == recvfd(sv[1]) <= 0){ + fprintf ( stderr, "%s: Couldn't get inStr(%d) fd: %s.\n", + progName, fd, strerror(errno) ); + setExit(1); + exit(exitValue); } printf("inStr fd receiverd: %d\n",fd); inStr = fdopen(fd, "rb"); if (fd == recvfd(sv[1]) <= 0){ - fprintf ( stderr, "%s: Couldn't enter capability mode: %s.\n", - progName, strerror(errno) ); - exit(1); + fprintf ( stderr, "%s: Couldn't get outStr(%d) fd: %s.\n", + progName, fd, strerror(errno) ); + setExit(1); + exit(exitValue); } outStr = fdopen(fd, "wb"); printf("outStr fd receiverd: %d\n",fd); @@ -1389,7 +1406,8 @@ if (cap_enter() < 0) { fprintf ( stderr, "%s: Couldn't enter capability mode: %s.\n", progName, strerror(errno) ); - exit(1); + setExit(1); + exit(exitValue); } # endif @@ -1416,9 +1434,12 @@ case ( -1 ): fprintf ( stderr, "%s: Couldn't fork: %s.\n", progName, strerror(errno) ); - exit(1); + setExit(1); + exit(exitValue); default: + printf("Parent.\n"); + printf("Waiting for son.\n"); fd = fileno(inStr); cap_rights_limit(fd, CAP_READ); sendfd(sv[0], fd);