Ticket #29 (closed enhancement: fixed)

Opened 5 years ago

Last modified 5 years ago

source steps should 'chmod -R u+w' before deleting old directory

Reported by: warner Owned by: warner
Priority: minor Milestone: 0.7.6
Version: Keywords:
Cc:

Description

Every once in a while, a source tree gets some files set to u-w (either due to an interrupted checkout, or test cases that fiddle with permissions as they run and then fail to set them back again). When a Source step with mode=clobber or mode=copy tries to delete these files, it gets an exception.

The Source step should do a 'chmod -R u+w workdir' before trying to delete the tree, to avoid this problem.

Change History

comment:1 Changed 5 years ago by ashcrow

Here is a patch (not fully tested, just unit tested locally) that should change permissions to 0700 on each file before removing to ensure that it can remove the file instead of assuming that it is possible. I did 0700 instead of 0600 since 0600 directories can not be removed:

[steve@greatjob slave]$ mkdir test
[steve@greatjob slave]$ chmod 0600 test/
[steve@greatjob slave]$ rm -rf test/
rm: cannot chdir from `.' to `test/': Permission denied
[steve@greatjob slave]$ chmod 0700 test/
[steve@greatjob slave]$ rm -rf test/
[steve@greatjob slave]$ 
[steve@greatjob slave]$ cvs diff commands.py
Index: commands.py
===================================================================
RCS file: /cvsroot/buildbot/buildbot/buildbot/slave/commands.py,v
retrieving revision 1.80
diff -r1.80 commands.py
67a68,70
>     
>     # Verify the directory is read/write/execute for the current user
>     os.chmod(dir, 0700)
76c79,84
<         if os.path.isdir(full_name):
---
> 
>         if os.path.isdir(full_name): 
>             # Ensure permissions on removing
>             for filename in os.listdir(full_name):
>                 file_to_chmod = os.path.join(full_name, filename)
>                 os.chmod(file_to_chmod, 0700)

comment:2 Changed 5 years ago by warner

  • Status changed from new to closed
  • Resolution set to fixed

I've committed a modified form of this patch: rather than looking in the child and chmoding everything there before entering, I just chmod the directory upon entry and the file just before deletion. I wrote up a unit test that seems to cover everything.

closing this one out. thanks for the patch!

Note: See TracTickets for help on using tickets.