Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 25 Jun 2013 06:34:43 GMT
From:      dpl@FreeBSD.org
To:        svn-soc-all@FreeBSD.org
Subject:   socsvn commit: r253479 - soc2013/dpl/head/contrib/bzip2
Message-ID:  <201306250634.r5P6YhSB082971@socsvn.freebsd.org>

next in thread | raw e-mail | index | archive | help
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);



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