Bug 42356 - uudecode -o doesn't work if piped
Summary: uudecode -o doesn't work if piped
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: 4.6.2-RELEASE
Hardware: Any Any
: Normal Affects Only Me
Assignee: freebsd-bugs (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2002-09-03 06:50 UTC by Kimura Fuyuki
Modified: 2004-08-24 10:21 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Kimura Fuyuki 2002-09-03 06:50:01 UTC
uudecode -o doesn't work if the output is piped to other programs.

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 -



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);
		}--tRhxagT6sE1F4yP2CVpm2N9ZDtmJzlkPrVQFEkuz3iUWSMaX
Content-Type: text/plain; name="file.diff"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename="file.diff"

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)
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
Comment 1 Juli Mallett freebsd_committer freebsd_triage 2002-09-03 07:10:48 UTC
* 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
Comment 2 Kimura Fuyuki 2002-09-03 09:28:40 UTC
> > 		} 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
Comment 3 Tony Finch 2002-09-03 10:55:51 UTC
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.
Comment 4 Tony Finch freebsd_committer freebsd_triage 2002-09-03 11:19:03 UTC
State Changed
From-To: open->feedback

Is the submitter happy with a manpage fix instead?
Comment 5 Kimura Fuyuki 2002-09-03 13:42:43 UTC
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
Comment 6 Tony Finch freebsd_committer freebsd_triage 2002-09-03 20:37:28 UTC
State Changed
From-To: feedback->patched

Patch applied to -CURRENT.
Comment 7 Tim Robbins freebsd_committer freebsd_triage 2004-08-24 10:20:41 UTC
State Changed
From-To: patched->closed

Fixed in -stable a long time ago.