Subject: Re: error with strip and install
To: Gord Matzigkeit <gord@enci.ucalgary.ca>
From: Chris G Demetriou <Chris_G_Demetriou@BALVENIE.PDL.CS.CMU.EDU>
List: port-pmax
Date: 12/13/1995 16:50:22
[ J.T.: i've cc'd you on this because i mentioned it to you a while
  ago, and dunno if you're on the pmax list... ]

> I've found a problem using the 1.1 install with the -s option--it
> ignores permissions given on the command line.
> 
> Here is the example:
> 
> b22# install -c -o gord -g bin -m 4555 login login.new
> b22# ls -l login.new
> -r-sr-xr-x  1 gord  bin  721800 Dec 13 14:07 login.new
> b22# install -s -c -o gord -g bin -m 4555 login login.new
> b22# ls -l login.new
> -rw-------  1 root  wheel  481600 Dec 13 14:08 login.new
> b22#
> 
> The second command does indeed strip the binary, but it also ignores
> the ownership and permission flags.
> 
> Is there a fix available, or should I go snooping through source code?

I ran into this on the Alpha...


This is a bug in NetBSD's install program.  'install' assumes that
strip strips the binary in place, i.e. that if 'install' has a file
descriptor for the file to be stripped, the file descriptor will be
valid after 'strip' has run.

This is not the case with GNU strip.

There are several ways to fix this.  The best is to fix install, so
that it doesn't make that (inappropriate) assumption.

The other is to hack GNU strip (actually, binutils/objcopy.c in the
pmax toolchain sources) so that the NetBSD install program works.
I've included a diff to do that below, but i note that this is _not_
as good a fix as the one mentioned above.



chris
=============
Index: binutils/objcopy.c
===================================================================
RCS file: /usr/users/cgd/NetBSD/cvs/src/cygnus/binutils/objcopy.c,v
retrieving revision 1.1.1.2
retrieving revision 1.2
diff -c -C10 -r1.1.1.2 -r1.2
*** 1.1.1.2	1995/08/19 02:01:56
--- 1.2	1995/10/12 06:19:00
***************
*** 1332,1351 ****
--- 1332,1352 ----
     Assumes that TO already exists, because FROM is a temp file.
     Return 0 if ok, -1 if error.  */
  
  static int
  smart_rename (from, to)
       char *from, *to;
  {
    struct stat s;
    int ret = 0;
  
+ #ifndef __NetBSD__
    if (lstat (to, &s))
      return -1;
  
    /* Use rename only if TO is not a symbolic link and has
       only one hard link.  */
    if (!S_ISLNK (s.st_mode) && s.st_nlink == 1)
      {
        ret = rename (from, to);
        if (ret == 0)
  	{
***************
*** 1357,1376 ****
--- 1358,1378 ----
  	{
  	  /* We have to clean up here. */
  	  int saved = errno;
  	  fprintf (stderr, "%s: %s: ", program_name, to);
  	  errno = saved;
  	  perror ("rename");
  	  unlink (from);
  	}
      }
    else
+ #endif /* __NetBSD__ */
      {
        ret = simple_copy (from, to);
        if (ret != 0)
  	{
  	  int saved = errno;
  	  fprintf (stderr, "%s: %s: ", program_name, to);
  	  errno = saved;
  	  perror ("simple_copy");
  	}
        unlink (from);