Support #2091
Git repos with identifiers ending in "git" aren't being deleted
100%
Description
Oh boy, this is a long one...
Sob story:
When I delete a project, I also want to delete its repos from the filesystem, which I believe is the default behavior. But my Git repo wasn’t being deleted, so I decided to implement that in a post-delete
script. Except that the script apparently isn’t being run either. In both cases, Redmine shows no errors, and neither do Apache’s and Redmine’s logs. I checked that scm.yml
is being read, and that post_delete
is pointing to an existing, executable script. The script works fine when ran from the command line.
So I added a warning log in scm_creator.rb
's execute
method just before the system
call, and, with git_ext
set to false
, created and deleted two projects, named removetest
and testegit
. Redmine’s log shows:
for removetest: repo at /home/redmine/redmine-2.0.3-1/repositories/git/removetest
Started DELETE "/redmine/projects/removetest" for 10.18.130.33 at Fri Jul 06 16:01:46 -0300 2012 Processing by ProjectsController#destroy as HTML Parameters: {"commit"=>"Delete", "confirm"=>"1", "id"=>"removetest", "utf8"=>"â", "authenticity_token"=>"o7lzjTLzw2QoOzbj6bdSEuGdXFAeDvjzycAocWTXfR0="} Running /home/redmine/redmine-2.0.3-1/repositories/scripts/pre-delete.sh with /home/redmine/redmine-2.0.3-1/repositories/git/removetest, git, removetest Running /home/redmine/redmine-2.0.3-1/repositories/scripts/post-delete.sh with /home/redmine/redmine-2.0.3-1/repositories/git/removetest, git, removetest Redirected to http://forge:8080/redmine/admin/projects Completed 302 Found in 205ms (ActiveRecord: 134.8ms)
for testegit: repo at /home/redmine/redmine-2.0.3-1/repositories/git/testegit
Started DELETE "/redmine/projects/testegit" for 10.18.130.33 at Fri Jul 06 15:50:44 -0300 2012 Processing by ProjectsController#destroy as HTML Parameters: {"commit"=>"Delete", "confirm"=>"1", "id"=>"testegit", "utf8"=>"â", "authenticity_token"=>"o7lzjTLzw2QoOzbj6bdSEuGdXFAeDvjzycAocWTXfR0="} Running /home/redmine/redmine-2.0.3-1/repositories/scripts/pre-delete.sh with /home/redmine/redmine-2.0.3-1/repositories/git/test, git, testegit Running /home/redmine/redmine-2.0.3-1/repositories/scripts/post-delete.sh with /home/redmine/redmine-2.0.3-1/repositories/git/test, git, testegit Redirected to http://forge:8080/redmine/admin/projects Completed 302 Found in 241ms (ActiveRecord: 153.2ms)
With git_ext
set to true
, deleting a project named testegit
(repo at /home/redmine/redmine-2.0.3-1/repositories/git/testegit.git
) yields:
Started DELETE "/redmine/projects/testegit" for 10.18.130.33 at Fri Jul 06 15:45:38 -0300 2012 Processing by ProjectsController#destroy as HTML Parameters: {"confirm"=>"1", "utf8"=>"â", "commit"=>"Delete", "authenticity_token"=>"o7lzjTLzw2QoOzbj6bdSEuGdXFAeDvjzycAocWTXfR0=", "id"=>"testegit"} Running /home/redmine/redmine-2.0.3-1/repositories/scripts/pre-delete.sh with /home/redmine/redmine-2.0.3-1/repositories/git/testegit, git, testegit Running /home/redmine/redmine-2.0.3-1/repositories/scripts/post-delete.sh with /home/redmine/redmine-2.0.3-1/repositories/git/testegit, git, testegit Redirected to http://forge:8080/redmine/admin/projects Completed 302 Found in 229ms (ActiveRecord: 138.8ms)
Note that the SCM_REPO_PATH the script receives is missing the last 4 characters, and that the repos are created correctly, so the The *-create
scripts work just fine, this happens only with the *-delete
scripts.
Ideally a delete script wouldn’t be necessary at all, and I haven’t found out why it apparently isn’t being run, but this does look like an attempt to remove an ending ".git” gone awry.
Associated revisions
Using default_path to fetch full path when removing (should fix #2091) and added Korean translation (thanks Jaebok Oh!)
History
#1 Updated by Humberto Anjos over 12 years ago
A slightly unrelated question: where is the script’s output logged?
#2 Updated by Andriy Lesyuk over 12 years ago
- Status changed from New to Open
- Assignee set to Andriy Lesyuk
#3 Updated by Andriy Lesyuk over 12 years ago
A slightly unrelated question: where is the script’s output logged?
It is not logged...
#4 Updated by Andriy Lesyuk over 12 years ago
Please try code from SVN if you can.
#5 Updated by Andriy Lesyuk over 12 years ago
- Status changed from Open to In Progress
- % Done changed from 0 to 100
#6 Updated by Humberto Anjos over 12 years ago
It is not logged...
Not even in Apache’s logs? If I’m not mistaken, SCM Creator v0.3 wrote the output there...
Please try code from SVN if you can.
Tomorrow
#7 Updated by Humberto Anjos over 12 years ago
Please try code from SVN if you can.
Victory! Well, almost
Git repos still aren’t being deleted on their own (neither are Subversion repos, now that I looked at it), but the post-delete script is getting the right arguments, so there’s a workaround for now. Thanks!
#8 Updated by Andriy Lesyuk over 12 years ago
Cool! Thanks! Check also this page for removing issues...
#9 Updated by Humberto Anjos over 12 years ago
Cool! Thanks! Check also this page for removing issues...
WARNING: You must ensure that ALL parent directories cannot be moved by other untrusted users. For example, parent
directories should not be owned by untrusted users, and should not be world writable except when the sticky bit set.
I’m not a sysadmin, so that “sticky bit set” part lost me... The directories were created and are being used by the same user running Redmine (called redmine
, rather unimaginatively). The permissions are set to 0777; yes, more than they should be, but I encountered some problems earlier (can’t recall which, unfortunately) which made me change. What permissions should they be?
#10 Updated by Andriy Lesyuk over 12 years ago
I’m not a sysadmin, so that “sticky bit set” part lost me... The directories were created and are being used by the same user running Redmine (called
redmine
, rather unimaginatively). The permissions are set to 0777; yes, more than they should be, but I encountered some problems earlier (can’t recall which, unfortunately) which made me change. What permissions should they be?
Oops... Seems I forgot to answer... They should be 755
! It can happen that users under which Redmine is running and which actually creates files are different. All repos should be own by that another user! If it’s redmine
- 755
should work fine!
#11 Updated by Andriy Lesyuk over 12 years ago
- Tracker changed from Bug to Support
- Due date set to 22 Jul 2012
- Status changed from In Progress to Closed