Subject: pkg/17967: umask 027 breaks misc/openoffice-0.0.0.641nb1 build
To: None <gnats-bugs@gnats.netbsd.org>
From: None <apb@cequrux.com>
List: netbsd-bugs
Date: 08/17/2002 17:52:36
>Number:         17967
>Category:       pkg
>Synopsis:       umask 027 breaks misc/openoffice-0.0.0.641nb1 build
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    pkg-manager
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sat Aug 17 08:55:00 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator:     Alan Barrett
>Release:        NetBSD 1.6F
>Organization:
Not much
>Environment:
Architecture: i386
pkgsrc/misc/openoffice Makefile revision 1.21
>Description:
The ../solenv/bin/deliver.pl script which is used during the
openoffice build handles the umask incorrectly.

There seem to be at least three bugs:

1) The default umask is set to 22 (decimal) instead of 022 (octal).

2) The test for whether a file is executable (and hence whether to chmod
   it to 0777 modified by the umask, or to 0666 modified by the umask)
   is broken.  It tests the world execute bit ($mode%2 == 1), whereas it
   should test the user execute bit (($mode & 0100) != 0), or perhaps
   test for any execute bits (($mode & 0111) != 0).

3) Operations that use a umask to modify a mode use subtraction (e.g.
   (0666 - $umask)), whereas they should use bitwise masking (e.g.
   (0666 & ~ $umask)).

>How-To-Repeat:
sh% cd /usr/pkgsrc/misc/openoffice
sh% make show-var VARNAME=PKGNAME
openoffice-0.0.0.641nb1
sh% umask 027
sh% make

Observe that the build fails, and that the following error message
appears close to the end of the make output:

/usr/pkgsrc/misc/openoffice/work/oo_641_src/solver/641/unxbsdi.pro/bin/javadep: Permission denied.

Observe that all the files in the .../oo_641_src/solver/641/unxbsdi.pro/bin
directory have weird permissions.

>Fix:
Add the following patch to the long list of patches for the
misc/openoffice-0.0.0.641 package.  I don't yet know whether this patch
is sufficient to make openoffice build for me, but it certainly helps.

--- ../solenv/bin/deliver.pl.orig	Tue Jun 12 10:55:05 2001
+++ ../solenv/bin/deliver.pl
@@ -102,7 +102,7 @@ $is_debug           = 0;
 $module             = 0;            # module name
 $base_dir           = 0;            # path to module base directory
 $dlst_file          = 0;            # path to d.lst
-$umask              = 22;           # default file/directory creation mask 
+$umask              = 022;          # default file/directory creation mask 
 $dest               = 0;            # optional destination path
 
 @action_data        = ();           # LoL with all action data
@@ -245,7 +245,7 @@ sub do_mkdir {
         print "MKDIR: $path\n";
     }
     else {
-        mkpath($path, 0, 0777-$umask); 
+        mkpath($path, 0, 0777 & ~ $umask); 
     }
 }
 
@@ -285,7 +285,7 @@ sub init_globals {
 
     $umask = umask();
     if ( !defined($umask) ) {
-        $umask = 22;
+        $umask = 022;
     }
 
     $common_outdir  = $ENV{COMMON_OUTDIR};
@@ -534,12 +534,12 @@ sub is_newer {
 sub fix_file_permissions {
     my $mode = shift;
     my $file = shift;
     
-    if ( $mode%2 == 1 ) {
-        $mode = 0777 - $umask;
+    if ( ($mode & 0111) != 0 ) { # any execute bits?
+        $mode = 0777 & ~ $umask;
     }
     else {
-        $mode = 0666 - $umask;
+        $mode = 0666 & ~ $umask;
     }
     chmod($mode, $file);
 }

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