bug-binutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: strip ignores permissions


From: Nick Clifton
Subject: Re: strip ignores permissions
Date: Wed, 26 Nov 2003 18:18:00 +0000
User-agent: Gnus/5.1001 (Gnus v5.10.1) Emacs/21.2 (gnu/linux)

Hi Dan,

> Gentlemen, your strip(1) program ignores permissions!
> $ ls -l readerLite.dat
> -rw-r--r--    1 jidanni  jidanni    408128 2003-07-30 18:13 readerLite.dat
> $ chmod 555 readerLite.dat
> $ strip readerLite.dat
> $ ls -l readerLite.dat
> -r-xr-xr-x    1 jidanni  jidanni    319456 2003-11-20 08:02 readerLite.dat

Indeed.  Please try applying the following patch and let me know of
you have any problems with it.

Cheers
        Nick

2003-11-26  Nick Clifton  <address@hidden>

        * rename.c (smart_rename): Make sure that we have write
        permission on the destination file before renaming.

Index: binutils/rename.c
===================================================================
RCS file: /cvs/src/src/binutils/rename.c,v
retrieving revision 1.7
diff -c -3 -p -r1.7 rename.c
*** binutils/rename.c   14 Sep 2003 12:20:16 -0000      1.7
--- binutils/rename.c   26 Nov 2003 18:18:45 -0000
*************** smart_rename (const char *from, const ch
*** 159,172 ****
    if (ret != 0)
      {
        /* We have to clean up here.  */
! 
!       non_fatal (_("%s: rename: %s"), to, strerror (errno));
        unlink (from);
      }
  #else
    /* Use rename only if TO is not a symbolic link and has
!      only one hard link.  */
!   if (! exists || (!S_ISLNK (s.st_mode) && s.st_nlink == 1))
      {
        ret = rename (from, to);
        if (ret == 0)
--- 159,176 ----
    if (ret != 0)
      {
        /* We have to clean up here.  */
!       non_fatal (_("unable to rename '%s' reason: %s"), to, strerror (errno));
        unlink (from);
      }
  #else
    /* Use rename only if TO is not a symbolic link and has
!      only one hard link, and we have permission to write to it.  */
!   if (! exists
!       || (!S_ISLNK (s.st_mode)
!         && S_ISREG (s.st_mode)
!         && (s.st_mode & S_IWUSR)
!         && s.st_nlink == 1)
!       )
      {
        ret = rename (from, to);
        if (ret == 0)
*************** smart_rename (const char *from, const ch
*** 193,199 ****
        else
        {
          /* We have to clean up here.  */
!         non_fatal (_("%s: rename: %s"), to, strerror (errno));
          unlink (from);
        }
      }
--- 197,203 ----
        else
        {
          /* We have to clean up here.  */
!         non_fatal (_("unable to rename '%s' reason: %s"), to, strerror 
(errno));
          unlink (from);
        }
      }
*************** smart_rename (const char *from, const ch
*** 201,207 ****
      {
        ret = simple_copy (from, to);
        if (ret != 0)
!       non_fatal (_("%s: simple_copy: %s"), to, strerror (errno));
  
        if (preserve_dates)
        set_times (to, &s);
--- 205,211 ----
      {
        ret = simple_copy (from, to);
        if (ret != 0)
!       non_fatal (_("unable to copy file '%s' reason: %s"), to, strerror 
(errno));
  
        if (preserve_dates)
        set_times (to, &s);
        





reply via email to

[Prev in Thread] Current Thread [Next in Thread]