From p@i609.hadiko.de Wed Sep 22 12:09:03 1999
Return-Path: <p@i609.hadiko.de>
Received: from mailgate.rz.uni-karlsruhe.de (nz40.rz.uni-karlsruhe.de [129.13.197.4])
	by hub.freebsd.org (Postfix) with ESMTP id 2D9751580D
	for <FreeBSD-gnats-submit@freebsd.org>; Wed, 22 Sep 1999 12:08:55 -0700 (PDT)
	(envelope-from p@i609.hadiko.de)
Received: from nce2.hadiko.de (hadince2.hadiko.uni-karlsruhe.de [172.20.32.2])
	by mailgate.rz.uni-karlsruhe.de with esmtp (Exim 3.02 #2)
	id 11Trl4-0007a2-00; Wed, 22 Sep 1999 21:08:50 +0200
Received: from i609.hadiko.de (hadii609.hadiko.uni-karlsruhe.de [172.20.44.159])
	by nce2.hadiko.de (8.9.0/8.9.0) with ESMTP id VAA26508
	for <FreeBSD-gnats-submit@freebsd.org>; Wed, 22 Sep 1999 21:08:47 +0200 (MET DST)
Received: (from p@localhost)
	by i609.hadiko.de (8.9.3/8.9.3) id VAA29442;
	Wed, 22 Sep 1999 21:08:47 +0200 (CEST)
	(envelope-from p)
Message-Id: <199909221908.VAA29442@i609.hadiko.de>
Date: Wed, 22 Sep 1999 21:08:47 +0200 (CEST)
From: un1i@rz.uni-karlsruhe.de
Sender: p@i609.hadiko.de
Reply-To: un1i@rz.uni-karlsruhe.de
To: FreeBSD-gnats-submit@freebsd.org
Subject: [PATCH] sysinstall can get SIGPIPE if a distr. file is broken
X-Send-Pr-Version: 3.2

>Number:         13900
>Category:       conf
>Synopsis:       [PATCH] sysinstall can get SIGPIPE if a distr. file is broken
>Confidential:   no
>Severity:       serious
>Priority:       low
>Responsible:    jkh
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Wed Sep 22 12:10:00 PDT 1999
>Closed-Date:    Mon Jan 3 20:28:56 PST 2000
>Last-Modified:  Mon Jan  3 20:31:43 PST 2000
>Originator:     Philipp Mergenthaler
>Release:        FreeBSD 4.0-CURRENT i386
>Organization:
University of Karlsruhe
>Environment:

	$FreeBSD: src/release/sysinstall/main.c,v 1.54 1999/08/28 01:34:16 peter  Exp $

>Description:

	Under certain circumstances (e.g., when fetching files in FTP ASCII mode
	from a server that does LF->CRLF substitution), distribution files can
	be damaged in such a way that gunzip or cpio stops. Sysinstall tries to
    write more data to it and therefore gets a SIGPIPE.

>How-To-Repeat:

/tmp%mkdir compat20 ; cd compat20
/tmp/compat20%fetch ftp://ftp2.de.freebsd.org/pub/FreeBSD/releases/i386/3.3-RELEASE/compat20/compat20.aa
/tmp/compat20%fetch ftp://ftp2.de.freebsd.org/pub/FreeBSD/releases/i386/3.3-RELEASE/compat20/compat20.ab
/tmp/compat20%fetch ftp://ftp2.de.freebsd.org/pub/FreeBSD/releases/i386/3.3-RELEASE/compat20/compat20.inf
/tmp/compat20%fetch ftp://ftp2.de.freebsd.org/pub/FreeBSD/releases/i386/3.3-RELEASE/compat20/compat20.mtree
/tmp/compat20%mv compat20.aa x
/tmp/compat20%sed -e 's/.*/&^M/' < x > compat20.aa   # simulate damage

Now use sysinstall to install this distribution from filesystem.


>Fix:

	I don't think it's necessary to handle this case differently from others
	that are already handled, so ignoring the signal is enough.
	But a hint for the user might be helpful (in dist.c and media.c).

/usr/src/release#diff -ru sysinstall sysinstall.new 
diff -ru sysinstall/dist.c sysinstall.new/dist.c
--- sysinstall/dist.c   Mon Sep 20 10:55:35 1999
+++ sysinstall.new/dist.c       Wed Sep 22 20:47:26 1999
@@ -717,7 +717,7 @@
                if (retval != n) {
                    fclose(fp);
                    dialog_clear_norefresh();
-                   msgConfirm("Write failure on transfer! (wrote %d bytes of %d bytes)", retval, n);
+                   msgConfirm("Write failure on transfer! (wrote %d bytes of %d bytes)\nMaybe one of the distribution files got damaged during transfer.", retval, n);
                    goto punt;
                }
            }
diff -ru sysinstall/main.c sysinstall.new/main.c
--- sysinstall/main.c   Wed Sep  1 20:16:39 1999
+++ sysinstall.new/main.c       Wed Sep 22 20:34:01 1999
@@ -56,6 +56,7 @@
        signal(SIGBUS, screech);
        signal(SIGSEGV, screech);
     }
+    signal(SIGPIPE, SIG_IGN);
 
     /* We don't work too well when running as non-root anymore */
     if (geteuid() != 0) {
Only in sysinstall.new: main.c.orig
diff -ru sysinstall/media.c sysinstall.new/media.c
--- sysinstall/media.c  Thu Sep  2 14:13:06 1999
+++ sysinstall.new/media.c      Wed Sep 22 20:47:09 1999
@@ -686,7 +686,7 @@
            break;
        }
        if (write(qfd[1], buf, i) != i) {
-           msgConfirm("Write error on transfer to cpio process, try of %d bytes.", i);
+           msgConfirm("Write error on transfer to cpio process, try of %d bytes.\nMaybe one of the distribution files got damaged during transfer.", i);
            break;
        }
        else {

>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->jkh 
Responsible-Changed-By: sheldonh 
Responsible-Changed-When: Wed Sep 22 12:32:08 PDT 1999 
Responsible-Changed-Why:  
's see what Jordan has to say about this. :-) 
State-Changed-From-To: open->closed 
State-Changed-By: jkh 
State-Changed-When: Mon Jan 3 20:28:56 PST 2000 
State-Changed-Why:  
Agreed, fix adopted, thanks. 
>Unformatted:
