From fuyuki@hadaly.dyndns.org  Mon Sep  2 22:47:36 2002
Return-Path: <fuyuki@hadaly.dyndns.org>
Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id 8164437B400
	for <FreeBSD-gnats-submit@freebsd.org>; Mon,  2 Sep 2002 22:47:36 -0700 (PDT)
Received: from t-mta1.odn.ne.jp (mfep1.odn.ne.jp [143.90.131.179])
	by mx1.FreeBSD.org (Postfix) with ESMTP id A3AAF43E65
	for <FreeBSD-gnats-submit@freebsd.org>; Mon,  2 Sep 2002 22:47:35 -0700 (PDT)
	(envelope-from fuyuki@hadaly.dyndns.org)
Received: from hadaly.dyndns.org ([218.46.6.95]) by t-mta1.odn.ne.jp
          with ESMTP
          id <20020903054734567.IXMK.1658.t-mta1.odn.ne.jp@mta1.odn.ne.jp>;
          Tue, 3 Sep 2002 14:47:34 +0900
Received: by hadaly.dyndns.org (Postfix, from userid 1001)
	id 24DAC5693; Tue,  3 Sep 2002 14:47:33 +0900 (JST)
Message-Id: <20020903054733.24DAC5693@hadaly.dyndns.org>
Date: Tue,  3 Sep 2002 14:47:33 +0900 (JST)
From: Kimura Fuyuki <fuyuki@hadaly.org>
To: FreeBSD-gnats-submit@freebsd.org
Subject: uudecode -o doesn't work if piped
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         42356
>Category:       bin
>Synopsis:       uudecode -o doesn't work if piped
>Confidential:   no
>Severity:       serious
>Priority:       low
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Mon Sep 02 22:50:01 PDT 2002
>Closed-Date:    Tue Aug 24 09:21:03 GMT 2004
>Last-Modified:  Tue Aug 24 09:21:03 GMT 2004
>Originator:     Kimura Fuyuki
>Release:        FreeBSD 4.6.2-RELEASE i386
>Organization:
>Environment:
System: FreeBSD hadaly.dyndns.org 4.6.2-RELEASE FreeBSD 4.6.2-RELEASE #17: Wed Aug 14 17:19:17 JST 2002 root@hadaly.dyndns.org:/sack/tmp/obj/pub/src/sys/NS i386


	
>Description:
uudecode -o doesn't work if the output is piped to other programs.
	
>How-To-Repeat:
 $ uudecode -o /tmp/a.tgz </tmp/a.uue
 $ tar tvzf /tmp/a.tgz
 drwxr-xr-x user/user         0 Nov 13 13:10 2001 dir/
 -rw-r--r-- user/user         3 Nov 13 13:10 2001 dir/file
 drwxr-xr-x user/user         0 Nov 13 13:10 2001 dir/RCS/
 -r--r--r-- user/user       307 Nov 13 13:10 2001 dir/RCS/file,v
 $ uudecode -o /dev/stdout </tmp/a.uue | tar xvzf -
 uudecode: /dev/stdout: stdin: Invalid argument
 
 gzip: stdin: unexpected end of file
 tar: child returned status 1
	
>Fix:
This patch could be a solution, but doesn't solve the below though I
don't think it's useful.

$ uudecode -o /tmp/a.tgz </tmp/*.uue | tar xvzf -

Index: uudecode.c
===================================================================
RCS file: /home/ncvs/src/usr.bin/uudecode/uudecode.c,v
retrieving revision 1.27
diff -u -r1.27 uudecode.c
--- uudecode.c	19 May 2002 11:22:52 -0000	1.27
+++ uudecode.c	3 Sep 2002 05:25:08 -0000
@@ -96,6 +96,8 @@
 			oflag = 1; /* output to the specified file */
 			sflag = 1; /* do not strip pathnames for output */
 			outfile = optarg; /* set the output filename */
+			if (strcmp(outfile, "/dev/stdout") == 0)
+				pflag = 1;
 			break;
 		case 'p':
 			if (oflag)

By the way, I don't understand the mean of the following lines. Are they
necessary? If they can be zapped, it could be a better solution.

		} else if (!freopen(buf, "w", stdout) ||
		    fchmod(fileno(stdout), getmode(mode_handle, 0) & 0666)) {
			warn("%s: %s", buf, filename);
			return(1);
		}

>Release-Note:
>Audit-Trail:

From: Juli Mallett <jmallett@FreeBSD.org>
To: Kimura Fuyuki <fuyuki@hadaly.org>
Cc: FreeBSD-gnats-submit@FreeBSD.org
Subject: Re: bin/42356: uudecode -o doesn't work if piped
Date: Mon, 2 Sep 2002 23:10:48 -0700

 * De: Kimura Fuyuki <fuyuki@hadaly.org> [ Data: 2002-09-02 ]
 	[ Subjecte: bin/42356: uudecode -o doesn't work if piped ]
 > By the way, I don't understand the mean of the following lines. Are they
 > necessary? If they can be zapped, it could be a better solution.
 > 
 > 		} else if (!freopen(buf, "w", stdout) ||
 > 		    fchmod(fileno(stdout), getmode(mode_handle, 0) & 0666)) {
 > 			warn("%s: %s", buf, filename);
 > 			return(1);
 > 		}
 
 This is to set the mode within the acceptable bitmask of modes, of the
 file being created.
 
 juli.
 -- 
 Juli Mallett <jmallett@FreeBSD.org>       | FreeBSD: The Power To Serve
 Will break world for fulltime employment. | finger jmallett@FreeBSD.org

