From walter.pelissero@iesy.net  Wed Dec 21 20:22:59 2011
Return-Path: <walter.pelissero@iesy.net>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 1973B1065672
	for <FreeBSD-gnats-submit@freebsd.org>; Wed, 21 Dec 2011 20:22:59 +0000 (UTC)
	(envelope-from walter.pelissero@iesy.net)
Received: from mail01.ish.de (mailout.ish.de [80.69.98.253])
	by mx1.freebsd.org (Postfix) with ESMTP id 6D1868FC14
	for <FreeBSD-gnats-submit@freebsd.org>; Wed, 21 Dec 2011 20:22:57 +0000 (UTC)
Received: from [94.79.129.6] (account walter.pelissero@iesy.net HELO scylla.home.lan)
  by mail-fe-01.mail01.ish.de (CommuniGate Pro SMTP 5.3.13)
  with ESMTPSA id 538584922 for FreeBSD-gnats-submit@freebsd.org; Wed, 21 Dec 2011 21:12:55 +0100
Received: from scylla.home.lan (localhost [127.0.0.1])
	by scylla.home.lan (8.14.5/8.14.5) with ESMTP id pBLKCr2K017122
	for <FreeBSD-gnats-submit@freebsd.org>; Wed, 21 Dec 2011 21:12:53 +0100 (CET)
	(envelope-from wcp@scylla.home.lan)
Received: (from wcp@localhost)
	by scylla.home.lan (8.14.5/8.14.5/Submit) id pBLK9e6h016976;
	Wed, 21 Dec 2011 21:09:40 +0100 (CET)
	(envelope-from wcp)
Message-Id: <201112212009.pBLK9e6h016976@scylla.home.lan>
Date: Wed, 21 Dec 2011 21:09:40 +0100 (CET)
From: "Walter C. Pelissero" <walter.pelissero@iesy.net>
Reply-To: walter@pelissero.de
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: b64encode/uuencode create files with no permissions
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         163515
>Category:       bin
>Synopsis:       [patch] b64encode(1)/uuencode(1) create files with no permissions
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Wed Dec 21 20:30:09 UTC 2011
>Closed-Date:    
>Last-Modified:  Fri Dec 23 13:55:35 UTC 2011
>Originator:     Walter C. Pelissero
>Release:        FreeBSD 8.2-STABLE amd64
>Organization:
>Environment:
System: FreeBSD scylla.home.lan 8.2-STABLE FreeBSD 8.2-STABLE #0: Wed Nov 30 12:39:31 CET 2011 root@scylla.home.lan:/usr/obj/usr/src/sys/GA870AUD3 amd64


	
>Description:
	b64encode when called with just one argument (input from
	stdin), but specifying an output file with the -o option,
	creates the file with mode 000 (that is, none is allowed to do
	anything with it).  Same behaviour is assumed from uuencode,
	being the same executable.
>How-To-Repeat:
	b64encode -o file.encoded file < /dev/null
>Fix:
	Apply the following patch:

Index: uuencode.c
===================================================================
RCS file: /repos/src/usr.bin/uuencode/uuencode.c,v
retrieving revision 1.18.30.1
diff -c -r1.18.30.1 uuencode.c
*** uuencode.c	3 Aug 2009 08:13:06 -0000	1.18.30.1
--- uuencode.c	21 Dec 2011 19:55:49 -0000
***************
*** 110,118 ****
  		mode = sb.st_mode & RWX;
  		++argv;
  		break;
! 	case 1:
  #define	RW	(S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH)
! 		mode = RW & ~umask(RW);
  		break;
  	case 0:
  	default:
--- 110,121 ----
  		mode = sb.st_mode & RWX;
  		++argv;
  		break;
! 	case 1: {
  #define	RW	(S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH)
! 		int om = umask(0);
! 		mode = RW & ~om;
! 		umask(om);	/* restore the umask */
! 	}
  		break;
  	case 0:
  	default:

>Release-Note:
>Audit-Trail:
>Unformatted:
