From blank@uni-trier.de  Fri Jan 14 00:39:34 2000
Return-Path: <blank@uni-trier.de>
Received: from hawaii.uni-trier.de (hawaii.uni-trier.de [136.199.8.223])
	by hub.freebsd.org (Postfix) with ESMTP id 9A9D515182
	for <FreeBSD-gnats-submit@freebsd.org>; Fri, 14 Jan 2000 00:39:33 -0800 (PST)
	(envelope-from blank@uni-trier.de)
Received: from blank.uni-trier.de (rzppp-67.uni-trier.de [136.199.4.67])
	by hawaii.uni-trier.de (8.9.3+Sun/8.9.3) with ESMTP id JAA09691
	for <FreeBSD-gnats-submit@freebsd.org>; Fri, 14 Jan 2000 09:39:30 +0100 (MET)
Received: (from blank@localhost)
	by blank.uni-trier.de (8.9.3/8.9.3) id TAA01645;
	Thu, 13 Jan 2000 19:53:19 +0100 (CET)
	(envelope-from blank)
Message-Id: <200001131853.TAA01645@blank.uni-trier.de>
Date: Thu, 13 Jan 2000 19:53:19 +0100 (CET)
From: blank@uni-trier.de (Sascha Blank)
Reply-To: blank@uni-trier.de (Sascha Blank)
To: FreeBSD-gnats-submit@freebsd.org
Subject: ctm_rmail does not honor umask
X-Send-Pr-Version: 3.2

>Number:         16119
>Category:       bin
>Synopsis:       ctm_rmail does not honor umask
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    iedowse
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Fri Jan 14 00:40:00 PST 2000
>Closed-Date:    Mon Aug 26 11:59:49 PDT 2002
>Last-Modified:  Mon Aug 26 11:59:49 PDT 2002
>Originator:     Sascha Blank
>Release:        FreeBSD 3.4-STABLE i386
>Organization:
>Environment:

A FreeBSD 3.4-STABLE (i386) system current as of Jan 12th 2000.

>Description:

When you feed a CTM delta into ctm_rmail the file that it produces has the
permission 0600 no matter what your umask is set to.  While this is of little
concern for most users it will definatively get you into trouble when you want
to make these deltas available over nfs or ftp (like I do on ctm.freebsd.org).

Important note: This problem report applies to 4.0-CURRENT as well.

>How-To-Repeat:

Simply feed a CTM delta into ctm_rmail and look at the permission of the
produced file.

>Fix:

The following small fix explicitly changes the permission to what the
user expects while taking the current umask into account.  Nothing
fancy, but it works.


*** ctm_rmail.c.orig	Tue Jul 28 00:26:25 1998
--- ctm_rmail.c	Thu Jan 13 19:27:40 2000
***************
*** 31,36 ****
--- 31,37 ----
  int delete_after = 0;		/* Delete deltas after ctm applies them. */
  int apply_verbose = 0;		/* Run with '-v' */
  int set_time = 0;		/* Set the time of the files that is changed. */
+ int mask = 0;			/* The current umask */
  
  void apply_complete(void);
  int read_piece(char *input_file);
***************
*** 60,65 ****
--- 61,69 ----
      int status = 0;
      int fork_ctm = 0;
  
+     mask = umask(0);
+     umask(mask);
+ 
      err_prog_name(argv[0]);
  
      OPTIONS("[-Dfuv] [-p piecedir] [-d deltadir] [-b basedir] [-l log] [file ...]")
***************
*** 442,447 ****
--- 446,452 ----
  	mk_piece_name(pname, delta, 1, 1);
  	if (rename(pname, dname) == 0)
  	    {
+ 	    chmod(dname, 0666 & ~mask);
  	    err("%s complete", delta);
  	    return 1;
  	    }
***************
*** 552,557 ****
--- 557,563 ----
  	unlink(tname);
  	return 0;
  	}
+     chmod(dname, 0666 & ~mask);
  
      /*
       * Throw the pieces away.

>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->suspended 
State-Changed-By: iedowse 
State-Changed-When: Tue Jan 22 14:55:13 PST 2002 
State-Changed-Why:  

Committed, thanks! 

http://www.FreeBSD.org/cgi/query-pr.cgi?pr=16119 
Responsible-Changed-From-To: freebsd-bugs->iedowse 
Responsible-Changed-By: iedowse 
Responsible-Changed-When: Tue Jan 22 14:55:42 PST 2002 
Responsible-Changed-Why:  
MFC reminder. 

http://www.FreeBSD.org/cgi/query-pr.cgi?pr=16119 
State-Changed-From-To: suspended->closed 
State-Changed-By: iedowse 
State-Changed-When: Mon Aug 26 11:59:03 PDT 2002 
State-Changed-Why:  

Now fixed in -STABLE too. 

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