From: Kimura Fuyuki <fuyuki@hadaly.org>
To: jmallett@FreeBSD.ORG
Cc: FreeBSD-gnats-submit@FreeBSD.ORG
Subject: Re: bin/42356: uudecode -o doesn't work if piped
Date: Tue, 03 Sep 2002 17:28:40 +0900

 > > 		} else if (!freopen(buf, "w", stdout) ||
 > > 		    fchmod(fileno(stdout), getmode(mode_handle, 0) & 0666)) {
 > > 			warn("%s: %s", buf, filename);
 > > 			return(1);
 > > 		}
 
 > This is to set the mode within the acceptable bitmask of modes, of the
 > file being created.
 
 I understand. I must have been half-asleep. :(
 
 -- fuyuki
 

From: Tony Finch <dot@dotat.at>
To: fuyuki@hadaly.org
Cc: FreeBSD-gnats-submit@FreeBSD.org
Subject: Re: bin/42356: uudecode -o doesn't work if piped
Date: Tue, 03 Sep 2002 10:55:51 +0100

 Kimura Fuyuki <fuyuki@hadaly.org> wrote:
 >	
 >uudecode -o doesn't work if the output is piped to other programs.
 >	
 >>How-To-Repeat:
 > $ uudecode -o /tmp/a.tgz </tmp/a.uue
 > $ tar tvzf /tmp/a.tgz
 > drwxr-xr-x user/user         0 Nov 13 13:10 2001 dir/
 > -rw-r--r-- user/user         3 Nov 13 13:10 2001 dir/file
 > drwxr-xr-x user/user         0 Nov 13 13:10 2001 dir/RCS/
 > -r--r--r-- user/user       307 Nov 13 13:10 2001 dir/RCS/file,v
 > $ uudecode -o /dev/stdout </tmp/a.uue | tar xvzf -
 > uudecode: /dev/stdout: stdin: Invalid argument
 > 
 > gzip: stdin: unexpected end of file
 > tar: child returned status 1
 
 I think this is a documentation bug, rather than a bug in uudecode itself.
 The manual page should suggest the -p option rather than -o /dev/stdout.
 (or perhaps failure to chmod should not be fatal)
 
 Would fixing the manual page satisfy you?
 
 Tony.
 -- 
 f.a.n.finch <dot@dotat.at> http://dotat.at/
 BISCAY SOUTHEAST FITZROY: EAST OR NORTHEAST 4 OR 5 BACKING MAINLY NORTHWEST 3
 OR 4. MAINLY FAIR. GOOD.
State-Changed-From-To: open->feedback 
State-Changed-By: fanf 
State-Changed-When: Tue Sep 3 03:19:03 PDT 2002 
State-Changed-Why:  
Is the submitter happy with a manpage fix instead? 

http://www.freebsd.org/cgi/query-pr.cgi?pr=42356 

From: Kimura Fuyuki <fuyuki@hadaly.org>
To: dot@dotat.at
Cc: FreeBSD-gnats-submit@FreeBSD.org
Subject: Re: bin/42356: uudecode -o doesn't work if piped
Date: Tue, 03 Sep 2002 21:42:43 +0900

 At Tue, 03 Sep 2002 10:55:51 +0100,
 Tony Finch <dot@dotat.at> wrote:
 > 
 > Kimura Fuyuki <fuyuki@hadaly.org> wrote:
 > >	
 > >uudecode -o doesn't work if the output is piped to other programs.
 > >	
 > >>How-To-Repeat:
 > > $ uudecode -o /tmp/a.tgz </tmp/a.uue
 > > $ tar tvzf /tmp/a.tgz
 > > drwxr-xr-x user/user         0 Nov 13 13:10 2001 dir/
 > > -rw-r--r-- user/user         3 Nov 13 13:10 2001 dir/file
 > > drwxr-xr-x user/user         0 Nov 13 13:10 2001 dir/RCS/
 > > -r--r--r-- user/user       307 Nov 13 13:10 2001 dir/RCS/file,v
 > > $ uudecode -o /dev/stdout </tmp/a.uue | tar xvzf -
 > > uudecode: /dev/stdout: stdin: Invalid argument
 > > 
 > > gzip: stdin: unexpected end of file
 > > tar: child returned status 1
 > 
 > I think this is a documentation bug, rather than a bug in uudecode itself.
 > The manual page should suggest the -p option rather than -o /dev/stdout.
 > (or perhaps failure to chmod should not be fatal)
 > 
 > Would fixing the manual page satisfy you?
 
 It would make standards@ people unhappy. Commit log says as follows:
 
 ----------------------------
 revision 1.18
 date: 2002/02/16 09:18:33;  author: mike;  state: Exp;  lines: +0 -1
 Un-deprecate the -p option.  We now have two ways to output to stdout:
 `-o /dev/stdout' or `-p'.
 
 Requested by:	grog, nectar
 ----------------------------
 revision 1.17
 date: 2002/01/27 18:21:23;  author: mike;  state: Exp;  lines: +26 -3
 Add -o option (POSIX.1-2001) to uudecode(1).  Deprecate the -p option
 (which allows one to redirect output to stdout); `-o /dev/stdout' is
 recommended instead.
 
 Submitted by:	Joseph Mallett <jmallett@xMach.org>
 MFC after:	2 weeks
 ----------------------------
 
 -- fuyuki
 
State-Changed-From-To: feedback->patched 
State-Changed-By: fanf 
State-Changed-When: Tue Sep 3 12:37:28 PDT 2002 
State-Changed-Why:  
Patch applied to -CURRENT. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=42356 
State-Changed-From-To: patched->closed 
State-Changed-By: tjr 
State-Changed-When: Tue Aug 24 09:20:41 GMT 2004 
State-Changed-Why:  
Fixed in -stable a long time ago. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=42356 
>Unformatted:
